13 terminal commands that every Mac user should know

Article Contents

When you think of Terminal, you probably imagine a hacker sitting in front of his computer in a dimly lit room trying to get into an FBI database. Actually, it is a simple tool that can make using your Mac much easier.

Now, I'm not saying that learning Terminal commands is easy, but using them definitely is. I have compiled a list of some basic commands that will help you start your journey to the Mac OS X domain, be it Mavericks, Yosemite or even an older system like Lion.

I have executed all these commands on my MacBook with Yosemite, but if you are one of the first to adopt El Capitn, your mileage may vary due to the fact that it is an early beta version.

# 1 Restart your Mac automatically after it freezes

Macs can be reliable, but they are known to have frozen occasionally. If you prefer not to have to manually force a shutdown, you can use this Terminal command to make OS X instantly restart in a freeze.

  • sudo systemsetup -setrestartfreeze on

# 2 Check for Software Updates Daily

By default, the Mac App Store checks for updates weekly, but if you prefer to receive them as soon as possible, you can use this command to be checked daily.

  • default write com.apple.SoftwareUpdate ScheduleFrequency -int 1

# 3 Change the type of screenshot file

If you don't like screenshots to be saved as PNG files on your Mac, you can change them to BMP, GIF, JPG, PDF or TIFF. Just be sure to change the "png" part of the command below to the desired file extension.

  • default write com.apple.screencapture type -string «png»

# 4 Change the location of the screenshot

You don't like screenshots on your desktop? You can change the storage location using the following command. Simply change the "/ folderlocation" part to the full location of the desired folder. More details here.

  • default write com.apple.screencapture location / folderlocation

Note: See the end of this guide for instructions on using folder locations with spaces in your name.

# 5 Show all hidden files and folders

Unlike Windows, in Mac OS X there is no option to view hidden files and folders, unless you know the exact location. But using this Terminal command, you can make everyone visible. To hide them again, change "true" to "false."

  • default write com.apple.finder AppleShowAllFiles -bool true

To make the changes appear immediately, be sure to press and hold «Alt» on the keyboard, right-click on the Finder of your Dock and then click on «Repeat».

# 6 Hide or unhide files and folders individually

If you don't want to see all the hidden files and folders on your Mac, you can unhide them one by one. For example, the Library's folder is the largest that most people want to hide, so let's do it. (Note that ~ is a shortcut to the main directory of your username.)

  • chflags nohidden ~ / Library /

Now let's try it with a file. The following hide the Secrets folder in my Documents.

  • chflags hidden ~ / Documents / Secrets

Note: See the end of this guide for instructions on using file and folder locations with spaces in your name.

# 7 Automatically open a Finder window when a unit is mounted

To have Finder automatically load a new window every time a flash drive (or any other type of volume) is mounted, use the following commands:

  • default write com.apple.frameworks.diskimages auto-open-ro-root -bool true
  • default write com.apple.frameworks.diskimages auto-open-rw-root -bool true
  • default write com.apple.finder OpenWindowForNewRemovableDisk -bool true

You only have to change them back to "false" if you want to go back.

# 8 Disable warning when emptying garbage

If you like to live life to the limit and do not worry about accidentally deleting a file that you put in the Trash, you can use the following command to disable that pop-up warning.

  • default write com.apple.finder WarnOnEmptyTrash -bool false

# 9 Delete files securely individually

If you wish to securely delete the files from your Mac, but you do not want the “Secure Empty Empty Trash” to be the default, you can destroy the files one by one safely in the Terminal. The following command uses one-pass overwriting before putting it in the trash. (Replace «/ dragedfile» with dragging the file over the one you want.)

  • srm -s / dragged file

And this uses seven passes:

  • srm -m / dragged file

If it's a folder you want to get rid of, use -rf after the srm part.

  • srm -rf / dragged folder

Click here to see more options to delete files / folders securely.

# 10 Add shipping shortcut to the OS X mail application

The Mail application does not come with a shortcut key to send an email, since the Enter key is only configured to insert a line break. But using the following command, create a new keyboard shortcut ( Command + Introduce ) to send mail.

  • default write com.apple.mail NSUserKeyEquivalents -dict-add «Send» -string «@ U21a9?

# 11 Disable automatic Emoji replacement

For those of you who like to live in the mood of the 90s, you can do it so that the emoji no longer replaces traditional emoticons with this.

  • default write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add «automaticEmojiSubstitutionEnablediMessage» -bool false

# 12 Add additional information to the login window

The login window does not reveal much information about your device, but if you want it to display additional information, such as your IP address and operating system version, use the following command. The information appears when you click on the clock in the mens bar and it is displayed one by one.

  • sudo default write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName

# 13 Make the terminal talk to you

This last Terminal command makes you have your own personal robot voice generator. All you have to do is enter "say" and add text inside the quotes.

Note for folder / file names with spaces in them

For some of the above tips, such as hiding specific folders or changing the location to save the screenshot, the location name may have a space in it. Use only one space in the Terminal will not work. Instead, add one after each word except the last one, keeping the spaces. For example:

  • top secret image.jpg

It will be: