linux - 如何杀死不存在的程序进程

标签 linux kill ps

前几天,我在我的ubuntu 16.04上安装了shellinabox,因为我不再使用它了,所以我通过sudo apt-get remove shellinabox卸载了它。卸载成功后,查看进程,发现shellinabox进程还在,如果杀掉这个进程,过几秒又会显示。

ldh@ldh55:~$ 
ldh@ldh55:~$ ps -ef|grep shellinabox
ldh        5178  10185  0 14:10 pts/21   00:00:00 grep --color=auto shellinabox
nobody   113899 113881  0 13:56 ?        00:00:00 shellinaboxd -t -s /:LOGIN -s /python:shell:shell:HOME:/usr/bin/python -s /ipython:shell:shell:HOME:/usr/bin/ipython -s /python3:shell:shell:HOME:/usr/bin/python3 -s /ipython3:shell:shell:HOME:/usr/bin/ipython3 -s /cling:shell:shell:HOME:/usr/local/bin/cling --static-file=styles.css:/usr/local/share/shellinabox/shellinabox.css --user-css=Tomorrow Light:+/usr/local/share/shellinabox/theme-tomorrow-light.css,Tomorrow Dark:-/usr/local/share/shellinabox/theme-tomorrow-dark.css
nobody   113990 113899  0 13:56 ?        00:00:00 shellinaboxd -t -s /:LOGIN -s /python:shell:shell:HOME:/usr/bin/python -s /ipython:shell:shell:HOME:/usr/bin/ipython -s /python3:shell:shell:HOME:/usr/bin/python3 -s /ipython3:shell:shell:HOME:/usr/bin/ipython3 -s /cling:shell:shell:HOME:/usr/local/bin/cling --static-file=styles.css:/usr/local/share/shellinabox/shellinabox.css --user-css=Tomorrow Light:+/usr/local/share/shellinabox/theme-tomorrow-light.css,Tomorrow Dark:-/usr/local/share/shellinabox/theme-tomorrow-dark.css
ldh@ldh55:~$ 
ldh@ldh55:~$ kill -9 113899
-bash: kill: (113899) - Operation not permitted
ldh@ldh55:~$ sudo !!
sudo kill -9 113899
ldh@ldh55:~$ ps -ef|grep shellinabox
ldh        5637  10185  0 14:10 pts/21   00:00:00 grep --color=auto shellinabox
ldh@ldh55:~$ 
ldh@ldh55:~$ ps -ef|grep shellinabox
ldh        5754  10185  0 14:10 pts/21   00:00:00 grep --color=auto shellinabox
ldh@ldh55:~$ ps -ef|grep shellinabox
nobody     5693   5675  1 14:10 ?        00:00:00 shellinaboxd -t -s /:LOGIN -s /python:shell:shell:HOME:/usr/bin/python -s /ipython:shell:shell:HOME:/usr/bin/ipython -s /python3:shell:shell:HOME:/usr/bin/python3 -s /ipython3:shell:shell:HOME:/usr/bin/ipython3 -s /cling:shell:shell:HOME:/usr/local/bin/cling --static-file=styles.css:/usr/local/share/shellinabox/shellinabox.css --user-css=Tomorrow Light:+/usr/local/share/shellinabox/theme-tomorrow-light.css,Tomorrow Dark:-/usr/local/share/shellinabox/theme-tomorrow-dark.css
nobody     5758   5693  0 14:10 ?        00:00:00 shellinaboxd -t -s /:LOGIN -s /python:shell:shell:HOME:/usr/bin/python -s /ipython:shell:shell:HOME:/usr/bin/ipython -s /python3:shell:shell:HOME:/usr/bin/python3 -s /ipython3:shell:shell:HOME:/usr/bin/ipython3 -s /cling:shell:shell:HOME:/usr/local/bin/cling --static-file=styles.css:/usr/local/share/shellinabox/shellinabox.css --user-css=Tomorrow Light:+/usr/local/share/shellinabox/theme-tomorrow-light.css,Tomorrow Dark:-/usr/local/share/shellinabox/theme-tomorrow-dark.css
ldh        5792  10185  0 14:10 pts/21   00:00:00 grep --color=auto shellinabox
ldh@ldh55:~$ 
ldh@ldh55:~$ sudo ls -l /proc/5693/
total 0
dr-xr-xr-x 2 nobody nogroup 0 Sep  5 14:11 attr
-rw-r--r-- 1 root   root    0 Sep  5 14:11 autogroup
-r-------- 1 root   root    0 Sep  5 14:11 auxv
-r--r--r-- 1 root   root    0 Sep  5 14:10 cgroup
--w------- 1 root   root    0 Sep  5 14:11 clear_refs
-r--r--r-- 1 root   root    0 Sep  5 14:10 cmdline
-rw-r--r-- 1 root   root    0 Sep  5 14:11 comm
-rw-r--r-- 1 root   root    0 Sep  5 14:11 coredump_filter
-r--r--r-- 1 root   root    0 Sep  5 14:11 cpuset
lrwxrwxrwx 1 root   root    0 Sep  5 14:11 cwd -> /home/shell
-r-------- 1 root   root    0 Sep  5 14:10 environ
lrwxrwxrwx 1 root   root    0 Sep  5 14:10 exe -> /usr/bin/shellinaboxd
dr-x------ 2 root   root    0 Sep  5 14:10 fd
dr-x------ 2 root   root    0 Sep  5 14:11 fdinfo
-rw-r--r-- 1 root   root    0 Sep  5 14:11 gid_map
-r-------- 1 root   root    0 Sep  5 14:11 io
-r--r--r-- 1 root   root    0 Sep  5 14:11 limits
-rw-r--r-- 1 root   root    0 Sep  5 14:11 loginuid
dr-x------ 2 root   root    0 Sep  5 14:11 map_files
-r--r--r-- 1 root   root    0 Sep  5 14:11 maps
-rw------- 1 root   root    0 Sep  5 14:11 mem
-r--r--r-- 1 root   root    0 Sep  5 14:10 mountinfo
-r--r--r-- 1 root   root    0 Sep  5 14:11 mounts
-r-------- 1 root   root    0 Sep  5 14:11 mountstats
dr-xr-xr-x 5 nobody nogroup 0 Sep  5 14:11 net
dr-x--x--x 2 root   root    0 Sep  5 14:10 ns
-r--r--r-- 1 root   root    0 Sep  5 14:11 numa_maps
-rw-r--r-- 1 root   root    0 Sep  5 14:11 oom_adj
-r--r--r-- 1 root   root    0 Sep  5 14:11 oom_score
-rw-r--r-- 1 root   root    0 Sep  5 14:10 oom_score_adj
-r-------- 1 root   root    0 Sep  5 14:11 pagemap
-r-------- 1 root   root    0 Sep  5 14:11 personality
-rw-r--r-- 1 root   root    0 Sep  5 14:11 projid_map
lrwxrwxrwx 1 root   root    0 Sep  5 14:11 root -> /
-rw-r--r-- 1 root   root    0 Sep  5 14:11 sched
-r--r--r-- 1 root   root    0 Sep  5 14:11 schedstat
-r--r--r-- 1 root   root    0 Sep  5 14:11 sessionid
-rw-r--r-- 1 root   root    0 Sep  5 14:11 setgroups
-r--r--r-- 1 root   root    0 Sep  5 14:11 smaps
-r-------- 1 root   root    0 Sep  5 14:11 stack
-r--r--r-- 1 root   root    0 Sep  5 14:10 stat
-r--r--r-- 1 root   root    0 Sep  5 14:11 statm
-r--r--r-- 1 root   root    0 Sep  5 14:10 status
-r-------- 1 root   root    0 Sep  5 14:11 syscall
dr-xr-xr-x 3 nobody nogroup 0 Sep  5 14:11 task
-r--r--r-- 1 root   root    0 Sep  5 14:11 timers
-rw-r--r-- 1 root   root    0 Sep  5 14:10 uid_map
-r--r--r-- 1 root   root    0 Sep  5 14:11 wchan
ldh@ldh55:~$ 
ldh@ldh55:~$ ll /usr/bin/shellinaboxd
ls: cannot access '/usr/bin/shellinaboxd': No such file or directory
ldh@ldh55:~$

