Courseiva

EX200 Create simple shell scripts Practice Question

A new intern created a script to display the current user's home directory:

#!/bin/bash echo "Home directory: $home"

The script outputs 'Home directory: ' with nothing after the colon. What is the most likely cause?

⚠ Common exam trap

EX200 often tests whether candidates overlook shell case-sensitivity and instead blame environment configuration or shell choice, when the real cause is a simple variable-name typo.

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

✓

There is a typo: it should be $HOME, not $home.

Bash variable names are case-sensitive, so $home is a distinct variable from the standard $HOME environment variable. Since 'home' was never assigned, it expands to an empty string, producing the observed output. The correct reference is $HOME.

Answer analysis

Option-by-option breakdown

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

  • ✗

    The HOME variable is not set in the environment.

    Why it's wrong here

    If HOME were genuinely unset, the script would not print a wrong-looking empty line for that specific reason. On RHEL and other Linux systems, HOME is set by the login process (PAM/systemd), inherited by subshells, and also re-established by bash for interactive and non-interactive shells using the current user's passwd entry. A missing HOME causes far more severe issues—such as shell startup scripts failing to find ~/.bashrc or commands using ~ misbehaving—so the symptom would not be limited to a single echo. Therefore an unset HOME is not the cause here.

  • ✓

    There is a typo: it should be $HOME, not $home.

    Why this is correct

    The command uses $home, which is a different variable name from $HOME because bash is case-sensitive. Environment variables like HOME are uppercase by convention, and the lowercase $home is not defined in any standard shell session, so it expands to an empty string. Assigning or exporting a lowercase home would require the script author to have previously set it, and echo "$home" would then output that value rather than the actual home directory. The only correct fix is to change the script to use $HOME (or ${HOME}).

  • ✗

    The script is run with 'sh' instead of 'bash'.

    Why it's wrong here

    Running a script with 'sh' instead of 'bash' changes the shell to POSIX mode, but it does not undefine standard environment variables. On RHEL, /bin/sh is actually a symlink to bash or a minimal POSIX shell, and every login shell—including the one that invokes the script—sets HOME from the passwd database or from PAM. The variable $HOME is not a bash-specific feature; it is part of the portable process environment that sh also honors. Thus, invoking the script as 'sh script.sh' would not strip HOME.

  • ✗

    The root user has no home directory.

    Why it's wrong here

    The root account's home directory is not empty or nonexistent; by default on Red Hat based systems, root's home is /root. The /etc/passwd entry for root explicitly lists /root as the home directory, and both su and login set HOME=/root for root sessions. If the script were executed by root, $HOME would expand to /root, yielding output rather than nothing. Claiming that root has no home directory reverses the actual security and administrative convention.

About these practice questions

This EX200 question is part of Courseiva's 427-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. 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 Red Hat exam blueprint

This EX200 practice question is part of Courseiva's free Red Hat 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 EX200 exam.