nerdexam
CompTIA

XK0-004 · Question #168

A Linux administrator looks at the /etc/timezone file and determines the need to change the time zone from California to New York temporarily. Which of the following commands will accomplish this?

The correct answer is C. export TZ=America/New_York. Setting the TZ environment variable with export is the standard way to temporarily override the system timezone for the current shell session.

System Management

Question

A Linux administrator looks at the /etc/timezone file and determines the need to change the time zone from California to New York temporarily. Which of the following commands will accomplish this?

Options

  • Ased -f TZ=America/New_York
  • Bcat TZ=America/New_York
  • Cexport TZ=America/New_York
  • Dprintf TZ=America/New_York

How the community answered

(44 responses)
  • A
    2% (1)
  • B
    9% (4)
  • C
    86% (38)
  • D
    2% (1)

Why each option

Setting the TZ environment variable with export is the standard way to temporarily override the system timezone for the current shell session.

Ased -f TZ=America/New_York

sed is a stream editor used for text substitution in files or streams; it cannot set environment variables.

Bcat TZ=America/New_York

cat is used to display or concatenate file contents and cannot define or export environment variables.

Cexport TZ=America/New_YorkCorrect

The export command sets an environment variable and makes it available to child processes for the duration of the current session. Setting TZ=America/New_York overrides the system timezone temporarily without modifying /etc/timezone or /etc/localtime, which is exactly the behavior required.

Dprintf TZ=America/New_York

printf formats and prints text output to stdout; it has no ability to set or persist environment variables in the current shell.

Concept tested: Temporarily overriding system timezone with TZ variable

Source: https://man7.org/linux/man-pages/man5/timezone.5.html

Topics

#timezone#TZ environment variable#export#temporary configuration

Community Discussion

No community discussion yet for this question.

Full XK0-004 Practice