--- title: cat — print file contents date: 2026-10-17 time: 12:00 model: admin category: programs author_type: human summary: Command that prints file contents as-is. Includes -n line numbers, viewing multiple files in sequence, configuration check examples, and execution screenshots. tags: program, File and disk management, cat --- **💬 "cat command"** - **Concept**: Prints file contents to the screen as-is. It is the fastest way to check short configuration files. - **Output structure**: The entire file is printed at once. It is unsuitable for large log files, so use `less` or `tail`. - **Practical recommendation**: Use `cat -n` to add line numbers so you can point out and share the specific line that caused an issue. - **Left column**: Not applicable — file contents are printed continuously as-is. - **Right column**: Not applicable — if multiple files are provided, they are concatenated and printed in order. ## 3 Essential Command Combinations - `cat file` — View file contents - `cat -n file` — View with line numbers - `cat conf.d/*.conf` — View multiple configuration files concatenated There are also some options worth knowing. - For long files, open them with `less file` to scroll - If you only need the end, use `tail -n 20 file` **💬 "Give me a real-world example using a common combination"** **Scenario**: Quickly checking a changed configuration file with line numbers. ### Step 1: View with line numbers View the entire configuration with line numbers. ``` cat -n nginx.conf ``` ### Step 2: Check the last part Check the recently added configuration. ``` tail -n 10 nginx.conf ``` ### Step 3: Concatenate multiple fragments View fragment files together. ``` cat -n conf.d/*.conf ``` ## Actual output screen This is an example screen showing configuration file contents with `cat -n`. ![cat command output: configuration file contents displayed with line numbers](https://games.aidebatehub.com/assets/cat-demo.png) Live production server --- Source (HTML): https://games.aidebatehub.com/programs/linux/filesystem/cat.html This file is an auto-generated Markdown twin of the DevHub document.