Terminal is a CLI (Command Line Interface), the language we type which interacts with the Mac. This tool is often overlooked as it is different from the GUI (Graphical User Interface), offering a rich interface. However, I’ve a useful list of macOS Terminal Commands that you can learn easily and do things instantly. Let’s start with the basics!
How to open Terminal on Mac
Spotlight is undoubtedly the easiest way to open Terminal on Mac. Follow the steps below to open Terminal. Now, let’s see how to get most of Terminal!
12 macOS Terminal commands to supercharge your Mac experience
1. Force your Mac to stay awake
It is annoying when your Mac goes to sleep when you are off for a short break. Of course, you can change Sleep Settings in System Preferences. However, it is easier to use Terminal to keep your Mac awake with the following command. caffeinate That’s not all! You can also add a timer to the command. Doing so will disable “caffeinate” mode after a preset time. You need to put the -t flag and specify the time in seconds, as shown below. caffeinate -t 150000 In this case, your Mac will exit the mode after 15,000 seconds or 250 minutes. You can increase or decrease the timer by changing the number of seconds in the command.
2. Flush DNS cache
I have seldom faced issues with Mac’s DNS cache. Yet I would suggest you flush DNS cache on Mac every once in a while. Not doing so will lead to problems like loading websites and 404 errors. (add screenshot- macos-shell-flush-dns) Enter the following command to flush DNS on Mac. udo dscacheutil -flushcache; sudo killall -HUP mDNSResponder Note: This command works only on macOS El Capitan and above. After flushing DNS, check if you can access the website with the issue.
3. Increase spacing between Dock apps
Too many apps in Dock triggering your OCD? Well, you can increase the spacing between each apps using terminal commands. Once done, your Dock will look neat and tidy. defaults write com.apple.dock persistent-apps -array-add ‘{tile-data={}; tile-type=“spacer-tile”;}’ And hit Return. Once done, type: killall Dock and press Return again.
4. Change default screenshot name
Mac saves screenshot with date and time as default. The naming convention tends to look unprofessional. Worry not; once again macOS terminal comes to the rescue. You can change the default name for a screenshot using the below command. defaults write com.apple.screencapture name “New Screen Shot Name” Now type: killall SystemUIServer
5. Change default screenshot format
Now that you have fixed the screenshot naming, how about changing the format? macOS saves a screenshot in the PNG format. Some online portals like immigration require images to be in .jpg format. Spending time to convert saved images to other formats is not ideal. Instead, you can use the terminal code to change the default image format. Furthermore, you can choose between Jpeg, TIFF, GIF, or even RAW (ideal for post-processing photos.) defaults write com.apple.screencapture type jpg
5. Download files without a browser
Want to download a file directly? With Terminal, you can download a file directly from the Internet. This method is useful only if you have a direct download link. Type the following command. cd ~/Downloads/ Note: If you want to download the contents to any other directory, replace “downloads” with the directory name. curl -O [URL of file you want to download]
6. Compress and password-protect folders
I recommend password-protecting sensitive data before sharing it with anyone. You can share the password separately with recipients. Using Terminal, you can compress and password-protect the folder. You need to navigate to Desktop and select the folder using the below command. cd ~/Desktop/ Select the folder zip -er
7. Display hidden files and folders
macOS hides critical files. The fail-safe mechanism assures that you don’t delete a system file by mistake. Doing so could crash your Mac. However, the feature becomes a limitation whenever you want to view hidden files on an external drive. The solution for this is the below Terminal command that lets you view hidden files. defaults write com.apple.finder AppleShowAllFiles -bool TRUE Now you will get to see all the hidden files. Enter killall Finder A word of caution: Don’t delete important system files. Before deleting anything, run a Google search. Use “False” instead of “True” in the above command to hide files again.
8. Access iCloud Drive using Terminal
To access the data from your iCloud Drive, use the following command. cd ~/Library/Mobile\ Documents/com~apple~CloudDocs/ However, we already have a detailed guide on how you can access, copy, or move data to your iCloud Drive, which you can check out anytime.
9. Shut Down or restart Mac using Terminal.
To shut down your mac with CLI (Command Line Interface) aka Terminal, use. sudo shutdown -h now Just as shut down, you can restart your Mac by sudo shutdown -r now
10. Supercharge Time Machine backup
Whenever you’re updating the Mac to the new version, backups are essential. The easiest way to take a backup is to use Time Machine. But do you know? You can speed up time machine backup using the terminal by this command. sudo sysctl debug.lowpri_throttle_enabled=1
11. Copy contents from one folder to another
Copying contents from one place to another is fairly easy with Terminal. Type in the following command: ditto -V ~/original/folder/ ~/new/folder/ Replace original with the current directory and new with the name of the directory to which you want to copy the contents.
12. Make your Mac say anything you want
This is the coolest command that macOS provides. You can make your Mac say anything you want by using the say command followed by the words. SAY “HELLO, IGEEKSBLOG”
Terminal commands ready reckoner
Impressed with all that you can do with the above Terminal Commands? We have curated and compiled the most useful macOS Terminal commands in the table below. Furthermore, the commands are segregated based on their utility. That’s it! These were some of the most common and useful Terminal commands. I hope this helped speed up your work and become a pro Mac user. Additionally, if you are looking for some quick shortcuts to increase your productivity, check out our ebook on 200+ Mac keyboard shortcuts. Related Reads:
How to view Calendar on Mac using Terminal Command Line Finder not responding on Mac: How to fix it How to hide the 2021 MacBook Pro notch How to update macOS on Macbook