Bootstrap FreeKB - Linux Files - Understanding the /etc/timezone and /etc/localtime files
Linux Files - Understanding the /etc/timezone and /etc/localtime files

Updated:   |  Linux Files articles

On some distributions, the /etc/timezone file contains the timezone of the system. On some distributions, the /etc/localtime file contains a symbolic link to the timezone being used by the system.

 


/etc/timezone

The /etc/timezone file is a text file. The cat command can be used to view the timezone in the /etc/timezone file.

[root@server1 ~]# cat /etc/timezone
US/Central

 

If a change is made to the /etc/timezone file, use the date command, and the new time zone should be displayed.

[root@server1 ~]# date
Mon Jan 01 00:00:01 CDT 2016

 


/etc/localtime

The ls -l /etc/localtime command can be used to view the file that is symbolically linked to the /etc/localtime file. In this example, the /etc/localtime file is symbolically linked to the /usr/share/zonefile/US/Eastern file, which means the system is configured to use the Eastern time zone (EST) in the USA. The /etc/localtime file is a binary file, meaning that the cat command cannot be used to read the contents of the file.

[root@server1 ~]# ls -l /etc/localtime
lrwxrwxrwx.  1 root root    01 Jan 01 00:01 localtime -> /usr/share/zoneinfo/US/Eastern

 

To change the time zone, remove the /etc/localtime file.

[root@server1 ~]# rm /etc/localtime

 

Use the ln -s command to create a new symbolic link from the appropriate time zone file to /etc/localtime. In this example, a new symbolic link is created to link /etc/share/zonefile/US/Cental to /etc/localtime.

[root@server1 ~]# ln -s /usr/share/zoneinfo/US/Central /etc/localtime

 

The ls -l /etc/localtime command again can be used to see that /etc/share/zonefile/US/Central has been symbolically linked to /etc/localtime.

[root@server1 ~]# ls -l /etc/localtime
lrwxrwxrwx.  1 root root    01 Jan 01 00:01 localtime -> /usr/share/zoneinfo/US/Central

 

Use the date command, and the new time zone should be displayed. In this example, instead of Eastern time zone (EST) being displayed, Central time zone (CDT) is now being used.

[root@server1 ~]# date
Mon Jan 01 00:00:01 CDT 2016

 

View the /etc/adjtime file to detemine if the system is configured to use LOCAL (local time) or UTC. In this example, type system is using UTC.

[root@server1 ~]# cat /etc/adjtime
0.0 0 0.0
0
UTC

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter c8f9a5 in the box below so that we can be sure you are a human.