How do I kill all processes running by my own non-root account?
I have some spinning smbd processes that I caused from my windows machine and so I telnetted into the linux server and I want to kill those spinning processes. I don't have authority to restart services or reboot the machine.
To kill all the processes that you have the permission to kill, simply run the command
kill -15 -1
orkill -9 -1
depending on the desired behavior (useman kill
for details)To kill a specific process, say, firefox, simply run
pkill firefox
orkillall firefox
depending on the behavior you want: What's the difference between 'killall' and 'pkill'?If you want to see what processes are running use the command
If you want to look up all processes by user bob, this might help
or
Use
sudo kill <pid>
orsudo killall <process-name>
You can use
If your searching for firefox type in terminal like
ps -ax | grep firefox
, it shows the process id of corresponding application. You can stop that application bykill
command if process id=1317,Let's try something more:
The
top
command is the traditional way to view your system’s resource usage and see the processes that are taking up the most system resources. Top displays a list of processes, with the ones using the most CPU at the top.htop
displays the same information with an easier-to-understand layout. It also lets you select processes with the arrow keys and perform actions, such as killing them or changing their priority, with the F keys.I would use
xkill
. Enterxkill
in a terminal and click in the window, or enterxkill
and the process ID and it will be terminated.Found out more about
xkill
on x.org.I'd break your problem into 2 parts:
1) How do I find the processes started by me? Run this:
The
whoami
is just in case you don't know the name of the account you are using, otherwise just type the name of the account without the back quotes.This will list all processes that can be deleted by your account.
2) The
ps
command will list the process number, the TTY, Time, and CMD. The process ID is the first column. Use that number to kill the process. Be careful while killing the process. You might break something if you kill the wrong process. To kill a process you will use thekill
command, which sends a SIGNAL to the process. The signal indicates what the process should do. For example, sending a-1
to the process will ask it to reload the configuration file; sending a-2
is equivalent to pressing the Control+C on that process;-9
will cause the kernel to abandon the process, without communicating it to the process.Supposing that ps -u
whoami
returned something likeAnd you wanted to kill the
firefox
process by its process id, then you'd do:Then you'd re-run the same
ps
command and check if the process was still running. If it is still running, then do aworking your way up to
-9
.To kill all processes started by your account, enter
kill <level> -1
. Same as before: work your way up to-9
.If you know the name of the process you can simply go
killall <processname>
, where the is what you are trying to kill. For example:killall fish
(fish, in this sense, is the Friendly Interactive SHell).Documentation for
killall
can be found here: http://manpages.ubuntu.com/manpages/hardy/man1/killall.1.htmlTo try to kill all processes owned by a user
username
, run:With this application you can view program listings
install htop
for see process and kill process You can install it and simply delete
I wrote a little script I wrote to kill (in my case) Skype:
But I found that as much as that worked then, it didn't work the next day because the pid was a different length and there for the amount of spaces was different
Then I came across this site and tried
which conveniently outputs processes in the format
So I adjusted my code in the script to this:
What this does is pipes all of the processes
justin
is running (that can be changed to any user name) togrep
which looks forskype
(this can be changed to your process) and then pipes that line tocut
which then reads only the PID and finally uses that PID in thekill
command to kill it....All processes in Linux respond to signals. Signals are an os-level way of telling programs to terminate or modify their behavior.
How To Send Processes Signals by PID
The most common way of passing signals to a program is with the kill command.
As you might expect, the default functionality of this utility is to attempt to kill a process:
This sends the TERM signal to the process. The TERM signal tells the process to please terminate. This allows the program to perform clean-up operations and exit smoothly.
If the program is misbehaving and does not exit when given the TERM signal, we can escalate the signal by passing the KILL signal:
This is a special signal that is not sent to the program.
Instead, it is given to the operating system kernel, which shuts down the process. This is used to bypass programs that ignore the signals sent to them...