UNIX MCQs โ€“ Software Management (Part โ€“ 2)

UNIX Question and Answer โ€“ Software Management

UNIX MCQ โ€“ Multiple Choice Questions for exam, interview, and Entrance Test

1. Which command is used to reinstall all installed packages in Debian-based distributions?

a) apt reinstall

b) apt-get reinstall

c) apt-get install โ€“reinstall $(dpkg โ€“get-selections | awk โ€˜{print $1}โ€™)

d) apt-get update โ€“reinstall

Answer: c) apt-get install โ€“reinstall $(dpkg โ€“get-selections | awk โ€˜{print $1}โ€™)

Explanation: This command reinstalls all installed packages in Debian-based distributions.


2. What is the purpose of the โ€œyum history undoโ€ command in CentOS?

a) Reverts the most recent transaction

b) Reverts all transactions

c) Reverts a specific transaction

d) Reverts package installations

Answer: a) Reverts the most recent transaction

Explanation: The โ€œyum history undoโ€ command reverts the most recent transaction in CentOS.


3. Which command is used to downgrade a package to a specific version in Arch Linux?

a) pacman -U package-version

b) pacman -S package-version

c) pacman -U $(pacman -Q | awk โ€˜{print $1}โ€™)

d) pacman -S โ€“force package-name

Answer: a) pacman -U package-version

Explanation: The โ€œpacman -U package-versionโ€ command downgrades a package to a specific version in Arch Linux.


4. What is the purpose of the โ€œdnf swapโ€ command in Fedora?

a) Swaps package versions

b) Swaps package repositories

c) Swaps package groups

d) Swaps package formats

Answer: a) Swaps package versions

Explanation: The โ€œdnf swapโ€ command swaps package versions in Fedora.


5. Which command is used to clean the package cache in Debian-based distributions?

a) apt clean

b) apt-get clean

c) apt purge

d) apt-get purge

Answer: b) apt-get clean

Explanation: The โ€œapt-get cleanโ€ command is used to clean the package cache in Debian-based distributions.


6. What is the purpose of the โ€œdnf autoremoveโ€ command in Fedora?

a) Removes unused packages

b) Removes outdated packages

c) Removes broken packages

d) Removes conflicting packages

Answer: a) Removes unused packages

Explanation: The โ€œdnf autoremoveโ€ command removes unused packages in Fedora.


7. Which command is used to display the files installed by a package in Fedora?

a) rpm -ql package-name

b) rpm -qf file-path

c) dnf list installed

d) dnf repoquery โ€“list package-name

Answer: d) dnf repoquery โ€“list package-name

Explanation: The โ€œdnf repoquery โ€“list package-nameโ€ command displays the files installed by a package in Fedora.


8. What does the command โ€œrpm -Uvh package.rpmโ€ do in CentOS?

a) Installs a package

b) Upgrades a package

c) Uninstalls a package

d) Verifies a package

Answer: b) Upgrades a package

Explanation: The โ€œrpm -Uvh package.rpmโ€ command upgrades a package in CentOS.


9. Which command is used to display the dependencies of a package in Fedora?

a) dnf repoquery โ€“requires package-name

b) dnf repoquery โ€“depends package-name

c) dnf repoquery โ€“provides package-name

d) dnf repoquery โ€“obsoletes package-name

Answer: a) dnf repoquery โ€“requires package-name

Explanation: The โ€œdnf repoquery โ€“requires package-nameโ€ command displays the dependencies of a package in Fedora.


10. What is the purpose of the โ€œdnf swap-allโ€ command in Fedora?

a) Swaps all installed packages

b) Swaps all repositories

c) Swaps all package versions

d) Swaps all package groups

Answer: c) Swaps all package versions

Explanation: The โ€œdnf swap-allโ€ command swaps all package versions in Fedora.


11. Which command is used to list all available package groups in Arch Linux?

a) pacman -Sg

b) pacman -Qg

c) pacman -Qgq

d) pacman -Qqg

Answer: a) pacman -Sg

Explanation: The โ€œpacman -Sgโ€ command lists all available package groups in Arch Linux.


12. What does the command โ€œpacman -Scโ€ do in Arch Linux?

a) Removes cached packages

b) Removes old package versions

c) Cleans package cache

