Y9000x 2022 安装 Ubuntu 24.04.1 踩坑大全

本文最后更新于:2025年4月18日 晚上 21:31

Y9000x 2022 安装 Ubuntu 24.04.1 踩坑大全

动机

我的 Ubuntu 22.04 双系统用着用着 3.5mm 耳机突然不好使了,遂无法在编程的时候听音乐,严重影响效率。

考虑到后期想把 Linux 作为开发主力平台使用,遂决定重装。

(并且受到 Ubuntu 24.04 精美的 Gnome 46 的诱惑😍、以及对 Nvidia 驱动更好的适配🤗)

系统安装

前期准备

先把 Ubuntu 22.04 的相关分区 //homeswap 全部删除,EFI 里的 ubuntu 文件夹也删掉,还电脑一个干净的环境。

把空闲空间分出 100 G 给我的 Windows E盘,以后直接挂载 Windows 的盘作为工作空间即可,方便。

U盘制作

必须拿一个完全空白的U盘,哪怕你给U盘分区也不行。

具体步骤参考:https://blog.csdn.net/qq_21386397/article/details/129894803

正式安装

进入BIOS把U盘的启动顺序调到最高,进入ubuntu的安装页面。

只需要注意分区那里要手动分区,安装引导程序的位置选择和 Windows 一样的硬盘。

swap 划分和内存一样的大小即可,以后数据处理不够内存的话还可以临时开辟 swap 。

/ 给大一点,因为软件都装到那里。我给了 100G 。

/home 够用就行,这里主要是自己的文件以及 Conda 环境(不过也可以设置到 / 里面)的文件。给了 77 G 。

后面就是看着点点就行了。

安装之后

第一件事是把 cfw 装上,后面很多软件包都要科学上网更方便。配镜像源太麻烦。

Nvidia 驱动不需要再装了,它默认会装一个比较新的(如果你装的时候联网了的话),这一点非常好。我的它自动装了 550 的驱动,工作的很好。

然后是基础的 apt 包:

1
2
sudo apt update
sudo apt install build-essential git curl wget vim cmake

更换内核

由于扬声器的问题在最新的内核已经修复,免去了自己修改内核的麻烦,所以直接更新内核即可。喜欢GUI ,所以下载了 Mainline Kernels 软件,可以方便地管理和下载内核。

1
2
3
sudo add-apt-repository ppa:cappelikan/ppa
sudo apt update && sudo apt upgrade -y
sudo apt install -y mainline

然后就是选择需要的内核进行安装。我这里直接选择了最新的 6.11 内核,以确保拥有最新的硬件补丁。

安装好之后更新以下 GRUB ,这样启动就会自动使用该内核启动:

1
sudo update-grub

软件安装

Clash For Windows

解压后把文件夹名改为 clash ,这样更短一点,然后移动到 /opt/clash ,这里一般是安装软件的存放位置,集中会更好。

添加快捷方式到系统应用菜单里:

保存下面的图片到 /opt/clash/clash.png

clash

clash 文件夹里创建 clash.desktop 文件,内容如下:

1
2
3
4
5
6
7
8
9
10
[Desktop Entry]
Name=Clash For Windows
Name[zh_CN]=Clash For Windows
Comment=Clash For Windows
Comment[zh_CN]=Clash For Windows
Exec=/opt/clash/cfw --no-sandbox
Terminal=false
Icon=/opt/clash/clash.jpeg
Categories=Development
Type=Application

然后创建一个软链接到 /usr/share/applications

1
sudo ln -s /opt/clash/clash.desktop /usr/share/applications/clash.desktop

重启系统或是注销或是重启gnome即可生效。

内部配置:

首先到 设置 > 网络 > 代理 里开启手动,把HTTP、HTTPS、FTP、SOCKS全部调为127.0.0.1,端口7890。

然后clash里确保 服务、TUN、混合模式 全部开启。

适配次元城动漫的需求:【Clash】我使用到的CFW特性的相关记录

星火应用商店

https://www.spark-app.store/

不解释,必装好吧。

常用必装软件

Snap商店:Firefox、Chrome、VSCode、Typora、Drawio

星火应用商店:LinuxQQ、WeChat(wine)、滴答清单、网易云音乐(wine)、WPS、次元城动漫

Tweaks 以及 gnome 插件系统

