`

head&tail&nohup&tar&find&cat&du&grep&cp&mv&chkconfig&service

阅读更多

1.head     tail

 

head test.txt

显示test.txt的前十行

head -n 20 test.txt

显示test.txt的前20

tail test.txt 

显示test.txt的后十行

tail -n 20 test.txt

显示test.txt的后20

tail -f test.txt

显示文件后十行,当文件有新增的时候自动显示新增的内容

 

2.nohup

 nohup 命令用于后台启动一个服务,相当于启动一个线程保护启动的服务

egnohup  ./xxx.sh &

 

3. tar打包/压缩/解包

-c  创包

-x  解包

-t  列出包中的内容

-r  增加文件到指定包

-u  更新包中的文件

-v  显示打包过程

-C  指定解包后的路径

-f  指定包文件名

-z  使用gzip进行压缩和解压

eg tar -zcvf  temp.tar.gz    /temp                      temp目录压缩打包到temp.tar.gz

egtar -zxvf   temp.tar.gz   -C  /home                temp.tar.gz解压到/home目录下

 

 

4.find用来查找指定文件

find  查找目录  表达式

eg find   .  -name  test.txt      在当前目录及其子目录下查找指定文件

egfind      /temp  -name  test.txt

  

5.cat 

cat  test.txt  test2.txt                                                    依次显示test.txt test2.txt

cat  test.txt  test2.txt > test3.txt                                显示test.txt test2.txt的内容到test3.txt

  

6.du  eg du   -sh  /test   查看test目录占用空间大小

   

7.grep

grep  [命令选项]   匹配模式   [要查找的文件]

eggrep  cams  test.txt                 test.txt中查找cams字符串

eggrep -r  cams   /test                 test目录以及子目录所有文件中查找cams字符串

 

grep输出流重定向进行查找

egps  -ef | grep  java   查找所有包含java的进程 

 

 8. cp

cp  -r  源文件    目的文件 

egcp  -r  ./ROOT   ./test

 

9..mv  移动  

重命名

egmv  /temp/test.txt   /root         移动

egmv  test.txt  testbak.txt             重命名

 

10.chkconfig查看服务   chkconfig --list

11.service 启动/停止/重启服务如httpd服务

    service httpd start

    service httpd stop

    service httpd restart

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics