15 Great Mac OS X Terminal Commands That You Might Not Know

15 Great Mac OS X Terminal Commands That You Might Not Know.


By : Amandeep Singh Chawla

The DOS prompt is the last remnant of the primordial era of computing, existing mostly for nostalgia’s sake. Unless you have been computing since the 90’s (or earlier) you have almost no reason to understand the Command Prompt, because why would anyone? It is a dreary spectacle. I like beginning my posts with a little Windows bashing; it helps illustrate how OS X’s Terminal is still relevant and grows in power with each iteration. We have already discussed how you can disable the dashboard and notification center and how to remove drop shadows from screenshots, but that is just the tip of the proverbial iceberg. If you learn how to wield this power, you can unlock abilities you didn’t know existed.
Mac-OS-X-Terminal-commands
We have to accept that modern computing has no place for typing instructions. It is a tawdry affair, to honor which, we will only mention features you can access through the terminal exclusively (and maybe some third-party apps).

Make Your Mac Speak

say your-statement-here
This command is self explanatory, you can trigger the native text-to-voice function by writing a word/sentence followed by ‘say’.

Play Games

As we almost always mention, OS X is Unix based and as such, has inherited numerous Unix legacies that have survived the migration to Mac. Emacs, a text editor, forms part of the UNIX system, which comes with a few easter eggs, like games. The technique is simple. First, find your Emacs version number.
cd /usr/share/emacs/; ls
This will display your version number. Mine is 22.1. Now, enter the following:
ls /usr/share/emacs/22.1/lisp/play
Replace 22.1 with whatever number you obtained in the former step. You get a directory of all the available games. Make a note, or take a screenshot. If you’re using Mavericks, chances are the attached screenshot is the same as what you’ll have.
Terminal-Gamelist
Now turn on Emacs by writing it in the terminal.
emacs
To access the games, press ‘Esc’ then ‘x’ and enter the name of the game you want to play, just the name, no extensions necessary. You can switch to the next game at any time by repeating this process.
Terminal-SnakeTerminal-Tetris

Watch Star Wars In ASCII

Speaking of nostalgia, you can actually watch Star Wars Episode IV – A New Hope on your mac depicted through ASCII art. If you’re using IPV6, you’ll be treated to a colored version with more scenes. If you have SSH and Telnet access as well as a terminal app on iOS, you can view it there as well. Make sure you don’t resize the window or it will garble the ASCII art’s arrangement. Enter the command below in the terminal and enjoy.
telnet towel.blinkenlights.nl

Terminal-StarWars

Backup To Time Machine At Will

If you are working on Time Capsule or any backup device, you can change how frequently your system is backed up. Simply enter
 sudo defaults write /System/Library/Launch Daemons/com.apple.backupd-auto StartInterval -int 1800
The number at the end of the above command represents seconds, 1800=30 minutes. You can change this to suit whatever frequency of backup to Time Machine you want.

Resize Image Preview Resolution

If you switch through different previews you will notice that the image resizes itself each time to adapt to the new image. This behaviour is off putting for some, especially digital comic enthusiasts, but, can be fixed through a simple terminal command.
 defaults write com.feedface.ffview udn_dont_resize_img_ win 1
Restart the app and image windows will now remain a constant size. To reverse this to default, enter the code again, replacing the ’1′ at the end with ’0′.
defaults write com.feedface.ffview udn_dont_resize_img_ win 0

X-Raying Your Folders

This command only works with Mountain Lion or earlier version of OS X. Quick look does what it says; it gives you a quick look at any file, gives you the total folder size, number of files inside etc. You can get even more detail by taking an x-ray image of a folder, simply type:

defaults write com.apple.finder QLEnableXRayFolders -boolean YES; killall Dock
To disable, enter the following
defaults write com.apple.finder QLEnableXRayFolders -boolean FALSE; killall Dock

Recently Used Apps

If you like having quick access to your recently used applications, you just have to copy and paste the command below and it will become a shortcut in your Dock. To remove the shortcut, just right click on it and ‘Remove from Dock’.
defaults write com.apple.dock persistent-others -array-add '{ "tile-data" = { "list-type" = 1; }; "tile-type" = "recents-tile"; }'; killall Dock

Terminal Frequently Used

Renaming Screenshots

When you take a screenshot on Mac, the default naming convention is ‘Screen Shot – Date -Time’, if you wish to change it so that you can replace the word “Screenshot” just use the following command and replace “Anything you like” with your preferred word/phrase.
defaults write com.apple.screencapture name "Anything you like"; killall SystemUIServer
If you want to revert to the default, use:
defaults write com.apple.screencapture name ""; killall SystemUIServer

Show Hidden Files

Sure, there are applications that let you look at OS X’s hidden files, but you don’t have to look anywhere else to get access to these files, as there is a very simple command that will do the job for you:
defaults write com.apple.finder AppleShowAll Files TRUE; killall Finder
To disable:
defaults write com.apple.finder AppleShowAll Files FALSE; killall Finder

Enable AirDrop On Older Macs

AirDrop is a Mac feature designed to quickly and easily share files. They work from Mac to Mac, of course the same results can be achieved with some cloud based solutions or file sharing apps, but you can enable it for older macs as well, even over ethernet.
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool TRUE; killall Finder
To revert to default, enter:
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool FALSE; killall Finder

File System Usage

If you want to find out where your file system is being used mostly, just write
sudo fs_usage
Give it a minute to finish and then scroll through the list to see what is taking most of your resources. I discovered that Google chrome is the most taxing app of all.

Investigate Files

If you come across an unsupported file but want to know what lies within it, you can use the following command to inspect the file’s contents, it will open every file, though MP3s and videos will look like gibberish. This comes in handy when you are trying to recover corrupt files or just examine a file for contents. Just write ‘cat’ followed by the path leading to the file. If you are not familiar with how to navigate through the file structures in OS X’s terminal, just right click the file and ‘Get info’, there you will see the file’s path. Below is an example:
cat /Users/Adi/Desktop/age.md

Terminal-Preview

Text Selection From Quick Look

Quick look is an option in Mac that will allow you to look at your text documents like an image preview (press spacebar on any document to see), those who use it know that you can’t select text from quicklook and must open the file to copy elements from it. However, with the command below, you can do exactly that.
defaults write com.apple.finder QLEnableTextSelection -bool TRUE; killall Finder
To undo:
defaults write com.apple.finder QLEnableTextSelection -bool FALSE; killall Finder

Create A Blank File Of Any Size

This is more important for testing other apps, mostly relevant to coders/developers. This command lets you create a blank file of any size you choose. You can name it whatever you choose as well. the convention is mkfile [filesize] [filename].[file-extension] mkfile 1m filename.ext

Toggle Chrome’s Two Finger Swipe Navigation

Chrome has this habit that if you swipe in one direction with both fingers, you will be take to the previous or the next page (depending on the gesture), if, like me, you are bothered by this, it can be disabled with a simple command.
defaults write com.google.Chrome.plist AppleEnableSwipeNavigateWithScrolls -bool FALSE
Restart Chrome and it will be done. If you want the feature back, just enter the following
defaults write com.google.Chrome.plist AppleEnableSwipeNavigateWithScrolls -bool TRUE
Know any terminal commands we don’t? Share them with us in the comments below.


You may also like

No comments:

Powered by Blogger.
//go.ad2up.com/afu.php?id=131698