nerdexam
CompTIA

XK0-004 · Question #243

A user wants to alias dir so it always returns the contents of the ls -la command. However, the user has to reset the alias with every login. Which of the following is the BEST action the user can…

The correct answer is C. echo "alias dir=ls -la" >> ~/.profile. When echoing something to a file, >> appends to the file and > overwrites the file.

Scripting, Containers and Automation

Question

A user wants to alias dir so it always returns the contents of the ls -la command. However, the user has to reset the alias with every login. Which of the following is the BEST action the user can take to ensure the command is always available?

Options

  • Aecho "alias dir=ls -la" > /etc/profile
  • Becho "alias dir=ls -la" >> /etc/skel
  • Cecho "alias dir=ls -la" >> ~/.profile
  • Decho "alias dir=ls -la" > ~/.bashrc

How the community answered

(43 responses)
  • A
    5% (2)
  • B
    2% (1)
  • C
    86% (37)
  • D
    7% (3)

Explanation

When echoing something to a file, >> appends to the file and > overwrites the file.

Topics

#alias#bash profile#shell configuration#login scripts

Community Discussion

No community discussion yet for this question.

Full XK0-004 Practice