当前位置:   article > 正文

linux命令应用大全,linux常用命令大全(精心整理-收藏了).pdf

linux命令应用大全,linux常用命令大全(精心整理-收藏了).pdf

linux常用命令大全(精心整理-收藏了)

文件、目录类

1.  cd dir

2.  cd ‐    //返回上一次所在的目录

3.  cd    //cd不加任何,返回home目录

4.  pwd

5.  ls ‐l    ll

6.  mkdir dir

7.  mkdir ‐p dir/dir

8.  touch file

9.  rmdir dir    //空目录

10.  rmdir ‐p //空目录

11.  rm ‐rf dir

12.  rm ‐rf file

13.  find dir ‐name *.txt  | xargs rm ‐rf    //将查找出来的文件都删除

14.  cp file dir/file

15.  cp ‐R dir1 dir2    //dir含子目录

16.  mv dir1 dir2

17.

18.  echo  'hello  world'    ‐‐>hello  world

文件查看、处理

1.  cat file

2.  cat ‐n file    //查看前面行

3.  head ‐n file

4.  tail ‐n file

5.  more file

6.  less file

7.  cat file1 > file2    //覆盖导入

8.  cat file1 >> file2    //追加导入

9.  vi file

10.  wc ‐l[‐m][‐c][‐w] file    //统计行数、字符数、字节数、单词数

文件查询、搜索、替换

1.  grep keyword    //常与cat搭配使用 cat file  | grep keword

2.  find dir ‐name file/dir    //搜索指定目录下的文件/目录名 *.txt    ??.log

3.  find  ./ ‐name "*.xml" ‐o ‐name "*.xsd"        //查找.xml或.xsd的文件

4.  find  ./ ‐maxdepth 3 ‐iname "applicationConsumer.xml"    //设置查询目录深度

5.  find dir ‐user user1    //搜索属于指定目录下属于user1的文件/目录

6.  locate file    //根据索引查找文件,需先运行"updatedb"

7.  sed ‐i  's/string1/string2/g' test.txt    //将test.txt中的string1替换成string2;‐i表示修

8.  sed ‐ne  '3,5p' test.txt    //查看test.txt的第三行到第五行

9.  awk ‐F  :  '{print $1,$5}' test.txt    //查看test.txt的第一列到第五列,列间用":"隔开

10.  awk  '{print $1,$5}' test.txt    //查看test.txt的第一列到第五列,列间用空格隔开

文本编辑vi底行模式下

1.  :set nu    //显示行号

2.  :set nonu    //不显示行号

3.  :n    //跳转到指的第n行

4.  :w file    //另存为

5.  :n1,n2 s/string1/string2/g    //从n1行到n2行将string1替换为string2

6.  :%s/string1/string2/g       //将所有行string1替换为string2,%代表所有行,g表示所有string1

7.  :%s+/usr/local/bin+/usr/bin+g    //替换的字符中含有“/”时,用+来代替/

8.  :wq    //保存并退出

9.  :q!    //强制退出,不保存

文本编辑vi命令模式下

1.  G    //到末行

2.  gg    //到首行

3.  dd    //删除行

4.  u    //撤销

5.  yy    //复制一行

6.  nyy    //复制n行

7.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/59219
推荐阅读
相关标签
  

闽ICP备14008679号