Linux下的基本指令

1. ls 指令

Linux下的基本指令
Linux下的基本指令

-r 對目錄反向排序 -t 以時間排序 -s 在l文件名后輸出該文件的大小。(大小排序,如何找到目錄下最大的文件) -r 列出所有子目錄下的文件(遞歸) -1 一行只輸出一個文件


2. pwd指令


3. cd 指令

Linux下的基本指令

代碼語言:JavaScript代碼運行次數:0運行復制

root@hcss-ecs-78b3:/# cd /rootroot@hcss-ecs-78b3:~# pwd/rootroot@hcss-ecs-78b3:~# cd .root@hcss-ecs-78b3:~# pwd/rootroot@hcss-ecs-78b3:~# cd ..root@hcss-ecs-78b3:/# pwd/root@hcss-ecs-78b3:/#
Linux下的基本指令
Linux下的基本指令

4. touch指令 代碼語言:javascript代碼運行次數:0運行復制

root@hcss-ecs-78b3:~# touch hello.txtroot@hcss-ecs-78b3:~# pwd/rootroot@hcss-ecs-78b3:~# lshello.txt

5. mkdir指令代碼語言:javascript代碼運行次數:0運行復制

root@hcss-ecs-78b3:~# mkdir kianaroot@hcss-ecs-78b3:~# lltotal 116drwx------ 12 root root  4096 Oct 15 11:03 ./drwxr-xr-x 24 root root  4096 Oct 15 09:32 ../drwx------  3 root root  4096 Jul 22  2023 .ansible/drwxr-xr-x  2 root root  4096 Jul 22  2023 .ansible_async/-rw-r--r--  1 root root   298 Oct 15 10:15 .bash_history-rw-r--r--  1 root root  3144 Jul 22  2023 .bashrcdrwx------  2 root root  4096 Feb 10  2023 .cache/drwxr-xr-x  7 root root  4096 Jul 22  2023 docker-library/-rw-r--r--  1 root root 21926 Jul 22  2023 get-docker.sh-rw-r--r--  1 root root  1326 Jul 21  2023 githubclone.sh-rw-------  1 root root     0 Feb 10  2023 .history-rwxr-xr-x  1 root root 15353 Jul 22  2023 HSSInstall*drwxr-xr-x  2 root root  4096 Oct 15 11:03 kiana/-rw-------  1 root root    20 Oct 15 10:11 .lesshstdrwxr-xr-x  8 root root  4096 Jul 22  2023 library/drwxr-xr-x  3 root root  4096 Oct 15 09:29 .local/-rw-r--r--  1 root root   161 Jul  9  2019 .profiledrwx------  4 root root  4096 Jul 22  2023 snap/drwx------  2 root root  4096 Oct 11 19:41 .ssh/drwxr-xr-x  9 root root  4096 Jul 22  2023 stackhub/-rw-r--r--  1 root root   173 Jul 22  2023 .wget-hsts-rw-------  1 root root   177 Oct 15 11:03 .Xauthorityroot@hcss-ecs-78b3:~#

代碼語言:javascript代碼運行次數:0運行復制

