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

Chapter 7 user Rights Operation-centos7.5 knowledge

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

I. Overview of user and group accounts

Linux controls resource access based on user identity

User account number

Super user

Ordinary user

Program user

Group account

Basic Group (Private Group)

Additional groups (public groups)

UID and GID

UID (User IDentity, user identification number)

GID (Group IDentify, group identification number)

/ etc/passwd

Save basic information such as user name, host directory, login Shell, etc.

File location: / etc/passwd

Each line corresponds to a user's account record.

/ etc/shadow

Get a user with a password

Grep'\ $6\ $'/ etc/shadow

Useradd command

Useradd [options]... User name

Common command options

-u,-d,

User ID specifies user home directory

Useradd-d / tmp/userdir/a04 A04

-e,

-g,-G

Group profile cat / etc/group

-g belongs to the main group when creating a new user

-G New user specifies multiple additional groups

Useradd A09-G iamyou,tcpdump,upload

Useradd-g iamyou A06

-M does not create a user home directory (uppercase)

-s specifies the SHELL used by the user

[root@localhost] # useradd-d / ftphome/mike-g mike-G ftpuser-s / sbin/nologin mike

Passwd command

Passwd [options]... User name

Common command options

-d specify an empty password

-l Lock the user

-S query user information (uppercase)

-u unlock

If the user name is not specified, change the password of the current account

Usermod command

Modify user properties

Usermod [options]... User name

Common command options

-l change the user name

Usermod-l A100 A10

-L,-U locking and unlocking (uppercase)

The following options have the same meaning as in the useradd command

-u (change user ID),-d (change user directory),-e (change user expiration time),-g (change user main group),-G (change user additional group),-s (change user shell)

Userdel command

Userdel [- r] user name

When the-r option is added, the user's host directory is deleted

[root@localhost ~] # useradd stu01

[root@localhost ~] # ls-ld / home/stu01/

Drwx- 2 stu01 stu01 4096 09-09 12:38 / home/stu01/

[root@localhost] # userdel-r stu01

[root@localhost ~] # ls-ld / home/stu01/

Ls: / home/stu01/: does not have that file or directory

Assignment:

1. Create a new directory / tmp/userdir and create three new users: specify the home directory / tmp/userdir, the user ID, and the user shell.

2. Think about whether you can set the password at the same time and how to do it.

-the next day-

Document source

When you create a new user account, copy it from the / etc/skel directory

Primary user initial profile

~ / .bash_profile

~ / .bashrc

~ / .bash_logout

Group account operation

Similar to the user account file

/ etc/group: save the basic information of the group account

/ etc/gshadow: save the password information of the group account

[root@localhost ~] # grep "adm" / etc/group

Sys:x:3:root,bin,adm

Adm:x:4:root,adm,daemon

Groupadd command

Groupadd [- g GID] group account name

[root@localhost ~] # groupadd-g 1000 market

[root@localhost] # tail-1 / etc/group

Market:x:1000:

Gpasswd command

Set group account password (rarely used), add / remove group members

Gpasswd [options]... Group account name

Usermod-G caiwubu c02

Gpasswd-a b001 caiwubu

Both of the above commands can add users to the group.

Common command options

-a: add a user to the group

-d: removes a user member from the group

-M: defines a list of group members, separated by commas

Groupdel command

Groupdel group account name

[root@localhost ~] # groupdel market

[root@localhost ~] # grep "market" / etc/group

Query account information

Id command

Query user identity

Id [user name]

Groups command

Query the group to which the user belongs

Groups [user name]

Finger command

Query the details of the user account

Finger [user name]

Users, w, who commands

Query user information that is logged in to the host

Access permission

Read r: allows you to view file contents and display directory lists

Write w: allows file contents to be modified, new files or subdirectories to be created, moved, or deleted in the directory

Executable x: allows you to run programs and change directories

Ownership (ownership)

Owner: the user account that owns the file or directory

Group: the group account that owns the file or directory

View permissions and attribution of files / directories

Permission operation:

There are two methods: letter permission method and numeric permission method.

Common command options

-R: recursively modify the permissions of all subitems under the specified directory

Set file and directory owners

Chown command

Chown master file or directory

Chown c01 abc.txt

Chown: a group file or directory

Chown: caiwubu abc.txt

Chown owner: group file or directory

Chown cai2:caiwubu bbb.txt

Common command options

-R (uppercase): recursively modify the attribution of all files and subdirectories under the specified directory

Chattr permission extension

Assignment:

1. What is the purpose of executing the "useradd-d / admin-e 2020-12-31-g wheel-G root admin" command?

2. The password string corresponding to the teacher user is preceded by "!!" in the shadow file. What does the logo mean?

3. What is the purpose of executing the "chmod 764 test" command?

4. What is the purpose of executing the "chown-R: ftp/ var/ftp/pub" command?

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

Wechat

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

12
Report