File and Directory access authority
For files and directories on Linux, "access authority" is set. You can manage restrictions such as allowing an account to read, allowing members of a group to write, not showing it to other accounts.
These access privileges are called "permission". This section explains how to check permissions of files and directories.
Last Update : February 28, 2019
File and Directory access authority Contents
- Display file/directory detailed information
- Check the owner/group of the file/directory
- How to read permissions
1. Display file/directory detailed information
You can check the owner, owning group, permissions etc of the file/directory by attaching "-l" (lower case L) to the ls command.
$ ls -l total 28 drwxrwxr-x 2 test_user group1 4096 6月 28 08:42 dir1 drwxrwxr-x 2 test_user group1 4096 6月 28 08:50 dir2 -rw-rw-r-- 1 test_user group1 0 6月 28 08:42 file1.txt -rw-rw-r-- 1 test_user group1 0 6月 28 08:42 file2.txt lrwxrwxrwx 1 test_user group1 13 6月 28 08:51 test.txt -> dir2/test.txt
2. Check the owner/group of the file/directory
The owner of the file directory is displayed in the third column of the output of "ls -l".
The group of file directories is displayed in the fourth column of the output of "ls -l".
$ ls -l total 28 drwxrwxr-x 2 test_user group1 4096 6月 28 08:42 dir1
in this case,
owner = test_user
group = group1
If you create a file or directory, the account you created will be the owner of the file and the primary group of the created account will be the owning group.
3. How to read permissions
You can check the permissions of the file/directory from the first 10 characters (eg "drwxrwxr-x") of the display output by ls - l. Each character has a meaning.
As for the part of "drwxrwxr-x", consider it into four as shown below.
The first letter represents "file type". Indicates whether this is a file, directory, symbolic link, etc. The first character represents "file type". It indicates whether this is a file, a directory, or a symbolic link.
The next three characters (red underlined part) represent the permissions for the owner of the file.
The next three characters (green underlined part) represent the permissions for the owning group of the file.
The next three characters (blue underlined part) represent the permissions for others.
The meanings of r, w, x, and - are as follows.
|r||file can be read|
|w||file can be written to|
|x||file can be executed (if it is a program)|
|-||specific permission has not been assigned|
There are s, S, t, and T in addition. I will explain it in another section.
There are various file types, but representative points are as follows.
|-||a regular file (rather than directory or link)|
|l (lowercase L)||a symbolic link to another program or file elsewhere on the system|