Windows
Linux
File Management
File System
Windows type equivalent in Linux
Shows the contents of a text file in the terminal. Also used to combine files.
Windows
→
type
Linux equivalents
cat
cat
cat
Overview
What this command does
Shows the contents of a text file in the terminal. Also used to combine files.
Migration tip:
cat stands for concatenate. You can use it to join multiple files together with cat file1 file2 > combined.txt.Practical tasks
Common use cases
Display file contents
Shows the contents of a text file in the terminal. Also used to combine files.
cat -n
Show line numbers
cat -A
Show special characters (tabs, line endings)
less file
Scroll through large files (better than cat)
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
cat file.txt
cat -n file.txt
less bigfile.txt
head -n 10 file.txt
tail -f /var/log/syslog
Walkthrough
Examples with explanations
# Windows: type file.txt
cat file.txt # display file
cat -n file.txt # display with line numbers
# For large files, use 'less' instead:
less bigfile.txt # scroll with arrows, q to quit
head -n 10 file.txt # first 10 lines
tail -f /var/log/syslog # watch a log file in real-time
Reference
Common options and variations
| Command or option | Use |
|---|---|
cat -n | Show line numbers |
cat -A | Show special characters (tabs, line endings) |
less file | Scroll through large files (better than cat) |
head -n 20 | Show first 20 lines only |
tail -n 20 | Show last 20 lines only |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.
| Distribution | Package manager / base | Equivalent command | Difference to notice |
|---|---|---|---|
| Debian/Ubuntu | same command | cat |
Same command on this distribution. |
| Fedora | same command | cat |
Same command on this distribution. |
| Arch | same command | cat |
Same command on this distribution. |
Keep learning