ubuntu 22.04.3 执行更新报错 Segmentation fault (core dumped)

最近有台设备意外关机重启,经过磁盘文件损坏修复,可以成功进入系统。但是执行更新命令的时候报错 Segmentation fault (core dumped),如下:

观察输出日志,锁定文件 /usr/lib/cnf-update-db,于是查看文件内容,发现是个 Python3 的脚本,里面的内容如下:

于是逐行执行脚本,发现执行到 from CommandNotFound.db.creator import DbCreator 出现闪退。

观察系统日志:

从系统日志上可以看到 libsqlite3 调用的数据库出现异常了,要么是数据库出问题,要么安装包出问题。更高概率是某个数据库文件出现问题了,那到底是哪个数据库文件呢?

我们不妨卸载重装一下 command-not-found,如下:

结果问题依旧,那么是不是 /var/lib/command-not-found 这个目录下的数据库导致的呢?我们观察数据库文件:

可以看到,这个目录下恰好有 libsqlite3 调用的数据库文件,我们删除这个目录,然后重启系统。

结果出乎意外的修复了这个问题。

参考链接


Ubuntu镜像源cn.arichinve.ubuntu.com自动跳转到清华镜像

Ubuntu 更新系统

在执行后,发现输出如下信息:

我明明记得源配置的是 cn.archive.ubuntu.com ,但是发现,系统更新时,自动去找了清华大学的Ubuntu源。

查看系统的 /etc/apt/sources.list 里面配置的也是 cn.archive.ubuntu.com

带着很多问号,在浏览器打开 https://cn.archive.ubuntu.com,发现网站已经自动跳转到清华镜像站了。

如果配置了防火墙过滤的场景需要特别注意这种情况。

参考链接


Ubuntu镜像源cn.arichinve.ubuntu.com不可用原因分析和解决

当笔记本电脑盖子关闭时如何禁用指纹认证(ubuntu 24.04)?

To disable fingerprint authentication when the laptop lid is closed, and re-enable when it is reopened, we will use acpid to bind to the button/lid.* event to a custom script that will stop and mask the fprintd service on lid close, and unmask and start the fprintd service on lid open.

We also check that the HDMI cable is connected by testing the contents of /sys/class/drm/card1-HDMI-A-1/status.

Follow the steps below: (ThinkPad T440 ubunu 24.04)

  1. Create file /etc/acpi/laptop-lid.sh with the following contents:

  2. Make the file executable with

  3. Create file /etc/acpi/events/laptop-lid with the following contents:

  4. Restart the acpid service with:

Now the fingerprint will be used only when the lid is open.

In order to restore the correct state of the fprintd service if you disconnect/reconnect while the laptop is off, you may call the above script from a systemd init file. The steps to do this are the following:

  1. Create a file named /etc/systemd/system/laptop-lid.service with the following contents:

  2. Reload the systemd config files with

  3. Start the service with

  4. Enable the service so that it starts automatically on boot

    Now the status should be correct even after connecting/disconnecting when the computer is off.

    References used for creating the code in the answer:

参考链接


This Indicator Shows CPU, GPU, Memory Usage on Ubuntu 24.04 Panel

There are several Gnome Shell extensions to display system resource usage in Ubuntu, but in this tutorial I’m going to introduce an indicator that works in not only GNOME, but also UnityMATE, and Budgie desktop environments.

It’s Indicator-SysMonitor, a free and open-source applet developed by the leader of Ubuntu Budgie team.

With it, user can display the usage and/or temperature of the following system resource in top-panel:

  • average CPU usage.
  • NVIDIA GPU utilization.
  • Memory usage.
  • network upload/download speed.
  • CPU, NVIDIA GPU temperature.
  • Swap usage.
  • Public IP address.

Most important is that user can customize the output, by setting which one or ones to display, in which order with which text. User just need to click the indicator on panel to open ‘Preferences’ dialog from pop-down menu, and format the output code in ‘Advanced’ tab.

How to Install Indicator-Sysmonitor

The developer has an Ubuntu PPA contains the packages for Ubuntu 18.04, Ubuntu 20.04, Ubuntu 22.04, Ubuntu 22.10, and even the next Ubuntu 23.04.

1. First, press Ctrl+Alt+T on keyboard to open a terminal window. When it opens, run command to add the PPA:

Type user password when it asks and hit Enter to continue.

2. For the old Ubuntu 18.04, you need to manually refresh package index after adding PPA:

3. And, install the indicator applet via command:

Finally, search for and open the applet like a normal application (it has same icon to System Monitor).

And click on the applet to open Preferences, and turn on start at login, configure output layout, refresh interval, etc.

Uninstall Indicator-Sysmonitor

You can close the applet by clicking on it in panel and select “Quit”. And remove the package at any time by running a single command in terminal window:

Also remove the PPA repository, either by running the command below or open “Software & Updates”and remove source line under “Other Software” tab.

参考链接


This Indicator Shows CPU, GPU, Memory Usage on Ubuntu 22.04 Panel

ubuntu 24.04编译CEF(Chromium Embedded Framework)

前置条件

1. 已经通过 GitLab的替代者-轻量级Gitea安装与配置-Windows 11 配置过镜像服务

