Windows
Linux
File Management
File System
Windows copy con equivalent in Linux
Lets you type content directly into a new file from the terminal, without opening an editor.
Windows
→
copy con
Linux equivalents
cat > filename
cat > filename
cat > filename
Overview
What this command does
Lets you type content directly into a new file from the terminal, without opening an editor.
Migration tip: After
cat > file, type your content and press Ctrl+D on a new line to save. For multi-line files in scripts, use a heredoc (<< 'EOF') instead.Practical tasks
Common use cases
Create a file from keyboard input
Lets you type content directly into a new file from the terminal, without opening an editor.
cat > file.txt
Type content, Ctrl+D to save
cat >> file.txt
Append to existing file
echo 'text' > file
One-liner: write single line
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
cat > newfile.txt
echo 'Hello World' > newfile.txt
cat > config.txt << 'EOF'
Walkthrough
Examples with explanations
# Windows: copy con newfile.txt
cat > newfile.txt
# type content, then Ctrl+D to save
# Easier for single lines:
echo 'Hello World' > newfile.txt
# Multi-line using heredoc:
cat > config.txt << 'EOF'
host=localhost
port=8080
EOF
Reference
Common options and variations
| Command or option | Use |
|---|---|
cat > file.txt | Type content, Ctrl+D to save |
cat >> file.txt | Append to existing file |
echo 'text' > file | One-liner: write single line |
echo 'text' >> file | One-liner: append single line |
printf 'line1\nline2\n' > file | Multi-line one-liner |
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 > filename |
Same command on this distribution. |
| Fedora | same command | cat > filename |
Same command on this distribution. |
| Arch | same command | cat > filename |
Same command on this distribution. |
Keep learning