首页 > 运维 > linux运维 > 正文

Linux下的基本指令

看不見的法師
发布: 2025-06-20 11:58:33
原创
771人浏览过

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下的基本指令

完结撒花~

以上就是Linux下的基本指令的详细内容,更多请关注php中文网其它相关文章!

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号