linux 常用的50个命令及例子
11. 文件操作:xargs
把所有的jpg拷贝到另外的目录下
1 |
# ls *.jpg | xargs -n1 -i cp {} /external-hard-drive/directory |
打包所有的jgp.
1 |
# find / -name *.jpg -type f -print | xargs tar -cvzf images.tar.gz |
下载文件列表中的所有文件
1 |
# cat url-list.txt | xargs wget –c |
12. 文件信息:ls
用一种人类可读的方式显示问文件信息
1 2 |
$ ls -lh -rw-r----- 1 ramesh team-dev 8.9M Jun 12 15:27 arch-linux.txt.gz |
按照文件的最后修改时间排序:
1 |
$ ls -ltr |
显示当前文件夹下所有的文件(并在文件夹的后边的追加/ , 用于区分)
1 |
$ ls -F |
13. 当前路径:pwd
打印当前路径
14. 目录切换命令:cd
“cd -” 返回上一个目录
15. 压缩命令:gzip
创建一个gz文件:
1 |
$ gzip test.txt |
解压一个文件a *.gz file:
1 |
$ gzip -d test.txt.gz |
显示压缩率: gzip -l
1 2 3 |
$ gzip -l *.gz compressed uncompressed ratio uncompressed_name 23709 97975 75.8% asp-patch-rpms.txt |
16. 压缩命令:bzip2
创建:file:
1 |
$ bzip2 test.txt |
解压: *.bz2 file:
1 |
bzip2 -d test.txt.bz2 |
17. 解压命令:unzip
解压一个文件:
1 |
$ unzip test.zip |
在不解压的情况下查看压缩文件内容:
1 2 3 4 5 6 7 8 |
$ unzip -l jasper.zip Archive: jasper.zip Length Date Time Name -------- ---- ---- ---- 40995 11-30-98 23:50 META-INF/MANIFEST.MF 32169 08-25-98 21:07 classes_ 15964 08-25-98 21:07 classes_names 10542 08-25-98 21:07 classes_ncomp |
18. 关机命令:shutdown
马上关机.
1 |
# shutdown -h now |
10分钟后关机.
1 |
# shutdown -h +10 |
重启系统马上.
1 |
# shutdown -r now |
强制在重启过程中文件检查.
1 |
# shutdown -Fr now |
19. FTP命令
登陆ftp并下载文件
1 2 |
$ ftp IP/hostname ftp> mget *.html |
查看ftp目录下的文件
1 2 3 4 5 6 |
ftp> mls *.html - /ftptest/features.html /ftptest/index.html /ftptest/othertools.html /ftptest/samplereport.html /ftptest/usage.html |
20. 计划任务crontab
查看某用户的计划任务
1 |
# crontab -u john -l |
增加一个新的计划任务(crontab -e).
1 |
*/10 * * * * /home/ramesh/check-disk-space |
Latest posts by Zhiming Zhang (see all)
- aws eks node 自动化扩展工具 Karpenter - 8月 10, 2022
- ReplicationController and ReplicaSet in Kubernetes - 12月 20, 2021
- public key fingerprint - 5月 27, 2021