马哥运维学习作业(二)
1、Linux上的文件管理類(lèi)命令都有哪些,其常用的使用方法及其相關(guān)示例演示。
答:文件管理類(lèi)命令有:cp,mv,rm
cp
命令功能:將一個(gè)或多個(gè)源文件或目錄復(fù)制到指定的目標(biāo)文件或目錄
命令格式:
? ? ? cp [OPTION]... [-T] SOURCE DEST ? ? ?//cp [選項(xiàng)]…[-T]源目的
? ? ? cp [OPTION]... SOURCE... DIRECTORY ? // cp [選項(xiàng)]…源…目錄
? ? ? cp [OPTION]... -t DIRECTORY SOURCE... ?// cp [選項(xiàng)]…-t 目錄 源…
常用選項(xiàng):
????-i:交互式復(fù)制,即覆蓋之前提醒用戶(hù)確認(rèn)
????-f:強(qiáng)制覆蓋目標(biāo)文件
????-r:遞歸復(fù)制目錄(大寫(xiě)R也是這個(gè)功能)
????-d:--no-dereference --preserv=links 復(fù)制符號(hào)鏈接文件本身,而非其指向的源文件
????-a:歸檔,相當(dāng)于-dR --preserve=all,archive,用于實(shí)現(xiàn)歸檔;
????--preserve[=ATTR_LIST]
????mode:權(quán)限 ? ?#默認(rèn)
????ownership:屬主和屬組 ? ? #默認(rèn)
????timestamps:時(shí)間戳 ? ? ?#默認(rèn)
????context:安全標(biāo)簽
????xattr:擴(kuò)展屬性
????links:符號(hào)鏈接
????all:上述所有屬性
????-p:--preserv=mode,ownership,timestamp
????-v:--verbose
命令示例:
(1)復(fù)制和改名
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | [root@C7-1?~]#?cp?anaconda-ks.cfg?/tmp/?????????#復(fù)制anaconda-ks.cfg到/tmp目錄下 [root@C7-1?~]#?ls?/tmp/?????????????????????????#ls查看已復(fù)制 anaconda-ks.cfg [root@C7-1?~]#?cp?anaconda-ks.cfg?/tmp/?????????#再一次執(zhí)行此命令,沒(méi)有加入-i參數(shù),也會(huì)提示用戶(hù)確認(rèn) cp:?overwrite?'/tmp/anaconda-ks.cfg'??y [root@C7-1?~]#?alias????????????????????????????#接上,因?yàn)閏p的別名默認(rèn)被系統(tǒng)設(shè)置為cp?-i,執(zhí)行cp就相當(dāng)于cp?-i alias?cp='cp?-i' alias?egrep='egrep?--color=auto' alias?fgrep='fgrep?--color=auto' alias?grep='grep?--color=auto' alias?l.='ls?-d?.*?--color=auto' alias?ll='ls?-l?--color=auto' alias?ls='ls?--color=auto' alias?mv='mv?-i' alias?rm='rm?-i' alias?which='alias?|?/usr/bin/which?--tty-only?--read-alias?--show-dot?--show-tilde' [root@C7-1?~]#?cp?anaconda-ks.cfg?/tmp/an.cfg???#復(fù)制anaconda-ks.cfg到/tmp目錄下并改名為an.cfg [root@C7-1?~]#?ls?/tmp/?????????????????????????#查看已復(fù)制并改名 an.cfg??anaconda-ks.cfg |
(2)使用-r參數(shù),復(fù)制目錄
| 1 2 3 4 5 | [root@C7-1?~]#?cp?/test1/?/tmp??????????????????#復(fù)制目錄時(shí),如果不加入-r參數(shù)會(huì)出現(xiàn)如下錯(cuò)誤提示 cp:?omitting?directory?'/test1/' [root@C7-1?~]#?cp?-r?/test1/?/tmp???????????????#復(fù)制目錄,要使用-r參數(shù),遞歸復(fù)制才可以 [root@C7-1?~]#?ls?/tmp/test1/???????????????????#如果源是目錄,目標(biāo)則創(chuàng)建指定的目錄,并復(fù)制源目錄中所有文件至目標(biāo)目錄中 1.txt??2.txt |
(3)使用-a參數(shù),把權(quán)限等都復(fù)制過(guò)來(lái)
| 1 2 3 4 5 6 7 8 9 10 11 | [root@C7-1?tmp]#?ls?-l?/var/log/wtmp?????????????????????????#首先查看/var/log/wtmp的權(quán)限為-rw-rw-r-- -rw-rw-r--.?1?root?utmp?41088?Aug?23?17:26?/var/log/wtmp [root@C7-1?tmp]#?cp?/var/log/wtmp?.??????????????????????????#復(fù)制/var/log目錄下的wtmp到當(dāng)前目錄下(.代表當(dāng)前目錄) [root@C7-1?tmp]#?ls?-l???????????????????????????????????????#查看wtmp權(quán)限為-rw-r--r--,和原本不一樣 total?44 -rw-r--r--.?1?root?root?41088?Aug?23?17:44?wtmp [root@C7-1?tmp]#?cp?-a?/var/log/wtmp?.???????????????????????#這次復(fù)制使用-a參數(shù) cp:?overwrite?'./wtmp'??y [root@C7-1?tmp]#?ls?-l???????????????????????????????????????#查看wtmp權(quán)限和/var/log下一樣了,都為-rw-rw-r-- total?44 -rw-rw-r--.?1?root?utmp?41088?Aug?23?17:26?wtmp |
mv
命令功能:為文件或目錄改名,或?qū)⑽募蚰夸浺苿?dòng)到其它位置
命令格式:
? ? ? ?mv [OPTION]... [-T] SOURCE DEST
? ? ? ?mv [OPTION]... SOURCE... DIRECTORY
? ? ? ?mv [OPTION]... -t DIRECTORY SOURCE...
常用選項(xiàng):
????????-i:交互式
????????-f:force強(qiáng)制覆蓋,不提示
????????-v:顯示移動(dòng)過(guò)程
? ? ? ? -u:若目標(biāo)文件已經(jīng)存在,且 source 比較新,才會(huì)更新(update)
? ? ? ? -b:若需覆蓋文件,則覆蓋前先行備份
? ? ? ? -t:即指定mv的目標(biāo)目錄,該選項(xiàng)適用于移動(dòng)多個(gè)源文件到一個(gè)目錄的情況,此時(shí)目標(biāo)目錄在前,源文件在后
命令示例:
(1)移動(dòng)文件
| 1 2 3 4 5 6 | [root@C7-1?tmp]#?mv?wtmp?test/????????????#移動(dòng)當(dāng)前目錄的wtmp文件到test目錄下 [root@C7-1?tmp]#?ls mylinux??test??wtmp_1??wtmp_2 [root@C7-1?tmp]#?ls?-l?test/??????????????#wtmp文件已移動(dòng)到test目錄下 total?44 -rw-rw-r--.?1?root?utmp?41088?Aug?23?17:26?wtmp |
(2)使用-f參數(shù),強(qiáng)制移動(dòng)不提示
| 1 2 3 4 5 6 | [root@C7-1?tmp]#?touch?wtmp???????????????#在tmp下再創(chuàng)建一個(gè)wtmp [root@C7-1?tmp]#?mv?wtmp?test/????????????#不加參數(shù)移動(dòng)到test下,由于之前已經(jīng)復(fù)制過(guò),所以出現(xiàn)提示,輸入n取消。(mv是mv?-i的別名。) mv:?overwrite?'test/wtmp'??n [root@C7-1?tmp]#?mv?-f?wtmp?test/?????????#加入-f參數(shù),則不會(huì)提示,直接移動(dòng)過(guò)去了 [root@C7-1?tmp]#?ls?test/????????????????? wtmp |
rm
命令功能:刪除一個(gè)目錄中的一個(gè)或多個(gè)文件或目錄
命令格式:rm [OPTION]... FILE...
命令選項(xiàng):
????-i:interactive交互式
????-f:force強(qiáng)制刪除
????-r:recursive遞歸刪除
刪除目錄:rm -rf /PATH/TO/DIR
危險(xiǎn)操作:rm -rf /*(6和7有提示,5沒(méi)有)
命令示例:
(1)使用-f參數(shù),強(qiáng)制刪除文件
| 1 2 3 4 5 6 7 | [root@C7-1?tmp]#?ls mylinux??test??wtmp_1??wtmp_2 [root@C7-1?tmp]#?rm?wtmp_1???????????????#不加參數(shù)刪除wtmp_2文件,由于rm是rm?-i的別名,所以會(huì)有如下的提示,按n取消。 rm:?remove?regular?file?'wtmp_1'??n [root@C7-1?tmp]#?rm?-f?wtmp_1????????????#加入-f參數(shù),則刪除時(shí)不會(huì)出現(xiàn)提示 [root@C7-1?tmp]#?ls??????????????????????#wtmp_2文件已刪除 mylinux??test??wtmp_2 |
(2)使用-r參數(shù),遞歸刪除目錄
| 1 2 3 4 5 6 7 8 9 10 | [root@C7-1?tmp]#?ls?-l??????????????????????????????????#下面顯示test是目錄,里面也有文件 total?48 drwxr-xr-x.?17?root?root??4096?Aug?23?18:13?mylinux drwxr-xr-x.??2?root?root????17?Aug?23?18:36?test -rw-r--r--.??1?root?root?41088?Aug?23?17:51?wtmp_2 [root@C7-1?tmp]#?rm?test????????????????????????????????#不加參數(shù),提示不能刪除test目錄 rm:?cannot?remove?'test':?Is?a?directory [root@C7-1?tmp]#?rm?-rf?test????????????????????????????#加入-r參數(shù)(同時(shí)加上-f),刪除test目錄 [root@C7-1?tmp]#?ls?????????????????????????????????????#test目錄已刪除完成 mylinux??wtmp_2 |
2、bash的工作特性之命令執(zhí)行狀態(tài)返回值和命令行展開(kāi)所涉及的內(nèi)容及其示例演示。
答:bash命令執(zhí)行完成后會(huì)有一個(gè)返回值,保存在$?中,如果正常執(zhí)行,返回0,錯(cuò)誤則返回值為1-255之間的數(shù)字。當(dāng)執(zhí)行命令后,執(zhí)行echo $?查看。
示例:
| 1 2 3 4 5 6 7 8 9 10 | [root@C7-1?tmp]#?ls?-l??????????????????????????????????#輸入一個(gè)正確的命令查看當(dāng)前目錄 total?48 drwxr-xr-x.?17?root?root??4096?Aug?23?18:13?mylinux -rw-r--r--.??1?root?root?41088?Aug?23?17:51?wtmp_2 [root@C7-1?tmp]#?echo?$?????????????????????????????????#查看,下面顯示0 0 [root@C7-1?tmp]#?lsss?-l????????????????????????????????#有意把ls輸入錯(cuò)誤,使用命令不能執(zhí)行 -bash:?lsss:?a‰°‘¤ [root@C7-1?tmp]#?echo?$?????????????????????????????????#查看,下面顯示127的錯(cuò)誤返回值 127 |
3、請(qǐng)使用命令行展開(kāi)功能來(lái)完成以下練習(xí):
(1)、創(chuàng)建/tmp目錄下的:a_c, a_d, b_c, b_d
(2)、創(chuàng)建/tmp/mylinux目錄下的:
mylinux/
├── bin
├── boot
│ ? └── grub
├── dev
├── etc
│ ? ├── rc.d
│ ? │ ? └── init.d
│ ? └── sysconfig
│ ? ? ? └── network-scripts
├── lib
│ ? └── modules
├── lib64
├── proc
├── sbin
├── sys
├── tmp
├── usr
│ ? └── local
│ ? ? ? ├── bin
│ ? ? ? └── sbin
└── var
├── lock
├── log
└── run
答:
(1)
| 1 2 3 4 5 6 7 | [root@cat?~]#?mkdir?-v?/tmp/{a,b}_{c,d} mkdir:?created?directory?`/tmp/a_c' mkdir:?created?directory?`/tmp/a_d' mkdir:?created?directory?`/tmp/b_c' mkdir:?created?directory?`/tmp/b_d' [root@cat?~]#?ls?-d?/tmp/{a,b}_{c,d} /tmp/a_c??/tmp/a_d??/tmp/b_c??/tmp/b_d |
(2)
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | [root@cat?~]#?mkdir?-pv?/tmp/mylinux/{bin,boot/grub,dev,etc/{rc.d/init.d,sysconfig/network-scripts},lib/modules,lib64,proc,sbin,sys,tmp,usr/local/{bin,sbin},var,lock,log,run} mkdir:?created?directory?`/tmp/mylinux' mkdir:?created?directory?`/tmp/mylinux/bin' mkdir:?created?directory?`/tmp/mylinux/boot' mkdir:?created?directory?`/tmp/mylinux/boot/grub' mkdir:?created?directory?`/tmp/mylinux/dev' mkdir:?created?directory?`/tmp/mylinux/etc' mkdir:?created?directory?`/tmp/mylinux/etc/rc.d' mkdir:?created?directory?`/tmp/mylinux/etc/rc.d/init.d' mkdir:?created?directory?`/tmp/mylinux/etc/sysconfig' mkdir:?created?directory?`/tmp/mylinux/etc/sysconfig/network-scripts' mkdir:?created?directory?`/tmp/mylinux/lib' mkdir:?created?directory?`/tmp/mylinux/lib/modules' mkdir:?created?directory?`/tmp/mylinux/lib64' mkdir:?created?directory?`/tmp/mylinux/proc' mkdir:?created?directory?`/tmp/mylinux/sbin' mkdir:?created?directory?`/tmp/mylinux/sys' mkdir:?created?directory?`/tmp/mylinux/tmp' mkdir:?created?directory?`/tmp/mylinux/usr' mkdir:?created?directory?`/tmp/mylinux/usr/local' mkdir:?created?directory?`/tmp/mylinux/usr/local/bin' mkdir:?created?directory?`/tmp/mylinux/usr/local/sbin' mkdir:?created?directory?`/tmp/mylinux/var' mkdir:?created?directory?`/tmp/mylinux/lock' mkdir:?created?directory?`/tmp/mylinux/log' mkdir:?created?directory?`/tmp/mylinux/run' [root@C7-1?~]#?tree?/tmp/mylinux/??????????????????#使用tree命令查看目錄結(jié)構(gòu) /tmp/mylinux/ |--?bin |--?boot |???`--?grub |--?dev |--?etc |???|--?rc.d |???|???`--?init.d |???`--?sysconfig |???????`--?network-scripts |--?lib |???`--?modules |--?lib64 |--?lock |--?log |--?proc |--?run |--?sbin |--?sys |--?tmp |--?usr |???`--?local |???????|--?bin |???????`--?sbin `--?var 24?directories,?0?files |
4、文件的元數(shù)據(jù)信息有哪些,分別表示什么含義,如何查看?如何修改文件的時(shí)間戳信息。
答:
文件的元數(shù)據(jù)是指文件的屬性、大小、創(chuàng)建時(shí)間、訪(fǎng)問(wèn)時(shí)間、屬主屬組等信息。
三個(gè)時(shí)間戳:
? ? ? ? ?Access time: 訪(fǎng)問(wèn)時(shí)間,簡(jiǎn)寫(xiě)為atime,讀取文件內(nèi)容
? ? ? ? ?Modify time: 修改時(shí)間,mtime,改變文件內(nèi)容(數(shù)據(jù))
? ? ? ? ?Change time: 改動(dòng)時(shí)間,ctime,元數(shù)據(jù)發(fā)生改變
使用stat命令查看元數(shù)據(jù)和時(shí)間戳信息
例:
| 1 2 3 4 5 6 7 8 9 | [root@C7-1?tmp]#?stat?wtmp_2? ??File:?'wtmp_2' ??Size:?41088???????????Blocks:?88?????????IO?Block:?4096???regular?file Device:?fd00h/64768d????Inode:?2169????????Links:?1 Access:?(0644/-rw-r--r--)??Uid:?(????0/????root)???Gid:?(????0/????root) Context:?unconfined_u:object_r:user_tmp_t:s0 Access:?2016-08-23?17:51:54.289738407?+0800 Modify:?2016-08-23?17:51:54.289738407?+0800 Change:?2016-08-23?17:51:54.289738407?+0800 |
修改時(shí)間戳信息
(1)使用touch修改
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | [root@C7-1?tmp]#?stat?wtmp_2?????????????#查看信息 ??File:?'wtmp_2' ??Size:?41088???????????Blocks:?88?????????IO?Block:?4096???regular?file Device:?fd00h/64768d????Inode:?2169????????Links:?1 Access:?(0644/-rw-r--r--)??Uid:?(????0/????root)???Gid:?(????0/????root) Context:?unconfined_u:object_r:user_tmp_t:s0 Access:?2016-08-23?17:51:54.289738407?+0800 Modify:?2016-08-23?17:51:54.289738407?+0800 Change:?2016-08-23?17:51:54.289738407?+0800 ?Birth:?- [root@C7-1?tmp]#?touch?wtmp_2????????????#touch一下這個(gè)文件 [root@C7-1?tmp]#?stat?wtmp_2?????????????#三個(gè)時(shí)間都變成當(dāng)前的時(shí)間了 ??File:?'wtmp_2' ??Size:?41088???????????Blocks:?88?????????IO?Block:?4096???regular?file Device:?fd00h/64768d????Inode:?2169????????Links:?1 Access:?(0644/-rw-r--r--)??Uid:?(????0/????root)???Gid:?(????0/????root) Context:?unconfined_u:object_r:user_tmp_t:s0 Access:?2016-08-23?20:27:02.444183598?+0800 Modify:?2016-08-23?20:27:02.444183598?+0800 Change:?2016-08-23?20:27:02.444183598?+0800 ?Birth:?- |
(2)使用-a參數(shù),修改訪(fǎng)問(wèn)時(shí)間
| 1 2 3 4 5 6 7 8 9 10 11 | [root@C7-1?tmp]#?touch?-a?wtmp_2??????????#使用-a參數(shù),修改訪(fǎng)問(wèn)時(shí)間 [root@C7-1?tmp]#?stat?wtmp_2??????????????#因?yàn)樵L(fǎng)問(wèn)時(shí)間變了,改動(dòng)時(shí)間也會(huì)隨著變 ??File:?'wtmp_2' ??Size:?41088???????????Blocks:?88?????????IO?Block:?4096???regular?file Device:?fd00h/64768d????Inode:?2169????????Links:?1 Access:?(0644/-rw-r--r--)??Uid:?(????0/????root)???Gid:?(????0/????root) Context:?unconfined_u:object_r:user_tmp_t:s0 Access:?2016-08-23?20:30:36.898170816?+0800 Modify:?2016-08-23?20:27:02.444183598?+0800 Change:?2016-08-23?20:30:36.898170816?+0800 ?Birth:?- |
(3)使用-m -t參數(shù)改修改時(shí)間
| 1 2 3 4 5 6 7 8 9 10 11 | [root@C7-1?tmp]#?touch?-m?-t?201306061020.30?wtmp_2???????#使用-m?-t把時(shí)間改為指定的時(shí)間 [root@C7-1?tmp]#?stat?wtmp_2??????????????????????????????#修改時(shí)間以改為上面指定的時(shí)間 ??File:?'wtmp_2' ??Size:?41088???????????Blocks:?88?????????IO?Block:?4096???regular?file Device:?fd00h/64768d????Inode:?2169????????Links:?1 Access:?(0644/-rw-r--r--)??Uid:?(????0/????root)???Gid:?(????0/????root) Context:?unconfined_u:object_r:user_tmp_t:s0 Access:?2016-08-23?20:30:36.898170816?+0800 Modify:?2013-06-06?10:20:30.000000000?+0800??????????? Change:?2016-08-23?20:35:26.698153542?+0800 ?Birth:?- |
5、如何定義一個(gè)命令的別名,如何在命令中引用另一個(gè)命令的執(zhí)行結(jié)果?
答:
(1)定義命令別名通過(guò)alias命令實(shí)現(xiàn):
alias NAME='VALUE'
例:定義iptime別名為查看網(wǎng)卡信息的命令
| 1 | [root@C7-1?tmp]#?alias?iptime='cat?/etc/sysconfig/network-scripts/ifcfg-eno16777736' |
(2)命令中引用另一個(gè)命令,可使用管道符“|”來(lái)實(shí)現(xiàn)
例:上面已設(shè)置iptime別名,通過(guò)管道符把來(lái)網(wǎng)卡信息傳遞給tail命令,通過(guò)tail -3來(lái)顯示后3行?
| 1 2 3 4 | [root@C7-1?tmp]#?iptime?|?tail?-3 IPADDR=10.3.20.71 NETMASK=255.255.255.0 GATEWAY=10.3.20.1 |
6、顯示/var目錄下所有以l開(kāi)頭,以一個(gè)小寫(xiě)字母結(jié)尾,且中間至少出現(xiàn)一位數(shù)字(可以有其它字符)的文件或目錄。
| 1 2 3 | [root@C7-1?tmp]#?touch?/var/l23dvad?????????????????? [root@C7-1?tmp]#?ls?-d?/var/l*[[:digit:]]*[[:lower:]] /var/l23dvad |
7、顯示/etc目錄下,以任意一個(gè)數(shù)字開(kāi)頭,且以非數(shù)字結(jié)尾的文件或目錄。
| 1 2 3 4 5 | [root@C7-1?~]#?touch?/etc/66dfdsdfd [root@C7-1?~]#?ls?-d?/etc/[0-9]*[^0-9] /etc/66dfdsdfd [root@C7-1?~]#?ls?-d?/etc/[[:digit:]]*[^[:digit:]] /etc/66dfdsdfd |
8、顯示/etc目錄下,以非字母開(kāi)頭,后面跟了一個(gè)字母以及其它任意長(zhǎng)度任意字符的文件或目錄。
| 1 2 3 | [root@C7-1?~]#?touch?/etc/6dfdsdfd? [root@C7-1?~]#?ls?-d?/etc/[^[:alpha:]][[:alpha:]]* /etc/6dfdsdfd |
9、在/tmp目錄下創(chuàng)建以tfile開(kāi)頭,后跟當(dāng)前日期和時(shí)間的文件,文件名形如:tfile-2016-08-06-09-32-22。
| 1 2 3 | [root@C7-1?~]#?touch?/tmp/tfile-`date?+"%Y-%m-%d-%H-%M-%S"` [root@C7-1?~]#?ls?-d?/tmp/tf*[0-9]??? /tmp/tfile-2016-08-23-21-10-15 |
10、復(fù)制/etc目錄下所有以p開(kāi)頭,以非數(shù)字結(jié)尾的文件或目錄到/tmp/mytest1目錄中。
| 1 2 3 4 5 6 7 8 9 10 11 | [root@C7-1?~]#?mkdir?/tmp/mytest1????????????????????????#如題目要求創(chuàng)建/tmp/mytest1目錄 [root@C7-1?~]#?ls?-d?/etc/p*[^[:digit:]]?????????????????#先用ls查看如題目要求的文件,正確后再按下面使用cp命令復(fù)制????????????????? /etc/pam.d????/etc/pki???????/etc/popt.d???/etc/prelink.conf.d??/etc/profile.d /etc/passwd???/etc/plymouth??/etc/postfix??/etc/printcap????????/etc/protocols /etc/passwd-??/etc/pm????????/etc/ppp??????/etc/profile?????????/etc/python [root@C7-1?~]#?cp?-r?/etc/p*[^[:digit:]]?/tmp/mytest1/ [root@C7-1?~]#?ls?-d?/tmp/mytest1/p*[^[:digit:]] /tmp/mytest1/pam.d????/tmp/mytest1/plymouth??/tmp/mytest1/ppp?????????????/tmp/mytest1/profile.d /tmp/mytest1/passwd???/tmp/mytest1/pm????????/tmp/mytest1/prelink.conf.d??/tmp/mytest1/protocols /tmp/mytest1/passwd-??/tmp/mytest1/popt.d????/tmp/mytest1/printcap????????/tmp/mytest1/python /tmp/mytest1/pki??????/tmp/mytest1/postfix???/tmp/mytest1/profile |
11、復(fù)制/etc目錄下所有以.d結(jié)尾的文件或目錄至/tmp/mytest2目錄中。
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | [root@C7-1?~]#?mkdir?/tmp/mytest2????????????????????????#如題目要求創(chuàng)建/tmp/mytest2目錄 [root@C7-1?~]#?ls?-d?/etc/*.d????????????????????????????#先用ls查看如題目要求的文件,正確后再按下面使用cp命令復(fù)制? /etc/bash_completion.d??/etc/dracut.conf.d??/etc/modules-load.d??/etc/rc.d???/etc/rc5.d???????/etc/sysctl.d /etc/binfmt.d???????????/etc/grub.d?????????/etc/my.cnf.d????????/etc/rc0.d??/etc/rc6.d???????/etc/tmpfiles.d /etc/chkconfig.d????????/etc/init.d?????????/etc/pam.d???????????/etc/rc1.d??/etc/rsyslog.d???/etc/xinetd.d /etc/cron.d?????????????/etc/ld.so.conf.d???/etc/popt.d??????????/etc/rc2.d??/etc/rwtab.d?????/etc/yum.repos.d /etc/depmod.d???????????/etc/logrotate.d????/etc/prelink.conf.d??/etc/rc3.d??/etc/statetab.d /etc/dnsmasq.d??????????/etc/modprobe.d?????/etc/profile.d???????/etc/rc4.d??/etc/sudoers.d [root@C7-1?~]#?cp?-r?/etc/*.d?/tmp/mytest2 [root@C7-1?~]#?ls?-d?/tmp/mytest2/*.d /tmp/mytest2/bash_completion.d??/tmp/mytest2/ld.so.conf.d????/tmp/mytest2/rc.d???????/tmp/mytest2/rwtab.d /tmp/mytest2/binfmt.d???????????/tmp/mytest2/logrotate.d?????/tmp/mytest2/rc0.d??????/tmp/mytest2/statetab.d /tmp/mytest2/chkconfig.d????????/tmp/mytest2/modprobe.d??????/tmp/mytest2/rc1.d??????/tmp/mytest2/sudoers.d /tmp/mytest2/cron.d?????????????/tmp/mytest2/modules-load.d??/tmp/mytest2/rc2.d??????/tmp/mytest2/sysctl.d /tmp/mytest2/depmod.d???????????/tmp/mytest2/my.cnf.d????????/tmp/mytest2/rc3.d??????/tmp/mytest2/tmpfiles.d /tmp/mytest2/dnsmasq.d??????????/tmp/mytest2/pam.d???????????/tmp/mytest2/rc4.d??????/tmp/mytest2/xinetd.d /tmp/mytest2/dracut.conf.d??????/tmp/mytest2/popt.d??????????/tmp/mytest2/rc5.d??????/tmp/mytest2/yum.repos.d /tmp/mytest2/grub.d?????????????/tmp/mytest2/prelink.conf.d??/tmp/mytest2/rc6.d /tmp/mytest2/init.d?????????????/tmp/mytest2/profile.d???????/tmp/mytest2/rsyslog.d |
12、復(fù)制/etc/目錄下所有以l或m或n開(kāi)頭,以.conf結(jié)尾的文件至/tmp/mytest3目錄中。
| 1 2 3 4 5 6 | [root@C7-1?~]#?mkdir?/tmp/mytest3??????????????????????#如題目要求創(chuàng)建/tmp/mytest3目錄 [root@C7-1?~]#?ls?-d?/etc/[1,m,n]*.conf????????????????#先用ls查看如題目要求的文件,正確后再按下 /etc/man_db.conf??/etc/mke2fs.conf??/etc/nsswitch.conf [root@C7-1?~]#?cp?-r?/etc/[1,m,n]*.conf?/tmp/mytest3/ [root@C7-1?~]#?ls?-d?/tmp/mytest3/[1,m,n]*.conf /tmp/mytest3/man_db.conf??/tmp/mytest3/mke2fs.conf??/tmp/mytest3/nsswitch.conf |
本文轉(zhuǎn)自cix123 ?51CTO博客,原文鏈接:http://blog.51cto.com/zhaodongwei/1837652,如需轉(zhuǎn)載請(qǐng)自行聯(lián)系原作者
總結(jié)
以上是生活随笔為你收集整理的马哥运维学习作业(二)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: lustre1.6.5+drbd主备切换
- 下一篇: AGG第三十五课 gsv_text 渲染