File Permission Linux
File Permission Linux
Permissions
specify what a particular person may or may not do with respect to a file or directory. As such,
permissions are important in creating a secure environment. For instance you don't want other
people to be changing your files and you also want system files to be safe from damage (either
accidental or deliberate). Luckily, permissions in a Linux system are quite easy to work with.
r – Read
w – Write
x – Execute
- No permission
Operators Definition
`+` Add permissions
`-` Remove permissions
`=` Set the permissions to the specified values
chmod ugo-rwx f1
The code above revokes all the read(r), write(w), and execute(x) permission from all user(u), group(g),
and others(o) for the file f1 which results in this.
chmod ug+rw,o-x f1
The code above adds read(r) and write(w) permission to both user(u) and group(g) and revoke
execute(x) permission from others(o) for the file f1
chmod ug=rx,o+r f1
assigns read(r) and execute(x) permission to both user(u) and group(g) and add read permission to
others for the file f1
Give the file’s owner read and write permissions and only read permissions to group members and all
other users:
Give the file’s owner read, write and execute permissions, read and execute permissions to group
members and no permissions to all other users:
Recursively set read, write, and execute permissions to the file owner and no permissions for all other
users on a given directory:
chmod -R 700 dirname
Read, write and execute permissions are set for directories as well as files. Read permission means
that the user may see the contents of a directory (e.g. use ls for this directory.) Write permission
means that a user may create files in the directory. Execute permission means that the user may
enter the directory (i.e. make it his current directory.)