linux文件及用戶(hù)管理的實(shí)例練習(xí)
1、顯示/etc目錄下,以非字母開(kāi)頭,后面跟了一個(gè)字母以及其它任意長(zhǎng)度任意字符的文件或目錄。
[root@centos7 etc]# ls -d /etc/[^[:alpha:]][:alpha:]*
2、復(fù)制/etc目錄下所有以p開(kāi)頭,以非數(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)換為大寫(xiě)后保存至/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、請(qǐng)總結(jié)描述用戶(hù)和組管理類(lèi)命令的使用方法并完成以下練習(xí):
(1)、創(chuàng)建組distro,其GID為2019;
[root@centos7 etc]# groupadd distro -g 2019
[root@centos7 etc]# getent group distro #驗(yàn)證distro的GID
distro:x:2019:
(2)、創(chuàng)建用戶(hù)mandriva, 其ID號(hào)為1005;基本組為distro;
[root@centos7 etc]# useradd mandriva -u 1005 -g distro
[root@centos7 etc]# id mandriva #驗(yàn)證mandriva的UID號(hào)和基本組
uid=1005(mandriva) gid=2019(distro) groups=2019(distro)
(3)、創(chuàng)建用戶(hù)mageia,其ID號(hào)為1100,家目錄為/home/Linux;
[root@centos7 etc]# useradd mageia -u 1100 -d /home/linux
[root@centos7 etc]# getent passwd mageia #驗(yàn)證結(jié)果
mageia:x:1100:1100::/home/linux:/bin/bash
(4)、給用戶(hù)mageia添加密碼,密碼為mageedu,并設(shè)置用戶(hù)密碼7天后過(guò)期
[root@centos7 etc]# echo "mageedu" | passwd mageia --stdin -x 7
[root@centos7 etc]# getent shadow mageia #驗(yàn)證結(jié)果
mageia:!!:18308:0:7:7:::
(5)、刪除mandriva,但保留其家目錄;
[root@centos7 etc]# userdel mandriva
[root@centos7 etc]# ls /home/ #驗(yàn)證結(jié)果 mandriva目錄依舊存在
diyoujia linux mandriva slackware test
(6)、創(chuàng)建用戶(hù)slackware,其ID號(hào)為2002,基本組為distro,附加組peguin;
[root@centos7 etc]# useradd slackware -u 2002 -g distro -G peguin
[root@centos7 etc]# id slackware #驗(yàn)證結(jié)果
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin)
(7)、修改slackware的默認(rèn)shell為/bin/tcsh;
[root@centos7 etc]# chsh slackware -s /bin/tcsh
[root@centos7 etc]# getent passwd slackware #驗(yàn)證結(jié)果
slackware:x:2002:2019::/home/slackware:/bin/tcsh
(8)、為用戶(hù)slackware新增附加組admins;
[root@centos7 etc]# usermod slackware -aG admins
[root@centos7 etc]# id slackware #驗(yàn)證結(jié)果
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin),2021(admins)
以上就是本次介紹的全部相關(guān)知識(shí)點(diǎn),感謝大家的學(xué)習(xí),希望腳本之家整理的內(nèi)容能夠幫助到大家。
- 淺析Linux常用文件管理命令
- Linux文件管理使用詳解
- Linux操作系統(tǒng)文件管理器的共享
- Linux文件/目錄的權(quán)限及歸屬管理使用
- linux文件目錄管理命令整理總結(jié)
- Linux賬號(hào)文件控制管理步驟詳解
- 你可能不知道的一些linux文件權(quán)限管理方法
- Linux文件權(quán)限與目錄管理詳解
- Linux du命令查看文件夾大小并按降序排列
- Linux中利用grep命令如何檢索文件內(nèi)容詳解
- Linux ftp 命令行中下載文件get與上傳文件put的命令應(yīng)用詳解
- Linux 刪除文件夾和文件的命令(強(qiáng)制刪除包括非空文件)
- linux文件管理命令實(shí)例分析【權(quán)限、創(chuàng)建、刪除、復(fù)制、移動(dòng)、搜索等】
相關(guān)文章
Linux遠(yuǎn)程訪(fǎng)問(wèn)及控制方式
SSH(Secure Shell)是一種協(xié)議,用于安全地通過(guò)不安全的網(wǎng)絡(luò)進(jìn)行遠(yuǎn)程登錄和其他網(wǎng)絡(luò)服務(wù),OpenSSH是SSH協(xié)議的一種開(kāi)源實(shí)現(xiàn),它支持?jǐn)?shù)據(jù)加密,能有效防止信息泄露,適用于多種操作系統(tǒng),SSH配置包括服務(wù)端和客戶(hù)端,可以通過(guò)密碼或密鑰對(duì)驗(yàn)證方式進(jìn)行身份驗(yàn)證2024-09-09linux系統(tǒng)中使用Vim刪除偶數(shù)行或者奇數(shù)行
vim中進(jìn)行奇偶數(shù)行操作,思路很簡(jiǎn)單,就是一次匹配兩行,然后刪除奇數(shù)行,刪除偶數(shù)行或者兩行合并。下面我們來(lái)看看具體怎么操作吧2014-08-08Linux安裝Redis實(shí)現(xiàn)過(guò)程及報(bào)錯(cuò)解決方案
這篇文章主要介紹了Linux安裝Redis實(shí)現(xiàn)過(guò)程及報(bào)錯(cuò)解決方案,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-08-08關(guān)于linux權(quán)限s權(quán)限和t權(quán)限詳解
本文介紹了linux系統(tǒng)內(nèi)的2個(gè)特殊權(quán)限s權(quán)限和t權(quán)限,簡(jiǎn)單易懂,大家可以詳細(xì)看看2018-03-03Linux提示網(wǎng)絡(luò)不可達(dá)問(wèn)題
這篇文章主要介紹了Linux提示網(wǎng)絡(luò)不可達(dá)問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-12-12