UNIX MCQs – UNIX Architecture (Part – 2)

1. In UNIX, what system call is used to create a new file?

a) open()

b) create()

c) makefile()

d) touch()

Answer

Answer: a) open()

Explanation: The open() system call is used to create a new file or open an existing one.

2. Which command is used to list 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 lists all files, including hidden ones, in UNIX.


3. What is the primary role of the shell in UNIX?

a) File management

b) Memory management

c) Process management

d) User interaction and command execution

Answer: d) User interaction and command execution

Explanation: The shell provides an interface for users to interact with the system and execute commands.


4. Which UNIX command is used to display the contents of a file starting from the end?

a) head

b) tail

c) more

d) less

Answer: b) tail

Explanation: The tail command displays the last part of a file by default in UNIX.


5. What UNIX system call is used to write data to a file?

a) read()

b) write()

c) append()

d) save()

Answer: b) write()

Explanation: The write() system call is used to write data to a file in UNIX.


6. Which command is used to search for occurrences of a pattern in files?

a) grep

b) find

c) locate

d) search

Answer: a) grep

Explanation: The grep command is used to search for occurrences of a pattern in files in UNIX.


7. What is the purpose of the fork() system call in UNIX?

a) Create a new process

b) Terminate the current process

c) Read data from a file

d) Write data to a file

Answer: a) Create a new process

Explanation: The fork() system call creates a new process by duplicating the existing one.


8. Which command is used to display the manual pages for a specific command in UNIX?

a) help

b) man

c) info

d) doc

Answer: b) man

Explanation: The man command displays the manual pages for a specific command in UNIX.


9. What UNIX system call is used to close a file descriptor?

a) close()

b) shutdown()

c) stop()

d) end()

Answer: a) close()

Explanation: The close() system call is used to close a file descriptor in UNIX.


10. Which command is used to rename files in UNIX?

a) move

b) rename

c) mv

d) cp

Answer: c) mv

Explanation: The mv command is used to rename files or move them to a different location in UNIX.


11. What is the function of the chmod command in UNIX?

a) Change file ownership

b) Change file permissions

c) Change file attributes

d) Change file location

Answer: b) Change file permissions

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


12. Which command is used to display the process status in UNIX?

a) ps

b) top

c) status

d) process

Answer: a) ps

Explanation: The ps command is used to display the process status in UNIX.


13. What UNIX system call is used to change the current working directory to the root directory?

a) chroot()

b) cdroot()

c) rootdir()

d) chdir()

Answer: a) chroot()

Explanation: The chroot() system call is used to change the current working directory to the root directory in UNIX.


14. Which command is used to display the environment variables in UNIX?

a) echo

b) env

c) set

d) vars

Answer: b) env

Explanation: The env command is used to display the environment variables in UNIX.


15. What is the primary role of the inode in UNIX?

a) Represent a directory entry

b) Store file data and metadata

c) Provide access control for files and directories

d) Represent a process in memory

Answer: b) Store file data and metadata

Explanation: An inode in UNIX stores information about a file, including its data blocks and metadata.


16. Which command is used to set or display the file creation mask in UNIX?

a) chmod

b) umask

c) chmask

d) mask

Answer: b) umask

Explanation: The umask command is used to set or display the file creation mask in UNIX.


17. What UNIX system call is used to change the access and modification times of a file?

a) touch()

b) time()

c) utime()

d) mtime()

Answer: c) utime()

Explanation: The utime() system call is used to change the access and modification times of a file in UNIX.


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

a) ln -s

b) link -s

c) sym

d) lnk

Answer: a) ln -s

Explanation: The ln command with the -s option is used to create symbolic links in UNIX.


19. What is the purpose of the lseek() system call in UNIX?

a) Read from a file

b) Write to a file

c) Move the file offset

d) Close a file

Answer: c) Move the file offset

Explanation: The lseek() system call is used to move the file offset in UNIX.


20. Which command is used to set or display file timestamps in UNIX?

a) touch

b) time

c) settime

d) timestamp

Answer: a) touch

Explanation: The touch command is used to set or display file timestamps in UNIX.


21. What is the purpose of the exec() system call in UNIX?

a) Create a new process

b) Replace the current process with a new program

c) Read data from a file

d) Write data to a file

Answer: b) Replace the current process with a new program

Explanation: The exec() system call is used to replace the current process with a new program in UNIX.


22. Which command is used to create a new hard link in UNIX?

a) ln

b) link

c) mklink

d) hardlink

Answer: a) ln

Explanation: The ln command is used to create hard links in UNIX.


23. What is the function of the fclose() function in UNIX?

a) Open a file

b) Close a file

c) Read from a file

d) Write to a file

Answer: b) Close a file

Explanation: The fclose() function is used to close a file in UNIX.


24. Which command is used to view the contents of a file one page at a time in UNIX?

a) cat

b) more

c) less

d) tail

Answer: b) more

Explanation: The more command is used to view the contents of a file one page at a time in UNIX.


25. What is the purpose of the mkdir command in UNIX?

a) Display the contents of a directory

b) Create a new directory

c) Remove a directory

d) Rename a directory

Answer: b) Create a new directory

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


26. In UNIX, which command is used to change the ownership of a file?

a) chown

b) chmod

c) chgrp

d) own

Answer: a) chown

Explanation: The chown command is used to change the ownership of a file in UNIX.


27. What is the purpose of the readlink() system call in UNIX?

a) Create a symbolic link

b) Read the contents of a file

c) Read the value of a symbolic link

d) Write data to a file

Answer: c) Read the value of a symbolic link

