Files & Navigation Questions with Answers

26 practice questions on Files & Navigation (Linux & Shell) with answers and step-by-step solutions. Try 10 samples below, then practise all 26 free in the AptiNest app.

Sample questions

Question 1Easy

What does cd .. do?

  1. Moves to the current user's home directory
  2. Moves to the parent directory
  3. Moves straight to the root directory /
  4. Lists the parent directory

Answer: B. Moves to the parent directory

Explanation

.. refers to the parent of the current directory.

Step-by-step solution

  1. Cd changes the current directory.
  2. The two dots name the parent directory, so cd .. moves up one level. Marked answer: option B.

Why the other options are wrong

  • A. Cd with no path or ~ goes to the home directory; cd .. does not.
  • C. Cd / goes to the root directory, not the parent.
  • D. Ls lists files; cd changes the directory.

Tip: A single dot is here, two dots are the parent, and a slash alone is the root.

Question 2Easy

Which directory holds most system configuration files?

  1. /bin
  2. /tmp
  3. /usr/local/lib
  4. /etc

Answer: D. /etc

Explanation

/etc stores host-specific configuration files.

Step-by-step solution

  1. System configuration files are stored in /etc directory.
  2. /etc contains files for system-wide settings and services.
  3. Other directories like /bin or /tmp have different purposes.
  4. Most system config files are located in /etc folder.
  5. Final answer: /etc.

Why the other options are wrong

  • A. /bin holds essential user commands, not most system configuration files.
  • B. /tmp holds temporary files that are often cleared, not system configuration.
  • C. /usr/local/lib holds local libraries, not the main system configuration files.

Tip: Remember, /etc is where most system-wide config files live.

Question 3Easy

What does cd with no arguments do in bash?

  1. Changes to the root directory
  2. Changes to your home directory
  3. Prints the current directory
  4. Changes to the previous directory

Answer: B. Changes to your home directory

Explanation

With no argument cd goes to $HOME. cd - goes to the previous directory.

Step-by-step solution

  1. No arguments means default target.
  2. The default is $HOME.
  3. cd - is the previous directory.

Why the other options are wrong

  • A. Root is cd /.
  • C. pwd prints the directory.
  • D. That needs cd -.

Question 4Easy

Which directory conventionally holds system log files on Linux?

  1. /var/log
  2. /etc/logs
  3. /usr/bin
  4. /home/log

Answer: A. /var/log

Explanation

/var holds variable data, and /var/log holds logs. /etc is for configuration.

Step-by-step solution

  1. /var is for variable data.
  2. Logs change constantly.
  3. So they live in /var/log.

Why the other options are wrong

  • B. /etc has config files, not logs.
  • C. /usr/bin holds executables.
  • D. Not a standard directory.

Question 5Medium

What does cp -r src dst do?

  1. Copies a directory and its contents recursively
  2. Renames src to dst and removes the original
  3. Creates a symbolic link
  4. Copies only the hidden files inside src

Answer: A. Copies a directory and its contents recursively

Explanation

-r is needed to copy directories.

Step-by-step solution

  1. cp -r src dst copies a directory and its contents recursively.
  2. -r stands for recursive, which means it copies folders and files inside them.
  3. This command ensures all files and subdirectories are copied properly.

Why the other options are wrong

  • B. That describes mv; cp -r copies and leaves the original in place.
  • C. Symbolic links are made with ln -s; cp -r makes real copies.
  • D. cp -r copies all files and folders, not just hidden ones.

Tip: Use -r when copying directories to include all files and subfolders.

Question 6Medium

After ln file1 file2 (hard link), file1 is deleted with rm file1. What happens to file2?

  1. It becomes a broken link pointing nowhere
  2. It is also deleted along with file1
  3. The data stays accessible through file2
  4. It becomes read-only

Answer: C. The data stays accessible through file2

Explanation

The inode is freed only when its link count reaches zero; file2 still references it.

Step-by-step solution

  1. A hard link is a second name for the same inode (the same data).
  2. Rm removes one name; the data is freed only when no names remain.
  3. File2 still points to the data, so it stays accessible.

Why the other options are wrong

  • A. A hard link does not become broken when another name is removed; that is a symbolic link behaviour.
  • B. Rm file1 removes only that name, not file2.
  • D. Removing a name does not change the file's permissions.

Tip: Hard link = another name for the same data; symbolic link breaks if its target is removed.

Question 7Medium

What does basename /home/asha/report.txt print?

  1. report.txt
  2. /home/asha
  3. report
  4. /home/asha/report

Answer: A. report.txt

Explanation

basename strips the leading directory. dirname strips the last component and prints /home/asha.

Step-by-step solution

  1. Remove everything up to the last slash.
  2. What remains is the file name.
  3. dirname gives the other part.

Why the other options are wrong

  • B. That is dirname.
  • C. The extension stays unless a suffix is given.
  • D. Not a valid output.

Question 8Medium

link is a symbolic link to target.txt. You delete target.txt. What does cat link do?

  1. Prints the old content from a cache kept by the symlink itself
  2. Fails with "No such file or directory"
  3. Prints nothing and succeeds
  4. Recreates target.txt

Answer: B. Fails with "No such file or directory"

Explanation

A symlink stores a path. If the target is gone, the link is dangling and following it fails.

Step-by-step solution

  1. The symlink stores only a path.
  2. Target removed.
  3. Following the path fails.

Why the other options are wrong

  • A. No cache is kept.
  • C. It fails with an error.
  • D. Links do not recreate files.

Question 9Hard

What is the difference between a hard link and a symbolic link?

  1. A symlink shares the inode; a hard link stores a path to it
  2. Hard links can cross file systems, but symlinks cannot
  3. They are identical in behaviour
  4. A hard link points to the same inode; a symlink is a separate file holding a path

Answer: D. A hard link points to the same inode; a symlink is a separate file holding a path

Explanation

A hard link is another name for the same inode, while a symlink breaks if its target is removed.

Step-by-step solution

  1. Hard links point to the same inode.
  2. Symbolic links are separate files with a path to the target.
  3. Hard link points to the same inode; a symlink is a separate file holding a path.
  4. Final answer: A hard link points to the same inode; a symlink is a separate file holding a path.

Why the other options are wrong

  • A. Reversed: a hard link shares the inode, and a symlink stores a path.
  • B. Hard links cannot cross file systems; symlinks can point across them.
  • C. They differ: hard links share the inode, while symlinks are separate files holding a path.

Tip: Remember: Hard links share inodes, symlinks store paths.

Question 10Hard

Two hard links to the same file share which attribute?

  1. Different inodes but same name
  2. The same permissions only
  3. The same inode
  4. The same parent directory

Answer: C. The same inode

Explanation

A hard link is another directory entry pointing to the same inode, so content and metadata are shared.

Step-by-step solution

  1. Each name points to an inode.
  2. Hard links point to the same one.
  3. ls -i shows the same number.

Why the other options are wrong

  • A. Hard links share the inode.
  • B. Permissions live in the inode, but sharing the inode is the real reason.
  • D. Links may be in different directories.

Tip: ls -i prints inode numbers.

Practise all 26 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all Linux & Shell topics · All topics