UNIX Question and Answer – File System Navigation
UNIX MCQ – Multiple Choice Questions for exam, interview, and Entrance Test
1. Which command is used to display the total size of a directory’s contents in human-readable format in UNIX?
a) size
b) ls -sh
c) du -h
d) wc -h
Answer: c) du -h
Explanation: The ‘du -h’ command displays the total size of a directory’s contents in human-readable format in UNIX.
2. What does the ‘ls -l’ command do in UNIX when used with a directory?
a) Lists files in the directory with detailed information
b) Lists directories only
c) Lists files in the directory without detailed information
d) Lists hidden files in the directory
Answer: a) Lists files in the directory with detailed information
Explanation: The ‘ls -l’ command lists files in the directory with detailed information when used with a directory in UNIX.
3. Which command is used to create a symbolic 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 symbolic link (soft link) in UNIX.
4. 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.
5. 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.
6. 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.
7. Which command is used to change the access time and modification time of a file to the current time in UNIX?
a) touch
b) modtime
c) mtime
d) changetime
Answer: a) touch
Explanation: The ‘touch’ command is used to change the access time and modification time of a file to the current time in UNIX.
8. 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.
9. Which command is used to display the permissions of a file or directory in symbolic mode in UNIX?
a) permissions
b) perms
c) chmod
d) ls -l
Answer: c) chmod
Explanation: The ‘chmod’ command is used to display the permissions of a file or directory in symbolic mode in UNIX.
10. 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.
11. 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.
12. 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.
13. Which command is used to display the contents of a file from the beginning in UNIX?
a) head
b) tail
c) less
d) more
Answer: a) head
Explanation: The ‘head’ command is used to display the contents of a file from the beginning in UNIX.
14. 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.
15. 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.
16. 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.
17. 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.
18. What does the ‘cd ~’ command do in UNIX?
a) Changes to the home directory
b) Changes to the previous directory
c) Stays in the current directory
d) Changes to the parent directory
Answer: a) Changes to the home directory
Explanation: The ‘cd ~’ command changes to the home directory in UNIX.
19. Which command is used to list files and directories in a long format in UNIX, including hidden files?
a) ls -a
b) ls -l
c) ls -h
d) ls -d
Answer: b) ls -l
Explanation: The ‘ls -l’ command lists files and directories in a long format in UNIX, including hidden files.
20. What does the ‘pwd’ command do when executed without any options 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: b) Prints the physical path of the current working directory
Explanation: The ‘pwd’ command prints the physical path of the current working directory in UNIX when executed without any options.
21. What does the ‘ls -C’ command do in UNIX?
a) Lists files and directories in columns
b) Lists files and directories in a compact format
c) Lists files and directories with detailed information
d) Lists files and directories in a tree structure
Answer: a) Lists files and directories in columns
Explanation: The ‘ls -C’ command lists files and directories in columns in UNIX.
22. Which command is used to display the size of files and directories in a human-readable format in UNIX?
a) size
b) ls -s
c) du -h
d) wc -h
Answer: c) du -h
Explanation: The ‘du -h’ command displays the size of files and directories in a human-readable format in UNIX.
23. What does the ‘ls -1’ command do in UNIX?
a) Lists files and directories in a single column
b) Lists files and directories in a long format
c) Lists files and directories with detailed information
d) Lists files and directories sorted by modification time
Answer: a) Lists files and directories in a single column
Explanation: The ‘ls -1’ command lists files and directories in a single column in UNIX.
24. Which command is used to change the group ownership of a file or directory in UNIX?
a) chgrp
b) chown
c) chmod
d) chowngrp
Answer: a) chgrp
Explanation: The ‘chgrp’ command is used to change the group ownership of a file or directory in UNIX.
25. What does the ‘ls -h’ command do in UNIX?
a) Lists files and directories in a human-readable format
b) Lists files and directories with detailed information
c) Lists hidden files and directories
d) Lists files and directories sorted by size
Answer: a) Lists files and directories in a human-readable format
Explanation: The ‘ls -h’ command lists files and directories in a human-readable format in UNIX.
26. Which command is used to create a symbolic link with an absolute path in UNIX?
a) ln -s
b) ln -f
c) ln -h
d) ln -r
Answer: b) ln -f
Explanation: The ‘ln -f’ command is used to create a symbolic link with an absolute path in UNIX.
27. What does the ‘ls -d’ command do in UNIX?
a) Lists directories only
b) Lists hidden files and directories
c) Lists detailed information about directories
d) Lists files and directories sorted by modification time
Answer: a) Lists directories only
Explanation: The ‘ls -d’ command lists directories only in UNIX.
28. 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.
29. What does the ‘ls -R’ command do in UNIX?
a) Lists files and directories recursively
b) Lists files and directories in reverse order
c) Lists files and directories with detailed information
d) Lists files and directories with human-readable sizes
Answer: a) Lists files and directories recursively
Explanation: The ‘ls -R’ command lists files and directories recursively in UNIX.
30. 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.
31. What does the ‘ls -F’ command do in UNIX?
a) Appends a slash to directories
b) Lists files with detailed information
c) Lists files in reverse order
d) Lists files with human-readable sizes
Answer: a) Appends a slash to directories
Explanation: The ‘ls -F’ command appends a slash to directories in UNIX.
32. Which command is used to list files and directories in a long format with user and group IDs displayed numerically in UNIX?
a) ls -l
b) ls -n
c) ls -o
d) ls -d
Answer: b) ls -n
Explanation: The ‘ls -n’ command lists files and directories in a long format with user and group IDs displayed numerically in UNIX.
33. 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.
34. Which command is used to create a soft link with an absolute path 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) with an absolute path in UNIX.
35. What does the ‘ls -a’ command do in UNIX?
a) Lists all files and directories, including hidden ones
b) Lists files with detailed information
c) Lists files in reverse order
d) Lists files with human-readable sizes
Answer: a) Lists all files and directories, including hidden ones
Explanation: The ‘ls -a’ command lists all files and directories, including hidden ones, in UNIX.