Knowing the Important Key Sequences

Sometimes you will enter a command from the Bash command line and nothing will happen or something totally unexpected will happen. If that happens, it is good to know that some key sequences are available to perform basic Bash management tasks. The following is a short list of the most useful key sequences:

Ctrl+C: Use this key sequence to quit a command that is not responding (or simply takes too long to complete). This key sequence works in most scenarios where the command is operational and producing output to the screen.

Ctrl+D: This key sequence is used to send the end-of-file (EOF) signal to a command. Use this when the command is waiting for more input. It will indicate this by displaying the secondary prompt, >.

Ctrl+R: This is the reversed search feature. When used, it will open the "reversed I-search" prompt. This prompt helps you locate commands you have used previously. The feature is especially useful when working with longer commands. Type the first characters of the command, and you will see immediately the last command you used that started with the same characters.

Ctrl+Z: Some people use Ctrl+Z to stop a command. In fact, it does stop your command, but it does not terminate it. A command that is interrupted with Ctrl+Z is just momentarily halted and can be restarted using the fg command. You can continue running the command in the background by issuing the bg command with the job number as the parameter. Use the jobs command to find the command's job number in your shell environment.

Was this article helpful?

0 0

Post a comment