XK0-004 · Question #365
Joe, a system administrator, realizes that the time zone on a system is different than his local time zone. Joe runs the command export Tz-America .Chicago to resolve this. However the next Joe logs i
The correct answer is C. Add the export Tz=America/Chicage command to the bash_profile file.. The 'export' command sets environment variables only for the current session. To persist a timezone change across logins, the export statement must be placed in a shell initialization file such as ~/.bash_profile.
Question
Joe, a system administrator, realizes that the time zone on a system is different than his local time zone. Joe runs the command export Tz-America .Chicago to resolve this. However the next Joe logs in, Joe notices the issue has returned. Which of the following is the BEST way for Joe to fix this issue so the solution persists across logins?
Options
- ARun the export Tz=/etc/localtime command
- BSet the correct the zone with the date command.
- CAdd the export Tz=America/Chicage command to the bash_profile file.
- DRun the export LC ALL=America/Chicago command
How the community answered
(27 responses)- B4% (1)
- C93% (25)
- D4% (1)
Why each option
The 'export' command sets environment variables only for the current session. To persist a timezone change across logins, the export statement must be placed in a shell initialization file such as ~/.bash_profile.
Setting TZ to a file path such as /etc/localtime is invalid syntax - the TZ environment variable requires a timezone name string like 'America/Chicago', not a filesystem path.
The 'date' command adjusts the displayed or hardware clock time but does not set the TZ environment variable, so it does not resolve a per-user timezone display issue.
Adding 'export TZ=America/Chicago' to ~/.bash_profile ensures the variable is set automatically every time a new login shell starts, because ~/.bash_profile is sourced by bash at each interactive login. This makes the timezone setting persistent across sessions without requiring Joe to re-run the export command manually after each login.
LC_ALL controls locale settings such as language, character encoding, and numeric formatting - it has no effect on the timezone and setting it to 'America/Chicago' would not change the displayed time zone.
Concept tested: Persisting TZ environment variable in bash_profile across logins
Source: https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html
Topics
Community Discussion
No community discussion yet for this question.