To manually change the system time in Linux, you can follow these steps:
- Open a terminal.
- Check the current date and time using the date command:
- To change the system time, you'll need root privileges, so switch to the root user or use the sudo command before the following steps:
- Set the system date and time using the date command in the following format:
date +%Y%m%d -s "20220101" # Setting the date to January 1, 2022
date +%T -s "09:30:00" # Setting the time to 9:30:00
Replace "20220101" and "09:30:00" with the desired date and time values respectively. Note that the time format is 24-hour clock.
- After setting the date and time, synchronize the hardware clock with the system time using the hwclock --systohc command:
After these steps, the system time should be changed. You can verify the changes by running the
date command again.