root@hcss-ecs-78b3:~# mkdir -p a/b/croot@hcss-ecs-78b3:~# lltotal 120drwx------ 13 root root  4096 Oct 15 11:05 ./drwxr-xr-x 24 root root  4096 Oct 15 09:32 ../drwxr-xr-x  3 root root  4096 Oct 15 11:05 a/drwx------  3 root root  4096 Jul 22  2023 .ansible/drwxr-xr-x  2 root root  4096 Jul 22  2023 .ansible_async/-rw-r--r--  1 root root   298 Oct 15 10:15 .bash_history-rw-r--r--  1 root root  3144 Jul 22  2023 .bashrcdrwx------  2 root root  4096 Feb 10  2023 .cache/drwxr-xr-x  7 root root  4096 Jul 22  2023 docker-library/-rw-r--r--  1 root root 21926 Jul 22  2023 get-docker.sh-rw-r--r--  1 root root  1326 Jul 21  2023 githubclone.sh-rw-------  1 root root     0 Feb 10  2023 .history-rwxr-xr-x  1 root root 15353 Jul 22  2023 HSSInstall*drwxr-xr-x  2 root root  4096 Oct 15 11:03 kiana/-rw-------  1 root root    20 Oct 15 10:11 .lesshstdrwxr-xr-x  8 root root  4096 Jul 22  2023 library/drwxr-xr-x  3 root root  4096 Oct 15 09:29 .local/-rw-r--r--  1 root root   161 Jul  9  2019 .profiledrwx------  4 root root  4096 Jul 22  2023 snap/drwx------  2 root root  4096 Oct 11 19:41 .ssh/drwxr-xr-x  9 root root  4096 Jul 22  2023 stackhub/-rw-r--r--  1 root root   173 Jul 22  2023 .wget-hsts-rw-------  1 root root   177 Oct 15 11:03 .Xauthorityroot@hcss-ecs-78b3:~# 

代碼語言:javascript代碼運行次數:0運行復制

root@hcss-ecs-78b3:~# tree kianakiana0 directories, 0 filesroot@hcss-ecs-78b3:~# tree aa└── b    └── c2 directories, 0 filesroot@hcss-ecs-78b3:~# 

6. which指令 代碼語言:javascript代碼運行次數:0運行復制

root@hcss-ecs-78b3:~# root@hcss-ecs-78b3:~# which tree/usr/bin/treeroot@hcss-ecs-78b3:~# which pwd/usr/bin/pwdroot@hcss-ecs-78b3:~# which ls/usr/bin/lsroot@hcss-ecs-78b3:~# 

7. alias指令

如:

給pwd命令取別名叫做kiana

代碼語言:javascript代碼運行次數:0運行復制

root@hcss-ecs-78b3:alias kiana=pwd

8. rm指令代碼語言:javascript代碼運行次數:0運行復制

root@hcss-ecs-78b3:~# lltotal 120drwx------ 13 root root  4096 Oct 15 11:05 ./drwxr-xr-x 24 root root  4096 Oct 15 09:32 ../drwxr-xr-x  3 root root  4096 Oct 15 11:05 a/drwx------  3 root root  4096 Jul 22  2023 .ansible/drwxr-xr-x  2 root root  4096 Jul 22  2023 .ansible_async/-rw-r--r--  1 root root   298 Oct 15 10:15 .bash_history-rw-r--r--  1 root root  3144 Jul 22  2023 .bashrcdrwx------  2 root root  4096 Feb 10  2023 .cache/drwxr-xr-x  7 root root  4096 Jul 22  2023 docker-library/-rw-r--r--  1 root root 21926 Jul 22  2023 get-docker.sh-rw-r--r--  1 root root  1326 Jul 21  2023 githubclone.sh-rw-------  1 root root     0 Feb 10  2023 .history-rwxr-xr-x  1 root root 15353 Jul 22  2023 HSSInstall*drwxr-xr-x  2 root root  4096 Oct 15 11:03 kiana/-rw-------  1 root root    20 Oct 15 10:11 .lesshstdrwxr-xr-x  8 root root  4096 Jul 22  2023 library/drwxr-xr-x  3 root root  4096 Oct 15 09:29 .local/-rw-r--r--  1 root root   161 Jul  9  2019 .profiledrwx------  4 root root  4096 Jul 22  2023 snap/drwx------  2 root root  4096 Oct 11 19:41 .ssh/drwxr-xr-x  9 root root  4096 Jul 22  2023 stackhub/-rw-r--r--  1 root root   173 Jul 22  2023 .wget-hsts-rw-------  1 root root   177 Oct 15 11:03 .Xauthorityroot@hcss-ecs-78b3:~# rm -rf kianaroot@hcss-ecs-78b3:~# lltotal 116drwx------ 12 root root  4096 Oct 15 11:22 ./drwxr-xr-x 24 root root  4096 Oct 15 09:32 ../drwxr-xr-x  3 root root  4096 Oct 15 11:05 a/drwx------  3 root root  4096 Jul 22  2023 .ansible/drwxr-xr-x  2 root root  4096 Jul 22  2023 .ansible_async/-rw-r--r--  1 root root   298 Oct 15 10:15 .bash_history-rw-r--r--  1 root root  3144 Jul 22  2023 .bashrcdrwx------  2 root root  4096 Feb 10  2023 .cache/drwxr-xr-x  7 root root  4096 Jul 22  2023 docker-library/-rw-r--r--  1 root root 21926 Jul 22  2023 get-docker.sh-rw-r--r--  1 root root  1326 Jul 21  2023 githubclone.sh-rw-------  1 root root     0 Feb 10  2023 .history-rwxr-xr-x  1 root root 15353 Jul 22  2023 HSSInstall*-rw-------  1 root root    20 Oct 15 10:11 .lesshstdrwxr-xr-x  8 root root  4096 Jul 22  2023 library/drwxr-xr-x  3 root root  4096 Oct 15 09:29 .local/-rw-r--r--  1 root root   161 Jul  9  2019 .profiledrwx------  4 root root  4096 Jul 22  2023 snap/drwx------  2 root root  4096 Oct 11 19:41 .ssh/drwxr-xr-x  9 root root  4096 Jul 22  2023 stackhub/-rw-r--r--  1 root root   173 Jul 22  2023 .wget-hsts-rw-------  1 root root   177 Oct 15 11:03 .Xauthorityroot@hcss-ecs-78b3:

