← All commands
Topic hub File Management
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
Debian/Ubuntu same command
cat > filename
Fedora same command
cat > filename
Arch same command
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 optionUse
cat > file.txtType content, Ctrl+D to save
cat >> file.txtAppend to existing file
echo 'text' > fileOne-liner: write single line
echo 'text' >> fileOne-liner: append single line
printf 'line1\nline2\n' > fileMulti-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.

DistributionPackage manager / baseEquivalent commandDifference 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

Related File Management commands