最佳答案

感谢@Amadan和@pitseeker,我检查了父进程的pstree,发现奇怪的进程可能是docker容器中的shellinabox进程,因为我也运行了shellinabox docker容器。

ldh@ldh55:~$ pstree -p 5675
docker-containe(5675)─┬─shellinaboxd(5693)───shellinaboxd(5758)
                      ├─{docker-containe}(5676)
                      ├─{docker-containe}(5677)
                      ├─{docker-containe}(5678)
                      ├─{docker-containe}(5679)
                      ├─{docker-containe}(5680)
                      ├─{docker-containe}(5681)
                      ├─{docker-containe}(5682)
                      ├─{docker-containe}(5683)
                      └─{docker-containe}(5757)
ldh@ldh55:~$ ps -ef|grep 5675
root       5675  15288  0 14:10 ?        00:00:00 docker-containerd-shim a865ae1d7398f23f8c3e484bce9817522b57a5f68d37a6756e812c93e72e4d1c /var/run/docker/libcontainerd/a865ae1d7398f23f8c3e484bce9817522b57a5f68d37a6756e812c93e72e4d1c docker-runc
nobody     5693   5675  0 14:10 ?        00:00:00 shellinaboxd -t -s /:LOGIN -s /python:shell:shell:HOME:/usr/bin/python -s /ipython:shell:shell:HOME:/usr/bin/ipython -s /python3:shell:shell:HOME:/usr/bin/python3 -s /ipython3:shell:shell:HOME:/usr/bin/ipython3 -s /cling:shell:shell:HOME:/usr/local/bin/cling --static-file=styles.css:/usr/local/share/shellinabox/shellinabox.css --user-css=Tomorrow Light:+/usr/local/share/shellinabox/theme-tomorrow-light.css,Tomorrow Dark:-/usr/local/share/shellinabox/theme-tomorrow-dark.css
ldh      104903  90695  0 15:11 pts/22   00:00:00 grep --color=auto 5675
ldh@ldh55:~$
ldh@ldh55:~$ docker ps|grep shellinabox
a865ae1d7398        9d6d77a31ef3                                             "shellinaboxd -t -..."   5 months ago        Up About an hour    0.0.0.0:5200->4200/tcp                          shellinaboxshell_shellinabox-shell_1
ldh@ldh55:~$ 
ldh@ldh55:~$ docker stop a865ae1d7398
a865ae1d7398
ldh@ldh55:~$ 
ldh@ldh55:~$ ps -ef|grep shellinabox
ldh      115468  90695  0 15:17 pts/22   00:00:00 grep --color=auto shellinabox
ldh@ldh55:~$ 
ldh@ldh55:~$

关于linux - 如何杀死不存在的程序进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52178216/

相关文章:

linux - 使用 Ansible 自动设置加密分区

linux - 无法清除父级为 init 的僵尸进程

linux - 在没有特定 session 的情况下杀死 screen #

linux - 如何通过 'wmctl' 和 'ps' 获得 X 应用程序的完整命令?

php - 为什么无法创建此目录?

c - 是否有可能在运行时获得递归值?

linux - 从 gzip 文件的开头剥离 bash 脚本

c - 为什么我的信号处理程序不处理 SIGKILL,有时会导致帐户注销

java - Linux下使用 'ps'命令,如何查看实时数据?

linux - 如何在 lunux 中找到进程及其所有子进程的总内存和 cpu 使用情况