nerdexam
LPI

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…

Shells and Shell Scripting

Question

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?

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)
  • A
    5% (1)
  • B
    70% (14)
  • C
    20% (4)
  • D
    5% (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 - set is used to set shell options or positional parameters, not define aliases.
  • C - alias has no --force flag; it overwrites silently by design, so no flag is needed.
  • D - alias has no --update flag; this syntax is entirely fabricated.
  • E - realias is 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

#bash aliases#shell built-ins#alias command#shell scripting

Community Discussion

No community discussion yet for this question.

Full 102-500 Practice