Changing Permissions with chmod (numbers)
Using numbers is another way to change permissions on a file. You only need to know what these numbers stand for. Read, Write and Execute permissions are each assigned a number. Read, or “r” is assigned 4, Write or “w” is assigned 2 and Execute or “x” is assigned 1. You would use each set’s total number to establish the permission.
READ – 4
WRITE – 2
EXECUTE – 1
To make permissions on a file “wide-open” for yourself as owner, you would set the first number to a 7. The number 7 is the total of READ, WRITE and EXECUTE (4+2+1=7). Then, to give the group READ access, the second number would be 4 (4+0+0=4). Then to give others READ only access, the third number would be 4 again (4+0+0=4). The permissions for that file would be “744”.
$ chmod 744 myfile.txt
You can use any combination of permissions from 0 (no permission) through 7 (full permission).
Examples:
Using chmod 777 on myfile.txt results in “rwx rwx rwx”
$ chmod 777 myfile.txt
Using chmod 755 on myfile.txt results in “rwx r-x r-x”
$ chmod 755 myfile.txt
Using chmod 644 on myfile.txt results in “rw- r- – r – -“
$ chmod 644 myfile.txt
Using chmod 000 on myfile.txt results in “— — —“
$ chmod 000 myfile.txt
The command can also be used recursively. To do this you would use the “-R” switch on the chmod command. By doing this you can change an entire directory as shown below:
$ chmod –R 775 /home/myfiles
All the files and directories below and including the myfiles directory will now have 755 permissions set.
1903 Wright Place, Suite 120
Carlsbad, CA 92008
Toll-Free (877) 633-7743
Email customercare@medsphere.com