English

User access on Linux

Linux privileges and permissions!

A man sitting on a coach and working with a keyboard on the knees
© This is not me but at least my keyboard is the same at the time😁! Photo is from microsoft collection.See reference here
0
31th Jan 2025

About this post

In the world of Unix operating systems, where users share resources on the same server, it is crucial to have a solid foundation and understanding of Linux user privileges, file and directory ownership, and access levels.

In this post, we'll learn about Linux permissions and how to configure privileges to secure our system.

Β 

Table of Contents

Linux Files and Directories

In Linux (like other Unix operating systems) everything is a file. Directories, files, and even devices are files (like the way that almost everything in Python is an object if you've experience in that).

Linux organizes these files in a hierarchical structure. In this tree-like structure, the highest file system level is for the root directory (the / directory). All other files and directories will be inside (under) the root directory.

└── /
β”œβ”€β”€ bin
β”œβ”€β”€ boot
β”œβ”€β”€ cdrom
β”œβ”€β”€ dev
β”œβ”€β”€ etc
β”œβ”€β”€ home
β”‚ β”œβ”€β”€ hosein
β”‚ β”‚ β”œβ”€β”€ Desktop
β”‚ β”‚ β”œβ”€β”€ Documents
β”‚ β”‚ β”œβ”€β”€ Download
β”‚ β”‚ ...
β”‚ └── guest
β”‚ β”œβ”€β”€ ...
β”‚ ...
β”œβ”€β”€ lib
...

User Groups on Linux

In real life, if you gather people together based on similarities or other purposes you are creating groups. Just like that, a collection of users can make a group on Linux.

Back to our library example, we can have student group with the purpose of studying, employees with the purpose of providing services and managers with the purpose of supervising the processes.

File Ownership

File ownership as the name suggests, determine who is the file owner and how they can treat to the file. It may sound corny but as soon as you use something in a shared space, there will be generic rules about that, these rules may not only apply to you, but also to the group you are in or even for others.

Think about a librarian who buy a new book, they are the owner of the book (file) and has full access to that.

Linux Permissions

File permissions are a set of rules that allows or disallows (or prevent) others from viewing, editing (or modifying) and executing (or running) them.

The mentioned actions are actually permission types that can be applied to a user or their user group or others.

Note that the root user or superuser can access any file one the system.

‑ Permission Types

Permission type at the first place determine the access or denial of access to a file or a directory. Also it indicates what exactly can you do if you have access to the file or directory.

It can be helpful if you memorise the symbolic (using letters) and octal (using numbers) notation for the permissions.

⎯ Read (r)

The read permission indicates that the user can open a file or can see the directory contents.

The symbol of this permission is r, the first letter of the word read. Also in octal notation the number 4 represent the read access.

⎯ Write (w)

The write permission indicates that the user can create, modify or delete a file or can create, modify or delete a directory. Here by modifying the directory I mean the user can change the directory name as an example.

The symbol of this permission is w, the first letter of the word write, and the octal notation is 2.

⎯ Execute (x)

The execute permission indicates that the user can can run executable files as a program or the user can enter into a directory.

The symbol of this permission is x, the second letter of the word execute. The octal notation is 1

Sometimes the user can only have the permission to execute the file, but no reading or writing permission. So in simple words, if you have execution permission for an executable file, no matter if you don't have read or write access, you can run that file. The linux kernel will open it on its own and then execute that.

⎯ No Permission (-)

No permission will be indicated with three dashs (---) or the number 0. When there is no permission, the user isn't able to read, write or execute anything.

⎯ Permission Types Table

Up to this point, you know the different types of permission and their symbolic and ocatl notations. You can see them in one place in the following table:

Permission Symbol (Complete form) Octal (How it formed)
No Permission - (---) 0
Execute x (--x) 1
Write w (-w-) 2
Write + Execute wx (-wx) 3 (2+ 1)
Read r (r--) 4
Read + Execute rx (r-x) 5 (4 + 1)
Read + Write rw (-rw) 6
Read + Write + Execute rwx (rwx) 7 (4 + 2 + 1)

‑ Permission Levels

⎯ User (u)

⎯ Group (g)

⎯ Other (o)

Viewing Permissions, Ownership and Groups

‑ Command Line

directory d file -

⎯ Using ls Command

⎯ Using stat Command

‑ Graphical User Interface

Modifying Permissions

‑ Permissions in CL

‑ Permission in GUI

Modifying Ownership

‑ Ownership in CL

‑ Ownership in GUI

Modyfing Group

‑ Group in CL

‑ Group in GUI

References

Conclusion

Rating 5 of 5
#linux#security
Linux privileges and permissions! | The Latest Articles About Development And Architecture | Hosein Pouyanmehr