Ubuntu 常见问题汇总【持续更新】

1、apt update 更新报错

  • 报错信息
root@rionserver:~# apt update
Get:1 file:/cdrom focal InRelease
Ign:1 file:/cdrom focal InRelease
Get:2 file:/cdrom focal Release
Err:2 file:/cdrom focal Release
  File not found - /cdrom/dists/focal/Release (2: No such file or directory)
......
Reading package lists... Done
E: The repository 'file:/cdrom focal Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
  • 解决方法
    在执行apt update 时,读取了/etc/apt/sources.list 中的更新源,因为没有cdrom 所以报错了。我们只需要注释掉即可。
root@rionserver:~# cat /etc/apt/sources.list
#deb [check-date=no] file:///cdrom focal main restricted

2、Ubuntu更新系统时间

当我们使用date来查看时间时,发现时间与本地时间不一致,可以先看看时区是否正确,也可以使用ntpdate 直接更新时间。

  • 下载ntpdate
apt install ntpdate
  • 更新时间
root@k8s-master:~# ntpdate -u ntp.api.bz # 网络时间同步命令

    注意:若不加上-u参数, 会出现以下提示:no server suitable for synchronization found

    -u:从man ntpdate中可以看出-u参数可以越过防火墙与主机同步;

国内其他的ntp服务器

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

注意:
如果更新时间之后发现时间还是不对,此时我们查看我们的时区
1. 查看时区

  • 方式一
root@k8s-master:~# timedatectl status
               Local time: Sat 2022-06-18 12:40:00 UTC
           Universal time: Sat 2022-06-18 12:40:00 UTC
                 RTC time: Sat 2022-06-18 12:40:00    
                Time zone: Etc/UTC (UTC, +0000)       # 伦敦标准时区,并不是东八区
System clock synchronized: yes                        
              NTP service: active                     
          RTC in local TZ: no                         
  • 方式二
root@k8s-master:~# date -R
Sat, 18 Jun 2022 12:40:10 +0000

2. 设置时区

  • 方式一
root@k8s-master:~# timedatectl set-timezone "Asia/Shanghai"
root@k8s-master:~# timedatectl status
               Local time: Sat 2022-06-18 20:48:17 CST
           Universal time: Sat 2022-06-18 12:48:17 UTC
                 RTC time: Sat 2022-06-18 12:48:17    
                Time zone: Asia/Shanghai (CST, +0800) 
System clock synchronized: yes                        
              NTP service: active                     
          RTC in local TZ: no  
  • 方式二
tzselect

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值