ArticleslgStudy

science

Alias (command)

Alias (command) is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Alias (command) rather than just read about it. In short: alias is a shell command that defines a word that the shell replaces with associated text before interpreting a command line. It is often used to enhance productivity by abbreviating a command or for including commonly used arguments with a command.

Alias (command) — main illustration
Alias (command) — illustration

Key takeaways

  • Alias (command) belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Alias (command) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Alias (command) from memory before moving on to harder problems.

Reference excerpt

alias is a shell command that defines a word that the shell replaces with associated text before interpreting a command line. It is often used to enhance productivity by abbreviating a command or for including commonly used arguments with a command. The command is available in Unix shells, AmigaDOS, 4DOS/4NT, FreeDOS, KolibriOS, PowerShell, ReactOS, EFI shell, and IBM i. Aliasing functionality in MS-DOS and Command Prompt is provided by the DOSKEY command. Since aliases are defined only for a shell session, regularly used aliases are often defined in a session startup shell script such as .bashrc. The alias commands may either be written in the config script directly or sourced from a separate file. Aliases were introduced in the C shell to survive in descendant shells such as tcsh and bash. As these aliases were limited to one line they were useful for creating relatively simple shortcut commands, but not more complex constructs. Older versions of the Bourne shell did not offer aliases, but did provide functions, which are more powerful than the csh alias. Eventually, the csh alias was implemented in the bash and ksh shells. With shells that support both functions and aliases but no parameterized inline shell scripts, the use of functions wherever possible is recommended. Nonetheless, aliases are necessary where chained aliases are required.

Features

Define The following is an example that defines gc to be a command the performs the action git commit.

In C shell and tcsh there is no equals sign:

To define an alias in PowerShell, the new-alias cmdlet is used:

In PowerShell, an alias cannot be used to specify default arguments for a command. Instead, this must be done by adding items to the collection $PSDefaultParameterValues, one of the PowerShell preference variables. In PowerShell, the set verb is used to change an existing alias. The following changes the alias ci to invoke the cls command.

In 4DOS/4NT shell, the eset command provides an interactive command line to edit an existing alias. For example:

List To view defined aliases:

To list aliases in a way that allows for re-creating them by sourcing the output (not available in 4DOS/4NT or PowerShell):

To report the definition of a particular alias name:

Remove In Unix shells and 4DOS/4NT, aliases can be removed via unalias. To remove the copy alias:

To remove all aliases (not available in 4DOS/4NT):

To remove all aliases in 4DOS/4NT:

In PowerShell, an alias is removed from the alias:\ drive via remove-item:

Ignore In Unix shells, an aliased word can be used without replacement by using quotes. For example, consider the following command that defines an alias ls that invokes the original ls with options -la. To invoke the original ls command (without the options), the following syntax is used: 'ls' or \ls.

In 4DOS/4NT shell, an asterisk is used. For example, the following defines dir to invoke the original dir (requires asterisk in the definition) with options /2/p. To later invoke the original dir, the syntax is *dir.

Chaining Typically, aliases are used to replace the first word of a command line, but some shells such as bash and ksh also support chaining – replacing subsequent words. For example, the following defines list to invoke ls and long to as a set of ls options. The command alias must end with a space to enable chaining.

Then, command line list long myfile expands to ls -Flas myfile. The behavior provided by chaining is not possible via shell functions.

Command arguments In the C Shell, arguments can be embedded inside the command using the string \!*. For example, with this alias:

ls-more /etc /usr expands to ls /etc /usr | more to list the contents of the directories /etc and /usr, pausing after every screenful. Without \!*,

would instead expand to ls | more /etc /usr which incorrectly attempts to open the directories in more. Some shells such as bash and ksh do not support this syntax, but do provide for similar functionality via shell functions — see § Alternatives below.

Alternatives Best practice is to only define an alias for a relatively simple command. Alternatives for more complicated logic include:

A shell script, which provides a rich ability to implement a command A symbolic link in the user's PATH (such as /bin), which in some cases may allow access to a buried command function for the small number of commands that use their invocation name to select the mode of operation A shell function, especially if the command being created needs to modify the internal runtime environment of the shell (such as environment variables) needs to change the shell's working directory, or must be implemented in a way which guarantees that it appear in the command search path for anything but an interactive shell (especially any "safer" version of rm, cp, mv and so forth) A relatively simple alias that includes a few arguments and supports subsequent arguments, can be converted to a shell function in a relatively straightforward process. For example, alias alias ll='ls -Flas' can be implemented as function ll () { ls -Flas "$@" ;}. To prevent a function from calling itself, use command: ls () { command ls --color=auto "$@" ; }. In older Bourne shells, use /bin/ls instead of command ls.

References

Further reading McElhearn, Kirk (2006). The Mac OS X Command Line: Unix Under the Hood. John Wiley & Sons. ISBN 978-0470113851.

External links

alias: define or display aliases – Shell and Utilities Reference, The Single UNIX Specification, Version 5 from The Open Group Bash man page for alias The alias Command by The Linux Information Project (LINFO)

Illustrations

Alias (command) illustration

Worked examples

Example 1 — a first encounter with Alias (command)

Start with the simplest possible case. Write down what Alias (command) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Alias (command) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Alias (command) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Alias (command)

In research
Alias (command) appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Alias (command) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Alias (command) is common in secondary-school and first-year university syllabi. It links to neighbouring topics IBM i Qshell commands, ReactOS commands, Standard Unix programs, so understanding it makes those chapters shorter.
In everyday life
Look for Alias (command) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Alias (command)” →

How to study Alias (command) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Alias (command) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Alias (command) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Alias (command) in simple terms?

alias is a shell command that defines a word that the shell replaces with associated text before interpreting a command line. It is often used to enhance productivity by abbreviating a command or for including commonly used arguments with a command.

Why does Alias (command) matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Alias (command)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Alias (command).

Tags

  • IBM i Qshell commands
  • ReactOS commands
  • Standard Unix programs
  • Unix SUS2008 utilities
  • Windows administration
  • Windows commands

Keep exploring