Linux File System Navigation 5 — Questions and Answers
Question 1: What happens when you type `cd` with no arguments?
- Changes to the current user's home directory (Correct answer)
- Moves to the root directory
- Stays in the current directory
- Prints the current directory path
Correct answer: Changes to the current user's home directory
`cd` with no arguments is equivalent to `cd $HOME` and navigates to the user's home directory.
Question 2: Which directory in the Linux FHS contains device files such as `/dev/sda`?
- /dev (Correct answer)
- /sys
- /proc
- /run
Correct answer: /dev
`/dev` holds device files that represent hardware and virtual devices managed by the kernel.
Question 3: What is the purpose of the `$CDPATH` variable in bash?
- Defines a colon-separated list of directories searched by `cd` (Correct answer)
- Sets the default path for the `find` command
- Stores the history of visited directories
- Overrides `$PATH` for directory changes
Correct answer: Defines a colon-separated list of directories searched by `cd`
When set, `$CDPATH` causes `cd` to search listed directories if the given path isn't found relative to the current location.
Question 4: Which command lists only the names of files in the current directory, one per line, without extra details?
- ls -1 (Correct answer)
- ls -l
- ls -a
- ls -s
Correct answer: ls -1
`ls -1` (digit one) forces one entry per line, displaying only file names without size or permission details.
Question 5: Where are shared library files typically stored on a 64-bit Linux system?
- /lib64 or /usr/lib64 (Correct answer)
- /bin64
- /share/lib
- /usr/shared
Correct answer: /lib64 or /usr/lib64
64-bit shared libraries live in `/lib64` or `/usr/lib64`, separate from 32-bit libraries in `/lib` and `/usr/lib`.
Question 6: What does the glob pattern `ls /etc/*.conf` match?
- All files in /etc ending with .conf (Correct answer)
- All .conf files anywhere on the system
- Only hidden .conf files in /etc
- All files in /etc containing 'conf' in their name
Correct answer: All files in /etc ending with .conf
The `*` wildcard matches any string of characters, so `*.conf` matches all files ending with `.conf` in `/etc`.
Question 7: Which command efficiently moves to a deeply nested directory you visited two `pushd` operations ago?
- popd twice
- cd - twice
- dirs -v then cd ~N (Correct answer)
- history | grep cd
Correct answer: dirs -v then cd ~N
`dirs -v` shows the directory stack with numbered indices, and `cd ~N` jumps directly to stack entry N.
What happens when you type `cd` with no arguments?