Changing Time Zone on Linux | CompTIA Linux+ Exam XK0-004

Change Time Zone from California to New York Temporarily

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?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

C.

https://www.thegeekstuff.com/2010/09/change-timezone-in-linux/

The correct answer is C. export TZ=America/New_York.

Explanation:

The /etc/timezone file stores the current timezone settings for the system. In order to temporarily change the timezone from California to New York, we need to set the TZ environment variable to America/New_York.

The export command is used to set environment variables in Linux. Therefore, the correct command to change the timezone to America/New_York temporarily is:

javascript
export TZ=America/New_York

This command will set the TZ environment variable to America/New_York, which will override the current timezone settings for the system.

Option A is incorrect because the sed command is used for editing files, not setting environment variables.

Option B is incorrect because the cat command is used to display the contents of a file, not set environment variables.

Option D is incorrect because the printf command is used for formatting and printing output, not setting environment variables.