The most important platform for development and system management in Linux/Unix is the shell environment. Shell has many very useful shortcut keys. Mastering these shortcut keys will greatly improve your work efficiency.
AD:
[51CTO technical materials] recently, I found that many colleagues, especially our PHP developers, basically do not use shortcuts in Linux/unix, seriously affecting work efficiency, therefore, this article is specially written. I will comment it out in detail after each usage.
All of the following commands are valid in Linux/unix shell. bash is the main command here. In case of any discrepancy, your own server shall prevail. Linux mentioned in this article mainly refers to RHEL/CentOS, and unix refers to FreeBSD, which is also the most used version on the server.
Ctrl + a switch to the command line
This operation has the same result as Home, but Home cannot be used in some unix environments, so this combination can be used. vim in Linux is also effective. In addition, this is also effective in many file editors in windows.
Ctrl + e switch to the end of the command line
The result of this operation is the same as that of END, but the End key cannot be used in some unix environments. vim in Linux is also valid. In addition, this is also effective in many file editors in windows.
Ctrl + l clear screen content, equivalent to clear
Ctrl + u clear the content before cutting the cursor
This command is useful in nslookup. I sometimes see my colleague deleting shell commands with one word at a time, which is very bad! In fact, it can be done with a Ctrl + u.
Ctrl + k cut the content after clearing the cursor
Ctrl + y paste the deleted character
This command is powerful. The characters to be deleted may be strings, but it is very likely to be a line of command.
Ctrl + r search in History commands(This is very easy to use. Input keywords to call up previous commands)
I strongly recommend this command. Sometimes there are too many history commands to find a complicated one. Here, shell will automatically find and call the command, which is very convenient.
Ctrl + c terminate command
Ctrl + d Exit shell, logout
Ctrl + z transferred to the background for running
However, the process transferred from Ctrl + z to the backend will be terminated after the current user exits. Therefore, it is better to use the nohup command &, the role of the nohup command is that the process continues to run after the user exits, and many scripts and commands require that the process remain valid when the root user exits.
I am not familiar with the following operations:
!!Repeat the last command
HistoryDisplays the numbers and History commands you have executed. This can be used together! Edit to execute XX command
Values (Ctrl + p)Display the previous command
Values (Ctrl + n)Display the next command
! $Displays the latest system parameter.
Finally, this is useful. For example, I first use cat
/Etc/sysconfig/network-scripts/ifconfig-eth0, then I want to edit it with vim. The general approach is to first use callback
Display the last command, use Home to move to the beginning of the command, delete cat, and then enter the vim command. In fact, we can use vim! $.
After the development and administrator master the above usage, the work will be very efficient. At the end of the use, you will inadvertently find that you can easily handle a lot of complicated commands between fingers.
Author: Andrew Yu is an experienced Linux/unix system engineer and project implementation engineer in a foreign company.