How to fix time on Linux

Using the timedatectl command to fix time on Linux

Sometimes we need to change the time on the computer, for whatever reason it is, the command is pretty straightforward:

timedatectl set-time "year-month-day hours:minutes:seconds"

The command above has to be executed as root and with quotes, the parameters are self-explanatory.

Also, there is no need to install or change anything. The command seems to be universal to most Linux versions.

You can also omit some parameters, like:

timedatectl set-time "year-month-day hours:minutes"

Or even:

timedatectl set-time "year-month-day"

An example of the command usage, setting the date to the time this post was written:

timedatectl set-time "2019-12-11 18:27:45"