There are a number of time management utilities available on Linux such as date and timedatectl commands to get the current timezone of system and synchronize with a remote NTP server to enable an automatic and more accurate system time handling.

 

Well, let us dive into the different ways of finding out our Linux system timezone.

 

1. We will start by using the traditional date command to find out present timezone as follows:

$ date

 

 

Alternatively, type the command below, where %Z format prints the alphabetic timezone and %z prints the numeric timezone:

$ date +"%Z %z"

 

Note: There are many formats in the date man page that you can make use of, to alter the output of the date command:

$ man date

 

2. Next, you can likewise use timedatectl, when you run it without any options, the command displays an overview of the system including the timezone like so:

$ timedatectl

 

More so, try to employ a pipeline and grep command to only filter the timezone as below:

$ timedatectl | grep “Time zone”

 

To set timezone in Linux using timedatectl command.

 

3. In addition, users of Debian and its derivatives can display the content of the file /etc/timezone using cat utility to check your timezone:

$ cat /etc/timezone

 

Important: For REHL/CentOS 7 and Fedora 25-22 users, the file /etc/localtime is a symbolic link to the timezone file under the directory /usr/share/zoneinfo/.

 

However, you can use date or timedatectl command to display the current time and timezone as well.

 

To change the timezone, create the symbolic link /etc/localtime to the appropriate timezone under /usr/share/zoneinfo/:

$ sudo ln  -sf /usr/share/zoneinfo/zoneinfo /etc/localtime

 

The flag -s enables creation of a symbolic link, otherwise a hard link is created by default and -f removes an existing destination file, which in this case is /etc/localtime.

 

For example, to change the timezone to Africa/Nairobi, issue the command below:

$ sudo ln -sf /usr/share/zoneinfo/Africa/Nairobi /etc/localtime

 

Bu cevap yeterince yardımcı oldu mu? 0 Bu dökümanı faydalı bulan kullanıcılar: (0 Oy)