How to use the SSH cat command

The SSH cat (concatenate) command displays file contents in your terminal and can also create small files. In particular, it’s useful for quickly viewing configuration files, logs, or text files without opening an editor. Furthermore, you can combine multiple files, add line numbers, or create new files by redirecting output.

Viewing file contents

To display the contents of a file:

cat myfile.txt

For example, to check your WordPress configuration:

cat wp-config.php

For large files, cat scrolls everything at once. Consider using head or tail to view only the beginning or end, see our guide on head and tail commands.

Viewing multiple files

SSH cat command concatenates files in order and displays them together:

cat file1.txt file2.txt

Useful when you need to compare or merge the output of several files.

Creating a new file

To create a file by typing content directly:

cat > newfile.txt

Type your content, then press Ctrl+D to save and exit. This overwrites the file if it already exists. To append instead of overwrite, use cat >> newfile.txt.

Useful options

Show line numbers:

cat -n myfile.txt

Show line endings (useful for debugging):

cat -e myfile.txt

Displays $ at the end of each line so you can spot hidden characters or Windows-style line endings.

Show tabs as ^I:

cat -T myfile.txt

Makes tab characters visible, helpful when checking indentation or formatting.

When you need to edit files rather than just view them, use nano or vi instead of cat >. These editors give you more control and let you navigate, search, and correct mistakes before saving. Additionally, for copying file contents into another file or command, you can pipe cat output, for example, cat file.txt | grep "search".

Common use cases

Typical uses for SSH cat command on a Linux hosting account:

  • Quickly viewing wp-config.php or .htaccess
  • Checking error logs or access logs
  • Inspecting small config or text files
  • Creating simple files like .htaccess rules or test files

For listing files in a directory first, see the SSH ls command. For finding files by name, see find and locate.

Need more help?

Explore more SSH and Linux hosting guides in our knowledgebase. JetHost web hosting includes SSH access for managing your server files directly.