Nearly ever computer comes with a CLI
- Windows: Git Bash (See "Introduction to Git")
- Mac/Linux: Terminal
Jeffrey Leek
Johns Hopkins Bloomberg School of Public Health
Nearly ever computer comes with a CLI
The CLI can help you:




/
~
Windows users:

Mac users:

$

pwd and press enter.
pwd can be used at any time to display the path to your working directory (pwd is an abbreviation for "print working directory")-pwd is a command that requires no flags or argumentspwd displays the path to the current working directoryjeff$ pwd
/Users/jeff
jeff$
clear will clear out the commands in your current CLI windowjeff$ pwd
/Users/jeff
jeff$ clear
jeff$
ls lists files and folders in the current directoryls -a lists hidden and unhidden files and foldersls -al lists details for hidden and unhidden files and folders-a and -l are flags (they're preceded by a -)-aljeff$ ls
Desktop Photos Music
jeff$ ls -a
Desktop Photos Music .Trash .DS_Store
jeff$
cd stands for "change directory"cd takes as an argument the directory you want to visitcd with no argument takes you to your home directorycd .. allows you to chnage directory to one level above your current directoryjeff$ cd Music/Debussy
jeff$ pwd
/Users/jeff/Music/Debussy
jeff$ cd ..
jeff$ pwd
/Users/jeff/Music
jeff$ cd
jeff$ pwd
/Users/jeff
jeff$
mkdir stands for "make directory"mkdir takes as an argument the name of the directory you're creating jeff$ mkdir Documents
jeff$ ls
Desktop Photos Music Documents
jeff$ cd Documents
jeff$ pwd
/Users/jeff/Documents
jeff$ cd
jeff$
touch creates an empty filejeff$ touch test_file
jeff$ ls
Desktop Photos Music Documents test_file
jeff$
cp stands for "copy"cp takes as its first argument a file, and as its second argument the path to where you want the file to be copiedjeff$ cp test_file Documents
jeff$ cd Documents
jeff$ ls
test_file
jeff$ cd ..
jeff$
cp can also be used for copying the contents of directories, but you must use the -r flagcp -r Documents More_docs copies the contents of Documents into More_docsjeff$ mkdir More_docs
jeff$ cp -r Documents More_docs
jeff$ cd More_docs
jeff$ ls
test_file
jeff$ cd ..
jeff$
rm stands for "remove"rm takes the name of a file you wish to remove as its argumentjeff$ ls
Desktop Photos Music Documents More_docs test_file
jeff$ rm test_file
jeff$ ls
Desktop Photos Music Documents More_docs
jeff$
rm to delete entire directories and their contents by using the -r flagrmjeff$ ls
Desktop Photos Music Documents More_docs
jeff$ rm -r More_docs
jeff$ ls
Desktop Photos Music Documents
jeff$
mv stands for "move"mv you can move files between directoriesjeff$ touch new_file
jeff$ mv new_file Documents
jeff$ ls
Desktop Photos Music Documents
jeff$ cd Documents
jeff$ ls
test_file new_file
jeff$
mv to rename filesjeff$ ls
test_file new_file
jeff$ mv new_file renamed_file
jeff$ ls
test_file renamed_file
jeff$
echo will print whatever arguments you providejeff$ echo Hello World!
Hello World!
jeff$
date will print today's datejeff$ date
Mon Nov 4 20:48:03 EST 2013
jeff$
pwdclearlscdmkdirtouchcprmmvdateecho