Ubuntu在命令行界面下进行时间设置

首先要把时区选对了,联网情况下,时间会自动同步,所以只要时区选对了,时间基本就是正确的时间了。

直接使用tzselect命令,就会出现时区选择的界面。做的还挺人性化的,跟着设置来过就好。

如果没有能自动同步,那么就要自己去和NTP服务器同步了,命令如下:

 

sudo ntpdate vn.pool.ntp.org


如果没有接入Internet的环境,那么就只好使用date命令来手动设定了。命令格式如下:

 

 

date -s=STRING
date --set=STRING


这是man中对date的解释。而针对后面的STRING的要求,就更宽泛了,man中具体是这么写的:

 

 

DATE STRING
       The --date=STRING is a mostly free format human  readable  date  string
       such  as  "Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or
       even "next Thursday".  A date string may contain items indicating  cal-
       endar  date,  time of day, time zone, day of week, relative time, rela-
       tive date, and numbers.  An empty string indicates the beginning of the
       day.   The date string format is more complex than is easily documented
       here but is fully described in the info documentation.


 

posted @ 2014-05-04 15:48  Superpig0501  阅读(986)  评论(0)    收藏  举报