UNIX Question and Answer – File System Navigation
UNIX MCQ – Multiple Choice Questions for exam, interview, and Entrance Test
1. What does the ‘ls -R’ command do in UNIX?
a) Lists files recursively
b) Lists files in reverse order
c) Lists files with detailed information
d) Lists files with human-readable sizes
Answer: a) Lists files recursively
Explanation: The ‘ls -R’ command lists files recursively in UNIX, i.e., it also lists files in subdirectories.
2. Which command is used to display the inode number of a file or directory in UNIX?
a) inode
b) i-node
c) stat
d) ls -i
Answer: d) ls -i
Explanation: The ‘ls -i’ command is used to display the inode number of a file or directory in UNIX.
3. What does the ‘pwd’ command do when executed with the ‘-L’ option in UNIX?
a) Prints the logical path of the current working directory
b) Prints the physical path of the current working directory
c) Prints the path of the parent directory
d) Prints the path of the symbolic link
Answer: a) Prints the logical path of the current working directory
Explanation: When executed with the ‘-L’ option, the ‘pwd’ command prints the logical path of the current working directory in UNIX.
4. Which command is used to change the group ownership of a file or directory in UNIX?
a) chgrp
b) chown
c) chmod
d) chmodify
Answer: a) chgrp
Explanation: The ‘chgrp’ command is used to change the group ownership of a file or directory in UNIX.
5. What does the ‘ls -t’ command do in UNIX?
a) Lists files by modification time
b) Lists files by size
c) Lists files by type
d) Lists files by name
Answer: a) Lists files by modification time
Explanation: The ‘ls -t’ command lists files by modification time in UNIX, with the most recently modified files appearing first.
6. Which command is used to create a soft link in UNIX?
a) ln -s
b) ln -f
c) ln -h
d) ln -r
Answer: a) ln -s
Explanation: The ‘ln -s’ command is used to create a soft link (symbolic link) in UNIX.
7. What does the ‘ls -a’ command do in UNIX?
a) Lists all files including hidden files
b) Lists files with detailed information
c) Lists files in reverse order
d) Lists files with human-readable sizes
Answer: a) Lists all files including hidden files
Explanation: The ‘ls -a’ command lists all files including hidden files in UNIX.
8. Which command is used to change the owner and group of a file or directory simultaneously in UNIX?
a) chown
b) chgrp
c) chmod
d) chowngrp
Answer: a) chown
Explanation: The ‘chown’ command is used to change the owner and group of a file or directory simultaneously in UNIX.
9. What does the ‘ls -S’ command do in UNIX?
a) Lists files by modification time
b) Lists files by size
c) Lists files by type
d) Lists files by name
Answer: b) Lists files by size
Explanation: The ‘ls -S’ command lists files by size in UNIX, with the largest files appearing first.
10. Which command is used to change the mode of a file in UNIX?
a) chmod
b) chown
c) chgrp
d) mod
Answer: a) chmod
Explanation: The ‘chmod’ command is used to change the mode (permissions) of a file in UNIX.
11. What does the ‘ls -l’ command do when executed with a symbolic link in UNIX?
a) Lists files in the target directory
b) Lists files with detailed information about the symbolic link
c) Lists files with detailed information about the target file
d) Lists files with detailed information about the parent directory
Answer: b) Lists files with detailed information about the symbolic link
Explanation: The ‘ls -l’ command lists files with detailed information about the symbolic link itself in UNIX.
12. Which command is used to display the contents of a file one page at a time in UNIX?
a) more
b) less
c) cat
d) tail
Answer: a) more
Explanation: The ‘more’ command is used to display the contents of a file one page at a time in UNIX.
13. What does the ‘ls -d’ command do in UNIX?
a) Lists directories only
b) Lists hidden files only
c) Lists detailed information about directories
d) Lists files with human-readable sizes
Answer: a) Lists directories only
Explanation: The ‘ls -d’ command lists directories only in UNIX.
14. Which command is used to create a hard link in UNIX?
a) ln -s
b) ln -h
c) ln
d) ln -f
Answer: c) ln
Explanation: The ‘ln’ command is used to create a hard link in UNIX.
15. What does the ‘ls -F’ command do in UNIX?
a) Lists files with detailed information
b) Appends a slash to directories
c) Lists files with human-readable sizes
d) Lists files sorted by modification time
Answer: b) Appends a slash to directories
Explanation: The ‘ls -F’ command appends a slash to directories in UNIX.
16. Which command is used to display the size of a file in UNIX?
a) size
b) ls -s
c) du
d) wc
Answer: b) ls -s
Explanation: The ‘ls -s’ command is used to display the size of a file in UNIX.
17. What does the ‘ls -m’ command do in UNIX?
a) Lists files with detailed information
b) Lists files with comma-separated values
c) Lists files with human-readable sizes
d) Lists files with modification time
Answer: b) Lists files with comma-separated values
Explanation: The ‘ls -m’ command lists files with comma-separated values in UNIX.
18. Which command is used to create a directory and parent directories if they do not exist in UNIX?
a) mkdir
b) mkdir -p
c) mdir
d) makedir
Answer: b) mkdir -p
Explanation: The ‘mkdir -p’ command is used to create a directory and parent directories if they do not exist in UNIX.
19. What does the ‘ls -g’ command do in UNIX?
a) Lists files with detailed information excluding the owner
b) Lists files with detailed information excluding the group
c) Lists files with detailed information excluding permissions
d) Lists files with detailed information excluding modification time
Answer: a) Lists files with detailed information excluding the owner
Explanation: The ‘ls -g’ command lists files with detailed information excluding the owner in UNIX.
20. Which command is used to create an empty file in UNIX?
a) touch
b) create
c) mkfile
d) newfile
Answer: a) touch
Explanation: The ‘touch’ command is used to create an empty file in UNIX.
21. Which command is used to display the size of a directory and its contents recursively in UNIX?
a) size
b) ls -s
c) du
d) wc
Answer: c) du
Explanation: The ‘du’ command is used to display the size of a directory and its contents recursively in UNIX.
22. What does the ‘ls -i’ command do in UNIX?
a) Lists files with detailed information including inode numbers
b) Lists files with detailed information including file sizes
c) Lists files with detailed information including modification time
d) Lists files with detailed information including permissions
Answer: a) Lists files with detailed information including inode numbers
Explanation: The ‘ls -i’ command lists files with detailed information including inode numbers in UNIX.
23. Which command is used to move back to the previous directory in UNIX?
a) cd –
b) cd ..
c) cd /
d) cd ~
Answer: a) cd –
Explanation: The ‘cd -‘ command is used to move back to the previous directory in UNIX.
24. What does the ‘ls -t’ command do in UNIX?
a) Lists files by modification time
b) Lists files by access time
c) Lists files by creation time
d) Lists files by size
Answer: a) Lists files by modification time
Explanation: The ‘ls -t’ command lists files by modification time in UNIX.
25. Which command is used to change the modification time of a file in UNIX?
a) touch
b) modtime
c) mtime
d) changetime
Answer: a) touch
Explanation: The ‘touch’ command is used to change the modification time of a file in UNIX.
26. What does the ‘ls -R’ command do in UNIX?
a) Lists files recursively
b) Lists files in reverse order
c) Lists files with detailed information
d) Lists files with human-readable sizes
Answer: a) Lists files recursively
Explanation: The ‘ls -R’ command lists files recursively in UNIX, including files in subdirectories.
27. Which command is used to create an empty file with a specific size in UNIX?
a) touch
b) create
c) mkfile
d) newfile
Answer: c) mkfile
Explanation: The ‘mkfile’ command is used to create an empty file with a specific size in UNIX.
28. What does the ‘ls -g’ command do in UNIX?
a) Lists files with detailed information excluding the owner
b) Lists files with detailed information excluding the group
c) Lists files with detailed information excluding permissions
d) Lists files with detailed information excluding modification time
Answer: a) Lists files with detailed information excluding the owner
Explanation: The ‘ls -g’ command lists files with detailed information excluding the owner in UNIX.
29. Which command is used to display the contents of a file from the end in UNIX?
a) tail
b) head
c) less
d) more
Answer: a) tail
Explanation: The ‘tail’ command is used to display the contents of a file from the end in UNIX.
30. What does the ‘ls -l’ command do when executed with a symbolic link in UNIX?
a) Lists files in the target directory
b) Lists files with detailed information about the symbolic link
c) Lists files with detailed information about the target file
d) Lists files with detailed information about the parent directory
Answer: b) Lists files with detailed information about the symbolic link
Explanation: The ‘ls -l’ command lists files with detailed information about the symbolic link itself in UNIX.
31. Which command is used to change the owner and group of a file or directory in UNIX?
a) chown
b) chgrp
c) chmod
d) chowngrp
Answer: a) chown
Explanation: The ‘chown’ command is used to change the owner and group of a file or directory simultaneously in UNIX.
32. What does the ‘ls -a’ command do in UNIX?
a) Lists all files including hidden files
b) Lists files with detailed information
c) Lists files in reverse order
d) Lists files with human-readable sizes
Answer: a) Lists all files including hidden files
Explanation: The ‘ls -a’ command lists all files including hidden files in UNIX.
33. Which command is used to display the contents of a file in UNIX?
a) cat
b) content
c) view
d) display
Answer: a) cat
Explanation: The ‘cat’ command is used to display the contents of a file in UNIX.
34. What does the ‘ls -F’ command do in UNIX?
a) Lists files with detailed information
b) Appends a slash to directories
c) Lists files with human-readable sizes
d) Lists files sorted by modification time
Answer: b) Appends a slash to directories
Explanation: The ‘ls -F’ command appends a slash to directories in UNIX.
35. Which command is used to display the size of a directory and its contents recursively in UNIX?
a) size
b) ls -s
c) du
d) wc
Answer: c) du
Explanation: The ‘du’ command is used to display the size of a directory and its contents recursively in UNIX.