Disable System Integrity Protection (SIP)

MacOS Sierra has a stricter Gatekeeper with not allowing Apps from unidentified developers and as a result will annoy us with saying that application is damaged and cannot be opened.

How to Disable System Integrity Protection (SIP) for MacOS Sierra?

With the following 2 options:

Option 1

For a certain application run in Terminal:

sudo xattr -rd com.apple.quarantine /Applications/LockedApp.app

Option 2

To disable checks globally (example: allow apps from anywhere) run in Terminal:

sudo spctl --master-disable


Disable the Startup Sound

os-x-10-10-finderTo permanently mute the startup sound, open the terminal and type:

  • sudo nvram SystemAudioVolume=%80
  • sudo nvram SystemAudioVolume=%01
  • sudo nvram SystemAudioVolume=%00
  • sudo nvram SystemAudioVolume=” “

Its depending on some models.

To restore the startup chime, type:

  • sudo nvram -d SystemAudioVolume

To temporarily disable the startup sound, just press the “Mute” button on your keyboard (that’s the F10 key on a MacBook) before shutting down or restarting your Mac.

Dock animations

Custom delay time

You may have noticed that there is a short delay before the Dock appears when your mouse hits the edge of the screen. There is a hidden setting that allows you to adjust the delay time using the Terminal.

Start by opening up the Terminal app (in Applications/Utilities). To remove the delay entirely, paste in the following line and press Return.

defaults write com.apple.Dock autohide-delay -float 0

The changes won’t take effect until you restart the Dock, which you can do by typing killall Dock and pressing Return.

The number at the end of the command is the delay time in seconds, which you can customise to your liking. My preferred delay is 0.1, which is a bit quicker than the default. To return to the default, just use the following command:

defaults delete com.apple.Dock autohide-delay

Screenshot: Terminal secret Dock delay setting

Custom animation speed

There is a related hidden setting that allows you to customise the speed of the animation when the Dock slides onto the screen. As before, paste the following line into the Terminal and press Return.

defaults write com.apple.dock autohide-time-modifier -float 0.5

Remember to restart the Dock with killall Dock for the changes to take effect. Just like the delay, the number at the end is the length of the animation in seconds. 0 will make the Dock instantly appear with no animation. My preferred time is about 0.5, which makes things just a little snappier than the default.

To return to the default, just use the following command:

defaults delete com.apple.Dock autohide-time-modifier


Customizing the Mac OS X Dock

Here are some handy Terminal tricks for making the Dock your own.


OS X Terminal App

All of these customization options rely on Terminal commands. Terminal is an application included in OS X that allows the user to, among other things, access and modify low-level settings in the operating system.

Terminal can be found in Applications > Utilities. You can either type the commands below directly into Terminal or copy and paste them. All commands are case sensitive. After entering each command press “Return” to submit it.

Because we’ll be modifying files that are in active use on the system, the changes won’t take place immediately.

Therefore, after entering each command, type the following and press Return to quickly restart the Dock:

killall Dock

The Dock will disappear briefly and then reload with the changes now visible.

Enable 2D Dock Mode

For the first few years of its life, the OS X dock was a 2D row of icons that displayed applications, utilities, and folders. Starting with the release of OS X 10.5 Leopard in 2007, however, Apple changed the dock to feature a “3D” look, with the icons now resting on a 3D platform. Functionality generally remained the same, but many users prefer the 2D look over the 3D look.

2D Dock in OS X Pre-Leopard

To change the Dock back to “2D Mode,” enter the following Terminal command and press Return:

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

After pressing Return, remember to type “killall Dock” (see above) to force the change to take effect.

The 3D Default Dock in OS X 10.8 Mountain Lion

Although the 2D Dock looks a bit different than its predecessors in earlier versions of OS X, the change still gives user the general look they were missing. If you don’t like the new look and want to change back to the default 3D Dock, simply retype the Terminal commands above and replace “YES” at the end with “NO” (again, remember to type “killall Dock” afterwards to force the change to take effect).

The 2D Dock in 10.8 Mountain Lion

Show Only Active Applications

By default, OS X’s Dock displays all active applications as well as inactive applications and folders that the user wants to keep handy. Some users, however, may wish to limit the Dock to displaying only open and active applications. To do this, head back to Terminal and enter the following command:

defaults write com.apple.dock static-only -bool TRUE

Once the change takes effect, you’ll notice that your Dock is likely much smaller now, with only open applications displayed. In the following screenshots, the first image shows the Dock before entering the Terminal command. Finder, Mail, TweetBot, Safari, Pages, Activity Monitor, and Terminal are open, but all the other applications are still displayed.

