显示日历
cal # 显示当月日历
cal 2 2007 # 显示2007年2月的日历
显示农历
#sudo apt-get install lunar
date '+%Y %m %d %H' |xargs lunar --utf8
设置日期
date -s mm/dd/yy
设置时间
date -s HH:MM
将时间写入CMOS
hwclock --systohc
查看CMOS时间
hwclock --show
读取CMOS时间
hwclock --hctosys
从服务器上同步时间
sudo ntpdate ntp.ubuntu.com
sudo ntpdate time.nist.gov
设置电脑的时区为上海
sudo dpkg-reconfigure tzdata
然后根据提示选择 Asia/Shanghai。这样在升级了 tzdata 包之后时区也是对的。
XP 和 Ubuntu 相差了 8 小时的时差
#关闭UTC,将当前时间写入CMOS。
sudo sed -ie 's/UTC=yes/UTC=no/g' /etc/default/rcS
sudo hwclock --systohc
将时间截转为时间
date -d@1234567890