linux 常用的50个命令及例子
11. 文件操作:xargs
把所有的jpg拷贝到另外的目录下
# ls *.jpg | xargs -n1 -i cp {} /external-hard-drive/directory打包所有的jgp.
# find / -name *.jpg -type f -print | xargs tar -cvzf images.tar.gz下载文件列表中的所有文件
# cat url-list.txt | xargs wget c 12. 文件信息:ls用一种人类可读的方式显示问文件信息
$ ls -lh -rw-r----- 1 rameshteam-dev 8.9M Jun 12 15:27 arch-linux.txt.gz按照文件的最后修改时间排序:
$ ls -ltr显示当前文件夹下所有的文件(并在文件夹的后边的追加/ , 用于区分)
$ ls -F 13. 当前路径:pwd打印当前路径
14. 目录切换命令:cd“cd -” 返回上一个目录
15. 压缩命令:gzip创建一个gz文件:
$ gziptest.txt解压一个文件a *.gz file:
$ gzip -d test.txt.gz显示压缩率: gzip -l
$ gzip -l *.gz compresseduncompressedratiouncompressed_name 237099797575.8% asp-patch-rpms.txt 16. 压缩命令:bzip2创建:file:
$ bzip2test.txt解压: *.bz2 file:
bzip2 -d test.txt.bz2 17. 解压命令:unzip解压一个文件:
$ unziptest.zip在不解压的情况下查看压缩文件内容:
$ unzip -l jasper.zip Archive:jasper.zip LengthDateTimeName -------------------- 4099511-30-98 23:50META-INF/MANIFEST.MF 3216908-25-98 21:07classes_ 1596408-25-98 21:07classes_names 1054208-25-98 21:07classes_ncomp 18. 关机命令:shutdown马上关机.
# shutdown -h now10分钟后关机.
# shutdown -h +10重启系统马上.
# shutdown -r now强制在重启过程中文件检查.
# shutdown -Fr now 19. FTP命令登陆ftp并下载文件
$ ftpIP/hostname ftp> mget *.html查看ftp目录下的文件
ftp> mls *.html - /ftptest/features.html /ftptest/index.html /ftptest/othertools.html /ftptest/samplereport.html /ftptest/usage.html 20. 计划任务crontab查看某用户的计划任务
# crontab -u john -l增加一个新的计划任务(crontab -e).
*/10 * * * * /home/ramesh/check-disk-space