Standard Dock Showing All Active and Inactive Items

After entering the Terminal command the Dock is much smaller, and only those open applications are displayed. This option is great for users who wish to use the Dock primarily as a tool for managing open applications while using another means, such as Spotlight, to actually launch applications.

OS X Dock Displaying Only Active Applications

To reverse the change, retype the Terminal command and replace “TRUE” with “FALSE”.

Change the Maximum Magnification Level

One of the “eye candy” features of OS X’s Dock is the Magnification option. This allows users to keep their Dock size very small while still being able to easily see and select applications when needed. Apple includes a slider to choose how big the “magnified” icons become with a default maximum of 128 pixels, but users can override that arbitrary maximum and set their own limit.

Default OS X Dock Magnification 128 Pixels

Return to Terminal and enter the following command:

defaults write com.apple.dock largesize -float 256

This will set the maximum to 256 pixels, as seen in the screenshot below.

Dock Magnification Set to 256 Pixels

You can also go nuts and set it even larger, to 512 pixels:

Dock Magnification Set to 512 Pixels

To reset the magnification level to the default size, enter this command:

defaults write com.apple.dock largesize -float 128

Granted, the usefulness of this command is limited but it is presented in the spirit of total customization.

Change the Dock’s Position

By default, the Dock sits centered in the middle of the screen. While you can’t move it to any arbitrary location, the following terminal commands allow you to pin the Dock to either then left or right side of the screen.

To position the Dock on the left side of the screen:

defaults write com.apple.dock pinning -string start

OS X Dock Pinned to Left Side of Screen

To position it on the right side of the screen:

defaults write com.apple.dock pinning -string end

OS X Dock Pinned to Right Side of Screen

To return the Dock to the default middle location:

defaults write com.apple.dock pinning -string middle

OS X Dock Pinned to Center of Screen

Note that this also works if you have your dock pinned vertically to the right or left of the screen using System Preferences > Dock > Position on Screen. In this configuration, “start” aligns the dock at the top of the screen while “end” places it at the bottom.

Dim Hidden App Icons

A useful feature of OS X’s window management is the ability to hide apps (Command-H). This leaves the app’s icon open in the Dock, but completely hides all of the app’s windows. By default, however, there is no indication via the Dock as to which apps are actually hidden compared to those with closed windows or windows that are buried underneath other applications.

Hidden Apps on the Dock

To change this, enter the following Terminal command, which will dim the icons of hidden applications:

defaults write com.apple.dock showhidden -bool true

In the second screenshot, below, Safari and Terminal are hidden after implementing this feature, and their icons are dimmed compared to the default setting. This allows users to easily see which apps are hidden without compromising the usefulness of the Dock. It’s frankly puzzling why Apple doesn’t enable this feature by default.

Dim Hidden Dock Icons

Use the Hidden “Suck” Animation to Minimize Windows

Users have two default options for the effect used when a window is minimized to the Dock: Scale and Genie. “Scale” does what its name implies and simply shrinks the application window down into the dock when minimized. “Genie” is a bit more interesting and distorts the window as it minimizes by pulling both bottom corners simultaneously.

Default Genie Animation OS X Dock

A hidden animation, “Suck,” can also be implemented with the following Terminal command:

defaults write com.apple.dock mineffect suck

This animation also distorts the window but appears to pull primarily from the bottom-right corner of the window. This results in a more interesting distortion of the window as it shrinks to the Dock, as if the window were indeed being “sucked” down from the bottom-right corner.

Hidden Suck Animation Dock OS X

To change the animation style again, you can reenter the command with “genie” or “scale” instead of “suck.” You can also change it by going to System Preferences > Dock > Minimize Window Using… and choose one of the default options.

Always Show Full Trash Icon

OS X’s Trash, like the Recycle Bin in Windows, has a dynamic icon that changes depending on its status. When there are no items in the Trash, the icon displays an empty trash can. When the user deletes an item, the icon immediately changes to show a trash can filled with paper.

In most situations, this is a useful visual indicator that something is in the Trash. For those who like a static icon, however, enter the following Terminal command to force the Trash to always display a full icon, even if there are no files inside:

defaults write com.apple.dock trash-full -bool YES

Always Show OS X Dock Trash Icon Full

After the change has take effect, you’ll notice that the Trash icon always looks full, regardless of whether any files are actually in the trash. To reverse the change, simply reenter the command and replace “YES” with “NO”.

