A systems administrator is writing a shell script designed to initialize a custom application. The script first configures network settings and then must start a long-running application binary named webapp. To conserve system resources, the shell process that runs the script should be replaced by the webapp process once the application starts. Which of the following commands, when placed at the end of the script, will achieve this?
The correct command is exec ./webapp. The exec shell built-in command replaces the current shell process with the specified command. This means the webapp process will take the place of the script's shell, inheriting its Process ID (PID) and not consuming extra resources by leaving the parent shell running.
The ./webapp & command runs the application in the background. The ampersand & creates a new child process for the application while the original script's shell continues to run or exits, but it is not replaced.
The nohup ./webapp command runs the application immune to the hangup (HUP) signal, which allows it to continue running if the terminal is closed. It does not replace the shell process.
The source ./webapp command executes the contents of the file in the current shell context. It is used to load functions or variables into the current shell, not to replace the shell process with a binary application.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does the `exec` command do in a shell script?
Open an interactive chat with Bash
How does `exec` differ from running a process in the background with `&`?
Open an interactive chat with Bash
Why wouldn't `nohup` or `source` work for replacing the shell process?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Services and User Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access