Linux from getting started to mastering-user management

Source: Internet
Author: User

I. User management commands

1. User's view

(1) View Current user

WHOAMI # #查看当前用户

(2) Viewing of users in the system

ID # #查看指定用户id信息

Id-u # #查看用户的uid

ID-G # #查看用户的gid

ID-G # #查看用户所在的所有组的id

Id-n # #显示名字而不显示id数字
2. User Switching

Su-User name # # # "-" identifies the current user's environment at the same time when user identity switching # # #

# # # Execution when the advanced user switch to low-level users do not need a password, low-level users switch to advanced needs, peer switching switching also need # # #

Note: Each time you switch to another user action opens a new shell process, you must exit with the Exit command and then switch to another user again.

3. How the user is stored in the system

/etc/passwd
User Information file
User name: Password: uid:gid: Description: Home directory: Default Shell

/etc/group
User group information file
Group name: Group password: Group ID: Group member

/etc/shadows
Certification Information file

/etc/skel/.*
By default the shell configuration is turned on, the user's bone file

/home/username
User's home directory

4. Deletion of the user


Userdel Student # #删除用户但是不删除用户的配置文件
Userdel-r Student # #删除用户并删除系统文件

5. User Establishment

******** User Information monitoring command **********

Watch-n 1 ' tail-n 3/etc/passwd/etc/group;ls-l/home ' # #加 "" means to monitor all subsequent commands. If there is no "" only monitor ";" before a command

                                                           ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp     # #在watch后面跟  -n 1  means one second monitoring                  

# #命令中的 ";" means the command before the semicolon is executed, followed by a semicolon.


(1)

Useradd # #建立用户的, when the user is established, read the/etc/login.defs file content determination rules
"After normal user id1000, super User ID before 200"

Useradd-u 8888 Student # #指定用户的uid

Useradd-g Student # #指定用户的初始组id, "The premise is that 21 user groups must be present"

Useradd-c ' haha ' student # #指定用户的说明

Useradd-g Student # #指定用户的附加组id, "The premise is that 21 user groups must be present"

useradd-d/HOME/WF Student # #指定用户的家目录

Useradd-s/bin/sh Student # #指定用户的默认shell

Userdel # #用户删除

"NOTE: Each time after the experiment to purify the user environment, that is, delete useless users"

(2)

Groupadd # #建立用户组

GROUPADD-G Student # #建立用户组并且指定用户组的初始组id

Groupdel # #删除用户组



(3) Change of user information

Usermod

Usermod-l new name Student # #更改用户新名称

Usermod-u 6666 Student # #更改用户uid

USERMOD-G Student # #更改用户的初始id

Usermod-g Student # #更改用户的附加组 (if you have an additional group, then use-G will change the original additional group)

Usermod-ag Student # #添加用户的附加组, if there is an additional group in it, a new additional group is appended later

Usermod-g "" Student # #删除用户所有附加组

Usermod-c "abc" Student # #更改用户的说明文字

usermod-d/home/lsy Student # #更改用户家目录的指向

Usermod-md/home/lsy Student # #更改用户家目录

Usermod-s/bin/sh Student # #更改用户的shell

Usermod-l Student # #冻结用户

Usermod-u Student # #解锁用户

6. User password settings passwd student [the system in this password does not interact with the consumer, which improves security]

Two. User authentication information Management

1. Certification Information file

The user's authentication information is recorded in/etc/shadows, which includes:

(1) User name:
(2) User password:

passwd Student
Passwd-l student # #在用户密码前加入 "!! ", similar to freezing
Passwd-u Student # #解锁密码
passwd-d Student # #清空student密码
Usermod-l student # #在用户密码前加入 "! ”
Usermod-u Student # #解锁用户

(3) The time the user password was last changed:

PASSWD-E Student # #会改变用户最后一次更改密码的时间为0, users will be forced to change their password upon login

chage-d 0 Student # #两个命令功能相似
(4) Minimum password period:

Passwd-n 1 Student # #student用户在一天之内不能更改密码

Change-m 1 Student # #同上

(5) Maximum password period:


Passwd-x Student # #student在30天内必须更改密码

Change-m Student # #同上


(6) Password warning period:

Passwd-w 2 Student # #密码过期前两天有警告输出

Change-w 2 Student # #同上

(7) The password is inactive

Passwd-i 1 Student # #密码过期后仍可登录系统的天数

Change-i 1 Student # #同上

(8) Password expiry date

CHAGE-E 2018-11-11 Student # #student用户在2018-11-11 will be frozen


(9) User-defined columns (cannot be manipulated)


Three. User authorization

User Authorization Profile/etc/sudoers
Authorization configuration command: Visudo This syntax will have syntax errors compared to VIM
Hostname View host (native) name


Linux from Getting started to mastering-user management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.