Useful Mac Terminal Commands You Should Know

One of the best ways to get the most out of Terminal on your Mac is to learn what all it can do for you. While it looks like more of a programmer’s thing, it is really easy to use once you have learned some commands for it. There are a number of commands, and they can accomplish different tasks for you.

Here we have compiled some of the most useful terminal commands you should know as a Mac user.

1. Restart Your Mac When It Is Frozen

maccommands-frozen
sudo systemsetup -setrestartfreeze on

The above command helps you reboot your Mac when it is frozen. Just type it once in Terminal and it will reboot your machine whenever it freezes up.

2. Show Hidden Folders and Files

maccommands-hiddenfiles
defaults write com.apple.finder AppleShowAllFiles -bool true

The above command enables Finder to show hidden files and folders on your Mac. It is quite useful when you wish to see the system folders that are hidden by default.

3. Enable 2D Dock

osxterminal-2ddock

If you’ve ever moved your Dock to the left or right of screen (depending on which OS X version you’re running), you may have seen the 2D Dock shown above. If you’d like to enable the 2D Dock in all positions, enter the following into Terminal:

defaults write com.apple.dock no-glass -boolean YES

Now restart your Dock to make the changes take effect by entering:

killall Dock

To put your Dock back to normal, replace the “YES”‘ in the above code to “NO” and restart the Dock once again by entering the above killall command.

4. Disable Delete Prompt

maccommands-trash
defaults write com.apple.finder WarnOnEmptyTrash -bool false

It disables the prompt that you get while emptying the Trash on your Mac. All the files in the Trash will be gone without you first confirming the action.

5. Show The Library Folder In OS X Lion

OS X Lion comes with the Library folder hidden by default but this can make troubleshooting any issues with your Mac, deleting the cache or just plain “tinkering” very difficult. In order to bring back the Library folder permanently, enter this command into Terminal:

chflags nohidden ~<strong>/</strong>Library<strong>/</strong>

6. Make Your Mac Speak Text

maccommands-say
say TEXT

Enter anything in the place of TEXT in the above command and your Mac will speak it out for you. Sometimes it helps to hear things out loud, such as checking to see if it is correct or to fully understand what it means.

7. Activate AirDrop on Older Macs

maccommands-airdrop
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool TRUE

While AirDrop can be used on newer Macs just out of the box, older Macs require you to execute the above command to enable the functionality. It lets you exchange files between several of your Macs instantly.

8. Rebuild the Spotlight Index

maccommands-spotlight
sudo mdutil -E /

Spotlight lets you quickly search for files and folders on your Mac. In order to do that it builds an index of all the files for faster searching. Sometimes the index needs to be rebuilt for various reasons, and the command above lets you do that. It helps you rebuild the Spotlight index on your Mac.

9. Enable Text Selection in Quick Look

maccommands-quicklook
defaults write com.apple.finder QLEnableTextSelection -bool TRUE

As the name implies, Quick Look lets you quickly look at a file on your Mac. You just need to click the file and press Spacebar to activate it. What it does not let you do, though, is select text. The command above removes that limitation and lets you enable text selection in Quick Look on your Mac.

10. Hide Desktop Icons

terminalcommands_desktop

A nice clean Desktop looks great but sometimes it’s not practical to keep all your files organized. If you’d like to hide all the icons on your Desktop through a Terminal command, enter the following:

defaults write com.apple.finder CreateDesktop -bool false
killall Finder

When you wish to bring your Desktop clutter back, copy and paste the following:

defaults write com.apple.finder CreateDesktop -bool true

Then enter the killall command.

11. Prevent Your Mac From Sleeping

maccommands-sleep
caffeinate

Like humans, your Mac does fall asleep when it is not used for a certain amount of time. To prevent your Mac from falling asleep you can use the above command.

12. Remove Dashboard From Your Mac

maccommands-dashboard
defaults write com.apple.dashboard mcx-disabled -boolean YES

When was the last time you used Dashboard on your Mac? If you do not remember you probably do not need it. The command above should help you remove it from your Mac.

If you ever want to get it back on your machine simply replace “YES” with “NO” in the above command, and it will be back.

13. See Commands History

maccommands-history
history

Have you ever wondered what all the commands are that you have typed into the Terminal so far? The command above should list out all of those commands for you.

Conclusion

Knowing these commands should help you make the most out of the Terminal app on your Mac. It will no longer be an app that only a geek uses; it will become an app that everyone uses.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Mahesh Makvana

Mahesh Makvana is a freelance tech writer who's written thousands of posts about various tech topics on various sites. He specializes in writing about Windows, Mac, iOS, and Android tech posts. He's been into the field for last eight years and hasn't spent a single day without tinkering around his devices.