Reply to comment
Linux File Permissions
How to change file permissions in a terminal is something most Ubuntu users will want to know how to do.
There's really not very much to it. The terminal is the most efficient way of handling such tasks, and very little knowledge is needed to accomplish the feat.
Common file permission settings, numerical values and their meanings:
File permissions can be checked in a terminal by typing: ls -l (optionally adding the path/to/the/file and/or just the name of the file at the end of the command, ie: ls -l /home/yourusername/name-of-file if the file is in your home directory).
- -rw------- (600) — The owner has read and write permissions.
- -rw-r--r-- (644) — The owner has read and write permissions; the group and others read only.
- -rwx------ (700) — The owner has read, write and execute permissions.
- -rwxr-xr-x (755) — The owner has read, write and execute permissions; the group and others read and execute.
- -rwx--x--x (711) — The owner has read, write and execute permissions; the group and others execute.
- -rw-rw-rw- (666) — Everyone can read and write to the file.
- -rwxrwxrwx (777) — Everyone can read, write and execute.
Permission changes can easily be made from the command-line with chmod.
For example, changing a file's permissions from 666, (readable and writable, by owner, the group, and others), to 644, (read and write for owner, and read only for the group and others) would be: chmod 644 name-of-file.
Changing permissions of folders works the same way, except that one might add an argument such as chmod -R 644 name-of-directory, (-R means "recursively"), if one wanted the folder's permissions to apply to the files within it.
The first number always refers to the owner, the second to the group, and the third to others.
There are other permissions, but these cover the vast majority of file permissions you'll encounter in your daily use of your Linux OS.
Typing man chmod in a terminal window will bring up CHMOD's man page which lists all the arguments and options available for the command.
The numerical values are arrived at by simple addition/subtraction:
- r (read) = 4
- w (write> = 2
- x (execute) = 1
- - (none) = 0
So for Read and Write permission it would be 4 + 2 giving a value of 6, Read and Write and Execute would be 4 + 2 + 1 which equals a value of 7.