9. man指令代碼語言:javascript代碼運行次數:0運行復制

root@hcss-ecs-78b3:~#  man manroot@hcss-ecs-78b3:~#  man pwdroot@hcss-ecs-78b3:~#  man ll
Linux下的基本指令

10. cp指令代碼語言:javascript代碼運行次數:0運行復制

drwx------ 12 root root  4096 Oct 15 11:22 ./drwxr-xr-x 24 root root  4096 Oct 15 09:32 ../drwxr-xr-x  3 root root  4096 Oct 15 11:05 a/drwx------  3 root root  4096 Jul 22  2023 .ansible/drwxr-xr-x  2 root root  4096 Jul 22  2023 .ansible_async/-rw-r--r--  1 root root   298 Oct 15 10:15 .bash_history-rw-r--r--  1 root root  3144 Jul 22  2023 .bashrcdrwx------  2 root root  4096 Feb 10  2023 .cache/drwxr-xr-x  7 root root  4096 Jul 22  2023 docker-library/-rw-r--r--  1 root root 21926 Jul 22  2023 get-docker.sh-rw-r--r--  1 root root  1326 Jul 21  2023 githubclone.sh-rw-------  1 root root     0 Feb 10  2023 .history-rwxr-xr-x  1 root root 15353 Jul 22  2023 HSSInstall*-rw-------  1 root root    20 Oct 15 10:11 .lesshstdrwxr-xr-x  8 root root  4096 Jul 22  2023 library/drwxr-xr-x  3 root root  4096 Oct 15 09:29 .local/-rw-r--r--  1 root root   161 Jul  9  2019 .profiledrwx------  4 root root  4096 Jul 22  2023 snap/drwx------  2 root root  4096 Oct 11 19:41 .ssh/drwxr-xr-x  9 root root  4096 Jul 22  2023 stackhub/-rw-r--r--  1 root root   173 Jul 22  2023 .wget-hsts-rw-------  1 root root   177 Oct 15 11:03 .Xauthorityroot@hcss-ecs-78b3:~# root@hcss-ecs-78b3:~# man manroot@hcss-ecs-78b3:~# root@hcss-ecs-78b3:~# cp .wget-hsts get-docker.shroot@hcss-ecs-78b3:~# lltotal 96drwx------ 12 root root  4096 Oct 15 11:27 ./drwxr-xr-x 24 root root  4096 Oct 15 09:32 ../drwxr-xr-x  3 root root  4096 Oct 15 11:05 a/drwx------  3 root root  4096 Jul 22  2023 .ansible/drwxr-xr-x  2 root root  4096 Jul 22  2023 .ansible_async/-rw-r--r--  1 root root   298 Oct 15 10:15 .bash_history-rw-r--r--  1 root root  3144 Jul 22  2023 .bashrcdrwx------  2 root root  4096 Feb 10  2023 .cache/drwxr-xr-x  7 root root  4096 Jul 22  2023 docker-library/-rw-r--r--  1 root root   173 Oct 15 11:32 get-docker.sh-rw-r--r--  1 root root  1326 Jul 21  2023 githubclone.sh-rw-------  1 root root     0 Feb 10  2023 .history-rwxr-xr-x  1 root root 15353 Jul 22  2023 HSSInstall*-rw-------  1 root root    20 Oct 15 11:27 .lesshstdrwxr-xr-x  8 root root  4096 Jul 22  2023 library/drwxr-xr-x  3 root root  4096 Oct 15 09:29 .local/-rw-r--r--  1 root root   161 Jul  9  2019 .profiledrwx------  4 root root  4096 Jul 22  2023 snap/drwx------  2 root root  4096 Oct 11 19:41 .ssh/drwxr-xr-x  9 root root  4096 Jul 22  2023 stackhub/-rw-r--r--  1 root root   173 Jul 22  2023 .wget-hsts-rw-------  1 root root   177 Oct 15 11:03 .Xauthorityroot@hcss-ecs-78b3:~# 