d) Checks for package updates

Answer: c) Cleans package cache

Explanation: The โ€œpacman -Scโ€ command cleans the package cache in Arch Linux.


13. Which command is used to search for a package in Arch Linux?

a) pacman -Ss

b) pacman -Si

c) pacman -Qs

d) pacman -Q

Answer: a) pacman -Ss

Explanation: The โ€œpacman -Ssโ€ command is used to search for a package in Arch Linux.


14. What is the purpose of the โ€œpacman -Qdtโ€ command in Arch Linux?

a) Lists all installed packages

b) Lists orphaned packages

c) Lists dependencies of a package

d) Lists packages not required by any other package

Answer: b) Lists orphaned packages

Explanation: The โ€œpacman -Qdtโ€ command lists orphaned packages in Arch Linux.


15. Which command is used to list installed packages by size in Arch Linux?

a) pacman -Qi

b) pacman -Sl

c) pacman -Qs

d) pacman -Qii

Answer: a) pacman -Qi

Explanation: The โ€œpacman -Qiโ€ command lists installed packages by size in Arch Linux.


16. What does the command โ€œyum makecacheโ€ do in CentOS?

a) Refreshes metadata for enabled repositories

b) Cleans metadata and cache

c) Rebuilds RPM database

d) Installs missing dependencies

Answer: a) Refreshes metadata for enabled repositories

Explanation: The โ€œyum makecacheโ€ command refreshes metadata for enabled repositories in CentOS.


17. Which command is used to enable a repository in Fedora?

a) dnf enable repository-name

b) dnf config-manager โ€“enable repository-name

c) dnf repo-enable repository-name

d) dnf set-repo repository-name โ€“enable

Answer: b) dnf config-manager โ€“enable repository-name

Explanation: The โ€œdnf config-manager โ€“enable repository-nameโ€ command enables a repository in Fedora.


18. What is the purpose of the โ€œdnf downgradeโ€ command in Fedora?

a) Downgrades installed packages to a specific version

b) Removes outdated packages

c) Reverts system to a previous state

d) Updates installed packages

Answer: a) Downgrades installed packages to a specific version

Explanation: The โ€œdnf downgradeโ€ command downgrades installed packages to a specific version in Fedora.


19. Which command is used to list enabled repositories in CentOS?

a) yum repolist

b) yum list enabled

c) yum repository-list

d) yum show-repos

Answer: a) yum repolist

Explanation: The โ€œyum repolistโ€ command lists enabled repositories in CentOS.


20. What does the command โ€œdnf repoquery โ€“whatprovidesโ€ do in Fedora?

a) Lists packages provided by a repository

b) Lists repositories provided by a package

c) Lists packages that provide a specific file

d) Lists repositories that provide a specific package

Answer: c) Lists packages that provide a specific file

Explanation: The โ€œdnf repoquery โ€“whatprovidesโ€ command lists packages that provide a specific file in Fedora.


21. Which command is used to display the currently active repositories in Arch Linux?

a) pacman -Qqg

b) pacman -Sl

c) pacman -Qm

d) pacman -Sy

Answer: b) pacman -Sl

Explanation: The โ€œpacman -Slโ€ command displays the currently active repositories in Arch Linux.


22. What is the purpose of the โ€œpacman -U package-fileโ€ command in Arch Linux?

a) Installs a package

b) Upgrades a package

c) Downgrades a package

d) Removes a package

Answer: a) Installs a package

Explanation: The โ€œpacman -U package-fileโ€ command installs a package in Arch Linux.


23. Which command is used to list all installed packages in Fedora?

a) dnf list installed

b) dnf list

c) dnf list installed | grep โ€œInstalledโ€

d) dnf repoquery โ€“installed

Answer: d) dnf repoquery โ€“installed

Explanation: The โ€œdnf repoquery โ€“installedโ€ command lists all installed packages in Fedora.


24. What does the command โ€œdnf remove โ€“orphansโ€ do in Fedora?

a) Removes outdated packages

b) Removes orphaned packages

c) Removes conflicting packages

d) Removes unused packages

Answer: b) Removes orphaned packages

Explanation: The โ€œdnf remove โ€“orphansโ€ command removes orphaned packages in Fedora.


