The power of the command line in Linux Distributions is still very much at the forefront, many admin task can simply be performed much more efficiently this way.
This faster command entry speed, for admin tasks is true even by using the basic terminal but many of the most up-to date command shells such as (bash, ksh and zsh) provide powerful tools that can be used to speed up shell command entry and processing even more.
The tools available fall into the following areas :
1.. Command and File-Path/File-name completion
2.. Command History
3.. Command line editing using Emacs or Vim
NB: in this post I will detail command completion, areas 2 and 3 above I will given their own posts.
Command and path/file-name completion
Completion Tools assist the user in typing commands at the command line, by looking for and suggesting matching words for incomplete ones. Completion is generally requested by pressing the completion key (often the Tab ↹ key).
Completion works by allowing you to enter only part of the text you need to complete a full command element, after you enter part of the text (Command or filename etc…) you press the TAB key, the shell then try’s to complete the rest of the element for you and adds one following space.
If only one possible command or file-name etc.. exists then the shell will complete this part/element of the command for you.
If more than one possibility exists then the shell will fill in what it can, it will then automatically show you all the possibilities or expect you to press the TAB key again for these options to be shown, depending on the shell you are using.
The concept of command line completion is very powerful and well worth learning, in order to speed-up command entry, it relates to the following areas when a shell command is being constructed:
Command name completion
Path and filename completion
Wildcard completion
Variable completion
Command argument completion
These areas are detailed as below :
Command name completion is the completion of the name of a command. In most shells, a command can be a program in the command path (usually $PATH), a builtin command, a function or alias.
Path/filename completion is the completion of the path to a file, relative or absolute.
Wildcard completion is a generalization of path completion, where an expression matches any number of files, using any supported syntax for file matching.
Variable completion is the completion of the name of a variable name (environment variable or shell variable). Bash, zsh, and fish have completion for all variable names. PowerShell has completions for environment variable names, shell variable names and – from within user-defined functions – parameter names.
Command argument completion is the completion of a specific command’s arguments. There are two types of arguments, named and positional: Named arguments, often called options, are identified by their name or letter preceding a value, whereas positional arguments consist only of the value. Some shells allow completion of argument names, but few support completing values.
The Tab Key then is the method by which you use the completion shell tool/service to speed up the entry of almost all elements of a command.
Wiki Ref : Command-line completion