Terminal in OS X often receives little attention from users and is even disregarded. Most new Mac users tend to approach Terminal with apprehension, much like encountering anything related to code or advanced features.
However, you need not fear Terminal or perceive it as a sophisticated feature reserved only for experienced users.
Before delving into the 10 essential Mac Terminal commands, users should grasp precisely what Terminal is and how it functions.
Terminal (also known as Terminal.app) is a simulation program, operating based on typical UNIX commands (OS X is UNIX-based, as opposed to Windows NT-based). Unlike OS X, which features a graphical user interface (GUI), Terminal operates on a text-based interface where all commands must be inputted - perhaps why some users feel intimidated by it.
Mytour won't dive into the intricacies of Terminal's operations, but we recommend acquainting yourself with the following three commands before exploring the rest:
ls - lists the contents of a specific directory.
cd - changes the current directory to another directory (similar to DOS).
sudo - grants authentication to a superuser for additional security permissions.
Pro Tip: Exercise caution when using the sudo command. You'll frequently need to input your OS X system password, and any errors could potentially damage the system irreversibly. If unsure, it's best to leave the command as is.
1. Disable Pop-up Accent Window on Lion/Mountain Lion
For foreign language typists, the pop-up accent window that appears when you hold down a character for an extended period can be incredibly useful. However, for those who frequently type repeated characters, this window can become quite bothersome. Use the simple command below to disable the Accent pop-up window:
defaults write -g ApplePressAndHoldEnabled -bool false
Press Return, then log out and log back in to see the changes. In case you wish to revert to the default settings as before, simply replace false with true.
2. Modify Default Backup Interval on Time Machine
By default, Time Machine backs up every hour when connected, but you can modify Time Machine's backup interval through Terminal. To do this, simply use the Terminal command below:
sudo defaults write /System/Library/Launch Daemons/com.apple.backupd-auto StartInterval -int 1800
The command above sets Time Machine to back up every 30 minutes. If you wish to change the backup time to your preference, just replace 1800 with the time (in seconds) you desire. For example, if you want Time Machine to back up every 15 minutes, which is 900 seconds, simply input 900.
Additionally, note that you're using the sudo command, so make sure you've entered the command correctly before pressing Return (and you'll be prompted to enter your system password).
3. Drag Dashboard Widget onto Desktop Screen
Many users often forget about the existence of Dashboard on Mac. In reality, most users don't need to use Dashboard but rely on hidden widgets within the operating system. To drag a Dashboard widget onto the desktop screen, use the Terminal command below:
defaults write com.apple.dashboard devmode YES
You must log out and log back in, then drag a widget onto your desktop screen, click and hold the widget, then press F12. This will remove the widget from Dashboard and allow you to drop it onto the desktop screen. Now you'll see the widget displayed above the open applications, similar to Gadgets in Windows 7.
To disable this feature, simply replace YES with NO in the command above. And of course, you'll need to log out and log back in once more.
4. Disable Auto-restore Feature on Lion/Mountain Lion
After upgrading to Lion, when you open something like Preview, all recently accessed PDF files will be displayed right in front of you, even if you've properly closed these files. However, there's no universal command to disable these files across the entire operating system, so you'll have to do it for each application individually. If you want to disable the displayed files for Preview, use the Terminal command:
defaults write com.apple.Preview NSQuitAlwaysKeepsWindows -bool false
Additionally, QuickTime is another culprit. Just enter the command:
defaults write com.apple.QuickTimePlayerX NSQuitAlwaysKeepsWindows -bool false
Make sure you've exited and restarted the applications to see the changes. In case you want to revert to the initial settings, simply replace false with true.
5. Display Hidden Files in Finder
By default, Finder in OS X hides some files (mostly irrelevant files), but if you want to view everything on your computer, simply enter the following Terminal command:
defaults write com.apple.finder AppleShowAllFiles TRUE
In case you want to hide these files, you just need to change TRUE to FALSE.
6. Change File Format for Screenshots
Screenshots using built-in shortcuts on OS X are quite useful, but by default, these screenshots are saved in PNG file format. If you want to change the PNG file format to another format, you can use the Terminal command below:
defaults write com.apple.screencapture type file-extension
In the command above, replace file-extension with the 3-letter abbreviation for the file format you desire. For JPEG format, simply enter JPG, and for Acrobat PDF format, use PDF.
7. Kill Dashboard
In the section above, Mytour introduced you to the Mac Terminal commands users should know to drag and drop Dashboard widgets onto the desktop screen. However, if you wish, you can completely remove Dashboard (for instance, if you're using an older Mac and facing memory issues) using this simple Terminal command:
defaults write com.apple.dashboard mcx-disabled -boolean YES
Then use the following Terminal command to restart the Dock:
killall Dock
If you wish to 'bring back' Dashboard, follow similar steps and replace YES with NO in the first command.
8. Safely Free Up Disk Space
When you delete files on Mac, OS X still retains fragments of the files across your entire hard drive space until these files are overwritten by new ones. If you want to securely erase all remaining fragments on the hard drive (for instance, if you plan to sell your Mac), use the command below:
diskutil secureErase freespace 3 /Volumes/name-of-drive
Replace /name-of-drive with the name of the drive you want to erase. This command utilizes a special algorithm to thoroughly scan every empty space 35 times, surpassing the standards of the US Department of Defense, which require only 7 passes.
Note that on larger hard drives, this process may take up to a full day, or even several days.
The diskutil command is a useful command that allows you to manage local drives and partitions directly from Terminal. However, please note that most commands require root privileges.
9. Remote Control Your Mac
You can remotely control your Mac via SSH, also known as Secure Shell, which is much more convenient than screen sharing because it uses fewer system resources and less bandwidth. The first thing you need to do is enable the Remote Login feature on your Mac by accessing System Preferences => Sharing and then clicking on Remote Login.
A small green button will appear along with an IP address that you can use to log in via Terminal. The connection between your local Mac and the remote computer (your Mac) is secure and encrypted, meaning no data can be intercepted while being transferred between the two Macs.
To log in to your Mac from another Mac, use the Terminal command below:
ssh -l username remote-address
In the command above, replace usename with the username you want to use to log in to OS X and remote-address with the IP address provided to you in the Sharing table. Now you can control your Mac and execute Terminal commands remotely.
10. 'Talk' to Your Mac
Last but not least, if you want your Mac to talk to you, simply use the say command as shown below:
say Hello World!
The words will be spoken in the default Mac voice, but if you want to change this, simply go to System Preferences => Dictation and Speech (on Mountain Lion) or Speech (on Lion). Here you can choose from various voices and download new voices from Apple's servers if desired. There's also another handy feature: the ability to convert entire text files into speech. Just enter the command:
say -o audio.aiff -f FILENAME.txt
Replace FILENAME.txt with your file. This will create an AIFF audio voice file named audio.aiff in the default Terminal directory.
Pro Tip: Have you ever wondered, is the Mac operating system pronounced as 'OS ten' or 'OS ex'? Mac will let you know the answer. Try typing 'say OS X' into Terminal. The result might surprise you.
Hopefully, through the article about 10 Terminal commands every Mac user should know, you've gained a clear understanding of Terminal and realized how important its role is. You can do much more using Terminal, and if you want to customize OS X beyond just changing wallpapers, then that's truly your starting point.
On Mac as well as Windows, when you no longer want to use any software or application, it's advisable to uninstall it from the system to free up memory and speed up your device's performance. Uninstalling applications on Mac differs somewhat from uninstalling software on Windows. If you're not familiar with how to uninstall applications on Mac, feel free to comment on the Mytour Fanpage for assistance.
If you have any questions or comments, you can leave them in the comments section below the article. Mytour will respond to your inquiries as soon as possible.
