TOP 50 Mac OS Terminal Commands

Disclosure: Some of the links on this site are affiliate links. This means that, at zero cost to you, I will earn an affiliate commission if you click through the link and finalize a purchase.

TOP 50 Mac OS Terminal Commands (works on M1 Mac!)

Mac OS has arguably the best graphical user interface of all available operating systems. However let us not forget the power of the Mac OS terminal!

If you are looking to harness the power of the Mac OS terminal, be sure to get familiar with this list of the top 50 terminal commands that you should know!

Don’t’ forget to use command + D to bookmark this page for future reference!

1. Disable Sleep Mode : caffeinate

$ caffeinate [-disu] [-t timeout] [-w Process ID] [command arguments...]

There are certain circumstances where it is very useful to stop a Mac from sleeping. Sure there are apps you can download and install to do this. However the quickest and easiest way is to use the caffeinate command! Read more…

2. A Better Copy Alternative : ditto

$ ditto [ <options> ] src [ ... src ] dst

Most command line users are familiar with the cp command for copying files and directories, however Mac OS X has the ‘ditto’ function as an alternative. Read more…

3. Display A Calendar : cal

$ cal [general options] [-hjy] [[month] year]

Did you know it is possible to display a very authentic calendar in the terminal? If you need to know the date, simply type cal to display the calendar. Read more…

4. “Get Yo Ass To Bed” : leave

$ leave [[+]hhmm]

Your terminal will give you a persistent reminder that it is time to leave, whether that be the end of your work day or perhaps if you keep staying up until morning doing some kinda Matrix coding. Read more…

5. Your Mac Will Say ANYTHING : say

$ say [-v voice] [-o out] [-f in | message]

Your Mac has a fantastic text to speech synthesis engine built in that can be manipulated by the terminal command say. What you choose to get your Mac to say is your prerogative… 😆 Read more…

6. Capture Screen To An Image : screencapture

$ screencapture [-icMPmwsWxSCUtoa] [files]

You may already be aware that your Mac has a screen capture program that you can find by using spotlight. You may not be aware that it is also accessible from the terminal. Read more…

7. Transfer Data From The Internet : curl

$ curl [options...] <url>

Another very useful command that I use in many of my tutorials that can be used for grabbing data from remote computers. Read more…

8. What’s In Your History File? : history

$ history [n]

Your terminal is keeping a track of all of those command that you have been typing. If you type the command without any arguments, you will be shown the last 16 commands entered. Read more…

9. Is Anyone Alive Out There? : ping

$ ping [-AaDdfnoQqRrv] [-c count] [-G sweepmaxsize]

The ping command basically sends out some data packets to a given network address and times the response time. In its most basic form, this command is great for testing either local network problems or whether a remote server is down. Read more…

10. Grab The Previous Command : !!

$ !!

Typing a double exclamation mark into the terminal will grab the last command entered. This is another seemingly lesser-known shortcut that can be very useful! Read more…

11. Change Directory : cd

cd [-L|-P] [dir]

This is probably the first command everyone should learn. It quite simply switches the current directory to whatever is specified in the following argument. Read more…

12. List Directory Contents : ls

ls [-Option(s)] [file ...]

The next command that everyone should learn simply lists the contents of the current directory.

There are a surprising amount of options that can be used with this command, but most of the time you will simply use the command without arguments. Read more…

13. Move Something : mv

mv <source file/folder> <target path>

Another staple terminal command use for moving files or folders. Following the mv command you simply specify the target file or folder path as the first argument and the destination path as the second argument.

The following example will move the file quickbrownfox.txt located in the home directory to the Desktop.

mv ~/quickbrownfox.txt ~/Desktop

14. Make A Directory : mkdir

mkdir [-pv] [-m mode] [folder...]

Once someone has become comfortable with navigating directories and listing their contents, the next skill to master is creating a directory. Read more…

15. Display The Content Of Files : cat

cat [-benstuv] [-] [file ...]

The cat command takes the contents of a file and ‘prints’ it into the terminal window. Here we don’t actually mean print [to paper] with ink, we mean to display on the screen. Read more…

16. Copy And Paste : pbcopy

pbcopy [-pboard {general | ruler | find | font}]

The pbcopy command allows us to copy something to the clipboard. We can use additional commands in conjunction with pbcopy in order to pass data to it that we wish to copy. Read more…

