Unix Permissions

3 minutes read

Within a directory, you can find out the file access rights by typing

ls -ls

The file access permissions is a combination of letters and hyphens. The letters and hyphens will make up 10 total symbols. The letters are d, r, w, x and occasionally s or S.

1
2
3
4
5
6
7
8
9
r - read

w - write

x- execute

d - indicates a directory

"-" - indicates a file

Either d or “-” will be present at the beginning if it is a folder or file respectively.

The 9 letters from the symbols indicate the permissions or the access rights and are taken as a group of three.

The left most group of 3 gives the file permissions for the user that owns the file (or directory). The right most group gives the permissions for all others. The middle three columns indicates the permission given to the group to which the user account belongs.

The letters of the symbol will carry different meanings depending if they are simple file or directory.

Files

1
2
3
4
r (or -) - indicates read permission or otherwise)
w (or -) indicates write permission (or otherwise)

x ( or -) indicates the exceute permission (or otherwise)

 

 

Folders

1
2
3
4
5
r - allow users to list files in the directory

w - allow users to delete files or move files into the directory

x - read files in the directory assuming you have the read right on the individual files.

For example

1
-rw-------

 

The above permission signifies a file that only the owner can read and write. No one else is allowed to read or write or execute it.

Changing access rights

Chmod refers to changing file mode. Only the owner of a file can use chmod to update file permissions. The following are the chmod symbols

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
u -user

g -group

o -other

a - all (everything including u, g, o)

r - read

w -write (and delete)

x -execute ( and acess directory)

+ - add permissions

"-" - take permission away

For example, the below command will add a read write permission to the file test.txt for group and others.

1
chmod go +rw test.txt

 

The below command will take away the read write permission for the file testing.txt for group and others.

1
chmod go -rw testing.txt

 

if we want to assign read, write permissions to the test file all instead, we can assign it using the command below

1
chmod a+rw test

Permissions as integers

The following integers represent the permissions applicable to files and directories.

1
2
3
4
5
6
7
1 - excecute

2 - write

4 - read

0 - clear permission

let’s take this numeric permission as an example

A permission 655 will indicate the following

6 = 4+2 – Indicating read and write

5 = 4 +1 – Indicating read and execute

We need to take the position of the numbers into account, so 655 represents ugo as each digit represents the permission for one of u, g and o. In the above example, the user has the read and write permissions, the group has the read and execute permissions and others also have the read and execute permissions.

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

Comments:

No comments

Related Posts:

In a Unix system, the two fundamental notion is that things are either a file or a process. A file is just a destination for or a source of a stream of data. A process on the other hand is a program that is currently running and this program may be associated ...
To convert a GMT date to Unix time in Golang, you can follow the steps below:First, you need to parse the GMT date string into a time.Time object using the time.Parse() function. The Parse() function takes two parameters: a layout string specifying the date fo...
Joomla ACL (Access Control List) is a powerful tool that allows you to control access to different parts of your website based on user roles. To use Joomla ACL effectively, you need to first understand the different user groups and permissions available in Joo...
If you are encountering common Joomla errors, there are a few steps you can take to try to fix them. One common issue is a blank white screen, which may be caused by a PHP error. To fix this, you can check the error logs for more information about what is caus...
To manage users on Bitbucket, you need to have the necessary administrative privileges. As an administrator, you can add new users to your repository, remove existing users, change user permissions, and manage user access to specific repositories. You can also...
Each Linux/Unix command has 3 communication channels: input, output and error. The output can be filtered and then redirected and by this way parts of it can be captured, depending on the needs. Redirecting the output to a file, using > or >>: > – ...