Command Line Crash Course For Unix Controlling Your Computer From The Terminal Zed A. Shaw December 2011
Introduction How To Use This Course You cannot learn to do this from videos alone. You can learn about the subject from the video. But to really learn to do this subject requires the book. The book "Command Line Crash Course" is included, and it s meant to be a fast workbook that makes you do things. Do not just watch these videos and then think you re done. Videos + Book is the way to go.
Introduction About Linux vs. OSX Linux and Apple s OSX use the same kind of Unix shell called bash. I m going to use OSX because my screen capture system is on it. But I ll show you how to get to the terminal on Ubuntu when I cover Ex 1. Keep in mind that my paths might be different, so just adapt.
Introduction Introduction Exercises 1-3 Ex 1: The Setup Ex 2: Paths, Folders, Directories (pwd) Ex 3: Who Are You? (whoami)
Introduction Exercise 1 The Setup Finding your terminal program and getting it to run.
Introduction Exercise 2 Paths, Folders, Directories (pwd) Figure out where your terminal starts off using the "print workind directory" command. See how that maps to your desktop file browser.
Introduction Exercise 3 Who Are You? Figure out what username the computer thinks you use.
Directories Directories Exercises 4-8 Ex 4: Make A Directory (mkdir) Ex 5: Change Directory (cd) Ex 6: List Directory (ls) Ex 7: Remove Directory (rmdir) Ex 8: Moving Around (pushd, popd) Go to this section.
Directories Exercise 4 Make A Directory (mkdir) Create new directories with the "make directory" command mkdir.
Directories Exercise 5 Change Directory (cd) Change to different directories with the "change directory" command cd.
Directories Exercise 6 List Directory (ls) List out the contents of a directory.
Directories Exercise 7 Remove Directory (rmdir) Remove a directory, but they have to be empty. See how trying to remove a full directory causes an error.
Directories Exercise 8 Moving Around (pushd, popd) Temporarily moving to another directory with "push directory" (pushd). Come back by "popping the directory" off with popd.
Files Files Exercises 9-16 Ex 9: Making Empty Files (touch) Ex 10: Copy A File (cp) Ex 11: Moving A File (mv) Ex 12: View A File (less) Ex 13: Stream A File (cat) Ex 14: Removing A File (rm) Ex 15: Pipes And Redirection Ex 16: Wildcard Matching Go to this section.
Files Exercise 9 Making Empty File (touch) Sometimes you need to just make an empty file. The touch command does that.
Files Exercise 10 Copy A File (cp) Copy a file s contents to another file with the cp command.
Files Exercise 11 Moving A File (mv) Move a file to a new place with the mv (move) command. This can also be considered "renaming" a file.
Files Exercise 12 View A File (less) Take a quick look at a file with the less command. The less command is a modern version of an old unix command called more. Get it? Ahhh, how droll.
Files Exercise 13 Stream A File (cat) Dump the contents of a file to the terminal with cat.
Files Exercise 14 Removing A File (rm) Remove a file, and also remove whole directories. DANGER! You can totally destroy your files if you re not careful.
Files Exercise 15 Pipes And Redirection Send the output of one command to the input of another. Chain inputs and outputs to multiple commands.
Files Exercise 16 Wildcard Matching Run commands on whole batches of files with a "wildcard". The wildcard is also called a "regular expression". If you want to learn about regular expressions, take a look at my other book, Learn Regex The Hard Way.
Searching Searching Exercises 17-18 Ex 17: Finding Files (find) Ex 18: Looking Inside Files (grep) Go To This Section
Searching Exercise 17 Finding Files (find) Find files by their names and types with the find command.
Searching Exercise 18 Looking Inside Files (grep) Find files by their contents with the grep command.
Help Help Exercises 19-20 Ex 19: Getting Command Help (man) Ex 20: Finding Help (apropos) Go to this section.
Help Exercise 19 Getting Command Help (man) Why remember things when you can just look them up? The man command helps you get information on other commands. You can also do help or -h on many commands.
Help Exercise 20 Finding Help (apropos) Sometimes you don t even know the name of the command. Searching online is usually better, but if you re desperate, there s apropos.
Sessions Sessions Exercises 21-23 Ex 21: What s In Your Environment (env, echo) Ex 22: Changing Environment Variables (export) Ex 23: Exiting Your Terminal (exit) Go to this section.
Sessions Exercise 21 What s In Your Environment (env, echo) What the environment is and what it does. Find out what s in your environment using env and echo.
Sessions Exercise 22 Changing Environment Variables (export) Changing the environment contents using the export command. Using unset to remove an environment variable.
Sessions Exercise 23 Exiting Your Terminal (exit) Using exit to... exit.
Epilogue Next Steps Where To Go From Here Get the cheat sheet. Print it out and keep it near you. Force yourself to use it every day. Go to this chapter.