






























































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 command is used to search for a specific string within files in a directory and its subdirectories? A) find B) grep - r C) sed D) diff Answer: B Explanation: The grep - r command recursively searches for a string in all files under a directory. Question 2. What does the command find /home - type f - name ".txt" do? A) Finds all directories in /home ending with .txt B) Finds all files in /home with .txt extension C) Deletes all .txt files in /home D) Lists the content of .txt files Answer: B Explanation: find /home - type f - name ".txt" searches for files (type f) in /home ending with .txt. Question 3. Which command can be used to compare the contents of two files line by line? A) grep B) diff C) sed D) awk Answer: B Explanation: The diff command compares files line by line and outputs the differences. Question 4. How do you replace all occurrences of the word "cloud" with "linux" in file.txt using sed? A) sed 's/linux/cloud/g' file.txt B) sed 's/cloud/linux/g' file.txt C) sed 'cloud/linux/g' file.txt
D) sed 'linux/cloud/g' file.txt Answer: B Explanation: In sed, s/old/new/g replaces "old" with "new" globally in each line. Question 5. Which character is used to redirect the output of a command to a file, overwriting the file? A) >> B) < C) > D) | Answer: C Explanation: The > operator overwrites the file with the output of the command. Question 6. What is the result of the command cat file1 | grep error? A) It deletes lines containing "error" in file B) It prints lines containing "error" from file C) It writes "error" into file D) It renames file1 to error Answer: B Explanation: The command pipes the content of file1 to grep, which filters lines containing "error". Question 7. Which regular expression matches any line that starts with "user"? A) user$ B) ^user C) user* D) *user Answer: B Explanation: ^ anchors the match to the start of the line in regular expressions. Question 8. What does the command tar - czvf backup.tar.gz /home/user do?
Answer: B Explanation: chown user:group file sets the owner and group. Question 12. What does chmod g+w file.txt do? A) Adds write permission to the group B) Removes write permission from the group C) Adds write permission to the owner D) Adds write permission to others Answer: A Explanation: g+w adds write permission for the group. Question 13. Which package manager is used in Ubuntu systems? A) yum B) dnf C) apt D) zypper Answer: C Explanation: apt is the main package manager for Debian-based (like Ubuntu) systems. Question 14. How do you install a package named nginx on a CentOS system? A) apt install nginx B) yum install nginx C) zypper install nginx D) dnf install nginx Answer: B Explanation: yum is commonly used on CentOS for package management. Question 15. Which file lists filesystems to be mounted at boot? A) /etc/mtab
B) /etc/fstab C) /etc/passwd D) /etc/shadow Answer: B Explanation: /etc/fstab specifies filesystems to mount at boot. Question 16. What command is used to show disk space usage of all mounted filesystems? A) du - sh B) df - h C) lsblk D) fdisk - l Answer: B Explanation: df - h displays disk space usage in human-readable format. Question 17. How do you create a new user account named "alice"? A) addgroup alice B) useradd alice C) groupadd alice D) chown alice Answer: B Explanation: useradd creates a new user account. Question 18. Which command changes the password for the current user? A) passwd B) usermod C) chsh D) chgrp Answer: A Explanation: passwd prompts for the new password for the user.
D) timedate Answer: B Explanation: date displays the current date and time. Question 23. What is the function of NTP in Linux? A) Network file transfer B) Network time synchronization C) Network protocol translation D) Network performance testing Answer: B Explanation: NTP (Network Time Protocol) keeps system time synchronized across networks. Question 24. How do you display all network interfaces and their IP addresses? A) netstat - i B) ifconfig - a C) route - n D) ip link show Answer: B Explanation: ifconfig - a lists all network interfaces and their details. Question 25. Which file is used for local hostname resolution? A) /etc/resolv.conf B) /etc/hostname C) /etc/hosts D) /etc/network/interfaces Answer: C Explanation: /etc/hosts maps hostnames to IP addresses locally. Question 26. How do you restart the NetworkManager service on a systemd-based Linux?
A) service network restart B) systemctl restart NetworkManager C) /etc/init.d/network restart D) networkctl restart Answer: B Explanation: systemctl restart NetworkManager restarts the service. Question 27. Which command shows currently running processes? A) ps aux B) jobs C) top D) Both A and C Answer: D Explanation: Both ps aux and top display running processes. Question 28. How can you kill a process with PID 1234? A) kill 1234 B) stop 1234 C) end 1234 D) terminate 1234 Answer: A Explanation: kill PID sends a signal to terminate the process. Question 29. Which signal is sent by default using the kill command? A) SIGKILL B) SIGHUP C) SIGTERM D) SIGSTOP Answer: C
C) meminfo D) top - h Answer: A Explanation: free - h displays memory usage in human-readable form. Question 34. How can you see kernel ring buffer messages? A) dmesg B) journalctl - k C) Both A and B D) uname - a Answer: C Explanation: Both dmesg and journalctl - k show kernel messages. Question 35. What is the default Docker network driver? A) host B) bridge C) overlay D) macvlan Answer: B Explanation: By default, Docker uses the bridge network driver for containers. Question 36. Which command lists all running Docker containers? A) docker images B) docker ps C) docker run D) docker container create Answer: B Explanation: docker ps lists all running containers.
Question 37. How do you start a stopped Docker container with ID abc123? A) docker run abc B) docker restart abc C) docker start abc D) docker up abc Answer: C Explanation: docker start is used for stopped containers. Question 38. Which tool is used for managing virtual machines in a cloud environment and for instance initialization? A) virt-manager B) cloud-init C) qemu D) docker Answer: B Explanation: cloud-init is commonly used for cloud VM initialization. Question 39. What is the main purpose of container orchestration systems like Kubernetes? A) Creating VMs B) Managing and scaling containers C) Managing user accounts D) Managing disk partitions Answer: B Explanation: Orchestration systems manage deployment, scaling, and networking of containers. Question 40. Which command initializes a new Git repository? A) git new B) git start C) git init
A) To initialize a repository B) To propose changes for review and merging C) To delete a repository D) To clone a repository Answer: B Explanation: Pull requests are used for code review and merging contributions. Question 45. Which command lists the commit history in Git? A) git status B) git log C) git history D) git commits Answer: B Explanation: git log shows the commit history. Question 46. What is the main advantage of GitOps in infrastructure management? A) Manual configuration B) Configuration as code and automation C) Disabling automation D) Enabling direct server changes Answer: B Explanation: GitOps allows infrastructure management via code and automation. Question 47. What command is used to run a command on multiple remote hosts using SSH? A) ssh-copy B) for HOST in ...; do ssh $HOST command; done C) ping HOST D) sshd Answer: B
Explanation: Looping over hosts in shell can automate remote command execution. Question 48. Which command counts the number of lines containing "error" in file.log? A) grep - c error file.log B) grep error file.log C) wc - l error file.log D) sed - n error file.log Answer: A Explanation: grep - c returns the count of matching lines. Question 49. How do you append the output of a command to a file? A) > B) >> C) < D) | Answer: B Explanation: >> appends output to a file without overwriting. Question 50. Which command is used to extract files from a tar archive? A) tar - czvf B) tar - xvf C) tar - tvf D) tar - uvf Answer: B Explanation: tar - xvf extracts files from a tar archive. Question 51. What is the effect of the command chmod o-rwx file.txt? A) Removes read, write, execute permissions for others B) Adds read, write, execute permissions for others
Question 55. Which command gives a summary of CPU usage by processes? A) ps aux B) top C) free D) iostat Answer: B Explanation: top shows live CPU usage per process. Question 56. How can you display the last 20 lines of a log file? A) head - n 20 logfile B) tail - n 20 logfile C) less logfile D) cat logfile Answer: B Explanation: tail - n 20 prints the last 20 lines of a file. Question 57. Which command searches for a running process by name? A) ps - ef | grep processname B) find processname C) grep processname /etc/passwd D) ls processname Answer: A Explanation: Piping ps output to grep finds matching process names. Question 58. What does the command hostnamectl do? A) Changes the hostname B) Displays or modifies system hostname and info C) Lists all hostnames D) Restarts network
Answer: B Explanation: hostnamectl is used for querying and setting the hostname. Question 59. Which file stores DNS server addresses for name resolution? A) /etc/hosts B) /etc/resolv.conf C) /etc/hostname D) /etc/nsswitch.conf Answer: B Explanation: /etc/resolv.conf lists DNS servers to use. Question 60. How do you reload systemd unit files after making changes? A) systemctl reload B) systemctl daemon-reload C) systemctl restart D) systemctl update Answer: B Explanation: systemctl daemon-reload reloads unit files. Question 61. Which command lists all enabled systemd services? A) systemctl list-units --type=service --state=enabled B) systemctl status C) service --list D) ps aux Answer: A Explanation: This lists only enabled services. Question 62. How can you force a mounted filesystem to unmount? A) unmount - f
Question 66. Which tool can be used to monitor real-time system logs? A) tail - f /var/log/syslog B) less /var/log/syslog C) cat /var/log/syslog D) grep /var/log/syslog Answer: A Explanation: tail - f follows the log file in real time. Question 67. Which command will display filesystem usage in a human-readable format? A) du - h B) df - h C) Both A and B D) ls - lh Answer: C Explanation: Both df - h and du - h provide human-readable output. Question 68. How do you add a user to a supplementary group? A) usermod - aG group user B) groupadd user group C) adduser group user D) groupmod - a user group Answer: A Explanation: usermod - aG appends the user to the group. Question 69. Which command will display the UUIDs of all filesystems? A) blkid B) lsblk - f C) Both A and B
D) fdisk - l Answer: C Explanation: Both can display UUIDs for filesystems. Question 70. How do you make a script file executable? A) chmod +x script.sh B) sh script.sh C) run script.sh D) chmod 744 script.sh Answer: A Explanation: chmod +x adds execute permission. Question 71. Which command shows the last login of all users? A) last B) who C) w D) users Answer: A Explanation: last displays login history. Question 72. What is the function of the /etc/sudoers file? A) Stores user passwords B) Configures user privileges for sudo C) Lists all system users D) Configures system services Answer: B Explanation: /etc/sudoers controls sudo access. Question 73. How do you display the IP routing table?