Mac Shortcuts

Mac Keyboard Shortcuts

I like to figure out the fastest way to do things. I hope these keystrokes help you to become the power user that lies within. These keystrokes have been tested in Mac OS X Mavericks (Mac OS 10.9) but most should work on other versions of Mac OS (10.8 Mountain Lion, 10.7 Lion, etc.).

Menu Symbols

Menu Symbol Key on Keyboard
  Command/Apple Key (like Control on a PC)
Also written as Cmd
  Option (like Alt on a PC)
  Shift
  Control (Control-click = Right-click)
  Tab
  Return
  Enter (on Number Pad)
  Eject
  Escape
  Page Up
  Page Down
  Home
  End
  Arrow Keys
  Delete Left (like Backspace on a PC)
  Delete Right (also called Forward Delete)

Finder

Action Keystroke
Open Sidebar item in a new Tab or Window (depending on Finder Preferences) Cmd-Click
Switch Finder views
(Icon, List, Column, Cover Flow)
Cmd-1, Cmd-2, Cmd-3, Cmd-4
In List view, expand a folder Right Arrow
In List view, collapse a folder Left Arrow
Rename the selected file/folder Press Return (or Enter)
Go into selected folder or open the selected file Cmd-Down Arrow
Go to parent folder Cmd-Up Arrow
Go Back Cmd-[  (that’s left bracket)
Go Forward Cmd-]  (that’s right bracket)
Select the next icon in Icon and List views Tab (Shift-Tab reverses direction)
Alternate columns in Column View Tab (Shift-Tab reverses direction)
Resize one column to fit the longest file name Double-Click column divider (or the resize widget at the bottom of the column divider, depending on your setup)
Resize all columns to fit their longest file names Option Double-Click column divider (or the resize widget at the bottom of the column divider, depending on your setup)
Copy and Paste files Cmd-C, then Cmd-V
Copy and Paste files Exactly (Keeps original ownership & permissions. Requires Admin username & password.) Cmd-C, then Cmd-V
Cut and Paste files (Move files) Cmd-C, then Cmd-Option–V
Move a file instead of copying
(Copies to the destination and removes it from the original disk.)
Cmd-Drag file to disk
Move selected files to the Trash Cmd-Delete
Empty the Trash (with warning) Cmd-Shift-Delete
Empty the Trash (without warning) Cmd-Opt-Shift-Delete
Cancel a drag-n-drop action while in the midst of dragging Esc
Show Inspector (a single, live refreshing Info window) Cmd-Opt-I
Undo the last action (such as rename file, copy file, etc.) Cmd-Z
Hide/Show Sidebar (on the left) Cmd-Opt-S
Hide/Show Toolbar (on the top) and the Sidebar Cmd-Opt-T
Move or Remove item in toolbar (at the top of the window). Works in most programs. Cmd-Drag
Open Quick Look (Previews most types of files without having to open them) Spacebar (or Cmd-Y) or on a trackpad tap with 3 fingers.
Zoom In/Out in Quick Look (Images & PDFs) Pinch on a trackpad or hold Opt while scrolling. For images, holding Opt zooms to 100%.
Find Files Cmd-F

App Switcher

Action Keystroke
Quickly switch between 2 apps
(like InDesign & Photoshop)
Press Cmd-Tab to switch to last used app.
Press Cmd-Tab again to switch back.
NOTE: Press keys quickly and do NOT hold.
Switch between apps Press Cmd-Tab & continue holding Cmd.
While holding Cmd, to choose which app you want to switch to you can:

  • press Tab (several times if needed) to scroll right
  • press tilde(~) or Shift-Tab to scroll left
  • use the left/right arrow keys
  • aim with the mouse
  • use end/home key to go to first/last app
Quit an app in the app switcher When in the app switcher you’re already holding Cmd, so hit Q to quit selected app.
Hide an app in the app switcher In the app switcher you’re already holding Cmd, so hit H to hide selected app.
Cancel the app switcher In the app switcher you’re already holding Cmd, so hit Esc or period(.)

Managing Windows & Dialogs

Action Keystroke
Switch to next window Cmd-tilde(~)
Switch to previous window Cmd-Shift-tilde(~)
See where the File/Folder is located (a menu will pop-up displaying the folder hierarchy). Works in most programs, including the Finder. Cmd-Click on name of the window (in the titlebar)
Move a window in the background without switching to it. Cmd-Drag on the window’s titlebar
Choose “Don’t Save” in a Dialog Cmd-D in some apps, but other apps use Cmd-Delete (Cmd-D will change the location to the Desktop)
 

Dock

Action Keystroke
Hide all other applications (except the one you’re clicking on) Command-Option click an App’s icon in Dock
Reveal a Dock item’s location in the Finder Command Click on the icon in the Dock
Force a file to open in a specific app While dragging the file onto an app’s icon in the Dock, hold Command-Option
In an App’s Dock menu change the Quit to Force Quit (Click & hold on an App in the Dock to show the menu) Hold Option while in Dock menu
Move Dock to left, bottom, right side of screen Hold Shift and drag Dock divider
Change the icon size of a stack (must be the grid view) Cmd-plus(+) or Cmd-minus(–)
Temporarily turn magnification on/off Hold Control-Shift
Force the Dock to only resize to non-interpolated icon sizes Hold Option while dragging Dock separator

Dashboard

Action Keystroke
Close a widget without having to open the widget dock Hold Option and hover over widget (close box will appear)
Reload/Refresh a widget Cmd-R
 

Working with Text
Some only work in Cocoa apps like Safari, Mail, TextEdit, etc.

Action Keystroke
Go to end of line Cmd-right arrow
Go to beginning of line Cmd-left arrow
Go to end of all the text Cmd-down arrow
Go to beginning of all the text Cmd-up arrow
Go to end of current or next word Option-right arrow
Go to beginning of current or previous word Option-left arrow
Add Shift to the above keystrokes to make a selection to that point.
On Laptops: Delete Text to the right of the cursor (like the Del key on a full keyboard) Function(fn)-Delete
Non-touching (Discontinuous) text selections Command-drag
Select non-linear areas Option-drag
Delete entire word to the left Opt-Delete
Paste and Match Style (so it looks the same as the text you are pasting into) Cmd–Opt-Shift–V
Look up word in dictionary Mouse over a word and hit Cmd-Ctrl-D (Or on a trackpad use 3 fingers to tap on a word)
Display Emoji pop-up (new in 10.9 Mavericks) Command-Control-Space (You can then start typing to search the list of Emojis)
Display Special/Alternate Characters (new in 10.9 Mavericks) Hold any key. Example: Holding the “A” key will display à á â etc. You can press the corresponding number under the character you want to type to choose it (or arrow over to it).
Auto completion word Start typing the word. Press Esc (or F5) to open suggested word list
Switch to Outline Mode in TextEdit
  • Press Option-Tab to convert the current line into a list item
  • Press Return to create another list item
  • Press Tab at the start of a blank list item to indent it, creating a sublist
  • Press Shift-Tab to remove a level of indention
  • Press Return twice to decrease the indent, exiting the current sublist/list

Screenshots
Screenshots are saved to the Desktop as a PNG file.

Action Keystroke
Take picture of the entire screen Cmd-Shift-3
Take picture of a selected area Cmd-Shift-4 and Drag over an area
While dragging:

  • Hold Spacebar to move selected area.
  • Hold Shift to change size in one direction only (horizontal or vertical)
  • Hold Option for center-based resizing.
Take picture of a specific window/object Cmd-Shift-4, then press Spacebar, then Click on the window/object
Hold Control with any of the follow keystrokes to copy the screenshot to the clipboard instead of making a file.

Spotlight

Action Keystroke
Open Spotlight Menu Cmd-Space
Open Spotlight Search Window Cmd-Option-Space
Launch Top Hit (in the Menu) Return
Reveal selected item in Finder In Spotlight Menu:
Cmd-Click item or press Cmd-Return
In Spotlight/Find Window: Press Cmd-R
Skip to first result in a category Cmd up/down arrow
Look up the definition of a word Type the word in Spotlight menu’s search field and hit Cmd–L to look it up.
Clear Spotlight’s search field Esc clears to do another search.
Esc a second time closes Spotlight menu.
 
 

Mission Control

Action Keystroke
Enter Mission Control Ctrl-Up Arrow
Move to a neighboring space/full screen app Ctrl-Left or Right Arrow
View Windows in the Current App Ctrl-Down Arrow
Show Desktop F11 (may need to hold the fn buton on some keyboards)
Show Dashboard F12 (may need to hold the fn buton on some keyboards) or the dedicated Dashboard key

Startup, Restart, Shutdown & Sleep

Action Keystroke
Eject CD on boot Hold Mouse button down immediately after powering on
Safe boot Hold Shift during startup
Start up in FireWire Target Disk mode Hold T during startup
Startup from a CD, DVD Hold C during startup
Bypass primary startup volume and seek a different startup volume (CD, etc.) Hold Cmd-Opt-Shift-Delete during startup
Choose Startup disk before booting Hold Option during startup
Start up in Verbose mode Hold Cmd-V during startup
Start up in Single-User mode (command line) Hold Cmd-S during startup
Shutdown immediately (no confirmation) Hold Cmd-Opt-Ctrl and press the Eject key or Power button
Restart immediately (no confirmation) Cmd-Ctrl-Eject
Forced Restart (only do this when absolutely needed) Cmd-Ctrl-Power button
Sleep immediately (no confirmation) Press the Power button (or hit Cmd-Opt-Eject)
Show Dialog with Restart, Sleep & Shutdown Options Hold Ctrl and press the Eject key or Power button (or hold the Power button about 1.5 seconds and the dialog will appear)
Put display to sleep Hold Ctrl-Shift and press the Eject key or Power button

Safari

Action Keystroke
Switch to Next Tab Ctrl-Tab (or Cmd-Shift-Right Arrow)
Switch to Previous Tab Ctrl-Shift-Tab (or Cmd-Shift-Left Arrow)
Go to one of the first 9 bookmarks in the Bookmarks Bar (doesn’t work on folders) Cmd-1 through Cmd-9
Move between found items Cmd-F, enter your search text and Press:
Return to Move Forward
Shift-Return to Move Backward
Cancel current Find Press Escape or Cmd-Period(.)
Scroll by one full screen Scroll Down: Spacebar or Option–Down Arrow
Scroll Up: Shift–Spacebar or Option-Up Arrow
Open Link in New Tab (in the background) Cmd–Click a link
Open Link in New Window Cmd–Opt–Shift Click a link
Add to Reading List Shift–Click a link

Apple Mail

Action Keystroke
Send Message Cmd–Shift–D (remember as D = Deliver)
Reply to Message Cmd–R or Opt–Double Click Message
Reply All Cmd–Shift–R
Go to Inbox Cmd–1
Go to other mailboxes in your favorites bar Cmd–2, 3, etc.
Prevent the next message from being automatically selected & marked as read Opt–Delete

Miscellaneous

Action Keystroke
Force Quit (displayed list of apps) Cmd-Opt-Esc
Scroll using a Trackpad (like a mouse’s scroll wheel) Slide 2 fingers on the trackpad
Right-click using a Trackpad (like on a 2 button mouse) Place 2 fingers on the trackpad and Click
Quickly find any menu item and launch it.
  1. Press Cmd-? which is Cmd-Shift-/
  2. In the Help menu Search that opens, start typing a few letters of your desired menu command.
  3. Arrow key down to the item you want and press Return to choose it.
If an app re-opens with the windows that were open when you last quit it, you can tell it not to re-open the windows. Hold Shift while launching an app
Change system volume without the confirmation beeps Hold Shift while changing volume
Change system volume in smaller increments Hold Opt–Shift while changing volume
Completely smooth scrolling, one pixel at a time. (Only works in some apps.) Hold Option while dragging scrollbar
Open System Preferences:
These launch directly into a preference pane. Here are 2 examples.
  • To open “Sound” Preferences:
    Hold Option & hit a Sound key (Mute, Volume Up or Down )
  • To open “Displays” Preferences:
    Hold Option & hit a Brightness key
