It is absolutely necessary to have the correct time on your Linux system. For example, you may want to automate stuff that requires the correct time to execute as desired. If you haven’t configured your Linux date during the initial installation, then there are other ways to do so.
You may find it straightforward to adjust the clock if you are using a Linux distribution with a desktop environment.
This is the GNOME desktop environment. Open up the menu over on the right-hand corner->click the settings icon->Details. From here, you can make changes to the time and date with simplicity.
The Linux date command
Linux has a program called date that allows you to display/change the date or time in the system. This is mainly intended for systems that are shell only. In order to display the full date and time, go ahead and type in this:
You should then get a date, followed by the time and time zone. If you want to display only the time, type this instead:
This will only display the time and nothing more. You use more arguments such as +%H +%D to display the hour and date, for example.
Now, in order to make changes to the date, you can simply use this command:
sudo date +%D -s 'Tue 28 Jan 2025'
This will make the date Tue 28 Jan 2025. Now we will change the time:
sudo date +%T -s '11:00:53'
The only downside is losing your new time/date upon rebooting your system. Luckily there’s a more permanent solution.
You can open the localtime file located in /etc/ to adjust the time by changing the timezone at the end of the time. We will need to use nano to do this.
sudo nano /etc/localtime
There’s a bunch of gibberish here, ignore all of it except for the end portion of the file. Type you will see familiar wording for a time zone. In this example, you will notice it says EST5EDT. That means EST+5.
Use this as a reference and change it into something like this:
Use CTRL+O to save and CTRL+X to exit nano. Reboot your system with sudo reboot. Your time will reflect the changes made in the localtime file.
Learn about how to update the system date and time automatically here.