user management
user accounts
Function: 1. Can log on to the operating system 2. Different users with different permissions
A unique identifier: UID (the serial number of Numbers starting from 0, the default maximum 60000)
Zhangsan (UID 1200)
Administrator root UID: always be 0
Ordinary users UID: the default since 1000
group accounts
User management: easy
A unique identifier: GID (the serial number of Numbers starting from 0, the default maximum 60000)
Sg (1500)
Principle: Linux a user must belong to at least one group
The classification of the group account:
Basic groups: system created with the user name
Additional group (dependent) : created by the administrator, the administrator to add
] # useradd zhangsan
Groups: zhangsan
Groups: sg xs mn haha xixi
local account data file
-/etc/passwd and/etc/shadow
-/etc/group,/etc/gshadow
/etc/passwd: storing user basic information configuration file
/root @ localhost ~ #/etc/passwd head - 1
root: x: 0-0: root:/root:/bin/bash
User name: password placeholder: UID: basic group GID: user description: the home directory: interpreter
user accounts to create
Useradd command
- format: useradd [option]... The user name
? Commonly used command options
-- - u: specify the UID number tag
- d: host directory (home directory) is specified, the default is/home/username
-- - G: specify additional group belongs to
-- - s: specify the user login the interpreter /sbin/nologin: prohibited operating system user login
usermod command
- format: usermod [option]... The user name
? Commonly used command options
- l: change user account login name
-- - u: user id
- d: the home directory path
- s: login interpreter
-- - G: additional reset//additional group
- l: change user account login name
-u: user id
Login -s: interpreter
password
The passwd command
- format: passwd [option]... The user name
/root @ localhost ~ # passwd nsd01 # interactive set
Change the password, user nsd01
New password: # input new password
Invalid password: password is less than eight characters
Enter a new password:
# to re-enter the new passwordPasswd: all the authentication token has been updated successfully,
[root @ localhost ~] # # su - nsd01 temporary switch user identity
[nsd01 @ localhost ~] $passwd
Change the password, user nsd01
As the nsd01 STRESS change password,
# (current) UNIX password: enter the old password
New password: # input new password
Enter a new password:
# to re-enter the new passwordPasswd: all the authentication token has been updated successfully,
[nsd01 @ localhost ~] $# exit exit, back to the root user
the passwd command, supporting the non-interactive password
-- stdin: from the standard input (such as pipeline) password
/root @ localhost ~ # echo 123 | passwd -- stdin nsd01
/etc/shadow, to save the password string/valid information such as
- each user record a line to: is divided into nine fields
/root @ localhost ~ # grep nsd01/etc/shadow
Nsd01: $6 $$B0n94XrpQ NVe937Nd LipQHTpYh0iV M4jCLdccfHxzRLprdxDzwk8WDDh/TzdTfh8lA9y9WKJ. 8 ls/l5. W/1 w. nV6CFX/: 18481:9999-7:0:9: :
The last time to change the password: since the 1970-1-1 reached the last time to change the password, experienced the number of days
The name of the field 1: user account
Column 2: the encrypted password string
Field 3: the last time to change passwords
Initial configuration file user
Source configuration file
New users, the new user's home directory, according to the/etc/skel directory replication templates
main initial configuration file
- ~/. Following: each time you login the system implementation, to define the initial variable values
- ~/. Bashrc: every time into the new Bash environment execution (open a new terminal)
/root @ localhost ~ # vim/root/bashrc # define permanent alias
Alias haha='echo haha
Open a new terminal test:
/root @ localhost ~ # haha
Haha
-/etc/bashrc: global configuration files that affect all users (open a new terminal)
/root @ localhost ~ # vim/etc/bashrc
Alias xixi='echo xixi'
Open a new terminal to verify
/root @ localhost ~ # xixi
/root @ localhost ~ # useradd nsd20
/root @ localhost ~ # # su - nsd20 equivalent to open a new terminal
[nsd20 @ localhost ~] $xixi
[nsd20 @ localhost ~] $exit
Logout
/root @ localhost ~ #
delete user
Userdel command
Format: userdel [-r] user name
Adding the -r option, host directory/user mail also delete
/root @ localhost ~ # userdel -r nsd01 # together with home directory delete
/root @ localhost ~ # userdel nsd02 # don't delete the home directory, delete user information only
group account management
/etc/group, save the basic information of the group account
A line, each group recorded to: is divided into four fields
/root @ localhost ~ # grep stugrp/etc/group
s tugrp: x: 1504: nsd06
The group name: password placeholder: group GID: group membership list
gpasswd command
- format: gpasswd [option]... Group name
? Commonly used command options
- a: add group, every time can only add a
- d: delete group members, every time can only delete a
- M: defining group membership list of users, can set up multiple
- A: define group admin list
/etc/gshadow: group management information configuration file
/root @ localhost ~ # grep nsd2103/etc/gshadow
group name: password encryption string: the administrator list: member of the group list
Delete group accounts: remove group, basic group can not delete
plan task
Purpose: according to the set time intervals for users to perform a certain fixed system task
Package: cronie, crontabs
System service: crond
log file:/var/log/cron
Use the crontab command
- edit: crontab -e [-u username]
- view: crontab -l/-u username
- clear: crontab - r/-u username
Plan tasks written form
Points when day week month mission command line (absolute path)
* * * * *
30 # 8 * * * every morning at 8:30 performs a
30 * * * # 23:30 in the evening every day do a
30 * * 5 # 23 weekly Friday 23:30 performs a
30 * * 1-5 # 23 every week from Monday to Friday drove to execute a
30 * * 1,3,6 # 23 weekly on Monday Wednesday 23:30 on Saturday performs a
30 23 1 * 1 # 1 per month or every Monday night 23:30 performs a
* * * * * # run once per minute
* * * * */5 # every 5 minutes to run a
0 # 2 * * * */to run once every 2 hours
* : match at any time within the scope of the
, the timing of the: separate multiple discrete
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull