Skip to content

Instantly share code, notes, and snippets.

@Dangeranger
Last active August 29, 2015 14:21
Show Gist options
  • Save Dangeranger/4ef3e5bc50df2da25988 to your computer and use it in GitHub Desktop.
Save Dangeranger/4ef3e5bc50df2da25988 to your computer and use it in GitHub Desktop.
Shell Scripting Primer OSX

###Core Commands

Command Description
cd Go to Home directory
cd ~ Go to Home directory
cd [folder] Go to a [folder]
cd / Go to Root of the operating system
ls List files and sub-directories in the directory
ls -l List details of files and sub-directories in the directory
ls -al List details of files and sub-directories including hidden
ls -lh List details of files and sub-directories with human readable sizes (50Kb)
ls -lR List details of all files and sub-directories recursively
sudo [command] Perform the [command] with super user (root) privileges
cat [file] Output the content of the file to the terminal screen
less [file] Read the file with the Less program, allowing page up, page down, find
nano [file] Edit the [file] with the Nano editor (simple beginner friendly)
open [file] Open a file with the default application (as though it were double-clicked)
ps List the process that are running under the currently logged in user
ps -wax List all the processes that are running under any users of the system
top List the processess running and the resource usage of the computer
exit Close the terminal session
clear Clear the terminal window screen

###Bash Keyboard Commands

Key/Command Description
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + L Clears the Screen
Command + K Clears the Screen
Ctrl + U Clears the line before the cursor position
Ctrl + H Same as backspace
Ctrl + R Lets you search through previously used commands
Ctrl + C Kill whatever you are running
Ctrl + D Exit the current shell
Ctrl + Z Puts whatever you are running into a suspended background process. fg restores it.
Ctrl + W Delete the word before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + T Swap the last two characters before the cursor
Esc + T Swap the last two words before the cursor
Alt + F Move cursor forward one word on the current line
Alt + B Move cursor backward one word on the current line
Tab Auto-complete files and folder names

###Other resources

Apple Shell Scripting Guide

Linux Command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment