Mastering Linux File Permissions: A Comprehensive Guide for Beginners and Experts – Part 1

This topic explores Linux file permissions as part of the ‘Linux Fundamental – A Journey with Linux‘ series. Discover ownership, user groups, and permissions, essential for managing file security and protecting valuable information on Linux file systems.

So now will start basic understanding of Linux file permission, which is used for the file to have privilege permission for certain access for the different purposes of the user.

The output of the ‘ls -l’ command will give a long listing of information, and here is the breakdown of each component:

  1. The starting ‘d‘ is indicated as a directory and ‘‘ as a file.
  2. The next nine characters are file permission for different 3 user types such as owner, group, and other users. Each set of three characters represents the permissions for each user type. The three possible characters are:
    • r‘ is read permission, which allows reading the contents of a file
    • w‘ is write permission, which allows modifying the contents of a file or creating/deleting files in a directory.
    • x‘ is execute permission, which allows executing the file as a program or accessing files within a directory.
  3. The next two columns represent the owner and group of the file, respectively. These columns display the user and group names or IDs associated with the file.
  4. The next column is for represents the file size, typically displayed in bytes and the next indicates which month and date with the exact time created or modified of the file.
  5. Last column for the file name or directory name.

Overall, your information accurately describes the components of Linux file permissions and their representation in the file permissions output.

Understanding File Permissions and Security in Linux

Linux file permissions and security are indeed essential for keeping your file system safe and secure from unauthorized access. The nine characters representing file permissions are indeed divided into three sets: rwx (owner), rwx (group), and rwx (other user). These sets determine the read, write, and execute permissions for each category of users, ensuring proper access control.

Changing Linux security permissions.

For changing permissions on Linux, you can use the command ‘chmod‘ which stands for change mode. The nine characters represent the mode of security, indicating the access permissions for various categories such as user, group, and others.

Exploring Symbolic and Octal Notations for Linux File Permissions:

There are different ways to change permissions on Linux: one is by using symbolic notation, and the other is by octal notation values.

Symbolic Notations of file permissions

Symbolic Notation represents file permissions using letters: ‘r’ for read, ‘w’ for write, and ‘x’ for execute. Each set of permissions for the owner, group, and others is represented by three letters.

So now we will explore Symbolic Notations. Here are some important letters, operators, and users that you should go through.

  1. Different letters of permission as ‘read’,’ write’, and ‘execute’

2. Different operators used as ‘+‘,’‘, and ‘=

3. Different categories of permissions are user, group, others, and all.

Now we will dive into symbolic notation, exploring how to change file permissions on Linux.

So, First will create a new file with the name “new.txt“, by using “ls -l” can check the long listing of files and directories with the file permissions.

We’ve noticed that the directory Linux has only one file “new.txt” with the file permissions user has ‘r(read) and w(write)’, group ‘r(read)’, and other ‘r(read)’.

So now will remove the read permission for both group and other users by using symbolic mode.

Here is the explanation of the command used ‘chmod go-r new.txt‘ :

The command used chmod(also known as “Change Mode”) is a command-line utility that modifies the permissions associated with files and folders.

g(group), o(other),-(remove permissions), and r(read)

will come out of the root user and try to read the file from other user

It was an error as ‘Permission denied’, So other users don’t have permission to read.

Only the root user was able to read except group and other users.

Now will give read permission to other users by ‘o+r‘, o mean of other users, operator ‘+’ adds permission, r is indicated as read.

It is changed, now will check to read the file by other users

Successfully we’re able to read the file, This is how we can change the file permission on Linux by using Symbolic Notation.

Octal Notation of file permissions

The octal notation is a method used to change a file in the Linux file system. This notation involves assigning numerical values to represent different file permissions and file types, allowing for precise control over access and operations on the file.

Here, we will explore the method of changing file permissions using octal notation values.

The file ‘new.txt’ only had read, write, and execute permissions, So now will try to change the permission by using Octal Notation mode.

The command used ‘chmod 704 new.txt’ was chmod(change mode) and the octal value 704 is explained below:

7 – binary was 111 and the file mode r(read), w(write), and x(execute) for a user.

0 – binary was 000 and the file mode was none for a group.

4 – binary was 100 and the file mode was r(read) for other users.

It means we’re giving a file permission to the file ‘new.txt’ for a user to all three as read, write, and execute permission. The group was not having any permission and other users were having only read permissions

Now will try some other octal values to see the difference, such as giving read(octal value 4) permission to the user and the other users, other side group was having write(octal value 2) and execute(octal value 1) permissions.

We have changed the mode of file permission to read for a user, write and execute for a group, and read for an other user.

As other user have read permission, so user razz can read the contents of the file.

Now will give all permission to read, write, and execute to all categories as a user, group, and other by using the octal value ‘777‘.

Here is the command that has executed: chmod 777 new.txt

  • 7 Octal value of binary was 111 as ‘rwx‘, where it was having all three permission read, write, and execute.
  • The 777 means all permission for all as ‘rwxrwxrwx‘ is shown below.

Will change the other user as no permission, the binary of ‘0‘ as ‘‘. This means the other user can’t read, write and execute on this file ‘new.txt‘.

Permission denied, The other user is not able to read the file.

changing the other user permission for read by giving the octal value ‘4‘ and binary was ‘100‘ as ‘r–‘ permission of other user but here was giving an error as Operation not permitted because it doesn’t have root privilege access to perform that critic task as changing the permission of the file.

So we can execute sudo with the command as root access.

Successfully changed the permission.

Now will try to write on the file as other user.

It shows as [ File ‘new.txt; is unwritable ] because it was having only read permission but not write permission.

So will change the permission of the other user as read and write, where the octal value of read is ‘4‘ and write was ‘2‘, for both read and write permission adding the 4 and 2 was 6.

Successfully, we’re able to write the file and also have read permission.

I hope you’ve learned and enjoyed this Walkthrough.

So, You can connect with me on LinkedIn & Twitter for more updates on Infosec.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.