Linux File Permissions

Opening a Terminal Window

Use your local terminal to connect to a cluster, or open a new terminal window on Swan.

Click here if you need help connecting to a cluster with a local terminal.

Click here if you need help opening a new terminal window within JupyterHub.

Listing File Permissions

Type the command ls -l to list the files and directories with file permissions for your current location.

The first character denotes whether an item is a file or a directory. If ’d’ is shown, it’s a directory, and if ‘-’ is shown, it’s a file. Following the first character you will see some combination of r,w,x, and -. The first rwx is the ‘read’ ‘write’ ‘execute’ file permissions for the creator of that file or directory. A ‘-‘ instead means a particular permission has not been granted. For example “rw-“ means the ‘execute’ permission has not been granted. The next three entries are the permissions for ‘group’ and the last three are the permissions for everyone else.

Following the file permissions are the name of the creator, the name of the group, the size of the file, the date it was created, and finally the name of the file.

Changing File Permissions

To change file permissions, use the command “chmod [permissions] [filename]” where permissions are indicated by a three-digit code. Each digit in the code correspondes to the three digits mentioned above in the permissions printout: One for the creater permissions, one for the group permissions, and one for everyone else. The command is interpreted as follows: 4=read 2=write 1=execute and any combination of these is given by summing their codes. Each chmod command will include 3 codes. For example, to give the creator of mars.txt rights to read, write and execute, the group rights to read and execute, and everone else only the right to read, we would use the command chmod 754 mars.txt