• We had to restore from a backup today after a failed software update. Backup was from 0000 EDT and restored it at 0800 EDT so we lost about 8hrs. Today is 07/20/2024. More info here.

How to kill a proccess?

thanks to all on this thread.

Office Libre froze on me for the first time.

I was working on a complex data base and as part of a reformatting technique, I copy and pasted a worksheet to another worksheet for backup and the whole thing froze.

Eventually I was able to close and start all over again from where I last saved.

If it happens again I will remember this thread and try some of the commands.

Interesting. I usually run skill $name.

I never heard of skill before. I was going to congratulate you on the find, but grief! Look how unflattering the man page is:

These tools are probably obsolete and unportable. The command syntax is
poorly defined. Consider using the killall, pkill, and pgrep commands
If it is a graphical process, like Libreoffice, you can use xkill. After you type xkill in a terminal, you then just click on the program that you want to close. Works great for me and is much easier than trying to find the process ID.
You can also use fuser command to kill all processes. For example you want to kill apache2, find full running command with top as below

#top -c

Output will as

1312 root      18   0 73516 2724 1252 S  0.0  0.3   0:00.02 /usr/sbin/apache2 -k start
 1313 www-data  18   0 73516 2048  564 S  0.0  0.2   0:00.00 /usr/sbin/apache2 -k start

and run fuser with -k option and command as below

#fuser -k /usr/sbin/apache2

and all processes will kill and output will as below of this command.

/usr/sbin/apache2: 1312e 1313e

Means these process ids has been killed.
ps and then kill is enough and most convenent if you don't care about data missing.
It should be stressed that SIGKILL aka -9 aka -KILL should be used as a last resort!

Kill can send a number of signals to a process to terminate. Sending a signal to the process first is usually a better option (as long as the program was well written and knows how to handle termination signals) as it lets the process clean itself up and potentially save progress before exiting. SIGKILL on the other hand doesn't send a signal to the process itself but to the kernel telling the kernel to immediately halt/kill/murder/destroy the given process. Sometimes this is the only option, but its generally not the cleanest.

I generally run ps to get the PID (comptuers work with PIDs you should be doing the same)
run kill $PID (sends SIGTERM signal by default if no flag is specified)

If it is still not killed i'll then run kill -9 or kill -KILL to SIGKILL the process.
I know this is the command line section, but if you are on a desktop, you can always press CTRL-ESC
To kill the current shell process, type this in a shell.
kill -9 $$
$$ is a environment variable for the current shell's Process ID.

Staff online

Members online