Add a Recent Items Stack

Enter the following Terminal command to create a special stack on the right side of the Dock that contains recently-accessed items:

defaults write com.apple.dock persistent-others -array-add '{ "tile-data" = { "list-type" = 1; }; "tile-type" = "recents-tile"; }'

After it has been created, right-click (Control-click) on the stack to change its options. Users can choose to display the most recent Applications, Documents, or Servers, or user-defined favorite Servers and Items. You can also customize how the stack is displayed.

Recent Items Stack

To get rid of the stack, simply right-click on it and choose “Remove from Dock.”

Add Spacers to the Dock

The OS X Dock by default contains a single non-modifiable spacer between the applications portion on the left and the file, folder, and Trash portion on the right. Using the Terminal command below, however, users can add additional spacers to the Dock to help further organize and separate Dock items.

Open Terminal and enter the following command:

defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'

Once enabled, you’ll see a blank space appear on the right side of your Dock. Clicking on this space does nothing, but it can be dragged around the Dock like any other item.

Add Space to OS X Dock

Users can add multiple spaces by entering the Terminal command repeatedly. In the screenshot below, four spacers have been added and used to group Dock icons based on task (typing, communication, system tools, etc.).

Multiple Spaces Add to OS X Dock

To remove a spacer, simply drag it off the Dock or right-click on it and choose “Remove from Dock.”


Terminal Tips

AppIconTerminalThe first thing to know about the Terminal is how to launch it, which you do by 
going to\Applications\Utilities\Terminal. Also, you’re no longer in graphical user-interface land: Most of what you’ll do in the Terminal is enter specific text strings, then press Return to execute them. When you see generic references like name-of-file or path-to-file throughout this article, replace that text with your file name or path.

Handy Terminal Pointers

  • Only text commands are accepted—you won’t use your mouse much inside of the Terminal, with a few exceptions like select games and other user interfaces.
  • After typing in a command, you can execute the command by pressing Return.
  • Every keystroke matters, including spaces, special symbols, and control keys.
  • Interrupt any running command by pressing Control-C.
  • Recall previously entered commands without retyping them by pressing the up arrow.
  • Curious about a new command? Type man command (where ‘command’ is the name of the command you’re having questions about), then press Return to read its instruction manual pages. For instance, man SSH will produce the manual for SSH. Press ‘q’ on the keyboard to exit the manual pages.
  • For a list of all commands available in the Terminal, hold down Escape, then press Y when prompted. Use the space bar to load more commands, and press ‘q’ to exit this view.
  • Page down through multipage results by pressing the space bar.
  • For commands that require the path to a file or folder, save yourself some typing by dragging and dropping the file or folder at the end of the command. The Terminal will automatically copy the dropped item’s path and name.
  • When typing out the path to a file, you can use the tab key to complete your typing. Simply type the first few characters of the name, then press tab. It’ll auto-complete the next letters for you.

Getting Around

When you first launch the Terminal application, your working directory (the directory you’re currently inside of) is your user’s Home Directory (the same directory that you can access in the Finder by clicking your name in the sidebar). You can test this by typing pwd (or ‘print working directory’) into the Terminal, then pressing enter. You’ll see the current directory printed out to the screen.

You can move to other directories by typing cd path/to/other/directory, replacing “path/to/other/directory” with the path name to the other folder that you wish to navigate to. When you press return, you’ll be taken to that directory (if it exists).

If you get lost, you can always return to your Home Directory by simply typing cd ~/ no matter where you’re at in the Terminal.

Anatomy of a Terminal Command

Unlike the sentences you were forced to diagram in sophomore English, Terminal commands only have three parts: the command, which calls a specific command-line utility; the options, which modify the command’s output; and the argument, which is typically the website, file, or other resource that the command will be operating on.

Remembering how the Terminal commands are created will help you in the future when experimenting with new commands and command line programs that take additional options and arguments.

Get Comfortable in Your Shell

The Terminal app is Apple’s implementation of a traditional UNIX command-line environment, called the shell. Since the introduction of OS X, Apple has used a particular shell instance called the Bash shell, and this is what you see by default when opening the Terminal application. You can verify this in Terminal | Preferences | Startup, and checking the option for “Default login shell”.

There are a myriad of different shells that you can use with the Terminal application; however, you will need to install most custom ones that don’t ship with OS X.

It is important to note that if this article inspires you to Google even more command-line tricks, remember that some command-line utilities are shell-specific, meaning that what works in Tcsh on that helpful blogger’s Linux box might not work in Bash on your Mac.

