Shared server guidance · Question & answer

How do I read a large server file without opening it in an editor?

Use a pager such as less for interactive reading, or head and tail for bounded excerpts. This is useful for large logs and reports because it avoids sending the entire file to the terminal. Reading a file still requires the appropriate access permissions.

BeginnerLinux VPS and dedicated servers with GNU utilities
Go to the answer

Before you start

  • An authorised SSH session on the Linux server.

Instructions

1. Open a read-only view

Replace the example with the exact text file you are authorised to read. In less, use the arrow keys or Space to move, / to search, and q to quit.

Remote Linux shell
less -N -- "$HOME/server-notes/report.txt"

-N displays line numbers. Avoid sharing a full report if it contains account details, tokens or personal information.

2. Read only a bounded excerpt

Use the beginning for headers or format checks and the end for recent appended content. The line count is explicit so output remains manageable.

Remote Linux shell
head -n 20 -- "$HOME/server-notes/report.txt"
tail -n 50 -- "$HOME/server-notes/report.txt"

These commands print the first 20 or last 50 lines; neither edits the source file.

Check the result

  • The excerpt shows the expected file and relevant time range. Exit the pager normally and confirm you are back at the shell prompt.

Troubleshooting

The output is unreadable
The file may be binary or compressed. Identify its format before choosing a format-specific reader.
less is unavailable
Use bounded head or tail output, or install the approved pager through the distribution package manager.

Official references

Use the documentation for your installed version when a flag, service name or platform feature differs.