Courseiva
Essential CommandsmediumMultiple ChoiceObjective-mapped

LFCS Essential Commands Practice Question

A system administrator has a cron job that runs a backup script. The script requires the variable BACKUP_DIR to be set, but the administrator cannot modify the script. Which is the most appropriate place to define the variable for cron?

⚠ Common exam trap

Watch out — candidates often assume cron inherits the user's login environment or sources profile files, but cron explicitly does not, making inline crontab variable definitions the only correct approach.

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

In the crontab file with the line 'BACKUP_DIR=/var/backups' before the command

Cron jobs run in a minimal environment and do not source shell profiles or login scripts. Defining BACKUP_DIR directly in the crontab file before the command ensures the variable is set in the cron execution context, which is the only reliable way to pass environment variables to cron without modifying the script.

Answer analysis

Option-by-option breakdown

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

  • In the crontab file with the line 'BACKUP_DIR=/var/backups' before the command

    Why this is correct

    crontab allows variable definitions.

  • In /etc/profile.d/backup.sh

    Why it's wrong here

    cron does not source /etc/profile.d files.

  • In /etc/environment

    Why it's wrong here

    PAM may read it but cron does not by default.

  • In ~/.bash_profile

    Why it's wrong here

    cron uses /bin/sh, not bash, and does not source .bash_profile.

About these practice questions

Courseiva writes every LFCS question from scratch — 507 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This LFCS practice question is part of Courseiva's free Linux Foundation 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 LFCS exam.