Linux 文件与目录管理
我们知道 Linux 的目录结构为树状结构,最顶级的目录为根目录 /。
其他目录通过挂载可以将它们添加到树中,通过解除挂载可以移除它们。
在开始本教程前我们需要先知道什么是绝对路径与相对路径。
-
绝对路径:
路径的写法,由根目录 / 写起,例如: /usr/share/doc 这个目录。 -
相对路径:
路径的写法,不是由 / 写起,例如由 /usr/share/doc 要到 /usr/share/man 底下时,可以写成: cd ../man 这就是相对路径的写法。
处理目录的常用命令
接下来我们就来看几个常见的处理目录的命令吧:
- ls(英文全拼:list files): 列出目录及文件名
- cd(英文全拼:change directory):切换目录
- pwd(英文全拼:print work directory):显示目前的目录
- mkdir(英文全拼:make directory):创建一个新的目录
- rmdir(英文全拼:remove directory):删除一个空的目录
- cp(英文全拼:copy file): 复制文件或目录
- rm(英文全拼:remove): 删除文件或目录
- mv(英文全拼:move file): 移动文件与目录,或修改文件与目录的名称
你可以使用 man [命令] 来查看各个命令的使用文档,如 :man cp。
ls (列出目录)
在Linux系统当中, ls 命令可能是最常被运行的。
语法:
[root@www ~]# ls [-aAdfFhilnrRSt] 目录名称
[root@www ~]# ls [–color={never,auto,always}] 目录名称
[root@www ~]# ls [–full-time] 目录名称
选项与参数:
- -a :全部的文件,连同隐藏文件( 开头为 . 的文件) 一起列出来(常用)
- -d :仅列出目录本身,而不是列出目录内的文件数据(常用)
- -l :长数据串列出,包含文件的属性与权限等等数据;(常用)
将目录下的所有文件列出来(含属性与隐藏档)
[root@www ~]# ls -al ~
cd (切换目录)
cd是Change Directory的缩写,这是用来变换工作目录的命令。
语法:
cd [相对路径或绝对路径]
#使用 mkdir 命令创建 runoob 目录
[root@www ~]# mkdir runoob
#使用绝对路径切换到 runoob 目录
[root@www ~]# cd /root/runoob/
#使用相对路径切换到 runoob 目录
[root@www ~]# cd ./runoob/
# 表示回到自己的家目录,亦即是 /root 这个目录
[root@www runoob]# cd ~
# 表示去到目前的上一级目录,亦即是 /root 的上一级目录的意思;
[root@www ~]# cd ..
接下来大家多操作几次应该就可以很好的理解 cd 命令的。
pwd (显示目前所在的目录)
pwd 是 Print Working Directory 的缩写,也就是显示目前所在目录的命令。
[root@www ~]# pwd [-P]
选项与参数:
- -P :显示出确实的路径,而非使用链接 (link) 路径。
实例:单纯显示出目前的工作目录:
[root@www ~]# pwd
/root <== 显示出目录啦~
实例显示出实际的工作目录,而非链接档本身的目录名而已。
[root@www ~]# cd /var/mail <==注意,/var/mail是一个链接档
[root@www mail]# pwd
/var/mail <==列出目前的工作目录
[root@www mail]# pwd -P
/var/spool/mail <==怎么回事?有没有加 -P 差很多~
[root@www mail]# ls -ld /var/mail
lrwxrwxrwx 1 root root 10 Sep 4 17:54 /var/mail -> spool/mail
# 看到这里应该知道为啥了吧?因为 /var/mail 是链接档,链接到 /var/spool/mail
# 所以,加上 pwd -P 的选项后,会不以链接档的数据显示,而是显示正确的完整路径啊!
mkdir (创建新目录)
如果想要创建新的目录的话,那么就使用mkdir (make directory)吧。
语法:
mkdir [-mp] 目录名称
选项与参数:
- -m :配置文件的权限喔!直接配置,不需要看默认权限 (umask) 的脸色~
- -p :帮助你直接将所需要的目录(包含上一级目录)递归创建起来!
实例:请到/tmp底下尝试创建数个新目录看看:
[root@www ~]# cd /tmp
[root@www tmp]# mkdir test <==创建一名为 test 的新目录
[root@www tmp]# mkdir test1/test2/test3/test4
mkdir: cannot create directory `test1/test2/test3/test4':
No such file or directory <== 没办法直接创建此目录啊!
[root@www tmp]# mkdir -p test1/test2/test3/test4
加了这个 -p 的选项,可以自行帮你创建多层目录!
实例:创建权限为 rwx–x–x 的目录。
[root@www tmp]# mkdir -m 711 test2
[root@www tmp]# ls -l
drwxr-xr-x 3 root root 4096 Jul 18 12:50 test
drwxr-xr-x 3 root root 4096 Jul 18 12:53 test1
drwx–x–x 2 root root 4096 Jul 18 12:54 test2
上面的权限部分,如果没有加上 -m 来强制配置属性,系统会使用默认属性。
如果我们使用 -m ,如上例我们给予 -m 711 来给予新的目录 drwx–x–x 的权限。
rmdir (删除空的目录)
语法:
rmdir [-p] 目录名称
选项与参数:
- -p :从该目录起,一次删除多级空目录
删除 runoob 目录
[root@www tmp]# rmdir runoob/
将 mkdir 实例中创建的目录(/tmp 底下)删除掉!
[root@www tmp]# ls -l <==看看有多少目录存在?
drwxr-xr-x 3 root root 4096 Jul 18 12:50 test
drwxr-xr-x 3 root root 4096 Jul 18 12:53 test1
drwx–x–x 2 root root 4096 Jul 18 12:54 test2
[root@www tmp]# rmdir test <==可直接删除掉,没问题
[root@www tmp]# rmdir test1 <==因为尚有内容,所以无法删除!
rmdir: `test1': Directory not empty
[root@www tmp]# rmdir -p test1/test2/test3/test4
[root@www tmp]# ls -l <==您看看,底下的输出中test与test1不见了!
drwx–x–x 2 root root 4096 Jul 18 12:54 test2
利用 -p 这个选项,立刻就可以将 test1/test2/test3/test4 一次删除。
不过要注意的是,这个 rmdir 仅能删除空的目录,你可以使用 rm 命令来删除非空目录。
cp (复制文件或目录)
cp 即拷贝文件和目录。
语法:
[root@www ~]# cp [-adfilprsu] 来源档(source) 目标档(destination)
[root@www ~]# cp [options] source1 source2 source3 …. directory
选项与参数:
-
-a:相当於 -pdr 的意思,至於 pdr 请参考下列说明;(常用)
-
-d:若来源档为链接档的属性(link file),则复制链接档属性而非文件本身;
-
-f:为强制(force)的意思,若目标文件已经存在且无法开启,则移除后再尝试一次;
-
-i:若目标档(destination)已经存在时,在覆盖时会先询问动作的进行(常用)
-
-l:进行硬式链接(hard link)的链接档创建,而非复制文件本身;
-
-p:连同文件的属性一起复制过去,而非使用默认属性(备份常用);
-
-r:递归持续复制,用於目录的复制行为;(常用)
-
-s:复制成为符号链接档 (symbolic link),亦即『捷径』文件;
-
-u:若 destination 比 source 旧才升级 destination !
用 root 身份,将 root 目录下的 .bashrc 复制到 /tmp 下,并命名为 bashrc
[root@www ~]# cp ~/.bashrc /tmp/bashrc
[root@www ~]# cp -i ~/.bashrc /tmp/bashrc
cp: overwrite `/tmp/bashrc'? n <==n不覆盖,y为覆盖
rm (移除文件或目录)
语法:
rm [-fir] 文件或目录
选项与参数:
- -f :就是 force 的意思,忽略不存在的文件,不会出现警告信息;
- -i :互动模式,在删除前会询问使用者是否动作
- -r :递归删除啊!最常用在目录的删除了!这是非常危险的选项!!!
将刚刚在 cp 的实例中创建的 bashrc 删除掉!
[root@www tmp]# rm -i bashrc
rm: remove regular file `bashrc'? y
如果加上 -i 的选项就会主动询问喔,避免你删除到错误的档名!
mv (移动文件与目录,或修改名称)
语法:
[root@www ~]# mv [-fiu] source destination
[root@www ~]# mv [options] source1 source2 source3 …. directory
选项与参数:
- -f :force 强制的意思,如果目标文件已经存在,不会询问而直接覆盖;
- -i :若目标文件 (destination) 已经存在时,就会询问是否覆盖!
- -u :若目标文件已经存在,且 source 比较新,才会升级 (update)
复制一文件,创建一目录,将文件移动到目录中
[root@www ~]# cd /tmp
[root@www tmp]# cp ~/.bashrc bashrc
[root@www tmp]# mkdir mvtest
[root@www tmp]# mv bashrc mvtest
将某个文件移动到某个目录去,就是这样做!
将刚刚的目录名称更名为 mvtest2
[root@www tmp]# mv mvtest mvtest2
Linux 文件内容查看
Linux系统中使用以下命令来查看文件的内容:
- cat 由第一行开始显示文件内容
- tac 从最后一行开始显示,可以看出 tac 是 cat 的倒着写!
- nl 显示的时候,顺道输出行号!
- more 一页一页的显示文件内容
- less 与 more 类似,但是比 more 更好的是,他可以往前翻页!
- head 只看头几行
- tail 只看尾巴几行
你可以使用 man [命令]来查看各个命令的使用文档,如 :man cp。
cat
由第一行开始显示文件内容
语法:
cat [-AbEnTv]
选项与参数:
- -A :相当於 -vET 的整合选项,可列出一些特殊字符而不是空白而已;
- -b :列出行号,仅针对非空白行做行号显示,空白行不标行号!
- -E :将结尾的断行字节 $ 显示出来;
- -n :列印出行号,连同空白行也会有行号,与 -b 的选项不同;
- -T :将 [tab] 按键以 ^I 显示出来;
- -v :列出一些看不出来的特殊字符
检看 /etc/issue 这个文件的内容:
[root@www ~]# cat /etc/issue
CentOS release 6.4 (Final)
Kernel \\r on an \\m
tac
tac与cat命令刚好相反,文件内容从最后一行开始显示,可以看出 tac 是 cat 的倒着写!如:
[root@www ~]# tac /etc/issue
Kernel \\r on an \\m
CentOS release 6.4 (Final)
nl
显示行号
语法:
nl [-bnw] 文件
选项与参数:
- -b :指定行号指定的方式,主要有两种:
-b a :表示不论是否为空行,也同样列出行号(类似 cat -n);
-b t :如果有空行,空的那一行不要列出行号(默认值); - -n :列出行号表示的方法,主要有三种:
-n ln :行号在荧幕的最左方显示;
-n rn :行号在自己栏位的最右方显示,且不加 0 ;
-n rz :行号在自己栏位的最右方显示,且加 0 ; - -w :行号栏位的占用的位数。
实例一:用 nl 列出 /etc/issue 的内容
[root@www ~]# nl /etc/issue
1 CentOS release 6.4 (Final)
2 Kernel \\r on an \\m
more
一页一页翻动
[root@www ~]# more /etc/man_db.config
#
# Generated automatically from man.conf.in by the
# configure script.
#
# man.conf from man-1.6d
….(中间省略)….
–More–(28%) <== 重点在这一行喔!你的光标也会在这里等待你的命令
在 more 这个程序的运行过程中,你有几个按键可以按的:
https://avg.163.com/topic/detail/10481875
https://avg.163.com/topic/detail/10481867
https://avg.163.com/topic/detail/10481494
https://avg.163.com/topic/detail/10481864
https://avg.163.com/topic/detail/10481857
https://avg.163.com/topic/detail/10481838
https://avg.163.com/topic/detail/10481171
https://avg.163.com/topic/detail/10481805
https://avg.163.com/topic/detail/10481429
https://avg.163.com/topic/detail/10481165
https://avg.163.com/topic/detail/10481782
https://avg.163.com/topic/detail/10481769
https://avg.163.com/topic/detail/10481767
https://avg.163.com/topic/detail/10481751
https://avg.163.com/topic/detail/10481760
https://avg.163.com/topic/detail/10481757
https://avg.163.com/topic/detail/10481752
https://avg.163.com/topic/detail/10481750
https://avg.163.com/topic/detail/10481735
https://avg.163.com/topic/detail/10481734
https://avg.163.com/topic/detail/10480976
https://avg.163.com/topic/detail/10481727
https://avg.163.com/topic/detail/10481714
https://avg.163.com/topic/detail/10481050
https://avg.163.com/topic/detail/10481702
https://avg.163.com/topic/detail/10481691
https://avg.163.com/topic/detail/10481688
https://avg.163.com/topic/detail/10481674
https://avg.163.com/topic/detail/10481655
https://avg.163.com/topic/detail/10481665
https://avg.163.com/topic/detail/10481657
https://avg.163.com/topic/detail/10481648
https://avg.163.com/topic/detail/10481651
https://avg.163.com/topic/detail/10481641
https://avg.163.com/topic/detail/10481626
https://avg.163.com/topic/detail/10481621
https://avg.163.com/topic/detail/10480469
https://avg.163.com/topic/detail/10480760
https://avg.163.com/topic/detail/10481210
https://avg.163.com/topic/detail/10480240
https://avg.163.com/topic/detail/10481104
https://avg.163.com/topic/detail/10481578
https://avg.163.com/topic/detail/10481577
https://avg.163.com/topic/detail/10481571
https://avg.163.com/topic/detail/10481560
https://avg.163.com/topic/detail/10480850
https://avg.163.com/topic/detail/10481541
https://avg.163.com/topic/detail/10481529
https://avg.163.com/topic/detail/10481528
https://avg.163.com/topic/detail/10481234
https://avg.163.com/topic/detail/10480417
https://avg.163.com/topic/detail/10481509
https://avg.163.com/topic/detail/10481494
https://avg.163.com/topic/detail/10480885
https://avg.163.com/topic/detail/10481106
https://avg.163.com/topic/detail/10481402
https://avg.163.com/topic/detail/10481484
https://avg.163.com/topic/detail/10481479
https://avg.163.com/topic/detail/10480935
https://avg.163.com/topic/detail/10481475
https://avg.163.com/topic/detail/10481452
https://avg.163.com/topic/detail/10480469
https://avg.163.com/topic/detail/10480777
https://avg.163.com/topic/detail/10480716
https://avg.163.com/topic/detail/10481433
https://avg.163.com/topic/detail/10481429
https://avg.163.com/topic/detail/10480612
https://avg.163.com/topic/detail/10481416
https://avg.163.com/topic/detail/10481372
https://avg.163.com/topic/detail/10481406
https://avg.163.com/topic/detail/10481082
https://avg.163.com/topic/detail/10481392
https://avg.163.com/topic/detail/10481396
https://avg.163.com/topic/detail/10481380
https://avg.163.com/topic/detail/10481359
https://avg.163.com/topic/detail/10481353
https://avg.163.com/topic/detail/10481354
https://avg.163.com/topic/detail/10481342
https://avg.163.com/topic/detail/10481338
https://avg.163.com/topic/detail/10481320
https://avg.163.com/topic/detail/10481327
https://avg.163.com/topic/detail/10481316
https://avg.163.com/topic/detail/10481171
https://avg.163.com/topic/detail/10481301
https://avg.163.com/topic/detail/10481299
https://avg.163.com/topic/detail/10481281
https://avg.163.com/topic/detail/10480655
https://avg.163.com/topic/detail/10481269
https://avg.163.com/topic/detail/10481260
https://avg.163.com/topic/detail/10481256
https://avg.163.com/topic/detail/10481247
https://avg.163.com/topic/detail/10481243
https://avg.163.com/topic/detail/10481236
https://avg.163.com/topic/detail/10481234
https://avg.163.com/topic/detail/10481230
https://avg.163.com/topic/detail/10481229
https://avg.163.com/topic/detail/10481223
https://avg.163.com/topic/detail/10480612
https://avg.163.com/topic/detail/10481210
https://avg.163.com/topic/detail/10481213
https://avg.163.com/topic/detail/10481206
https://avg.163.com/topic/detail/10481194
https://avg.163.com/topic/detail/10481197
https://avg.163.com/topic/detail/10481186
https://avg.163.com/topic/detail/10481151
https://avg.163.com/topic/detail/10481171
https://avg.163.com/topic/detail/10481165
https://avg.163.com/topic/detail/10481159
https://avg.163.com/topic/detail/10481156
https://avg.163.com/topic/detail/10480692
https://avg.163.com/topic/detail/10481149
https://avg.163.com/topic/detail/10481145
https://avg.163.com/topic/detail/10481118
https://avg.163.com/topic/detail/10480478
https://avg.163.com/topic/detail/10481106
https://avg.163.com/topic/detail/10481093
https://avg.163.com/topic/detail/10481104
https://avg.163.com/topic/detail/10481096
https://avg.163.com/topic/detail/10481091
https://avg.163.com/topic/detail/10481088
https://avg.163.com/topic/detail/10481082
https://avg.163.com/topic/detail/10480417
https://avg.163.com/topic/detail/10480669
https://avg.163.com/topic/detail/10481050
https://avg.163.com/topic/detail/10481048
https://avg.163.com/topic/detail/10481026
https://avg.163.com/topic/detail/10481040
https://avg.163.com/topic/detail/10480331
https://avg.163.com/topic/detail/10481030
https://avg.163.com/topic/detail/10481010
https://avg.163.com/topic/detail/10481005
https://avg.163.com/topic/detail/10481008
https://avg.163.com/topic/detail/10480998
https://avg.163.com/topic/detail/10480988
https://avg.163.com/topic/detail/10480976
https://avg.163.com/topic/detail/10480953
https://avg.163.com/topic/detail/10480946
https://avg.163.com/topic/detail/10480698
https://avg.163.com/topic/detail/10480935
https://avg.163.com/topic/detail/10480934
https://avg.163.com/topic/detail/10480932
https://avg.163.com/topic/detail/10480931
https://avg.163.com/topic/detail/10480921
https://avg.163.com/topic/detail/10480918
https://avg.163.com/topic/detail/10480911
https://avg.163.com/topic/detail/10480913
https://avg.163.com/topic/detail/10480453
https://avg.163.com/topic/detail/10480903
https://avg.163.com/topic/detail/10480898
https://avg.163.com/topic/detail/10480897
https://avg.163.com/topic/detail/10480885
https://avg.163.com/topic/detail/10480881
https://avg.163.com/topic/detail/10480469
https://avg.163.com/topic/detail/10480515
https://avg.163.com/topic/detail/10480853
https://avg.163.com/topic/detail/10480850
https://avg.163.com/topic/detail/10480841
https://avg.163.com/topic/detail/10480820
https://avg.163.com/topic/detail/10480842
https://avg.163.com/topic/detail/10480834
https://avg.163.com/topic/detail/10480240
https://avg.163.com/topic/detail/10480489
https://avg.163.com/topic/detail/10480828
https://avg.163.com/topic/detail/10480818
https://avg.163.com/topic/detail/10480809
https://avg.163.com/topic/detail/10480793
https://avg.163.com/topic/detail/10480792
https://avg.163.com/topic/detail/10480777
https://avg.163.com/topic/detail/10480774
https://avg.163.com/topic/detail/10480549
https://avg.163.com/topic/detail/10480473
https://avg.163.com/topic/detail/10480760
https://avg.163.com/topic/detail/10480753
https://avg.163.com/topic/detail/10480752
https://avg.163.com/topic/detail/10480737
https://avg.163.com/topic/detail/10480734
https://avg.163.com/topic/detail/10480716
https://avg.163.com/topic/detail/10480708
https://avg.163.com/topic/detail/10480700
https://avg.163.com/topic/detail/10480698
https://avg.163.com/topic/detail/10480387
https://avg.163.com/topic/detail/10480692
https://avg.163.com/topic/detail/10480694
https://avg.163.com/topic/detail/10480687
https://avg.163.com/topic/detail/10480674
https://avg.163.com/topic/detail/10480669
https://avg.163.com/topic/detail/10480663
https://avg.163.com/topic/detail/10480436
https://avg.163.com/topic/detail/10480660
https://avg.163.com/topic/detail/10480657
https://avg.163.com/topic/detail/10480655
https://avg.163.com/topic/detail/10480650
https://avg.163.com/topic/detail/10480646
https://avg.163.com/topic/detail/10480602
https://avg.163.com/topic/detail/10480645
https://avg.163.com/topic/detail/10480618
https://avg.163.com/topic/detail/10480636
https://avg.163.com/topic/detail/10480635
https://avg.163.com/topic/detail/10480631
https://avg.163.com/topic/detail/10480630
https://avg.163.com/topic/detail/10480628
https://avg.163.com/topic/detail/10480625
https://avg.163.com/topic/detail/10480622
https://avg.163.com/topic/detail/10480621
https://avg.163.com/topic/detail/10480442
https://avg.163.com/topic/detail/10480612
https://avg.163.com/topic/detail/10480610
https://avg.163.com/topic/detail/10480607
https://avg.163.com/topic/detail/10480606
https://avg.163.com/topic/detail/10480603
https://avg.163.com/topic/detail/10480322
https://avg.163.com/topic/detail/10480600
https://avg.163.com/topic/detail/10480599
https://avg.163.com/topic/detail/10480596
https://avg.163.com/topic/detail/10480593
https://avg.163.com/topic/detail/10480592
https://avg.163.com/topic/detail/10480589
https://avg.163.com/topic/detail/10480590
https://avg.163.com/topic/detail/10480587
https://avg.163.com/topic/detail/10480417
https://avg.163.com/topic/detail/10480577
https://avg.163.com/topic/detail/10480575
https://avg.163.com/topic/detail/10480576
https://avg.163.com/topic/detail/10480573
https://avg.163.com/topic/detail/10480568
https://avg.163.com/topic/detail/10480362
https://avg.163.com/topic/detail/10480566
https://avg.163.com/topic/detail/10480388
https://avg.163.com/topic/detail/10480555
https://avg.163.com/topic/detail/10480549
https://avg.163.com/topic/detail/10480544
https://avg.163.com/topic/detail/10480545
https://avg.163.com/topic/detail/10480541
https://avg.163.com/topic/detail/10480530
https://avg.163.com/topic/detail/10480523
https://avg.163.com/topic/detail/10480344
https://avg.163.com/topic/detail/10480519
https://avg.163.com/topic/detail/10480515
https://avg.163.com/topic/detail/10480505
https://avg.163.com/topic/detail/10480323
https://avg.163.com/topic/detail/10480310
https://avg.163.com/topic/detail/10480499
https://avg.163.com/topic/detail/10480391
https://avg.163.com/topic/detail/10480494
https://avg.163.com/topic/detail/10480489
https://avg.163.com/topic/detail/10480272
https://avg.163.com/topic/detail/10480488
https://avg.163.com/topic/detail/10480486
https://avg.163.com/topic/detail/10480484
https://avg.163.com/topic/detail/10480483
https://avg.163.com/topic/detail/10480331
https://avg.163.com/topic/detail/10480479
https://avg.163.com/topic/detail/10480478
https://avg.163.com/topic/detail/10480313
https://avg.163.com/topic/detail/10480473
https://avg.163.com/topic/detail/10480470
https://avg.163.com/topic/detail/10480469
https://avg.163.com/topic/detail/10480467
https://avg.163.com/topic/detail/10480464
https://avg.163.com/topic/detail/10480458
https://avg.163.com/topic/detail/10480455
https://avg.163.com/topic/detail/10480460
https://avg.163.com/topic/detail/10480454
https://avg.163.com/topic/detail/10480453
https://avg.163.com/topic/detail/10480450
https://avg.163.com/topic/detail/10480447
https://avg.163.com/topic/detail/10480364
https://avg.163.com/topic/detail/10480442
https://avg.163.com/topic/detail/10480440
https://avg.163.com/topic/detail/10480437
https://avg.163.com/topic/detail/10480436
https://avg.163.com/topic/detail/10480432
https://avg.163.com/topic/detail/10480424
https://avg.163.com/topic/detail/10480421
https://avg.163.com/topic/detail/10480417
https://avg.163.com/topic/detail/10480420
https://avg.163.com/topic/detail/10480403
https://avg.163.com/topic/detail/10480402
https://avg.163.com/topic/detail/10480399
https://avg.163.com/topic/detail/10480400
https://avg.163.com/topic/detail/10480398
https://avg.163.com/topic/detail/10480240
https://avg.163.com/topic/detail/10480395
https://avg.163.com/topic/detail/10480390
https://avg.163.com/topic/detail/10480359
https://avg.163.com/topic/detail/10480389
https://avg.163.com/topic/detail/10480391
https://avg.163.com/topic/detail/10480388
https://avg.163.com/topic/detail/10480387
https://avg.163.com/topic/detail/10480383
https://avg.163.com/topic/detail/10480381
https://avg.163.com/topic/detail/10480375
https://avg.163.com/topic/detail/10480374
https://avg.163.com/topic/detail/10480373
https://avg.163.com/topic/detail/10480370
https://avg.163.com/topic/detail/10480371
https://avg.163.com/topic/detail/10480368
https://avg.163.com/topic/detail/10480366
https://avg.163.com/topic/detail/10480364
https://avg.163.com/topic/detail/10480362
https://avg.163.com/topic/detail/10480360
https://avg.163.com/topic/detail/10480359
https://avg.163.com/topic/detail/10480357
https://avg.163.com/topic/detail/10480348
https://avg.163.com/topic/detail/10480353
https://avg.163.com/topic/detail/10480356
https://avg.163.com/topic/detail/10480351
https://avg.163.com/topic/detail/10480349
https://avg.163.com/topic/detail/10480344
https://avg.163.com/topic/detail/10480341
https://avg.163.com/topic/detail/10480338
https://avg.163.com/topic/detail/10480337
https://avg.163.com/topic/detail/10480333
https://avg.163.com/topic/detail/10480332
https://avg.163.com/topic/detail/10480331
https://avg.163.com/topic/detail/10480329
https://avg.163.com/topic/detail/10480322
https://avg.163.com/topic/detail/10480328
https://avg.163.com/topic/detail/10480327
https://avg.163.com/topic/detail/10480323
https://avg.163.com/topic/detail/10480316
https://avg.163.com/topic/detail/10480319
https://avg.163.com/topic/detail/10480317
https://avg.163.com/topic/detail/10480313
https://avg.163.com/topic/detail/10480310
https://avg.163.com/topic/detail/10480309
https://avg.163.com/topic/detail/10480308
https://avg.163.com/topic/detail/10480217
https://avg.163.com/topic/detail/10480305
https://avg.163.com/topic/detail/10480304
https://avg.163.com/topic/detail/10480303
https://avg.163.com/topic/detail/10480293
https://avg.163.com/topic/detail/10480292
https://avg.163.com/topic/detail/10480287
https://avg.163.com/topic/detail/10480284
https://avg.163.com/topic/detail/10480283
https://avg.163.com/topic/detail/10480281
https://avg.163.com/topic/detail/10480279
https://avg.163.com/topic/detail/10480278
https://avg.163.com/topic/detail/10480277
https://avg.163.com/topic/detail/10480272
https://avg.163.com/topic/detail/10480271
https://avg.163.com/topic/detail/10480264
https://avg.163.com/topic/detail/10480268
https://avg.163.com/topic/detail/10480267
https://avg.163.com/topic/detail/10480265
https://avg.163.com/topic/detail/10480263
https://avg.163.com/topic/detail/10480259
https://avg.163.com/topic/detail/10480256
https://avg.163.com/topic/detail/10480255
https://avg.163.com/topic/detail/10480251
https://avg.163.com/topic/detail/10480247
https://avg.163.com/topic/detail/10480242
https://avg.163.com/topic/detail/10480240
https://avg.163.com/topic/detail/10480239
https://avg.163.com/topic/detail/10480236
https://avg.163.com/topic/detail/10480234
https://avg.163.com/topic/detail/10480233
https://avg.163.com/topic/detail/10480226
https://avg.163.com/topic/detail/10480224
https://avg.163.com/topic/detail/10480220
https://avg.163.com/topic/detail/10480223
https://avg.163.com/topic/detail/10480221
https://avg.163.com/topic/detail/10480219
https://avg.163.com/topic/detail/10480216
https://avg.163.com/topic/detail/10480217
https://avg.163.com/topic/detail/10479774
https://avg.163.com/topic/detail/10480212
https://avg.163.com/topic/detail/10480211
https://avg.163.com/topic/detail/10480209
https://avg.163.com/topic/detail/10480205
https://avg.163.com/topic/detail/10480201
https://avg.163.com/topic/detail/10480202
https://avg.163.com/topic/detail/10480195
https://avg.163.com/topic/detail/10480196
https://avg.163.com/topic/detail/10480194
https://avg.163.com/topic/detail/10480192
https://avg.163.com/topic/detail/10480033
https://avg.163.com/topic/detail/10480184
https://avg.163.com/topic/detail/10480185
https://avg.163.com/topic/detail/10480183
https://avg.163.com/topic/detail/10480176
https://avg.163.com/topic/detail/10480173
https://avg.163.com/topic/detail/10480172
https://avg.163.com/topic/detail/10480171
https://avg.163.com/topic/detail/10480169
https://avg.163.com/topic/detail/10480167
https://avg.163.com/topic/detail/10480165
https://avg.163.com/topic/detail/10480164
https://avg.163.com/topic/detail/10480162
https://avg.163.com/topic/detail/10480161
https://avg.163.com/topic/detail/10480159
https://avg.163.com/topic/detail/10480003
https://avg.163.com/topic/detail/10480157
- 空白键 (space):代表向下翻一页;
- Enter :代表向下翻『一行』;
- /字串 :代表在这个显示的内容当中,向下搜寻『字串』这个关键字;
- :f :立刻显示出档名以及目前显示的行数;
- q :代表立刻离开 more ,不再显示该文件内容。
- b 或 [ctrl]-b :代表往回翻页,不过这动作只对文件有用,对管线无用。
less
一页一页翻动,以下实例输出/etc/man.config文件的内容:
[root@www ~]# less /etc/man.config
#
# Generated automatically from man.conf.in by the
# configure script.
#
# man.conf from man-1.6d
….(中间省略)….
: <== 这里可以等待你输入命令!
less运行时可以输入的命令有:
- 空白键 :向下翻动一页;
- [pagedown]:向下翻动一页;
- [pageup] :向上翻动一页;
- /字串 :向下搜寻『字串』的功能;
- ?字串 :向上搜寻『字串』的功能;
- n :重复前一个搜寻 (与 / 或 ? 有关!)
- N :反向的重复前一个搜寻 (与 / 或 ? 有关!)
- q :离开 less 这个程序;
head
取出文件前面几行
语法:





