Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to understand the Linux authority system

Shulou Source: shulou.com Published: 2022-06-01 04:08:42 10月04日 Update

In this issue, the editor will bring you about how to understand the Linux authority system. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

As I get older, I have more and more experience, but my memory is getting worse and worse. In order to cope with the heavy daily tasks, I had to prepare a long to-do list. Behind every item, I keep reminding me that no matter what surprises my life is full of, I can't escape its mediocre nature.

And I will be more sensitive to time. Every time you hit the keyboard, you will mobilize the twist of your bones and joints, leaving an irrevocable mark: the super user of windows, whose name is Administrator. The word is too long for me to remember. Relatively speaking, the superuser of linux is called root, which has only four letters. Its energy consumption is much lower than the former.

In the third section, when we first came into contact with the command line, we used the chmod command to give execution permissions to plain text files. This section will take a look at the two closely related concepts of user permissions and file permissions.

1. Add users

Up to now, there is only one user in our system, so it is time to learn from Nu WA and pinch a few clay figurines.

First, create two users: zhang3 and li4.

[root@localhost ~] # useradd zhang3

View the three outputs of the following command.

# A group called zhang3 has been added to the system, and the group file stores the group information of the system [root@localhost] # tail-N1 / etc/group zhang3:x:1000: # there is a user named zhang3 in the system, and the shadow file stores their passwords. A lot of security penetration is to get it for brute force cracking [root@localhost ~] # tail-N1 / etc/shadow Zhang3VOV 18207VOV0VIE99999V7: # home directory, there is a directory called zhang3 [root@localhost ~] # ll / home-- full-time total 0 drwx-. 2 zhang3 zhang3 83 2019-11-06 22 09 purl 33.357165082-0500 zhang3

Next, set a password for the user we just created using passwd. The password needs to be entered twice for confirmation. If you want to change the password, use the chpasswd command.

[root@localhost] # passwd zhang3 Changing password for user zhang3. New password: BAD PASSWORD: The password is shorter than 8 characters Retype new password: passwd: all authentication tokens updated successfully.

So how do you delete an existing user? This is done through the userdel command. Plus the parameter f will force you to exit when other users are using the system.

Userdel-f zhang3

2. File permission description

From the above command execution results, we found two very interesting things. After adding the user, in addition to adding some content to the password file shadow, the information is also added to the group file. This involves two attributes of the user: user name and group name.

A user has only one name code, but can have multiple groups. The following command creates a user li4 with a password of 123 and appends a group called zhang3 to it. You can see the information changes in the / etc/group file.

[root@localhost ~] # useradd-G zhang3-p 123 li4 [root@localhost ~] # tail-n 2 / etc/group zhang3:x:1000:li4 li4:x:1001:

All right, let's switch to our file permissions. To validate the following command, we first create a script file called confirm777.sh. To make the script visible to all users, we create it in the / tmp directory.

Cat > / tmp/confirm777.sh

Tags: File permissions user command directory system owner next password that is two information meaning script switch content only article time result Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Technology macOS Linux Huawei