Ubuntu问题汇总

Note

csdn的搜索好像不能搜索到代码块中的内容,标题或正文中如果直接有报错文本,搜索到的概率会高。

18.04

apt-get报错 Could not get lock

E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)

[root@ubuntu1804 ~]#sudo apt-get update
Reading package lists... Done
E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/
[root@ubuntu1804 ~]#sudo rm -rf /var/lib/apt/lists/lock
[root@ubuntu1804 ~]#sudo apt-get update
Hit:1 http://mirrors.aliyun.com/ubuntu bionic InRelease
Hit:2 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease
Hit:3 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease
Hit:4 http://mirrors.aliyun.com/ubuntu bionic-security InRelease
Reading package lists... Done

apt报错ModuleNotFoundError: No module named CommandNotFound

ModuleNotFoundError: No module named CommandNotFound
error processing package update-notifier-common
dpkg: error processing package update-notifier-common (–configure)

先尝试如下方法是否可行

cd /var/lib/dpkg
sudo mv info info.bak
sudo mkdir info
sudo apt-get upgrade

update命令是依赖python3的,应该是依赖系统默认的python3的某个版本,如果手动更新了python版本,并且修改了软链接。那么要将cnf-update-db改为指定的python版本

如何查找自己的python版本

whereis python
whereis python3

找到的绝对路径再执行ls -l查看软链接指向哪里

vim /usr/lib/cnf-update-db
# 原来写的是python3不是python3.6
#!/usr/bin/python3.6

vi/vim方向键无用

卸载原来的vim,重新安装即可

apt-get remove vim-common -y
apt-get install vim -y

报错ModuleNotFoundError: No module named ‘netifaces’

已经安装了netifaces模块,执行netplan命令仍然报错

root@dev-k8s-master03:~# sudo apt-get install -y python3-netifaces
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-netifaces is already the newest version (0.10.4-0.1build4).
0 upgraded, 0 newly installed, 0 to remove and 276 not upgraded.
root@dev-k8s-master03:~# cat /etc/os-release 
NAME="Ubuntu"
VERSION="18.04.6 LTS (Bionic Beaver)"

Traceback (most recent call last):
File “/usr/sbin/netplan”, line 20, in
from netplan import Netplan
File “/usr/share/netplan/netplan/init.py”, line 18, in
from netplan.cli.core import Netplan
File “/usr/share/netplan/netplan/cli/core.py”, line 24, in
import netplan.cli.utils as utils
File “/usr/share/netplan/netplan/cli/utils.py”, line 25, in
import netifaces
ModuleNotFoundError: No module named ‘netifaces’
分析:
系统安装了多个python版本,然后系统默认的python3指向的是未安装netifaces模块的python版本
解决

root@dev-k8s-master03:~# whereis python 
python: /usr/bin/python3.6m /usr/bin/python3.6m-config /usr/bin/python /usr/bin/python2.7 /usr/bin/python3.7m /usr/bin/python3.6-config /usr/bin/python3.6 /usr/bin/python3.7 /usr/lib/python2.7 /usr/lib/python3.8 /usr/lib/python3.6 /usr/lib/python3.7 /etc/python /etc/python2.7 /etc/python3.6 /etc/python3.7 /usr/local/lib/python2.7 /usr/local/lib/python3.6 /usr/local/lib/python3.7 /usr/include/python3.6m /usr/include/python3.6 /usr/share/python /usr/share/man/man1/python.1.gz

使用python3.7直接导入netifaces模块报错,python3.6则正常

root@dev-k8s-master03:~# /usr/bin/python3.6
Python 3.6.9 (default, Mar 10 2023, 16:46:00) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import netifaces
>>> exit()

root@dev-k8s-master03:~# python3
Python 3.7.5 (default, Dec  9 2021, 17:04:37) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import netifaces
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'netifaces'
>>> sudo apt-get install -y python3-netifaces
KeyboardInterrupt
>>> exit

