
































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

































Table of Contents Section I: Linux System Architecture (Questions 1–20)
Correct Answer: B Explanation: fork() creates a new process (the child) that is an exact copy of the calling process (the parent), except for the process ID (PID). The exec() family of calls is used to replace the process image with a new program. Q8. Which directory contains device special files such as /dev/sda and /dev/tty? A) /proc B) /sys C) /dev D) /etc Correct Answer: C Explanation: The /dev directory contains device special files that represent hardware components. For example, /dev/sda represents the first SATA/SCSI hard disk, and /dev/tty represents a terminal device. Q9. Which command shows the absolute path of the current working directory? A) ls B) cd C) pwd D) dir Correct Answer: C Explanation: pwd (print working directory) displays the full absolute path of the directory you are currently in. ls lists directory contents, cd changes directories, and dir is a legacy/Windows-style command. Q10. Which of the following commands displays the first 10 lines of a file by default? A) cat B) tail C) head D) less Correct Answer: C Explanation: head displays the first 10 lines of a file by default. cat displays the entire file. tail displays the last 10 lines. less is a pager for interactive viewing. Q11. What does the command find ~ - name '.pdf' accomplish? A) Finds all .pdf files in the current directory only B) Finds all .pdf files in the root directory C) Finds all .pdf files in the user's home directory and all subdirectories D) Searches for the text ".pdf" inside all files Correct Answer: C Explanation: The tilde (~) represents the user's home directory. The - name '.pdf' predicate matches
files ending with .pdf. The find command searches recursively by default within the specified starting directory. Q12. Which command creates an archive file named backup.tar containing all files from /home? A) tar - cf backup.tar /home B) tar - cf /home backup.tar C) tar - xf backup.tar /home D) tar - xf /home backup.tar Correct Answer: A Explanation: The - c flag creates a new archive, and - f specifies the archive filename. The correct syntax is tar - cf archive_name.tar directory_to_archive. The - x flag is for extraction, not creation. Q13. Which directory is commonly used for temporary files that are typically cleared on reboot? A) /var B) /tmp C) /etc D) /bin Correct Answer: B Explanation: The /tmp directory holds temporary files. Many distributions clear /tmp on reboot or via periodic cleanup. /var holds variable data (logs, spools), /etc contains configuration files, and /bin contains essential user binaries. Q14. Which file contains detailed information about the system's CPU(s), including model, speed, and cache size? A) /proc/meminfo B) /proc/cpuinfo C) /proc/version D) /proc/uptime Correct Answer: B Explanation: /proc/cpuinfo contains per-processor details such as model name, clock speed, and cache size. /proc/meminfo shows memory statistics, /proc/version shows kernel version, and /proc/uptime shows system uptime. Q15. Which command is used to change file ownership? A) chmod B) chown C) chgrp D) passwd
Correct Answer: C Explanation: To correctly prepend a directory to PATH and make it available to child processes, you must use export. The syntax export PATH=/new/dir:$PATH preserves the existing path and adds the new directory at the front. Option A sets the variable but does not export it to child processes. Q20. Which command is used to search for all lines in a file that contain a specific pattern, ignoring case? A) grep - i pattern file B) less - i pattern file C) find pattern file D) cut pattern file Correct Answer: A Explanation: grep - i performs a case-insensitive search. grep is the standard text-search tool. less is a pager, find searches for files (not text within files), and cut extracts columns/sections from lines. Section II: Installation and Package Management Questions 21– 40 Q21. Which package management tool is used on Red Hat-based Linux systems? A) apt-get B) rpm C) dpkg D) portage Correct Answer: B Explanation: Red Hat-based distributions (RHEL, CentOS, Fedora) use RPM (Red Hat Package Manager) as their low-level package format and tool. apt-get and dpkg are Debian/Ubuntu tools. portage is used by Gentoo. Q22. On an Ubuntu system, which file contains the addresses of software repositories? A) /etc/yum/yum.conf B) /etc/dnf/dnf.conf C) /etc/apt/sources.list D) /etc/rpm/repos.d Correct Answer: C Explanation: Ubuntu uses the APT package manager. Repository addresses are defined in /etc/apt/sources.list and files under /etc/apt/sources.list.d/. The other options belong to Red Hat-based systems (YUM/DNF). Q23. Which command installs a package named nginx on a Debian-based system? A) rpm - ivh nginx B) apt install nginx
C) yum install nginx D) dnf install nginx Correct Answer: B Explanation: apt (or apt-get) is the package management command for Debian-based systems. rpm, yum, and dnf are used on Red Hat-based systems. Q24. Which command removes a package named apache2 along with its configuration files on a Debian system? A) apt remove apache B) apt purge apache C) apt delete apache D) apt uninstall apache Correct Answer: B Explanation: apt remove removes the package but leaves configuration files. apt purge removes the package and its configuration files. There is no apt delete or apt uninstall command. Q25. What is the primary purpose of a package manager? A) To compile source code into binaries B) To automate the installation, upgrade, configuration, and removal of software C) To create user accounts D) To manage network connections Correct Answer: B Explanation: A package manager automates the process of installing, upgrading, configuring, and removing software packages. It handles dependencies and verifies package integrity. Q26. Which directory contains documentation and example configuration files for installed software packages? A) /etc/defaults/ B) /var/info/ C) /usr/share/doc/ D) /usr/examples/ Correct Answer: C Explanation: /usr/share/doc/ contains documentation, README files, and example configuration files for installed packages. /etc contains system configuration files, not package documentation. Q27. Which command searches for available packages matching the name python on a Debian system? A) apt search python B) apt find python C) apt list python D) apt locate python
Q32. Which command lists all installed packages on a Debian system? A) apt list --installed B) dpkg - l C) Both A and B D) apt show --all Correct Answer: C Explanation: Both apt list --installed and dpkg - l list installed packages. dpkg - l provides a detailed listing with status codes. apt list --installed provides a more concise listing. Q33. What is a repository in the context of Linux package management? A) A local cache of downloaded packages B) A central location (server or directory) from which packages are retrieved C) A configuration file for the kernel D) A type of filesystem Correct Answer: B Explanation: A repository is a storage location (typically a remote server) from which package managers retrieve packages and metadata. It may also be a local directory on the filesystem. Q34. Which command shows detailed information about an installed package named openssh- server on a Debian system? A) apt info openssh-server B) apt show openssh-server C) dpkg info openssh-server D) Both A and B Correct Answer: D Explanation: Both apt info and apt show display detailed package information including version, dependencies, and description. dpkg uses - s (status), not info, for installed package details. Q35. Which file on a Red Hat-based system contains repository configuration? A) /etc/apt/sources.list B) /etc/yum.repos.d/ C) /etc/rpm.conf D) /etc/repos.conf Correct Answer: B Explanation: On Red Hat-based systems, repository configuration files are stored in /etc/yum.repos.d/ with .repo extensions. /etc/apt/sources.list is used on Debian-based systems. Q36. What does the dpkg - i package.deb command do? A) Installs a Debian package file from the local filesystem B) Downloads and installs a package from a repository
C) Removes a Debian package D) Lists installed Debian packages Correct Answer: A Explanation: dpkg - i installs a .deb package file directly from the filesystem. It does not resolve dependencies automatically. For dependency resolution, apt install ./package.deb is preferred. Q37. Which command checks for and fixes broken package dependencies on a Debian system? A) apt check B) apt install - f C) dpkg --repair D) apt fix-deps Correct Answer: B Explanation: apt install - f (or apt-get install - f) attempts to fix broken dependencies by installing missing packages or removing conflicting ones. Q38. Which of the following are characteristics of a Long Term Support (LTS) Linux distribution? (Choose two.) A) It receives security updates for an extended period (often 5+ years) B) It is updated with new major features every 6 months C) It prioritizes stability over bleeding-edge software D) It is only available for enterprise customers Correct Answer: A, C Explanation: LTS distributions such as Ubuntu LTS and RHEL provide extended security updates and prioritize stability. They do not receive frequent major feature updates (that is the model for rolling or short-term releases) and are available to all users, not only enterprises. Q39. Which command removes packages that are no longer needed (orphaned dependencies) on a Debian system? A) apt clean B) apt autoremove C) apt remove --orphans D) dpkg --purge-orphans Correct Answer: B Explanation: apt autoremove removes packages that were installed as dependencies but are no longer required by any installed package. apt clean only clears the local package cache. Q40. What is the purpose of the --no-install-recommends option with apt install? A) It prevents installation of recommended but non-essential packages B) It skips the installation confirmation prompt C) It installs packages without checking dependencies D) It forces reinstallation of an already-installed package
another. export-logs | sort passes the log output to sort for ordering. Redirection (>) writes to a file, not another command. Q45. Which command appends the output of a command to an existing file without overwriting it? A) > B) >> C) < D) | Correct Answer: B Explanation: The >> operator redirects standard output in append mode. The single > operator truncates and overwrites the target file. < redirects input, and | pipes output to another command. Q46. What is the purpose of grep - i pattern file? A) Inverts the match B) Counts matching lines C) Ignores case when matching D) Prints only the filename Correct Answer: C Explanation: The - i option makes grep case-insensitive, so pattern, Pattern, and PATTERN all match. - v inverts the match, - c counts lines, and - l prints only filenames. Q47. Which command extracts the second field from a colon-delimited file? A) cut - d: - f2 file B) cut - f: - d2 file C) awk - F2 : file D) sed - d: 2 file Correct Answer: A Explanation: cut - d: sets the delimiter to colon, and - f2 selects the second field. awk could accomplish the same with awk - F: '{print $2}', but the given awk syntax is incorrect. sed is a stream editor, not a field extractor in this form. Q48. Which command counts the number of lines in a file? A) wc - l file B) wc - w file C) wc - c file D) count file Correct Answer: A Explanation: wc - l counts lines. - w counts words, and - c counts bytes. There is no standard count command.
Q49. Which command displays the last 20 lines of a file and follows new additions in real time? A) tail - n 20 file B) tail - f - n 20 file C) head - f - n 20 file D) less +F file Correct Answer: B Explanation: tail - f follows the file as it grows. Combined with - n 20, it starts by showing the last 20 lines and then continues to display new lines. head cannot follow. less +F is an alternative but does not match the exact tail syntax requested. Q50. Which command creates a tar archive named backup.tar from the /home directory? A) tar - cf backup.tar /home B) tar - xf backup.tar /home C) tar - cf /home backup.tar D) tar - tf backup.tar /home Correct Answer: A Explanation: - c creates an archive, - f specifies the archive filename. The syntax is tar - cf archive.tar directory. - x extracts, and - t lists contents. Q51. Which command compresses a file using gzip and removes the original file by default? A) gzip file B) gzip - k file C) gunzip file D) zip file Correct Answer: A Explanation: gzip file compresses file to file.gz and removes the original by default. - k (keep) preserves the original. gunzip decompresses. zip creates a ZIP archive and does not remove the original. Q52. What does command1 && command2 do? A) Runs command1 and command2 in parallel B) Runs command2 only if command1 succeeds C) Runs command1 only if command2 succeeds D) Pipes command1 output to command Correct Answer: B Explanation: The && operator is a logical AND for exit statuses. command2 executes only if command1 returns exit status 0 (success). The ; separator runs commands unconditionally, and || runs the second only on failure. Q53. Which command displays the absolute path of the current working directory?
Correct Answer: B Explanation: rmdir removes empty directories only. rm dir fails on directories without - r. del and removedir are not standard Linux commands. Q58. What does chmod 755 file set? A) rwxr-xr-x B) rw-r--r-- C) rwxrwxrwx D) r-xr-xr-x Correct Answer: A Explanation: 7 = rwx for owner, 5 = r-x for group, 5 = r-x for others. The result is rwxr-xr-x. This is a common permission for executables and directories. Q59. What does chmod u+x script.sh do? A) Removes execute permission from the owner B) Adds execute permission for the file owner C) Changes the file owner D) Makes the script invisible to other users Correct Answer: B Explanation: In symbolic mode, u means user/owner, + adds, and x is execute. This grants the owner execute permission, allowing them to run the script. Q60. Which command changes the owner of a file to alice? A) chmod alice file B) chown alice file C) chgrp alice file D) passwd alice file Correct Answer: B Explanation: chown changes file ownership. chmod changes permissions, chgrp changes group, and passwd manages passwords. Q61. What is the numeric equivalent of rw-r--r--? A) 755 B) 644 C) 600 D) 777 Correct Answer: B Explanation: rw- = 4+2 = 6, r-- = 4, r-- = 4. Combined: 644. This is the standard permission for regular files that should be readable by all but writable only by the owner.
Q62. Which command displays the first 10 lines of a file? A) cat B) tail C) head D) less Correct Answer: C Explanation: head displays the first 10 lines by default. tail displays the last 10. cat displays the entire file. less is an interactive pager. Q63. Which command finds all .pdf files in the user's home directory and subdirectories? A) find ~ - name ".pdf" B) find. - name ".pdf" C) find / - name ".pdf" D) find ~ - type pdf Correct Answer: A Explanation: ~ expands to the user's home directory. - name ".pdf" matches files ending in .pdf. Option B searches the current directory, not home. Option C searches the entire filesystem. Option D uses an invalid - type value. Q64. What does the export command do in a shell? A) Exports variables to child processes B) Exports files to a remote server C) Exports command history to a log D) Exports the current directory Correct Answer: A Explanation: export marks a shell variable for inclusion in the environment of child processes. Without export, a variable is local to the current shell and not inherited by commands it launches. Q65. Which command adds /new/dir to the PATH variable? A) PATH=/new/dir:$PATH B) export PATH=$PATH:/new/dir C) export PATH=/new/dir:$PATH D) set PATH=/new/dir:$PATH Correct Answer: C Explanation: export makes the variable available to child processes. Placing /new/dir: before $PATH prepends the new directory. Option A sets the variable but does not export it. Option B appends rather than prepends. Option D uses incorrect syntax. Section III: GNU and Unix Commands (Continued) Q66. Which command displays the manual page for the passwd command? A) help passwd B) man passwd
Q71. What does command1 || command2 do? A) Runs command1 and command2 in parallel B) Runs command2 only if command1 fails C) Runs command1 only if command2 succeeds D) Pipes command1 output to command Correct Answer: B Explanation: The || operator is a logical OR for exit statuses. command2 executes only if command returns a non-zero (failure) exit status. && is the logical AND operator. Q72. Which command changes to the home directory of the current user? A) cd .. B) cd ~ C) cd / D) cd - Correct Answer: B Explanation: ~ expands to the current user's home directory. .. is the parent directory, / is the root directory, and - switches to the previous directory. Q73. Which command moves a file named report.txt to the /archive directory? A) cp report.txt /archive B) mv report.txt /archive C) rm report.txt /archive D) ln report.txt /archive Correct Answer: B Explanation: mv moves or renames files. cp copies, rm removes, and ln creates links. Q74. Which command removes a non-empty directory named project and all its contents? A) rmdir project B) rm - r project C) rm project D) del project Correct Answer: B Explanation: rm - r removes directories recursively, including contents. rmdir only removes empty directories. rm project fails on non-empty directories. del is not a standard Linux command. Q75. What does chmod 644 file set? A) rwxr--r-- B) rw-r--r--
C) rw-rw-rw- D) r--r--r-- Correct Answer: B Explanation: 6 = rw- for owner, 4 = r-- for group, 4 = r-- for others. The result is rw-r--r--, the standard permission for regular files. Q76. What does chmod g-w file do? A) Adds write permission for the group B) Removes write permission from the group C) Changes group ownership D) Removes all permissions from the group Correct Answer: B Explanation: In symbolic mode, g means group, - removes, and w is write. This removes write permission from the group while leaving other permissions unchanged. Q77. Which command displays the last 20 lines of a log file and continues to follow new entries? A) tail - n 20 logfile B) tail - f - n 20 logfile C) head - f - n 20 logfile D) less +20 logfile Correct Answer: B Explanation: tail - f follows the file as it grows. Combined with - n 20, it starts with the last 20 lines and then displays new additions in real time. Q78. Which command extracts a gzip-compressed tar archive named backup.tar.gz? A) tar - cf backup.tar.gz B) tar - xf backup.tar.gz C) tar - tf backup.tar.gz D) gzip - d backup.tar.gz Correct Answer: B Explanation: tar - xf extracts an archive. Modern tar auto-detects gzip compression. - c creates, - t lists contents, and gzip - d decompresses only the gzip layer without extracting the tar archive. Q79. Which command is used to search for a string within a file and display matching lines? A) find B) grep C) locate D) which Correct Answer: B Explanation: grep searches text within files and displays matching lines. find and locate search for files by name or metadata. which locates executables in the PATH.