Learning Material

The Linux Command Line: A Practical Guide

Learning Material · Systems

Cover: The Linux Command Line: A Practical Guide

Navigating the filesystem

pwd              # print current directory
ls -la           # list all files, including hidden, with details
cd /var/log      # change directory
find . -name "*.log"  # search for files by name, recursively

These four cover the overwhelming majority of everyday navigation — everything else is a variation with extra flags.

Reading and searching text

cat file.txt          # print entire file
less file.txt         # page through a large file
grep "ERROR" app.log  # find lines matching a pattern
grep -r "TODO" src/   # search recursively through a directory

grep is one of the highest-value commands to actually know well — searching logs or source code for a pattern is a constant task, and grep handles it faster than opening files one by one in an editor.

The pipe: chaining commands together

ps aux | grep node | wc -l

The pipe (|) sends one command's output directly into the next command's input. This example: list all running processes, filter to lines containing "node," then count how many lines remain — three simple tools combined into one useful answer, without any of them being specially designed to work together.

File permissions, decoded

-rwxr-xr--  1 alice staff  1024 Jan 5 10:00 script.sh

Reading left to right after the file type character: owner permissions (rwx — read, write, execute), group permissions (r-x), everyone else (r--). chmod 754 script.sh sets exactly this — each digit is the sum of read (4), write (2), and execute (1) for owner, group, and others respectively.

Process management

ps aux           # list running processes
top              # live view of resource usage
kill -9 1234     # forcibly terminate process ID 1234
nohup ./script.sh &  # run a command that keeps running after you log out

kill -9 should be a last resort — it terminates a process immediately with no chance to clean up open files or connections. A plain kill (signal 15) asks the process to shut down gracefully first.

Tab completion and command history are not optional shortcuts. Tab-completing paths and commands, and pressing the up arrow (or Ctrl+R to search history) instead of retyping, is the difference between the terminal feeling slow and feeling instant — most terminal fluency is really just muscle memory for these two habits.

Redirecting output

echo "log entry" >> app.log   # append to a file
command 2> errors.log          # redirect only error output
command > /dev/null 2>&1       # discard all output entirely

A single > overwrites a file; >> appends. 2> specifically redirects stderr (error output), separate from stdout — useful when you want to log errors without cluttering normal output, or vice versa.

Comments