linux的date 显示非当前时间、date 设置系统时间、ntpdate命令

本文介绍了Linux中使用date命令显示和设置系统时间,包括显示前/后两天时间的语法,以及如何通过ntpdate与NTP服务器进行时间同步。提到了ntpdate的常用国内外服务器列表,确保系统时间准确。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.3.2 date 显示非当前时间

(1)date -d ‘2 days ago’ (功能描述:显示前两天时间【数字可以改动】)
(2)date -d ‘-2 days ago’ (功能描述:显示后天时间【数字可以改动】)

显示前两天时间
在这里插入图片描述
显示后天时间
在这里插入图片描述

1.3.3 date 设置系统时间

date -s 字符串时间

在这里插入图片描述

1.3.4ntpdate命令

改完时间后,想再把时间改回来需要用ntpdate,如果没有的话,需要先下载(yum install ntpdate -y),一般情况是都有的

在这里插入图片描述

注意:若不加上-u参数, 会出现以下提示:no server suitable for synchronization found(-u:从man ntpdate中可以看出-u参数可以越过防火墙与主机同步)

ntpdate常用服务器
国内

cn.pool.ntp.org 中国开源免费NTP服务器
time1.aliyun.com 阿里云NTP服务器
time2.aliyun.com 阿里云NTP服务器
ntp1.aliyun.com 阿里云NTP服务器
ntp2.aliyun.com 阿里云NTP服务器

国外

time1.apple.com 苹果NTP服务器
time2.apple.com 苹果NTP服务器
time3.apple.com 苹果NTP服务器
time4.apple.com 苹果NTP服务器
time5.apple.com 苹果NTP服务器
time1.google.com 谷歌NTP服务器
time2.google.com 谷歌NTP服务器
time3.google.com 谷歌NTP服务器
time4.google.com 谷歌NTP服务器
pool.ntp.org 开源免费NTP服务器

详细的请看我之前发的博客
linux常用命令下https://blog.youkuaiyun.com/Redamancy06/article/details/125349887
linux常用命令中https://blog.youkuaiyun.com/Redamancy06/article/details/125327352
linux常用命令上https://blog.youkuaiyun.com/Redamancy06/article/details/125317329

评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Redamancy_06

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值