102-500 · Question #140
Which command will set the local machine's timezone to UTC?
The correct answer is B. ln -s /usr/share/zoneinfo/UTC /etc/localtime. Option B works because /etc/localtime is the file Linux reads to determine the system timezone, and symlinking it to the appropriate entry in /usr/share/zoneinfo/ is the standard, persistent way to configure it - the symlink survives reboots and is recognized by virtually all…
Question
Options
- Acat UTC > /etc/timezone
- Bln -s /usr/share/zoneinfo/UTC /etc/localtime
- Cdate --timezone=UTC
- Dmv /usr/timezone/UTC /etc
How the community answered
(26 responses)- A4% (1)
- B77% (20)
- C15% (4)
- D4% (1)
Explanation
Option B works because /etc/localtime is the file Linux reads to determine the system timezone, and symlinking it to the appropriate entry in /usr/share/zoneinfo/ is the standard, persistent way to configure it - the symlink survives reboots and is recognized by virtually all Linux distributions.
Why the distractors fail:
- A (
cat UTC > /etc/timezone) -/etc/timezonestores a timezone name string on Debian-based systems, but you'decho "UTC" > /etc/timezone, notcata nonexistent file; this command would error or produce garbage. - C (
date --timezone=UTC) -datehas no--timezoneflag; it displays or sets the clock time, not the system timezone, and any change would be session-scoped at best. - D (
mv /usr/timezone/UTC /etc) - that path doesn't exist, and moving a zoneinfo file rather than symlinking it would break the source, not configure the system.
Memory tip: Think "Localtime Needs a Symlink" - ln -s points /etc/localtime at the right zone file, just like pointing a clock hand at the correct time zone on a map.
Topics
Community Discussion
No community discussion yet for this question.