更改默认python

root@dev-k8s-master03:~# update-alternatives --list python3
/usr/bin/python3.7
root@dev-k8s-master03:~# update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
root@dev-k8s-master03:~# update-alternatives --list python3
/usr/bin/python3.6
/usr/bin/python3.7
root@dev-k8s-master03:~# update-alternatives --config python3
There are 2 choices for the alternative python3 (providing /usr/bin/python3).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.7   2         auto mode
  1            /usr/bin/python3.6   1         manual mode
  2            /usr/bin/python3.7   2         manual mode

Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/python3.6 to provide /usr/bin/python3 (python3) in manual mode

升级git的正确方法

apt install --only-upgrade git

如果执行apt upgrade git则会升级整个系统

mysql证书相关

背景

一台新机器ubuntu1804配置清华大学的https的MySQL源,提示证书不被信任。

提示详细信息:
Certificate verification failed: The certificate is NOT trusted. The certificate chain uses expired certificate. Could not handshake: Error in the certificate verification. [IP: 101.6.15.130 443]

root@ubuntu:apt#apt update                                           
Err:6 https://mirrors.tuna.tsinghua.edu.cn/mysql/apt/ubuntu bionic Release                                     
  Certificate verification failed: The certificate is NOT trusted. The certificate chain uses expired certificate.  Could not handshake: Error in the certificate verification. [IP: 101.6.15.130 443]

分析

新安装的ubuntu机器上没有安装ca机构颁发的一些服务器的证书文件导致的。别人的一些解决方法都是将源里面的https改为http,这种方法不安全,也不是正确的解决方法。

解决
安装被ca机构信任的颁发的证书

apt install ca-certificates

再次执行apt update无报错

root@ubuntu:apt#apt update
Hit:1 http://mirrors.ustc.edu.cn/ubuntu bionic InRelease
Hit:2 https://mirrors.tuna.tsinghua.edu.cn/mysql/apt/ubuntu bionic InRelease
Hit:3 http://mirrors.ustc.edu.cn/ubuntu bionic-updates InRelease        
Hit:4 http://mirrors.ustc.edu.cn/ubuntu bionic-backports InRelease
Hit:5 http://mirrors.ustc.edu.cn/ubuntu bionic-security InRelease
Reading package lists... Done                      
Building dependency tree       
Reading state information... Done
295 packages can be upgraded. Run 'apt list --upgradable' to see them.

事后

查看这个包的详细信息,了解这个包里面都包含了什么内容

root@mysql-slave:~#apt show ca-certificates 
Package: ca-certificates
Version: 20230311ubuntu0.18.04.1
Priority: important
Section: misc
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Michael Shuler <michael@pbandjelly.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 397 kB
Depends: openssl (>= 1.1.0), debconf (>= 0.5) | debconf-2.0
Breaks: ca-certificates-java (<< 20121112+nmu1)
Enhances: openssl
Task: minimal
Supported: 5y
Download-Size: 151 kB
APT-Sources: http://mirrors.ustc.edu.cn/ubuntu bionic-updates/main amd64 Packages
Description: Common CA certificates
 Contains the certificate authorities shipped with Mozilla's browser to allow
 SSL-based applications to check for the authenticity of SSL connections.
 .
 Please note that Debian can neither confirm nor deny whether the
 certificate authorities whose certificates are included in this package
 have in any way been audited for trustworthiness or RFC 3647 compliance.
 Full responsibility to assess them belongs to the local system
 administrator.

说明:常用CA证书
包含 Mozilla 浏览器附带的证书颁发机构,允许基于 SSL 的应用程序检查 SSL 连接的真实性。
请注意,Debian 既不能确认也不能否认此软件包中包含的证书颁发机构是否已经过可信度或 RFC 3647 合规性审核。
评估它们的全部责任属于本地系统管理员。

ubuntu2204