Clearing the Screen

After you begin typing a lot of commands into the Terminal, the scrolling history becomes longer and longer as all of the content for a single session (a session is created each time you open a new Terminal window or tab), it may become necessary to clear the screen to get a fresh view of what you’re trying to accomplish.

There are two ways in the Terminal application to clear the screen.

The first way is using the UNIX command called clear. When you type this into the Terminal, followed by the enter key, all of the content will be removed, and you’ll be presented with a new prompt, ready to type in more commands without the distractions.

Using the clear command, however, will keep all of the original content and you can still access this by scrolling up. To completely irradiate the content from previous commands in this scroll view, simply press Command + K. This Terminal-specific command will reset the Terminal window, giving you a pristine working area.

A different approach to this is to use Option + Command + K to clear only the scrollback. When you type this command, all of the scroll back content will be erased, while the currently visible command will still be viewable.

OS X’s Hidden Preferences

When it comes to customizing the look and feel of your Mac, the options listed in System Preferences only scratch the surface. Hiding throughout the OS are dozens of hidden preferences that can only be changed through the defaults command. Too many exist to list them all here, so we’ve compiled our five favorites. Always remember to quit an application before modifying its defaults. You can reset any of these commands by replacing TRUE with FALSE and executing the same command again.

Disable the Auto-Restore Feature of OS X

With OS X Lion, Apple introduced a feature that auto-restored files when opening up applications (such as opening up Preview and having all of your recently accessed PDFs appear), and this can sometimes happen even if you closed the application correctly. Both Preview and QuickTime are two main culprits here, and you can disable this auto-restore feature in both of these applications.

To do this, open the Terminal and type the following command:

defaults write com.apple.Preview NSQuitAlwaysKeepsWindows -bool false

That will disable the feature in Preview, but if you also want this feature disabled in QuickTime Player, then you can type this command as well:

defaults write com.apple.QuickTimePlayerX NSQuitAlwaysKeepsWindows -bool false

You’ll need to quit and restart the apps to see this change take effect, and if you want to reverse this, then run the same commands above, replacing “false” with “true.”

Show Hidden Files in The Finder

Believe it or not, the files you see listed on your Desktop in the Finder do not represent all of the files contained in your Desktop folder. In almost every folder, the OS hides system files that Apple considers too important for the likes of us to mess with (or too mundane for us to be bothered with). Now and again, though, it’s useful to view these files. To see the full contents of all folders in the Finder, execute the following command:

defaults write com.apple.finder AppleShowAllFiles TRUE

You should note here, however, that any files that begin with a dot are, by UNIX nature, hidden files. These files can be system files that are necessary to handle folder and file management. Be sure to keep this in mind before deleting or editing any files that don’t look familiar to you.

Change the File Format for Screenshots

Have you ever taken a screenshot on the Mac and gotten back a PNG file, but longed for a different file format instead? Fortunately, you can save them in a variety of formats, including PDF, JPG, and GIF just to name a few. Switching to your preferred format by executing the following command in the Terminal:

defaults write com.apple.screencapture type extension

Replace the “extension” word in the command above with the name of the file extension that you actually want as a screenshot. For instance, if we wanted JPG, you could type the following command:

defaults write com.apple.screencapture type JPG

When you press return, then log out of your Mac and back in, screenshots will taken using this new format instead of PNG. Pretty nifty, eh?

Disable the Dashboard

As with most Mac users, we’ve always had a love-hate relationship with the Dashboard. Released on OS X Tiger (10.4), we’ve always had a soft spot for this feature, but these days, it’s mostly just a waste of space on the Dock. Fortunately, you can remove this feature from OS X with ease. Simply open the Terminal and type in the following command:

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

When you press return, you’ll need to enter one more command to make this new change take effect immediately. Type in the following command to restart the Dock and rid your Mac of the Dashboard feature:

killall Dock

If you don’t wish to enter the above command, then you can simply log out of your Mac and back in to see the change take effect.

Mac Security, Terminal Style

The Unix command line is where many (if not most) of OS X’s security practices were born — and it’s still the place to go to lock down files, resolve system conflicts, and erase your tracks. After all, UNIX gives the Mac it’s strong security foundation, and provides the basis for the Terminal command line.

Compress and Password-protect a File or Folder

Password-protected archives can’t be expanded by the Finder, a limitation that adds another layer of hassle, er, security.

