Most operating systems have a file permission system that controls access to files for different users. On systems with multiple users, permissions prevent malicious actions, like deleting each other’s files.
On Unix and Unix-like systems (including DTU’s HPC server), there are three types of users:
... and three types of permissions:
Each user on Unix systems belongs to at least one group but can belong to multiple groups. Each file has an owner and an associated group. Groups can be given specific permissions on a file.
Imagine you are leading a project. You want:
project.txt
.You can create a project-specific group, assign team members to it, and then set the file permissions accordingly: full rights for yourself, read-only for the group, and no access for others.
Groups provide a simple way to manage access for multiple users.
When you access databar/HPC via terminal, you can use the command id
. This will display your user id, id of your primary group and all groups you belong to.
You can use the same command with addition of the person's DTU login: id USERNAME
(replacing USERNAME with their DTU login).
You can easily check file permissions using the platform's file explorer (under the Data
menu), by hovering the file or folder and clicking the permissions button:
If you are in the folder with the file/folder of interest, you can use the command ll
or ls -l
.
This will list all the files and folders within that folder and corresponding information. We can see the file permission as the first sequence of dashes and characters.
First character is either d
(d stands for directory) telling us it is a folder or a -
telling us it is a file. In this case we see a textfile, thus it is -
.
Then three groups of three characters (triplets) follow: - First triplet: permissions for user. - Second triplet: permissions for group. - Third triplet: permissions for others.
Letters indicate permissions are granted; dashes mean they are not: - r: read - w: write - x: execute
Explanation:
rw-
: User can read and write, but not execute.r--
: Group can only read.r--
: Others can only read.You will also see the file owner and the file’s group.
You are only able to change file permissions if you are the owner of the file
The file explorer from the platform also allows you to change the file or folder permissions:
That is done using the command chmod
. Permissions are represented as numbers:
Those numbers are added together for each user type.
Let's see on example. First we display the permissions using ll
. We see reading and writing permissions for file owner and reading permissions for group and all. That would translate to a number 644. The first number represents permissions for file owner. We get 6 by adding up together 4 and 2. That means permissions for writting and reading.
Now we want to add writting permisions for group. We want to use the chmod
command to set it to 664.
For this purpose exists command chown
. The syntax to do that is following:
chown :GROUP FILE
You can not do that by yourself. You have contact us here