search
HomeOperation and MaintenanceLinux Operation and MaintenanceWhat information is stored in linux file permissions

Linux file permissions store three types of information: 1. The permission information of the file owner, that is, the permission information of the user who owns the file or directory; 2. The permission information of the group to which the file owner belongs, that is, the permission information of the user who owns the file or directory. The permission information of the group of the file or directory; 3. The permission information of other users, that is, the permission information of other people except the owner and the group.

What information is stored in linux file permissions

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

Linux file permissions store the permissions of the file owner, the permissions of the file owner's group, and the permission information of other users. Corresponds to 3 types of access identities (file owner, group, other users)

Everything in Linux is a file

Folders are actually files

Ordinary files What is saved is text information, and what the folder saves is the directory entry information of the files under the current folder

Directory entry: it is the file name and file index

What information is stored in linux file permissions

Access Permissions

1. Readable permissions (read): Allows viewing the contents of files or folders, displaying directory lists

2. Writable permissions (write): Allows modifying file contents, allowing directory listing Create, move, delete files or subdirectories in

3. Executable permissions (execute): Allow the program to switch directories

Ownership (ownership)

1. File Owner: the user account that owns the file or directory--"Owner--user--"u

2. Group: the group account that owns the file or directory-- 》Organize the community--group--》g

3. Others (other): In addition to the owner and other people in the group--》outsiders--others--》o

use Cases to explain the permissions of files

# ls -al up.txt 
-rw-r--r--. 1 root root 126 4月   9 16:59 up.txt

1. The first column of blank separation is the set permissions. The third column is the owner and the fourth column is the group

    1.1、第一列一般十个字符组成
                第一个字符表示文件类型
                        f  为文件
                        d  为文件夹
                        l  为链接文件
                        b  为块设备文件(block)        --》磁盘设备文件
                        c  为字符设备文件       --》显示字符相关
                        p  为管道文件    
                        s  为socket文件  --》进程通信的
                                1.文件socket
                                        本机上的不同进程之间通信的方式
                                2.网络socket 
                                        ip:port 不同的机器之间的不同的进程通信,192.168.0.123:3

2. File descriptor fd

File descriptor: The Linux kernel creates a file descriptor table for each process. This table records all the files opened by the process. In order to facilitate the process to know which files it has opened, it is given to each process. Each file is numbered, and this number is the file descriptor. Moreover, when a process reads or writes a file, it directly uses the corresponding number and no longer uses the file name.

Linux ACL Access Control Permissions

Linux System The traditional permission control method is nothing more than using three identities (file owner, belonging group, other users) and matching them with three permissions (read r, write w, access x). For example, we can use the ls -l command to view the detailed information of all files in the current directory, which includes the permission settings for each file:

# ls -l

total 36
drwxr-xr-x. 2 root root 4096 Apr 15 16:33 Desktop
drwxr-xr-x. 2 root root 4096 Apr 15 16:33 Documents
...
-rwxr-xr-x. 2 root root 4096 Apr 15 16:33 post-install
...

In the above output information, "rwxr-xr-x" indicates Different users have permissions to access files, that is, the file owner has read, write, and access permissions to the file (rwx), the group to which the file belongs has read and access permissions to the file (r-x), and other users have read, write, and access permissions to the file. Access permissions (r-x).

The characters before permission indicate the specific type of file, such as d indicates directory, - indicates ordinary file, l indicates connection file, b indicates device file, etc.

But in practical applications, the above three identities are not enough at all. Let me give you an example.

What information is stored in linux file permissions

There is a /project directory in the root directory of the above picture, which is the project directory of the class. Every student in the class can access and modify this directory. The teacher needs to have the highest permissions for the directory. Of course, students in other classes cannot access this directory.

How do I need to plan the permissions of this directory? It should be like this. The teacher uses the root user as the owner of this directory, and the permissions are rwx; all students in the class join the tgroup group, making the tgroup group the owner of the /project directory, and the permissions are rwx; the permissions of others are set to 0 (that is ---). In this way, the permissions to access this directory meet our requirements.

One day, a trial student st came to the class. She must be able to access the /project directory, so she must have r and x permissions on this directory; but she has not studied previous courses, so She cannot be given the w permission because she is afraid that she will change the wrong content in the directory, so the permission of student st is r-x. But how to assign her identity? Become the owner? Of course not, otherwise where should I put the root? Join a tgroup? It doesn't work, because the permissions of the tgroup group are rwx, and we require the permissions of the student st to be r-x. What if you change other people's permissions to r-x? This will make the /project directory accessible to all students in other classes.

