How To Set Date, Time And Timezone In Ubuntu 20.04 LTS?

Ubuntu is among the most popular Linux distributions, which is developed by Canonical. It is easy to use, easy to install, and includes mostly free and opensource softwares.

Most of the systems installed Ubuntu detects and synchronizes time automatically. However, you may find that your system is not synchronizing properly in this case you can set date time or timezone manually.

So in this article, we will set date, time, and timezone manually using a terminal in Ubuntu 20.04 LTS.

How to display the current date and time

To display the current date and time you can use the following command in your terminal –

date

or also you can use –

timedatectl

Most of the modern systems based on systemd use a utility called timedatectl to set or display the date and time of a system.

How to change the current date and time using the date command

To change the current date, use the following command –

sudo date +%Y%m%d -s "20200820"

This command will set the current date to 20 Aug 2020.

Change time using the command line –

sudo date +%T -s "09:28:00"

If you want to change both date and time then you should use the date command in the given format –

sudo date -s "20 AUG 2020 09:28:00 PM"

How to change the current date and time using timedatectl

By using timedatectl command you can set or display the current date, time and timezone, etc of a system.

To set time we will use set-time with timedatectl command –

timedatectl set-time 09:03:10

If you want to modify the system date only then use –

timedatectl set-time 20200821

The date is passed in the YYYYMMDD format in the command given above.

You can use the following command to set date and time using a single command –

timedatectl set-time '2020-08-21 09:03:10'

How to change the timezone

To see the list of available timezones use the following command –

timedatectl list-timezones

This will display the list of timezones you can scroll and choose the appropriate one.

Now to set timezone use the following command –

timedatectl set-timezone 'Your_time_zone'

For example, my timezone is Asia/Kolkata so I will use –

timedatectl set-timezone 'Asia/Kolkata'

As you can see in the image above the time zone is now changed to Asia/Kolkata(IST, +0530).

Synchronizing the system clock with a remote NTP server

Instead of setting the time manually using the date or timedatectl command you can synchronize the system clock with the remote NTP server. NTP or Network Time Protocol is an internet protocol that is used to synchronize time between computers.

Please note you should have NTP installed in your system to start automatic time synchronization using NTP servers.

Now use the following command in your terminal –

timedatectl set-ntp true

As you can see in the image above, the system clock is now synchronized and NTP services are active now. The system will now automatically update the system date and time.

If you want to disable NTP services use –

timedatectl set-ntp false

Conclusion

By reading this you can now change the date, time, and timezone in a system. Also, you can start NTP services to start time synchronization automatically. Now still if you have a query you can write us in the comments below.

Leave a Comment