Explanation: The readlink() system call is used to read the value of a symbolic link in UNIX.


28. Which command is used to display the process ID of the current shell session in UNIX?

a) pid

b) getpid

c) echo

d)ps−p∗∗

Answer:c)echo**

Explanation: The echo $$ command displays the process ID (PID) of the current shell session in UNIX.


29. What is the primary role of the mount command in UNIX?

a) Create a new file system

b) Mount a file system

c) Unmount a file system

d) Check file system integrity

Answer: b) Mount a file system

Explanation: The mount command is used to attach a file system to the system’s directory tree in UNIX.


30. In UNIX, what is the purpose of the umount command?

a) Create a new file system

b) Mount a file system

c) Unmount a file system

d) Check file system integrity

Answer: c) Unmount a file system

Explanation: The umount command is used to detach a mounted file system in UNIX.


31. Which command is used to display the current system time in UNIX?

a) clock

b) time

c) date

d) systemtime

Answer: c) date

Explanation: The date command is used to display the current system time and date in UNIX.


32. What is the function of the mknod command in UNIX?

a) Create a new file

b) Create a new directory

c) Create a special file

d) Create a symbolic link

Answer: c) Create a special file

Explanation: The mknod command is used to create special files, such as device files, in UNIX.


33. Which command is used to display the amount of free and used memory in the system in UNIX?

a) mem

b) free

c) top

d) ps

Answer: b) free

Explanation: The free command is used to display the amount of free and used memory in the system in UNIX.


34. What is the purpose of the sync command in UNIX?

a) Synchronize system clocks

b) Synchronize file system buffers with disk

c) Synchronize user sessions

d) Synchronize network connections

Answer: b) Synchronize file system buffers with disk

Explanation: The sync command is used to flush file system buffers to disk, ensuring data integrity in UNIX.


35. Which command is used to display the routing table in UNIX?

a) route

b) netstat

c) ifconfig

d) arp

Answer: a) route

Explanation: The route command is used to display or manipulate the IP routing table in UNIX.


36. What is the purpose of the grep command in UNIX?

a) Search for files

b) Search for text patterns in files

c) Display file permissions

d) Display file contents

Answer: b) Search for text patterns in files

Explanation: The grep command is used to search for text patterns in files in UNIX.


37. Which command is used to display information about currently logged-in users in UNIX?

a) users

b) who

c) w

d) last

Answer: b) who

Explanation: The who command is used to display information about currently logged-in users in UNIX.


38. What is the purpose of the chsh command in UNIX?

a) Change shell

b) Change ownership of a file

c) Change file permissions

d) Change file attributes

Answer: a) Change shell

Explanation: The chsh command is used to change the login shell for a user in UNIX.


39. Which command is used to display information about CPU usage in UNIX?

a) cpu

b) top

c) ps

d) load

Answer: b) top

Explanation: The top command is used to display real-time information about CPU usage and running processes in UNIX.


40. What is the function of the mkfifo command in UNIX?

a) Create a regular file

b) Create a special file

c) Create a directory

d) Create a named pipe

Answer: d) Create a named pipe

Explanation: The mkfifo command is used to create a named pipe, also known as a FIFO (first in, first out), in UNIX.


41. Which command is used to display information about disk usage in UNIX?

a) du

b) df

c) disk

d) space

Answer: b) df

Explanation: The df command is used to display information about disk usage and available disk space in UNIX.


42. What is the purpose of the renice command in UNIX?

a) Rename a file

b) Change the priority of a running process

c) Change file permissions

d) Change file ownership

Answer: b) Change the priority of a running process

Explanation: The renice command is used to change the priority of a running process in UNIX.


43. Which command is used to display information about system processes in UNIX?

a) ps

b) top

c) pstree

d) process

Answer: a) ps

Explanation: The ps command is used to display information about system processes, including their IDs, states, and resource usage, in UNIX.


44. What is the purpose of the shutdown command in UNIX?

a) Restart the system

b) Power off the system

c) Close user sessions

d) Hibernate the system

Answer: b) Power off the system

Explanation: The shutdown command is used to gracefully power off or reboot the system in UNIX.


45. Which command is used to display information about file system inode usage in UNIX?

a) inodes

b) ls

c) df

d) stat

Answer: a) inodes

Explanation: The inodes command is used to display information about file system inode usage in UNIX.


46. What is the purpose of the syslogd daemon in UNIX?

a) Manage user sessions

b) Manage system logs

c) Manage network connections

d) Manage file permissions

Answer: b) Manage system logs

Explanation: The syslogd daemon is responsible for managing system logs in UNIX.


47. Which command is used to display information about system memory and swap usage in UNIX?

a) meminfo

b) swapinfo

c) free

d) top

Answer: c) free

Explanation: The free command is used to display information about system memory and swap usage in UNIX.


48. What is the purpose of the fsck command in UNIX?

a) Mount a file system

b) Unmount a file system

c) Check and repair file system integrity

d) Create a new file system

Answer: c) Check and repair file system integrity

Explanation: The fsck command is used to check and repair file system integrity in UNIX.


49. Which command is used to display the list of open files and processes that have them open in UNIX?

a) files

b) open

c) lsof

d) fstat

Answer: c) lsof

Explanation: The lsof command is used to display the list of open files and processes that have them open in UNIX.


50. What is the purpose of the kill command in UNIX?

a) Kill a process

b) Remove a file

c) Change file permissions

d) Rename a file

Answer: a) Kill a process

Explanation: The kill command is used to terminate or send signals to processes in UNIX.

Related Articles

Linux MCQ

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