华南俳烁实业有限公司

考試首頁(yè) | 考試用書 | 培訓(xùn)課程 | 模擬考場(chǎng) | 考試論壇  
  當(dāng)前位置:Linux認(rèn)證 > 紅帽認(rèn)證 > 紅帽認(rèn)證輔導(dǎo) > 文章內(nèi)容
  

RHCE7認(rèn)證學(xué)習(xí)筆記:管理用戶和用戶組

來源:Linux社區(qū) [ 2016年2月16日 ] 【

創(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

RHCE7認(rèn)證學(xué)習(xí)筆記5——管理用戶和用戶組

組的管理:userdel刪除組,添加組 groupadd

首頁(yè) 1 2 尾頁(yè)
本文糾錯(cuò)】【告訴好友】【打印此文】【返回頂部
將考試網(wǎng)添加到收藏夾 | 每次上網(wǎng)自動(dòng)訪問考試網(wǎng) | 復(fù)制本頁(yè)地址,傳給QQ/MSN上的好友 | 申請(qǐng)鏈接 | 意見留言 TOP
關(guān)于本站  網(wǎng)站聲明  廣告服務(wù)  聯(lián)系方式  站內(nèi)導(dǎo)航  考試論壇
Copyright © 2007-2013 中華考試網(wǎng)(Examw.com) All Rights Reserved
法库县| 昌邑市| 武山县| 昌江| 江孜县| 恭城| 孝昌县| 樟树市| 玉环县| 文成县| 岚皋县| 枣庄市| 迭部县| 海宁市| 梓潼县| 西乌| 怀集县| 金湖县| 高唐县| 富源县| 开鲁县| 泸定县| 定西市| 吉木乃县| 古交市| 浙江省| 尤溪县| 白山市| 和平区| 比如县| 夹江县| 新沂市| 城固县| 德化县| 深水埗区| 英吉沙县| 福清市| 南昌市| 钟山县| 南投县| 磴口县|