Linux user classification and user management

Time:2021-7-29
User classification UID explain
administrators 0 All permissions
Program user 1-999 It is not allowed to log in to the system when running specific programs or services
Ordinary users 1000-60000 Created by the administrator, you can log in to the system to manage and maintain the system

The user’s attribute information includes but is not limited to: home directory, unique identity (uid), belonging group (GID), etc.

#Create user, must be unique
useradd yunwei

#View created users
id yunwei

#Switch user identity
su yunwei
ls -al
#View the shell parsers supported by the system
cat /etc/shell

#Create a user and specify the nologin parser, that is, it is not allowed to log in to the system
useradd -s /sbin/nologin test
#Change the password of the specified user
passwd yunwei
12345678
12345678

#Modify the password of the currently logged in user
passwd 
12345678
12345678

#Set the password through script without interactive setting
echo 12345678|passwd --stdin yunwei1
#Save file of user basic information
vim /etc/passwd
name:password:UID:GID:GECOS:directory:shell

#Save file of user password information
vim /etc/shadow
Name: encrypted password: offset date of the last password modification: minimum password modification interval: how many days must the password be modified: reminder period of password modification warning: grace period of password modification: account expiration date: reserved field
#Displays information related to the user's account date
chage -l yunwei

#The password must be changed when setting user login
chage -d 0 yunwei

#Set user expiration in 30 days
date -d '+30days' +%F
chage -E $(date -d '+30days' +%F) yunwei
#Modify the user's shell information
usermod -s /bin/sh test

#Modify and migrate the user's home directory information
usermod -md /home/test1 test1
#Delete users only
userdel test

#Delete information such as user and home directory
userdel -r test

#Delete the logged in user
userdel -f test1

Recommended Today

Programming Xiaobai must understand the network principle

How is the network composed? Why can we easily surf the Internet now?Whether you are a computer major or not, you may always have such questions in your heart!And today we will solve this matter and tell you the real answer! Basic composition of network First, let’s look at this sentence Connect all computers together […]