linux_file_permissions.md 2.43 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+++
title = "Linux File Permissions"
description = "How to view and change file permissions with Linux commands"
weight = 20
+++

- [Opening a Terminal Window] (#opening-a-terminal-window)
- [Listing File Permissions] (#listing-file-permissions)
- [Changing File Permissions] (#changing-file-permissions)

## Opening a Terminal Window
-----------------------

Use your local terminal to connect to a cluster, or open a new terminal window on [Crane](https://crane.unl.edu). 

Adam Caprez's avatar
Adam Caprez committed
16
Click [here](https://hcc.unl.edu/docs/Quickstarts/connecting/) if you need help connecting to a cluster 
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
with a local terminal.
	
Click [here](https://hcc.unl.edu/docs/guides/running_applications/jupyter/) 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.

{{< figure src="/images/LinuxList.png" >}}  

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`

{{< figure src="/images/LinuxChange.png" >}}