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?

  1. A"." means the current directory and ".." the parent directory; .bashrc, whose name starts with ".", is a hidden file and is not shown without -a
  2. B"." means the current directory and ".." the parent directory; .bashrc is a write-protected file and is not shown without -a
  3. 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.
Practice this topic Back to topic

Books on Linux and Command-Line Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Linux and Command-Line Basics questions

  1. When the commands above are run in order, which of the following is the result of the last two cat commands?
  2. A directory contains six files: a1.txt, a2.txt, a10.txt, b1.txt, c1.txt and a1.csv. Which of the following is the number of files shown when "ls [ab]?.txt" is run in this directory?
  3. After "chmod 754 run.sh" is run on the file run.sh, which of the following is the permission notation shown at the start of the line from "ls -l run.sh"?
  4. touch creates a new file from 666, and mkdir a new directory from 777, with the umask bits removed. Which of the following is the correct pair of permissions when a new file and a new directory are created in a shell whose umask is 027?
  5. The directory d has permissions rwx--x--x (711), and the file f.txt in it has rw-r--r-- (644). A user who is neither the owner nor the superuser runs "ls d" and "cat d/f.txt". Which of the following is the result?