Linux Set Date and Time From a Command Prompt

h‮‬ttps://www.lautturi.com
Linux Set Date and Time From a Command Prompt

To set the date and time on a Linux system from the command prompt, you can use the date command with the -s option followed by the desired date and time in the format YYYYMMDDhhmm.ss.

For example, to set the date and time to April 1, 2021 at 12:30:00, you can use the following command:

date -s "202104011230.00"

This will set the date and time to the specified value.

It's important to note that you may need to have root privileges to use the date command to set the date and time.

You can also use the timedatectl command to set the date and time on a system that uses the systemd init system. For example:

timedatectl set-time "20210401 12:30:00"

This will set the date and time to the specified value.

For more information about using the date command and the timedatectl command, you can refer to the date manual page and the timedatectl manual page. For example:

man date
man timedatectl

It's also important to note that you may need to restart some services or applications for the changes to take effect.

Created Time:2017-10-30 10:17:38  Author:lautturi