創(chuàng)建用戶時(shí)一般不直接指定-p設(shè)置密碼,而是在創(chuàng)建用戶后,使用echo 'password'|passwd --stdin username 設(shè)置密碼
修改用戶屬性時(shí),也可以使用usermod,與useradd和chage的選項(xiàng)類似:
[root@clz ~]# usermod --help
-c, --comment COMMENT new value of the GECOS field 修改全稱
-d, --home HOME_DIR new home directory for the user account修改家目錄
-e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
-f, --inactive INACTIVE set password inactive after expiration
to INACTIVE
-g, --gid GROUP force use GROUP as new primary group
-G, --groups GROUPS new list of supplementary GROUPS
-l, --login NEW_LOGIN new value of the login name
-L, --lock lock the user account
-m, --move-home move contents of the home directory to the
new location (use only with -d)
-p, --password PASSWORD use encrypted password for the new password
-s, --shell SHELL new login shell for the user account
-u, --uid UID new UID for the user account
-U, --unlock unlock the user account
手工創(chuàng)建用戶的家目錄,例如:
當(dāng)前用戶的家目錄為:/home/tom
[tom@clz ~]$ pwd
/home/tom
修改用戶家目錄為:/home/tom1
[root@clz ~]# usermod -d /home/tom1 tom
此時(shí)切換到tom用戶,因?yàn)樾碌募夷夸洓]有創(chuàng)建,會(huì)報(bào)錯(cuò):
手工創(chuàng)建家目錄:
[root@clz ~]# mkdir /home/tom1
將/etc/skell下面的隱藏文件拷貝到新的家目錄:
[root@clz ~]# cp -a /etc/skel/.[^.]* /home/tom1
修改家目錄文件的屬主屬組,之后再切換用戶即可:
[root@clz home]# chown tom.tom -R tom1
查看用戶屬于哪些組,使用groups命令:
[root@clz home]# groups tom
tom : tom
為用戶添加多個(gè)組:
[root@clz tom1]# usermod -a -G wheel tom
[root@clz tom1]# groups tom
tom : tom wheel
修改用戶的主組 usermod -g:
修改刪除用戶的屬組,可以使用gpasswd命令:
[root@clz tom1]# gpasswd --help
-a, --add USER add USER to GROUP
-d, --delete USER remove USER from GROUP 將用戶刪除某個(gè)組
-r, --remove-password remove the GROUP's password
-R, --restrict restrict access to GROUP to its members
-M, --members USER,... set the list of members of GROUP
用戶的默認(rèn)的登陸時(shí)間屬性在/etc/login.defs
組的管理:userdel刪除組,添加組 groupadd
2015職稱計(jì)算機(jī)考試書PowerPoint2007中 .. 定價(jià):¥45 優(yōu)惠價(jià):¥42 更多書籍 | |
2015年全國(guó)職稱計(jì)算機(jī)考試教材(2007模 .. 定價(jià):¥225 優(yōu)惠價(jià):¥213 更多書籍 |