报错key 找不到

Err:8 https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64  InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY DDCAE044F796ECB0
Get:10 https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64  InRelease [1,474 B]
Err:9 https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/amd64  InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY DDCAE044F796ECB0
Err:10 https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64  InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY DDCAE044F796ECB0
Hit:11 https://ppa.launchpadcontent.net/graphics-drivers/ppa/ubuntu jammy InRelease
Reading package lists... Done                           
W: GPG error: https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64  InRelease: The following signatures couldn't be verified because the public key is no
E: The repository 'https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64  InRelease' is not signed.
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.
W: GPG error: https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/amd64  InRelease: The following signatures couldn't be verified because the public key 
E: The repository 'https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/amd64  InRelease' is not signed.
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.
W: GPG error: https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64  InRelease: The following signatures couldn't be verified because the public key is not available: 
E: The repository 'https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64  InRelease' is not signed.
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.

解决:

root@master01:~# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DDCAE044F796ECB0
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
root@master01:~# apt-key list 
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
/etc/apt/trusted.gpg
--------------------
pub   rsa4096 2017-09-28 [SCE]
      C95B 321B 61E8 8C18 09C4  F759 DDCA E044 F796 ECB0
uid           [ unknown] NVIDIA CORPORATION (Open Source Projects) <cudatools@nvidia.com>

/etc/apt/trusted.gpg.d/graphics-drivers-ubuntu-ppa.gpg
------------------------------------------------------
pub   rsa4096 2015-08-12 [SC]
      2388 FF3B E10A 76F6 38F8  0723 FCAE 110B 1118 213C
uid           [ unknown] Launchpad PPA for Graphics Drivers Team

/etc/apt/trusted.gpg.d/ubuntu-keyring-2012-cdimage.gpg
------------------------------------------------------
pub   rsa4096 2012-05-11 [SC]
      8439 38DF 228D 22F7 B374  2BC0 D94A A3F0 EFE2 1092
uid           [ unknown] Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com>

/etc/apt/trusted.gpg.d/ubuntu-keyring-2018-archive.gpg
------------------------------------------------------
pub   rsa4096 2018-09-17 [SC]
      F6EC B376 2474 EDA9 D21B  7022 8719 20D1 991B C93C
uid           [ unknown] Ubuntu Archive Automatic Signing Key (2018) <ftpmaster@ubuntu.com>

root@master01:~# apt-key export F796ECB0 | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/nvidia.gpg
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Ubuntu 20.10 是 Ubuntu 的一个版本,如果你当前使用的是 Ubuntu 20.04,你可以通过升级来获得 Ubuntu 20.10。首先,你需要确保你的系统已经更新到最新的状态,然后你可以按照以下步骤进行升级: 1. 打开终端,输入以下命令来更新你的系统: ``` sudo apt update sudo apt upgrade sudo apt dist-upgrade ``` 2. 接下来,输入以下命令来安装升级工具: ``` sudo apt install update-manager-core ``` 3. 编辑 `/etc/update-manager/release-upgrades` 文件,确保 `Prompt` 行的值为 `normal`: ``` sudo nano /etc/update-manager/release-upgrades ``` 4. 运行以下命令来开始升级过程: ``` sudo do-release-upgrade ``` 5. 系统会提示你确认升级,按照提示操作并耐心等待升级完成。 6. 完成升级后,你的系统将会是 Ubuntu 20.10。 请注意,在升级之前,确保备份重要的数据,并确认你的系统满足 Ubuntu 20.10 的系统要求。记得在升级过程中遵循系统的提示和警告。引用 [3<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Ubuntu 20.04 / 20.10 如何升级到 Ubuntu 21.04 ?](https://blog.csdn.net/xiaochong0302/article/details/127279802)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [Ubuntu 20.10 正式发布:新特性亮点汇总](https://blog.csdn.net/zdhsoft/article/details/109391281)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值