




















































































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!





















































































Question 1. Which component of a Linux system provides the interface between hardware and software? A) Shell B) Kernel C) Init system D) Package manager Answer: B Explanation: The kernel is the core of the OS that communicates directly with hardware and provides services to user-space programs. Question 2. In a GRUB configuration file, which directive sets the default boot entry? A) timeout B) default C) title D) root Answer: B Explanation: The default line tells GRUB which menu entry to boot automatically if no user input occurs. Question 3. Which runlevel (or systemd target) corresponds to multi-user mode without a graphical interface? A) runlevel 3 / multi-user.target B) runlevel 5 / graphical.target C) runlevel 1 / rescue.target D) runlevel 0 / poweroff.target
Answer: A Explanation: Traditional SysV runlevel 3 and the systemd multi-user.target provide a full multi-user environment without X. Question 4. What does the pwd command display? A) Current user’s password file B) Present working directory path C) Process working data D) Permissions of the working directory Answer: B Explanation: pwd prints the absolute pathname of the directory you are currently in. Question 5. Which command recursively copies a directory and preserves attributes? A) cp -r B) cp -a C) mv -R D) rsync -a Answer: B Explanation: cp -a (archive) copies recursively and retains ownership, timestamps, and symlinks. Question 6. Which of the following commands is used to view the manual page for a command? A) help ls B) info ls
Answer: B Explanation: >> adds the command’s standard output to the end of the target file without overwriting. Question 10. What does the following pipeline do? ps aux | grep httpd A) Starts the httpd service B) Shows all processes containing “httpd” in their command line C) Terminates all httpd processes D) Counts the number of httpd processes Answer: B Explanation: ps aux lists processes; grep httpd filters lines that contain the string “httpd”. Question 11. Which option for grep makes the search case-insensitive? A) -i B) -v C) -c D) -n Answer: A Explanation: -i tells grep to ignore case when matching patterns. Question 12. To locate all files named “report.txt” under /home, which command is appropriate? A) find /home -name report.txt
B) locate report.txt /home C) grep -r report.txt /home D) ls -R /home | report.txt Answer: A Explanation: find searches directory trees; -name matches the exact filename. Question 13. What is the purpose of the tee command? A) To edit files interactively B) To duplicate input to both a file and standard output C) To compress data streams D) To terminate a pipeline Answer: B Explanation: tee reads from standard input and writes to both a file and the screen. Question 14. Which line adds an alias ll for ls -lAh in a Bash session? A) alias ll='ls -lAh' B) set ll='ls -lAh' C) export ll='ls -lAh' D) function ll { ls -lAh } Answer: A Explanation: alias name='command' defines a shortcut for the current shell. Question 15. Which environment variable determines where the shell looks for executable files?
Question 18. To install the package htop on a RHEL-based system, which command is correct? A) apt install htop B) yum install htop C) pacman -S htop D) emerge htop Answer: B Explanation: yum (or dnf on newer RHEL) installs RPM packages. Question 19. Which file stores local user account information such as username and UID? A) /etc/shadow B) /etc/passwd C) /etc/group D) /etc/login.defs Answer: B Explanation: /etc/passwd contains user names, UIDs, GIDs, home directories, and shells. Question 20. Where are encrypted password hashes kept on most Linux systems? A) /etc/passwd B) /etc/group C) /etc/shadow D) /etc/login.defs Answer: C
Explanation: /etc/shadow holds the hashed passwords and aging information, readable only by root. Question 21. Which command creates a new group named devops? A) useradd devops B) groupadd devops C) addgroup devops D) mkgroup devops Answer: B Explanation: groupadd adds a new group to the system; addgroup is a Debian wrapper but groupadd is universal. Question 22. To change a user’s default shell to /bin/bash, which command is appropriate? A) chsh -s /bin/bash username B) usermod -s /bin/bash username C) passwd -s /bin/bash username D) setenv SHELL /bin/bash username Answer: B Explanation: usermod -s sets the login shell for an existing user. Question 23. Which file defines sudo privileges for the group wheel? A) /etc/sudoers B) /etc/group C) /etc/passwd D) /etc/sudoers.d/wheel
Answer: C Explanation: Default file mode is 666; subtract umask 027 → 640 (rw-r-----). Question 27. Which process state is indicated by the letter “Z” in the output of ps? A) Running B) Sleeping C) Zombie D) Stopped Answer: C Explanation: “Z” denotes a zombie process—a terminated child whose parent hasn’t reaped it. Question 28. Which command sends the SIGTERM signal to process ID 1234? A) kill -9 1234 B) kill -15 1234 C) kill -SIGTERM 1234 D) Both B and C Answer: D Explanation: -15 and -SIGTERM are equivalent; both send the termination signal. Question 29. To display a continuously updating view of system processes, which command is used? A) ps -ef
B) top C) htop D) Both B and C Answer: D Explanation: Both top and the more user-friendly htop provide real-time process monitoring. Question 30. Which niceness value makes a process run with the lowest possible priority? A) - B) 0 C) 19 D) 20 Answer: C Explanation: Niceness ranges from -20 (highest priority) to 19 (lowest). Higher numbers mean lower priority. Question 31. Which command lists all open network sockets on the system? A) lsof -i B) netstat -tuln C) ss -tuln D) All of the above Answer: D Explanation: lsof -i, netstat -tuln, and ss -tuln each display open sockets; all are valid.
Question 35. What is an inode in Linux? A) A type of user account B) A data structure storing metadata about a file C) A network interface D) A bootloader configuration entry Answer: B Explanation: An inode holds file attributes (owner, permissions, timestamps) and pointers to data blocks. Question 36. Which pathname is absolute? A) ./scripts/run.sh B) ../etc/passwd C) /usr/local/bin/python D) bin/ls Answer: C Explanation: An absolute path starts with “/” and references the root directory. Question 37. Which command creates a gzipped tar archive named backup.tar.gz of /home/user? A) tar -czf backup.tar.gz /home/user B) tar -cvf backup.tar.gz /home/user C) gzip -c /home/user > backup.tar.gz D) zip -r backup.tar.gz /home/user Answer: A
Explanation: -c creates, -z compresses with gzip, and -f specifies the archive name. Question 38. To extract the contents of archive.tar.bz2 into the current directory, which command is correct? A) tar -xjf archive.tar.bz B) tar -xzf archive.tar.bz C) unzip archive.tar.bz D) gunzip -c archive.tar.bz2 | tar -xvf - Answer: A Explanation: -j tells tar to use bzip2 decompression. Question 39. Which command schedules a job to run at 02:30 AM every day? A) at 02:30 /path/script.sh B) cron 02:30 * * * /path/script.sh C) echo "0 2 * * * /path/script.sh" >> /etc/crontab D) crontab -e and add 30 2 * * * /path/script.sh Answer: D Explanation: In a user’s crontab, the minute comes first; 30 2 * * * runs at 02: daily. Question 40. Which utility runs a command once at a specified future time and then exits? A) cron B) at C) batch
C) Ctrl-b % D) Ctrl-b & Answer: A Explanation: Ctrl-b is the default prefix; c creates a new window. Question 44. Which log file typically contains kernel messages on a Debian system? A) /var/log/messages B) /var/log/syslog C) /var/log/kern.log D) /var/log/dmesg Answer: B Explanation: Debian writes most system and kernel messages to /var/log/syslog. (On Red Hat it’s /var/log/messages.) Question 45. Which command rotates logs according to the configuration in /etc/logrotate.conf? A) logrotate /etc/logrotate.conf B) rotate-logs C) syslogd -r D) journalctl --rotate Answer: A Explanation: logrotate processes the configuration file and rotates logs as defined. Question 46. Which command shows the last 100 lines of a file and continues to display new lines as they are added?
A) tail -n 100 -f /var/log/auth.log B) head -n 100 -f /var/log/auth.log C) less +F /var/log/auth.log D) Both A and C Answer: D Explanation: tail -f follows the file; less +F also follows in “follow” mode. Question 47. Which shebang line invokes the Bash interpreter? A) #!/bin/sh B) #!/usr/bin/env bash C) #!/bin/bash D) Both B and C Answer: D Explanation: Both /usr/bin/env bash (portable) and /bin/bash directly start Bash. Question 48. In a Bash script, how do you reference the third positional argument? A) $ B) $[3] C) ${3} D) Both A and C Answer: D Explanation: $3 and ${3} are equivalent; they expand to the third argument. Question 49. Which quoting style prevents variable expansion in Bash?
Question 52. Which systemd command displays the status of the ssh service? A) systemctl status sshd.service B) service ssh status C) systemctl is-active sshd D) Both A and C Answer: D Explanation: systemctl status gives a full status; is-active returns “active”/“inactive”. Question 53. To enable a service to start automatically at boot, which command is used? A) systemctl enable httpd B) systemctl start httpd C) chkconfig httpd on D) Both A and C (depending on distro) Answer: D Explanation: systemctl enable works on systemd; older SysV systems use chkconfig. Question 54. Which unit type in systemd represents a mount point? A) .service B) .mount C) .target D) .socket Answer: B Explanation: .mount unit files describe filesystem mounts.
Question 55. In systemd, what does the Requires= directive indicate? A) The unit must start after the listed unit B) The listed unit must be active for this unit to start C) The listed unit is a dependency that will be stopped when this unit stops D) It defines a socket activation relationship Answer: B Explanation: Requires= creates a strong dependency; if the required unit fails, the dependent unit will not start. Question 56. Which command creates a custom systemd service file for /usr/local/bin/cleanup.sh? A) nano /etc/systemd/system/cleanup.service B) systemctl create cleanup.service C) touch /etc/init.d/cleanup D) systemd-run cleanup.service Answer: A Explanation: Custom unit files are placed under /etc/systemd/system/ and edited with a text editor. Question 57. Which MySQL command dumps all databases to a file named all.sql? A) mysqldump -A > all.sql B) mysqldump --all-databases > all.sql C) mysql -u root -e "dump all" > all.sql D) Both A and B