Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Reboot a hung system with Spotlight and Terminal System
I hate switching off the power on a hung system. As a last resort before doing that, when logging out or even Force Quit won't work, I've had some success with this method. Invoke Spotlight with Command-Space. Even if you don't see the search box appear, keep following these steps. Type Terminal and hit Return. With a bit of luck, you'll see a Terminal window open.

Log into Terminal as an administrator, for example: ssh admin@mycomputername.local (replace admin with the short name of an administrator account, and mycomputername.local with your computer's Bonjour name (see the Sharing preference pane).

Enter the admin password when prompted. If you get a message that the system can't verify the identity of the computer and asking you if you want to proceed, type yes. Once logged in, you can try any Terminal command and see if it works. Usually, I just type sudo reboot and enter the admin password when prompted.

It's worth a try when it seems that nothing but a cold, hard, power-off restart will work.
    •    
  • Currently 2.90 / 5
  You rated: 3 / 5 (10 votes cast)
 
[54,667 views]  

Reboot a hung system with Spotlight and Terminal | 26 comments | Create New Account
Click here to return to the 'Reboot a hung system with Spotlight and Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Reboot a hung system with Spotlight and Terminal
Authored by: Hodag on Dec 30, '08 07:47:57AM

Dear God it worked! Thank You Thank You Thank You! I just saved 9 hours of writing a tech manual by being able to kill the hung process without killing everything!

---
--
Adam C.



[ Reply to This | # ]
Reboot a hung system with Spotlight and Terminal
Authored by: thyvillageidiot on Dec 30, '08 08:25:50AM

How can I kill a single process? For example, Safari?



[ Reply to This | # ]
Reboot a hung system with Spotlight and Terminal
Authored by: frgough on Dec 30, '08 08:50:37AM

With the terminal open, type top and press enter. Look for the program you want to quit and note its PID. Then type q to quit TOP, and enter sudo kill -9 xxx where xxx is the PID of the program you want to kill. Enter your password when prompted. The program should die, and hopefully free your hung machine.



[ Reply to This | # ]
Reboot a hung system with Spotlight and Terminal
Authored by: VxJasonxV on Dec 30, '08 09:16:49AM
I think:

killall Safari

Will work much easier for you ;). If that doesn't seem to do anything, I think (don't quote me 100% on this), that killall -9 Safari will work a bit more brute force.

If that doesn't work, prepending sudo to the command will... hopefully.

[ Reply to This | # ]
Reboot a hung system with Spotlight and Terminal
Authored by: seanasy on Dec 30, '08 04:11:43PM

In addition to the above Terminal commands, you can:

- type Cmd-Opt-Esc, select Safari and click the Force Quit button,
- launch Activity Monitor, select Safari and click the Quit Process button.



[ Reply to This | # ]
Reboot a hung system with Spotlight and Terminal
Authored by: siMac on Dec 30, '08 08:01:55AM

Why bother with SSH? All you need is a terminal window and you can just enter 'sudo reboot' then the admin password.

SSH would be useful if you are unable to get a terminal window to open on the hung machine as you will be able to issue the reboot command from another machine on the same network.



[ Reply to This | # ]
Reboot a hung system with Spotlight and Terminal
Authored by: Alrescha on Dec 30, '08 08:09:23AM

I think implied was the possibility that you might not be logged in as an administrator (I do not use a privileged userid most of the time). In this case, you still don't need to use ssh, but could just type "su admin_user_name" and type the appropriate password.

A.



[ Reply to This | # ]
Reboot a hung system with Spotlight and Terminal
Authored by: Stormchild on Dec 30, '08 08:21:28AM

Yeah, was going to ask the same thing. There's no reason to SSH to your own machine. And if you're only going to execute a single command as root, there's no need to even 'su'. Just 'sudo' the command.



[ Reply to This | # ]
Reboot a hung system with Spotlight and Terminal
Authored by: junklight on Dec 30, '08 08:25:15AM

ah ssh'ing from another machine - a trick that has saved me on more than one occasion.

Often if you have ssh'd in you can kill rogue processes.

ps -A and a sudo kill -9 XXX where XXX is the process number can often work wonders.



[ Reply to This | # ]
Reboot a hung system with Spotlight and Terminal
Authored by: kainewynd2 on Dec 30, '08 08:58:34AM
It is easier to just type: 'login username' rather than ssh. SSH requires remote login to be checked, login always works on a local machine (which is what this hint is for).

In short, replace this:
Log into Terminal as an administrator, for example: ssh admin@mycomputername.local (replace admin with the short name of an administrator account, and mycomputername.local with your computer's Bonjour name (see the Sharing preference pane).

With this:
Log into Terminal as an administrator; for example: login admin (replace admin with the short name of an administrator account).

Simple as pie... ;)

[ Reply to This | # ]
Reboot a hung system with Spotlight and Terminal
Authored by: kiltbear on Dec 30, '08 09:07:18AM

Very cool, my suggestion was to "su admin" rather than "login admin"

Slightly different than "sudo". "sudo" is kind of like an enhanced "su".

"sudo newuser", if you are an admin account will allow you to use your own password to become that new user. "su newuser" will prompt you for the newuser's password.

Another subtle difference is that "su newuser" won't try to do any login stuff, like sourcing your .profile, etc, which login will. So, in some case "su admin" will get you to your privileged execute status with less fuss and muss if things are hanging.



[ Reply to This | # ]
Reboot a hung system with Spotlight and Terminal
Authored by: mat79 on Dec 30, '08 10:45:56AM

IIRC only the Admin-Users are in the sudoers file, so a login would be safer



[ Reply to This | # ]
If all else fails, grab your iPhone/iPod touch
Authored by: Stormchild on Dec 30, '08 08:32:35AM

I actually use my iPod touch to save my machine when the entire UI manager locks up (in which case there's no way you can open a Terminal window). I log in via SSH with TouchTerm and try to kill the frozen process. When one application after another starts beachballing (usually this is caused by a kernel lock that blocks disk access), this is often the only way to deal with the problem other than forcing it to power down.

You'll have to enable "Remote Login" (*before* you have a problem, obviously!) in the Sharing panel of System Preferences for this to work.

If you happen to have another Mac or any other computer with an SSH client, you can do it that way too.



[ Reply to This | # ]
Reboot a hung system with Spotlight and Terminal
Authored by: allentown on Dec 30, '08 09:00:23AM

If you can get a terminal running, do not even bother with the reboot. Just type `top -u` and you should be able to see the hung process. -u sorts the list by CPU usage. Once you know the name of the process, for example, if it was Finder, just type `sudo killall Finder.app`. You can then issue a clean restart, or in the case of Finder, it will relaunch.

This can be a nice way to deal with apps that still need some data saved.



[ Reply to This | # ]
Reboot a hung system with Spotlight and Terminal
Authored by: aardvarko on Dec 30, '08 12:00:38PM

su is NOT sudo. You do not need to be in sudoers to use "su". Sudo is a much more recent development; su stands for "switch user".



[ Reply to This | # ]
Reboot a hung system with Spotlight and Terminal
Authored by: CareyB on Dec 30, '08 01:15:38PM
I think what you're looking for is: "sudo -i"

[ Reply to This | # ]
sudo -i
Authored by: CareyB on Dec 30, '08 01:20:50PM

Sorry... This gives an interactive 'sudo' session, but if you're not an administrative user, it still ain't root.

---
I'm willing to put up with you, if you're willing to put up with me.



[ Reply to This | # ]
sudo -s
Authored by: gatorparrots on Jan 06, '09 03:35:00PM
Try sudo -s for a root shell.

[ Reply to This | # ]
Reboot a hung system with Spotlight and Terminal
Authored by: ljharb on Dec 30, '08 07:40:13PM

When you need a reboot, and for some reason you're afraid of cutting the power - just hit command-control-eject (or eject if youre not on a laptop). That's been the reboot key command since they started putting power buttons on keyboards.

PS - nobody's ever broken a computer by turning it off and on too much. Just cut the power.



[ Reply to This | # ]
Reboot a hung system with Spotlight and Terminal
Authored by: dandj on Dec 30, '08 08:51:44PM

Might be obvious to some but the "killall [ApplicationName]" command is case sensitive.

eg "killall preview" doesn't work but "killall Preview" does.



[ Reply to This | # ]
What do you mean by "a hung system"?
Authored by: clh on Dec 30, '08 09:37:20PM
I'm not clear about what condition you're talking about. A hung process should not normally prevent you from rebooting, or bringing up the Force Quit dialog. A hung system, though... what does that look like? Can you not switch between running apps using Command+Tab, or by clicking on windows? Can you not launch from the Dock? I'm not sure I've ever seen OS X in a state of system-wide unresponsiveness where you would still be able to launch & use Terminal on the same machine. I've only seen kernel panics (and not many of them, thankfully).

[ Reply to This | # ]
What do you mean by "a hung system"?
Authored by: gsperling on Dec 31, '08 12:29:42AM

Why, one with really long assets, don't you know? =)



[ Reply to This | # ]
Hung GUI
Authored by: gshenaut on Dec 31, '08 12:04:15PM

A number of times I've seen a frozen GUI, but in that case, Terminal won't run either. The best solution is the remote login via ssh (the above suggestion to use touchterm on the iphone is great).

Greg Shenaut



[ Reply to This | # ]
Reboot a hung system with Spotlight and Terminal
Authored by: CyberSkull on Dec 30, '08 10:42:33PM

Great hint. But anything other than a server I have would have SSH turned off. But this is great thing to try to kill the window server or any errant process. Thanks for the tip!



[ Reply to This | # ]
No need to find out your Bonjourt hostname...
Authored by: fbitterlich on Jan 02, '09 03:10:03AM

... just use "ssh admin@localhost" instead.

There might be valid reasons to do this, but as others have already noted, a simple "su" might do the trick just as well. And that doesn't require SSH to be enabled in the Sharing pref pane beforehand.



[ Reply to This | # ]
Reboot a hung system with Spotlight and Terminal
Authored by: Westside guy on Jan 02, '09 11:04:24AM

By default if you're not running as an admin, sudo won't work because you won't be in /etc/sudoers. However you can add yourself using visudo, and from that point on you'll have sudo access from your non-admin account - even if you toggle your account's admin status, the system seems to keep track of the changes to /etc/sudoers that were made manually.

But yeah, "sudo /sbin/reboot" is very handy when your computer won't otherwise respond...



[ Reply to This | # ]