Linux Commands

Lrwxrwxrwx in Linux

Linux being a multi-user OS uses the concept of ownership and permissions to protect the system and prevent users from accessing each other’s confidential data. It lets the owner of a file to control who can access the file and what level of access they can have. While viewing the Linux file permissions, you might have come across the lrwxrwxrwx permission. This post will describe the lrwxrwxrwx permission in Linux and what the characters corresponding to the permissions mean.

Let’s start with the basic concept.

These are the following three permission classes in Linux:

User: The owner or the user who created the file belongs to this class. The ownership of a file can also be granted to other users.

Group: Multiple users belong to a group. All members of a group have the same permission access to a file.

Other: Any user who has access to the file but he is neither the owner nor belongs to any group belongs to this class.

Each file in Linux has the following three permission types:

Read: It allows the user to open and read the contents of the file. However, the user is not permitted to alter the contents of the file.

Write: It allows the user to edit and change the content of the file.

Execute: It allows the user to run the file (if it is executable).

Lrwxrwxrwx Meaning in Linux

Let’s see what these letters mean:

l: refers to a symbolic link.

r: read

w: write

x: execute

So, the “l” in lrwxrwxrwx permission means this file is a symbolic link. A symbolic link similar to a Windows shortcut is a type of file that points to another file or directory in the system. A symbolic has no content of its own but it contains the content of the actual file to which it points. If you make any change in the symbolic, it will be reflected in the actual file.

The lrwxrwxrwx apparently means maximum allowable permission. However, this is not true in the case of a symbolic link. Every symbolic link is created with lrwxrwxrwx permission but it is a dummy permission. The valid permission of a symbolic link is the permission of the actual file it links to.

Let’s explain it by an example. Create a sample1 file using the command below:

$ touch sample1

Now, view the permissions of the sample1 file through the ls command:

$ ls -l sample1

You will see that the owner has read and write permissions to the file. Remove the write permission through the command below:

$ chmod u-w sample1

Now if you view the permissions of the sample1 file, you will see the owner has only the read permission.

Create a symbolic link file sample2 pointing to the sample1 file.

$ ln -s sample1 sample2

If you view the permission, you will see the symbolic link has the lrwxrwxrwx permission.

To verify it, try to write to the symbolic link file. You will not be able to do that as it points to the sample1 file which has no write permission.

Now, allow the write permission to the actual file sample1.

$ chmod u+w sample1

If you try to write to the symbolic link, you will be able to do that as it reflects the permissions of the actual file which has now the write access.

Conclusion

That’s all! The symbolic links are created with the lrwxrwxrwx permissions but these permissions are never used in any operation. The actual permission of the symbolic link is the permission of the real file it points to. Now, I hope you have understood what the lrwxrwxrwx permission means in Linux. Check Linux Hint for more helpful articles.

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.