﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-migrantdk</title><link>http://www.cnitblog.com/migrantdk/</link><description /><language>zh-cn</language><lastBuildDate>Tue, 05 May 2026 14:49:33 GMT</lastBuildDate><pubDate>Tue, 05 May 2026 14:49:33 GMT</pubDate><ttl>60</ttl><item><title>Linux实用代码(1)--文件系统操作</title><link>http://www.cnitblog.com/migrantdk/archive/2007/07/07/29590.html</link><dc:creator>TZ</dc:creator><author>TZ</author><pubDate>Sat, 07 Jul 2007 05:13:00 GMT</pubDate><guid>http://www.cnitblog.com/migrantdk/archive/2007/07/07/29590.html</guid><description><![CDATA[<p><span class=bold>Linux实用代码(1)--文件系统操作</span><br><br></p>
<div style="FONT-SIZE: 13px">这篇文档实用性很强，它不是讲某个命令的参数具体含义，而是从实际<br><br>工作的角度来考虑，完成什么工作需要什么指令。<br><br><br>&nbsp;&nbsp;文件系统操作是最基本的操作，没有文件系统，操作系统根本就运行不了。<br><br>&nbsp;&nbsp;下面是我们经常要做的一些事情。在下面具体参数意义不解释，要了解这些<br><br>&nbsp;&nbsp;可以查询该命令帮助文档<br><br>&nbsp;&nbsp;1. 创建目录<br><br>&nbsp; &nbsp;&nbsp;&nbsp;mkdir<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO1. 在当前路径创建一级目录<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# mkdir test <br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO2. 在当前路径创建多级目录<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# mkdir -p mytest/test1/test1_1<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO3. 在创建目录的同时给新建的目录赋权限<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# mkdir -m 777 testmod <br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 这样任何人对此目录都有任何权限<br><br>&nbsp;&nbsp;2. 复制文件与文件夹<br><br>&nbsp; &nbsp;&nbsp;&nbsp;cp<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO1. 复制指定目录的文件到当前目录，并重命名<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# cp ~/.bashrc bashrc_bak<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO2. 强制复制指定目录的文件到当前目录，而不管当前目录是否含有该文件<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# cp -f ~/.bashrc bashrc<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO2. 复制指定目录到当前目录<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# cp -r /root/test .<br>&nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# cp -r /root/test/ .<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 两者效果一样，在复制目录时，会将源路径的最后一级目录全部复制过去，包括它本身。<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO3. 复制指定目录的文件到指定目录<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# cp ~/.bashrc /bak/.bashrc<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO4. 在复制时将源文件的全部属性也复制过来。若不指定参数，则目标文件与源文件属性可能不一致。<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# cp -a ~/.bashrc /bak/.bashrc<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO5. 若两个文件夹要保证同步，一个文件的改了，另一个文件也跟着改，但是要保证两个文件的文件都是最新的。<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# cp -u /src/.bashrc /bak_src/bashrc<br><br>&nbsp;&nbsp;3. 建立链接文件，包括硬链接与软链接<br><br>&nbsp; &nbsp;&nbsp;&nbsp;ln<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO1. 建立类似于 Windows 的快捷方式<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# ln -s test.txt test.txt_slnk<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO2. 当想备份一个文件，但空间又不够，则可以为该文件建立一个硬连接。这样，就算原文件删除了，只要该<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 链接文件没被删除，则在存储空间里还是没有被删除。<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# ln -l test.txt test.txt_hlnk<br><br>&nbsp;&nbsp;4. 删除文件<br><br>&nbsp; &nbsp;&nbsp;&nbsp;rm<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO1. 删除当前目录的文件<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# rm test.txt<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO2. 强制删除当前目录的文件，不弹出提示<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# rm -f test.txt<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO3. 强制删除整个目录，包括目录与文件全部删除，需要管理员权限<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# rm -r -f test<br><br>&nbsp;&nbsp;5. 删除文件夹<br><br>&nbsp; &nbsp;&nbsp;&nbsp;rmdir<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO1. 删除一个空目录<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# rmdir emptydir<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO2. 删除多级空目录<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# rmdir -p emptydir/d1/d11<br><br>&nbsp;&nbsp;6. 挂载文件系统与卸载文件系统<br><br>&nbsp; &nbsp;&nbsp;&nbsp;mount / umount<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO1. 挂载光驱<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# mount -t iso9660 /dev/cdrom /mnt/cdrom<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO2. 挂载光驱，支持中文<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# mount -t iso9660 -o codepage=936,iocharset=cp936 /dev/cdrom /mnt/cdrom<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO3. 挂载 Windows 分区，FAT文件系统<br><br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;[root@rehat root]# mount -t vfat /dev/hda3 /mnt/cdrom&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO4. 挂载 Windows 分区，NTFS文件系统<br><br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;[root@rehat root]# mount -t ntfs -o iocharset=cp936 /dev/hda7 /mnt/had7<br><br>&nbsp; &nbsp;&nbsp;&nbsp;No5. 挂载 ISO 文件<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# mount -o loop /abc.iso /mnt/cdrom<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO6. 挂载 软驱<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# mount /dev/fd0 /mnt/floppy<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO7. 挂载闪盘<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# mount /dev/sda1 /mnt/cdrom<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO8. 挂载 Windows 操作系统共享的文件夹<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# mount -t smbfs -o username=guest,password=guest //machine/path /mnt/cdrom<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO9. 显示挂载的文件系统<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# mount<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# cat /etc/fstab&nbsp; &nbsp; &nbsp; &nbsp; 显示系统启动自动加载的文件系统<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# cat /etc/mtab&nbsp; &nbsp; &nbsp; &nbsp; 显示当前加载的文件系统<br><br>&nbsp;&nbsp;7. 检查磁盘空间<br><br>&nbsp; &nbsp;&nbsp;&nbsp;df<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO1. 显示所有存储系统空间使用情况,同时显示存储系统的文件系统类型s<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# df -aT<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO2. 显示指定文件系统的空间使用情况&nbsp; &nbsp; &nbsp; &nbsp; <br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# df -t ext3<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<br>&nbsp; &nbsp;&nbsp;&nbsp;NO3. 人性化显示各存储空间大小<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# df -ah<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO4. 有时候挂载了网络文件系统，若只想看本机的文件系统用如下命令<br><br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;[root@rehat root]# df -ahlT<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO5. 查看某个文件系统的磁盘使用情况<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# df -h /dev/cdrom<br><br><br>&nbsp;&nbsp;8. 检查目录空间大小<br><br>&nbsp; &nbsp;&nbsp;&nbsp;du<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO1. 查看当前文件夹大小<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# du -sh<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO2. 查看当前文件及文件中包含的子文件夹大小<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# du -ch<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO3. 查看文件的大小<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# du -h test1.txt<br><br>&nbsp; &nbsp;&nbsp;&nbsp;NO4. 同时查看多个文件的大小<br><br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;[root@rehat root]# du -h test1.txt test2.txt<br><br>&nbsp;&nbsp;9. 磁盘碎片整理<br><br>&nbsp; &nbsp;&nbsp;&nbsp;linux 下基本上不用碎片整理，它每隔一段时间会自动整理<br>&nbsp; &nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;10. 创建/改变文件系统<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO1. 创建文件系统类型<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# umount /dev/sdb1<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# mkfs -t ext3 /dev/db1<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# mount /dev/sdb1 /practice<br><br>&nbsp;&nbsp;11. 改变文件或文件夹权限<br><br>&nbsp; &nbsp;&nbsp; &nbsp;chmod<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO1. 将自己的笔记设为只有自己才能看<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# chmod go-rwx test.txt<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;或者<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# chmod 700 test.txt<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO2. 同时修改多个文件的权限<br><br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; [root@rehat root]# chmod 700 test1.txt test2.txt<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO3. 修改一个目录的权限，包括其子目录及文件<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# chmod 700 -R test<br><br>&nbsp;&nbsp;12. 改变文件或文件夹拥有者<br><br>&nbsp; &nbsp;&nbsp; &nbsp;chown 该命令只有 root 才能使用<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO1. 更改某个文件的拥有者<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# chown jim:usergroup test.txt<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO2. 更改某个目录的拥有者,并包含子目录<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# chown jim:usergroup -R test<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;13. 查看文本文件内容<br><br>&nbsp; &nbsp;&nbsp; &nbsp;cat<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO1. 查看文件内容，并在每行前面加上行号<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# cat -n test.txt<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO2. 查看文件内容，在不是空行的前面加上行号<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# cat -b test.txt<br>&nbsp; &nbsp;&nbsp; &nbsp; <br>&nbsp; &nbsp;&nbsp; &nbsp;NO3. 合并两个文件的内容<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# cat test1.txt test2.txt &gt; test_new.txt<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO4. 全并两具文件的内容，并追回到一个文件<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# cat test1.txt test2.txt &gt;&gt; test_total.txt<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO5. 清空某个文件的内容<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# cat /dev/null &gt; test.txt<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO6. 创建一个新的文件<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# cat &gt; new.txt 按 CTRL + C 结束录入<br><br>&nbsp;&nbsp;14. 编辑文件文件<br><br>&nbsp; &nbsp;&nbsp; &nbsp;vi<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO1. 新建档案文件<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# vi newfile.txt<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO2. 修改档案文件<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# vi test.txt&nbsp; &nbsp;test.txt 已存在<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO3. vi 的两种工作模式：命令模式，编辑模式<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO4. 进入 vi 后为命令模式，按 Insrt 键进入编辑模式<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;按 ESC 进入命令模式，在命令模式不能编辑，只能输入命令<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO5. 命令模式常用命令<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;:w 保存当前文档<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;:q 直接退出 vi<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;:wq 先保存后退出<br>&nbsp; &nbsp;&nbsp; &nbsp; <br>&nbsp;&nbsp;15. 路径操作<br><br>&nbsp; &nbsp;&nbsp; &nbsp;cd pwd<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO1. 显示当前路径<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# pwd<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO2. 返回用户主目录<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# cd<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO3. 改变到其它路径<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# cd /etc<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO4. 返回到上一级目录<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# cd ..<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO5. 返回到根目录<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# cd /<br><br>&nbsp;&nbsp;16. 查询文件或文件夹<br><br>&nbsp; &nbsp;&nbsp; &nbsp;find<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO1. 查找当前用户主目录下的所有文件<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# find ~ <br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO2. 让当前目录中文件属主具有读、写权限，并且文件所属组的用户和其他用户具有读权限的文件；<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# find . -perm 644 -exec ls -l {} \;<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO3. 为了查找系统中所有文件长度为0的普通文件，并列出它们的完整路径；<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# find / size 0 -type f -exec ls -l {} \;<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO4. 查找/var/logs目录中更改时间在7日以前的普通文件，并在删除之前询问它们；<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# find /var/logs -mtime +7 -type f -ok rm -i {} \;<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO5. 为/找系统中所有属于root组的文件；<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# find / -group root -exec ls -l {} \;<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO6. find命令将删除当目录中访问时间在7日以来、含有数字后缀的admin.log文件<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# find . -name "admin.log[0-9][0-9][0-9]" -atime -7 -ok rm { } \;<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO7. 为了查找当前文件系统中的所有目录并排序<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# find . -type d | sort<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO8. 为了查找系统中所有的rmt磁带设备<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# find /dev/rmt<br><br>&nbsp;&nbsp;17. 显示文件/文件夹清单<br><br>&nbsp; &nbsp;&nbsp; &nbsp;ls / dir<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO1. 显示所有文件，包括以.开头的隐含文件<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# ls -a<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO2. 显示文件的详细信息<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# ls -l<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO3. 显示当前目录及所有子目录信息<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# ls -Rl<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO4. 以时间排序显示目录,这在找最新文件有用<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# ls -tl<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO5. 以文件大小排序<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# ls -Sl<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO6. 显示文件大小,并按大小排序<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# ls -s -l -S<br><br>&nbsp;&nbsp;18. 移动或更改文件/文件夹名称<br><br>&nbsp; &nbsp;&nbsp; &nbsp;mv 与 cp命令用法相似<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO1. 若移动目标文件已存在，要在移动之前，先备份原来的目录文件<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# mv -b test.txt test2/<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;这样在 test2 下将有两个文件 test.txt 及 text.txt~<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;其中 test.txt~ 是备份文件，test.txt是新的文件<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO2. 若移动目标文件已存在，但不想弹出是否覆盖的提示，直接覆盖<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# mv -f test.txt test2/<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO3. 当源与目标都拥有同一个文件，若源文件比目标新则移动，否则不移动<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# mv -u test.txt test2/<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO4. 更改文件名称<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# mv test.txt test2.txt<br><br>&nbsp; &nbsp;&nbsp; &nbsp;NO5. 更改目录名称<br>&nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;[root@rehat root]# mv /test2 /test2_2</div>
<a href="http://www.cnitblog.com/migrantdk/"></a>
<img src ="http://www.cnitblog.com/migrantdk/aggbug/29590.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/migrantdk/" target="_blank">TZ</a> 2007-07-07 13:13 <a href="http://www.cnitblog.com/migrantdk/archive/2007/07/07/29590.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>上善若水-静水深流</title><link>http://www.cnitblog.com/migrantdk/archive/2007/07/06/29576.html</link><dc:creator>TZ</dc:creator><author>TZ</author><pubDate>Fri, 06 Jul 2007 10:07:00 GMT</pubDate><guid>http://www.cnitblog.com/migrantdk/archive/2007/07/06/29576.html</guid><wfw:comment>http://www.cnitblog.com/migrantdk/comments/29576.html</wfw:comment><comments>http://www.cnitblog.com/migrantdk/archive/2007/07/06/29576.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/migrantdk/comments/commentRss/29576.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/migrantdk/services/trackbacks/29576.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;老子说：&#8220;上善若水：水善利万物而不争，处众人之所恶，此乃谦下之德也；故江海所以能为百谷王者，以其善下之，则能为百谷王。天下莫柔弱於水，而攻坚强者莫之能胜，此乃柔德也；故柔之胜刚，弱之胜强坚。因其无有，故能入于无间，由此可知不言之教、无为之益也。&#8221;孔丘闻言，恍然大悟道：&#8220;先生此言，使我顿开茅塞也：众人处上，水独处下；众人处易，水独处险；众人处洁，水独处秽。所处尽人之所恶，夫谁与之争乎？此所以为上善也。&#8221;老子点头说：&#8220;汝可教也！<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;老子还说：&#8220;以其不争，故天下莫能与之争，此乃效法水德也。水几于道；道无所不在，水无所不利，避高趋下，未尝有所逆，善处地也；空处湛静，深不可测。善为渊也；损而不竭，施不求报，善为仁也；&#8230;&#8230;..。 <br></ca>
<img src ="http://www.cnitblog.com/migrantdk/aggbug/29576.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/migrantdk/" target="_blank">TZ</a> 2007-07-06 18:07 <a href="http://www.cnitblog.com/migrantdk/archive/2007/07/06/29576.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>