Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: chown command

  1. #1
    Join Date
    Nov 2019
    Beans
    11

    chown command

    In my Linux exam book the statement is made that chown can do the following but no syntax given:

    1. make new group
    2. change owner and group at the same time


    As an example:
    1. new group (lab) is created
    2. give the new group (lab) and an owner (xyz) access to the file (new-file).


    new group - lab
    add owner - xyz
    new-file (file name to receive new permissions)

    What is the chown command to do this ?

    Thanks

  2. #2
    Join Date
    Jun 2014
    Beans
    5,780

    Re: chown command

    There are countless web sites with detailed explanations of using the chown command such as the one below. An online search should provide you with all the information you need.

    https://linuxize.com/post/linux-chown-command/

  3. #3
    Join Date
    Jun 2019
    Location
    Dirndl-land
    Beans
    254
    Distro
    Lubuntu 19.10 Eoan Ermine

    Re: chown command

    Quote Originally Posted by skybird182 View Post
    In my Linux exam book the statement is made that chown can do the following but no syntax given:

    1. make new group
    2. change owner and group at the same time
    2. is correct, 1. is to my knowledge not correct.

    https://linux.die.net/man/1/chown

  4. #4
    Join Date
    Nov 2019
    Beans
    11

    Re: chown command

    I looked at websites to find an example before posting.

  5. #5
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    19,331
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: chown command

    If you want to learn this stuff, here's a reference: http://linuxcommand.org/tlcl.php
    It is a no-hassle download. Nothing to sign up to get. No email to provide. Grab the boot in your preferred language.

    Plus, every Unix system has local manpages. If you are going to work at the shell or CLI, you'll **NEED** to learn to use the manpages.

    Code:
    $ man chmod
    To search the tiny, 1-line summary for every command, use apropos
    Code:
    $ apropos chown
    This will return all the manpages with that term. Not all manpages are for commands. Some are for configuration files, so we often need to specify exactly which manpage section to be shown.
    On one of my systems,
    Code:
    $ apropos passwd
    chgpasswd (8)        - update group passwords in batch mode
    chpasswd (8)         - update passwords in batch mode
    fgetpwent_r (3)      - get passwd file entry reentrantly
    getpwent_r (3)       - get passwd file entry reentrantly
    gpasswd (1)          - administer /etc/group and /etc/gshadow
    grub-mkpasswd-pbkdf2 (1) - generate hashed password for GRUB
    mkpasswd (1)         - Overfeatured front end to crypt(3)
    mksmbpasswd (8)      - formats a /etc/passwd entry for a smbpasswd file
    pam_localuser (8)    - require users to be listed in /etc/passwd
    passwd (1)           - change user password
    passwd (1ssl)        - compute password hashes
    passwd (5)           - the password file
    passwd2des (3)       - RFS password encryption
    smbpasswd (5)        - The Samba encrypted password file
    smbpasswd (8)        - change a user's SMB password
    SSL_CTX_set_default_passwd_cb (3ssl) - set passwd callback for encrypted PEM file handling
    SSL_CTX_set_default_passwd_cb_userdata (3ssl) - set passwd callback for encrypted PEM file handling
    update-passwd (8)    - safely update /etc/passwd, /etc/shadow and /etc/group
    vnc4passwd (1)       - change a VNC password
    vncpasswd (1)        - change a VNC password
    There are 3 lines returned with just "passwd". It is handy to understand the passwd DB/config file organization. That is documented in section ... 5.
    If we use man passwd, then the first found section will be shown - section 1, for the command. To see section 5,
    Code:
    $ man -s 5 passwd
    Anyway, you'll need to learn to use manpages so there isn't any need to wait for someone on a forum to sorta answer the question, but not really answer it at all.

    It is against the rules to do someone's homework in these forums. We certainly won't answer test questions.

  6. #6
    Join Date
    Jun 2019
    Location
    Dirndl-land
    Beans
    254
    Distro
    Lubuntu 19.10 Eoan Ermine

    Re: chown command

    Normal syntax would be

    sudo chown [options] xyz:lab [file]. A typical option would be -R if [file] is a directory.

  7. #7
    Join Date
    Jun 2006
    Location
    UK
    Beans
    Hidden!
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: chown command

    Quote Originally Posted by skybird182 View Post
    What is the chown command to do this ?
    From the posting guidelines, which are part of the forum rules:

    While we are happy to serve as a resource for hints and for asking questions when you get stuck and need a little help, the Ubuntu Forums is not a homework service.
    Ubuntu 16.04 Desktop Guide - Ubuntu 18.04 Desktop Guide - Forum Guide to BBCode - Using BBCode code tags - IRC #ubuntuforums

    Member: Not Canonical Team

    Please do not PM me about your forum account unless you have been asked to. The correct place to contact an admin about your account is here.

  8. #8
    Join Date
    Nov 2019
    Beans
    11

    Re: chown command

    This is what I got when I tried the above command: new-file is a file

    Is an option missing ?

    sudo chown xyz:lab new-file
    chown: invalid user: ‘xyz:lab’

  9. #9
    Join Date
    Nov 2019
    Beans
    11

    Re: chown command

    This is very helpful. Thanks

  10. #10
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    19,331
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: chown command

    Quote Originally Posted by skybird182 View Post
    This is what I got when I tried the above command: new-file is a file

    Is an option missing ?

    sudo chown xyz:lab new-file
    chown: invalid user: ‘xyz:lab’
    xyz:lab is username:groupname
    Both must exist as shown in the command.

    BTW, xyz.lab is also an acceptable way to say username.groupname. Old Unix terminals didn't have a ':' character, so the '.' can be used.

    So, thefu:users or thefu:audio might be clearer examples.

    "new-file" must exist too. To create an empty file, use the 'touch' command.
    The book link provided above has a chapter on Unix permissions.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •