Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the command for Linux to modify permissions

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, I will introduce to you what is the command for Linux to modify permissions. The content of the article is good. Now I would like to share it with you. Friends who feel in need can understand it. I hope it will be helpful to you. Let's read it along with the editor's ideas.

In the Linux command, chmod is used to modify the permissions of a file or directory. There are three general permissions for files or directories, which are:

R: read

W: write

X: execute.

In addition, there are three special permissions, namely:

Suid:Set User ID

Sgid:Set Group ID

Sticky: sticky position.

Here, we only show how to use chmod to modify the general permissions of files and directories.

Scope of permissions and scope of permissions for code files and directories, including:

U:User, the owner of a file or directory

G:Group, that is, the group to which a file or directory belongs

O:Other, except for the owner of the file or directory or the group to which it belongs, all other users fall within this scope

A:All, or all users, includes the owner, the group to which it belongs, and other users.

The codes for permissions include:

R: read permission, numeric code 4

W: write permission, numeric code 2

X: execute or switch permissions, numeric code 1

-: do not have any permissions, the number code is 0

S: when the file is executed, the setuid or setgid permissions of the file are set according to the user type specified by the who parameter.

Syntax and options description chmod syntax:

Chmod [- cfRv] [--help] [--version] [+ /-/ =] [file or directory.]

Chmod [- cfRv] [--help] [--version] [numeric code] [file or directory.]

Chmod [- cfRv] [--help] [--reference=] [--version] [file or directory.]

Option description:

-c or-- changes: the effect is similar to the-v parameter, but only returns the changed part

-f or-- quiet or-- silent: no error message is displayed

-R or-- recursive: recursive processing that processes all files and subdirectories under the specified directory together

-v or-- verbose: displays the instruction execution process

-- help: displays online help information

-- reference=: sets all the permissions of the specified file or directory to the same permissions as the reference file or directory

-- version: displays version information

+: open this permission setting for files or directories within the scope of permission

-: close the permission setting for files or directories within the scope of permission

=: specify the permission setting for a file or directory with a permission scope.

First of all, let's look at the information about files and directories through the ls-l command:

As shown in the figure above, taking it as an example, we analyze the meaning of each content in turn.

Line 1: total 16, which represents the total disk footprint of the listed content in KB

Column 1: dr-xr-xr-x, indicating the type and permissions of the file or directory

Column 2: 4, indicating the number of links to a file or directory

Column 3: bin.guo, which represents the owner of the file or directory

Column 4: staff, indicating the group in which the file or directory resides

Column 5: 136, which represents the size of the file or directory itself

Column 6: Nov 24 11:26, indicating the last update time of the file or directory

Column 7: a, which represents the name of the file or directory.

The content of column 1 (except total) is particularly rich. Take dr-xr-x-r-x as an example (a total of 10 characters), we further analyze it:

The 1st character d, which indicates the type of file or directory, which includes

P, which represents a named pipe file

D, which represents the catalog file

L, which represents a symbolic link file

-, which represents a normal file

S, which represents the Socket file

C, which represents the character device file

B, which represents the block device file.

The 2nd-4th character rmurx indicates the owner permission of the file or directory

The 5th-7th character rmurx indicates that the owner of the file or directory has the same group user rights

The 8th-10th characters rmurx denote other user rights for a file or directory.

In addition, you may have noticed that some files or directories are followed by a character after their displayed permissions, or. Or @, specifically:

Displayed as @ in the Mac terminal

In Linux system, it is shown as.

This means that the file or directory to which it belongs has the SELinux security context tag open, and if not, it is not open.

Next, demonstrate some concrete examples of operation:

Example 1: add all users' execute rights to test-one

Example 2: revoke the execute rights of test-one owner group users and write permissions of other users

Example 3: recursively revoke the execution rights of all users of folder a

Example 4: add all permissions for all users to test-one

Example 5: revoke the execute rights of the test-one owner and all permissions of other users

Of the many commands in Linux, the chmod command is a relatively simple one. Starting with this, let's feel the charm of Linux together.

The above is the full content of what is the command for Linux to modify permissions, and more related to the command for Linux to modify permissions can be searched for previous articles or browse the following articles to learn ha! I believe the editor will add more knowledge to you. I hope you can support it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report