search
HomeOperation and MaintenanceLinux Operation and MaintenanceWhat are the types of linux file permissions?

What are the types of linux file permissions?

Mar 09, 2022 pm 01:20 PM
linuxFile Permissions

There are 7 types of Linux file permissions: 1. r permission, which means you can read the contents of the file; 2. w permission, which means you can modify the contents of the file; 3. x permission; 4. rw permission, which means you can Read and write the file; 5. wx permission; 6. rx permission, which means the file can be read and executed; 7. rwx permission, which means it can read, write, and execute.

What are the types of linux file permissions?

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

First of all, if we want to manage user permissions, we must know how to check the permissions of a file. We can use the ll command or the ls -l command to check the permissions of a file, as follows Figure:

What are the types of linux file permissions?

We can see that using the ll command lists some information about the files under /app. There are 7 columns in total. These 7 columns represent the detailed information of the files under /app. :

(1) There are 11 characters in the first column. The first column shows the file type. There are 7 categories of files under Linux:

 1.-  普通文件
 2.d  目录文件
 3.b  块设备文件
 4.c  字符设备
 5.l   符号链接文件
 6.p 管道文件
 7.s 套件字文件

This is 7 types under Linux Different file types, and then the next 9 digits are the permissions we are going to introduce. These 9 digit permissions are divided into 3 groups, each group has 3 digits. There are two situations for each one, as shown in the picture above, the first group is rwx, It means readable, writable and executable. If r means readable, - means unreadable, w means writable, - means unwritable, x means executable, and - means not executable. The first group of these three sets of permissions represents the permissions of the file owner, the second group represents the permissions of the file owner group, and the third group represents the permissions of other people. The last . indicates enabling selinux, which I won’t go into details here.

(2) The second column has only one number, indicating the number of connections to the file. The above 3 means that the file has three links.

(3) The third column represents the owner of the file, that is, the name of the owner. As shown above, root means that the file belongs to the root user.

(4) The fourth column represents all the groups of the file, that is, the name of the group. As shown above, root means that the file belongs to the root group.

 (5)The fifth column indicates the size of the file.

 (6)The sixth column indicates the update time of the file.

(7) The seventh column represents the file name

File permissions

#The operations we can perform on files are nothing more than reading, writing, and executing. And their combined permissions: create, delete, modify (if you can write, you can modify it naturally); the 3-digit permissions are nothing more than the combination of r, w, x, rw, rx, wx, and rwx.

There are 7 types of file permissions:

  • r permission: indicates that the content of the file can be read, use cat or less.

  • w Permission: Indicates that the content of the file can be modified, using vim, vi, etc.

  • xPermissions: No effect.

  • rw permissions: Indicates that the file can be read and written.

  • wx permission: equivalent to w permission, can only write.

  • rx permission: indicates that the file can be read and executed.

  • rwx permissions: indicates readable, writable, and executable, which is the highest permission.

#How to modify permissions? Who has the right to modify the permissions of files or directories?

Modifying permissions is done through the chmod command.

对所有者权限修改 chmod u+/-r/x/w/rx/rw/wx/rwx +文件名
对群组权限修改     chmod g+/-r/x/w/rx/rw/wx/rwx +文件名
对其他用户权限修改 chmod o+/r/x/w/rx/rw/wx/rwx +文件名

At the same time, we can also use binary methods to represent file permissions. For each set of permissions, there are only two possibilities for each bit, that is, yes or no. We can use 1 to mean yes and 0 to mean no. It will look like this:

r-- 100 =4
\-w- 010 =2
\--x 001 =1
rw- 110 =6
r-x 101 =5
\-wx 011=3
rwx 111=7
\--- 000 =0

Because numbers can be used to represent permissions, then we have an easier way to change file permissions:

chmod 777 /app/house

or chmod the permissions represented by numbers. Add files so that all permissions of the files can be changed at once.

**  Experiment to see who can modify the permissions of the file. The root user is a super user and can modify all permissions. There will be no further experiments** here.

 Now we are creating users liubei, guanyu, zhangfei, caocao, creating group shuguo, setting the group administrator as guanyu, and setting the group members as liubei, guanyu, caocao; create the directory test under the app. Modify the permissions to 777, modify the group to shuguo, switch the user to Liu Bei, create a test.file under /test, the command is as follows:

useradd liubei
useradd guanyu
useradd zhangfei
useradd caocao
groupadd shuguo
gpasswd -A guanyu shuguo
gpasswd -M liubei,guanyu,zhangfei
cd /app
mkdir test
chmod 777 test
su - liubei
cd /app/test
touch test.file
ll

The result is as shown below:

What are the types of linux file permissions?

What are the types of linux file permissions?