Obviously, the three identities with normal permissions are not enough, and it is impossible to set access permissions for an individual user. In this case, you need to use ACL access control permissions.

ACL is the abbreviation of Access Control List. In Linux systems, ACL can set permissions for a single user to access files. It can also be said that in addition to setting file access permissions in the traditional way (three identities with three permissions), you can also use ACL to set it. Take the st student in this example. Since giving it the three traditional identities cannot solve the problem, you can consider using ACL permission control to directly set r-x permissions for accessing files for the st user.

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of What information is stored in linux file permissions. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The 5 Core Components of the Linux Operating SystemThe 5 Core Components of the Linux Operating SystemMay 08, 2025 am 12:08 AM

The five core components of the Linux operating system are: 1. Kernel, 2. System libraries, 3. System tools, 4. System services, 5. File system. These components work together to ensure the stable and efficient operation of the system, and together form a powerful and flexible operating system.

The 5 Essential Elements of Linux: ExplainedThe 5 Essential Elements of Linux: ExplainedMay 07, 2025 am 12:14 AM

The five core elements of Linux are: 1. Kernel, 2. Command line interface, 3. File system, 4. Package management, 5. Community and open source. Together, these elements define the nature and functionality of Linux.

Linux Operations: Security and User ManagementLinux Operations: Security and User ManagementMay 06, 2025 am 12:04 AM

Linux user management and security can be achieved through the following steps: 1. Create users and groups, using commands such as sudouseradd-m-gdevelopers-s/bin/bashjohn. 2. Bulkly create users and set password policies, using the for loop and chpasswd commands. 3. Check and fix common errors, home directory and shell settings. 4. Implement best practices such as strong cryptographic policies, regular audits and the principle of minimum authority. 5. Optimize performance, use sudo and adjust PAM module configuration. Through these methods, users can be effectively managed and system security can be improved.

Linux Operations: File System, Processes, and MoreLinux Operations: File System, Processes, and MoreMay 05, 2025 am 12:16 AM

The core operations of Linux file system and process management include file system management and process control. 1) File system operations include creating, deleting, copying and moving files or directories, using commands such as mkdir, rmdir, cp and mv. 2) Process management involves starting, monitoring and killing processes, using commands such as ./my_script.sh&, top and kill.

Linux Operations: Shell Scripting and AutomationLinux Operations: Shell Scripting and AutomationMay 04, 2025 am 12:15 AM

Shell scripts are powerful tools for automated execution of commands in Linux systems. 1) The shell script executes commands line by line through the interpreter to process variable substitution and conditional judgment. 2) The basic usage includes backup operations, such as using the tar command to back up the directory. 3) Advanced usage involves the use of functions and case statements to manage services. 4) Debugging skills include using set-x to enable debugging mode and set-e to exit when the command fails. 5) Performance optimization is recommended to avoid subshells, use arrays and optimization loops.

Linux Operations: Understanding the Core FunctionalityLinux Operations: Understanding the Core FunctionalityMay 03, 2025 am 12:09 AM

Linux is a Unix-based multi-user, multi-tasking operating system that emphasizes simplicity, modularity and openness. Its core functions include: file system: organized in a tree structure, supports multiple file systems such as ext4, XFS, Btrfs, and use df-T to view file system types. Process management: View the process through the ps command, manage the process using PID, involving priority settings and signal processing. Network configuration: Flexible setting of IP addresses and managing network services, and use sudoipaddradd to configure IP. These features are applied in real-life operations through basic commands and advanced script automation, improving efficiency and reducing errors.

Linux: Entering and Exiting Maintenance ModeLinux: Entering and Exiting Maintenance ModeMay 02, 2025 am 12:01 AM

The methods to enter Linux maintenance mode include: 1. Edit the GRUB configuration file, add "single" or "1" parameters and update the GRUB configuration; 2. Edit the startup parameters in the GRUB menu, add "single" or "1". Exit maintenance mode only requires restarting the system. With these steps, you can quickly enter maintenance mode when needed and exit safely, ensuring system stability and security.

Understanding Linux: The Core Components DefinedUnderstanding Linux: The Core Components DefinedMay 01, 2025 am 12:19 AM

The core components of Linux include kernel, shell, file system, process management and memory management. 1) Kernel management system resources, 2) shell provides user interaction interface, 3) file system supports multiple formats, 4) Process management is implemented through system calls such as fork, and 5) memory management uses virtual memory technology.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.