1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
| # -m/--create-home the user's home directory is created as /home/username. The directory is populated by the files in the skeleton directory. The created files are owned by the new user.
# -G/--groups 所属组名 默认组名=username; a comma separated list of supplementary groups which the user is also a member of. The default is for the user to belong only to the initial group
# -s/--shell a path to the user's login shell. Ensure the chosen shell is installed if choosing something other than Bash.
useradd -m -G testu -s /bin/bash testu
useradd -m -s /bin/bash testu
# with the -u/--uid and -g/--gid options when creating the user
useradd -r -u 850 -g 850 -s /usr/bin/nologin username
# To add a new user named archie
useradd -m archie
# Although it is not required to protect the newly created user archie with a password, it is highly recommended to do so:
passwd archie
# To change a user's home directory:
usermod -d /my/new/home -m username
ln -s /my/new/home/ /my/old/home
# To change a user's login name:
usermod -l newname oldname
# To change the user's login shell:
usermod -s /bin/bash username
# User accounts may be deleted with the userdel command:
userdel -r username
# To mark a user's password as expired, requiring them to create a new password the first time they log in, type:
chage -d 0 username
|