Set System Time in Linux: Date Command Guide

You can adjust the time on a Linux system using the command line tool date.

  1. To set the system time, you can use the following command:
sudo date --set "YYYY-MM-DD HH:MM:SS"

Replace YYYY with the year, MM with the month, DD with the date, HH with the hour, MM with the minute, and SS with the second. Please replace these values with the actual numerical values.

For example, to set the system time to 8:30 AM on January 1, 2022, you can use the following command:

sudo date --set "2022-01-01 08:30:00"
  1. If you only want to set the date part of the system time, you can use the following command:
sudo date --set "YYYY-MM-DD"

For example, to set the system date to January 1, 2022, you can use the following command:

sudo date --set "2022-01-01"
  1. If you only want to set the time part of the system time, you can use the following command:
sudo date --set "HH:MM:SS"

For example, to set the system time to 8:30, you can use the following command:

sudo date --set "08:30:00"

Please note that root permissions are required to set the system time, so you need to add sudo before the command.

bannerAds