Linux Permissions

Commands

Command Affects Description
chown files & directories change owner or group or default group
chmod files & directories change permissions
umask files & directories change default permissions

Permissions

x Read Write Execute
file can read file can write file can execute file
directory can list the contents of the directory can create files inside the directory can step into the directory

chown

Notations

Octal

1
chmod 775 file

Verbose

1
chmod u+rw file

Special bits

Bit Affects Description Octal command Verbose command
setUID files execute the file as the owner of the file chmod 2755 file chmod u+s file
setGID directories newly created files inherit the group of the parent folders group chmod 4755 directory chmod g+s directory

umask

Changes the default permissions for a session.

1
umask # 0002

On Ubuntu 16.04.
The default umask is 0002.
The default file permissions are 0666.
The default directory permissions are 0777.

The default umask is subtracted from the default octal value of the file or directory.

file

0666
0002
0664

Newly created file permissions are 0664 by default.
This can be seen from a file being created having -rw-rw-r– permissions.

directory

0777
0002
0775

Newly created directory permissions are 0775 by default.
This can be seen from a directory being created having drwxrwxr-x permissions.

You can change the umask value for a session.

1
2
3
4
5
touch file
ls file # -rw-rw-r--
umask 0007
touch file2
ls file2 # -rw-rw----

Advanced

If you need more fine control you can use acl.