11. mv指令


理論雜談

Linux下的基本指令
Linux下的基本指令
Linux下的基本指令

12. cat指令

Linux下的基本指令

重定向操作

Linux下的基本指令

13. more指令 代碼語言:javascript代碼運行次數:0運行復制

[atong@LiWenTong ~]$ ls -l  / | moretotal 162drwxr-xr-x  2 root root  4096 Apr 25 05:39 bindrwxr-xr-x  4 root root  1024 Apr 25 04:11bootdrwxr-xr-x  9 root root  3820 May  4 23:20 devdrwxr-xr-x 84 root root  4096 May  5 00:37 etc

14. less指令


15. head指令


16. tail指令

Linux下的基本指令
Linux下的基本指令

17. 時間相關的指令17.1. date顯示


18. Cal指令

Linux下的基本指令

19. find 查找指令

Linux下的基本指令

20. grep指令

Linux下的基本指令
Linux下的基本指令

21 .zip/unzip指令

Linux下的基本指令

如圖,我們壓縮了一個壓縮包day4.zip,將這個壓縮包傳遞給other,但是當我們打開之后發現day4.zip下的文件并沒有一起傳送過去,只傳了一個空文件夾day4.zip,解決方式就是要加上一個 ‘-r’

代碼語言:javascript代碼運行次數:0運行復制

zip -r day4.zip day4
Linux下的基本指令
Linux下的基本指令
Linux下的基本指令
Linux下的基本指令

22. tar指令:打包/解包,不打開它,直接看內容

Linux下的基本指令
Linux下的基本指令
Linux下的基本指令

23. uname指令

Linux下的基本指令

收尾雜談代碼語言:javascript代碼運行次數:0運行復制

cnt=0; while [ $cnt -le 100 ]; do echo "hello $cnt"; let cnt++;done

代碼語言:javascript代碼運行次數:0運行復制

cnt=0; while [ $cnt -le 100 ]; do touch code${cnt}.c; let cnt++;done
Linux下的基本指令

完結撒花~

? 版權聲明
THE END
喜歡就支持一下吧
點贊15 分享