Linux and Command-Line Basics
In the home directory, "ls" shows only notes.txt, while "ls -a" shows ".", "..", ".bashrc" and "notes.txt". Which of the following correctly explains this result?
- A"." means the current directory and ".." the parent directory; .bashrc, whose name starts with ".", is a hidden file and is not shown without -a
- B"." means the current directory and ".." the parent directory; .bashrc is a write-protected file and is not shown without -a
- C"." means the root directory and ".." the home directory; .bashrc, whose name starts with ".", is a hidden file and is not shown without -a
Show answer and explanation
Answer: A. "." means the current directory and ".." the parent directory; .bashrc, whose name starts with ".", is a hidden file and is not shown without -a
Every directory contains an entry "." for the directory itself and ".." for its parent. Files and directories whose names start with "." are treated as hidden: ls does not show them without options, and shows them with -a (all). Configuration files of shells and tools, such as .bashrc, are often given hidden names so that they do not clutter ordinary listings. Whether a file is shown depends only on its name and has nothing to do with its permissions.
- A. Correct. Both the meaning of "." and ".." and the handling of hidden files are described correctly.
- B. Whether ls shows a file depends on whether its name starts with ".", not on write permission.
- C. The root directory is written "/" and the home directory "~". "." and ".." are the directory itself and its parent.