nerdexam
CompTIACompTIA

XK0-005 · Question #1238

XK0-005 Question #1238: Real Exam Question with Answer & Explanation

The correct answer is C: echo "alias dir=ls -la" >> ~/.profile. {"question_number": 5, "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?

System Management

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

Explanation

{"question_number": 5, "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?", "correct_answer": "C", "explanation": "To make an alias persist across logins for a specific user, it should be appended to a shell initialization file that is sourced at login time. ~/.profile is sourced by login shells (bash, sh) and is the standard, shell-agnostic location for user-specific environment settings. Choice C uses '>>' (append), which is correct - it adds the alias without overwriting existing content. Choice A writes to /etc/profile, which affects all users system-wide and requires root access; it is overly broad for a single user's alias. Choice B targets /etc/skel, which is a directory used as a template for new user home directories - not appropriate here. Choice D writes to ~/.bashrc using '>' (overwrite), which would destroy all existing content in the file, making it destructive even if .bashrc were the right target. ~/.profile is the safest and most appropriate per-user, login-persistent location.", "generated_by": "claude-sonnet", "llm_judge_score": 3}

Topics

#Linux Shell#Aliases#Shell Configuration#User Environment

Community Discussion

No community discussion yet for this question.

Full XK0-005 PracticeBrowse All XK0-005 Questions