Incoming from windows - easy taskkill

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
shingetsu

Incoming from windows - easy taskkill

Post by shingetsu »

Ok, now this is for all you people coming in from windows (it can be useful to veterans too, though as a light utility, nothing more).
You probably remember this:

Code: Select all

taskkill /IM something.exe
Now when you tried doing, say, this:

Code: Select all

kill brasero
it asked you for a pid. After googling you did this:

Code: Select all

pidof brasero
and had to write it manually.
Well these days are over! There's actually a pretty simple way to get this working. I wrote a small (technically under 1kb) script that does it for you. The basic script is as follows:

Code: Select all

#!/bin/bash
#nkill by Shingetsu (http://forums.linuxmint.com/memberlist.php?mode=viewprofile&u=89380)
PROCS="$@"
for p in $PROCS
do
kill `pidof $p`
done
What this does: it accepts something like

Code: Select all

nkill brasero gedit firefox
(I call it nkill (n for Name)).
Basically the name of every process you send as an argument is checked, then killed. This sends the SIGTERM command. SIGTERM won't ALWAYS work, however It is safer though. For a more "effective script, consider this:

Code: Select all

#!/bin/bash
#fnkill by Shingetsu (http://forums.linuxmint.com/memberlist.php?mode=viewprofile&u=89380)
PROCS="$@"
for p in $PROCS
do
kill -9 `pidof $p`
done
The -9 here sends the SIGKILL signal. While always effective, and can result an consequences in certain cases.
I was going to make a last version of the script... one where 1st parameter decides whether to use -9 or not, but got lasy and just made the -9 version fnkill.

Anyway, put this script into /usr/bin under the name nkill and/or fnkill and you can go around using it (should work in alt+f2 also).

Use this with great responsibility. Thank you all :P.

P.S.* Yes this is selfish propaganda. Yes this is still useful. The real reason I posted is in the case I kill my comp so I can get the script back.

P.S.S. * This should be compatible with sudo -> with it, the program would be run as root and as such all commands in it would have the "sudo su" effect. So that will work too.
veggen

Re: Incoming from windows - easy taskkill

Post by veggen »

What's wrong with killall? It kills by name and is already in your system.
eanfrid

Re: Incoming from windows - easy taskkill

Post by eanfrid »

We even have xkill to kill an open window with a single mouse click :)
shingetsu

Re: Incoming from windows - easy taskkill

Post by shingetsu »

veggen wrote:What's wrong with killall? It kills by name and is already in your system.
killall is an excellent tool, but what I disliked of it was that:
1. It's not safe outside of linux (while this script can be used on unix safely)
2. killall doesn't kill impure executable, kill does. This is why this script uses kill, actually.
3. killall isn't often mentioned on searches. Whereas if a user types in "kill process linux" or "taskkill in linux" or similar, this is sure to pop up.
Thank you however, for mentioning it, now people that read it will also be aware of the alternative.
eanfrid wrote:We even have xkill to kill an open window with a single mouse click :)
Since when is xkill capable of killing all instances of multiple running executable? One of my main points was that one avoids typing multiple commands and just runs one single command (runnable from alt+f2).

After running a few benchmarks I noticed that nkill performs SLIGHTLY slower than killall -e, but about the same speed as killall (in some cases slightly faster, mainly in cases of multiple instances of multiple programs running).

If I made any outstanding mistake in my 3 clauses, please correct me. I got this idea around 3 am (and finished it around 3:15, if we include the research for better alternatives) so it's quite possible I did, in fact, make a mistake.
altair4
Level 20
Level 20
Posts: 11446
Joined: Tue Feb 03, 2009 10:27 am

Re: Incoming from windows - easy taskkill

Post by altair4 »

I'm confused by the premise.

Most windows users have never heard of taskkill. Most Windows users don't even know they have a terminal emulator and if they do they think they are running DOS. Most Windows users kill processes using Task Manager. The Linux ( Gnome ) equivalent is System Monitor: gnome-system-monitor.

Then it becomes System Monitor > Right click brasero > Kill Process
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
shingetsu

Re: Incoming from windows - easy taskkill

Post by shingetsu »

altair4 wrote:I'm confused by the premise.

Most windows users have never heard of taskkill. Most Windows users don't even know they have a terminal emulator and if they do they think they are running DOS. Most Windows users kill processes using Task Manager. The Linux ( Gnome ) equivalent is System Monitor: gnome-system-monitor.

Then it becomes System Monitor > Right click brasero > Kill Process
Weird, I always used the cmd (when I was forced to use a windows install) and most windows users I know prefer a fast cmd command or a batch script rather than using the task manager. It's possible that my limited experience in the area lead to a false assumption based on an overly limited selection, however I believed the chance of that to be quite low.
fraze

Re: Incoming from windows - easy taskkill

Post by fraze »

This is definitely useful. Having left Win* some time ago, still the old habits creep up and I find myself using the odd backslash or Win* cmd. Filed this away just in case.

Thanks shingetsu.
Post Reply

Return to “Tutorials”