COURSE · 13 chapters · 77 lessons
The command line
Type into a real Linux running inside your browser and learn where files live
All 13 chapters are ready. The last one teaches you `vi` and then puts everything together. There is no connection to the outside network, so `git` and `curl` are out of scope.
Where you are right now
- 01Where am I?Walk around and find your files, with just pwd, ls and cd.9 slides · 13 exercisesGo to the exercises
Create, move, remove
- 02Make it, move it, remove itHandle files and boxes with your own hands, using mkdir, touch, cp, mv and rm.8 slides · 13 exercisesGo to the exercises
Read without opening
- 03Put what is in a file on the screenUse cat to put a file on the screen. Join files, number the lines, make new ones.8 slides · 13 exercisesGo to the exercises
- 04Just the top and the bottomUse head and tail to slice the start and the end out of a big file.8 slides · 13 exercisesGo to the exercises
- 05Read it a page at a timeUse less to move up and down a long file. Open it, search it, get out of it.8 slides · 13 exercisesGo to the exercises
Count it, and identify it
- 06Counting thingsUse wc to count lines, words and bytes. And see how a byte differs from a character.8 slides · 13 exercisesGo to the exercises
- 07What a file is made ofUse stat to see everything except the contents. Use od to see the bytes themselves.8 slides · 13 exercisesGo to the exercises
Search by name and by content
- 08Track it down by nameUse find to track down a file by name when you have no idea where it is.8 slides · 13 exercisesGo to the exercises
- 09Narrow it down by kind and sizeUse -type and -size on find to get only the files, or only the big ones.8 slides · 13 exercisesGo to the exercises
- 10Search by the words insideUse grep to find words written inside a file, and change the sieve with -i and -v.9 slides · 13 exercisesGo to the exercises
- 11Search by shape (regular expressions)Use ^ $ . [] * and the + ? | of -E to search for a shape rather than a word.9 slides · 13 exercisesGo to the exercises
Look it up yourself
- 12Looking up the tools themselvesUse which, type and --help to find out where a command lives and how to use it.8 slides · 13 exercisesGo to the exercises
Point the output at a file
- 13Keep the result in a file (`>`)Point the output of a command at a file, so the result does not just flow past and vanish.7 slides · 13 exercisesGo to the exercises
- 14Add without wiping (`>>`)Use >> to add a result to the end of a file while keeping what is already there.6 slides · 13 exercisesGo to the exercises
- 15Split the errors off (`2>`)Errors come out of a different way out. Split them with 2>, join them with 2>&1, throw them away with /dev/null.8 slides · 13 exercisesGo to the exercises
- 16Pour a file in (`<`)Use < to wire a file to the standard input, so tools that only have a way in become usable.6 slides · 13 exercisesGo to the exercises
Join them with a pipe
- 17Join them with a pipe (`|`)The way out of one command into the way in of the next. Build things up, as many stages as you like.7 slides · 13 exercisesGo to the exercises
- 18Show it and keep it (`tee`)Use tee to branch a pipe, so you can watch what is happening partway and keep it.6 slides · 13 exercisesGo to the exercises
- 19Turn a stream into arguments (`xargs`)Use xargs to hand what came down a pipe to the next command as its arguments.8 slides · 13 exercisesGo to the exercises
Sort it, drop duplicates
- 20Sort it (`sort`)Sort lines with sort. As numbers, in reverse, or on a column you choose.8 slides · 13 exercisesGo to the exercises
- 21Drop duplicates, count them (`uniq`)Squash repeated lines with uniq, count them with -c, and learn why sort has to come first.6 slides · 13 exercisesGo to the exercises
Pull out, and replace
- 22Pull out a column (`cut`)Use cut to take part of a line. How to name the column by its separator, and where it gives up.6 slides · 13 exercisesGo to the exercises
- 23Swap characters, delete them (`tr`)Swap characters one for one with tr. Delete with -d, squeeze runs with -s. A tool that only reads stdin.6 slides · 13 exercisesGo to the exercises
- 24Line them up side by side, number them (`paste` and `nl`)Join two files sideways with paste. Number the lines with nl and cat -n.6 slides · 13 exercisesGo to the exercises
- 25Swap one piece of text for another (`sed`)Swap text with the s command of sed. Choose lines, delete lines. Rewrite the file itself with -i.7 slides · 13 exercisesGo to the exercises
- 26Calculate on columns (`awk`)Pull out columns with awk, choose lines by condition, and get totals and averages. The tool that does what cut could not.7 slides · 13 exercisesGo to the exercises
- 27Show the difference (`diff`)Show what differs between two files. How to read - and +, and how to use the exit status.7 slides · 13 exercisesGo to the exercises
The read, write and execute marks
- 28Read the nine characters of `ls -l`How to read a string like rw-r--r--. The one character for the kind, and three sets of rwx.7 slides · 13 exercisesGo to the exercises
- 29Change permissions with symbols (`chmod u+x`)Hand chmod three things: who, what to do, and to what. The u g o a and + - = combinations.7 slides · 13 exercisesGo to the exercises
- 30Change permissions with numbers (`chmod 755`)Add up r=4, w=2 and x=1 into three digits. What 644 and 755 mean, and why 777 is too strong.8 slides · 13 exercisesGo to the exercises
- 31The default for new things (`umask`)Why touch gives you 644. Read the number being taken off a base of 666.8 slides · 13 exercisesGo to the exercises
Owners, and permissions on folders
- 32Owners and groupsWho the nine characters apply to. How only one of the three is chosen, and why you cannot change the owner.8 slides · 13 exercisesGo to the exercises
- 33The permissions of a directoryA box's x means "pass through". Whether something can be removed is decided by the box, not the file.8 slides · 13 exercisesGo to the exercises
Who am I
- 34Become root (`su`)The special user who slips past every permission check. Switch with su, come back with exit.8 slides · 13 exercisesGo to the exercises
- 35Read the registersWho exists is written in
/etc/passwd. Point the tools you know at the register and run an inspection.8 slides · 13 exercisesGo to the exercises
Create users and groups
- 36Make a userAdd a person with
adduser. Give them a password, become them, then remove them.8 slides · 13 exercisesGo to the exercises - 37Make a group and put people in itThe box that lets two people touch the same file. Including the difference between a main group and an added one.8 slides · 13 exercisesGo to the exercises
- 38Share a shelf with a groupPut the nine characters of chapter 6 together with the groups of chapter 7 and build a shelf two people can write to. Including setgid and umask.8 slides · 13 exercisesGo to the exercises
See what is running
- 39See what is running (`ps`)Processes and PIDs. List them with ps, and pick the columns you want with -o.8 slides · 13 exercisesGo to the exercises
- 40See the parentage as a tree (`pstree`)Every process branches off from 1. See the shape of it at a glance.8 slides · 13 exercisesGo to the exercises
- 41Who is heavy right now (`top`)ps is a photograph, top is a film. Find what is eating the CPU and the memory.8 slides · 13 exercisesGo to the exercises
Send a signal, run in the background
- 42Send a signal and stop it (`kill`)kill is not a tool for killing but for sending a signal. TERM the request, and KILL the last resort.8 slides · 13 exercisesGo to the exercises
- 43Run it in the background (`&` and `jobs`)The way out when nothing comes back. Send it behind you, and call it back.8 slides · 13 exercisesGo to the exercises
- 44Give up your place in the queue (`nice`)Let work that is in no hurry stand back, so what you want now feels lighter.7 slides · 13 exercisesGo to the exercises
The map from the root, and links
- 45The map from the root (below `/`)Roughly the same layout on every server. Remember them by their job and you will not get lost.8 slides · 13 exercisesGo to the exercises
- 46Make a shortcut (`ln -s`)A note saying "look over there". Lose what it points at and it is lost.7 slides · 13 exercisesGo to the exercises
- 47A second name on the same contents (`ln`)A name and its contents are separate things. Remove the name and the contents are still there.8 slides · 13 exercisesGo to the exercises
Pack, compress, measure
- 48Free space and usage (`df` and `du`)Measure it before it fills up. Find out what is eating it.8 slides · 13 exercisesGo to the exercises
- 49Pack it all into one (`tar`)Turn many files into one box. Carry the shape of the tree with them.6 slides · 13 exercisesGo to the exercises
- 50Shrink it (`gzip`)Say the same contents in less space. Learn what
.tar.gzreally is.6 slides · 13 exercisesGo to the exercises - 51Now, in the shape of a file (`/proc`)Read files that are not on the disk. Ask the kernel directly.6 slides · 13 exercisesGo to the exercises
Variables and PATH
- 52Containers for values (variables)Make the shell remember things. Passing them to a child needs
export.6 slides · 13 exercisesGo to the exercises - 53How a command gets found (`PATH`)Why typing
lsrunsls. Building a toolbox of your own.6 slides · 13 exercisesGo to the exercises
Quoting and expansion
- 54Guarding with quotes (`'`, `"` and `\`)Let the shell rewrite it, or hand it over as it is. Handling names with spaces in them.6 slides · 13 exercisesGo to the exercises
- 55The order things expand in (`~`, `$`, `*`)What the shell does, and in what order, between the return key and the command running.7 slides · 13 exercisesGo to the exercises
Make it a tool of your own
- 56Aliases and historyGive a long command a short name, and call back the moves you typed.8 slides · 13 exercisesGo to the exercises
- 57Writing it down in `.profile`Write your own settings in the file that is read every time you open a terminal.8 slides · 13 exercisesGo to the exercises
Scripts and the execute permission
- 58`#!` and the execute markWrite the steps you typed into a file, so you can call them by a name of your own.8 slides · 13 exercisesGo to the exercises
- 59Taking arguments (`$1`)Make the words written after your script usable inside it.8 slides · 13 exercisesGo to the exercises
Branching, loops, exit status
- 60Branching with `if`Look at a condition and change what you do. See that
[is a command and it all joins up.8 slides · 13 exercisesGo to the exercises - 61Repeating with `for`Take things off a row one at a time and do the same to each.8 slides · 13 exercisesGo to the exercises
- 62`while` and `read`Go round while a condition holds. Read lines one at a time, without splitting them.8 slides · 13 exercisesGo to the exercises
- 63Exit statusEvery command hands back a success or failure. Read it, and put one on your own tools.8 slides · 13 exercisesGo to the exercises
- 64Giving names with functionsGive a lump of procedure a name and call it as often as you like. The close of chapter 11.8 slides · 13 exercisesGo to the exercises
Run on a schedule, keep a log
- 65Running at a settled timeBuild something that runs without your typing. You hand over one table of times.8 slides · 13 exercisesGo to the exercises
- 66Keeping a recordMix your own words into the machine's record, in a shape you can read back later.8 slides · 13 exercisesGo to the exercises
Your own address, your own server
- 67Checking your own addressRead your name and number on the network. What you reach, and why you do not.8 slides · 13 exercisesGo to the exercises
- 68Checking whether it reachesSend and see if it comes back. When it does not, read where it stopped.8 slides · 13 exercisesGo to the exercises
- 69Seeing the doors that are openRead the list of doors being waited at. Learn what comes back when you knock on a shut one.8 slides · 13 exercisesGo to the exercises
- 70Standing up a server of your ownRun the one who hands out files, and fetch from it yourself. Read the number and the headings that come back.8 slides · 13 exercisesGo to the exercises
Modes and editing
- 71Modes, and how to get outOpen
viand get out for certain. Move between the mode that types and the mode that commands.8 slides · 13 exercisesGo to the exercises - 72Starting to typeThe six of
iaIAoO. Learn to choose where you begin typing.8 slides · 13 exercisesGo to the exercises - 73Moving where you meant
h j k land0 $ w b,gg Gand line numbers. Carry the cursor in one breath.8 slides · 13 exercisesGo to the exercises - 74Removing, and mending
xdwddDrcw, and the shape with a number. Undo withu, repeat with..8 slides · 13 exercisesGo to the exercises - 75Copying, and pastingCopy with
yyand paste withp. Put withddto move lines about.8 slides · 13 exercisesGo to the exercises - 76Searching, and replacingFind by contents with
/and jump. Replace them all with:%s.8 slides · 13 exercisesGo to the exercises
A final challenge
- 77A test of skillPut thirteen chapters of tools together with no instructions. No new commands appear.8 slides · 10 exercisesGo to the exercises