17.View System Utilisation : top

top

Executing the top command launches an in-terminal app that monitors the current processes and resource usage. Read more…

18. End Processes : kill

kill <pid>

The kill command is pretty self explanatory. It will terminate a program specified by its PID as the primary argument.

You can get the PID for a program that you want to kill by using either the top command or the ps command. Read more…

19. Open a File : open

open <file>

This is another very self explanatory command, but it is one that I didn’t know existed until very recently!

The open command quite simply opens a file. You can use it to open any file, even ones that are not compatible with the terminal. These will simply open in the GUI as if you clicked them.

This command could be useful if you want to quickly view files whilst navigating in the terminal. However it would become really valuable when used in script writing.

20. Edit a File : nano

nano <path/file>

Nano is an awesome terminal text editor, which is very useful for making edits to files. If you are editing configuration file variables then you will find this very useful!

For more information about editing files with Nano, check out my article on editing files with the command line.

21. Download Packages : brew

brew <command> <arguments>

If you are using the terminal for anything more than a few simple configuration options, you will likely benefit from the use of a package manager. Read more / how to install…

22. Enter The Matrix : cmatrix

cmatrix

Yes it is entirely possible to turn your terminal into the matrix and totally impress your friends! Simply enter the command cmatrix and your terminal will display a very authentic recreation! Read more / how to install…

23. Download Youtube : youtube-dl

youtube-dl [OPTIONS] URL [URL...]

Tired of using web-based YouTube downloading services that are peppered with ads? This command is awesome! It is easily the quickest and cleanest way to download YouTube videos. Read more / how to install…

24. Play Tetris : tetris

tetris

Tetris in the Mac terminal is surprisingly good, and addictive! Why not give it a try? Read more / how to install…

25. ASCII Aquarium : asciiquarium

asciiquarium

Ok so this is might not go down in history as the most useful terminal command, however it is surprisingly relaxing and quite impressive! Trust me when I say that you will watch it for longer than you think! Read more / how to install…

26. Awesome Terminal Text : toilet

toilet [ -hkostvSW ] [ -d fontdirectory ]

I had to include this one just because the name is so funny 😆 but contrary to the name, this command can produce beautiful text in the terminal. Read more / how to install…

27. Snakes On A Game : nsnake

nsnake

Going back to the topic of terminal games, nsnake is a must have! All of that old Nokia nostalgia gives me a warm fuzzy feeling. Read more / how to install…

28. Eat Them Up Yum Yum : myman

myman

Another classic game that has been given the terminal treatment. I have to admit these terminal games are far more addictive than you might think! Read more / how to install…

29. Snakes On A Domain : python

python3

Python is a highly useful tool to have installed on your system. There can be a little confusion surrounding the version, so it is best to think of Python2 and Python3 as separate entities.

A great little example that we can use is the simple web server tool, which runs in terminal and allows us to navigate folders via a browser:

python3 -m http.server

Read more / how to install…

30. Watch Star Wars Episode IV

I literally cannot believe someone has done this… there is an ASCII version of the entire Episode IV of Star Wars: A New Hope!

Set aside some time, go to the terminal and type the following:

nc towel.blinkenlights.nl 23

Users of vintage technology with OS versions older than Sierra should use the following instead:

telnet towel.blinkenlights.nl

31. Disable Gatekeeper

Mac OS includes a technology called Gatekeeper, which is designed to ensure that only trusted software runs on your Mac.

This is a great feature for protecting the average user from malware attacks and stopping my Mom’s online banking getting hacked. However for more advanced users it can be a nuisance.

It is possible to disable Gatekeeper and prevent the nuisance security checking, allowing all software to be installed directly. Simply enter the following command:

sudo spctl --master-disable

Read more…

32. Add Space In The Dock

This is a very cool little hidden hack for those who are meticulous when it comes to organising things. It is possible to put spaces in the dock so that you can group programs into neat little groups!

defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'

Read more…

33. Hide Folders in Finder

To hide a folder, enter the following command:

chflags hidden <folder path/name>

Then to unhide the folder, enter the following command:

chflags nohidden <folder path/name>

Read more…

34. Schedule a Shutdown

You can shutdown your Mac after a specified amount of time by using the -h flag and specifying the number of minutes:

sudo shutdown -h +120

If you wish to cancel a shutdown event, simply use the following command:

