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)).