n 絕對路徑:路徑的寫法『必定由根目錄 / 寫起』,例如: /usr/share/doc 。shell
n 相對路徑:路徑的寫法『不是由 / 寫起』,例如由 /usr/share/doc 要到 /usr/share/man 底下時,能夠寫成:『cd ../man』這就是相對路徑的寫法啦!相對路徑意指『相對於目前工做目錄的路徑!』less
. 表明此層目錄ide .. 表明上一層目錄spa - 表明前一個工做目錄unix ~ 表明『目前用戶身份』所在的家目錄component ~account 表明 account 這個用戶的家目錄(account是個帳號名稱)orm |
1.cd -Change the current directory to dir視頻
[root@localhost 桌面]# cd /tmp/rem
2. pwd - print name of current/working directory
mkdir [OPTION]... DIRECTORY...
[root@localhost tmp]# mkdir aaa
drwxr-xr-x. 2 root root 4096 2月 27 19:34 aaa
[root@localhost tmp]# mkdir -p bbb/ccc
drwxr-xr-x. 2 root root 4096 2月 27 19:34 aaa
drwxr-xr-x. 3 root root 4096 2月 27 19:35 bbb
drwxr-xr-x. 2 root root 4096 2月 27 19:35 ccc
[root@localhost tmp]# mkdir -m 777 ddd
drwxr-xr-x. 2 root root 4096 2月 27 19:34 aaa
drwxr-xr-x. 3 root root 4096 2月 27 19:35 bbb
drwxrwxrwx. 2 root root 4096 2月 27 19:39 ddd
4.rmdir - remove empty directories
rmdir [OPTION]... DIRECTORY...
[root@localhost tmp]# rmdir ddd
[root@localhost tmp]# rmdir -p bbb/ccc/
1.ls - list directory contents
drwxr-xr-x. 2 root root 4096 2月 27 19:34 aaa
. aaa .esd-1000 .ICE-unix .X0-lock .XIM-unix
.. .esd-0 .font-unix .Test-unix .X11-unix
aaa .esd-0 .esd-1000 .font-unix .ICE-unix .Test-unix .X0-lock .X11-unix .XIM-unix
drwxrwxrwt. 10 root root 4096 2月 27 19:43 .
145499 drwxr-xr-x. 2 root root 4096 2月 27 19:34 aaa
2.cp - copy files and directories
cp [OPTION]... SOURCE... DIRECTORY
[root@localhost tmp]# cp bbb bbb.cp
[root@localhost tmp]# cp bbb bbb.cp
-rw-rw-rw-. 1 root root 0 2月 27 19:51 bbb
[calf@localhost tmp]$ cp bbb bbb.calf #正常複製
-rw-rw-rw-. 1 root root 0 2月 27 19:51 bbb
-rw-rw-r--. 1 calf calf 0 2月 27 20:06 bbb.calf
[calf@localhost tmp]$ cp -p bbb bbb.p #保留屬性的複製
-rw-rw-rw-. 1 root root 0 2月 27 19:51 bbb
-rw-rw-r--. 1 calf calf 0 2月 27 20:06 bbb.calf
-rw-rw-rw-. 1 calf calf 0 2月 27 19:51 bbb.p
[root@localhost tmp]# cp /etc/passwd /etc/shadow /etc/group .
[root@localhost tmp]# ls #複製3個文件到當前目錄
3.rm - remove files or directories
aaa bbb bbb.a bbb.calf bbb.cp bbb.p
[root@localhost tmp]# rm bbb.p
[root@localhost tmp]# rm -f bbb.cp
[root@localhost tmp]# rm -rf * #刪除當前目錄下所有文件
[root@localhost ~]# rm -rf /tmp/* #刪除/tmp目錄下所有文件
[root@localhost tmp]# rm -aaa #刪除失敗
Try 'rm ./-aaa' to remove the file "-aaa".
Try 'rm --help' for more information.
[root@localhost tmp]# rm ./-aaa #刪除成功
mv [OPTION]... SOURCE... DIRECTORY
[root@localhost tmp]# mv /root/aaa .
#移動/root/aaa到當前目錄
[root@localhost tmp]# mv aaa bbb
[root@localhost tmp]# mv /root/aaa /root/ccc .
#移動多個文件到當前目錄
5.basename - strip directory and suffix from filenames
[root@localhost tmp]# basename /etc/sysconfig/network
6.dirname - strip last component from file name
[root@localhost tmp]# dirname /etc/sysconfig/network
[root@localhost tmp]# file test
[root@localhost tmp]# file /bin/cd
/bin/cd: POSIX shell script, ASCII text executable
[root@localhost tmp]# file /var/lib/mlocate/mlocate.db
/var/lib/mlocate/mlocate.db: data
1.cat - concatenate files and print on the standard output
[root@localhost tmp]# cat /etc/passwd
[root@localhost tmp]# cat -n /etc/passwd #顯示行號
[root@localhost tmp]# cat -r /etc/passwd
#倒序的倒序輸出文本內容
2.tac - concatenate and print files in reverse
[root@localhost tmp]# tac /etc/passwd #倒序輸出文本內容
[root@localhost tmp]# nl /etc/passwd
1.more - file perusal filter for crt viewing
[root@localhost tmp]# more /etc/passwd
[root@localhost tmp]# less /etc/passwd
1.head - output the first part of files
[root@localhost tmp]# head /etc/passwd
#顯示前10行內容,默認
[root@localhost tmp]# head -n 5 /etc/passwd #顯示前5行內容
[root@localhost tmp]# head -n +5 /etc/passwd #顯示前5行內容
[root@localhost tmp]# head -n -5 /etc/passwd
#顯示倒數第5行以前的內容
2.tail - output the last part of files
[root@localhost tmp]# tail /etc/passwd #顯示最後10行,默認
[root@localhost tmp]# tail -n 5 /etc/passwd #顯示最後5行
[root@localhost tmp]# tail -n -5 /etc/passwd #顯示最後5行
[root@localhost tmp]# tail -n +5 /etc/passwd #從第5行開始顯示
注意:head的最後一個例子與tail的最後一個例子的區別。
[root@localhost tmp]# tail -f /var/log/messages
#若是message的內容繼續增長,tail將繼續輸出增長的內容。