Linux user, group creation and permission view

    在我们的生活或者工作中都需要有属于自己的一些账户、账号。这些账户、账号存在的意义就是为了能够方便的管理,同时也是为了更好的保证每个用户的信息安全不被泄露。就像我们在银行办理一个银行卡号,个人的身份信息和电话号码全绑定在一起,去银行再次办理业务时只要输入卡号我们的信息就全部读取出来,当然还要输入我们的用户密码。
            首先我们要先创建一个用户ha:     useradd ha

After creating our user, let’s take a look at the user’s owner and group. We can view the user information by adding our user name to id Linux user, group creation and permission view
. In the figure, we can see three pieces of information, namely uid, gid and group. , So what do these three messages mean?
Uid refers to our user id, which is our user name, just as we must first have a name when we play a game to create a character.
gid is the name of our group. When each user is created, there will be one and only Belongs to its own group, the name is the same as the user name.
Then we created a user, but individual users belong to multiple groups at the same time. Simply put, two users A and B have exactly the same two sets of skins, but A bought another skin, then A will be placed in two In groups of different skins, both sets of skin A can be used.
We now create a group g1: groupadd g1 After
we create the group, add the user ha we created before to the g1 group: usermod -aG g1 ha
Linux user, group creation and permission view
We can see from the above picture that the ha user belongs to the group we created There is another g1 group behind, -aG means to add users to the new group without overwriting the original group. If you want to overwrite, just remove the a before G.
Or use the gpasswd -a ha g1 command to add user ha to the g1 group.
Then the problem comes again. Like some members have expired and do not want to renew, how do we remove users from the privileged group? At this time, we need to know that our user information is all in the /etc/passwd directory, and we create The group information is in the etc/group directory. This is where we use the gpasswd -d ha g1 command to remove user ha from group g1. In this way, user ha no longer has the rights of group g1.
Next we create a directory dir1: mkdir dir1 mkdir (create directory)
Linux user, group creation and permission view
We created a directory named dir1, but I entered a command of ll -d below, this command is used to view the permissions of the directory, all commands should be ll -d dir1, view the permissions of the directory dir1, The -d parameter is to view the directory, and the -d is to view the file permissions.
Linux user, group creation and permission view
We see the permissions of the directory dir1, but we don’t understand it. Don’t worry, I’ll talk about it.

Linux user, group creation and permission view
The letters in the picture are permissions, counted from the back to the front in groups of three. The d at the beginning does not need to be counted. What do these three groups correspond to? Counting from first to last corresponds to owner, group and others. What do these letters mean? r means to read, that is, we can view the content of this file, w means to write, we can enter the directory to modify some things, x is to execute, after we finish writing some content, we want the content to execute is x.

Guess you like

Origin blog.51cto.com/14881361/2543827