Customize the toolbar at the top of a window. Works in the Finder, Apple Mail, Preview, etc. but not some apps, like Firefox.
  • Cmd drag icons to rearrange.
  • Cmd drag icon off toolbar to remove.
  • Ctrl-click toolbar and choose Customize for more options.
Move the Terminal cursor with the mouse Option–click where you’d like the cursor

Preview

Action Keystroke
Zoom In or Out Cmd-Plus(+) or Cmd-Minus(-)
Zoom to Actual Size Cmd-0
Zoom to Fit Cmd-9

Emacs Key Bindings
Only work in Cocoa apps like Safari, Mail, TextEdit, etc.

Action Keystroke Remember As
go to start of line (move cursor to start of line) Ctrl-A A = Start of alphabet
go to end of line (move cursor to end of line) Ctrl-E E = End
go up one line Ctrl-P P = Previous
go down one line Ctrl-N N = Next
go back a character (move cursor left) Ctrl-B B = Back
go forward a character (move cursor right) Ctrl-F F = Forward
delete the character to the right of the cursor Ctrl-D D = Delete
delete the character to the left of the cursor Ctrl-H  
delete the selection or to the end of the line (acts like cutting the text) Ctrl-K K = Kill
yank back the killed text (acts like pasting) Ctrl-Y Y = Yank
scroll down Ctrl-V  
center the current line in the window Ctrl-L  
insert line break after the cursor without moving the cursor Ctrl-O  
transpose letters (swaps letters on left and right of cursor) Ctrl-T T = Transpose

Mac Multi-Touch Gestures

Multitouch gestures let you use several fingers to do cool stuff on Mac Laptops and the Magic Trackpad.
Some gestures do not work on older laptops.

General Must be enabled in System Preferences.

Action Gesture
Scroll Up/Down/Left/Right 2-Finger Drag Up/Down/Left/Right
Right-Click (Ctrl-Click) 2-Finger Click
Zoom In on the Screen Hold Control and 2-Finger Drag Up
Zoom Out on the Screen Hold Control and 2-Finger Drag Down
Lookup Word in Dictionary 3-Finger Tap on the Word

Quick Look (In Finder)

Action Gesture
Open Quick Look 3–Finger Tap on a File
Exit Fullscreen Quick Look Pinch In Quick Look
Enter Fullscreen Quick Look Expand (Reverse Pinch) In Quick Look
 

Mission Control, Etc.

Action Gesture
Open and Close Mission Control 3–Finger Swipe Up/Down
Switch between full-screens apps or spaces 3–Finger Swipe Left/Right
Show Desktop (Push All Windows Aside) 4–Finger Expand.
To Restore the Windows do a 4–Finger Pinch.
View Launchpad 4-Finger pinch
Open Notification Center 2-Finger swipe from the right side of the trackpad
Show all windows in the current app (App Exposé) 3-Finger swipe down.
3-Finger swipe up to exit.

Safari

Action Gesture
Go Back/Forward 2-Finger Swipe Left/Right/td>
Zoom Out (Decrease Font Size) Pinch
Zoom in (Increase Font Size) Expand (Reverse Pinch)
Auto Zoom into Content 2–Finger tap on the content you want to enlarge

Calendar

Action Gesture
Go to Previous/Next Day, Week or Month (Works like Cmd-Left/Right Arrow) 2-Finger Swipe Left/Right
 

Preview

Action Gesture
Rotate Image Rotate (Clockwise or Counter Clockwise)
Zoom Out (Decrease Image Size) Pinch Over Image
Zoom In (Increase Image Size) Expand (Reverse Pinch) Over Image
Flip through Multiple Images/Pages 2-Finger Swipe Up/DownLeft/Right

Quicktime

Action Gesture
Scrub Backward/Forward through the Video 2-Finger Swipe Left/Right
(or Up/Down)
Exit Fullscreen Pinch
Enter Fullscreen Expand (Reverse Pinch)

OS X Mavericks 10.9.4 bootable USB

