In a shell script, if you want a loop to execute infinitely, which of the following would be the most appropriate construct?

  • while true; do
  • for (( ; ; )); do
  • until false; do
  • do forever;
The most appropriate construct for an infinite loop in a shell script is while true; do. This creates a loop that continues to execute as long as the condition true remains true, effectively resulting in an infinite loop.

A colleague informs you that they're unable to access a service on a remote server. You suspect it might be a firewall issue. How would you list the current firewall rules to diagnose the issue?

  • iptables -L
  • firewall-cmd --list-all
  • ufw status
  • netstat -an
To list the current firewall rules on a Linux system using iptables, you can use the command iptables -L. This command will display the current firewall rules, allowing you to diagnose potential issues and ensure that the necessary ports are open for the service your colleague is trying to access.

When you want to continue to the next iteration of a loop without executing the subsequent commands in the current iteration, you use the __________ command.

  • continue
  • break
  • exit
  • return
When you want to continue to the next iteration of a loop without executing the subsequent commands in the current iteration, you use the **continue** command. It allows you to skip the current iteration and proceed to the next iteration of the loop.

Which column in the top command output represents the percentage of CPU usage for a process?

  • %CPU
  • %MEM
  • PID
  • COMMAND
In the top command output, the %CPU column represents the percentage of CPU usage for each process. This column shows the proportion of CPU resources that a process is currently utilizing.

Which file in Linux is used to set the hostname and the order in which the system resolves addresses?

  • /etc/hostname
  • /etc/hosts
  • /etc/resolv.conf
  • /etc/networks
The /etc/hosts file is used to set the hostname and the order in which the system resolves addresses. It contains mappings of IP addresses to hostnames and can be used to define the local system's hostname.

The command used to resize the filesystem on a partition in Linux is _________.

  • resize2fs
  • mv
  • chmod
  • cp
The command used to resize the filesystem on a partition in Linux is resize2fs. This command is used after resizing a partition to adjust the filesystem to use the newly available space.

A user reports that their application occasionally freezes. You suspect it's due to the application waiting for some I/O operations to complete. Which state might the process be in during these freezes?

  • D (Uninterruptible Sleep)
  • R (Running)
  • S (Sleeping)
  • Z (Zombie)
During an I/O operation, a process might enter the "D" state, which stands for Uninterruptible Sleep. This state indicates that the process is waiting for a resource to become available, and it cannot be interrupted. It's often associated with I/O-related delays or problems.

The __________ command in Linux allows mounting of NFS shared directories.

  • mount
  • nfs
  • fstab
  • showmount
The mount command in Linux allows mounting of NFS (Network File System) shared directories. You can use this command to make remote file systems accessible on your local system through NFS.

To iterate over a range of numbers in a loop, one might use the seq command combined with the _________ loop.

  • for
  • while
  • until
  • numeric
To iterate over a range of numbers in a loop, one might use the seq command combined with the for loop. The seq command generates a sequence of numbers, and the "for" loop can be used to loop through these numbers, allowing you to perform actions on each number within the specified range. This is a common technique in shell scripting for tasks like counting or iterating through numerical data.

How do you denote the start of a block of code in a Bash if statement?

  • then
  • start
  • begin
  • do
In a Bash if statement, you denote the start of a block of code with the keyword then. This is where the code to be executed if the condition is true begins. It's important to follow then with the code that should be executed when the condition is met.