可参考 https://cn.linux-console.net/?p=16747 。

装好后在字体那里改为 1.25 缩放,更佳适配笔记本高分屏,要不然字太小了。

fsearch安装

1
2
3
sudo add-apt-repository ppa:christian-boxdoerfer/fsearch-stable
sudo apt update
sudo apt install fsearch

grub-customizer安装

1
2
3
sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer

hexo 安装

写博客用。

1
2
3
sudo apt install nodejs npm
sudo npm install hexo-cli -g
sudo apt install pandoc

配置

Ubuntu 24.04 系统配置:

网络:开始手动代理

电源:设置电源按钮行为、显示电量百分比

多任务:应用切换:仅包括当前工作空间中的应用

Ubuntu 桌面:

  • 桌面图标 关闭 Show Home Folder
  • Dock:Configure Dock Behavior 里关闭 包括已卸载的卷

鼠标和触摸板:调快一点

键盘:删除切换输入法的快捷键,因为我要使用fcitx5

系统:

  • 区域和语言:把输入法框架调为fcitx5
  • 用户:开启自动登录、指纹登录。设置二次元头像。
  • 关于:更改设备名称,默认的太长了,显示到终端里很难看。

Fcitx5 配置:

由于ubuntu24.04自带fcitx5,只是没有启用,所以只需要去gnome设置 系统 > 区域与语言 > Manage Installed languages > 键盘输入法系统 里从iBus切换到fcitx5即可。不要卸载iBus!没必要还可能引入不必要的麻烦。

使用fcitx5不需要关闭wayland。

image-20241005203457897

image-20241005203438414

image-20241005203557693

fcitx5提供了方便的剪贴板 ctrl+; 即可唤起。

如果希望输入法使用下面的双排显示,可以到 输入法 > 拼音 > 预编辑模式 切换为 不显示

image-20241005203725766

如果希望添加 ii 和 io 快捷输入markdown内联代码和公式,可以到 输入法 > 拼音 > 管理自定义词组 进行添加。这里还可以配置 PgUp 和 PgDn 切换候选词页面。

好看的macOS皮肤:

thep0y/fcitx5-themes-candlelight: fcitx5的简约风格皮肤——烛光

VSCode 配置:

登录 Github 账号,自动同步配置。但是注意去 setting.json 里把 Windows 特定的配置给注释掉。

安装 Jetbrains Mono 和 0xProto Nerd Mono 字体。

Typora 配置:

自己看着设置去配就行了。

Git 和 Github 配置

配置 Git:

1
2
3
git config --global user.name "Qalxry"
git config --global user.email "qalxry@qq.com"
git config --global --list

生成密钥:

1
2
3
4
ls -al ~/.ssh
ssh-keygen -t ed25519 -C "qalxry@qq.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

复制公钥到 Github:

1
cat ~/.ssh/id_ed25519.pub

测试:

1
ssh -T git@github.com

使用需求

开机自动启动QQ等软件:

可在 Tweaks(优化) 里面加入。然后 QQ 里面设置自动登录,非常方便。

开机自动挂载 Windows 硬盘分区:

在 crontab 里面设置开机运行一个脚本进行挂载。建议事先给分区都分配一个没有空格的英文名称,这样 Ubuntu 挂载的适合就会挂载的到对应名称的文件夹里,方便辨识,否则会使用 UUID 作为硬盘挂载的名称。

当然我们挂载分区就直接使用 UUID 比较方便。可以用自带的 磁盘 应用程序来查看 UUID ,不容易搞错。

1
2
3
4
5
6
{
echo "Starting auto mount script"
mkdir -p /media/takagisan/Storage
mount UUID=7152E432F736F985 /media/takagisan/Storage
echo "Finished auto mount script"
} > /home/takagisan/myfiles/auto_mount.log 2>&1

其实最好再写一个脚本在关机的时候删除创建的文件夹比较好。不过不写应该也问题不大,因为每次开机都由我们的脚本来挂载就行,不要再去手动挂载了。

由于这里必须使用 root 权限,所以下面要配置 root 下的 cron:

1
sudo crontab -e

在最后面加上:

1
@reboot /home/takagisan/myfiles/auto_mount.sh

Grub 美化

参考:Grub2主题修改和美化--------Linux&Windows

推荐两款好看的主题:

Elegant-wave-grub-themes

image-20241006141553647

Pentract grub theme

image-20241006141623599

Ubuntu 系统备份

由于我已经被 Ubuntu 24.04 搞麻了,只能备份一下保险。

使用 timeshift 将整个系统备份到我的移动磁盘上专门的 ext4 分区上。

1
sudo apt install timeshift

整个过程还是比较简单的,跟着 GUI 选项一步步选就行了。

深度学习环境配置

安装 Miniconda3:

使用 wget 命令下载 Miniconda 最新版本的安装脚本:

1
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

使用 bash 运行下载的 Miniconda 安装脚本:

1
bash Miniconda3-latest-Linux-x86_64.sh

这里的使用许可很长,不要一直按 enter,太慢,直接用方向下键。

一共需要输入两次 yes :

  • 第一次是让你确认许可
  • 第二次是在安装脚本运行完毕后,将被询问是否初始化 Miniconda 。选择 yes,此步骤会自动将 Miniconda 添加到系统的 PATH 环境变量中,这非常重要!选错只能重装了。

初始化后,需要重新启动终端或运行以下命令以使更改生效:

1
source ~/.bashrc

卸载 Miniconda 3:

1
2
rm -rf ~/miniconda3
rm -rf ~/.condarc ~/.conda ~/.continuum

然后去 ~/.bashrc 里面找到下面的内容并删除:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/takagisan/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/takagisan/miniconda3/etc/profile.d/conda.sh" ]; then
. "/home/takagisan/miniconda3/etc/profile.d/conda.sh"
else
export PATH="/home/takagisan/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<

安装 CUDA 和 cuDNN :

安装 CUDA:

唉,安装了 CUDA 12.4 发现和 PyTorch 2.2.2 不太适配,还是编译不了 CUDA 代码。虽然可以把 PyTorch 更新到 2.4.1 就支持 CUDA 12.4 了,但是担心其他的包跟不上那么快。还是装回 CUDA 12.1 吧,只是编译的时候设置环境变量为 GCC 12.3 就好。

可从这里查看 CUDA 和 GCC 版本的对应关系:https://stackoverflow.com/questions/6622454/cuda-incompatible-with-my-gcc-version

由于 Ubuntu 24.04 的 GCC 版本是 13.2 的,而支持该版本 GCC 的 CUDA 最低版本是 12.4 ,恰好 CUDA 12.4 需要的驱动版本就是 550 (Ubuntu 24.04 自动安装的,好家伙原来考虑到了这一层吗),于是安装 12.4 版本的即可。

最好不要无视 GCC 版本强制安装,后面编译 CUDA 代码可能会出问题。

官网 选择合适的 CUDA ,然后选择 Installer Typerunfile(local) ,这个比较方便可控。然后根据指导即可。

比如 12.4 的:

1
2
wget https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_550.54.14_linux.run
sudo sh cuda_12.4.0_550.54.14_linux.run

遇到提示存在已有的installer,选择 continue

注意如果不想再安装N卡驱动,就取消勾选 Driver ,由于前面一般都装好了驱动,所以取消勾选。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ sudo sh cuda_12.4.0_550.54.14_linux.run
请把您的手指放在指纹读取器上
===========
= Summary =
===========

Driver: Not Selected
Toolkit: Installed in /usr/local/cuda-12.4/

Please make sure that
- PATH includes /usr/local/cuda-12.4/bin
- LD_LIBRARY_PATH includes /usr/local/cuda-12.4/lib64, or, add /usr/local/cuda-12.4/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-12.4/bin
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 550.00 is required for CUDA 12.4 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
sudo <CudaInstaller>.run --silent --driver

Logfile is /var/log/cuda-installer.log

出现上面的就是成功了,那个警告仅仅是因为取消重复安装驱动而已。

安装好后按照提示里去 ~/.bashrc 里添加环境变量:

1
2
3
# CUDA-12.4
export PATH=$PATH:/usr/local/cuda-12.4/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-12.4/lib64

然后 source ~/.bashrc 更新配置。

通过 nvcc --version 查看是否安装成功。

安装 cuDNN:

根据官网指导安装即可,注意选择 deb(local) 即可,这样会方便一点。

卸载原有 CUDA:

CUDA提供了卸载程序,sudo 运行该卸载程序,根据指导卸载即可。

卸载程序位于 /usr/local/cuda-12.1/bin/cuda-uninstaller ,其中的版本号自行替换。

后期注意修改 ~/.bashrc 即可。

Conda 环境配置:

涵盖了目前工作内容所需的全部包。

1
2
3
4
5
6
7
8
9
10
conda create -n gnn python=3.10 -y
conda activate gnn
pip install torch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/cu121
pip install torch-scatter torch-sparse torch-cluster -f https://data.pyg.org/whl/torch-2.2.2+cu121.html
pip install dgl -f https://data.dgl.ai/wheels/torch-2.2/cu121/repo.html
pip install tensorboard torch_geometric scikit-learn pydantic xformers==0.0.25.post1 transformers
pip install seaborn umap pacmap plotly

conda install -c pytorch faiss-gpu
pip install pytorch-metric-learning

问题解决

解决 CUDA 12.1 与 GCC 13.2、12.3.0 的兼容性问题导致 CUDA 编译报错:

报错信息如下:

第一种是使用 Ubuntu 24.04 默认预装的 GCC 13.2 时报错编译器版本不兼容:

1
2
3
4
/usr/local/cuda-12.1/include/crt/host_config.h:132:2: error: #error -- unsupported GNU version! gcc versions later than 12 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
132 | #error -- unsupported GNU version! gcc versions later than 12 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
| ^~~~~
error: command '/usr/local/cuda-12.1/bin/nvcc' failed with exit code 1

第二种是降级到 CUDA 12.1 最高支持版本 GCC 12.3 出现的另外一个问题:

似乎是编译器的问题?详情见 https://github.com/pybind/pybind11/issues/4606 。

1
2
3
4
5
6
7
8
9
10
11
/home/takagisan/miniconda3/envs/gnn/lib/python3.10/site-packages/torch/include/pybind11/detail/../cast.h: In function ‘typename pybind11::detail::type_caster<typename pybind11::detail::intrinsic_type<T>::type>::cast_op_type<T> pybind11::detail::cast_op(make_caster<T>&)’:
/home/takagisan/miniconda3/envs/gnn/lib/python3.10/site-packages/torch/include/pybind11/detail/../cast.h:45:120: error: expected template-name before ‘<’ token
45 | return caster.operator typename make_caster<T>::template cast_op_type<T>();
| ^
/home/takagisan/miniconda3/envs/gnn/lib/python3.10/site-packages/torch/include/pybind11/detail/../cast.h:45:120: error: expected identifier before ‘<’ token
/home/takagisan/miniconda3/envs/gnn/lib/python3.10/site-packages/torch/include/pybind11/detail/../cast.h:45:123: error: expected primary-expression before ‘>’ token
45 | return caster.operator typename make_caster<T>::template cast_op_type<T>();
| ^
/home/takagisan/miniconda3/envs/gnn/lib/python3.10/site-packages/torch/include/pybind11/detail/../cast.h:45:126: error: expected primary-expression before ‘)’ token
45 | return caster.operator typename make_caster<T>::template cast_op_type<T>();
|

我想到之前我用 Ubuntu 22.04 的时候,都能轻松编译通过,于是到之前编译的 .o 文件里查看了一下编译器版本,是 11.4.0 ,于是我果断下载了这个版本的 GCC 和 G++ ,果然解决了这个问题。上面 issue 里面也有人提到使用更低版本的 GCC 编译成功了,也暗示着这个方法可行。

1
sudo apt install gcc-11 g++-11

调一下不同版本的优先级:

1
2
3
4
5
6
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 30
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 20
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 30
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 10

验证优先级:

1
2
3
4
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
gcc --version
g++ --version

再试一下编译成不成功:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
(gnn) (base) takagisan@yuki:/media/takagisan/Storage/Project/SIT2024/2_Dev/pygmkan$ pip install .
Processing /media/takagisan/Storage/Project/SIT2024/2_Dev/pygmkan
Preparing metadata (setup.py) ... done
Building wheels for collected packages: pygmkan
Building wheel for pygmkan (setup.py) ... done
Created wheel for pygmkan: filename=pygmkan-1.0-cp310-cp310-linux_x86_64.whl size=93792 sha256=21654d8d0d339ad89ccf0982ec9648ba77c78b95fcfdb0c093d354d25f40eacc
Stored in directory: /tmp/pip-ephem-wheel-cache-lrwgwoa7/wheels/2c/1a/15/69287036b59cb26294b63cae0a454973880588b562be44443b
Successfully built pygmkan
Installing collected packages: pygmkan
Attempting uninstall: pygmkan
Found existing installation: pygmkan 1.0
Uninstalling pygmkan-1.0:
Successfully uninstalled pygmkan-1.0
Successfully installed pygmkan-1.0

