O'Reilly logo

Linux Pocket Guide, 2nd Edition by Daniel J. Barrett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

chown — stdin  stdout  - file  -- opt  --help  --version

Synopsis

chown [options] user_spec files

The chown (change owner) command sets the ownership of files and directories. To make user smith the owner of several files and a directory, run:

# chown smith myfile myfile2 mydir

The user_spec parameter may be any of these possibilities:

  • A username (or numeric user ID), to set the owner: chown smith myfile

  • A username (or numeric user ID), optionally followed by a colon and a group name (or numeric group ID), to set the owner and group: chown smith:users myfile

  • A username (or numeric user ID) followed by a colon, to set the owner and to set the group to the invoking user’s login group: chown smith: myfile

  • A group name (or numeric group ID) preceded by a colon, to set the group only: chown :users myfile

  • --reference= file to set the same owner and group as another given file

Useful options

--dereference

Follow symbolic links and operate on the files they point to.

-R

Recursively change the ownership within a directory hierarchy.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required