Inscrivez-vous maintenant pour un meilleur devis personnalisé!

Nouvelles chaudes

How to close apps in MacOS from the command line

Jan, 18, 2024 Hi-network.com
| -- this is the pipe that sends the output of the first command to the next command
The MacBook Pro on top of a table.
June Wan/

It's a rare occasion that I find a MacOS app goes awry, but it does happen. When an app stopsresponding on the MacOS desktop, there's a user-friendly GUI tool that can help you. Go to the Apple menu, click Force Quit, find the app in question, andForce Quit.

However, that trick doesn't always work. On several occasions, I've discovered the Force Quit app refuses to do the job. When that happens, most people would probably turn to the restart option.

Also: How to optimize storage on your MacOS device

But don't do that -- there's a better way. Because MacOS is very much grounded in Linux, you have the power of the command line at your fingertips. That power gives you the ultimate control over those apps, such that you can send them packing with impunity.

There are two commands that I'm going to show you how to use. Once you have the hang of these two commands, you'll never run into an app that you cannot close -- no matter how stubborn it is.

Let's get to it.

Locating the app name

What you'll need: The only thing you'll need for this task is a laptop or desktop running MacOS. It doesn't matter which, nor does it matter which version of the OS you are using. I would, however, recommend you update MacOS to the latest version supported by your hardware and keep it up to date at all times. 

Also: How to update every Apple device

With that public service announcement out of the way, let's get to the app-closing trick.

1. Open the terminal app

The first thing to do is click the Launchpad icon in your dock, locate the icon for the Terminal app, and click it.

2. Locate the name of the app to close

This is the tricky part. We have to find the name of the app we want to close. I often have issues with Apple Mail, so let's use that app as our example. 

Also: How to quickly fix Apple Mail when it's not working

Keep in mind that Linux commands are case-sensitive, so we're not looking formail, we're looking forMail.What we're going to do is use two Linux commands,ps and grep,to list all instances of running apps that include the wordMail. The command for this task is:

ps aux |grepMail|grep Mail

For those who want to know, here's the breakdown of the command:

  • ps -- reports a snapshot of a current process
  • aux -- are ps options forallprocesses associated with auser ID,and use the defaultformatfor output
  • | -- this is the pipe that sends the output of the first command to the next command
  • grep -- print lines that match a pattern
  • Mail -- the pattern used forgrep to match

The output of the command should include something like this:

jackwallen 20722 0.0 2.3 415470192 378896 ?? S Thur09PM 21:07.22 /System/Applications/Mail.app/Contents/MacOS/Mail

From that listing, we now know the app is, in fact, running under the nameMail.We can use that name to kill the application. The reason why we want to verify this name is to not only ensure we have the correct name, but to make sure we don't accidentally kill an app we need running that might have a similar name.

2. How to kill the application

We're now going to kill the Apple Mail application with thekillallcommand, which is done with:

killallMail

You should now find that Apple Mail has been forced closed, even when the Force Quit app failed to work.

A word of caution

Only use this process when you are certain the Force Quit app will not work and when you know the name of the app you want to kill. Don't go randomly using thekillallcommand on anything that's running because you could cause problems with your OS or lose data. Usekillall wisely and it will serve as a helping hand before you have to turn to rebooting.

tag-icon Tags chauds: technologie Services et logiciels Systèmes d’exploitation Plus de how-tos

Copyright © 2014-2024 Hi-Network.com | HAILIAN TECHNOLOGY CO., LIMITED | All Rights Reserved.
Our company's operations and information are independent of the manufacturers' positions, nor a part of any listed trademarks company.