View File Contents 1.cat command
Function: View the contents of a file
Syntax: Cat file name
2. More Commands
Role: View the contents of a file by paging
Syntax: more file names
Example: MORE/ETC/PASSWD
Press ENTER to refresh a row, press the space to refresh one screen
Exit: Press Q Health
3.less command
Role: View the contents of a file by paging
Syntax: less file name
Example: LESS/ETC/PASSWD
Use the cursor keys to page UP
Exit: Press Q Health
Summary:
The difference between more and less in Linux
MORE: Does not support back, but almost no need to add parameters, the space bar is the page down, the ENTER key is down the line, in the case of no need to back the situation is convenient.
Less: Supports rollover, either up (PageUp button) or down (pagedown button). , the SPACEBAR is a page down, and the ENTER key is a downward-turning line
4. Head command
Function: View the first few lines of the file
Syntax: Head-n file name (n is a specific number that represents the first n rows)
Example: View/etc/passwd Top 3 lines of content
[Email protected] ~]# head-3/etc/passwd
Root:x:0:0:root:/root:/bin/bash
Bin:x:1:1:bin:/bin:/sbin/nologin
Daemon:x:2:2:daemon:/sbin:/sbin/nologin
5.tail command
Function: View the contents of the file after several lines
Syntax: Tail-n file name (n is a specific number that represents the reciprocal n line)
Description: Starting from the following line, viewing the file, showing the last 10 rows by default
Parameter-n shows how many rows
Example: Add an Nginx user, the/etc/passwd file will be appended to the Nginx user-related information, can be displayed with the tail command
[Email protected] ~]# Useradd nginx
[Email protected] ~]# tail-1/etc/passwd
Nginx:x:1002:1002::/home/nginx:/bin/bash
[Email protected] ~]#
-F Dynamic Display data (not closed) often used to view logs
Linux Cloud Computing Cluster Architecture Learning notes: 1-3 viewing file contents