OS X Mavericks 10.9.4 bootable USB (DMG File) (13E28)
Use the "Restore" option in Disk Utility to write it down on a USB-stick.

How

Format Your USB Flash Drive

1. Insert the USB flash drive into your Mac’s USB port.
2. Launch Disk Utility, located at /Applications/Utilities/.
3. In the list of drives attached to your Mac, select the USB flash drive device. In my case, it’s called 14.9 GB SanDisk Cruzer Media.
4. Click the ‘Partition’ tab.
5. Select ‘1 Partition’ from the Volume Scheme dropdown menu.
6. Enter a descriptive name for your flash drive; I chose "USB Install Drive"
7. Select Mac OS X Extended (Journaled) from the Format dropdown menu.
8. Click the ‘Options’ button.
9. Select ‘GUID Partition Table’ from the list of available partition schemes.
10. Click ‘OK.

Now the USB flash drive is prepared you can Restore "OS X Base System.dmg" to your flash drive.

1. Click on "Restore" in the Disk Utility window.
2. Drag "OS X Base System.dmg" to "Source"
3. Drag the usb flash drive (in my case "USB Install Drive") to "Destination"
4. Click "Restore" en enter your system password.
5. Done.

1. Restart the machine and go to Recovery Mode (Kepp Press Command + R until logo appears during startup)
2. Go To disk utility and change the Startup Disk form the Menu
3. Select the "USB Install Drive" and Restart
4. It will start the installation from the bootable disk

Running mongo as service

Make sure that you added you /bin directory to you system variable PATH

First I executed this command:

D:\mongodb\bin>mongod --remove

Then executed this one:

D:\mongodb\bin>mongod --dbpath=D:\mongodb --logpath=D:\mongodb\log.txt --install

After that right there in the command prompt execute:

services.msc

And look for MongoDB service and click start.

UNIX Commands

VI Commands

General Startup
To use vi: vi filename
To exit vi and save changes: ZZ   or  :wq
To exit vi without saving changes: :q!
To enter vi command mode: [esc]

Counts
A number preceding any vi command tells vi to repeat
that command that many times.

Cursor Movement

h       move left (backspace)
j       move down
k       move up
l       move right (spacebar)
[return]   move to the beginning of the next line
$       last column on the current line
0       move cursor to the first column on the current line
^       move cursor to first nonblank column on the current line
w       move to the beginning of the next word or punctuation mark
W       move past the next space
b       move to the beginning of the previous word or punctuation mark
B       move to the beginning of the previous word, ignores punctuation
e       end of next word or punctuation mark
E       end of next word, ignoring punctuation
H       move cursor to the top of the screen
M       move cursor to the middle of the screen
L       move cursor to the bottom of the screen

Screen Movement

G        move to the last line in the file
xG       move to line x
z+       move current line to top of screen
z        move current line to the middle of screen
z-       move current line to the bottom of screen
^F       move forward one screen
^B       move backward one line
^D       move forward one half screen
^U       move backward one half screen
^R       redraw screen ( does not work with VT100 type terminals )
^L       redraw screen ( does not work with Televideo terminals )

Inserting

r        replace character under cursor with next character typed
R        keep replacing character until [esc] is hit
i        insert before cursor
a        append after cursor
A        append at end of line
O        open line above cursor and enter append mode

Deleting

x       delete character under cursor
dd      delete line under cursor
dw      delete word under cursor
db      delete word before cursor

Copying Code

yy      (yank)’copies’ line which may then be put by
the p(put) command. Precede with a count for
multiple lines.

Put Command
brings back previous deletion or yank of lines,
words, or characters

P       bring back before cursor
p       bring back after cursor

 Find Commands

?       finds a word going backwards
/       finds a word going forwards
f       finds a character on the line under the cursor going forward
F       finds a character on the line under the cursor going backwards
t       find a character on the current line going forward and stop one character before it
T       find a character on the current line going backward and stop one character before it
;    repeat last f, F, t, T

Miscellaneous Commands

