Skip to content

Instantly share code, notes, and snippets.

@akingdom
Last active August 8, 2024 07:20
Show Gist options
  • Save akingdom/d85129b08a96ffba8c89741abf6d1974 to your computer and use it in GitHub Desktop.
Save akingdom/d85129b08a96ffba8c89741abf6d1974 to your computer and use it in GitHub Desktop.
Useful command-line (terminal) commands to use on MacOS

Command-line (MacOS)

On MacOS the command line is typically accessed via Terminal.app, equivalent to cmd.exe on Microsoft Windows. The Terminal app passesthe text commands to the operating system for processing, then displays the returned results or errors.

Killing processes on MacOS

In MacOS here are two ways to kill processes in one hit. I'll use Google Drive as an example.

List process IDs (optional, useful to query beforehand or verify afterwards):

ps aux | grep "Google Drive" | awk '{print $2}'

Kill:

ps aux | grep "Google Drive" | awk '{print $2}' | xargs kill -9

-or-

sudo killall -9 "Google Drive"

The above two perform the same task.

Dock

The Dock is the window manager of MacOS as well as a place to access application features.

Resetting preferences

I had an issue where switching back to an application would show a different frontmost window to when I left it. Resetting Dock preferences fixed this. killall Dock quits and re-launches the Dock app to force a re-load of the new preferences.

rm ~/Library/Preferences/com.apple.dock.plist && killall Dock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment