Linux permissions

The shared folders

The BiRD platform manages the shared folders under the directories:

  • /LAB-DATA/BiRD/shares/<folder>
  • /SCRATCH-BIRD/shares/<folder>

These folders are accessible upon request for each user with the agreement of the project manager.

Description of files and folder permissions

The files and folder permissions are managed by the owner of these files and folders. A linux file or folder always has an owner and a group. Use the "ls" command with "-l" argument to visualize the linux rights:

(base) [charpentier-e1@login-01 results]$ ls -lh
total 17G
-rw-rw---- 1 charpentier-e1 dge-seq  17G  3 mars   2020 2015_10_06_DGESeqrun1MiSeq.zip
drwxrws--- 1 charpentier-e1 dge-seq    4 23 août   2018 analyseBIRD_RUN10_human_solenne
drwxrws--- 1 charpentier-e1 dge-seq    4 23 août   2018 analyseBIRD_RUN11_human_solenne

Triplets of permissions are set for the owner, the group, and others:

  • the first letter is the type of file: "d" for directory, "-" for file
  • the first triplet are the permissions for the user (owner)
  • the second triplet are the permissions for the group
  • the third triplet are the permissions for the rest of the users of the server

The letter code for the triplets are

  • "r" for read
  • "w" for write
  • "x" or "s" for execute

Changing file permissions

These permissions can be changed with the "chmod" command

Octal representation

Octal Digit Binary Representation (rwx) Permission
4 100 read only
5 101 read and execute
6 110 read and write
7 111 read, write, and execute (full permissions)

User categories

symbol category Description
u user Owner of the file
g group Group of the file
o other All other users of the server

Using the chmod command

# set write permission for the group
chmod g+w <file>

# remove write permission for the group
chmod g-w <file>

# set read/write/execute for the user, read/execute permission for the group, and none for others
chmod 750 <folder>

# set read/write/execute permissions recursively for user and group
chmod -R 770 <folder>

Most commonly used commands to set permissions on folder and all subfolders/files

# find all sub-folders inside a folder and set read/write/execute for user and group
find <folder> -type d -exec chmod 770 {} \;

# find all files inside a folder recursively and set read/write for user and group
find <folder> -type f -exec chmod 660 {} \;

Notes

  • Replace <folder> or <file> with the real path of the folder/file you want to change permissions on.
  • Only the owner of the file/folder can change its permissions.
  • "x" permission on a folder is necessary to enter the directory (i.e., cd into it), and to access any of its files.

Links

Linux permission tutorial (french): https://linux.goffinet.org/administration/securite-locale/permissions-linux/

Linux permission tutorial (english): https://www.digitalocean.com/community/tutorials/an-introduction-to-linux-permissions

SO question on recursive permissions changing: https://stackoverflow.com/questions/19737525/find-type-f-exec-chmod-644

Ubuntu documentation for permissions: https://doc.ubuntu-fr.org/permissions