The Finder can make ZIP archives from files and folders in one click from the File menu or the right-click contextual menu. When security is an issue, the Terminal’s zip command supersedes that with its ability to encrypt archived files and folders. The encryption standard is relatively weak by military or industrial standards, but it should be more than enough to defeat a nosy boss or family member.

To create an encrypted archive from a folder in the current directory, execute the following command:

zip -re archiveName name/of/folder

In the above command, replacing name/of/folder with the path and name of the folder you’d like to compress and archiveName with the name you’ve chosen for the zipped file. To retrieve the contents of an encrypted archive, execute unzip archiveName.

Fix File Permissions

In a multiuser system such as OS X, file permissions ensure privacy and security. Now and again, though, they can cause problems, especially when different users are swapping things through a shared folder on the same machine. If the permissions controls in the File Info dialog fail to resolve a problem, chmod and chown are certain to.

Generally, chmod is used to assign role-based permissions for users other than the owner. To ensure that anyone can open and modify a file, execute this command:

sudo chmod 777 path-to-file

Replace path-to-file with the actual file path and name of the file, which you can generate automatically by dragging a file from the Finder window into the Terminal window. When run, this command assigns full permissions to anyone who uses that machine, which is bad for security but good for convenience.

For more limited permissions, execute this command instead of the one above:

sudo chmod 644 path-to-file

Using this second command allows anyone to access and open the file, but only the file’s owner can modify it. To modify permissions on a folder and all of its contents, add the -R option after the command name.

Chown, on the other hand, assigns ownership of a file to particular user. If a file you’ve copied from someone else’s account refuses you access, execute the following command:

sudo chown your-short-user-name path-to-file

Securely Erase Free Space on Your Mac

It may sound strange, but deleted files aren’t actually deleted. Emptying the trash merely tells the operating system to mark the space as available, without actually removing the data that occupies that space on the drive. When new data needs the space, it writes over the old data, but until then, anyone with the right software can still recover the original data, and sometimes this recovery can still happen long after you’ve actually emptied the Trash on your Mac.

Disk Utility offers a one-line Terminal command to scrub free space of existing data. Execute this command:

diskutil secureErase freespace 3 /Volumes/name-of-drive

You can get the name of your drive by using the following two basic commands to look up the available system drives:

cd /Volumes/


This will list the available drives, which you can copy and paste into the above command for the “name-of-drive” path.

diskutil is the command line equivalent of using the Disk Utility application on your Mac (located in /Applications/Utilities).

The utility will write to each drive sector 35 times, using a special algorithm. Thirty-five passes is well above the U.S. Department of Defense’s own standard for erasing data, which requires only seven passes for wiping data from a drive.

Note that with large capacity drives, this process may take a long time (perhaps days) to complete due to the capacity and work that needs to take place to do a 35-pass wipe of the data.

A Note About Sudo

Note that chmodchown, and several other commands in this tutorial are running under sudo, which requires an administrator’s password before executing the proceeding command.

Sudo is a super user account that is built into UNIX-based systems, and because it executes commands as the administrator, overriding the system’s usual warnings and precautions, you should be extremely careful when using this command.

Be extremely cautious with this. If sudo tells the system to erase the entire hard drive, for example, the system will happily do it, no questions asked. You should always double-check what you’ve typed when performing a sudo command. The commands using sudo in these tutorials are relatively safe, but you can get into trouble if you don’t know what you are doing here.

Remotely Control Another Mac

Terminal commands aren’t limited to just the local computer sitting in front of you. One of their most practical applications is controlling other Macs through remote shell connections (or SSH). Continue reading, and we’ll show you how to do this and possibly cause mischief with your co-workers and roommates with this functionality.

Establishing a Secure Shell Connection

SSH, or secure shell, opens a Terminal session on a remote machine, so all commands are then executed in the remote Terminal rather than the local one. The connection is encrypted, meaning none of the traffic passing between the two machines can be read if intercepted.

To get started, first make sure that SSH log-ins are enabled on the remote Mac by opening System Preferences and selecting the Sharing pane. Check the box next to Remote Login, and the SSH service will activate.

To connect to a remote computer via SSH, open the Terminal on the local machine and execute this command:

ssh -l username remote-address

Replace username with your username on the remote Mac and remote-address with the remote Mac’s IP address. (The remote IP address is listed in the remote machine’s Sharing pane when you click on Remote Login.) Press Return, and enter the remote username’s password at the prompt. SSH will connect you to the remote machine. (If you’re asked to add the remote machine to a list of known hosts, press Y for yes.) Once you’re connected, you can execute any Terminal command remotely.

