1椿息、groupadd : create a new group
? ??????????groupadd [options] group
? ?????????? -g, --gid GID :創(chuàng)建用戶組時指定gid
? ? ? ? ? ? ?-r, --system: Create a system group.
2、goupdel:delete a group????????
?????????????groupdel [options] GROUP
3坷衍、useradd:?create a new user or update default new user information
????????????useradd [options] LOGIN_NAME
? ? ? ???? useradd -D
? ? ? ? ? ?useradd -D [options]
? ? ? ? ? ? 常用選項:
????????????-c, --comment COMMENT:添加用戶描述
? ??????????-d, --home-dir HOME_DIR:設置用戶家目錄
? ??????????-e, --expiredate EXPIRE_DATE:設置用戶過期時間寝优,格式:YYYY-MM-DD
? ??????????-g, --gid GROUP:設置用戶主組
? ??????????-G, --groups GROUP1[,GROUP2,...[,GROUPN]]],指定用戶的附加組枫耳,多個組之間用逗號
????????????????????分割
????????????-r, --system :? ? ?Create a system account. 創(chuàng)建系統(tǒng)用戶
? ??????????-s, --shell SHELL:指定用戶默認shell
? ??????????-u, --uid UID: 指定用戶的uid
4乏矾、passwd:?update user's authentication tokens
? ??????????passwd [-k] [-l] [-u [-f]] [-d] [-e] [-n mindays] [-x maxdays] [-w warndays] [-i inactivedays] [-S] [--stdin] [username]
? ??????????-l, --lock : 鎖定用戶密碼
? ??????????-u, --unlock :解鎖用戶密碼
? ??????????-d, --delete :清空用戶密碼
? ??????????-e, --expire : 設置用戶密碼過期日期,Available to? root only.
? ??????????-n, --minimum DAYS 迁杨,?設置用戶密碼最短期限钻心,Available to? root only.
? ??????????-x, --maximum DAYS ,設置用戶密碼最長期限铅协,Available to? root only.
? ??????????-w, --warning DAYS捷沸,設置用戶密碼告警期限,Available to? root only.
?5狐史、userdel:? delete a user account and related files
????????????userdel [options] LOGIN_NAME
???????????? -r, --remove , 刪除用戶時一并刪除其家目錄? ? ? ? ? ?
6痒给、usermod:?modify a user account
? ??????????usermod [options] LOGINNAME
? ??????????-u, --uid UID
????????????-G, --groups GROUP1[,GROUP2,...[,GROUPN]]]:修改用戶的附加組;原來的附加組將被覆蓋骏全;可與-a 結合使用苍柏,則表示給用戶追加新的附加組
????????????-a, --append,給用戶添加新組. 只與 -G 選項一起使用
????????????-c, --comment COMMENT:修改用戶描述
????????????-d, --home HOME_DIR:修改用戶家目錄,但家目錄中的文件不會移動姜贡,此時結合-m 實現(xiàn)试吁;
????????????-m, --move-home:只能與-d 選項一同使用,用于將原來的家目錄中文件移動到新的家目錄中
????????????-s, --shell SHELL:修改用戶的默認shell
????????????-L, --lock:Lock a user's password. This puts a '!' in front of the encrypted password
????????????-U, --unlock: Unlock a user's password. This removes the '!' in front of the encrypted password.?
????????????-l, --login NEW_LOGIN:修改用戶名
????????????-f, --inactive INACTIVE
????????????-e, --expiredate EXPIRE_DATE
7楼咳、gpasswd:? administer /etc/group and /etc/gshadow
? ??????-a, --add user
? ? ? ? ? Add the user to the named group.
? ? ? ? -d, --delete user
? ? ? ? ? Remove the user from the named group.
? ? ? -r, --remove-password: 清空用戶組密碼熄捍,只在使用newgrp 臨時切換到一個組時。
? ? ? ? ? Remove the password from the named group. The group password will be empty. Only group members will be allowed to use newgrp to join the named group.
? ? ? -M, --members user,...
? ? ? ? ? Set the list of group members.
8母怜、 id : print real and effective user and group IDs/顯示用戶真實有效的ID
????????????id [OPTION]... [USER]
????????????-g, --group,print only the effective group ID 治唤, 只顯示有效的gid
????????????-G, --groups , print all group IDs,顯示所有的用戶組,包括主組和附加組
????????????-n, --name , print a name instead of a number, for -ugG ,顯示用戶組的名字而不是id
????????????-u, --user , print only the effective user ID 糙申, 只顯示有效的uid
示例:
(1)、創(chuàng)建組distro船惨,其GID為2016柜裸;
? ? ? ? ? ? >>>groupadd -g 2016 distro
? ? ? ? ? ?>>> tail -1 /etc/group
????????????????????distro:x:2016:
? (2)、創(chuàng)建用戶mandriva, 其ID號為1005粱锐;基本組為distro疙挺;
? ? ? ? ? ? >>>useradd mandriva -u 1005 -g distro
? ? ? ? ? ? >>>tail -1 /etc/passwd
? ? ? ? ? ? >>>mandriva:x:1005:2016::/home/mandriva:/bin/bash
? (3)、創(chuàng)建用戶mageia怜浅,其ID號為1100铐然,家目錄為/home/linux;
? ? ? ? ? ? >>>useradd -u 1100 -d /home/linux mageia
? ? ? ? ? ? >>>tail -1 /etc/passwd
? ? ? ? ? ? >>>mageia:x:1100:1100::/home/linux:/bin/bash
? (4)蔬崩、給用戶mageia添加密碼,密碼為mageedu搀暑;
? ? ? ? ? ? >>>echo "mageedu" | passwd --stdin mageia
????????????????????Changing password for user mageia.
????????????????????passwd: all authentication tokens updated successfully.
? (5)沥阳、刪除mandriva,但保留其家目錄自点;
? ?????????>>> userdel mandriva
? ? ? ? ? >>> ll /home/mandriva -d
????????????drwx------. 2 1005 distro 62 Aug 30 17:47 /home/mandriva
? ? ? ? >>> id mandriva
????????????id: mandriva: no such user
? (6)桐罕、創(chuàng)建用戶slackware,其ID號為2002桂敛,基本組為distro功炮,附加組peguin;
? ??????>>>groupadd peguin
????????>>>useradd slackware -u 2002 -g distro -G peguin
? ? ? ? >>>tail -1 /etc/passwd
????????????????slackware:x:2002:2016::/home/slackware:/bin/bash
? ? ? ? ?>>>tail -1 /etc/group
????????????????peguin:x:5003:slackware
? (7)术唬、修改slackware的默認shell為/bin/tcsh薪伏;
? ???????>>>usermod -s /bin/tcsh slackware
? ? ? ? >>> tail -1 /etc/passwd
????????????slackware:x:2002:2016::/home/slackware:/bin/tcsh
? (8)、為用戶slackware新增附加組admins粗仓;
? ???????>>>groupadd admins
????????????????usermod -G admins slackware
? ? ? ? >>>tail -1 /etc/group
????????????????admins:x:5004:slackware