Terminal Cheat Sheet

Malisha Tharindu
1 min readMay 26, 2020

Here some of useful Terminal commands for Mac users.

Basic

pwd       #print working directoryls        #list files in directoryclear     #clear the terminal screen of all previous commands cd        #change directory~         #home directory (cd~ #this will change directory to home         directory)..        #up one directory (cd .. #this will change directory to up one)-         #previous working directory (use cd -)help      #get help
-h #get help
--help #get help
man #manualcat #output the contents of a filemkdir #create new directoryopen #open a file with the associated program, a directory with Finder, or a URL with the default web browserps #list all running processeskill #terminate existing processrmd #permanently delete filermdir #remove directory

Git

When working with Git following commands will be used frequently

git clone <url>                #Clone directorygit checkout -b <new-branch>   #Create new local branchgit push -u origin <new-branch>            #Sync local branch with remotegit checkout <branch>          #Checkout branchgit push origin <branch>       #Push branch to remotegit branch -d <branchname>     #Deletes local branchgit push origin :<branchname>  #Deletes remote branch git subtree push --prefix docs origin gh-pages  #Push docs as subtree to gh-pages
git branch -m <oldname> <newname>
#Rename branch
git branch -m <newname> #Rename current branchgit branch -d <branchname> #deletes local branchgit push origin :<branchname> #deletes remote branchgit remote prune <branchname> #update local/remote sync

--

--

Malisha Tharindu

Entrepreneur | iOS Developer | Web Developer with more than 5 Years of Experience. Founder of Learn with Malisha