第三周作業(yè)

顯示/etc目錄下,以非字母開頭,后面跟了一個字母以及其它任意長度任意字符的文件或目錄

  • ls /etc/[^[:alpha:]]

復(fù)制/etc目錄下所有以p開頭,以非數(shù)字結(jié)尾的文件或目錄到/tmp/mytest1目錄中。

  • cp -r /etc/p*[^[:digit:]] /tmp/mytest1/

將/etc/issue文件中的內(nèi)容轉(zhuǎn)換為大寫后保存至/tmp/issue.out文件中

  • cat /etc/issue|tr '[:lower:]' [:upper:] >> /tmp/issue.out

請總結(jié)描述用戶和組管理類命令的使用方法并完成以下練習(xí):

  • 創(chuàng)建組distro,其GID為2019
    [root@centos7 ~]#groupadd -g 2019 distrp
    [root@centos7 ~]#cat /etc/group|tail -1
    distrp:x:2019:

  • 創(chuàng)建用戶mandriva, 其ID號為1005;基本組為distro
    [root@centos7 ~]#useradd -u 1005 -g distrp mandriva
    [root@centos7 ~]#id mandriva
    uid=1005(mandriva) gid=2019(distrp) groups=2019(distrp)

  • 創(chuàng)建用戶mageia,其ID號為1100,家目錄為/home/linux
    [root@centos7 ~]#useradd -u 1100 -d /home/linux mageia
    [root@centos7 ~]#id mageia
    uid=1100(mageia) gid=1100(mageia) groups=1100(mageia)

  • 給用戶mageia添加密碼,密碼為mageedu,并設(shè)置用戶密碼7天后過期
    [root@centos7 ~]#echo magedu |passwd --stdin mageia
    Changing password for user mageia.
    passwd: all authentication tokens updated successfully.
    [root@centos7 ~]#passwd -x 7 mageia
    Adjusting aging data for user mageia.
    passwd: Success

  • 刪除mandriva,但保留其家目錄
    [root@centos7 ~]#userdel mageia
    [root@centos7 ~]#ls /home
    li linux mandriva

  • 創(chuàng)建用戶slackware,其ID號為2002,基本組為distro,附加組peguin
    [root@centos7 ~]#groupadd peguin
    [root@centos7 ~]#groupadd distro
    [root@centos7 ~]#useradd -u 2002 -g distro -G peguin slackware
    [root@centos7 ~]#id slackware
    uid=2002(slackware) gid=2021(distro) groups=2021(distro),2020(peguin)

  • 修改slackware的默認(rèn)shell為/bin/tcsh
    [root@centos7 ~]#usermod -s /bin/tcsh slackware
    [root@centos7 ~]#cat /etc/passwd | tail -1
    slackware:x:2002:2021::/home/slackware:/bin/tcsh

  • 為用戶slackware新增附加組admins
    [root@centos7 ~]#groupadd admins
    [root@centos7 ~]#id slackware
    uid=2002(slackware) gid=2021(distro) groups=2021(distro),2020(peguin)
    [root@centos7 ~]#usermod -aG admins slackware
    [root@centos7 ~]#id slackware
    uid=2002(slackware) gid=2021(distro) groups=2021(distro),2020(peguin),2022(admins)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容