完美解决!

解决混合模式和独显模式下的 GPU 问题:

这个是 6.11 kernel 带来的问题,换回 6.8.0 就好了。久违的 使用独立显卡启动 也回来了。看来只能等 Nvidia Driver 适配更高版本的 kernel 才行了。

解决 VSCode 和 Chrome 初次启动时显示“您登录计算机时,您的登录密钥环未被解锁”的问题:

参考解决方案: 解决:您登录计算机时,您的登录密钥环未被解锁

在使用Ubuntu Desktop的时候,自行安装的软件,在打开应用时会出现提示:“您登录计算机时,您的登录密钥环未被解锁”。

  1. 终端输入 seahorse

  2. 点击 + ,添加“密码密钥环”

  3. 名称任意

  4. 不输入密码,直接继续

  5. 继续

  6. 设为默认

完成后重启。

解决 LinuxQQ 由于启动快于 Clash 导致 QQ 登陆失败的问题:

启动应用程序 软件里修改 QQ 的自启动命令为: bash -c 'sleep 3 && /opt/QQ/qq %U' 即可解决。

解决 Gnome 系统应用开机时启动非常慢的问题:

可能是我安装又卸载了 flatpak 的问题,参见:https://blog.csdn.net/HHoao/article/details/142669896

安装 dbus-broker 软件包解决。

可以通过删除 xdg-desktop-portal-gnome 软件包或者安装 dbus-broker 软件包解决。

1
2
3
4
sudo apt remove xdg-desktop-portal-gnome
sudo apt install dbus-broker
sudo systemctl enable --global dbus-broker.service
sudo systemctl enable dbus-broker.service

重启后问题解决,但是引发了 fcitx5 不再开机自启动的问题,可以手动把 fcitx5 添加到启动应用程序里面即可。

PS:这个也是导致 fix_theme.sh 需要长时间( sleep 60 )才能生效的问题,修复了这个后只需要 sleep 5 就可以了。

解决Firefox浏览器鼠标中间没有自动滚动:

去Firefox的设置里面找 自动滚动 。Chrome似乎没有这个设置,不知道flag里面有没有。反正我一直使用firefox,不管了

解决初次使用Firefox进行同步时,没有同步到密码之类的:

如果之前没有完全勾选同步这些选项,则后面即使再勾选回来,也没用了,必须在首次启动firefox的之前时候就勾选上才会自动同步。

解决ubuntu24.04中安装网易云音乐(wine)报错 libsane 无法安装的问题:

在此下载deb手动进行安装即可: https://launchpad.net/ubuntu/kinetic/amd64/libsane/1.1.1-5

解决百度翻译(wine)启动后闪退问题:

/usr/share/applications/com.baidu.translateclient.desktopExec 行末添加 --no-sandbox 即可。应用更改需要 alt+f2 并输入 r 重启 gnome 。

解决百度翻译(wine)截图翻译只有黑屏的问题:

这个和搜狗输入法闪烁一样,都是 Wayland 的问题,唉,没办法只能先老老实实禁用 Wayland 用回 X11 了。

临时禁用的方法是注销后在右下角选择 Xorg 启动,永久禁用的方法是:

1
sudo nano /etc/gdm3/custom.conf

取消 WaylandEnable=false 的注释即可。但是会导致下面的问题 禁用 Wayland 导致无法启用黑夜模式

解决禁用 Wayland 导致无法启用黑夜模式的问题:

禁用 Wayland 有个 BUG,就是每次启动你的黑夜模式就调不了了,只有白天模式。

有一个临时解决的方法是:每次开机都得手动开关一下 Gnome 拓展里的 User Theme ,这样就恢复正常了。不过也可以通过脚本来完成,约等于没有 BUG 了🤗 。

下面的命令保存为 fix_theme.sh ,后面的路径需要自行修改。

