nerdexam
CompTIA

XK0-005 · 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. The administrator needs to temporarily change the timezone for the current shell session to New York without affecting the system-wide configuration.

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

(33 responses)
  • A
    6% (2)
  • B
    15% (5)
  • C
    70% (23)
  • D
    9% (3)

Why each option

The administrator needs to temporarily change the timezone for the current shell session to New York without affecting the system-wide configuration.

Ased -f TZ=America/New_York

`sed -f TZ=America/New_York` is syntactically incorrect for setting an environment variable; `sed` is a stream editor used for text transformation based on scripts or expressions.

Bcat TZ=America/New_York

`cat TZ=America/New_York` would attempt to display the contents of a file named 'TZ=America/New_York', which is not how environment variables are set or modified.

Cexport TZ=America/New_YorkCorrect

The `TZ` environment variable controls the timezone setting for the current shell session and any processes launched from it. Using `export TZ=America/New_York` temporarily overrides the system's default timezone, ensuring that time-related commands reflect the New York timezone only in that session.

Dprintf TZ=America/New_York

`printf TZ=America/New_York` would simply print the literal string 'TZ=America/New_York' to standard output, without setting any environment variable.

Concept tested: Temporarily setting timezone using environment variables

Source: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/ch-configuring_time_using_chrony#s2-setting-the-timezone-manual

Topics

#Environment variables#Time zone management#Linux commands#Shell commands

Community Discussion

No community discussion yet for this question.

Full XK0-005 Practice