Linux command line essentials.
The shell is just a program that runs other programs. Watch commands run live in a simulated terminal โ six steps from 'what's that $ symbol?' to chaining commands with pipes.
Linux command line essentials animated tutorial. Shell, navigation, file operations, viewing files, redirection, and pipes. Covers RHCSA EX200 exam objectives for shell basics.A few commands and a few symbols get you 90% of what you'll need at the Linux shell every day. Watch the terminal below as you step through.
- ยทRoughly what a 'file' and a 'directory' (folder) are
- ยทKnowing how to open a terminal app on your computer
- ยทNothing else โ this is the on-ramp
Move around the filesystem, create/copy/delete files, read files, send command output to files, and chain commands with pipes.
pace: 10 minutes
echo HellowhoamidateThe shell and the prompt
When you open a terminal you're running a 'shell' โ a small program whose only job is to take a line of text from you, find the command you named, and run it. On Linux that shell is usually Bash. The $ symbol (called the prompt) means 'I'm ready for your next command'. Try typing the command name, optional flags starting with -, and arguments โ all separated by spaces.
The Unix philosophy: do one thing well, and connect with pipes. Every command you learn is a building block. grep alone is useful; cat | grep | sort | uniq -c | head is engineering. Build the habit of asking "is there a command that does just this one step?"
$pwd$ls / ls -la$cd DIR / cd ..$cd ~ / cd -$touch FILE$mkdir -p PATH$cp SRC DST$cp -r DIR DST$mv SRC DST$rm FILE / rm -rf DIR$cat FILE$less FILE$head -N / tail -N$tail -f FILE$grep PATTERN FILE$wc -l$sort / sort -n$uniq -c$find PATH -name PAT$history$man CMD$CMD --help$which CMD$Ctrl-C$Ctrl-R, then typeYou want to change to your home directory and see what's there. Which two commands?
You want to save the output of `ls /etc` into a file called list.txt โ replacing whatever's already in list.txt. Which symbol?
Why does rm -rf / on Linux destroy almost everything?
What does the pipe character | do?
These aren't graded โ they're just for active recall, which is what actually makes the lesson stick.
Try the Bash Command Challenge
Reading is one thing โ typing the command yourself is what makes it stick. 37 challenges across Easy, Medium, and Hard. Free play, no timer required.
Read this lesson as text6 chapters ยท quiz answers
01The shell and the prompt
When you open a terminal you're running a 'shell' โ a small program whose only job is to take a line of text from you, find the command you named, and run it. On Linux that shell is usually Bash. The $ symbol (called the prompt) means 'I'm ready for your next command'. Try typing the command name, optional flags starting with -, and arguments โ all separated by spaces.
02Where am I, what's here, where can I go
Three navigation commands cover 90% of moving around. pwd prints your current directory. ls lists what's in the current directory. cd changes to another directory โ give it an absolute path (starting with /) or a relative one (relative to where you are now).
03Making and moving things
Create empty files with touch. Create directories with mkdir. Copy with cp, rename or move with mv, delete with rm. rm is permanent โ there's no recycle bin. Use -r to recurse into directories. Use -i to make rm ask before each delete (a good habit for new users).
04Reading files
Four commands for looking at file contents. cat prints the whole file (fine for short ones). less is a pager โ for long files, press space to advance, q to quit, / to search. head shows just the first lines (default 10). tail shows the last. tail -f follows the file as it grows โ perfect for live log viewing.
05Redirecting output
By default a command prints to your screen (technically 'standard output'). Use > to redirect into a file (overwriting it). >> appends to a file instead. 2> redirects errors separately. 2>&1 redirects errors into the same place as normal output. < feeds a file in as the command's input. Combining these is a superpower.
06Pipes โ connect commands
The pipe | takes the output of one command and feeds it as the input of the next. This is the heart of Unix: many small tools that each do one thing, chained together. Most pipelines you'll write look like 'produce some text โ filter or transform it โ present it'.
Quiz โ answers
- You want to change to your home directory and see what's there. Which two commands?
- โcd ~ && lscd ~ goes to your home directory (~ is shorthand). Then ls lists it. cd alone (no argument) also works.
- You want to save the output of
ls /etcinto a file called list.txt โ replacing whatever's already in list.txt. Which symbol? - โls /etc > list.txt> overwrites the target file with the command's output. >> appends instead. | feeds output to another command, not a file.
- Why does rm -rf / on Linux destroy almost everything?
- โ-r recurses into directories, -f forces no-confirm, and / is the root of the filesystem โ so it walks the whole tree and deletesThere's no recycle bin and no confirmation. This is the classic Linux foot-gun. Modern rm versions refuse / by default but the principle stands โ be careful.
- What does the pipe character | do?
- โTakes one command's standard output and feeds it as another command's standard inputPipes connect tools end-to-end. It's how the Unix 'small tools' philosophy becomes a productivity multiplier.
keep going โ these pair well with what you just learned.
SELinux contexts
Why Apache can't read your file. Watch the policy engine decide โ and learn the workflow for fixing denials. RHCSA-ready.
Linux boot process
From power button to login prompt. Every stage in the chain โ UEFI, GRUB, kernel, initramfs, systemd โ with the rescue moves that save you. RHCSA-ready.
LVM stacking
Layer-by-layer build of an LVM stack: disks โ PVs โ VG โ LVs โ filesystem. Then extend live and snapshot. RHCSA-ready.