##Now liubei is the owner of test.file, guanyu is the administrator of group sanguo, liubei, zhangfei, guanyu are group members of shuguo, caocao is other and the current test owner. Can group members, group administrators, and others modify the permissions of test.file.

liubei is the owner:

What are the types of linux file permissions?##guanyu is shuguo’s group manager

What are the types of linux file permissions?zhangfei is shuguo’s Group members

What are the types of linux file permissions?

caocao is not a member of shuguo’s group

What are the types of linux file permissions?

It can be seen that only root and the owner of the file can modify the permissions of the file, others No one can modify it.

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of What are the types of 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
Linux Operations: Utilizing the Maintenance ModeLinux Operations: Utilizing the Maintenance ModeApr 19, 2025 am 12:08 AM

Linux maintenance mode can be entered through the GRUB menu. The specific steps are: 1) Select the kernel in the GRUB menu and press 'e' to edit, 2) Add 'single' or '1' at the end of the 'linux' line, 3) Press Ctrl X to start. Maintenance mode provides a secure environment for tasks such as system repair, password reset and system upgrade.

Linux: How to Enter Recovery Mode (and Maintenance)Linux: How to Enter Recovery Mode (and Maintenance)Apr 18, 2025 am 12:05 AM

The steps to enter Linux recovery mode are: 1. Restart the system and press the specific key to enter the GRUB menu; 2. Select the option with (recoverymode); 3. Select the operation in the recovery mode menu, such as fsck or root. Recovery mode allows you to start the system in single-user mode, perform file system checks and repairs, edit configuration files, and other operations to help solve system problems.

Linux's Essential Components: Explained for BeginnersLinux's Essential Components: Explained for BeginnersApr 17, 2025 am 12:08 AM

The core components of Linux include the kernel, file system, shell and common tools. 1. The kernel manages hardware resources and provides basic services. 2. The file system organizes and stores data. 3. Shell is the interface for users to interact with the system. 4. Common tools help complete daily tasks.

Linux: A Look at Its Fundamental StructureLinux: A Look at Its Fundamental StructureApr 16, 2025 am 12:01 AM

The basic structure of Linux includes the kernel, file system, and shell. 1) Kernel management hardware resources and use uname-r to view the version. 2) The EXT4 file system supports large files and logs and is created using mkfs.ext4. 3) Shell provides command line interaction such as Bash, and lists files using ls-l.

Linux Operations: System Administration and MaintenanceLinux Operations: System Administration and MaintenanceApr 15, 2025 am 12:10 AM

The key steps in Linux system management and maintenance include: 1) Master the basic knowledge, such as file system structure and user management; 2) Carry out system monitoring and resource management, use top, htop and other tools; 3) Use system logs to troubleshoot, use journalctl and other tools; 4) Write automated scripts and task scheduling, use cron tools; 5) implement security management and protection, configure firewalls through iptables; 6) Carry out performance optimization and best practices, adjust kernel parameters and develop good habits.

Understanding Linux's Maintenance Mode: The EssentialsUnderstanding Linux's Maintenance Mode: The EssentialsApr 14, 2025 am 12:04 AM

Linux maintenance mode is entered by adding init=/bin/bash or single parameters at startup. 1. Enter maintenance mode: Edit the GRUB menu and add startup parameters. 2. Remount the file system to read and write mode: mount-oremount,rw/. 3. Repair the file system: Use the fsck command, such as fsck/dev/sda1. 4. Back up the data and operate with caution to avoid data loss.

How Debian improves Hadoop data processing speedHow Debian improves Hadoop data processing speedApr 13, 2025 am 11:54 AM

This article discusses how to improve Hadoop data processing efficiency on Debian systems. Optimization strategies cover hardware upgrades, operating system parameter adjustments, Hadoop configuration modifications, and the use of efficient algorithms and tools. 1. Hardware resource strengthening ensures that all nodes have consistent hardware configurations, especially paying attention to CPU, memory and network equipment performance. Choosing high-performance hardware components is essential to improve overall processing speed. 2. Operating system tunes file descriptors and network connections: Modify the /etc/security/limits.conf file to increase the upper limit of file descriptors and network connections allowed to be opened at the same time by the system. JVM parameter adjustment: Adjust in hadoop-env.sh file

How to learn Debian syslogHow to learn Debian syslogApr 13, 2025 am 11:51 AM

This guide will guide you to learn how to use Syslog in Debian systems. Syslog is a key service in Linux systems for logging system and application log messages. It helps administrators monitor and analyze system activity to quickly identify and resolve problems. 1. Basic knowledge of Syslog The core functions of Syslog include: centrally collecting and managing log messages; supporting multiple log output formats and target locations (such as files or networks); providing real-time log viewing and filtering functions. 2. Install and configure Syslog (using Rsyslog) The Debian system uses Rsyslog by default. You can install it with the following command: sudoaptupdatesud

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool