To set the system date in Linux, you can use the date command with superuser privileges. Here’s how to do it:
Set the Date and Time: You can set the date and time using the following command format:
sudo date MMDDhhmmYYYYMMis the month (01-12)DDis the day (01-31)hhis the hour (00-23)mmis the minutes (00-59)YYYYis the year (e.g., 2023)
For example, to set the date to December 31, 2023, at 15:30 (3:30 PM), you would use:
sudo date 123115302023Set the Hardware Clock: After setting the system date, you may want to synchronize the hardware clock with the system clock:
sudo hwclock --systohcVerify the Change: You can verify that the date has been set correctly by running:
date
Make sure you have the necessary permissions to change the system date, as it typically requires superuser access.
