GNU/Linux Command-Line Tools Summary
Prev
Chapter 4. Shell Tips
Next
4.1. General Shell Tips
- Automatic Command Completion
- ESC -Y (Y: special character)
- CTRL -X -Y (Y: special character)
~ (tilde) complete a user name
@ (at sign) complete a machine name
$ (dollars sign) complete an environment variable name
! (exclamation mark) a magic character for completing a command name or a file name. The ! special character has the same function as the TAB key. It works in some other situations; for example when completing man page names.
- alias
Use the TAB key and bash will attempt to complete the command for you automatically. You can use it to complete command (tool) names. You can also use it when working with the file-system, when changing directories, copying files et cetera.
There are also other lesser known ways to use automatic command completion (for example completing user names):Prev
testing autoindexing Will attempt to complete the command name for you. If it fails it will either list the possible completions (if they exist). If there are none it will simply beep (and/or) flash the screen.
Lists the possible completions (it won't attempt to complete it for you) or beep if there are no possible completions.
Special-characters:
Use the following special characters combined with either ESC -Y or CTRL -X -Y , where Y is some special characters. For example ESC -$ or CTRL -X -$ to complete an environment variable name.
The alias command will list your current aliases. You can use unalias to remove the alias (to disable it just for one command add a “\” (back-slash) before the command)...
An alias allows one command to be substituted for another. This is used to make a command do something else or to automatically add certain options. This can be either be done during one session using the alias command (see below) or the information can be added to the .bashrc file (found in the users home directory).
Below is an example of what an alias section (within your .bashrc file) might look like:
# my personal aliases
alias cp='cp -vi' #to prompt when copying if you want to overwrite and will tell you where information is going
alias rm='rm -i' #Prompts you if you really want to remove it.
alias mv='mv -i' #Prompts you if you are going to overwrite something
On any Mandriva GNU/Linux system the global aliases (for all users) are all in /etc/profile.d/alias.sh. The above listed commands already have aliases, as well as several other commonly used commands.
set is one of bash's inbuilt commands, try looking in the bash manual for its many usage options.
Using set with the -x option will make bash print out each command it is going to run before it runs it.
This can be useful to find out what is happening with certain commands such as things being quoted that contain wildcards or special symbols that could cause problems, or complex aliases. Use set +x to turn this back off.
Examples
After using set -x you can run the command:
ls
The output printed before the command runs (for example):
+ ls -F --color=auto
Which means that the command is really an alias to run ls with the -F and --color=auto options. Use a “\” (backslash) before the command to run it without the alias.
The backslash escape character
* License

