How do I kill processes in Ubuntu?

1,331,671

Solution 1

To kill all the processes that you have the permission to kill, simply run the command

kill -15 -1 or kill -9 -1 depending on the desired behavior (use man kill for details)

To kill a specific process, say, firefox, simply run

pkill firefox or killall 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

ps -ef

If you want to look up all processes by user bob, this might help

pgrep -l -u bob

or

ps -ef | grep bob

Solution 2

Use sudo kill <pid> or sudo killall <process-name>

Solution 3

You can use

ps -ax | grep application name 

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 by kill command if process id=1317,

kill -9 1317

Solution 4

Let's try something more:

sudo apt-get install htop 

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.

Solution 5

I would use xkill. Enter xkill in a terminal and click in the window, or enter xkill and the process ID and it will be terminated.

Found out more about xkill on x.org.

Share:
1,331,671

Related videos on Youtube

djangofan
Author by

djangofan

Updated on September 18, 2022

Comments

  • djangofan
    djangofan over 1 year

    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.

  • Simon Richter
    Simon Richter about 12 years
    I'd start with kill -15 -1, and only move on to kill -9 -1 if there are stubborn processes and I know what I'm doing. Randomly killing processes that may be in the middle of a database transaction is not something one should do as casually as you suggest.
  • Simon Richter
    Simon Richter about 12 years
    Also, Firefox's process is named firefox-bin.
  • ste_kwr
    ste_kwr about 12 years
    No, you can try running killall firefox and killall firefox-bin and see what works. I agree with your first comment.
  • pl1nk
    pl1nk almost 12 years
    I don't think this is relevant to this question, you are using sudo -- the OP has not such privileges, as mentioned in the question.
  • ish
    ish almost 12 years
    The OP doesn't have privileges, please edit your answer or it may be deleted or converted into a comment as "not an answer".
  • Sergiy Kolodyazhnyy
    Sergiy Kolodyazhnyy about 9 years
    Use it second in frequency after pkill nd love it. +1
  • PythoNic
    PythoNic over 8 years
    xkill doesnt work in this case...
  • Alvar
    Alvar over 8 years
    @PythoNic in what case is that?
  • PythoNic
    PythoNic over 8 years
    He wants to kill a non-window process which is also not related to the X server as it seems for me... (Anyway a good tool.)
  • Java.beginner
    Java.beginner over 8 years
    Thanks @ste_kwr, worked with your instructions, after struggling for two days...
  • muru
    muru over 8 years
    You could have dropped the -l, and ran pgrep -u justin skype, and to kill: pkill -u justin skype (or pkill -KILL -u justin skype to send SIGKILL).
  • Shailyn Ortiz
    Shailyn Ortiz over 6 years
    If he doesn't have privileges he just have to do kill <pid> or killall <process-name> I just used it in my non root account, I wouldn't be able to do it if it wasn't for this Answer.
  • SDsolar
    SDsolar almost 6 years
    The advantage to not needing PIDs is in cron jobs. Using names works out cleanly.
  • SDsolar
    SDsolar almost 6 years
    This is definitely the Unix Way. Well done both of you. I will use this one.
  • Josh
    Josh over 4 years
    top is a nice command I like to use to see what processes are running and a little more information on how much resources they are using etc.
  • Egor Pavlikhin
    Egor Pavlikhin over 4 years
    What is -15 and what is -1?
  • Danijel
    Danijel about 3 years
    This blocked my mouse cursor and I had to do sudo killall xkill!