Linux has user settings known as permission for finding the access permissions of specific files. There is always a group and owner attributes assigned to every directory of a file system on the shared systems.

Users can share the files with their teammates to access the data from the files. It offers a convenient way of providing access to various users.

However, this access sharing option can sometimes create risks with the data available in the files. So, there is a specific process to check file permissions using the ls command. In this article, we will provide a brief on checking file permissions with ls Linux.

The ls command is used for finding out the information about the directory permissions.  In its default mode, ls returns the complete list of the directory (current working). We can also mention a specific directory to display. So let’s execute different ls commands and see the results:

The above command is used for showing the complete information about the files with their permissions.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/image1-44.png" data-lazy- height="321" src="data:image/svg xml,” width=”705″>

The -h command works to change the display type of the file size. With -h, instead of raw bytes, the system shows the file sizes in human-readable units such as kilobytes, megabytes, etc.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/image3-38.png" data-lazy- height="206" src="data:image/svg xml,” width=”666″>

The -a command works to display all hidden files with their names and other details.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/image2-41.png" data-lazy- height="437" src="data:image/svg xml,” width=”696″>

Using the -l option with ls will provide more information about the files in a directory.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/image4-35.png" data-lazy- height="326" src="data:image/svg xml,” width=”691″>

The first character of each line in the output shows if the listed object is a specific directory. A (d) indicates that the list is a directory. In the first line, there is no d, which shows that it is a regular file.

Different permission levels are denoted by the letters rwx:

Permission Directories Files
r can ls the directory can read the file
w Modifies the contents of the directory can write the file
x Access the directory with a cd can execute the file

X, g, and r appear multiple times. They are grouped into three groups based on their ownership level:

Owner Permissions: The first three characters following the directory (d) slot indicate permission settings for a particular owner.

Group Permissions: The rwx set represents the permissions of the group. A group member can only read a file when using the command -rw-r–r–. Members of a group can view and enter the directory when the permissions are drwxr-xr-x.

Other Permissions: “Other” (also called “world” in some cases) is the last RWX set. Everyone outside the group is in this set. The permissions are the same for these in both examples above as well.

About the author

<img alt="" data-lazy-src="https://secure.gravatar.com/avatar/a6dca3a5394c9d066a8078ddf9ede366?s=112&r=g" data-lazy- height="112" src="data:image/svg xml,” width=”112″>

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.