chown
CommandThe chown
command in Linux is used to change the ownership of files and directories.
chown [OPTION]... [OWNER][:[GROUP]] FILE...
-c, --changes
: like verbose but report only when a change is made-f, --silent, --quiet
: suppress most error messages-v, --verbose
: output a diagnostic for every file processed--dereference
: affect the referent of each symbolic link (this is the default), rather than the symbolic link itself-h, --no-dereference
: affect symbolic links instead of any referenced file (useful only on systems that can change the ownership of a symlink)Change the owner of a file:
chown newowner file.txt
Change the owner and group of a file:
chown newowner:newgroup file.txt
Change the owner of a directory and its contents recursively:
chown -R newowner directory/
Suppress error messages:
chown -f newowner file.txt