The default field separator for operations like splitting strings is determined by the _________ built-in variable.
- IFS
- SHELL
- PATH
- PWD
The default field separator for operations like splitting strings is determined by the IFS (Internal Field Separator) built-in variable. The IFS variable defines how the shell separates words when it parses strings, making it a crucial component for tasks like parsing CSV files or text processing in scripts.
In a shell script, if you want to refer to the last argument passed, you would use the _________ special variable.
- $!
- $@
- $?
- $_
In a shell script, you would use the $_ special variable to refer to the last argument passed. This variable holds the last argument to the last command that was executed.
You've just set up a new Linux server and need to install a web server. Which package management command would you likely use in a Debian-based system?
- apt-get
- yum
- dnf
- pacman
In a Debian-based system, such as Ubuntu, you would likely use the 'apt-get' command to install packages. The 'apt-get' command is used for package management and is specifically designed for Debian-based distributions.
You've been tasked with writing a script that processes input arguments. How would you check if the number of arguments provided to the script is less than 3?
- if [ "$#" -lt 3 ]
- if [ "$#" -eq 3 ]
- if [ "$#" -gt 3 ]
- if [ "$#" -eq 0 ]
To check if the number of arguments provided to the script is less than 3, you would use if [ "$#" -lt 3 ]. This tests whether the number of script arguments, represented by $#, is less than 3. Option 2 checks if the number of arguments is exactly 3, and Option 3 checks if it's greater than 3. Option 4 checks if there are no arguments.
Which option with the ssh command specifies a different port for connection?
- -p
- -s
- -l
- -r
The correct option is -p. When using the ssh command, you can specify a different port for the connection using the -p option followed by the port number (e.g., ssh -p 2222 user@hostname). This is useful when an SSH server is configured to listen on a non-default port.
In the context of package management, what does the term "repository" refer to?
- A centralized location where software packages are stored and maintained.
- A virtual environment used for package testing.
- A command used to remove packages from a Linux system.
- A file containing package metadata.
In package management, a "repository" refers to a centralized location where software packages are stored and maintained. These repositories contain packages that can be downloaded, installed, or updated on a Linux system using package management tools.
The ________ command in Linux is used to send a signal to a process, often used for termination.
- continue
- kill
- pause
- stop
The kill command in Linux is used to send a signal to a process, often used for termination. It allows you to gracefully terminate or send specific signals to processes, giving you control over their behavior.
You've been tasked with setting up a Linux server that can share files with Windows clients in the network, ensuring they can access it seamlessly. Which software would you primarily consider installing?
- Samba
- NFS
- SSH
- FTP
To enable seamless file sharing with Windows clients, you would primarily consider installing Samba. Samba is a software suite that allows interoperability between Linux/Unix servers and Windows-based clients. It provides support for the SMB/CIFS protocol used in Windows networking.
Which command displays a visual representation of disk usage in Linux?
- ncdu
- dd
- du
- df
The correct command to display a visual representation of disk usage in Linux is ncdu. It stands for "NCurses Disk Usage" and provides a detailed and interactive view of disk usage, allowing users to navigate through directories and identify space-consuming files or folders. Unlike the other options, ncdu is specifically designed for this purpose.
When debugging, which shell built-in command can be used to read and execute commands from a file?
- source
- execute
- run
- debug
When debugging in shell scripting, the source command (or . for short) is used to read and execute commands from a file. This is often used to include external script files or configuration files into the current script, allowing you to reuse code or set environment variables.