Home > Article > Operation and Maintenance > What are the commands to open files in Linux?
The commands to open a file in Linux are: 1. cat command, used to view the file content; 2. tac command, displayed from the last line; 3. nl command, output the line number when displayed; 4. The more command is used to display file contents page by page, etc.
Recommended: "linux course"
Open the terminal program and directly use the cat command to view the contents of the file sample. Just type cat sample.txt at the prompt and press Enter. The function of the cat command is to display the entire file content starting from the first line.
In Linux systems, there are many commands to view the contents of text files, such as cat/tac/nl/more/less/head/tail and other commands. In addition to the functions of other cat commands mentioned above:
1, tac: start displaying from the last line, you can see that tac is in the opposite alphabetical order of cat;
2, nl: output the line number when displaying ;
3, more: display the file content page by page;
4, less is similar to more, but it can turn pages forward;
5, head : Read only the first few lines;
6, tail: Read only the last few lines;
7, od: Read the file in binary mode.
The above is the detailed content of What are the commands to open files in Linux?. For more information, please follow other related articles on the PHP Chinese website!