4 Cool Things You Can Do With The Mac Terminal
The Terminal is the Mac OS X analogue of the Windows command prompt, or CMD. It’s a tool, as you probably already know, that allows you to control your computer using text commands, as opposed to a graphical user-interface.
Although using the Terminal can seem a little daunting at first, it will pay off to get familiar with it. Learning a few simple Terminal commands lets you perform certain tasks in the blink of an eye, that would otherwise be inaccessible, or downright tedious.
The five Terminal tips below are a few that nearly everyone can make use of. They’re a good addition to your Terminal toolbox, and serve as interesting examples to see what getting proficient with the Terminal can do for you.
To get started, open the Terminal application using Spotlight, or locate it in Applications -> Utilities -> Terminal.
1. Copy Files With Original Permissions
There are a number of different commands available in the Terminal to move or copy files and folders. The command shown here will copy a given file or folder, while retaining the original file permissions.
sudo ditto -vV -rsrc src [SOURCE-FILE-PATH] dst [DESTINATION-FILE-PATH]
This command takes two inputs: the file path of the original file or folder, and the file path of the destination file or folder. You can type these in manually, or drag a file or folder onto the Terminal to insert its file path at the location of your Terminal cursor. More information about the ditto command can be found here.
2. Delete Stubborn Files
Sometimes files refuse to be deleted from the Trash, often because they’re still used by another application in the background. If you can’t find the culprit application to close it down, and we’re talking about a relatively innocent file (i.e. not a system file, but a document), you can use the Terminal to forcibly delete it.
rm -v [SOURCE-FILE-PATH]
This command takes only one input: the path of the file you’re trying to delete. Again, you can type this file path manually, or drag and drop the file onto the Terminal to insert it at the location of your cursor. More information about the rm command can be found here.
3. Change The Default Screenshot File Format
By default, Mac OS X saves your screenshots to your desktop as PNG files. However, other file formats are also supported, like JPG, GIF, or even PDF. Using Terminal, you can easily change the default screenshot format to one of these other filetypes.
defaults write com.apple.screencapture type [FILE-EXTENSION]
This command takes only one input: the new screenshot file format. If you enter an unsupported (or nonsensical) file format, you’ll get no indication that anything went wrong, but attempting to take a screenshot will serve you with an error message. If this should happen, you can just change the file format again using the above command.
4. Always Show The Current Path In Finder
Finder always shows the name of the folder that’s currently in focus at the top of its window. Using another Terminal trick, you can have Finder show the folder path instead of the folder name.
defaults write com.apple.finder _FXShowPosixPathInTitle -bool [YES-OR-NO]
This command takes a single boolean (i.e. yes or no) input. If you want to turn this feature on, use ‘YES’. If you want to turn this feature off, use ‘NO’ instead.
Finder needs to be relaunched to view the changes. You can do this by restarting your computer, or by executing the above command. Before doing so, make sure there are no move or copy actions currently in progress.
Do you have any more interesting Terminal tips or tricks up your sleeve? Let us know in the comments below!