Whether you are a novice or a very experienced Linux user, you will still be able to easily change the time zone settings of your Linux computer. You can do this in three different and main ways: in one you will use the desktop GUI, while in the other two you will use the command line. Read the guide to find out how to proceed.
Steps
Method 1 of 3: Using the Graphical User Interface (GUI)
Step 1. Select the 'Administration' item from the 'System' menu, then choose the 'Time and Date' item
- Alternatively, you can click on the system clock and select 'Time and Date' from the context menu that will appear.
- This method is specific to Ubuntu. The menu options are similar for many Linux distributions.
Step 2. Select your current time zone
Depending on the Linux distribution you are using, you may need to select the time zone tab as a first step.
Step 3. Select your location on the world map
Most distributions will come with a graphical map from which you can easily select your location. This will make it easier for you to select the correct time zone.
After choosing the strip of the map corresponding to your position, select the city that is closest to your area of residence
Method 2 of 3: Use the Time and Date Menu
Step 1. Enter the 'Terminal' window
This method will give you an ASCII menu from which you can select your time zone. Type one of the following commands according to the Linux distribution you are using:
-
Ubuntu:
dpkg-reconfigure tzdata
-
Redhat:
redhat-config-date
-
CentOS / Fedora:
system-config-date
-
FreeBSD / Slackware:
tzselect
Step 2. Select your time zone
Each distribution will display a slightly different menu, but which will essentially provide the same functions. Choose the region and city that is closest to your current location. This will change your system's time zone settings.
Method 3 of 3: Use the Command Line
Step 1. Check your current time zone
Log in as 'root'. Access the 'Terminal' window and check the current time zone using the command
at your place
. The system date will be displayed in the following format:
Mon Aug 12 12:15:08 PST 2013
. PST in this case refers to the Pacific Standard Time. Alternatively, you could read GMT, referring to Greenwich Mean Time.
Step 2. Select the geographic area corresponding to your time zone
Move to the directory
/ usr / share / zoneinfo
. A list of geographic areas will be displayed. Choose the area closest to you by selecting its number.
-
The path to the directory
/ usr / share / zoneinfo
- it may vary depending on the Linux distribution you are using.
Step 3. Back up your current time zone settings
If you wish, you can do this by renaming the settings configuration file for the time zone. Use the following command
mv / etc / localtime / etc / localtime-old
Step 4. Set your computer clock based on the geographic area and city closest to your current location
Use the following command, remembering to substitute the correct geographic area and city for your needs:
ln -sf / usr / share / zoneinfo / Europe / Amsterdam / etc / localtime
If your city of residence is not on the list, select one that has the same time zone
Step 5. Verify that the time zone has been set correctly
Run the command again
at your place
and verify that the time zone matches the one you just changed.
Step 6. Set the system clock to automatically synchronize with a 'time server' on the web
Most modern Linux distributions already come with the package to use the NTP service. Use the following commands to install the NTP service based on the Linux distribution you are using:
-
Ubuntu / Debian:
sudo aptitude install ntp
-
CentOS:
sudo yum install ntp
sudo / sbin / chkconfig ntpd on
-
Fedora / RedHat:
sudo yum install ntp
sudo chkconfig ntpd on
-
Type the 'ntpdate' command:
ntpdate && hwclock –w
- There are many public servers to connect to. You can find an updated list directly online at this address.
Advice
- In Linux RedHat there is a utility called 'Setup' that allows you to set the time zone by choosing it from a list, to be able to do this however you will need to install the package 'redhat-config-date' (NOTE: on RHEL5 the package to be installed is called ' system-config-date '>
- To configure UTC:
- The time synchronization server parameter of the 'rdate' command can be any public server that supports the RFC-868 protocol. You can find a list of valid servers at this address. Note: As of April 2007, NIST has announced that it will remove support for the RFC-868 protocol (you can find the official announcement at this link). In April 2009 all this has not yet happened.
- On some Linux versions RedHat, Slackware, Gentoo, SuSE, Debian, Ubuntu, and on any other 'normal' Linux version, the command to view and change the time settings is 'date' and not 'clock'.
- On mobile phones, and other small devices running Linux, the time zone settings are stored differently. They are saved in the '/ etc / TZ' directory, in the format described in the documentation available at this link. Edit the file manually or use the 'echo' command (e.g. the 'echo GMT0BST> / etc / TZ' command, set the UK time zone).
- Use the 'vi / etc / sysconfig / clock' command and change the 'UTC' parameter as follows: 'UTC = true'.
- In systems using i dpkg (for example Debian and Ubuntu / Kubuntu), you can try to use the command 'sudo dpkg-reconfigure tzdata'. This way you can configure everything correctly in a few simple steps.
Warnings
- Some applications (such as PHP) have separate time zone settings from those of the operating system.
- On some systems there is a special utility in which to configure the correct time zone, after which the changes will be automatically applied to the system configuration. For example Debian provides the 'tzsetup' or 'tzconfig' system utility.
- When updating a virtual server, you rely on the physical clock of the computer it is installed on rather than using the 'NTP' service. Trying to change the system clock or use the 'NTP' service will not work because the virtual server is unable to do so.