UNIX MCQs – File System Navigation (Part -1)

UNIX Question and Answer – File System Navigation

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

1. Which command is used to list the contents of a directory in UNIX?

a) ls

b) cd

c) pwd

d) dir

Answer: a) ls

Explanation: The ls command is used to list the contents of a directory in UNIX.


2. What does the ‘cd’ command do in UNIX?

a) Display the current directory

b) Change the current directory

c) Create a new directory

d) Remove a directory

Answer: b) Change the current directory

Explanation: The ‘cd’ command is used to change the current directory in UNIX.


3. Which command is used to display the current working directory in UNIX?

a) ls

b) cd

c) pwd

d) dir

Answer: c) pwd

Explanation: The ‘pwd’ command is used to display the current working directory in UNIX.


4. What does the ‘touch’ command do in UNIX?

a) Create a new directory

b) Change file permissions

c) Update the access and modification times of a file

d) Display the contents of a file

Answer: c) Update the access and modification times of a file

Explanation: The ‘touch’ command is used to update the access and modification times of a file in UNIX.


5. Which command is used to create a new directory in UNIX?

a) touch

b) mkdir

c) mkfile

d) newdir

Answer: b) mkdir

Explanation: The ‘mkdir’ command is used to create a new directory in UNIX.


6. What does the ‘rm’ command do in UNIX?

a) Rename a file

b) Remove a file

c) Read from a file

d) Write to a file

Answer: b) Remove a file

Explanation: The ‘rm’ command is used to remove or delete a file in UNIX.


7. Which command is used to move files or directories in UNIX?

a) move

b) mv

c) cp

d) rename

Answer: b) mv

Explanation: The ‘mv’ command is used to move files or directories in UNIX.


8. What does the ‘cp’ command do in UNIX?

a) Copy files or directories

b) Move files or directories

c) Rename files or directories

d) Change file permissions

Answer: a) Copy files or directories

Explanation: The ‘cp’ command is used to copy files or directories in UNIX.


9. Which command is used to create a new file in UNIX?

a) makefile

b) create

c) touch

d) newfile

Answer: c) touch

Explanation: The ‘touch’ command is used to create a new file in UNIX.


10. What does the ‘rmdir’ command do in UNIX?

a) Remove a file

b) Rename a file

c) Remove an empty directory

d) Read from a file

Answer: c) Remove an empty directory

Explanation: The ‘rmdir’ command is used to remove an empty directory in UNIX.


11. Which command is used to list the contents of a directory including hidden files in UNIX?

a) ls -h

b) ls -a

c) ls -l

d) ls -r

Answer: b) ls -a

Explanation: The ‘ls’ command with the ‘-a’ option is used to list the contents of a directory including hidden files in UNIX.


12. What does the ‘mv’ command do in UNIX?

a) Move files or directories

b) Make a new directory

c) Modify file permissions

d) Merge files

Answer: a) Move files or directories

Explanation: The ‘mv’ command is used to move files or directories in UNIX.


13. Which command is used to create a new directory in UNIX?

a) create

b) mkdir

c) newdir

d) touch

Answer: b) mkdir

Explanation: The ‘mkdir’ command is used to create a new directory in UNIX.


14. What does the ‘rm’ command do in UNIX?

a) Remove a file

b) Rename a file

c) Read from a file

d) Write to a file

Answer: a) Remove a file

Explanation: The ‘rm’ command is used to remove or delete a file in UNIX.


15. Which command is used to copy files or directories in UNIX?

a) cp

b) mv

c) cpdir

d) copy

Answer: a) cp

Explanation: The ‘cp’ command is used to copy files or directories in UNIX.


16. What does the ‘mkdir’ command do in UNIX?

a) Rename a directory

b) Remove a directory

c) Create a new directory

d) Display the contents of a directory

Answer: c) Create a new directory

Explanation: The ‘mkdir’ command is used to create a new directory in UNIX.


17. Which command is used to navigate to the home directory in UNIX?

a) cd home

b) cd /

c) cd ~

d) cd ..

Answer: c) cd ~

Explanation: The ‘cd ~’ command is used to navigate to the home directory in UNIX.


18. What does the ‘cd ..’ command do in UNIX?

a) Change to the root directory

b) Change to the parent directory

c) Change to the previous directory

d) Change to the home directory

Answer: b) Change to the parent directory

Explanation: The ‘cd ..’ command is used to change to the parent directory in UNIX.


