L01 – the Terminal • What Is a Terminal? O Command Line Interface with the Computer. Text Only. in the Old Days the Terminal
Total Page:16
File Type:pdf, Size:1020Kb
L01 – The Terminal • What is a terminal? o Command line interface with the computer. Text only. In the old days the terminal was the only interface to the computer. o Terminal, bash, shell, console, are all interchangeable words, as far as we’re concerned. o The terminal will be our programming environment, we won’t use IDE’s like Eclipse. • Using the terminal o Everything you can do using the Finder, such as navigate to different folders, open files, create files and directories, can also be done via the terminal. o Navigating the file system § “pwd” – present working directory; reports your current location in the file system § “cd <dir>” – change directory; goes into a specified directory § “ls” – list; lists the contents of your pwd • “ls –alF” – the options “-alF” lists all files (even hidden files) with extra information. § “.” and “..” – shortcuts that refer to current directory, and up one level directory • e.g.: “cd ..” takes you up one level. “cd .” takes your to the current directory, effectively does nothing. § “~” is a shortcut that refers to your home directory. For me its /Users/gregorychen3 o Making changes to the file system § “mkdir <name>” – make directory; creates a new directory (folder) called <name> § “cp <src> <dest>” – copy; copies file located at <src> to <dest>. Hint: use “.” and “..” shortcuts to specify the file paths § “mv <src> <dest>” – move; move a file located at <src> to <dest>. Hint: use “.” and “..” shortcuts to specify the file paths § “rm <file>” – remove; removes the file located at <file>. • “rm –r <dir>” – remove recursive; removes directory located at <dir>. o Other § “man <cmd>” – displays the manual page for <cmd>. For example, “man ls” obtains the manual page for the “ls” command. “q” to quit the man page. § “*” – matches any sequence of characters. • e.g.: “rm *” removes all files in the current directory, don’t do this. “rm *.class” removes all files that end with .class .