Linux常用命令

1、查找/opt目录下大于1G大小的文件命令:

find /opt/  -type f -size +1G

2、一台机器上部署多个tomcat时,删除指定tomcat进程

ps -ef|grep jypt-tomcat|grep 'jdk'|awk '{print $2}'|xargs kill -9

3、vi编辑态模式下批量修改

:%s/原字符窜/修改后字符串/g

4、批量替换单个文件中的字符串

sed -i 's/原字符串/替换后字符串/g' file_name

5、批量替换多个文件中的字符串

sed -i 's/原字符串/替换后的字符串/g' ·grep 原字符串 -rl 目录·

6、查询某个目录下带mainbo字符串的文件(查询包括二级、三级目录)

grep -rl mainbo 查询目录

7、vi编辑文件指定行【比如:编辑第20行】

vi file_name +20

8、查看文件的行数、单词数、字符数、最长行的长度

nl file_name | wc -l

nl file_name | wc -w

nl file_name | wc -m

nl file_name | wc -L

9、获取tomcat指定时间段内的日志

sed -n '/起止时间/,/终止时间/p' catalina.out

 10、查看文件可以使用命令如下

(1)nl、(2)cat、(3)less、(4)more、(5)tac

11、已知端口号,找到对应的进程

lsof -i:port

netstat aux|grep port

12、已经进程id,找到对应应用

ps aux|grep PID

原文地址:https://www.cnblogs.com/Will-guo/p/6373729.html