This tutorial assumes you only want to connect to other machines on your local network, but you can also connect to Macs across the Internet using SSH.

Freak Out Your Roommates

There are hundreds of useful remote commands, but let’s get you started with a good gag. If you know that someone else is using the remote computer, SSH into the machine, and execute:

say “Ouch. Don’t press the keys so hard.”

The remote machine’s default voice will read the statement over the speakers. This is even funnier if can do it from a laptop in the next room. (Please use this power responsibly. Impersonating deities or the NSA is bad form.)

Pranks aside, say can quickly create a machine-read audio book from a text file. Execute say -osavedaudio.aiff -f file-to-read.txt. Say will convert the file and save it as savedaudio.aiff in the Terminal’s current directory.

Troubleshoot a Remote Server’s Network Connection

Remote servers are great — until they stop responding. Then one of the first questions to answer is whether the entire machine has gone offline or whether a particular service (such as remote log-in) has stopped responding.

To find out, execute the following command in the Terminal:

ping remote-address

Replace “remote-address” with the domain name, hostname, or IP address of the remote server. For instance, to ping our server from work, we execute:

ping maclife.com

The utility will send a generic knock-knock to the server. If the server is still operating and attached to the network, ping will display each response, along with the time it took to receive it.

Note that in order for this to work properly, the server on the receiving end must be able to respond to ICMP packets. With modern server architecture, and for security purposes, many server administrators have turned these features off on servers, so your mileage may vary.

Copy Files Across a Secure Network Connection

The next time you leave your thumb drive at home, grab the files you need over the network with secure copy, or SCP, which piggybacks on SSH, so you’ll need Remote Login enabled on the remote machine. The syntax for this command can get a bit long — in addition to the remote machine’s address and log-in info, you’ll need the names and locations of the files you want to copy — but it’s well worth the effort if it saves your bacon for that big client presentation. Like SSH, SCP transfers data over an encrypted connection.

To copy a file from a remote machine by executing the following command:

scp username@remote-address:path-to-file target-file

For instance, to copy a file called rental_agreement.doc from our remote machine to a new file called agreement.doc on our local machine, we’d execute:

scp tandorra@ agreement.doc

Obviously, the burden in this situation is knowing the exact location and name of the file before transferring it. Copying a file from your local machine to a remote one is a little easier. In that situation, we’d execute this command instead:

scp file-to-copy user@remote-address:path-to-new-saved-file

In our example, we could also replace our originally copied file–agreement.doc–to the remote machine with this command: scp agreement.doctandorra@

Turn Off a Mac Remotely

If you need to turn off a Mac after leaving the house, SSH into the machine, and execute the following command:

sudo shutdown -h now

You’ll be required to enter your admin password because this command will kick all of the users off of the system and restart the machine at all cost. So, be sure that you don’t have any important work being performed on the Mac you’re about to switch off.

Manage and adjust text

If you like Spotlight and Search on your Mac, then you’ll love grep. This is an old-school pattern-matching utility that comes standard on many UNIX-based machines, including the Mac.

Like Spotlight, grep searches the full contents of files. Unlike Spotlight, however, grep specializes in locating patterns, which makes it ideal for analyzing text documents. Meanwhile, diff, fmt, and textutil offer other ways to quickly compare, format, and manage text files.

Find Patterns in Text Docs

One of our favorite uses of grep is checking finished documents for words and phrases we use too frequently. For instance, we tend to overuse compound sentences joined by “but.” The following command tells us how many lines in article.txt contain the offending word:

grep -ic but article.txt

In this example, the i option tells grep to ignore case (counting both uppercase and lowercase instances), and the c option tells it to return only the number of matches, not all of the lines in which the search term appears. For details, execute man grep.

Compare the Differences Between Two Text Files

Here’s one for writers, office workers, and coders who deal with a lot of document revisions and file revisions. The next time you need to quickly compare the differences between two text files, execute this command:

diff -y firstfile secondfile

Replace “firstfile” with the path and name of the first file (remember that you can drag and drop files into the Terminal to have their paths automatically inputted for you). Next, replace “secondfile” with the path and name of the file that you wish to compare with the first.

The -y option tells diff to split the output into two columns, one for each file, so the differences can be seen more easily.

Combine and Convert Documents of Any Type

Not everyone wants or needs a copy of Microsoft Word. Unfortunately, we all sometimes need to work with Word documents. Textutil can convert between Word, rich-text, and plain-text formats — and it can combine multiple documents, change fonts, and adjust font size while doing it.

To convert and combine all Word documents in the current directory to a single rich-text document called combined.rtf, execute this command:

