Skip to Content

Terminal Tips: Unfreeze your Mac

Look, it's nothing to be ashamed of, it happens to everyone: your Mac has frozen up and won't respond. I know, I know, for years we Mac folks used to love poking fun at Windows because it freezes up. Apple even made a commercial about it. As someone who has used both, I will say that I have seen this far, far less frequently with Macs... but it happens.

When apps freeze, it's generally pretty easy to deal with. Control-click (or "right" click for you crazy kids with your multi-button mice) the app icon in the dock, and if it says "Application Not Responding" it will offer a "Force Quit" option. Hopefully that will do it.

But what if it doesn't? Read on for your options...
Force quit the front-most application: If you are using OS X 10.5 (Leopard) or later, Apple suggests that you press Option-Shift-Command-Esc and hold down these keys for three seconds.

kill(1) it: if "Force Quit" doesn't work, and you're comfortable using Terminal (the application is in your Utilities folder), you can find the PID (Process ID) and use "kill" to force the app to quit. With a name like "kill" you ought to be reticent to use it, and if you decide to use it, do so with care. If you use kill, don't expect to get a chance to save your data. That said, if the app has been frozen for some time, it's unlikely that you're getting your unsaved data back.

To find a PID for an application, use this line in the Terminal application (Note that I'm using Safari in this example, but you can do the same for any app, just replace "SAFARI.APP" with whatever app you are trying to find):

ps ux | fgrep -i SAFARI.APP | fgrep -v fgrep

you will see a line that looks something like this (note that "tjluoma" is my login name, yours is almost certainly different):

tjluoma 830 0.0 5.7 5219788 239908 ?? S 10:20AM 0:45.82 /Applications/Safari.app/Contents/MacOS/Safari -psn_0_307275

There are only two things you really care about here: the first is the path "/Applications/Safari.app/Contents/MacOS/Safari" which tells you that you have the right process; the second is the number immediately following the login name, which is, in this case "830" which is the "process ID" or "PID" for Safari. Every process on your computer has a PID, and it will be different every time for all but a few very low-level system processes. (I will use "830" in the examples below, but you should be sure to use whichever PID matches the app you want to quit. Failure to do so could lead to Bad Things.)

Next you have to decide which of kill's tricks you want to try. There are many of them, but I generally only use 3:

kill -QUIT [pid] tells the app "Hey, I want you out of here." Unfortunately this probably won't work if the app is "Not Responding" but it doesn't hurt to try. To use the Safari example, I would enter this in Terminal:

kill -QUIT 830
Note: You can also use "kill -3 830" instead, but I find "-QUIT" easier to remember.

After that I try "kill -TERM" as sort of a "No, really, I mean it, get your stuff and get out, now."

kill -TERM 830

Note: you can also use "kill -15 830" instead, but I find "-TERM" easier to remember.

If neither of those work you are left with only two options: reboot the system (which is almost always an option) or "kill -9". Let me make this clear: "kill -9" is the last resort. "kill -9" is putting a gun to the forehead of the app and pulling the trigger. You know how I've mentioned that you can use names or numbers ("kill -15" or "kill -TERM")? The name for "kill -9" is "kill -KILL" just so you know we're not messing around. Think of "kill -9" as your last defense against the zombie apocalypse.

kill -9 830

or (kill -KILL 830) should send your process to process heaven immediately.

"But what if my entire computer is not responding?"

The above will work fine if you are trying to target just one application, but what if you get into a situation where the entire computer won't respond. My old PowerBook would often get into a situation where I could move the mouse, but nothing else. Your choices are fairly limited at this point.

If you don't have another computer available, your best bet is to hold down the power button until the computer shuts off.
If you do have another computer available -- and let me be clear that in this case, "computer" includes and iPad, iPhone, or iPod touch -- you might have another option available. However, to use this option, you have to have a little foresight and setup your Mac to let you login remotely.

Option 1: Screen Sharing or VNC: I mention this first because it's the easier option, but frankly I wouldn't expect it to help in these situations. If the computer is frozen, accessing it via Screen Sharing or VNC is just going to let you see the same problem on a different screen. But, again, it doesn't hurt to try.

Option 2: Remote Login (aka "ssh"): I know this option is likely to work because it has often worked for me. As with Screen Sharing, you have to turn it on via System Preferences » Sharing. Check the box next to "Remote Login" which is what Apple calls "ssh" probably because "Remote Login" is fairly obvious to anyone who can read, whereas "ssh" is only obvious to a few. In Terminal.app, go to Shell » New Remote Connection and click on "Secure Shell (ssh)" and select the computer you want to connect to. Once you are connected, you have two more options:

1) Logout from the commandline:

