Command Linux

Check File Permissions with ls Linux

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:

$ ls

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

$ ls -h

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.

$ ls -a

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

$ ls -l

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

$ ls -lah

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.

Related Articles

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

Back to top button