25. Which command is used to install a package in Arch Linux from the Arch User Repository (AUR)?

a) pacman -U package-name

b) pacman -S package-name

c) yaourt -S package-name

d) yay -S package-name

Answer: d) yay -S package-name

Explanation: The โ€œyay -S package-nameโ€ command installs a package from the AUR in Arch Linux.


26. Which command is used to list all installed packages in CentOS?

a) yum list installed

b) yum list

c) yum list installed | grep โ€œInstalledโ€

d) yum repoquery โ€“installed

Answer: a) yum list installed

Explanation: The โ€œyum list installedโ€ command lists all installed packages in CentOS.


27. What does the command โ€œdnf module listโ€ do in Fedora?

a) Lists all available modules

b) Lists installed modules

c) Lists enabled modules

d) Lists disabled modules

Answer: a) Lists all available modules

Explanation: The โ€œdnf module listโ€ command lists all available modules in Fedora.


28. Which command is used to enable a service in systemd?

a) systemctl enable

b) systemctl start

c) systemctl enable-service

d) systemctl start-service

Answer: a) systemctl enable

Explanation: The โ€œsystemctl enableโ€ command is used to enable a service in systemd.


29. What is the purpose of the โ€œsystemctl statusโ€ command in systemd?

a) Starts a service

b) Stops a service

c) Restarts a service

d) Displays the status of a service

Answer: d) Displays the status of a service

Explanation: The โ€œsystemctl statusโ€ command displays the status of a service in systemd.


30. Which command is used to reload systemd configuration without restarting?

a) systemctl reload

b) systemctl reload-service

c) systemctl restart

d) systemctl daemon-reload

Answer: d) systemctl daemon-reload

Explanation: The โ€œsystemctl daemon-reloadโ€ command is used to reload systemd configuration without restarting.


31. What does the command โ€œjournalctlโ€ do in systemd?

a) Lists all active services

b) Displays system logs

c) Displays journal files

d) Modifies journal settings

Answer: b) Displays system logs

Explanation: The โ€œjournalctlโ€ command displays system logs in systemd.


32. Which command is used to list all available unit files in systemd?

a) systemctl list-units

b) systemctl list-services

c) systemctl list-all

d) systemctl list-unit-files

Answer: d) systemctl list-unit-files

Explanation: The โ€œsystemctl list-unit-filesโ€ command lists all available unit files in systemd.


33. What is the purpose of the โ€œsystemctl maskโ€ command in systemd?

a) Stops a service and prevents it from being started manually

b) Disables a service and prevents it from being started automatically

c) Enables a service and allows it to be started automatically

d) Reloads systemd configuration without restarting

Answer: a) Stops a service and prevents it from being started manually

Explanation: The โ€œsystemctl maskโ€ command stops a service and prevents it from being started manually in systemd.


34. Which directory contains unit files in systemd?

a) /etc/systemd/system

b) /etc/systemd/units

c) /usr/lib/systemd/system

d) /usr/share/systemd/units

Answer: c) /usr/lib/systemd/system

Explanation: Unit files in systemd are located in the โ€œ/usr/lib/systemd/systemโ€ directory.


35. What does the command โ€œsystemctl isolateโ€ do in systemd?

a) Switches to a different target

b) Starts a specific service

c) Stops a specific service

d) Reloads systemd configuration

Answer: a) Switches to a different target

Explanation: The โ€œsystemctl isolateโ€ command switches to a different target in systemd.


36. Which command is used to list active units in systemd?

a) systemctl list-units

b) systemctl list-active

c) systemctl list-services

d) systemctl list-all

Answer: a) systemctl list-units

Explanation: The โ€œsystemctl list-unitsโ€ command is used to list active units in systemd.


37. What is the purpose of the โ€œsystemctl unmaskโ€ command in systemd?

a) Enables a masked service

b) Disables a masked service

c) Reloads systemd configuration

d) Starts a masked service

Answer: a) Enables a masked service

Explanation: The โ€œsystemctl unmaskโ€ command enables a masked service in systemd.


38. Which command is used to list failed units in systemd?

a) systemctl list-failed

b) systemctl list-units โ€“failed

c) systemctl list-errors

d) systemctl list-status

Answer: b) systemctl list-units โ€“failed

