Common commands in Linux (3): Several commands to view the contents of files, understanding of ctrl+c

1. Instructions for viewing the contents of the file

(1) More command: view the content of the file, in the lower left corner there is the current progress of viewing the content of the file

• more [filename]
• 一直回车,可以向下查看内容
• 在键盘上按下b键可以向前翻页,显示之前一页的内容
• 在键盘上按下f键可以向后翻页,显示后面一页的内容,
如果展示到了文件的结尾,more命令就自动结束

(2) Less command: View the content of the file, and display the file name in the lower left corner

• less [filename]
• 一直回车,可以向下查看内容
• 在键盘上按下b键可以向前翻页,显示之前一页的内容
• 在键盘上按下f键可以向后翻页,显示后面一页的内容

(3) The principle of more and less

The more command and the less command are very useful when viewing large files, such as 100M files, 200M files, 1G files

The more instruction and less instruction use the pre-loading method when viewing the content of the file. First, load part of the content from the disk into the memory. When we are dynamically viewing the content of the file, more or less will dynamically load the memory. Change the content of the idle files in the file, and change some content that we may be about to view

2.head instruction: view the content of the file header

• head [filename] defaults to view the 10 lines of the file header
• head -n [num] [filename] view the num lines of the file header

3.tail instruction: view the contents of the end of the file

• tail [filename] defaults to view the 10 lines at the end of the file.
• tail -f [filename] detects whether there are new changes in filename

4.history: View the commands executed in history

• History
Insert picture description here
quickly executes previously executed commands
1. ![之前执行过的命令的头部]
2. ![之前执行过的命令对应的数字]
3. 常用的一种方式:使用键盘中向上的箭头,查找之前执行的命令,命令操作的时候,还要配备table键来快捷补全命令

5.man command: View command introduction, system functions, library functions, prototypes, and introduction + return value commands

• man 1 [command name] to view commands
• man 2 [system function name] to view the introduction of system functions
• man 3 [library function name] to view the introduction of library functions. The
following figure takes the library function strlen as an example:
Insert picture description here
Insert picture description here
Note: If man finds Not strlen solution: switch to root user,
execute yum -y install man-pages
Insert picture description here

6.ctrl+c: a. Interrupt the current command input b. End the executing foreground process

(1) The command executed under the Linux operating system is essentially an executable program. For the win operating system, it is equivalent to an exe program.
(2) Entering a command in the command line and pressing Enter to execute it is equivalent to executing the current one Executable programs
Some commands (executable programs) will end after execution.
Some commands (executable programs) may fall into a'waiting state' during execution, and you need to manually execute a ctrl+c End executable program (command)

Guess you like

Origin blog.csdn.net/weixin_50886514/article/details/113454923