1
2
3
4
5
6
7
8
9
10
#!/bin/bash

# 等待一些时间确保图形会话已完全启动
sleep 5

# 禁用并重新启用 GNOME 扩展并记录日志
gnome-extensions disable user-theme@gnome-shell-extensions.gcampax.github.com > /home/takagisan/myfiles/fix_theme.log 2>&1
sleep 3
gnome-extensions enable user-theme@gnome-shell-extensions.gcampax.github.com > /home/takagisan/myfiles/fix_theme.log 2>&1

可能会想到和开机自动挂载硬盘分区一样,用 crontab 来开机自动运行,但我们必须要确保 gnome 运行之后再运行我们的脚本,所以不能使用 crontab 了。我们使用 autostart.desktop 来自动执行文件。

1
sudo chmod +x /home/takagisan/myfiles/fix_theme.sh

创建 ~/.config/autostart/fix_theme.desktop 文件:

1
2
3
4
5
6
[Desktop Entry]
Type=Application
Exec=/home/takagisan/myfiles/fix_theme.sh
Terminal=false
Name=Fix Theme
Comment=Fix theme on login

不过有的时候调 User Theme 没有用,似乎需要在启动一段时间后再去调才能够成功,所以把 sleep 调大了一些,也许有用。

解决y9000x 2022的没有外放声音的问题:

更新linux内核版本。尽管低音有些缺失。ubuntu 24.04自带的6.8.0还是没有加入cs35l41放大器的补丁,所以还是得更新内核。

我直接更新到了 6.11 。

解决y9000x 2022出现的3.5mm耳机只有噼啪响的问题:

直接重装系统吧,应该是你装着装着搞坏了,此类问题真的非常难排查。建议装 ubuntu 24.04.1

解决ubuntu24.04使用Wayland和fcitx5/iBUS的输入法问题:

要么卸载fcitx5,改用fcitx4并关闭wayland才能使用搜狗输入法。要么加入我们fcitx5大军吧!

解决ctrl+space不能够切换输入法的问题:

检查ctrl+space是否和gnome的快捷键冲突了,我就是先手贱把gnome设置里的切换输入法快捷键从super+space改成了ctrl+space,导致和fcitx5的冲突了。解决方法是删除gnome里的快捷键。

解决y9000x 2022在Ubuntu22.04和Ubuntu24.04的指纹设备问题:

https://askubuntu.com/questions/1445458/ubuntu-22-04-fingerprint-sensor-04f30c4c-elan-microelectronics-corp-hp-envy

使用官方提供的驱动可以完美解决!指纹就是爽!终端 sudo 都可以用指纹!

解决fcitx5输入法无法在gnome内置应用中显示GUI的问题:

Gnome 插件:Input Method Panel

https://extensions.gnome.org/extension/261/kimpanel/

但是会导致你的fcitx5配置不会被应用……没有仔细研究,反正这个需求不是很强,所以还是到不得不用的时候再开启吧……

解决Ubuntu输入emoji🤗的问题:

Gnome 插件:Emoji Copy

https://extensions.gnome.org/extension/6242/emoji-copy/

完美适配 24.04 的 gnome 46 。还可以到插件设置里改快捷键。快捷键设置:

  • Super + ;<super>semicolon
  • Super + .<super>period

改快捷键之后注意要点击旁边的✅进行确定,否则不会应用。

解决 Clash 导致无法 ssh 到 Github 的问题:

参考:https://docs.github.com/zh/authentication/troubleshooting-ssh/using-ssh-over-the-https-port

GitHub Enterprise Server 用户:目前不支持经 SSH 通过 HTTPS 端口访问 GitHub Enterprise Server。

要测试通过 HTTPS 端口的 SSH 是否可行,请运行以下 SSH 命令:

1
ssh -T -p 443 git@ssh.github.com

启用通过 HTTPS 的 SSH 连接:

如果你能在端口 443 上通过 SSH 连接到 git@ssh.github.com,则可覆盖你的 SSH 设置来强制与 GitHub.com 的任何连接均通过该服务器和端口运行。

要在 SSH 配置文件中设置此行为,请在 ~/.ssh/config 编辑该文件,并添加以下部分:

1
2
3
4
Host github.com
Hostname ssh.github.com
Port 443
User git

再次连接到 GitHub.com 来测试这是否有效。

