人妖在线一区,国产日韩欧美一区二区综合在线,国产啪精品视频网站免费,欧美内射深插日本少妇

新聞動態(tài)

linux文件及用戶管理的實例練習

發(fā)布日期:2022-02-10 16:25 | 文章來源:源碼之家

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

[root@centos7 etc]# ls -d /etc/[^[:alpha:]][:alpha:]*

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

[root@centos7 etc]# mkdir /tmp/mytest1 && cp -a /etc/[p]*[^[:digit:]] /tmp/mytest1/
[root@centos7 etc]# ls /tmp/mytest1/ #查看結(jié)果
pam.d passwd- pinforc plymouth pnm2ppa.conf postfix prelink.conf.d profile protocols purple
passwd pbm2ppa.conf pki pm popt.d ppp printcap profile.d pulse python

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

[root@centos7 etc]# tr 'a-z' 'A-Z' < /etc/issue >/tmp/issue.out
[root@centos7 etc]# cat /tmp/issue.out 查看內(nèi)容
\S
KERNEL \R ON AN \M

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

(1)、創(chuàng)建組distro,其GID為2019;

[root@centos7 etc]# groupadd distro -g 2019
[root@centos7 etc]# getent group distro #驗證distro的GID
distro:x:2019:

(2)、創(chuàng)建用戶mandriva, 其ID號為1005;基本組為distro;

[root@centos7 etc]# useradd mandriva -u 1005 -g distro
[root@centos7 etc]# id mandriva #驗證mandriva的UID號和基本組
uid=1005(mandriva) gid=2019(distro) groups=2019(distro)

(3)、創(chuàng)建用戶mageia,其ID號為1100,家目錄為/home/Linux;

[root@centos7 etc]# useradd mageia -u 1100 -d /home/linux
[root@centos7 etc]# getent passwd mageia #驗證結(jié)果
mageia:x:1100:1100::/home/linux:/bin/bash

(4)、給用戶mageia添加密碼,密碼為mageedu,并設置用戶密碼7天后過期

[root@centos7 etc]# echo "mageedu" | passwd mageia --stdin -x 7
[root@centos7 etc]# getent shadow mageia #驗證結(jié)果
mageia:!!:18308:0:7:7:::

(5)、刪除mandriva,但保留其家目錄;

[root@centos7 etc]# userdel mandriva
[root@centos7 etc]# ls /home/ #驗證結(jié)果 mandriva目錄依舊存在
diyoujia linux mandriva slackware test

(6)、創(chuàng)建用戶slackware,其ID號為2002,基本組為distro,附加組peguin;

[root@centos7 etc]# useradd slackware -u 2002 -g distro -G peguin
[root@centos7 etc]# id slackware #驗證結(jié)果
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin)

(7)、修改slackware的默認shell為/bin/tcsh;

[root@centos7 etc]# chsh slackware -s /bin/tcsh
[root@centos7 etc]# getent passwd slackware #驗證結(jié)果
slackware:x:2002:2019::/home/slackware:/bin/tcsh

(8)、為用戶slackware新增附加組admins;

[root@centos7 etc]# usermod slackware -aG admins
[root@centos7 etc]# id slackware #驗證結(jié)果
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin),2021(admins)

以上就是本次介紹的全部相關知識點,感謝大家的學習,希望本站整理的內(nèi)容能夠幫助到大家。

香港服務器租用

版權聲明:本站文章來源標注為YINGSOO的內(nèi)容版權均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務器上建立鏡像,否則將依法追究法律責任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學習參考,不代表本站立場,如有內(nèi)容涉嫌侵權,請聯(lián)系alex-e#qq.com處理。

實時開通

自選配置、實時開通

免備案

全球線路精選!

全天候客戶服務

7x24全年不間斷在線

專屬顧問服務

1對1客戶咨詢顧問

在線
客服

在線客服:7*24小時在線

客服
熱線

400-630-3752
7*24小時客服服務熱線

關注
微信

關注官方微信
頂部