Home  >  Article  >  Operation and Maintenance  >  How to modify the system time in linux

How to modify the system time in linux

青灯夜游
青灯夜游Original
2021-12-21 17:18:5477458browse

How to modify the Linux system time: 1. Use the date command to set the system date and time, the syntax is "date -s "Year Month Day Hour: Minutes Second""; 2. Execute "hwclock -- systohc" command to save the settings, shut down and restart.

How to modify the system time in linux

#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

Modify the system time under Linux

In Linux, you can use the date command to modify the system time.

The date command can be used to display or set the system date and time.

For example, if the time is set to 2021-07-12 18:30:50, we can first set the date

date -s 20210712

and then set the time

date -s 18:30:50

You can also do it in one step, just use the command

date -s "20210712 18:30:50"

Once the time is set, it needs to be saved. It's okay if you can shut down normally. The system will be saved once when it is shut down, but if you may shut down abnormally, you can save the settings first like this

hwclock --systohc

Yes, that’s how it is written. Most of the writing methods on the Internet are

clock -w

or

hwclock -w

, and if you analyze it carefully, you will know that clock is a soft link to hwclock. The -w parameter is not mentioned at all in hwclock help and man. I don’t know which year the -w is written in.

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of How to modify the system time in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn