How to set the system date?

To set the system date in Linux, you can use the date command with superuser privileges. Here’s how to do it:

  1. Set the Date and Time: You can set the date and time using the following command format:

    sudo date MMDDhhmmYYYY
    
    • MM is the month (01-12)
    • DD is the day (01-31)
    • hh is the hour (00-23)
    • mm is the minutes (00-59)
    • YYYY is 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 123115302023
    
  2. Set the Hardware Clock: After setting the system date, you may want to synchronize the hardware clock with the system clock:

    sudo hwclock --systohc
    
  3. Verify 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.

0 Comments

no data
Be the first to share your comment!