textutil -cat rtf -output combined.rtf *.doc

Sometimes, of course, you only need to convert a single file. Use this command to do so while changing the font to 12pt Helvetica:

textutil -cat rtf -font Helvetica -fontsize 10 -output converted-file.rtf file-to-convert.doc


OS X Tweaks

One of the reasons we use Macs is how self-sufficient OS X tends to be. Most of the time, system maintenance occurs in the background, and mundane tasks that do require user participation (backups, for instance) are made as painless as possible (thank you, Time Machine.) For those times when we want or need more system-level control, these are the Terminal commands to rely on.

Backup in a Snap

Time Machine is a great way to make sure that all of your files and the entire operating system is always backed up in case anything should happen to your Mac. But, did you know that you can also back up on-demand with Time Machine using the tmutil commands available in the command line?

To back up your Mac, simply execute this command in the Terminal:

tmutil startbackup

After pressing enter, your Mac will go to work and begin creating a new backup. You can also stop the backup at any time by executing this command instead:

tmutil stopbackup

Identify and Eliminate Memory Hogs

When sluggish performance slows your desktop to a crawl, a runaway application might be the culprit. Check CPU and memory usage in all open applications by executing top. The command returns a list of every running process our your Mac, along with its allocated resources. The CPU field is easy enough to interpret–any process using more than half is sure to slow others down. The memory fields are a bit more complicated but, in general, the bigger the numbers, the greater the drain on your system.

If the problem app is visible on the Desktop, quit it as you normally would, using Command + Q or, if that fails to respond, using Force Quit (Command + Option + Escape).

But if the culprit is a lower-lever utility that runs behind the scenes, you’ll need more Terminal magic to end its misadventures. Make note of the problem process’s number in the PID column, and execute this command:

sudo kill PID-number

In the command above, replace PID-number with the application’s actual process number. The targeted process will terminate, freeing up its system resources.

Be extremely careful when killing background processes. Some are necessary for OS X to function properly. Only kill process when you know for a fact that they are bogging down your Mac, and that you started the process and it’s not a system process.

Find Free Space on All of Your Drives

If you have a Mac with multiple drives, with specific drives for iTunes, movies, music, and photos, then it may be hard to see exactly how much free space is available on your Mac at a single glance. Fortunately, the Terminal can help out quite a bit with this investigative process.

To see all of your free space available to you, execute this command inside of the Terminal application:

df -hl

When you do this, you’ll get a listing of the drives available to your Mac, and the percent capacity remaining on those drives. You might find that you have a lot more space than originally thought.

Generate Screenshots

If OS X’s default screenshot settings don’t meet your needs, you can assign image formats and file names for screenshots on the fly with screencapture, which lets you take shots of DVD Player (usually forbidden by the Finder at the insistence of the movie industry’s copyright lawyers). To create an instant, noiseless capture, execute this command:

screencapture -x -t jpg capture.jpg

Replace jpg with the 3-digit abbreviation for your chosen file format (PDF, TIF, GIF, and PNG are also available) and capture.jpg is the name of the saved file.

Using this command, you can also grab hard-to-get screenshots like screenshots of the login screen on OS X.



Top Terminal Commands

You’ll find the Terminal in the Utilities folder within the Applications folder. To carry out any of the following commands you will need to copy/paste or type in the line of text then hit enter. For the most part, applications will need restarting before changes take place. For most applications you can just quit and open them again, but for the Finder and the Dock it is easiest to just type “killall Finder” or “killall Dock” into Terminal after the command.

To reverse any of them, just repeat the command with NO at the end instead of YES, or vice versa.

Make hidden applications’ dock icons translucent.

defaults write com.apple.Dock showhidden -bool YES


Normally the arrows next to artists and albums in your iTunes library search the iTunes store when you click them. 
This command changes them so that clicking will search your iTunes library instead.

defaults write com.apple.iTunes invertStoreLinks -bool YES


This allows you to drag widgets out of Dashboard onto the desktop. 
Requires the dock to be relaunched to take effect, so type “killall Dock” and press enter. Now, if you click and hold onto a widget in the dashboard and press F12 to return to the desktop, the widget won’t disappear with the rest.

defaults write com.apple.dashboard devmode YES


Force all mail to be displayed as plain text.

defaults write com.apple.mail PreferPlainText -bool YES


Set expanded save dialogs as default 
(showing column/list view of folders rather than a drop down menu). Replace TRUE with FALSE to reverse.

defaults write -g NSNavPanelExpandedStateForSaveMode -bool YES