Explanation: The โ€œsystemctl list-units โ€“failedโ€ command is used to list failed units in systemd.


39. What is the purpose of the โ€œsystemctl catโ€ command in systemd?

a) Displays the contents of a unit file

b) Modifies the contents of a unit file

c) Creates a new unit file

d) Deletes a unit file

Answer: a) Displays the contents of a unit file

Explanation: The โ€œsystemctl catโ€ command displays the contents of a unit file in systemd.


40. Which command is used to reload the systemd journal?

a) systemctl reload-journal

b) systemctl restart-journald

c) journalctl โ€“flush

d) journalctl โ€“reload

Answer: d) journalctl โ€“reload

Explanation: The โ€œjournalctl โ€“reloadโ€ command is used to reload the systemd journal.


41. What does the command โ€œsystemctl rebootโ€ do in systemd?

a) Shuts down the system

b) Restarts the system

c) Puts the system in hibernation

d) Puts the system in sleep mode

Answer: b) Restarts the system

Explanation: The โ€œsystemctl rebootโ€ command restarts the system in systemd.


42. Which command is used to enable persistent journal logging in systemd?

a) systemctl enable-persistence

b) systemctl enable-journal

c) systemctl enable-logging

d) systemctl enable systemd-journald.service

Answer: d) systemctl enable systemd-journald.service

Explanation: The โ€œsystemctl enable systemd-journald.serviceโ€ command is used to enable persistent journal logging in systemd.


43. What is the purpose of the โ€œjournalctl โ€“vacuum-sizeโ€ command in systemd?

a) Cleans up old journal files until the disk space used by the journal is below a specified size

b) Deletes all journal files

c) Increases the size limit of the journal

d) Compresses journal files to save disk space

Answer: a) Cleans up old journal files until the disk space used by the journal is below a specified size

Explanation: The โ€œjournalctl โ€“vacuum-sizeโ€ command cleans up old journal files until the disk space used by the journal is below a specified size in systemd.


44. Which command is used to display the dependency tree of a unit in systemd?

a) systemctl show

b) systemctl list-dependencies

c) systemctl list-unit-dependencies

d) systemctl list-transitive-dependencies

Answer: b) systemctl list-dependencies

Explanation: The โ€œsystemctl list-dependenciesโ€ command is used to display the dependency tree of a unit in systemd.


45. What does the command โ€œsystemctl poweroffโ€ do in systemd?

a) Shuts down the system

b) Restarts the system

c) Puts the system in hibernation

d) Puts the system in sleep mode

Answer: a) Shuts down the system

Explanation: The โ€œsystemctl poweroffโ€ command shuts down the system in systemd.


46. Which command is used to disable a service in systemd?

a) systemctl disable

b) systemctl stop

c) systemctl disable-service

d) systemctl stop-service

Answer: a) systemctl disable

Explanation: The โ€œsystemctl disableโ€ command is used to disable a service in systemd.


47. What is the purpose of the โ€œsystemctl isolate rescue.targetโ€ command in systemd?

a) Switches to rescue mode

b) Switches to emergency mode

c) Switches to multi-user target

d) Switches to graphical target

Answer: a) Switches to rescue mode

Explanation: The โ€œsystemctl isolate rescue.targetโ€ command switches to rescue mode in systemd.


48. Which command is used to reload the systemd target without restarting?

a) systemctl reload

b) systemctl reload-target

c) systemctl restart

d) systemctl daemon-reload

Answer: d) systemctl daemon-reload

Explanation: The โ€œsystemctl daemon-reloadโ€ command is used to reload the systemd target without restarting.


49. What does the command โ€œsystemctl list-jobsโ€ do in systemd?

a) Lists all active jobs

b) Lists failed jobs

c) Lists queued jobs

d) Lists completed jobs

Answer: c) Lists queued jobs

Explanation: The โ€œsystemctl list-jobsโ€ command lists queued jobs in systemd.


50. Which directory contains unit override files in systemd?

a) /etc/systemd/system

b) /etc/systemd/overrides

c) /etc/systemd/user

d) /etc/systemd/systemd.conf.d

Answer: a) /etc/systemd/system

Explanation: Unit override files in systemd are located in the โ€œ/etc/systemd/systemโ€ directory.

Related Articles