Friday, 13 July 2012

BASH SHELL COMMAND SHORTCUTS

The default command terminal or shell (command line) in most Linux distros is BASH (Bourne Again SHell). In Bash, remember that it is simple to correct an error in typing a command using “CTRL-u”. Performing this action will abandon the entire line resulting in the removal of any input from the buffer (and hence evidence such as the BASH history file). Unlike Windows, Linux operating systems are case-sensitive. In Linux it matters what the case you use.

Linux allows commands to be put into “sleep”, killed, sent into the background, and many more options. Some of these are discussed in table 1. This includes a list of keys that can be used in a shell and are listed with their effect.

In addition, there are a number of other simple techniques for controlling execution in a Linux terminal shell. These include sending output to the foreground (fg), background (bg or &), redirecting it (> or >>) or piping it to another command (|).

Key Sequence

Result

CTRL-j

Line feed. “CTRL-J reset CTRL-J” can act as a reset command on some systems.

CTRL-u

Remove the current line from the command buffer (and do not log it).

CTRL-s

Stop (and restart) a process. This sequence may suspend a command (i.e. pause it). CTRL-s stops the system from sending any further data to the screen until a CTRL-q is pressed.

CTRL-s

CTRL-s and CTRL-q control the flow of output to the terminal. CTRL-q resumes a terminal following the CTRL-s key.

CTRL-z

Use CTRL-Z to stop a job. The command “bg” (background) can be used to put the program into the background (type "bg" on the command line).

CTRL-c

Interrupt a program. This is used to “break” a program execution. This signal allows the program to clean up before exiting.

CTRL-d

This is an end-of-input response. Some commands (such as mail) require this. Use with caution as this may log you out of some shells.

CTRL-\

Kills a program (without cleaning up).

CTRL-L

Clears the screen. This is the same as the command "clear".

CTRL-C

Abandon the current command line and return to the prompt.

TAB

TAB is used to auto-complete the names of directories and files. Hit Tab for the shell to expand a name of a file such that the system expands it to a unique name that matches what you've typed so far. If there are multiple items that match what you've typed (i.e., there is nothing unique yet), you can hit Tab again to show the names of all files or directories in your current working directory that match what you've typed so far.

CTRL-R

This is a history search on recent commands

HOME / END

Use the "HOME" key to go to the start of a command line and the "END" key to jump to the end.

Table 1 BASH shortcuts

No comments: