Running Commands from the Shell
computer software
Running Commands from the Shell Running Commands from the Shell
Running Commands from the Shell   Home | Site Map | About Us | Products | Services | News | Contact Us | Links Running Commands from the Shell
Running Commands from the Shell Running Commands from the Shell

Copyright © 2009

Linux® Bible


TABLE 2-3
Keystrokes for Cutting and Pasting Text in Command Lines
Keystroke
Full Name
Meaning
Ctrl+K
Cut end of line
Cut text to the end of the line.
Ctrl+U
Cut beginning of line
Cut text to the beginning of the line.
Ctrl+W
Cut previous word
Cut the word located behind the cursor.
Alt+D
Cut next word
Cut the word following the cursor.
Ctrl+Y
Paste recent text
Paste most recently cut text.
Alt+Y
Paste earlier text
Rotate back to previously cut text and paste it.
Ctrl+C
Delete whole line
Delete the entire line.
Command-Line Completion
To save you a few keystrokes, the bash shell offers several different ways of completing partially
typed values. To attempt to complete a value, type the first few characters, and then press Tab.
Here are some of the values you can type partially:
Environment variable -- If the text you type begins with a dollar sign (
$
), the shell
completes the text with an environment variable from the current shell.
Username -- If the text you type begins with a tilde (
~
), the shell completes the text with
a username.
Command, alias, or function -- If the text you type begins with regular characters, the
shell tries to complete the text with a command, alias, or function name.
Hostname -- If the text you type begins with an at (
@
) sign, the shell completes the text
with a hostname taken from the
/etc/hosts
file.
To add hostnames from an additional file, you can set the HOSTFILE variable to the
name of that file. The file must be in the same format as
/etc/hosts.
Here are a few examples of command completion. (When you see <Tab>, it means to press the Tab
key on your keyboard.) Type the following:
$ echo $OS<Tab>
$ cd ~ro<Tab>
$ fing<Tab>
The first example causes
$OS
to expand to the
$OSTYPE
variable. In the next example,
~ro
expands to the root user's home directory (
~root/
). Next,
fing
expands to the
finger
command.
Of course, there will be times when there are several possible completions for the string of charac-
ters you have entered. In that case, you can check the possible ways text can be expanded by
TIP
TIP
51
Running Commands from the Shell
2