In this tutorial you will learn how to change the timezone on Ubuntu Server. This is also an overview timezone tutorial that will explain what a timezone is, from where can you download the tz database, how to see the time zones in it and also how the time zones are represented inside of the Ubuntu Server.
Code used during this tutorial:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# Ubuntu Server Change and overview timezone cd ~/vagrant/ubuntu-trusty32/ vagrant up --provider virtualbox vagrant ssh # Run on both host and guest OS # Print the system date and time date cat /etc/timezone # Reconfigure an already installed package # tzdata package: time zone and daylight-saving time data sudo dpkg-reconfigure tzdata date cat /etc/timezone # Non-interactive method sudo bash -c 'echo "Europe/Bucharest" > /etc/timezone' sudo dpkg-reconfigure -f noninteractive tzdata # It's good to know that you should also restart the cron service too if you want the changes to take effect sudo service cron stop sudo service cron start # File system timezones ls /usr/share/zoneinfo/ ls -lh /usr/share/zoneinfo/Europe/Bucharest # Time zone naming convention Area/Location # "Etc/UTC" represents Coordinated Universal Time # EET Eastern European Time # tz database vi ~/Desktop/tzdata2015g/europe # The reference source code includes such a compiler called zic (zone information compiler), # as well as code to read those files and use them in standard # application programming interfaces such as localtime() and mktime() # Typically, these files are taken by a software distributor like Debian, compiled, and then the source and # binaries are packaged as part of that distribution. # A time zone is a region that observes a uniform standard time for legal, commercial, and social purposes. # Useful links http://askubuntu.com/questions/3375/how-to-change-time-zone-settings-from-the-command-line https://launchpad.net/ubuntu/+source/tzdata http://www.christopherirish.com/2012/03/21/how-to-set-the-timezone-on-ubuntu-server/ http://stackoverflow.com/questions/8671308/non-interactive-method-for-dpkg-reconfigure http://askubuntu.com/questions/103643/cannot-echo-hello-x-txt-even-with-sudo http://tecadmin.net/change-timezone-on-linux/ http://www.thegeekstuff.com/2010/09/change-timezone-in-linux/ https://en.wikipedia.org/wiki/Time_zone https://en.wikipedia.org/wiki/Tz_database https://en.wikipedia.org/wiki/List_of_tz_database_time_zones ftp://ftp.iana.org/tz/releases/tzdata2015g.tar.gz |
Useful links:
http://askubuntu.com/questions/3375/how-to-change-time-zone-settings-from-the-command-line
https://launchpad.net/ubuntu/+source/tzdata
http://www.christopherirish.com/2012/03/21/how-to-set-the-timezone-on-ubuntu-server/
http://stackoverflow.com/questions/8671308/non-interactive-method-for-dpkg-reconfigure
http://askubuntu.com/questions/103643/cannot-echo-hello-x-txt-even-with-sudo
http://tecadmin.net/change-timezone-on-linux/
http://www.thegeekstuff.com/2010/09/change-timezone-in-linux/
https://en.wikipedia.org/wiki/Time_zone
https://en.wikipedia.org/wiki/Tz_database
https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
ftp://ftp.iana.org/tz/releases/tzdata2015g.tar.gz