UNIX MCQs – File System Navigation (Part -4)

UNIX Question and Answer – File System Navigation

UNIX MCQ – Multiple Choice Questions for exam, interview, and Entrance Test

1. Which command is used to change the owner of a file or directory in UNIX?

a) chown

b) chgrp

c) chmod

d) chuser

Answer: a) chown

Explanation: The ‘chown’ command is used to change the owner of a file or directory in UNIX.


2. 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.


3. Which command is used to create multiple directories simultaneously in UNIX?

a) mkdir

b) makedirs

c) mkdir -m

d) mkdir -p

Answer: d) mkdir -p

Explanation: The ‘mkdir -p’ command is used to create multiple directories simultaneously in UNIX.


4. What does the ‘ls -Q’ command do in UNIX?

a) Quotes file and directory names

b) Lists files with detailed information

c) Lists files in reverse order

d) Lists files with human-readable sizes

Answer: a) Quotes file and directory names

Explanation: The ‘ls -Q’ command quotes file and directory names in UNIX.


5. Which command is used to display the number of lines, words, and characters in a file in UNIX?

a) wc

b) count

c) stats

d) size

Answer: a) wc

Explanation: The ‘wc’ command is used to display the number of lines, words, and characters in a file in UNIX.


6. 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.


7. 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.


8. 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.


9. 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.


10. 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.


11. 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.


12. 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.


13. 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.


14. 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.


15. 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.


16. 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.


17. 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.


18. 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.


19. 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.


20. 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.


21. 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.


22. What does the ‘ls -lh’ command do in UNIX?

a) Lists files with long format and human-readable sizes

b) Lists files with long format and hidden files

c) Lists files with long format and detailed information

d) Lists files with long format and sorted by size

Answer: a) Lists files with long format and human-readable sizes

Explanation: The ‘ls -lh’ command lists files with long format and human-readable sizes in UNIX.


23. Which command is used to rename a directory in UNIX?

a) rename

b) mvdir

c) mv -r

d) mv

Answer: d) mv

Explanation: The ‘mv’ command is used to rename a directory in UNIX.


24. What does the ‘pwd’ command do when executed inside a symbolic link in UNIX?

a) Prints the path of the symbolic link

b) Prints the path of the target file or directory

c) Prints the path of the parent directory

d) Prints the path of the current working directory

Answer: d) Prints the path of the current working directory

Explanation: The ‘pwd’ command prints the path of the current working directory, regardless of whether it is a symbolic link or not.


25. Which command is used to copy files and directories recursively in UNIX?

a) cp -r

b) cp -a

c) cp -p

d) cp -f

Answer: a) cp -r

Explanation: The ‘cp -r’ command is used to copy files and directories recursively in UNIX.


26. What does the ‘ls -l’ command do when executed inside a symbolic link in UNIX?

a) Lists files with long format

b) Lists files with long format and detailed information

c) Lists files in the target directory

d) Lists files with long format and hidden files

Answer: b) Lists files with long format and detailed information

Explanation: The ‘ls -l’ command lists files with long format and detailed information in UNIX, regardless of whether it is executed inside a symbolic link or not.


27. 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.


28. What does the ‘ls’ command do when executed with a directory name in UNIX?

a) Lists files in the directory

b) Lists detailed information about the directory

c) Lists hidden files in the directory

d) Lists files recursively in the directory

Answer: a) Lists files in the directory

Explanation: The ‘ls’ command lists files in the directory when executed with a directory name in UNIX.


29. Which command is used to remove a symbolic link in UNIX?

a) unlink

b) rm

c) del

d) remove

Answer: a) unlink

Explanation: The ‘unlink’ command is used to remove a symbolic link in UNIX.


30. What does the ‘cd -‘ command do when executed 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: b) Changes to the previous directory

Explanation: The ‘cd -‘ command changes to the previous directory in UNIX.


31. Which command is used to display the permissions of files and directories in UNIX?

a) permissions

b) perms

c) chmod

d) ls -l

Answer: d) ls -l

Explanation: The ‘ls -l’ command is used to display the permissions of files and directories in UNIX.


32. What does the ‘mkdir -p’ command do in UNIX?

a) Creates a new directory

b) Removes a directory

c) Creates multiple directories

d) Renames a directory

Answer: c) Creates multiple directories

Explanation: The ‘mkdir -p’ command creates multiple directories, including parent directories if they do not exist, in UNIX.


33. Which command is used to display the size of files and directories in UNIX?

a) size

b) ls -s

c) du

d) df

Answer: c) du

Explanation: The ‘du’ command is used to display the size of files and directories in UNIX.


34. What does the ‘mv’ command do when used to move a file to a destination that is a directory in UNIX?

a) Moves the file and renames it

b) Throws an error message

c) Moves the file into the directory

d) Copies the file into the directory

Answer: c) Moves the file into the directory

Explanation: When used to move a file to a destination that is a directory, the ‘mv’ command moves the file into the directory in UNIX.


35. Which command is used to change the permissions of files and directories in UNIX?

a) chmod

b) chperm

c) chown

d) perm

Answer: a) chmod

Explanation: The ‘chmod’ command is used to change the permissions of files and directories in UNIX.

Related Articles

Linux MCQ

Welcome to Linux Multiple Choice Questions (MCQ) Section Embark on a journey through the world of...