If you lot've moved or are traveling with your Linux laptop, you may be wondering how to change your system'due south fourth dimension zone. Information technology's easy to set your Linux computer's time zone from the command line. Here's how to practise it.

Viewing Time Zones With tzselect

tzselect continent selection

On Linux systems, time zones are defined by the Fourth dimension Zone Database, as well known equally tzdata, managed by the Internet Assigned Numbers Authority.

As time zones can alter politically, it's helpful to have them managed in a central database that other systems can use. Tom Scott explains why this is such a skillful idea:

To view the names of the fourth dimension zones in the database for your location, you lot can employ the tzselect control. It's a carte-driven program that will narrow down the name of the time zone you desire.

You kickoff with the tzselect command at the shell:

          tzselect        

This will bring up a carte du jour of continents, and you tin can drill down through to your land'due south and your local area'southward time zone, if applicable.

For instance, the Pacific Fourth dimension Zone is represented every bit "America/Los_Angeles." tzselect will enquire to confirm whether this is correct. Afterwards that, it volition tell you lot how to make the change permanent using the $TZ environment variable.

Setting Time Zones With the $TZ Environment Variable

TZ environemntal variable on the linux command line

Y'all tin can but gear up the time zone with the $TZ environment variable. For example, to prepare information technology to the Pacific Time Zone:

          export TZ="America/Los_Angeles"                  

To make this change permanent, you can put this line in your shell configuration files like .bashrc or .zshrc.

Setting Time Zones With /etc/timezone and /etc/localtime

/etc/localtime symbolic link

If you desire to make system-wide changes to the time zone, such every bit for a desktop organization or a laptop that stays in one location, yous can use the /etc/timezone and /etc/localtime files. Which file you'll apply depends on which organisation you're running.

Debian and Ubuntu systems use the former. These files are unremarkably set at installation, but you lot can change them afterward. To discover out which files you apply on your organisation, consult your distribution'due south documentation.

To alter the time zone using /etc/timezone, yous'd edit information technology with any text editor and place the fourth dimension zone name you got earlier in that file. You'll need to use sudo because the root user owns the file.

For instance, to edit it with vim:

          sudo vim /etc/timezone        

With /etc/localtime, y'all modify the time zone past creating a symbolic link to a binary file that has the same proper name equally the time zone in the /usr/share/zoneinfo directory.

If you wanted to gear up your machine to Pacific fourth dimension using /etc/localtime, you'd utilize the ln command with the -southward choice to create a symbolic link and -f to overwrite it if it already exists:

          sudo ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime        

Now Y'all Can Set the Time Zone From the Command Line

No matter where your travels take you, you can always make sure yous're keeping the right time with a few simple commands. If you lot're looking to convert time zones in the browser, read on for more on how to use a web-based tool, MyTimeZone, to exercise so.