解决终端以及认证弹窗没有指纹解锁的问题:

此处假设开机登录的时候能够使用指纹。

  1. 打开/etc/pam.d/common-auth文件进行编辑:

    1
    sudo nano /etc/pam.d/common-auth

  2. 在文件顶部的添加以下行:

    1
    auth    sufficient   pam_fprintd.so

    完整的文件内容应如下所示:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    #
    # /etc/pam.d/common-auth - authentication settings common to all services
    #
    # This file is included from other service-specific PAM config files,
    # and should contain a list of the authentication modules that define
    # the central authentication scheme for use on the system
    # (e.g., /etc/shadow, LDAP, Kerberos, etc.). The default is to use the
    # traditional Unix authentication mechanisms.
    #
    # As of pam 1.0.1-6, this file is managed by pam-auth-update by default.
    # To take advantage of this, it is recommended that you configure any
    # local modules either before or after the default block, and use
    # pam-auth-update to manage selection of other modules. See
    # pam-auth-update(8) for details.
    auth sufficient pam_fprintd.so
    # here are the per-package modules (the "Primary" block)
    auth [success=2 default=ignore] pam_unix.so nullok
    auth [success=1 default=ignore] pam_sss.so use_first_pass
    # here's the fallback if no module succeeds
    auth requisite pam_deny.so
    # prime the stack with a positive return value if there isn't one already;
    # this avoids us returning an error just because nothing sets a success code
    # since the modules above will each just jump around
    auth required pam_permit.so
    # and here are more per-package modules (the "Additional" block)
    auth optional pam_cap.so
    # end of pam-auth-update config

解决GRUB选择选项后背景不清空的问题:

为每个 menuentry 添加:

1
2
3
if background_image ; then
clear
fi

建议到 grub-customizer 里编辑。

解决外接无线键盘 F1 ~ F12 变成调亮度等功能的问题:

参考解决方法:Ubuntu_部分键盘F1~F12强制为功能键

有点奇怪,2.4G模式下会出现这个问题,但如果改为有线连接就没问题了。

为了避免对系统的不当修改,还是放弃 2.4G 直接使用有线模式比较保险吧。

解决 pkexec 没传递环境变量的问题

法1:

使用 alias gsudo='pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY GTK_THEME=$GTK_THEME QT_STYLE_OVERRIDE=$QT_STYLE_OVERRIDE XDG_CURRENT_DESKTOP=$XDG_CURRENT_DESKTOP'

法2:

gsudo.sh 脚本放在 /usr/local/bin/gsudo.sh 并且直接使用是一种可行的方法,尤其是在你希望通过命令 gsudo 来执行该脚本时。

这种方式将会创建一个更为灵活的解决方案,避免在每个用户的 .bashrc.zshrc 中添加别名。你可以按以下方式处理:

步骤 1: 创建脚本文件

  1. 使用你提供的内容创建脚本 gsudo.sh

    1
    sudo nano /usr/local/bin/gsudo.sh

    然后将以下内容粘贴到文件中:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    #!/bin/bash
    pkexec env \
    DISPLAY="$DISPLAY" \
    XAUTHORITY="$XAUTHORITY" \
    GTK_THEME="$GTK_THEME" \
    QT_STYLE_OVERRIDE="$QT_STYLE_OVERRIDE" \
    XDG_CURRENT_DESKTOP="$XDG_CURRENT_DESKTOP" \
    DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS" \
    XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" \
    DBUS_SESSION_BUS_PID="$DBUS_SESSION_BUS_PID" \
    "$@"
  2. 保存并关闭文件。

步骤 2: 赋予执行权限

确保 gsudo.sh 脚本具有执行权限:

1
sudo chmod +x /usr/local/bin/gsudo.sh

步骤 3: 创建 gsudo 的别名

你可以通过创建一个符号链接来让 gsudo 命令指向这个脚本。这样,你只需要在任何地方执行 gsudo 即可调用脚本:

1
sudo ln -s /usr/local/bin/gsudo.sh /usr/local/bin/gsudo

步骤 4: 测试命令

执行 gsudo 命令来确认它是否按预期工作:

1
gsudo your-command