.    repeat last command
u    undoes last command issued
U    undoes all commands on one line
xp    deletes first character and inserts after second (swap)
J    join current line with the next line
^G    display current line number
%    if at one parenthesis, will jump to its mate
mx    mark current line with character x
‘x    find line marked with character x

NOTE: Marks are internal and not written to the file.

Line Editor Mode
Any commands form the line editor ex can be issued
upon entering line mode.

To enter: type ‘:’
To exit: press[return] or [esc]

ex Commands
For a complete list consult the
UNIX Programmer’s Manual

READING FILES
copies (reads) filename after cursor in file
currently editing

:r filename

WRITE FILE

:w     saves the current file without quitting

MOVING

:#    move to line #
:$    move to last line of file

SHELL ESCAPE
executes ‘cmd’ as a shell command.
:!’cmd’

For change the color in console in home directory

vi .bashrc

add the following line

unset LS_COLORS

enter the following command for the current session

[ugunasekaran@phxbeacon02 logs]$ cd

[ugunasekaran@phxbeacon02 ~]$ . .bashrc

[ugunasekaran@phxbeacon02 ~]$ cd –

For executing the last command /

Kill the process: ^Z and kill %1and enter one more time

To start the app server:

cd /v3app/intl/bin

./wrapper.sh start

To Find unique records in file

cat signin-ato-2013-04-12.txt | cut -d , -f2 | sort | uniq | wc -l

 For Sudo Access

sudo su – was

For Deployment:

perl /var/tmp/v3deploy/deploy.pl -deliverable beacon –servetraffic –nocreatedatasource –force –nodiskcheck –odbName=ibeacon-app –calPoolName=v3beaconintl E765_INTL_BUNDLED_14590170_R1.zip

export PATH=/path/to/dir:$PATH

To set vi mode

set –v vi

Writing into file

tee a_`date ‘+%m%d%y_%H_%M_%S’`

fbuild | tee “/c/Users/ugunasekaran/Desktop/mvnlog`date ‘+%d_%m_%H_%M_%S’`.log”

File Transfer to Ubundu/Linux/Unix – PSCP is in downloads folder – Go to download and run this command

pscp source_file_name userid@server_name:/path/destination_file_name.

Inline editing of file contents

perl -i.bkp -npe ‘s/hive -e/hive -S -e/;’ *.sh

Searching pattern in file

find . -name “*” -exec grep -i “top dispute” {} \; -print

Replacing pattern in file

find . -name “*sas” -exec perl -pi -e ‘s/guzhu\@ebay.com/DL-eBay-PD-TNS-PD\@corp.ebay.com/g’ {} \; -print

Replacing pattern in file from list of files

for f in $(cat test.txt); do echo “Processing $f…” ; perl -pi.uv-back -e ‘s/guzhu\@ebay.com/DL-eBay-PD-TNS-PD\@corp.ebay.com/g’ $f; done

Remote File Copy

Copy the file “foobar.txt” from a remote host to the local host

$ scp your_username@remotehost.edu:foobar.txt /some/local/directory

Copy the file “foobar.txt” from the local host to a remote host

$ scp foobar.txt your_username@remotehost.edu:/some/remote/directory

Copy the directory “foo” from the local host to a remote host’s directory “bar”

$ scp -r foo your_username@remotehost.edu:/some/remote/directory/bar

Copy the file “foobar.txt” from remote host “rh1.edu” to remote host “rh2.edu”

$ scp your_username@rh1.edu:/some/remote/directory/foobar.txt \
your_username@rh2.edu:/some/remote/directory/

Copying the files “foo.txt” and “bar.txt” from the local host to your home directory on the remote host

$ scp foo.txt bar.txt your_username@remotehost.edu:~

Copy the file “foobar.txt” from the local host to a remote host using port 2264

$ scp -P 2264 foobar.txt your_username@remotehost.edu:/some/remote/directory

Copy multiple files from the remote host to your current directory on the local host

$ scp your_username@remotehost.edu:/some/remote/directory/\{a,b,c\} .
$ scp your_username@remotehost.edu:~/\{foo.txt,bar.txt\} .

Terminal Multiplexers

TMUX