Alias (command)

Alias (command)

In computing, alias is a command in various command line interpreters (shells) such as Unix shells, 4DOS/4NT and Windows PowerShell, which enables a replacement of a word with another string. It is mainly used for abbreviating a system command, or for adding default arguments to a regularly used command. Typically, an alias will last for the life of the shell session but regularly used aliases can be placed in the shell's configuration file ("~/.cshrc" or the systemwide "/etc/csh.cshrc" for csh, or "~/.bashrc" or the systemwide "/etc/bashrc" or "/etc/bash.bashrc" for bash) so that they will be available for all shell sessions.

Creating aliases

Aliases can be created by supplying name/value pairs as arguments for the alias command. An example of the Bash shell syntax is:

alias copy="cp"

The corresponding syntax in the C shell or tcsh shell is:

alias copy "cp"

This alias means that when the command copy is read in the shell, it will be replaced with cp and that command will be executed instead.

In the 4DOS/4NT shell the following syntax is used to define cp as an alias for the 4DOS copy command:

alias cp copy

To create a new alias in Windows PowerShell, the new verb can be used with the alias cmdlet:

new-alias ci copy-item

This creates a new alias called ci that will be replaced with the copy-item cmdlet when executed.

Viewing currently defined aliases

To view defined aliases the following commands can be used:

alias # Used without arguments; displays a list of all current aliases alias -p # Analogous to the above; not available in 4DOS/4NT and PowerShell alias "myAlias" # Displays the command for a defined alias

Overriding aliases

In Unix shells, if an alias exists for a command, it is possible to override the alias by surrounding the command with quotes. For example, consider the following alias definition:

alias ls='ls -la'

To override this alias and execute the ls command as it was originally defined, the following syntax can be used:

'ls'

In Windows PowerShell, the set verb can be used with the alias cmdlet to change an existing alias:

set-alias ci cls

The alias ci will now point to the cls command.

Removing aliases

In Unix shells and 4DOS/4NT, aliases can be removed by executing the unalias command:

unalias copy # Removes the copy alias unalias -a # The -a switch will remove all aliases; not available in 4DOS/4NT

In Windows PowerShell, the alias can to be removed from the alias: drive using remove-item:

remove-item alias:ci # Removes the ci alias

Typical aliases

Some commonly used aliases in the Bash shell:

alias ls='ls --color=tty' # use colors alias la='ls -a' # list all files alias ll='ls -l' # long listing format alias rm='rm -i' # prompt before overwrite alias cp='cp -i' alias mv='mv -i' alias vi='vim' # use improved vi editor

Standard aliases of Windows PowerShell include:

new-alias cd set-location new-alias ls get-childitem new-alias dir get-childitem new-alias echo write-output new-alias ps get-process new-alias kill stop-process

Alternatives

When not using arguments, as in the vi alias defined above, one might create a symbolic link with the ln command rather than use an alias. This method will result in the vi command being available to all users, independent of the shell.

External links

*man|cu|alias|SUS|define or display aliases
* [http://www.ss64.com/bash/alias.html Bash man page for alias]
* [http://www.bellevuelinux.org/alias.html The alias Command] by The Linux Information Project (LINFO)


Wikimedia Foundation. 2010.

Игры ⚽ Нужна курсовая?

Look at other dictionaries:

  • Alias (unix) — Saltar a navegación, búsqueda En informática alias es una orden dispponible en varios intérpretes de comandos tales como los shells de Unix, 4DOS/4NT y Windows PowerShell, que permite reemplazar una palabra o serie de palabras con otra. Su uso… …   Wikipedia Español

  • Alias — An alias is a pseudonym and may also refer to:In family names: *An additional component of a surname to distinguish its users from other families of the same surname. So whereas an alias is used nowadays to hide someone s identity, an alias was… …   Wikipedia

  • Alias (Unix) — En informática alias es una orden disponible en varios intérpretes de comandos tales como los shells de Unix, 4DOS/4NT y Windows PowerShell, que permite reemplazar una palabra o serie de palabras con otra. Su uso principal es el de abreviar… …   Wikipedia Español

  • Command & Conquer: Generals — Command Conquer: Generals Entwickler: Electronic Arts Verleger: Electronic Arts Publikation …   Deutsch Wikipedia

  • Command & Conquer: Generäle — Command Conquer: Generals Entwickler: Electronic Arts Verleger: Electronic Arts Publikation …   Deutsch Wikipedia

  • Command & Conquer: Generäle — Command Conquer: Generals Entwickler Electronic Arts Publisher …   Deutsch Wikipedia

  • Command & Conquer 4: Tiberian Twilight — Command Conquer 4: Tiberian Twilight …   Deutsch Wikipedia

  • alias — ► ADVERB ▪ also known as. ► NOUN 1) a false identity. 2) Computing an identifying label used to access a file, command, or address. DERIVATIVES aliasing noun. ORIGIN Latin, at another time, otherwise …   English terms dictionary

  • Command key — The Command key The Command key, also historically known as the Apple key, open Apple key or meta key is a modifier key present on Apple Keyboards. The Command key s purpose is to allow the user to enter keyboard shortcut commands to GUI… …   Wikipedia

  • Command — Befehlstaste Die Befehlstaste ist eine Taste auf Tastaturen von Apple Computern. Unter Mac Anwendern wird sie oft auch Apfeltaste genannt. Im deutschen Sprachgebrauch haben sich aber auch Bezeichnungen wie Propeller , Kleeblatt oder… …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”