You've written a script that processes a list of files. You want to ensure that even if a filename contains spaces, it's treated as a single argument. Which built-in variable should you modify?
- IFS (Internal Field Separator)
- PS1 (Prompt String 1)
- OIFS (Original Internal Field Separator)
- FS (Field Separator)
To ensure that filenames with spaces are treated as single arguments in a script, you should modify the OIFS (Original Internal Field Separator) variable. This allows you to temporarily change the IFS value to a specific character (e.g., newline) and then restore it to its original value after processing the filenames. This ensures that spaces don't break the filenames into multiple arguments.
Which file in the /proc directory can be inspected to gather information about the system's CPU?
- /proc/cpuinfo
- /proc/meminfo
- /proc/filesystems
- /proc/sys/kernel
The /proc/cpuinfo file in the /proc directory is used to gather information about the system's CPU. It provides details about the processor, including its model, speed, and features. This is a valuable resource for understanding the CPU's capabilities and characteristics.
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.
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.
In Linux, services that are set to restart automatically after a failure are said to be "_________".
- Resilient
- Autorestart
- Persistent
- Robust
In Linux, services that are set to restart automatically after a failure are said to be "Autorestart." This feature ensures that critical services can recover from failures and continue running, enhancing system reliability and availability.
Which loop in shell scripting tests the condition before executing the body of the loop?
- while
- for
- until
- do-while
The while loop in shell scripting tests the condition before executing the body of the loop. It will repeatedly execute the loop body as long as the specified condition remains true.
What is the primary keyword to start a loop that will iterate a fixed number of times in shell scripting?
- for
- while
- repeat
- loop
The primary keyword to start a loop that will iterate a fixed number of times in shell scripting is for. The for loop allows you to specify the number of iterations and is commonly used for such purposes.
You are setting up a new server and need to ensure that only specific users can SSH into the machine. Which configuration file would you modify to achieve this?
- /etc/ssh/sshd_config
- /etc/hosts.allow
- /etc/ssh/authorized_keys
- /etc/passwd
To restrict SSH access to specific users, you would modify the /etc/ssh/sshd_config file. This file contains the configuration options for the SSH server, including settings related to user access, authentication, and permissions.
In the context of containers, what does the acronym "OCI" stand for?
- Open Container Initiative
- Open Container Image
- Overarching Container Integration
- Operating Container Infrastructure
In the context of containers, "OCI" stands for the "Open Container Initiative." OCI is a standardized and open industry effort that defines container specifications and runtime standards, ensuring compatibility and portability between different container runtimes.
The _________ utility is used to create, grow, shrink, and repair ext2, ext3, and ext4 file systems.
- resize2fs
- mkfs
- df
- lsblk
The correct option is resize2fs. The resize2fs utility is used to resize (grow or shrink) ext2, ext3, and ext4 file systems. It allows you to adjust the size of the file system to match the size of the underlying disk or partition. This is a crucial tool for managing file system sizes in Linux.
The ________ command in Linux allows you to enforce a user to change their password upon the next login.
- passwd
- chsh
- chfn
- usermod
The "passwd" command in Linux allows you to enforce a user to change their password upon the next login. This is often used for security reasons, such as when a user's password has expired.
protocol is considered to be highly secure and is commonly used in Linux?
- OpenVPN
- PPTP
- L2TP
- IPSec
OpenVPN is considered highly secure and commonly used in Linux. It's an open-source VPN protocol that provides strong encryption and is widely trusted for creating secure network connections.