Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

ToolPurpose
catConcatenate and display file contents
lessScroll through large files page by page
moreBasic page-by-page file viewing
headShow the first lines of a file
tailShow the last lines of a file (great for logs)
diffShow differences between two files
cmpCompare two files byte by byte
duEstimate file and directory space usage
dfReport filesystem disk space usage
rsyncSync/copy files efficiently, locally or remote
ddConvert and copy raw data (devices, images)
scpCopy 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”.