《師父》各獎盃獲取方法講解
阿新 • • 發佈:2022-02-15
檔案與目錄
-
ls(英文全拼:list files): 列出目錄及檔名
-
cd(英文全拼:change directory):切換目錄
-
pwd(英文全拼:print work directory):顯示目前的目錄
-
mkdir(英文全拼:make directory):建立一個新的目錄
-
rmdir(英文全拼:remove directory):刪除一個空的目錄
-
cp(英文全拼:copy file): 複製檔案或目錄
-
rm(英文全拼:remove): 刪除檔案或目錄
-
mv(英文全拼:move file): 移動檔案與目錄,或修改檔案與目錄的名稱
ls
選項與引數
- -a :全部的檔案,連同隱藏檔案( 開頭為 . 的檔案) 一起列出來(常用)
- -d :僅列出目錄本身,而不是列出目錄內的檔案資料(常用)
- -l :長資料串列出,包含檔案的屬性與許可權等等資料;(常用)
[root@VM-20-7-centos var]# ls adm cache db games kerberos local log nis preserve spool yp bt_setupPath.conf crash empty gopher lib lock mail opt run tmp [root@VM-20-7-centos var]# ls -a . adm cache db games kerberos local log nis preserve spool .updated .. bt_setupPath.conf crash empty gopher lib lock mail opt run tmp yp [root@VM-20-7-centos var]# ls -d . [root@VM-20-7-centos var]# ls -l total 72 drwxr-xr-x. 2 root root 4096 Apr 11 2018 adm -rw-r--r-- 1 root root 4 Feb 19 18:59 bt_setupPath.conf drwxr-xr-x. 6 root root 4096 Jan 14 11:23 cache drwxr-xr-x. 2 root root 4096 Jun 10 2021 crash drwxr-xr-x. 3 root root 4096 Nov 23 20:10 db drwxr-xr-x. 3 root root 4096 Mar 7 2019 empty drwxr-xr-x. 2 root root 4096 Apr 11 2018 games drwxr-xr-x. 2 root root 4096 Apr 11 2018 gopher drwxr-xr-x. 3 root root 4096 Dec 2 23:32 kerberos drwxr-xr-x. 28 root root 4096 Jan 14 11:24 lib drwxr-xr-x. 2 root root 4096 Apr 11 2018 local lrwxrwxrwx. 1 root root 11 Mar 7 2019 lock -> ../run/lock drwxr-xr-x. 10 root root 4096 Feb 20 03:15 log lrwxrwxrwx. 1 root root 10 Mar 7 2019 mail -> spool/mail drwxr-xr-x. 2 root root 4096 Apr 11 2018 nis drwxr-xr-x. 2 root root 4096 Apr 11 2018 opt drwxr-xr-x. 2 root root 4096 Apr 11 2018 preserve lrwxrwxrwx. 1 root root 6 Mar 7 2019 run -> ../run drwxr-xr-x. 11 root root 4096 Mar 7 2019 spool drwxrwxrwt. 5 root root 4096 Feb 19 18:59 tmp drwxr-xr-x. 2 root root 4096 Apr 11 2018 yp [root@VM-20-7-centos var]# ls -al total 84 drwxr-xr-x. 19 root root 4096 Jan 14 11:27 . dr-xr-xr-x. 20 root root 4096 Feb 22 21:52 .. drwxr-xr-x. 2 root root 4096 Apr 11 2018 adm -rw-r--r-- 1 root root 4 Feb 19 18:59 bt_setupPath.conf drwxr-xr-x. 6 root root 4096 Jan 14 11:23 cache drwxr-xr-x. 2 root root 4096 Jun 10 2021 crash drwxr-xr-x. 3 root root 4096 Nov 23 20:10 db drwxr-xr-x. 3 root root 4096 Mar 7 2019 empty drwxr-xr-x. 2 root root 4096 Apr 11 2018 games drwxr-xr-x. 2 root root 4096 Apr 11 2018 gopher drwxr-xr-x. 3 root root 4096 Dec 2 23:32 kerberos drwxr-xr-x. 28 root root 4096 Jan 14 11:24 lib drwxr-xr-x. 2 root root 4096 Apr 11 2018 local lrwxrwxrwx. 1 root root 11 Mar 7 2019 lock -> ../run/lock drwxr-xr-x. 10 root root 4096 Feb 20 03:15 log lrwxrwxrwx. 1 root root 10 Mar 7 2019 mail -> spool/mail drwxr-xr-x. 2 root root 4096 Apr 11 2018 nis drwxr-xr-x. 2 root root 4096 Apr 11 2018 opt drwxr-xr-x. 2 root root 4096 Apr 11 2018 preserve lrwxrwxrwx. 1 root root 6 Mar 7 2019 run -> ../run drwxr-xr-x. 11 root root 4096 Mar 7 2019 spool drwxrwxrwt. 5 root root 4096 Feb 19 18:59 tmp -rw-r--r-- 1 root root 163 Mar 7 2019 .updated drwxr-xr-x. 2 root root 4096 Apr 11 2018 yp
cd [相對路徑或絕對路徑]
[root@VM-20-7-centos var]# ls adm cache db games kerberos local log nis preserve spool yp bt_setupPath.conf crash empty gopher lib lock mail opt run tmp [root@VM-20-7-centos var]# cd log [root@VM-20-7-centos log]# cd ./var/lib -bash: cd: ./var/lib: No such file or directory [root@VM-20-7-centos log]# cd /var/lib [root@VM-20-7-centos lib]#
**pwd **
選項與引數:
- -P :顯示出確實的路徑,而非使用連結 (link) 路徑。
[root@VM-20-7-centos lib]# pwd
/var/lib
mkdir
選項與引數
- -m :配置檔案的許可權喔!直接配置,不需要看預設許可權 (umask) 的臉色~
- -p :幫助你直接將所需要的目錄(包含上一級目錄)遞迴建立起來!
[root@VM-20-7-centos home]# mkdir foo
[root@VM-20-7-centos home]# ls
foo lighthouse www
[root@VM-20-7-centos home]# mkdir foo
mkdir: cannot create directory ‘foo’: File exists
[root@VM-20-7-centos home]# mkdir foo/fooo
[root@VM-20-7-centos home]# mkdir foo/fooo/foooo/fooooo
mkdir: cannot create directory ‘foo/fooo/foooo/fooooo’: No such file or directory
[root@VM-20-7-centos home]# mkdir -p foo/fooo/foooo/fooooo
[root@VM-20-7-centos home]# mkdir defaultAuthFolder
[root@VM-20-7-centos home]# mkdir -m 711 CustomAuthFolder
[root@VM-20-7-centos home]# ls -l
total 20
drwx--x--x 2 root root 4096 Feb 22 22:12 CustomAuthFolder
drwxr-xr-x 2 root root 4096 Feb 22 22:11 defaultAuthFolder
drwxr-xr-x 3 root root 4096 Feb 22 22:06 foo
drwx------ 5 lighthouse lighthouse 4096 Feb 15 19:40 lighthouse
drwxr-xr-x 2 root root 4096 Jan 14 11:27 www
rmdir
選項與引數:
- -p :從該目錄起,一次刪除多級空目錄
[root@VM-20-7-centos home]# rmdir foo
rmdir: failed to remove ‘foo’: Directory not empty
[root@VM-20-7-centos home]# rmdir -p foo/fooo
rmdir: failed to remove ‘foo/fooo’: Directory not empty
[root@VM-20-7-centos home]# rmdir -p foo/fooo/foooo/fooooo
[root@VM-20-7-centos home]# ls
CustomAuthFolder defaultAuthFolder lighthouse www
[root@VM-20-7-centos home]# mkdir CustomAuthFolder/test
[root@VM-20-7-centos home]# cd CustomAuthFolder/test ls
[root@VM-20-7-centos test]# mkdir helloworld
[root@VM-20-7-centos test]# cd /home/ CustomAuthFolder/test ls
[root@VM-20-7-centos home]# cd /home/CustomAuthFolder/test ls
[root@VM-20-7-centos test]# ls
helloworld
[root@VM-20-7-centos test]# cd ..
[root@VM-20-7-centos CustomAuthFolder]# ls
test
[root@VM-20-7-centos CustomAuthFolder]# rmdir test/
rmdir: failed to remove ‘test/’: Directory not empty
[root@VM-20-7-centos CustomAuthFolder]# rmdir -p test/
rmdir: failed to remove ‘test/’: Directory not empty
[root@VM-20-7-centos CustomAuthFolder]# rmdir -f test/
rmdir: invalid option -- 'f'
Try 'rmdir --help' for more information.
[root@VM-20-7-centos CustomAuthFolder]# rmdir test/helloworld
[root@VM-20-7-centos CustomAuthFolder]# ls
test
本文來自部落格園,作者:weichangk,轉載請註明原文連結:https://www.cnblogs.com/weichangk/p/15925281.html