File Operations
Navigation tells you where files are; file operations let you look at, compare, measure, and move them. These commands are part of every Linux system and show up constantly in day-to-day work — checking a log, spotting differences between two configs, seeing what is filling up your disk, or copying data safely between machines.
What File Operations Cover
The commands in this section fall into four groups:
- Viewing — read files and their contents without a full editor (
cat,less,more,head,tail) - Comparison — find out whether two files differ and where (
diff,cmp) - Disk usage — see how much space things take and what is free (
du,df) - Transfer & copying — move files around, locally or across networks (
rsync,dd, plus SCP via Server Tools)
Common File Operation Tools
| Tool | Purpose |
|---|---|
cat | Concatenate and display file contents |
less | Scroll through large files page by page |
more | Basic page-by-page file viewing |
head | Show the first lines of a file |
tail | Show the last lines of a file (great for logs) |
diff | Show differences between two files |
cmp | Compare two files byte by byte |
du | Estimate file and directory space usage |
df | Report filesystem disk space usage |
rsync | Sync/copy files efficiently, locally or remote |
dd | Convert and copy raw data (devices, images) |
scp | Copy files over SSH (see Server Tools) |
These tools compose nicely with the pipes and redirection covered later in the book — for example tail -f access.log | grep ERROR — so it pays to learn them together with CLI Navigation.
Why This Matters
Knowing these commands helps you:
- Read and debug log files without leaving the terminal
- Spot configuration drift by comparing files quickly
- Avoid “disk full” surprises before they take a server down
- Back up and sync data safely, including over the network
- Work confidently on remote servers where there is no GUI
Mastering file operations is what turns “I can change directories” into “I can actually get work done on a Linux system”.