Keyboard Shortcuts


Your other friend when using BASH is the Ctrl key, although you'll also find the Alt key handy. These keys provide shortcuts to vital command-line shell functions. They also let you work more efficiently when typing by providing what most programs call keyboard shortcuts.

Shortcuts for Working in BASH

Table 18-1 lists the most common keyboard shortcuts in BASH (there are many more; see BASH's man page for details). If you've explored the emacs text editor, you might find these shortcuts familiar. Such keyboard shortcuts are largely the same across many of the software packages that originate from the GNU Project. Often, you'll find an option within many SUSE Linux software packages that lets you use emacs-style navigation, in which case, these keyboard shortcuts will most likely work equally well.

Table 18-1. Keyboard Shortcuts in BASH

Shortcut

Description

Navigation

Left/right cursor key

Move left/right in text

Ctrl+A

Move to beginning of line

Ctrl+E

Move to end of line

Alt+F

Move forward one word[1]

Alt+B

Move back one word[1]

Editing

Ctrl+U

Delete everything behind cursor to start of line

Ctrl+K

Delete from cursor to end of line

Ctrl+W

Delete from cursor to beginning of word

Alt+D

Delete from cursor to end of word

Ctrl+T

Transpose characters on left and right of cursor

Alt+T

Transpose words on left and right of cursor

Miscellaneous

Ctrl+L

Clear screen (everything above current line)

Ctrl+U

Undo everything since last command[2]

Alt+R

Undo changes made to the line[3]

Ctrl+Y

Undo deletion of word or line caused by using Ctrl+K, Ctrl+W, and so on[4]

Alt+L

Lowercase current word (from the cursor to end of word)

[1]This is specific to SUSE Linux. Not all Linux distros let you use these shortcuts.

[2] In most cases, this has the effect of clearing the line.

[3]This is different from Ctrl+U, because it will leave intact any command already on the line, such as one pulled from your command history.

[4]This is different from Ctrl+U, because it will leave intact any command already on the line, such as one pulled from your command history.

Tip 

It might be useful to photocopy Table 18-1 and stick it on the side of your monitor or keyboard as a reference guide.

Shortcuts for System Control

In terms of the control over your system offered by keyboard commands, as mentioned in Chapter 17, pressing Ctrl+Z has the effect of stopping the current program. It suspends the program until you switch back into it or tell it to resume in another way, or manually kill it.

In the same style, pressing Ctrl+C while a program is running will quit it. This sends the program's process a termination signal, a little like killing it using the top program. Ctrl+C can prove handy if you start a program running by accident and quickly want to end it, or if a command takes longer than you expected to work and you cannot wait for it to complete. It's also a handy way of attempting to end crashed programs. Some complicated programs don't take too kindly to being quit in this way, particularly those that need to save data before they terminate. However, most should be okay.

Ctrl+D is another handy keyboard shortcut. This sends the program an end-of-file (EOF) message. In effect, this tells the program that you've finished your input. This can have a variety of effects, depending on the program you're running. For example, pressing it on its own at the shell prompt when no program is running will cause you to log out (if you're using a GUI terminal emulator like Konsole, the program will quit). This happens because pressing Ctrl+D informs the BASH shell program that you've finished your input. BASH then interprets this as the cue that it should log you out. After all, what else can it do if told there will be no more input?

While it might not seem very useful for day-to-day work, Ctrl+D is vital for programs that expect you to enter data at the command line. You might run into these as you explore BASH. If ever you read in a man page that a program requires an EOF message during input, you'll know what to press.




Beginning SUSE Linux from Novice to Professional
Beginning SUSE Linux: From Novice to Professional
ISBN: 1590594584
EAN: 2147483647
Year: 2005
Pages: 293
Authors: Keir Thomas

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net