Linux and Command-Line Basics

The directory /home/alice/data exists, and the current directory is /home/alice/work. Which of the following is the directory shown when "cd ../data" is run and then "pwd"?

  1. A/data
  2. B/home/alice/data
  3. C/home/alice/work/data
Show answer and explanation

Answer: B. /home/alice/data

A path that does not start with "/" is a relative path and is interpreted starting from the current directory. ".." means the parent directory, so .. moves from /home/alice/work to /home/alice, and data then leads into /home/alice/data. pwd prints the current directory as an absolute path starting with "/". An absolute path starting with "/" always refers to the same place regardless of the current directory.

  • A. /data is the data directory directly under the root directory. A relative path is interpreted from the current directory, not from "/".
  • B. Correct. .. moves to /home/alice, and from there into data.
  • C. /home/alice/work/data is where "cd data" would go. ".." means going back to the parent directory.
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. 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?
  2. When the commands above are run in order, which of the following is the result of the last two cat commands?
  3. 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?
  4. 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"?
  5. 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?