Command Line Crash Course For Unix
Controlling Your Computer From The Terminal
Zed A. Shaw
How To Use This Course
Youcannotlearn to do this from videos alone. You can learnaboutthe subject from the video. But to really learnto dothis 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.
About Linux vs. OSX
Linux and Apple’s OSX use the same kind of Unix shell calledbash.
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.
Ex 1: The Setup
Ex 2: Paths, Folders, Directories (pwd) Ex 3: Who Are You? (whoami)
Finding your terminal program and getting it to run. Go to the exercise.
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. Go to the exercise.
Who Are You?
Figure out what username the computer thinks you use. Go to the exercise.
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.
Make A Directory (mkdir)
Create new directories with the "make directory" command mkdir.
Change Directory (cd)
Change to different directories with the "change directory" command cd.
List Directory (ls)
List out the contents of a directory. Go to the exercise.
Remove Directory (rmdir)
Remove a directory, but they have to be empty.
See how trying to remove a full directory causes an error. Go to the exercise.
Moving Around (pushd, popd)
Temporarily moving to another directory with "push directory" (pushd).
Come back by "popping the directory" off with popd. Go to the exercise.
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.
Making Empty File (touch)
Sometimes you need to just make an empty file. The touch command does that.
Copy A File (cp)
Copy a file’s contents to another file with the cp command. Go to the exercise.
Moving A File (mv)
Move a file to a new place with the mv (move) command. This can also be considered "renaming" a file.
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. Go to the exercise.
Stream A File (cat)
Dump the contents of a file to the terminal with cat. Go to the exercise.
Removing A File (rm)
Remove a file, and also remove whole directories. DANGER! You can totally destroy your files if you’re not careful.
Pipes And Redirection
Send the output of one command to the input of another. Chain inputs and outputs to multiple commands.
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.
Ex 17: Finding Files (find)
Ex 18: Looking Inside Files (grep) Go To This Section
Finding Files (find)
Find files by their names and types with the find command. Go to the exercise.
Looking Inside Files (grep)
Find files by their contents with the grep command. Go to the exercise.
Ex 19: Getting Command Help (man) Ex 20: Finding Help (apropos)
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. Go to the exercise.
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.
Ex 21: What’s In Your Environment (env, echo) Ex 22: Changing Environment Variables (export) Ex 23: Exiting Your Terminal (exit)
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. Go to the exercise.
Changing Environment Variables (export)
Changing the environment contents using the export command.
Using unset to remove an environment variable. Go to the exercise.
Exiting Your Terminal (exit)
Using exit to ... exit. Go to the exercise.
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.