You are writing a Bash script to automate server maintenance. You want to check if a directory exists before trying to create it. Which command would you use within your script to check for the directory's existence?

  • if [ -d "$directory" ]
  • if [ -e "$directory" ]
  • if [ -f "$directory" ]
  • if [ -s "$directory" ]
The correct command to check if a directory exists in a Bash script is if [ -d "$directory" ]. This condition tests whether the given directory path, represented by $directory, exists as a directory. Option 2 -e checks for the existence of any file or directory, not specifically a directory. Option 3 -f checks for regular files, and Option 4 -s checks if the file has a size greater than zero.

If you want to shift the positional parameters to the left, which command would you use?

  • shift
  • mv
  • leftshift
  • change
The correct answer is a) shift. The 'shift' command is used in shell scripts to shift the positional parameters to the left. When you use 'shift' without an argument, it discards the value of $1 and shifts the rest of the positional parameters, updating $1 to the previous $2, $2 to the previous $3, and so on. This is useful when processing command-line arguments.

Which built-in variable in a shell script would you use to determine the number of positional parameters?

  • $#
  • $@
  • $*
  • $$
To determine the number of positional parameters passed to a shell script, you would use the built-in variable $#. It represents the count of arguments supplied to the script.

Which SSH configuration parameter specifies the maximum number of authentication attempts allowed per connection?

  • MaxLoginAttempts
  • MaxAuthTries
  • AuthMaxRetries
  • LoginAttempts
The SSH configuration parameter that specifies the maximum number of authentication attempts allowed per connection is MaxAuthTries. It can be set in the SSH server configuration file (sshd_config) to enhance security by limiting the number of failed login attempts.

Docker primarily deals with which kind of virtualization?

  • Containerization
  • Hypervisor-based virtualization
  • Paravirtualization
  • Emulation
Docker primarily deals with containerization, which is a lightweight form of virtualization. Containers share the host OS kernel, making them efficient and suitable for packaging and running applications.

What is the primary purpose of the chmod command in Linux?

  • Changing file permissions
  • Creating new directories
  • Deleting files
  • Displaying file contents
The primary purpose of the chmod command in Linux is to change file permissions. It allows you to modify the access permissions of files and directories. You can use it to control who can read, write, and execute a particular file or directory.

The _________ special variable in a shell script provides an option for random number generation.

  • $RANDOM
  • $PID
  • $USER
  • $HOME
The $RANDOM special variable in a shell script provides an option for random number generation. You can use $RANDOM to generate random integers within a specific range. It's commonly used for tasks like creating random passwords or simulating randomness in scripts.

A system administrator wants to dynamically alter the kernel's behavior without rebooting. What feature of the Linux kernel allows for this?

  • Sysctl
  • init.d
  • Kernel Modules
  • Udev
The Sysctl feature allows a system administrator to dynamically alter the kernel's behavior without rebooting. It provides a way to modify kernel parameters at runtime, making it a powerful tool for fine-tuning system behavior.

Which operator would you use in Bash to check if two strings are equal?

  • =
  • ==
  • #NAME?
  • equals
In Bash, to check if two strings are equal, you use the == operator. It is used in conditional statements to compare two strings. Remember to enclose the strings in double square brackets for the comparison, like [[ string1 == string2 ]].

What is the primary distinction between top and htop when monitoring system processes?

  • top is a basic system monitoring tool, while htop is an advanced alternative.
  • top displays real-time data, while htop provides more interactivity and customization.
  • top is text-based, while htop offers a graphical interface.
  • top shows memory usage, while htop focuses on CPU usage.
The primary distinction between top and htop is that top displays real-time data about system processes, whereas htop provides more interactivity and customization. htop allows users to sort and filter processes, view detailed information, and easily send signals to processes directly from the interface. While both tools show similar information, htop offers a more user-friendly and feature-rich experience for process monitoring.