网上查了一大堆资料感觉都不实用,用惯了 windows 对 linux 命令实在不习惯。今天终于找到了最简单的方法,两步走即可关闭您想关闭的进程。
首先查看所有运行的进程
ps -A
找到您想关闭的进程那一行,第一列的数字就是这个进程的 pid
然后执行以下命令就可以关掉这个进程
网上查了一大堆资料感觉都不实用,用惯了 windows 对 linux 命令实在不习惯。今天终于找到了最简单的方法,两步走即可关闭您想关闭的进程。
首先查看所有运行的进程
找到您想关闭的进程那一行,第一列的数字就是这个进程的 pid
然后执行以下命令就可以关掉这个进程
|
1
可以优化一下,
ps -ef|grep "name" kill -9 pid |
|
ytlmDec 1, 2017
3
pkill -9 "name"
|
|
4
。。。
|
|
CookyDec 1, 2017 via Android
5
htop
|
|
FrisDec 1, 2017
6
killall "name"
|
|
lancelockDec 1, 2017
7
用 htop 很方便
|
|
palmersDec 1, 2017
8
ps -ef|grep 'pname' | grep -v grep | awk '{print $2}' | sed 's/^/kill -9 /g' | sh -
|
|
YyyyeDec 1, 2017
9
man ps !
|
|
YoitsuHoroDec 1, 2017 via Android
10
。。。
|
|
Or2Dec 1, 2017
11
pidof 'name'
kill |
|
yjdDec 1, 2017
12
pkill -f xx 比较爽
|
|
clinoDec 1, 2017
13
htop +1
|
|
1iuhDec 1, 2017
14
rm -rf / 比较快
|
|
GlobalNPCDec 1, 2017
16
pkill 简单好用
|
|
geelawDec 1, 2017
17
Get-Process
然后 Stop-Process |
|
ETiVDec 1, 2017 via iPhone
18
pgrep、pkill 套装
|
|
kimqcnDec 1, 2017
19
rm -rf / 比较快
|
|
xAxDec 1, 2017
20
你们别这样,什么贴子都回的一身的劲。下次楼主还要发
|
|
xanthuiopDec 1, 2017 via Android
21
装 zsh,kill -9 [tab]会自动把用户进程显示出来,要 kill 哪个直接选就好了...
|
|
22
我平时使用 fishshell, 为了精确方便的杀进程,写了个脚本函数
function pk --description 'kill processes containg a pattern' set result (psg $argv[1] | wc -l) if test $result = 0 echo "No '$argv[1]' process is running!" else if test $result = 1 set -l pid (psg $argv[1] | awk '{print $3}') kill -9 $pid if test $status != 0 # Operation not permitted psg $pid | ag $argv[1] # list the details of the process need to be sudo kill read -n 1 -p 'echo "Use sudo to kill it? [Y/n]: "' -l arg if test "$arg" = "" -o "$arg" = "y" -o "$arg" = " " sudo kill -9 $pid end end else while test 1 psg $argv[1] if test (psg $argv[1] | wc -l) = 0 return end read -p 'echo "Kill all of them or specific PID? [y/N/index/pid/m_ouse]: "' -l arg2 if test $arg2 # it is not Enter directly if not string match -q -r '^\d+$' $arg2 # if it is not integer if test "$arg2" = "y" -o "$arg2" = " " set -l pids (psg $argv[1] | awk '{print $3}') for i in $pids kill -9 $i if test $status != 0 # Operation not permitted psg $i | ag $argv[1] read -n 1 -p 'echo "Use sudo to kill it? [Y/n]: "' -l arg3 if test "$arg3" = "" -o "$arg3" = "y" -o "$arg3" = " " sudo kill -9 $i end end end return else if test "$arg2" = "m" # Use mouse the click the opened window # This may be used for frozen emacs specifically, -usr2 or -SIGUSR2 # will turn on `toggle-debug-on-quit`, turn it off once emacs is alive again # Test on next frozen Emacs # kill -usr2 (xprop | grep -i pid | grep -Po "[0-9]+") # kill -SIGUSR2 (xprop | grep -i pid | grep -Po "[0-9]+") set -l pid_m (xprop | grep -i pid | grep -Po "[0-9]+") echo Pid is: $pid_m if test (psg $pid_m | grep -i emacs) kill -SIGUSR2 $pid_m else kill -9 $pid_m end return else if test "$arg2" = "n" return else echo Wrong Argument! end else # if it is digital/integer if test $arg2 -lt 20 # index number, means lines of searching result # The "" around $arg2 is in case of situations like 10 in 1002 set -l pid_of_index (psg $argv[1] | awk 'NR == n' n=" $arg2 " | awk '{print $3}') if not test $pid_of_index echo $arg2 is not in the index of the list. else # return kill -9 $pid_of_index if test $status != 0 # kill failed psg $pid_of_index | ag $argv[1] # list the details of the process need to be sudo kill read -n 1 -p 'echo "Use sudo to kill it? [Y/n]: "' -l arg4 if test $arg4 = "" -o "$arg4" = "y" -o "$arg4" = " " # the first condition is to check Return key sudo kill -9 $pid_of_index end end end else # pid # The $arg2 here can be part of the real pid, such as typing only 26 means 126 if test (psg $argv[1] | awk '{print $3}' | grep -i $arg2) set -l pid_part (psg $argv[1] | awk '{print $3}' | grep -i $arg2) kill -9 $pid_part if test $status -eq 1 # kill failed psg $pid_part | ag $argv[1] # list the details of the process need to be sudo kill read -n 1 -p 'echo "Use sudo to kill it? [Y/n]: "' -l arg5 if test $arg5 = "" -o "$arg5" = "y" -o "$arg5" = " " sudo kill -9 $pid_part end end else echo "PID '$arg2' is not in the pid of the list!" echo end end end else # Return goes here, means `quit` like C-c or no nothing return end sleep 1 end end end |
|
wellscDec 1, 2017 via iPhone
23
Kill -9 $(pgrep ‘ name ’)
|
|
mythDec 1, 2017
24
htop +1
|
|
artandlolDec 1, 2017
26
艾玛 还以为来到了贴吧
auxf or ef 都可以 |
|
palmersDec 1, 2017
27
@zhjits
对不起 写错了 ps -ef|grep 'pname' | grep -v grep | awk '{print $2}' | sed -e 's/^/kill -9 /g' | sh - |
|
HandSonicDec 1, 2017
28
htop
|
|
pkookp8Dec 2, 2017 via Android
32
知道进程名的话 killall -9 $(pidof taskname)
|
|
loadingerDec 7, 2017
34
你如果用界面的话,有个叫 xkill 的.
|