File and directory permissions can only be modified by their owners, or by the superuser (root),by using the chmod system utility.
• chmod (change [file or directory] mode)
$ chmod options files
chmod accepts options in two forms. Firstly, permissions may be specified as a sequence of 3 octal digits (octal is like decimal except that the digit range is 0 to 7 instead of 0 to 9). Each octal digit represents the access permissions for the user/owner, group and others respectively. The mappings of permissions onto their corresponding octal digits is as follows:
$ chmod 600 private.txt
sets the permissions on private.txt to rw------- (i.e. only the owner can read and write to the file). Permissions may be specified symbolically, using the symbols u (user), g (group), o (other), a (all), r (read), w (write), x (execute), + (add permission), – (take away permission) and = (assign permission).
For example, the command:
$ chmod ug=rw,o-rw,a-x *.txt
sets the permissions on all files ending in *.txt to rw-rw---- (i.e. the owner and users in the file's group can read and write to the file, while the general public do not have any sort of access).chmod also supports a -R option which can be used to recursively modify file permissions, e.g.
$ chmod -R go+r play
will grant group and other read rights to the directory play and all of the files and directories within play.
• chgrp (change group)
$ chgrp group files
can be used to change the group that a file or directory belongs to. It also supports a -R option.
With proper syntax explain the use of chmod command.
Reviewed by enakta13
on
November 11, 2012
Rating: