linux常用命令

发布时间 2023-09-19 11:07:34作者: 无敌小阿没

1.前十大占用内存

ps aux --sort=-%mem | head -n 11

2.查看系统中特定的文件

find / -name *read*

3.查看当前目录下的指定文件

find . -name *read*

4.安装已经解压过的包

python ./setup.py install

5.排序 升序

ls -tlrb

6.统计文件的个数

ls|wc -l

7.查看挂载盘的情况

df -h

8.查看单个目录的大小

du -sh 

9.全部目录各个文件的大小

du -sh *

10.查看内核版本

cat /proc/version

11.查看cpu的信息

cat /proc/cpuinfo

12.redhat的版本 cat /etc/redhat-release,centos的版本 cat /etc/centos-release,ubuntu的系统版本 cat /etc/issue

13.ubuntu系统版本 lsb-release -a

14.防火墙状态 ufw status  

15.vim快速到第一行 gg,快速到最后一行 G

16.删除特定时间和特定大小的日志语句(删除30天之前的,且大于100M的日志)

find . -name "*.log" -mtime +30 -type f -size +100M|xargs rm -rf {}

17.重启mysql数据库 

service mysql start

查看mysql的状态 

service mysql status

pid服务的位置

pwdx pid

18.替换文件指定的内容(将t.txt文件中的hello替换为hhhh) 

sed -i 's/hello/hhhh/g' t.txt

19.查看端口

lsof -i:port

netstat -anp|grep port