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 method of Linux rights management

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "what is the method of Linux rights management". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what is the method of Linux rights management"?

1. Overview of file permissions

Permissions vary according to the type of file. Although each file has a permission of 777, when you create a file, you do not see that the permission of the file is 777. This is because some permissions are masked because of the mask.

For each file, it consists of different information, as shown in the figure. This is an empty file called CAT1 that we created earlier. The details of this file are shown below.

The method of Linux File Rights Management method of Linux File Rights Management

The difference between a text file and a catalog file is that the first descriptor is different, while the directory uses "d" as the descriptor. As shown in the figure, this is a directory called CAT that you created earlier, and the details and related descriptions of this directory are shown below.

The method of Linux File Rights Management method of Linux File Rights Management

Using the ls command with the-l option, you can identify the type of each file listed from the first letter of the license string. Here are several common identification numbers.

● -: general files (hard links).

● l: symbolic links (soft links, which can be created using the ln command with the-s option).

● d: directory.

● c: character device file.

● p: name the pipe.

● s: sockets.

● b: block device special files.

2. File rights management

From the CAT1 file you just created, you can see that although the file was created by the cat user, the cat user does not have executable permissions on the file. Now that you want to add executable rights (x) to CAT1, leave the task to the chmod command. Using the chmod command is also very simple, as shown below, to add executable rights to the CAT1 file for cat users.

[cat@cat] $chmod upright x CAT1

After the above operation, the cat user has the executable right to the CAT1 file. Of course, the same is true for adding other permissions, which can also be authorized using the "chmod+rwx file name". Interested readers can try, here only talk about the method, you can practice through this method, in order to better master.

If you also grant executable rights to directories under the CAT directory, you can use the Chmod command with the-R option in the following format:

Chmod-R directory name 1 / directory name 2

Where directory 2 is a subdirectory of directory 1, that is, directory 2 is created under directory 1.

Using the-R option, various permissions can be granted recursively.

Next, we will talk about revoking the permissions of a user (or user group) to the file, using the same command as chmod, as shown below, to revoke the executable rights of the cat user to the file CAT1.

[cat@cat] $chmod Umurx CAT1

According to the file permission value, 4 represents readable, 2 represents writable, and 1 represents executable, and if the permission value exists, it is expressed as 1, otherwise it is expressed as 0 (actually expressed in binary). You can calculate the permission value in a file or directory. As shown in the figure, the weight limit value named CAT1 file is calculated.

The method of Linux File Rights Management method of Linux File Rights Management

If you need to grant permissions to the file, you can also use the form of "chmod 664 CAT1" to authorize the user.

Sometimes, for convenience, you can use chown to change the owner of a file by granting ownership to someone else. Here's how to transfer the cat user's CAT1 file to the dog user and switch to the root user before execution. / home/CAT1 is used because the CAT1 file is in the home directory of the cat user.

[root@cat ~] # chown dog / home/cat/CAT1

After executing the command, you can use the ls command with the-l option to confirm that the change to the owner of the file was successful. The following command displays the details of the file after changing the owner of the file.

[cat@cat] $ls-ltotal 0 dog cat RW Aug 9 21:27 CAT1 here, I believe you have a deeper understanding of "what is the method of Linux rights management", you might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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