Linux & shell: View & compare files
9 Linux & shell commands: View & compare files. Click a command to see what each part does.
Linux & shell: View & compare filesIndex
- Whole sheet251
- Navigate & list13
- Create, copy, move, delete13
- View & compare files9
- Permissions & ownership31
- Help & shell basics11
- Users & groups6
- Install packages7
- Package & software versions29
- System info9
- Network basics & SSH10
- Zip & compress4
- Shell operators6
- Processes6
- Files & search8
- Text processing pipelines4
- Disk3
- Network5
- Services & logs6
- Archives & copying4
- Firewall7
- Scheduling: cron & systemd timers6
- Storage, mounts & LVM10
- Kernel, hardware & limits8
- Performance & tracing10
- TLS & certificates8
- Packet capture & network debugging10
- Terminal tools8
View & compare files9
cat <file>Print a fileWhat each part does
catconcatenate: print one or more files to the screen
cat -n <file>Print with line numbersWhat each part does
-n--number: number every output line
less <file>Read a long file page by pageWhat each part does
lessscroll a file: Space/b = page down/up, /text = search, n = next match, G = end, q = quit
head -n 20 <file>First lines of a fileWhat each part does
headstart of a file-n 20how many lines (default 10)
tail -n 50 <file>Last lines of a fileWhat each part does
tailend of a file-n 50how many lines (default 10); add -f to keep following
wc -l <file>Count lines, words, bytesWhat each part does
wcword count-lcount lines only (-w words, -c bytes)
diff -u <old-file> <new-file>Compare two filesWhat each part does
diffshow differences (exit 0 = same, 1 = different)-uunified format: - removed lines, + added lines, 3 lines of context
file <file>What kind of file is this?What each part does
filedetect the type: text, ELF binary, gzip, JSON…
stat <file>Size, permissions and timestamps of a fileWhat each part does
statdetailed metadata: size, inode, permissions, access/modify/change times
Nothing matches.
My DevOps Playbook by Angelo John Calleja