Ubuntu系统手动升级

1、sudo apt update

2、sudo apt upgrade -y

3、sudo do-release-upgrade

或是下面2个命令:
sudo apt update && apt upgrade -y
sudo do-release-upgrade 

ps:
sudo do-release-upgrade -h
Usage: do-release-upgrade [options]

Options:
  -h, --help            show this help message and exit
  -V, --version         Show version and exit
  -d, --devel-release   If using the latest supported release, upgrade to the
                        development release
  --data-dir=DATA_DIR   Directory that contains the data files
  -p, --proposed        Try upgrading to the latest release using the upgrader
                        from $distro-proposed
  -m MODE, --mode=MODE  Run in a special upgrade mode. Currently 'desktop' for
                        regular upgrades of a desktop system and 'server' for
                        server systems are supported.
  -f FRONTEND, --frontend=FRONTEND
                        Run the specified frontend
  -c, --check-dist-upgrade-only
                        Check only if a new distribution release is available
                        and report the result via the exit code
  --allow-third-party   Try the upgrade with third party mirrors and
                        repositories enabled instead of commenting them out.
  -q, --quiet           
软件清除:

	sudo apt-get autoclean: 自主清理旧版本的软件缓存 /var/cache/apt/archives/
	sudo apt-get clean: 清理所有软件缓存 /var/cache/apt/archives/
	sudo apt-get autoremove: 自主删除系统不再使用的孤立软件,慎用
	
内核清除:	

	dpkg --get-selections | grep linux
	
	能看到已经安装的版本,其中带image的一般就是旧版本
	deinstall指已经删除的旧版本
	install表示还未删除的旧版本内核​​
	
清理残留数据:
	dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P 

(1) remove – 卸载软件包
(2) autoremove – 卸载所有自动安装且不再使用的软件包
(3) purge – 卸载并清除软件包的配置  


这里重点介绍一下autoremove:
apt-get autoremove的行为重点是卸载所有自动安装,例如:C 依赖于 B, D 依赖于B, 且D没有被其他手动安装的包依赖。 
apt-get remove C 将删除C, 同时提示你用apt-get autoremove去清除B,D ;
apt-get autoremove C 将删除B, C, D 。所以,这条命令最恐怖的是在不了解的情况下,你不知道他会把系统中的什么配置文件给删除.
查看已安装的软件:
 apt list --installed | grep -i package关键字
 dpkg --list | grep -i package关键字

source源换成国内:只针对20.04

1、sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

2、把下面内容copy覆盖到sources.list里,保存

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse

deb http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse

3、sudo apt update

常用的Ubuntu版本代号如下:

  • Ubuntu 22.04:jammy
  • Ubuntu 20.04:focal
  • Ubuntu 18.04:bionic
  • Ubuntu 16.04:xenial

参考:

Ubuntu 如何 在线升级系统_ubuntu_~晨曦静竹~-华为云开发者联盟

如何在Ubuntu中用apt命令删除/卸载软件包(remove/clean/purge)_ubuntu remove-CSDN博客

sudo apt-get autoremove最好不使用_sudo apt autoremove-CSDN博客

Ubuntu20.04更换国内镜像源(阿里、网易163、清华、中科大)_ubuntu_MidoQ-重庆城市开发者社区

ubuntu20.04更改为国内软件源_ubuntu20.04 ruanjianyuan-CSDN博客

Ubuntu 22.04 更换内地源_ubuntu22.04更换国内源-CSDN博客

Ubuntu系统界面卡死解决方案记录_ubuntu卡在开机界面-CSDN博客

### Ubuntu 系统升级失败的解决方案 当遇到 Ubuntu 系统升级失败的情况时,可以尝试以下方法解决问题: #### 方法一:清理 APT 缓存并更新软件包列表 APT 的缓存可能存在问题,导致系统无法正常完成升级。可以通过运行以下命令清除旧的依赖项和错误索引,并刷新软件包列表[^4]。 ```bash sudo apt-get autoclean && sudo apt-get clean && sudo apt-get update ``` 此过程有助于移除无用的文件以及修复潜在的索引问题。 --- #### 方法二:手动处理冲突或损坏的软件包 有时某些特定的第三方仓库(如 Redis 的自定义源)可能导致升级过程中出现问题。在这种情况下,建议禁用这些仓库或将它们暂时移到其他位置后再继续升级。 对于 Redis 的情况,可采取如下措施: 1. 将 `/etc/apt/sources.list.d/redis*` 文件重命名或移动至安全目录。 2. 执行 `sudo apt-get update` 更新本地索引。 3. 如果仍有残留数据影响升级,则进一步执行清理操作以确保环境干净。 --- #### 方法三:使用高级工具排查启动问题 如果系统升级后进入黑屏状态或者完全无法引导,可能是由于 GRUB 配置不当或其他核心组件缺失引起的。此时可以根据官方指南逐步调试并恢复正常的开机流程[^1]。 具体步骤包括但不限于以下几个方面: - **检查磁盘分区挂载状况** ```bash mount | grep 'on / ' ``` - **重建 initramfs 和 grub 菜单条目** ```bash sudo update-initramfs -u sudo update-grub ``` 上述指令能够帮助重新构建必要的初始化脚本和服务加载器配置文件。 --- #### 方法四:针对显卡驱动引发的兼容性异常 随着新内核版本发布,部分图形适配器可能会因为缺乏及时支持而失效。对此类现象需特别关注 NVIDIA 或 AMD 显卡的相关补丁程序是否存在匹配当前系统的发行版[^5]。 以下是基于 DKMS 动态编译机制实现自动维护 GPU 设备驱动的方法概述: 1. 安装动态模块管理服务; ```bash sudo apt-get install dkms ``` 2. 查询已安装好的驱动型号信息; ```bash lsmod | grep nvidia ``` 3. 强制重新编译指定代号的目标模块实例; ```bash sudo dkms install -m nvidia -v XXX.XX ``` 注意替换其中的大写占位符为实际检测所得数值! --- #### 总结说明 综上所述,在面对复杂的 Linux 发行版迁移场景下,务必保持耐心逐一排除干扰因素直至最终成功达成目标为止。以上列举了几种常见类型的应对策略供参考选用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值