基础知识

CIPD 全称 Chrome Infrastructure Package Deployment (https://chromium.googlesource.com/infra/luci/luci-go/+/main/cipd/README.md),主要用于管理 Google 项目构建中用到的二进制文件(例如编译器之类的),你可以简单的认为是针对大文件的git系统。

CIPD管理的所有文件可以在(https://chrome-infra-packages.appspot.com)上查看。

手动下载( version 参数从 depot_tools/cipd_client_version 读取)

linux-x86-64:
https://chrome-infra-packages.appspot.com/client?platform=linux-amd64&version=git_revision:b1f414539ac10cc67a0250890a38712cc06cf102

windows-x86-64:
https://chrome-infra-packages.appspot.com/client?platform=windows-amd64&version=git_revision:b1f414539ac10cc67a0250890a38712cc06cf102

动手实践

外网构建

国内镜像构建
1. 使用镜像地址替换 Git 仓库

命令执行后的 .gitconfig 文件:

2. 配置HTTP代理服务器

由于 Chromium 项目不仅依赖了一系列的第三方 Git 项目,还依赖了一系列已经编译后的二进制文件,这些文件被托管在 CIPD (Chrome Infrastructure Package Deployment) / GCS(Google Cloud Storage) 服务器上,这部分服务器也是没办法正常访问下载文件的,因此我们把这些二进制文件依旧托管在刚刚搭建的 Gitea 服务器上面,作为一个独立的 Git 项目来维护,减少非必要的服务器。

但是如何更改这部分的下载地址呢?我们可以通过设置 http_proxy 的方式,使用 Python 脚本,在脚本中完成下载数据的重定向。

代理脚本如下:

参考配置文件如下:

3. 执行编译

参考链接


ubuntu 24.04编译webkitgtk/WPE

前置条件
  • ubuntu 24.04.2 LTS
解决方案

如果先执行

在不关闭当前窗口的情况下,尝试构建 WPE

则基本上会出现如下报错信息:

原因是上一次执行设置了相关环境变量,后一次执行构建命令部分变量覆盖失败。

解决方法很简单,重新打开一个全新的构建窗口,然后重新执行上述命令即可解决此问题。

参考链接

Ubuntu 22.04 LTS 中安装经典 GNOME Flashback 指南

GNOME Flashback(又名 classic GNOME)是旧 GNOME 3 shell 的一个分支,它使用早期 GNOME 2 技术的布局和原则。它的速度快如闪电,并且在设计上非常轻量级。因此,它非常适合几十年前的老旧硬件。

随着带有现代 GNOME 42 的 Ubuntu 22.04 LTS 的发布,有必要寻找轻量级的桌面环境选项。

此外,GNOME Flashback 很容易安装在现代 Ubuntu Linux 中,你仍然可以享受 Ubuntu 性能而不必关心 GNOME 42、GTK4、libadwaita 之类的东西。

在 Ubuntu 22.04 LTS 中下载并安装经典 GNOME Flashback

按照以下步骤在 Ubuntu 22.04 LTS 中下载并安装经典 GNOME Flashback(Metacity)。

在 Ubuntu 22.04 LTS 中打开终端(CTRL+ALT+T)并运行以下命令。安装大小约为 61MB。

Install GNOME Classic Flashback Metacity in Ubuntu 22.04 LTS
Install GNOME Classic Flashback Metacity in Ubuntu 22.04 LTS

最后,安装完成后,退出。重新登录时,在登录选项中使用经典的 GNOME Flashback(Metacity) 。

Choose GNOME Classic while logging in
Choose GNOME Classic while logging in

经典 GNOME Flashback 的特点

首先,当你登录时,你将体验到传统的 GNOME 技术,它已被证明具有良好的生产力,并且比今天的技术快得多。

在顶部有旧版的面板,左侧是应用菜单,而系统托盘位于桌面的右上方。应用程序菜单显示所有已安装的应用和软件快捷方式,你可以在工作流程中轻松浏览。

此外,在右侧部分,系统托盘具有默认小部件,例如网络、音量控制、日期和时间以及关机菜单。

Classic GNOME Flashback Metacity in Ubuntu 22.04 LTS
Classic GNOME Flashback Metacity in Ubuntu 22.04 LTS

底部面板包含打开的窗口和工作区切换器的应用列表。默认情况下,它为你提供四个工作区供你使用。

此外,你可以随时更改顶部面板的设置以自动隐藏、调整面板大小和背景颜色。

除此之外,你可以通过 ALT + 右键点击 顶部面板添加任意数量的旧版小程序。

Panel Context Menu
Panel Context Menu

 

Add to panel widgets
Add to panel widgets

经典 GNOME 的性能

首先,磁盘空间占用极小,仅安装 61 MB。我的测试使用了大约 28% 的内存,其中大部分被其他进程占用。猜猜是谁?是的,是 snap-store(又名 Ubuntu 软件)。

因此,总体而言,它非常轻巧,内存(仅 28 MB)和 CPU(0.1%)占用空间非常小。

Performance of GNOME Classic in Ubuntu 22.04
Performance of GNOME Classic in Ubuntu 22.04

此外,假设你将其与同样使用相同技术的 Ubuntu MATE 进行比较。在这种情况下,它比 MATE 更轻量,因为你不需要任何额外的 MATE 应用及其用于通知、主题和其他附加资源的软件包。

结束语

我希望本指南在你决定在 Ubuntu 22.04 LTS Jammy Jellyfish 中安装经典 GNOME 之前帮助你获得必要的信息。

参考链接


如何修复 Ubuntu 上的 Busybox Initramfs 错误

本简短指南介绍了如何修复 Ubuntu Linux 上的 Busybox Initramfs 错误。我使用 Ubuntu 24.04 LTS 作为我的 Dell Inspiron 笔记本电脑上的日常驱动程序。今天我将其打开,启动过程将我带到 BusyBox shell,最后出现 initramfs 提示符。

据我所知,我没有做错任何事。我没有强行关闭系统电源。昨天还运行得很好!然而,今天当我开机时,在启动过程中遇到了意想不到的问题。我发现自己没有正常加载,而是重定向到 BusyBox shell,并最终到达 initramfs 提示符。

我无法跳过这个屏幕。而且它也没有显示问题到底是什么。我所看到的只是一个空白的 Busybox shell

我此时不知道该怎么办。所以我只是通过 exit 命令来看看会发生什么。

然后我看到了实际的错误:

Ubuntu 上的 Busybox Initramfs 错误
Ubuntu 上的 Busybox Initramfs 错误

正如您在上面的输出中看到的,/dev/sda1 分区已损坏。该分区中的文件系统有一些错误。

如果您遇到过此类问题,则需要使用 fsck 命令检查并修复有问题的 Linux 文件系统。

请注意,有时输入 exit 命令后您不会看到任何错误。在这种情况下,请尝试在所有文件系统上运行 fsck

什么是 Busybox 和 Initramfs?

对于那些想知道的人来说,BusyBox 是一个软件套件,它在一个小型可执行文件中提供了许多常见的 UNIX 实用程序。它提供了您通常在 GNU fileutilsshellutils 等中找到的大多数实用程序的替代品。

Initramfs是一个基于 tmpfs 的初始ram文件系统。它包含在调用实际根文件系统上的 init 二进制文件之前挂载文件系统所需的工具和脚本。

修复 Ubuntu Linux 上的 Busybox Initramfs 错误

1. 要解决 Ubuntu Linux 上的 initramfs 错误,您需要使用 fsck 修复损坏分区中的文件系统 命令如下:

将 /dev/sda1 替换为您的分区名称。在您的系统中,它可能是 /dev/sdb1/dev/sdc1 等。您可以使用 cat /proc/partitions 或 blkid 或 lsblk 命令来获取 Busybox 中的 Linux 分区详细信息。请参阅本指南列出 Linux 中的磁盘分区。不要忘记传递 -y 标志。否则,您应该手动键入 -y 并每次按 ENTER 键来修复错误。

2. 现在,fsck 命令将开始自动修复文件系统中的所有坏块。

几分钟后,您将看到如下输出:

3. 接下来,输入 reboot 并按 ENTER 重新启动系统!

修复 Ubuntu Linux 上的 Busybox Initramfs 错误
修复 Ubuntu Linux 上的 Busybox Initramfs 错误

如果 reboot 命令不起作用,请输入 exit 并按 ENTER

交叉手指并等待系统重新启动!如果一切顺利,您的系统将正常启动,没有任何问题。

这些步骤帮助我和其他许多人解决了 Ubuntu Linux 操作系统上的 Busybox Initramfs 错误。如果您陷入 initramfs 提示符,本指南肯定会帮助您修复 Ubuntu 中的 initramfs 错误。

注意:如果您经常收到此错误,则可能是您的硬盘变得越来越弱。遇到这种情况,建议尽快备份数据并更换硬盘。

这不仅仅适用于 Ubuntu 操作系统。 initramfs 错误可能发生在 Debian 和其他 Ubuntu 衍生产品(例如 Pop OS、Linux mint 等)上。为了修复基于 Debian 的系统中的 initramfs 错误,只需按照上述步骤操作即可。

参考链接


如何修复 Ubuntu 上的 Busybox Initramfs 错误

关于Ubuntu下ZRAM的配置和使用

当前自己使用的服务器内存比较小,需要扩容,只是服务器比较老了,内存扩展困难,但是服务器的负载并不高。因此可以尝试使用内存压缩的方式来适当扩展内存。

安装

软件包封装好了对应的东西(甚至是systemctl服务),并不需要自己写脚本

重启之后,一个内存大小一半的 ZRAM 就出现了。

参考链接


Ubuntu 22.04使用Podman部署Tomcat 9的详细教程

安装必要的依赖:

官方镜像会在报错的时候暴露 Tomcat 9 版本号,错误堆栈,构成安全隐患,我们需要通过构建自定义镜像解决此问题:

内容如下:

构建镜像:

设置容器开机自启:

查看启动文件:

内容如下:

Systemd 配置:

后续 WAR 包存储到 /home/data/.tomcat/webapps 目录下即可进行正常访问。

参考链接