LFCS · Question #512
Which of the following benefits does an alias in bash provide?
The correct answer is D. It allows a string to be substituted for the first word of a simple command. An alias in bash allows a user to define a shorthand string that the shell will substitute for a longer command or sequence of commands.
Question
Options
- AIt provides faster lookups for commands in the system directory.
- BIt creates a local copy of a file from another directory.
- CIt hides what command you are running from others.
- DIt allows a string to be substituted for the first word of a simple command.
How the community answered
(22 responses)- C5% (1)
- D95% (21)
Why each option
An alias in bash allows a user to define a shorthand string that the shell will substitute for a longer command or sequence of commands.
Aliases do not inherently provide faster lookups; they are evaluated by the shell before the actual command execution lookup occurs.
Aliases are a command substitution mechanism, not a tool for creating local copies of files.
Aliases do not hide commands; they simply provide an alternative name or shorthand for commands, which are still visible if the alias is expanded or inspected.
An alias functions by allowing the shell to substitute a defined string for the first word of a simple command, enabling users to create shortcuts for frequently used or complex commands. For example, 'alias ll="ls -lha"' allows 'll' to execute 'ls -lha'.
Concept tested: Bash alias functionality
Source: https://www.gnu.org/software/bash/manual/bash.html#Aliases
Topics
Community Discussion
No community discussion yet for this question.