Find the process id via System Monitor,
htop, grepping through
ps, whatever (I prefer
pgrep -l, see below). Let's say it is 4536 this time. Then kill it dead:
kill -9 4536
The shotgun approach
pkill -9 apt-get
That will kill dead any processes that somehow match the pattern "apt-get". You don't have to look up a process number. This corresponds to these processes:
pgrep -l apt-get
-l option changes the output from only process numbers to numbers + name. This is good because you can check yourself before blasting away. Maybe when you run
pkill -9 nuke you accidentally kill the process
Wtf is -9?
Normally kill programs like
pkill put you in the position of Darth Vader fighting Obi Wan. Vader wants to kill Ben, Ben acknowledges Vader's desire, Ben gracefully accepts death now that his task is done. This is the same as using the
But sometimes processes don't want to die. Or they'll gladly die, just as soon as they've finished doing this one little thing. But you need them to die now, not when it's convenient for them. So you use the
Why does it keep hanging?
Maybe some other process is interfering. It would probably be something called update, or synaptic, or apt, or anything else along these lines. Kill all of these, one by one, retrying your apt-get command after each kill. Worst case scenario, you kill an important process and have to reboot. Not so bad if you're sitting on the couch with your Ubuntu laptop, sucks if you're remoting to a server across the country.
Maybe you changed your update sources and apt-get didn't get the memo yet. Run
sudo apt-get update. But first make sure there aren't any interfering processes.
I don't have permission to kill anything :|
Tough beans if you don't own the system. But if you do, use
sudo in front of each command, like so:
sudo pkill -9 process-i-hate. I intentionally didn't include the sudos for you because you oughtn't kill without thought for your binary victims.