CompTIA Linux+ (XK0-004) — Question 174
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?
Answer options
- A. echo "alias dir=ls -la" > /etc/profile
- B. echo "alias dir=ls -la" >> /etc/skel
- C. echo "alias dir=ls -la" >> ~/.profile
- D. echo "alias dir=ls -la" > ~/.bashrc
Correct answer: C
Explanation
The correct answer is C because adding the alias to ~/.profile ensures it is executed every time the user logs in. Options A and B affect system-wide configurations or skeleton files, which do not apply to an individual user’s session. Option D would work for bash shells, but using ~/.profile is more universally applicable for different shell types.