root@iZ28rwmhep0Z:~# adduser xyz Adding user `xyz' ... Adding new group `xyz' (1000) ... Adding new user `xyz' (1000) with group `xyz' ... Creating home directory `/home/xyz' ... Copying files from `/etc/skel' ... Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for xyz Enter the new value, or press ENTER for the default Full Name []: Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n] y
xyz@iZ28rwmhep0Z:~$ adduser -help adduser [--home DIR] [--shell SHELL] [--no-create-home] [--uid ID] [--firstuid ID] [--lastuid ID] [--gecos GECOS] [--ingroup GROUP | --gid ID] [--disabled-password] [--disabled-login] [--encrypt-home] USER Add a normal user adduser --system [--home DIR] [--shell SHELL] [--no-create-home] [--uid ID] [--gecos GECOS] [--group | --ingroup GROUP | --gid ID] [--disabled-password] [--disabled-login] USER Add a system user adduser --group [--gid ID] GROUP addgroup [--gid ID] GROUP Add a user group addgroup --system [--gid ID] GROUP Add a system group adduser USER GROUP Add an existing user to an existing group general options: --quiet | -q don't give process information to stdout --force-badname allow usernames which do not match the NAME_REGEX[_SYSTEM] configuration variable --help | -h usage message --version | -v version number and copyright --conf | -c FILE use FILE as configuration file
删除用户 - deluser
deluser -r xx 加-r可删除该用户home目录,直接删除不删目录
新增用户组 - addgroup
-help查看详细参数
删除用户组 - delgroup
-help查看详细参数 su命令可切换到root命令, su otherUser 则切换至其他用户,对于有sudo权限的用户可直接使用sudo执行root身份的命令
其他
Linux用户及用户组都有对应的id,UID为用户id,GID为用户组id。
使用id可查看uid,gid,groups信息
1 2
xyz@iZ28rwmhep0Z:~$ id uid=1000(xyz) gid=1000(xyz) groups=1000(xyz)