为什么这样做

  1. 全局可用:将脚本放在 /usr/local/bin/ 目录下,意味着它对系统中的所有用户都可用。
  2. 无需修改配置文件:不需要修改 .bashrc.zshrc 文件,因此不会干扰现有的用户配置。
  3. 灵活性:这种方法让你能够根据需要调整脚本的内容,并且可以通过符号链接调整命令名称。

这种方法比直接在用户的 .bashrc.zshrc 文件中添加别名更加灵活,也更符合脚本和命令的常规管理方式。如果你在系统范围内管理多个用户,使用这种方法通常是推荐的做法。

解决双系统切换导致windows时间错乱的问题

1
2
3
4
sudo apt-get install ntpdate # 在Ubuntu下更新本地时间
sudo ntpdate time.windows.com
sudo apt install util-linux-extra
sudo hwclock --localtime --systohc # 将本地时间更新到硬件上

解决Alt+Tab切换到VSCode后,VSCode异常滚动的问题

安装 imwheel

1
2
sudo apt-get install imwheel
imwheel # 启动

必须在每次开机时启动它(或者在应用程序中添加它来开机启动)。

可以用 pgrep -lf imwheel 来看它是否在运行;可以用 pkill imwheel 停止它。

如果只是这样做,还会有无法 Ctrl+滚轮 的问题,以及鼠标侧键都用不了了。

进一步配置 imwheel :

1
nano ~/.imwheelrc

输入:

1
2
3
4
5
6
7
8
9
10
11
12
13
".*"
None, Thumb1, Alt_L|Left
None, Thumb2, Alt_L|Right
Control_L, Up, Control_L|Button4
Control_L, Down, Control_L|Button5
Control_R, Up, Control_R|Button4
Control_R, Down, Control_R|Button5
Shift_L, Up, Shift_L|Button4
Shift_L, Down, Shift_L|Button5
Alt_L, Up, Button4,3
Alt_L, Down, Button5,3
Alt_R, Up, Button4,3
Alt_R, Down, Button5,3

(以上是我弄的配置,还另外加了 Alt+滚轮 高速滚动的效果,全部窗口有效)

含义:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<Key Modifiers Input>, <Mouse Action Input>, <Key Action Output>

Key Modifiers Input:
Alt_L, Alt_R, Meta_L, Meta_R, Control_L, Control_R, Shift_L, Shift_R or None
Mouse Action Input:
Up, Down, Left, Right, Thumb
Key Action Output:
KeySym [, Output Repetitions[, Delay Before KeyUp Event [, Delay Before Next KeyPress Event]]]

Index Interpreted As Button Number
1 Wheel Up 4
2 Wheel Down 5
3 Wheel Left 6
4 Wheel Right 7
5 Thumb Button 1 8
6 Thumb Button 2 9

https://wiki.archlinux.org/title/IMWheel

https://man.archlinux.org/man/imwheel.1

保存后:

1
killall imwheel && imwheel

为了确保开机启动,可以:

1
echo "killall imwheel; imwheel" >> ~/.bashrc

参考:

https://blog.csdn.net/qq_33512762/article/details/128985799

https://github.com/freeplane/freeplane/issues/134#issuecomment-1567664447

设置断电时自动开启节电模式

可以将电池模式下的低电量阈值调为 99(不能是 100,否则不启用),这样只要断开电源,就会马上因为低电量事件开启节电模式。

而插电模式下不会有低电量时间,插上电后 Ubuntu 会自动恢复成原来的模式。

命令如下:

1
sudo nano /etc/UPower/UPower.conf

PercentageLow 设置为 99:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# When UsePercentageForPolicy is true, the levels at which UPower will
# consider the battery low, critical, or take action for the critical
# battery level.
#
# This will also be used for batteries which don't have time information
# such as that of peripherals.
#
# If any value is invalid, or not in descending order, the defaults
# will be used.
#
# Defaults:
# PercentageLow=20
# PercentageCritical=5
# PercentageAction=2
PercentageLow=99 # 把这里的值改为99
PercentageCritical=5
PercentageAction=2

重启UPower服务后即可:

1
sudo systemctl restart upower

Y9000x 2022 安装 Ubuntu 24.04.1 踩坑大全
https://qalxry.github.io/2024/10/06/Y9000x-2022-安装-Ubuntu-24-04-1-踩坑大全/
作者
しずり雪
发布于
2024年10月6日
更新于
2025年4月18日
许可协议