df
Displays disk space usage across all mounted filesystems.
df -h
The -h flag presents sizes in a human-readable format (KB, MB, GB).
free
Shows total, used, and free memory (RAM) along with swap usage.
free -m
The -m option displays values in megabytes. Swap space acts as virtual memory—when physical RAM is exhausted, the system borrows disk space to prevent crashes.
head
Outputs the first portion of a file. Without specifying a count, it displays the first 10 lines.
head -n /path/to/file.txt
tail
Retrieves the final lines of a file. The default output includes 10 lines when no count is provided.
tail -n /var/log/syslog
To monitor a file's live modifications:
tail -f /var/log/messages
This is commonly used for watching log files update in real time. Changes can come from direct file edits or from other processes writing to the file.
less
Views file contents one screen at a time. Navigation uses these controls:
less /path/to/file
- Arrow keys: move up/down by line
- Space / Page Down: move forward one page
- Page Up / b: move backward one page
- Number + Enter: jump to specific line
wc
Counts lines, words, and bytes within a file.
wc -lwc /path/to/document.txt
-l: line count-w: word count (separated by whitespace)-c: byte count
Running without flags reports all three statistics by default.
date
Reads or sets the system date and time.
Basic output:
date
Formatting options:
date +%F
date "+%Y-%m-%d"
Both commands return the current date in YYYY-MM-DD format.
Timestamp with time:
date "+%F %T"
date "+%Y-%m-%d %H:%M:%S"
Quoting ensures the format string stays intact. Useful for generating log filenames with embedded timestamps.
Calculating relative dates for backup rotation:
date -d "-7 day" "+%Y-%m-%d"
date -d "+1 month" "+%Y-%m-%d %H:%M:%S"
The -d flag accepts relative time specifications. Use + for future dates or - for past dates. Supported units include day, month, and year.
Format specifiers available:
| Specifier | Meaning |
|---|---|
%F |
Full date (YYYY-MM-DD) |
%T |
Time (HH:MM:SS) |
%Y |
Four-digit year |
%m |
Month (zero-padded) |
%d |
Day (zero-padded) |
%H |
Hour (24-hour, zero-padded) |
%M |
Minute (zero-padded) |
%S |
Second (zero-padded) |
cal
Displays calendars in the terminal.
cal
Defaults to the current month.
Three-month view:
cal -3
Shows the previous month, current month, and next month.
Specific year:
cal -y 2025
Renders the entire year's calendar.
clear
Wipes the terminal screen for a clean workspace.
clear
Or press Ctrl + L. Note that previous output remains accessible by scrolling up—clear only shifts the viewport.
Pipelines
The pipe symbol | chains commands together, passing one command's output as input to the next.
Filtering:
ls / | grep "bin"
Lists root directory contants, then filters for entries containing "bin".
Pagination:
cat /var/log/system.log | less
Combines file display with scrollable navigation.
Aggregation:
ls /etc | wc -l
Counts how many items exist in the /etc directory. The wc command receives file listing as input and tallies the lines.
Pipes enable composing simple utilities into powerful one-liners. Each segment performs a specific transformasion, and results flow left to right through the chain.