19. Which command is used to create a symbolic link in UNIX?

a) ln -s

b) link

c) sym

d) lnk

Answer: a) ln -s

Explanation: The ‘ln -s’ command is used to create a symbolic link in UNIX.


20. What does the ‘touch’ command do in UNIX?

a) Create a new directory

b) Change file permissions

c) Update the access and modification times of a file

d) Display the contents of a file

Answer: c) Update the access and modification times of a file

Explanation: The ‘touch’ command is used to update the access and modification times of a file in UNIX.


21. Which command is used to remove a directory in UNIX?

a) rmdir

b) rm -r

c) rd

d) remove

Answer: a) rmdir

Explanation: The ‘rmdir’ command is used to remove a directory in UNIX.


22. What does the ‘pwd’ command do in UNIX?

a) Print working directory

b) Print file permissions

c) Print file contents

d) Print file size

Answer: a) Print working directory

Explanation: The ‘pwd’ command is used to print the current working directory in UNIX.


23. Which command is used to remove a file in UNIX?

a) delete

b) rm

c) del

d) remove

Answer: b) rm

Explanation: The ‘rm’ command is used to remove or delete a file in UNIX.


24. What does the ‘ls -l’ command do in UNIX?

a) List files with long format

b) List files in a long listing format

c) List files with detailed information

d) List files in a single column format

Answer: b) List files in a long listing format

Explanation: The ‘ls -l’ command is used to list files in a long listing format in UNIX.


25. Which command is used to rename a file in UNIX?

a) rename

b) move

c) mv

d) cp

Answer: c) mv

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


26. Which command is used to list the contents of a directory in long format along with hidden files in UNIX?

a) ls -lh

b) ls -la

c) ls -al

d) ls -lr

Answer: b) ls -la

Explanation: The ‘ls -la’ command is used to list the contents of a directory in long format along with hidden files in UNIX.


27. What does the ‘cd’ command do when executed without any arguments in UNIX?

a) Changes to the root directory

b) Changes to the previous directory

c) Stays in the current directory

d) Changes to the home directory

Answer: d) Changes to the home directory

Explanation: When executed without any arguments, the ‘cd’ command changes to the home directory in UNIX.


28. Which command is used to display detailed information about a file or directory in UNIX?

a) info

b) stats

c) dir

d) stat

Answer: d) stat

Explanation: The ‘stat’ command is used to display detailed information about a file or directory in UNIX.


29. What does the ‘touch’ command do when used with a filename that does not exist in UNIX?

a) Creates a new file

b) Modifies the access time of the file

c) Throws an error message

d) Changes file permissions

Answer: a) Creates a new file

Explanation: When used with a filename that does not exist, the ‘touch’ command creates a new file in UNIX.


30. Which command is used to remove a directory along with its contents in UNIX?

a) rmdir

b) rm -rf

c) del

d) remove

Answer: b) rm -rf

Explanation: The ‘rm -rf’ command is used to remove a directory along with its contents forcefully in UNIX.


31. What does the ‘mv’ command do when used to move a file to a directory that does not exist in UNIX?

a) Moves the file and creates the directory

b) Throws an error message

c) Moves the file to the parent directory

d) Renames the file

Answer: b) Throws an error message

Explanation: When used to move a file to a directory that does not exist, the ‘mv’ command throws an error message in UNIX.


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

a) mdir

b) mkdir -p

c) newdir

d) mkd

Answer: b) mkdir -p

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


33. What does the ‘cd ..’ command do when executed multiple times in UNIX?

a) Changes to the root directory

b) Stays in the current directory

c) Moves to the parent directory

d) Moves to the home directory

Answer: c) Moves to the parent directory

Explanation: The ‘cd ..’ command moves to the parent directory in UNIX.


34. Which command is used to copy files preserving their attributes and permissions in UNIX?

a) cp -a

b) cp -p

c) cp -r

d) cp -f

Answer: a) cp -a

Explanation: The ‘cp -a’ command is used to copy files preserving their attributes and permissions in UNIX.


35. What does the ‘rmdir’ command do when used with a non-empty directory in UNIX?

a) Removes the directory along with its contents

b) Throws an error message

c) Removes the directory if it is empty

d) Moves the contents to the parent directory

Answer: b) Throws an error message

Explanation: The ‘rmdir’ command throws an error message when used with a non-empty directory in UNIX.

Related Articles

Linux MCQ

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