Courseiva
System Management →mediumMultiple Choice

XK0-006 System Management Practice Question

An administrator wants to start a long-running script in the background so that it continues running even after logging out. Which command should be used?

⚠ Common exam trap

Many exam-takers confuse backgrounding (&) with detaching from the terminal (nohup); candidates pick & alone and forget that SIGHUP kills the job on logout.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

nohup script.sh &

nohup (no hangup) makes the process immune to the SIGHUP signal that is sent to child processes when the controlling terminal closes on logout. Appending & backgrounds the job so the shell returns a prompt immediately. Combining both is required: nohup alone still runs in the foreground and blocks the terminal, while & alone leaves the process vulnerable to SIGHUP on logout.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    script.sh &

    Why it's wrong here

    The ampersand only backgrounds the job within the current shell; it still receives SIGHUP when the session ends, terminating the script. nohup is required to survive logout. Backgrounding is tempting because it frees the terminal, and would be correct when the script must run concurrently but the session stays open.

  • ✓

    nohup script.sh &

    Why this is correct

    nohup makes the process immune to SIGHUP, so it survives terminal closure and logout, while the trailing & backgrounds it immediately. This satisfies the requirement that the script keeps running after the session ends, unlike a plain background job.

  • ✗

    nohup script.sh

    Why it's wrong here

    nohup ignores SIGHUP but does not itself detach the process from the terminal; without backgrounding or redirection the script still blocks the shell and may stall on terminal I/O. It is tempting because it addresses logout survival, and would be correct when combined with & and output redirection.

  • ✗

    bg script.sh

    Why it's wrong here

    bg only resumes a job already stopped in the current shell; it neither starts a new process nor detaches it from the terminal, so the script still dies on logout. nohup or setsid with disown is required. bg would be the right command for resuming a suspended foreground job within the same interactive session.

About these practice questions

One of 781 original XK0-006 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official CompTIA exam blueprint

This XK0-006 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the XK0-006 exam.