Bash keyboard shortcuts | Linux

Linux

Cursor Movement

Key                 Action

CTRL-A                Move cursor to the beginning of the line.

CTRL-E                Move cursor to the end of the line.

CTRL-F                 Move cursor forward  one character; same  as the right arrow  key.

CTRL-B             Move cursor backward one character; same  as the left arrow  key.

ALT-F                  Move cursor forward  one word.

ALT-B                   Move cursor backward one word.

CTRL-L                  Clear  the screen  and move the cursor to the top left corner.  The clear command does  the same  thing.

 

 Modifying Text

 Cutting and Pasting (Killing and Yanking) Text

The Readline documentation uses the terms killing and yanking to refer to what we would commonly call cutting  and pasting.

Key                         Action

CTRL-D                       Delete the character at the cursor location.

CTRL-T                         Transpose  (exchange) the character at the cursor location with the one preceding it.

ALT-T                           Transpose  the word at the cursor location  with the one pre ceding  it.

ALT-L                            Convert the characters from the cursor location to the end of the word to lowercase.

ALT-U                         Convert the characters from the cursor location to the end of the word to uppercase.

Cut and  Paste Commands

Key                         Action

CTRL-K                        Kill text from the cursor location to the end of line.

CTRL-U                        Kill text from the cursor location to the beginning of the line.

ALT-D                            Kill text from the cursor location to the end of the current word.

ALT-BACKSPACE                 Kill text from the cursor location to the beginning of the current word.  If the cursor is at the beginning of a word,  kill the previous word.

CTRL-Y                        Yank text from the kill-ring and  insert it at the cursor location.

Completion Commands

ALT-?                       Display list of possible  completions.  On most systems you can also do this by pressing  the TAB key a second  time, which is much easier.

ALT-*                      Insert all possible  completions.  This is useful when you want to use more than one possible  match.

CTRL-R

(reverse-i-search)`’:

The prompt changes  to indicate that we are performing a reverse incre- mental search.  It is “reverse” because  we are searching from “now” to some time in the past. Next, we start typing our search  text, which in this example is /usr/bin:

(reverse-i-search)`/usr/bin':  ls -l /usr/bin > ls-output.txt

 

Immediately, the search  returns its result.  Now we can execute the command by pressing  ENTER, or we can copy the command to our current command line for further editing by pressing  CTRL-J. Let’s copy it. Press CTRL-J:

$  ls -l /usr/bin  > ls-output.txt

Our  shell prompt returns, and our command line is loaded

 

History Commands

Key                   Action

CTRL-P                  Move to the previous history entry. Same  action as the up arrow. CTRL-N       Move to the next history entry. Same  action as the down  arrow. ALT-<    Move to the beginning (top) of the history list.

ALT->                   Move to the end (bottom) of the history list; i.e.,  the current command line.

CTRL-R                 Reverse incremental  search. Searches incrementally from the current command line up the history list.

ALT-P                     Reverse search, non-incremental.  With this key, type the search string and  press ENTER before  the search  is performed.

ALT-N                   Forward  search, non-incremental.

CTRL-O                 Execute the current item in the history list and  advance to the next one.  This is handy if you are  trying to re-execute a sequence of commands in the history list.

History Expansion Commands

Sequence              Action

!!                             Repeat  the last command. It is probably easier  to press the up arrow  and  ENTER.

!number                   Repeat  history list item number.

!string                     Repeat  last history list item starting with string.

!?string                  Repeat  last history list item containing  string.

 

In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.