chown
Screenshot of the chown command manual
The chown command is used on Unix-like systems to change the owner of a file. In most implementations, it can only be executed by the Superuser. Unprivileged (regular) users who wish to change the group of a file that they own may use chgrp.
Usage
The general syntax for the chown command is:
chown [-R] [[user]][:group] target1 [[target2 ..]]
- The optional user parameter indicates the new user who should take ownership of the targets.
- The optional group parameter (which must be prefixed with a colon, :) indicates the group with which the targets should be associated.
- The target parameters indicate the files or directories for which the user and/or group will be changed.
- A widely supported option is -R which specifies a recursive change for any named target directory and files within.
- One of either user or group must be specified. The chown command will not execute properly without at least one of those parameters.
- The user and group parameters can be either symbolic names or identifiers (i.e. a User ID or Group ID).
Usage examples
- Note, these commands must be run as root
$ chown root /var/run/httpd.pid
- Change the owner of /var/run/httpd.pid to 'root' (the standard name for the Superuser).
$ chown rob:developers strace.log
- Change the owner of strace.log to 'rob' and the group identifier to 'developers'.
$ chown nobody:nobody /tmp /var/tmp
- Change the owner of /tmp and /var/tmp to ‘nobody’ (not a good idea)
- Change the group associated with the same targets to the group ‘nobody’ (conventionally the ‘nobody’ user's group)
$ chown :512 /home
- Change the group identifier of /home to 512 (regardless of whether a group name is associated with the identifier 512 or not).
$ chown -R us base
- Change the ownership of base to the user us and make it recursive (-R)
See also
External links
Unix command line programs and builtins (more) |
|
File system |
cat · cd · chmod · chown · chgrp · cksum · cmp · cp · du · df · file · fsck · fuser · ln · ls · lsattr · lsof · mkdir · mount · mv · pwd · rm · rmdir · split · touch
|
|
Processes |
at · chroot · cron · exit · kill · killall · nice · pgrep · pidof · pkill · ps · pstree · sleep · time · top · wait · watch
|
|
User environment |
env · finger · id · logname · mesg · passwd · su · sudo · uname · uptime · w · wall · who · whoami · write
|
|
Text processing |
awk · comm · cut · ed · ex · fmt · head · iconv · join · less · more · paste · sed · sort · tac · tail · tr · uniq · wc · xargs
|
|
Shell programming |
alias · basename · dirname · echo · expr · false · printf · test · true · unset
|
|
Networking |
inetd · netstat · ping · rlogin · netcat · traceroute
|
|
Searching |
find · grep · strings
|
|
Miscellaneous |
banner · bc · cal · clear · date · dd · lp · man · size · tee · tput · yes · umask
|
|