The cat command
concatenate files and print on the standard output 33 examples from the lessons of the IVski Linux Playground — try them in the terminal next to them.
Options in the examples
-n, --number- number all output lines
Examples
cat README.txt
cat documents/hello.txt
cat file1.txt file2.txt
cat > newfile.txt
cat >> existing.txt
cat -n myfile.txt
cat file.txt | wc -wCount words via pipe
cat /etc/sudoersSudo configuration (use visudo to edit!)
cat /etc/passwd | grep '/bin/bash'Find bash users
cat /etc/passwd | cut -d: -f1 | sort | head -10
cat access.log | awk '{print $1}' | sort | uniq -c | sort -rn
cat file.txt | tr -s ' 'Squeeze multiple spaces
cat /etc/passwd
cat /etc/group
cat /etc/hosts
cat /proc/meminfoDetailed memory info
cat ~/.bash_history
cat urls.txt | xargs -P 4 wgetDownload 4 at a time
cat names.txt | xargs -I{} echo "Hello, {}!"
cat /etc/apt/sources.listWhere packages come from
cat /etc/nginx/sites-available/default
cat /etc/nginx/nginx.conf
cat /etc/passwd | grep -E '/bin/(bash|sh)$'Users with shell access
cat /etc/passwd | grep ana
cat /home/ana/.ssh/id_ed25519.pub
cat /etc/resolv.confWhich DNS server does the system ask?
cat ~/RESTORE-NOTES.txtWhat was done during the restore?
cat ~/.ssh/configHow is web01 configured?
cat ~/handover.txtWhat did Marko change?
cat -n /etc/nginx/conf.d/shop.confLook at the file with line numbers
cat ~/ticket-4521.txtWhat does the user see?
cat ~/note-from-ana.txtWhat happened?
cat /etc/nginx/sites-available/shopWhere does nginx send /api/?
Lessons that use cat
- cat — Viewing File Contents
- wc — Counting Words and Lines
- sudo — Superuser Powers
- Pipes & Redirection
- sort & uniq — Sorting and Deduplication
- cut & tr — Extracting Columns
- whoami, id & User Info
- Network Basics
- free — Memory Usage
- Command History
- xargs — Build Command Lines
- apt — Package Manager Basics
- Serving Your Own Pages
- Configuration & Server Blocks
- Mission: Security Sweep
- Mission: New Hire Setup
- Mission: The Internet Is Down?
- Mission: Locked Out of the Server
- Mission: One Missing Character
- Mission: Locked Out After the Holiday
- Mission: Deleted, But Still Full
- Mission: 502 Bad Gateway