Sample questions
Question 1Easy
- Moves to the current user's home directory
- Moves to the parent directory
- Moves straight to the root directory /
- Lists the parent directory
Answer: B. Moves to the parent directory
Explanation
.. refers to the parent of the current directory.
Step-by-step solution
- Cd changes the current directory.
- 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?
- /bin
- /tmp
- /usr/local/lib
- /etc
Answer: D. /etc
Explanation
/etc stores host-specific configuration files.
Step-by-step solution
- System configuration files are stored in /etc directory.
- /etc contains files for system-wide settings and services.
- Other directories like /bin or /tmp have different purposes.
- Most system config files are located in /etc folder.
- 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?
- Changes to the root directory
- Changes to your home directory
- Prints the current directory
- 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
- No arguments means default target.
- The default is
$HOME. 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?
- /var/log
- /etc/logs
- /usr/bin
- /home/log
Answer: A. /var/log
Explanation
/var holds variable data, and /var/log holds logs. /etc is for configuration.
Step-by-step solution
/var is for variable data.- Logs change constantly.
- 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?
- Copies a directory and its contents recursively
- Renames src to dst and removes the original
- Creates a symbolic link
- 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
cp -r src dst copies a directory and its contents recursively.- -r stands for recursive, which means it copies folders and files inside them.
- 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?
- It becomes a broken link pointing nowhere
- It is also deleted along with file1
- The data stays accessible through file2
- 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
- A hard link is a second name for the same inode (the same data).
- Rm removes one name; the data is freed only when no names remain.
- 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?
- report.txt
- /home/asha
- report
- /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
- Remove everything up to the last slash.
- What remains is the file name.
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?
- Prints the old content from a cache kept by the symlink itself
- Fails with "No such file or directory"
- Prints nothing and succeeds
- 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
- The symlink stores only a path.
- Target removed.
- 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?
- A symlink shares the inode; a hard link stores a path to it
- Hard links can cross file systems, but symlinks cannot
- They are identical in behaviour
- 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
- Hard links point to the same inode.
- Symbolic links are separate files with a path to the target.
- Hard link points to the same inode; a symlink is a separate file holding a path.
- 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?
- Different inodes but same name
- The same permissions only
- The same inode
- 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
- Each name points to an inode.
- Hard links point to the same one.
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 →