XK0-006 practice question 6 of 15

A Linux user runs the following command: nohup ping comptia.com & Which of the following commands should the user execute to attach the process to the current terminal?

Full set: 149 questions
Answer options
A: renice
B: jobs
C: exec
D: fg Correct answer
Correct Answer:
D. fg
Explanation

The nohup command ensures a process continues running even if the user logs out, and the & operator places the process into the background. The jobs command lists background processes. To bring a background process to the foreground and attach it to the current terminal session, the fg (foreground) command is used. This allows the user to interact with the process or view its standard output directly in the terminal.

Why Incorrect

A. renice is used to change the scheduling priority of a running process, not to attach it to a terminal.
B. jobs lists the background processes but does not attach any of them to the foreground.
C. exec replaces the current shell process with a new command, which is not the desired action.

References

1. GNU Bash Manual, Section 3.2.2 "Job Control Basics". The manual states, "To move a job to the foreground, use the fg command."

2. Arpaci-Dusseau, R. H., & Arpaci-Dusseau, A. C. (2018). Operating Systems: Three Easy Pieces. Arpaci-Dusseau Books. Chapter 5, "Processes API", discusses process control, including backgrounding and foregrounding processes.

3. MIT OpenCourseWare, 6.005 Software Construction, "Command Line" reading. This material covers shell basics, including job control with &, jobs, bg, and fg.

Scroll to Top