Display the currently chosen screen saver to be shown as the desktop background. 
Press Control-C or Command-. to stop.

/System/Library/Frameworks/ScreenSaver.framework/Resources/ ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background


Display useful system stats in the login window. 

defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo SystemVersion 

Replace “SystemVersion” with one of the following for different stats:



To remove accounts from the login window 
Type this command with the short name of each account you wish to remove.

sudo defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array-add shortname1 shortname2 shortname3


Skip disk image verification. Potentially risky, use with disk images from trusted sources.

defaults write com.apple.frameworks.diskimages skip-verify -bool YES


Put double scroll arrows at both ends of scroll bar. 
Use Appearance pane in system preferences to reset.

defaults write "Apple Global Domain" AppleScrollBarVariant DoubleBoth


Disable the unexpectedly quit dialog that normally appears when an application crashes.
Replace “none” with “prompt” to enable again.

defaults write com.apple.CrashReporter DialogType none


Set the history limit in Safari to a certain number of items and and/or a certain age.

defaults write com.apple.Safari WebKitHistoryItemLimit 2000


defaults write com.apple.Safari WebKitHistoryAgeInDaysLimit 30


Show hidden files in the Finder.

defaults write com.apple.finder AppleShowAllFiles -bool YES


Enable the debug menu in Safari.

defaults write com.apple.safari IncludeDebugMenu -bool YES


Deactivate Dashboard. 
Requires the dock to be relaunched to take effect, so type “killall Dock” and press enter.

defaults write com.apple.dashboard mcx-disabled -bool YES

Terminal Snow Leopard Tips !

There are a huge amount of hidden settings for Mac OS X and its applications that aren’t accessible from preferences dialog boxes or the System Preferences. Applications such as Tinkertool and Mac Pilot allow you to access some of these, but the real flexibility is from the Terminal. From here it is possible to edit any preferences file for any application on your Mac.
You’ll find the Terminal in the Utilities folder within the Applications folder. 

To carry out any of the following commands you will need to copy/paste or type in the line of text then hit enter.

See You – Folder Previews in Quick Look
Save some precious time by seeing all the content of a folder. Hit the space bar and you can view all the files via a  translucent folder icon.

You need to type the following command:

defaults write com.apple.finder QLEnableXRayFolders 1

Auto Action – Autoplay Movies in QuickTime X
Apple sometimes messes up and QuickTime is a great example.

If you want to play your movies automatically and surely miss the preferences option then use this command:

defaults write com.apple.QuickTimePlayerX MGPlayMovieOnOpen 1

Full Screen Action – QuickTime  In Full Screen When Switching Applications
Sometimes you want a sneak peek at all the action and when you do that, QuickTime will automatically exit full screen.

To rectify this, use the following magical words:

defaults write com.apple.QuickTimePlayerX MGFullScreenExitOnAppSwitch 0

Always Use Protection – Snow Leopard’s Hidden Malware Protection

Bet you didn’t know this one. Apple has quietly incorporated  malware support that detects malicious software and its quite effective too. Read all the details here.

Test Your Text – Enable Text Substitutions

If you want to globally enable text substitutions, use the three commands one after the other:

defaults write -g WebAutomaticTextReplacementEnabled -bool true
defaults write -g WebAutomaticDashSubstitutionEnabled -bool true
defaults write -g WebContinuousSpellCheckingEnabled -bool true

Shortcut To Success – Access iTunes
Access iTunes by just hitting the (F8) “Play” button which is above the 8 and 9 keys.


Round It Of – Get Rid of Rounded Corners in QuickTime
If you don’t care for the  rounded corners when playing movies in QuickTime, then don’t fret as you can get rid of them in seconds.

Just type:

defaults write com.apple.QuickTimePlayerX MGCinematicWindowDebugForceNoRoundedCorners 1

Go To China Town – Draw Chinese Characters On The Trackpad
I can’t speak Mandarin but I just find this a super cool feature.
In Snow Leopard  you can draw the actual characters on your trackpad!

Just Shoot Me- Record Videos Via QuickTime X
You don’t need to invest in some fancy software to shoot yourself as now you can record from your iSight camera.

Stick Them Up – Keyboard  Shortcut For Sticky Notes
Assign a  a keyboard shortcut (System Preferences > Keyboard)  so that you create a  sticky note automatically when you select some text.

Hope you enjoyed this article and more importantly enjoying your Mac with Snow Leopard. Do tell us if you know more tricks or tips and don’t forget to write them in the comments section.