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

[Linux] user groups, user actions

2025-02-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

​ /: root directory

​ root: home of Super Admin (root)

​ home: home of other users (ordinary users)

​ etc: configuration fil

​ usr: where the shared files are stored (the installation path of the software)

​ lib: dependent libraries

Concepts of Linux user groups and users

Basic concept

Users are divided into super administrators and ordinary users.

A user group is a snap-in for a user, and a user belongs to at least one user group

Dependency relationship

Ultra-managed operation user

Supertubes can create, modify, delete, and modify passwords

Ultra-managed operation user group

Super management can add, delete and modify user groups, and move users to different user groups.

User groups are similar to tags, and the same user may have multiple tags, that is, a user can belong to multiple user groups.

User operation

Cannot add, delete or modify users or user groups

Super management user group

New user group

Groupadd group name

View user groups

Group name to which a user belongs: groups user name

Modify group name

Groupmod-n new group name original group name

Delete a user group

Groupdel group name

Ps: there are users under the user group. You need to delete the user before deleting the user group.

Ultra-managed management user

Create a user

Useradd-m [- g group name] new user name

Parameter explanation:

-m automatically sets up the user's home directory in the / home directory. The home directory name is the new user name-g group name specifies the group in which the new user belongs. If the "- g group name" parameter is not taken, a group with the same name as the new user name will be created.

Set user password (modify)

New user name for passwd

Modify user name

Usermod-l new name and old name

Delete user

Userdel-r user name

Parameter explanation:

-r recursion abbreviation, recursion. Recursively delete the directory file of the user name

1.1 if you use the-r parameter, adding a user name with the same name will report an error of Creating mailbox file: File exists

Overmanage users and user groups

Add a user to a user group

New user name for useradd-m-g group

Move users to user groups

Usermod-g group username

Copy users to user groups

Usermod-G group username

Remove a user from a group

Gpasswd-d user name group

PS: only users who can be deleted can be copied from other groups. If you want to delete the only user in the group, use: userdel-r user name

Super manage to view and modify read and write permissions of / etc/sudoers file

Ll-h view the permissions of sudoers

[root@james etc] # ll-h

-rMurray. 1 root root 4.0K Mar 2 2012 sudoers

For an expression with a length of 10, the first bit is the file type identification bit, and the last 9 bits are 3 * 3 permission definition bits

File identification bit

: file

D: directory

Why three 3s?

The first 3

Permissions of the current user

The second 3

Permissions of users in the same group as the current user

The third 3

Permissions of users in other groups

Why are there three people in each group?

First place

R: English read acronym read permission

Second place

W: abbreviation permission for English write

No. 3

X: execute permission

-rMurray. Root users have read, write and executable permissions. Users in the same group as root can only read, while users in other groups do not have any permissions.

Binary representation of-rmurr-

Bit 1:-File

Position 2-4: r music-= 100 = 1.22 + 0.11 + 0 * 10 = 4

Position 5-7, position 8-10

Modify the permissions of sudoers using binary parameters

[root@james etc] # chmod 740 sudoers

[root@james etc] # ll-h | grep sudoers

-rwxr-. 1 root root 4.0K Mar 2 2012 sudoers

Use / etc/sudoers to grant the user sudo permission

Vim / etc/sudoers join

The average user uses the supermanagement command-must be prefixed with sudo

[tom@james ~] $usermod-G emp tom

-bash: / usr/sbin/usermod: Permission denied

[tom@james ~] $sudo usermod-G emp tom

We trust you have received the usual lecture from the local System

Administrator. It usually boils down to these three things:

# 1) Respect the privacy of others.#2) Think before you type.#3) With great power comes great responsibility.

[sudo] password for tom:

[tom@james ~] $

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

Servers

Wechat

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

12
Report