sudo killall shutdown

Read more…

35. Use Touch ID for Sudo Password

If you have a Mac with a Touch ID facility and you use your fingerprint for login, you can also use this authentication method for your terminal sudo password.

In order to do this you need to add the following line to the top of the file /etc/pam.d/sudo

auth sufficient pam_tid.so

Read more…

36. Booyakasha On Completion

You can add the following command on to the end of any other command and your Mac will say “booyakasha!” when it has completed that command!

; say boo yaka sha!

For example let’s say you want to update Homebrew, you can write the following command and your Mac will say “booyakasha!” on completion.

brew update ; say boo yaka sha!

You can of course get your Mac to say whatever you like, but I recommend you get it to say something funny! 😆

37. Remove The Shadow From A Screenshot

When you take a screenshot of a Window, rather than the whole screen, you will notice that there is a shadow. It is possible to turn off the shadow with the following two commands:

defaults write com.apple.screencapture disable-shadow -bool TRUE

killall SystemUIServer

If you want to enable the shadow again, you can reverse the boolean:

defaults write com.apple.screencapture disable-shadow -bool FALSE

killall SystemUIServer

38. Change Screenshot File Format

When you take a screenshot, by default it is saved in the PNG file format. However it is possible to change the format using terminal!

Simply enter the following command to save screenshots in JPG format!

defaults write com.apple.screencapture type JPG

If you want to revert this back to PNG, simply enter the following:

defaults write com.apple.screencapture type JPG

39. Change The Dock Animation Speed

The following command changes how long of a delay there is between the cursor hitting the bottom of the screen and the dock appearing. Replace the zero with the desired number of seconds:

defaults write com.apple.dock autohide-delay -float 0

killall Dock

Read more…

40. Create A File Of Any Size

Sometimes it can be useful to have a large file for testing purposes, or a file of a very specific size. With this command it is possible to create an empty file with a specified size.

mkfile <size> <file name>

Read more…

41. Get Website Updates

There is a very cool RSS reader for terminal called Newsboat, giving you a very lightweight way to read this site and many other sites. This would be especially useful when the internet connection is poor. You can install Newboat using brew:

brew install newsboat

Read more…

42. Get The Weather Report

There is an awesome ASCII weather app that resides online, which is accessible by the curl command. This website prints a weather report in the terminal using ASCII characters and uses your IP address for location, very cool!

curl wttr.in

43. Clear The Terminal : clear

clear

A very simple but useful command that I have yet to mention in any previous lists of terminal commands is clear, which simply clears the terminal screen.

44. Useful Serial Terminal : screen

screen <port> <baud>

It is possible to use the built-in screen command to connect to external hardware. This is particularly useful for connecting to RS232 / USB serial devices. Read more…

45. Modify File Permissions : chmod

chmod <permissions> <file/folder>

When using systems that are derived from Unix, such as Linux or Mac OS, it is often necessary to work with file and folder permissions. Read more…

46. Clear Browsing Cache : mDNSResponder

Emptying your Mac’s DNS cache and allowing it to look up domains on the external DNS service is a simple fix if your Mac is not displaying web pages correctly:

sudo killall -HUP mDNSResponder

sudo killall mDNSResponderHelper

sudo dscacheutil -flushcache

47. Won’t You Please, Please Help Me? : whatis

whatis <command>

If you are looking for further information on another command, you may be aware that you can type <command> --help and in may cases you will be given some information about the command. Read more…

48. Compare Two Files : opendiff

opendiff <file 1> <file 2>

The opendiff command is a superior approach to compare two files of the same kind, and it’s integrated into every Mac. Read more…

49. Join GitHub : git

git <command> <arguments>

GitHub is a fantastic resource and it is likely you will have already come across it if you have used terminal for any length of time. Read more…

50. Create Your Own Command!

If you are still hungry for new terminal commands, perhaps its time to take a break, you know, see some friends? No? Ok, in which case, why not get started in creating your own terminal commands! Read more…

Thanks so much for visiting my site! If this article helped you achieve your goal and you want to say thanks, you can now support my work by buying me a coffee. I promise I won't spend it on beer instead... 😏

1 thought on “TOP 50 Mac OS Terminal Commands (works on M1 Mac!)”

Leave a Comment

Your email address will not be published. Required fields are marked *


Scroll to Top