sudo killall -HUP WindowServer

You will be asked to enter your administrator password. This will have the same effect as logging you out. After that you can either reboot or log back in. Note that this will not save any unsaved work.

2) Reboot from the commandline:

sudo shutdown -r now

You will be asked to enter your administrator password. This will not save any unsaved work. The computer will shutdown whatever processes it can, and then reboot the system.

No one ever wants to find themselves in this situation, but if you do, it's good to know what options you have.

Look, it's nothing to be ashamed of, it happens to everyone: your Mac has frozen up and won't respond. I know, I know, for years we Mac...
 

Add a Comment

*0 / 3000 Character Maximum Comment Moderation Enabled. Your comment will appear after it is cleared by an editor.

29 Comments

Filter by:
Richard Cravens

You can minimize your system freeze frequency under both Leopard and Snow Leopard by judicious use of maintenance tools such as Onyx.

Many times system instability and freezes are caused by corrupt system caches or corrupted log files. Onyx can clean/refresh these for you.

Since I have started using this tool (in 2005) system freezes are extremely rare.

Even OS X needs preventative maintenance.

http://www.apple.com/downloads/macosx/system_disk_utilities/onyx.html

July 17 2010 at 2:05 PM Report abuse rate up rate down Reply
weatheredwatcher

There is a far, far easier way to do this via the command line (and with a lot less typing) ps aux | grep [s]afari

Allow me to explain. I use aux rather that ux 'cause that will give you ALL the running processes, not just your user processes. fgrep is the equivalent of grep -f. There is no reason to use the -f flag here. Finally, notice the [] brackets. We are using a regex expression here to search for safari We are saying that it must have the first letter 's'. Since grep [s]afari is not the same as grep safari, this will not include our ps aux | grep... command in the listing. That simple bracket replaces the second pipe/grep filter.

July 15 2010 at 1:28 PM Report abuse rate up rate down Reply
samtnx

for those who want something much easier to remember, top and kill are all you need.

July 13 2010 at 2:56 PM Report abuse rate up rate down Reply
Brian

I use htop as a top replacement. Additionally, I use an alternate syntax for tracking down offending processes: ps -ef | grep -i processname. I've also aliased ps to include the -ef switch and grep to include -i, which allows me to simply type ps | grep processname.

July 13 2010 at 11:27 AM Report abuse rate up rate down Reply
Bruno

How do you launch a terminal when your computer is frozen?

July 13 2010 at 8:37 AM Report abuse rate up rate down Reply
Lew Rodgers

I've had two occasions and simply turn it off - or unplug, if it won't shut down. Find something else to do for 30 minutes - plug it in and turn it on and you are back in business. The first time this happened, none of the simple recommended procedures worked so I took it in to the Apple store and left it. 3 hours later I was called and told it was working fine. The Tech explained there is a reset switch built in which requires a down time of 30 minutes to reset and usually corrects every time. No Charge!!

July 13 2010 at 5:49 AM Report abuse rate up rate down Reply
exnewt

I've had good luck using Activity Monitor to kill "SpinDump" which sometimes appears in conjunction with recalcitrant applications; 85% of the time it works, the app unfreezes and I go on my merry way.

July 13 2010 at 5:09 AM Report abuse rate up rate down Reply
Xenos

Just right-click the icon of the App on the dock. Pressing and holding the Option key will change "Quit" into "Force Quit" in the popup menu.

July 13 2010 at 3:26 AM Report abuse rate up rate down Reply
Tom

I'm experiencing more and more of these freezes as well. Don't know what the deal is with windows 7, but for me Snow Leopard is by far the most unstable Mac OS version I have used. Oddly enough, the apps that crash the most are Finder, Safari and iTunes. Are they considered crap too?

I'm a happy mac user since the Tiger days, but I'm getting more and more annoyed by the ever present beach-ball.

July 13 2010 at 2:55 AM Report abuse rate up rate down Reply
4 replies to Tom's comment
K.C.

I'd expect this article on site written by 15 year olds that like to find the geekiest way to solve a problem.

Command+Option+Escape is what us mere mortals would de because it's simple and effective. No need to get under the hood.

July 13 2010 at 1:32 AM Report abuse rate up rate down Reply
Buy an ad here

Tweets

© 2012 AOL Inc. All Rights Reserved.