linux管理文件,Linux 管理文件与目录
我们先看下文
Linux文件是以根为起始点,在Linux / 代表起始也就是根,因为Linux是倒树根你可以直接理解成一棵树倒着,先是树根,然后树干,再然后树枝最后到达树叶比如:/home/user/1.txt 我们先看下文件的路径全貌 [root@localhostuser]#ls/home/user/1.txt /home/user/1.txt 一、常用的文件及目录的管理命令吧! ls:列出文件 [root@localhostuser]#ls 1.txt cd:切换目录比如 [root@localhostuser]#pwd /home/user [root@localhostuser]#cd/usr/local/ [root@localhostlocal]#pwd /usr/local pwd:显示当前目录位置 [root@localhostuser]#pwd /home/user mkdir:创建目录 [root@localhostuser]#ls 1.txt [root@localhostuser]#mkdirtest [root@localhostuser]#ll 总用量4 -rw-r--r--1rootroot09月2222:061.txt drwxr-xr-x2rootroot40969月2222:10test cp:复制文件或目录 [root@localhostuser]#lstest/ [root@localhostuser]#cp1.txttest/ [root@localhostuser]#lstest/ 1.txt mv:剪切或者重命名 [root@localhostuser]#lstest/ 1.txt [root@localhostuser]#ls 1.txttest [root@localhostuser]#mv1.txt2.txt [root@localhostuser]#ls 2.txttest [root@localhostuser]#mv2.txttest/ [root@localhostuser]#ls test [root@localhostuser]#lstest/ 1.txt2.txt rm:删除文件或目录 [root@localhostuser]#lstest/ 1.txt2.txt [root@localhostuser]#rmtest/1.txt rm:是否删除普通空文件"test/1.txt"?y [root@localhostuser]#lstest/ 2.txt [root@localhostuser]#rm-rtest/ rm:是否进入目录"test"?y rm:是否删除普通空文件"test/2.txt"?y rm:是否删除目录"test"?y [root@localhostuser]#ls [root@localhostuser]# 二、文件查看 cat:查看文件内容,从第一行开始 [root@localhostuser]#cat1.txt TheisTestpage. TheisTestpage2. TheisTestpage3. tac:查看内容文件,从最后一行开始 [root@localhostuser]#tac1.txt TheisTestpage3. TheisTestpage2. TheisTestpage. nl:查看内容文件,显示的时候顺带显示行 [root@localhostuser]#nl1.txt 1TheisTestpage. 2TheisTestpage2. 3TheisTestpage3. more:查看内容,分屏显示,该命令在文件内容较多的时候使用效果直观,省略了部分内容~注意看--More--(25%)一个屏幕显示了四分之一的内容 [root@localhostuser]#more/etc/man.config # #Generatedautomaticallyfromman.conf.inbythe#configurescript. ... #ThekeywordFHSwillcausethisbehaviour(andoverridesFSSTND). #Explicitlygivencatdirsoverride. --More--(25%) less:类似more只不过less可以往上翻 head:可以查看前几行 [root@localhostuser]#head/etc/man.config # #Generatedautomaticallyfromman.conf.inbythe #configurescript. # #man.conffromman-1.6f # #Formoreinformationaboutthisfile,seethemanpagesman(1) #andman.conf(5). # #Thisfileisreadbymantoconfigurethedefaultmanpath(alsoused tail:只看最后几行(默认10行) [root@localhostuser]#tail/etc/man.config # #Enable/disablemakewhatisdatabasecronupdates. #IfMAKEWHATISDBUPDATESvariableisuncommented #andsettonorN,cronscripts #/etc/cron.daily/makewhatis.cron #/etc/cron.weekly/makewhatis.cron #willnotupdatemakewhatisdatabase. #Otherwisethedatabasewillbeupdated. # #MAKEWHATISDBUPDATESn 当然也可以使用head与tail组合查看特定的行Linux 文件与目录管理,比如我只想看1.txt的第二行: [root@localhostuser]#cat1.txt TheisTestpage. TheisTestpage2. TheisTestpage3. [root@localhostuser]#head-21.txt|tail-1 TheisTestpage2. [root@localhostuser]# 至此简单的文件及目录的管理查看命令基本就OK拉 欢迎大家关注459479177QQ群 (编辑:晋中站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |