linux----进程管理

进程管理

类似于 windows系统中的ctrl+shift+esc 进程管理

  • ps process status 进程状态的意思 报告进程的状态 kill killall 干掉

    • -a 显示所有的进程

    • -u 指定用户的进程详细信息

    • -x 通常跟a一起来用 列出详细的信息

    • -r 正在运行的进程

sudo ps -a | more -5     #显示所有的进程 分页显示 每页显示5个
sudo ps -u root | more 20

sudo ps -u root | grep kworker



root@ubuntu:~# ps -aux | grep nginx #重点 常用 ★★★★★
root     114640  0.0  0.0  28352   868 ?       Ss   00:26   0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
www      114641  0.0  0.8  50024 25472 ?       S    00:26   0:00 nginx: worker process
www      114642  0.0  0.8  50024 25472 ?       S    00:26   0:00 nginx: worker process
root     115424  0.0  0.0  15972   972 pts/23   S+   00:42   0:00 grep --color=auto nginx
#上面表明服务启动



#用户     #进程号 #cpu占用率   #内存占用率 #虚拟内存   #驻留内存的量   #进程的控制终端 ?表示不是终端进入de #进程的状态 R就绪 S可中断的休眠状态   T暂停 #进程的开始时间   #已经执行的时间   #进程名字
www      114641  0.0          0.8         50024     25472           ?       S    00:26   0:00 nginx: worker process



root@ubuntu:~# service nginx stop
root@ubuntu:~# ps -aux | grep nginx
root     115466  0.0  0.0  15972  1084 pts/23   S+   00:43   0:00 grep --color=auto nginx
守护进程  


#下面表明 服务停止


#杀死进程 kill  


1.kill 进程号   #杀死指定的进程
2.kill -9 进程号   #强制杀死制定的进程


killall -TERM 进程名字 比如 killall -TERM nginx 杀死所有跟nginx 相关的进程


  • netstat 查看某一个服务是否启动了

netstat -ntlp | grep 端口号或者服务名称  
举例:
root@ubuntu:~# netstat -ntlp | grep 22
tcp       0     0 0.0.0.0:22             0.0.0.0:*               LISTEN     1051/sshd
tcp6       0     0 :::22                   :::*                   LISTEN     1051/sshd

 

 

  • top

类似于 windows ctrl+shift+esc q退出

#服务器当前的时间    #系统运行的时间 分钟  #登录用户数    #系统的负载   1分钟平均负载 5分钟 15分钟 单核 这些不会超过1 
top - 00:55:45       up 8:40,             5 users,   load average: 0.00, 0.00, 0.02
#任务数 运行 休眠 停止
Tasks: 261 total,   1 running, 191 sleeping,   0 stopped,   0 zomb
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.
总内存   空闲 使用 用户缓存的
KiB Mem : 3014208 total,   646580 free, 1350112 used, 1017516 b
交换分区
KiB Swap:   998396 total,   998396 free,       0 used. 1326144 a


更加方便的工具  

apt-get install htop

htop  
q退出  

 

猜你喜欢

转载自www.cnblogs.com/quietzpc/p/12170691.html