chmod--helpUsage:chmod [OPTION]... MODE[,MODE]... FILE...or:chmod [OPTION]... OCTAL-MODE FILE...or:chmod [OPTION]... --reference=RFILEFILE...ChangethemodeofeachFILEtoMODE.With--reference,changethemodeofeachFILEtothatofRFILE.-c,--changeslikeverbosebutreportonlywhenachangeismade-f,--silent,--quietsuppressmosterrormessages-v,--verboseoutputadiagnosticforeveryfileprocessed--no-preserve-rootdonottreat'/'specially (the default)--preserve-rootfailtooperaterecursivelyon'/' --reference=RFILEuseRFILE's mode instead of MODE values -R, --recursive change files and directories recursively --help display this help and exit --version output version information and exit Each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.
Symbolic Mode
ls-lfile1.txt-rw-rw-r--1useruser6set300:16file1.txt# Change the file1.txt permissions, by removing group write permissionschmodg-wfile.txt-rw-r--r--1useruser6set300:16file1.txt# Change permissions to allow only the owner to read the filechmoda=,u=rfile1.txt# No permissions for all users and read permissions for the owner-r--------1useruser6set300:16file1.txt
Numeric octal Mode
Octal number
Permissions
File listing
7 (4+2+1)
read, write and execute
rwx
6 (4+2+0)
read and write
rw-
5 (4+0+1)
read and execute
r-x
4 (4+0+0)
read only
r--
3 (0+2+1)
write and execute
-wx
2 (0+2+0)
write onyl
-w-
1 (0+0+1)
execute only
--x
0 (0+0+0)
none
---
stat-c"%a"file1.txt400# Assign read/write permissions to owner and group, read permissions to everyone elsechmod664file1.txt-rw-rw-r--1useruser6set300:16file1.txt
chown--helpUsage:chown [OPTION]... [OWNER][:[GROUP]] FILE...or:chown [OPTION]... --reference=RFILEFILE...Changetheownerand/orgroupofeachFILEtoOWNERand/orGROUP.With--reference,changetheownerandgroupofeachFILEtothoseofRFILE.-c,--changeslikeverbosebutreportonlywhenachangeismade-f,--silent,--quietsuppressmosterrormessages-v,--verboseoutputadiagnosticforeveryfileprocessed--dereferenceaffectthereferentofeachsymboliclink (this isthedefault), rather than the symbolic link itself-h,--no-dereferenceaffectsymboliclinksinsteadofanyreferencedfile (usefulonlyonsystemsthatcanchangetheownershipofasymlink) --from=CURRENT_OWNER:CURRENT_GROUPchangetheownerand/orgroupofeachfileonlyifitscurrentownerand/orgroupmatchthosespecifiedhere.Eithermaybeomitted,inwhichcaseamatchisnotrequiredfortheomittedattribute--no-preserve-rootdonottreat'/'specially (the default)--preserve-rootfailtooperaterecursivelyon'/' --reference=RFILEuseRFILE's owner and group rather than specifying OWNER:GROUP values -R, --recursive operate on files and directories recursively The following options modify how a hierarchy is traversed when the -R option is also specified. If more than one is specified, only the final one takes effect. -H if a command line argument is a symbolic link to a directory, traverse it -L traverse every symbolic link to a directory encountered -P do not traverse any symbolic links (default) --help display this help and exit --version output version information and exit Owner is unchanged if missing. Group is unchanged if missing, but changed to login group if implied by a ':' following a symbolic OWNER. OWNER and GROUP may be numeric as well as symbolic. Examples: chown root /u Change the owner of /u to "root". chown root:staff /u Likewise, but also change its group to "staff". chown -hR root /u Change the owner of /u and subfiles to "root".# Give file ownership to "root"sudo chown root file1.txt -rw-rw-r-- 1 root user 6 set 3 00:16 file1.txt# It can be used for group changing too with "root:root"