Linux Basics (User management)

Source: Internet
Author: User

First, the user's management

1, thinking: Why should there be users in the system?

底层的安全设定的一部分,用户有特定的权力。限制权力组:用来共享权力的 两种:   能决定的叫附加组(不一定都有)               不能改变的组 初始组(所有用户都有)   

2, the form of user existence

        用户是以表格的形式存在加上调用的配置文件

3. User Configuration file

/etc/passwd         用户信息文件用户名称:密码:用户id(用户×××号):组id:用户说明:用户家目录:默认用户使用的shell

/etc/group User Group Information

Group name: Group password: Group ID: Additional Group member

/home/username              用户家目录/etc/ske.*          用户骨文件(用户环境配置模版,在用户建立时会自动复制到家目录中)

4, the user's view
WhoAmI View the name of the current user

ID Username View the user's ID information
-U view uid of user

-G View the user's initial group ID

-G View all group IDs for the group in which the user resides

-n              以名称显示信息

5, the user's establishment and deletion
Watch-n 1 ' tail-n 4/etc/passwd//etc/group;echo ===;ls-1/home '
View the user's information every second

/etc/login.defs you can set the default information for setting up a user in this file

Useradd username using default rules to establish a user (see/etc/login.defs for rules)

Useradd-u 6666 (ID) specifies the UID of the user

Useradd-g 6666 (initial group ID) Username The initial group ID of the specified user

Groupadd-g 6666 GroupName Creating an initial group

Groupadd GroupName set up a group
Group
USERADD-G 6666 username specifying additional groups

Useradd-c "Test User" username specifying descriptive text

Useradd-d/mnt/westos username designated home directory

Useradd-s username The shell of the specified user (the system can be viewed in/etc/shells by the shell)

Delete: Userdel username Remove user Identity

Userdel-r username Deleting user identities and profiles

Difference: Only the user identity is deleted and will fail when created again

To completely delete the created user:

Man Useradd View Useradd
Kill-9 force an end to a certain binary
6. User Management
Usermod-l Linux (new user name) teacher (original user) change user name

Usermod-u ID studnet (user name) change user uid

Usermod-g Student Change an additional group (clear all of the original additional groups, Tea creates a new group)

Usermod-g "" Student Clear all additional groups

Usermod-ag Student Add additional groups on the original basis

USERMOD-C Test Student Add explanatory text

Usermod-c "" Student clear all the explanatory text

usermod-d/home/lee Student change user home directory

Usermod-md/home/lee Student Renaming user and home directories

Usermod-s/bin/Changing the user's shell
Before you change, you must check the shell that the user can use

Where/sbin/nologin and/usr/sbin/nologin are system shells and cannot provide interactive page functions, i.e. cannot log in and switch
Modify Shell

7. User Switching
Su-username advanced User Switching to low-level users does not require a password

Low-level user Switching to advanced users or switching to a peer requires a password

Attention:
1), after the user switches in time to exit in the switch to the next user
2), Su-represents the switch user identity and user environment
8, the user's authentication information
/etc/shadow record the user's authentication information

User name:
Password: MD5 sha512 encrypted symmetric encryption
passwd username only Super User execution

passwd Normal User execution

Usermod-l Freeze Account

Usermod-u Unlocking

Passwd-l Freeze Account

Passwd-u Unlocking

passwd-d Clear Password

The last time the password was modified: When the number is 0 o'clock, the password will be enforced when the system is logged in.

Chage-d 0 Student
PASSWD-E Student
Minimum password expiration: How long does the password change?

Chage-m 1 Student
Passwd-n 3 Student
Maximum password Duration: How long the password must be changed 99999

CHAGE-M Student
Passwd-x Student
Password Expiration Warning:

Chage-w 2 Student
Passwd-w 2 studnet
Password inactive period: After the password is frozen, you can change the password within the time

Chage-i 2 Student
Passwd-i 0 Student
Password expiry date:

Chage-e "2018-11-11" teacher
No user customizations are set:
9. User decentralization
1), configuration file
/etc/sudoers

2), Configuration name order
Visudo This command provides syntax detection

User Name Host name = (Execute program Identity) command
linux11 dns=server.exampl= (Root)/usr/sbin/useradd

Execute with the sudo username command

User Name Host name = (Execute program identity) NOPASSWD: Command 1, Command 2 does not require a password to execute a command

10. Modify the password of the virtual machine super User (without knowing the password)
1), restart the virtual machine, always press up and down until the option appears

Then select which of the following, press E
2), then appear an interface, from the end of the linux16 to delete, has been deleted to the RO, the RO changed to RW, and then add a space, plus rd.break, and then press CTRIL+X.


3) Then when the code is no longer scrolling, enter charoot/sysroot/, press ENTER, and then enter the passwd, the page will let you enter a new password, and then enter the password to be modified, repeat the password two times, and then enter two exit, then you can use the modified password to login
Step One

Step Two

Step Three

Step Four

Linux Basics (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.