查看linux内存

1. ps -aux | sort -k 4n  | tail -n 10   对使用内存排序

或者

ps -aux | sort -k 3n  | tail -n 10  对cpu进行排序

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         2323  0.0  0.1  43520  2968 ?        Ss   Mar18   1:04 /usr/lib/systemd/systemd --system --deserialize 15
root         33333  0.0  0.0      0     0 ?        S    Mar18   0:00 [kthreadd]
 

2.查看机器当前内存

 free -m
                    total        used        free      shared  buff/cache   available
Mem:           1838        1080          84           0         673         604
Swap:             0           0           0

3.杀掉进程,减少内存消耗,PID 是第一步查出来的

 kill  -9  PID

4.查看PID所属文件

pwdx PID

5.使用top分析

使用top 命令可以实时的监视进程 检查进程,也可以使用top -p PID 查看指定进程

获取使用内存最高的PID,    然后top -p PID -H 查看里面的线程信息

jstack  线程PID | grep a3a4    转化成人类语言,分析

 

6.阿里云被人入侵挖矿了

kill 完进程之后会反复重启,所以需要删除源文件

获取反复重启的进程PID

ls -l  /proc/PID

查看cwd 对应的文件

lrwxrwxrwx    1 root root 0 Apr 15 21:31 cwd -> /tmp/.ice-unix/

 删除对应的文件,rm 命令符如果删除不了,需要使用chattr 命令

lsattr   File   查看这个文件的权限

chattr   -(aAcCdDeijsStTu)  File    删除文件对应权限

[root@hadoop90 etc]# touch test  创建文件
[root@hadoop90 etc]# chattr +i test  给test文件添加权限    
[root@hadoop90 etc]# lsattr test    查看文件权限
----i--------e-- test
[root@hadoop90 etc]# rm -rf test  尝试rm删除,失败
rm: cannot remove ‘test’: Operation not permitted
[root@hadoop90 etc]# chattr -i -e test  去除权限之后,可以成功删除
[root@hadoop90 etc]# lsattr test
---------------- test
[root@hadoop90 etc]# rm -rf test
[root@hadoop90 etc]# ls -l |grep test
[root@hadoop90 etc]#

在执行rm -rf File 操作就可以删除文件了,如果还有挖矿进程在运行,在杀掉进程看看

有的还修改了/etc/crontab  定时任务,那就需要修改/etc/crontab文件

vi  /etc/crontab

SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
MAILTO=root
#
# check scripts in cron.hourly, cron.daily, cron.weekly, and cron.monthly
#
就是下面这个  删除或者注释掉  
# -*/15 * * * *   root  test -x /usr/lib/cron/run-crons && /usr/lib/cron/run-crons >/dev/null 2>&1

接着修改对应用户.ssh/authorized_keys,一般都是root,这个文件可能也被修改了

[root@hadoop90 ~]# echo ""> /root/.ssh/authorized_keys 
-bash: /root/.ssh/authorized_keys: Permission denied
[root@hadoop90 ~]# lsattr /root/.ssh/authorized_keys 
----i----------- /root/.ssh/authorized_keys
[root@hadoop90 ~]# chattr -i /root/.ssh/authorized_keys 
[root@hadoop90 ~]# echo ""> /root/.ssh/authorized_keys

被挖矿真的很恶心啊,我擦

 

 

 

 

 

参考:

https://www.jianshu.com/p/6d573e42310a

https://blog.csdn.net/cxy1991xm/article/details/97000287     

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值