102-500 · Question #81
If an alias ls exists, which of the following commands updates the alias to point to the command ls -l instead of the alias's current target?
The correct answer is B. alias ls='ls -l'. Running alias ls='ls -l' simply redefines the alias - the alias built-in creates or overwrites an existing alias with the same name, so re-running it with a new target is all that's needed to update it. Why the distractors fail: A - set is used to set shell options or…
Question
Options
- Aset ls='ls -l'
- Balias ls='ls -l'
- Calias --force ls='ls -l'
- Dalias --update ls ls='ls -l'
- Erealias ls='ls -l'
How the community answered
(20 responses)- A5% (1)
- B70% (14)
- C20% (4)
- D5% (1)
Explanation
Running alias ls='ls -l' simply redefines the alias - the alias built-in creates or overwrites an existing alias with the same name, so re-running it with a new target is all that's needed to update it.
Why the distractors fail:
- A -
setis used to set shell options or positional parameters, not define aliases. - C -
aliashas no--forceflag; it overwrites silently by design, so no flag is needed. - D -
aliashas no--updateflag; this syntax is entirely fabricated. - E -
realiasis not a real command in any standard shell.
Memory tip: Think of alias like a variable assignment - just reassign it with the same name and new value to update it, no special flags required.
Topics
Community Discussion
No community discussion yet for this question.