Skip to content



Most notes on this page are based on my Ubuntu laptop.

  • 20.04: 2021-09-12 -> Now. 🔗
  • 18.04: 2020-04-12 -> 2021-09-12. 🔗
  • 16.04: ~ -> 2020-04-12
  • 14.04: ~ -> ~

Package Manager

Advanced Package Tool (APT)

APT is a package management system for Debian and other Linux distributions based on it, such as Ubuntu.


PPAs (Personal Package Archive) are repositories hosted on Launchpad. You can use PPAs to install or upgrade packages that are not available in the official Ubuntu repositories.

see also:

dpkg (Debian Package Manager)

“dpkg works under the hood of APT. While APT manages remote repositories and resolves dependencies for you, it use dpkg to actually make the changes of installing/removing package.” 🔗

  • list installed packages: dpkg -l
    • flag ‘ii’ (installed) and ‘rc’ (removed but configuration), refer to 🔗 for more details


  • snaps: the packages
  • snapd: the tool for using packages

Snaps are self-contained applications running in a sandbox with mediated access to the host system. 🔗

  • list all installed packages:
$ date
Sat 11 Jun 2022 08:22:05 PM CST
$ snap list
Name                             Version                     Rev    Tracking       Publisher   Notes
bare                             1.0                         5      latest/stable  canonical✓  base
canonical-livepatch              10.2.3                      146    latest/stable  canonical✓  -
core                             16-2.56                     13308  latest/stable  canonical✓  core
core18                           20220428                    2409   latest/stable  canonical✓  base
gnome-3-28-1804                  3.28.0-19-g98f9e67.98f9e67  161    latest/stable  canonical✓  -
gtk-common-themes                0.1-79-ga83e90c             1534   latest/stable  canonical✓  -
kde-frameworks-5                 5.47.0                      27     latest/stable  kde✓        -
kde-frameworks-5-core18          5.61.0                      32     latest/stable  kde✓        -
kde-frameworks-5-qt-5-14-core18  5.68.0                      4      latest/stable  kde✓        -
ksnip                            1.10.0                      443    latest/stable  dporobic    -
  • check available updates
# without refreshing
$ snap refresh --list
# perform refreshing
$ sudo snap refresh
  • check info of packages
$ snap info <snap name>

see also:


GNOME (originally an acronym for GNU Network Object Model Environment) is a desktop environment for Unix-like operating systems.

The version on my T460p is 3.28.2, which can be seen from About.


GNOME Shell is the graphical shell of the GNOME desktop environment. It provides basic functions like launching applications, switching between windows and is also a widget engine. . User interface elements provided by GNOME Shell include the Panel at the top of the screen, the Activities Overview, and Message Tray at the bottom of the screen. 🔗

The version on my T460p is

$ gnome-shell --version
GNOME Shell 3.28.4

GNOME Shell Extensions

GNOME Shell Extensions are small pieces of code written by third party developers that modify the way GNOME works. They are similar to Chrome Extensions or Firefox Addons. We can install the extensions via in Firefox. After installation, we can disable or enable, or even configure on such website, alternatively, we can use gnome-tweaks to control them.

Lunar Date

Here is a plugin to show Chinese Lunar Date: Lunar Calendar 农历. Since here are some latest comments, I guess it would be OK.

However, the first installation attempt failed, it shows ERROR. Then I realized that I might need to install the dependency mentioned in the plugin page,

sudo apt install gir1.2-lunar-date-2.0

Then reinstall the plugin, it succeed! But interestingly, the Chinese characters are shown as Pinyin (see the following left image)

Before After
Screenshot from 2021-05-03 14-04-34 Screenshot from 2021-05-03 14-40-47

Then I found the same issue in an older post

A solution is


Although no found, there is

$ pwd
$ ll | grep lunar
-rw-r--r-- 1 root root   4746 Nov 12  2016


$ sudo cp ../../en/LC_MESSAGES/

It cannot take effects immediately, the natural way is to reboot. But currently I do not want to reboot, and then I tried to reinstall the plugin in Firefox, but not work.

Then I tried to reload locale since the modification seems related to locale, so I found this answer and tried

$ . /etc/default/locale

but not work.

Then I realized that it might be necessary to reload GNOME Shell, so I found How to restart GNOME Shell from command line?, and tried

$ gnome-shell --replace &

It works, as shown in the above right figure. A minor side change is that the English colon in the time 14:37 seems to change to the Chinese colon.

System Monitor

通过 gnome-shell extension: gnome-shell-system-monitor-applet 实现

不过目前有个小问题,字体略小,尝试通过 gnome-tweaks 中的 scaling 来改变字体大小,但似乎对这些字体仍不适用,先将就用着吧。

unblack lock screen

Win+L 锁屏后,很快就直接变黑了。因为感觉屏保还挺好看的,所以并不想直接黑屏。参考 GNOME3锁屏和锁屏后,如何设置屏幕常亮? - Eglinux的回答 - 知乎,安装 Unblank lock screen.

更简单的技巧是长按 Win+L,似乎确实不会直接黑屏,然后会直接采用设置的关屏时间(Setting > Power),参考 GNOME3锁屏和锁屏后,如何设置屏幕常亮? - dale的回答 - 知乎

sound device chooser

tried but not good. Sound Input & Output Device Chooser


File Permissions

采用ls -l 便可以查看文件(夹)权限,比如

-rw-rw-r--  1 weiya weiya    137969 3月   8  2017 font.txt
-rw-r--r--  1 root  root      35792 12月 26 23:50 geckodriver.log
-rw-r--r--  1 root  root     327350 12月 27 01:38 ghostdriver.log

  1. 文件类型和文件权限 - 文件类型由第一个字母表示,常见的有 d(目录),-(文件),l(链接) - 权限分为三段,每三个字符一段,分别表示,文件所有者 u、文件所属组 g、其他用户 o对该文件的权限,其中
    • r: 可读,等于 4
    • w: 可写,等于 2
    • x: 可执行,等于 1
    • -: 无权限,等于 0
    • s: set user or group ID on execution (s)
    • X: execute/search only if the file is a directory or already has execute permission for some user
    • t: restricted deletion flag or sticky bit
  2. 文件链接个数
  3. 文件所有者
  4. 文件所在群组
  5. 文件长度
  6. 时间
  7. 文件名称


chmod -R 700 Document/
chmod -R [ugoa...][[+-=][perms...]] # refer to `man chmod` for more details

其中 -R 表示递归,perms 为上述 rwxXst,而 a 表示所有用户,即 ugo.

采用 chown 改变所有者,比如

chown -R username:users Document/

chmod g+s . 会使得当前文件夹 . 中所有新建文件或文件夹都继承 . 的 group,而不是创建者所属的 group,所以这一般配合 chgrp 使用。参考 ‘chmod g+s’ command

Modify vs Change

在找学习资料时,突然不是很确定当初是否已经在用这台笔记本了,所以想确定一下本机的装机时间,参考 How can I tell what date Ubuntu was installed?,主要时通过查看文件的上次修改时间,比如

$ ls -lt /var/log/installer/
total 1200
-rw-rw-r-- 1 root   root 464905 Dec  2  2016 initial-status.gz
-rw-r--r-- 1 root   root     60 Dec  2  2016 media-info
-rw------- 1 syslog adm  334743 Dec  2  2016 syslog
-rw------- 1 root   root   2467 Dec  2  2016 debug
-rw------- 1 root   root 407422 Dec  2  2016 partman
-rw------- 1 root   root     17 Dec  2  2016 version
-rw------- 1 root   root    956 Dec  2  2016 casper.log


$ ls -lt /
drwxrwxr-x   2 root root       4096 Dec  2  2016 cdrom
drwx------   2 root root      16384 Dec  2  2016 lost+found
drwxr-xr-x   2 root root       4096 Apr 21  2016 srv

出现了 2016.04.21 的一条记录。但如果我加上 -c,结果竟然不一样

$ ls -clt /
drwxrwxr-x   2 root root       4096 Dec  2  2016 cdrom
drwxr-xr-x   2 root root       4096 Dec  2  2016 srv
drwx------   2 root root      16384 Dec  2  2016 lost+found

难道 ls 默认显示的时间不是上次修改时间吗??另外注意到 srv 其实是一个空文件夹。

这时我用 stat 进一步查看,

$ stat /srv
  File: /srv
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: 825h/2085d  Inode: 1179649     Links: 2
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2021-05-05 08:43:20.955106697 +0800
Modify: 2016-04-21 06:07:49.000000000 +0800
Change: 2016-12-02 02:46:47.363728274 +0800
 Birth: -


  • Modify: the last time the file was modified (content has been modified)
  • Change: the last time meta data of the file was changed (e.g. permissions)

然后进一步查看 Windows 系统的时间,

$ ll -clt
drwxrwxrwx  1 weiya weiya       4096 Oct  1  2016 '$Recycle.Bin'/
drwxrwxrwx  1 weiya weiya          0 Sep 29  2016  FFOutput/
-rwxrwxrwx  2 weiya weiya   15151172 Jul  2  2016  WindowsDENGL.tt2*
-rwxrwxrwx  2 weiya weiya   16092228 Jul  2  2016  WindowsDENG.tt2*
-rwxrwxrwx  2 weiya weiya   16217976 Jul  2  2016  WindowsDENGB.tt2*
-rwxrwxrwx  1 weiya weiya     400228 Mar 19  2016  bootmgr*
-rwxrwxrwx  1 weiya weiya          1 Mar 19  2016  BOOTNXT*
drwxrwxrwx  1 weiya weiya       8192 Mar 18  2016  Boot/

最早可以追溯到 2016.03.18.


I found a file res/res_monodecomp/.fuse_hidden0016fbd000000001, which is “a file was deleted but there is at least one software which is still using it, so it cannot be removed permanently” 🔗. And it is suggested to use lsof to determine the application that uses such file. However,

$ lsof ./res/res_monodecomp/
lsof: WARNING: can't stat() tracefs file system /sys/kernel/debug/tracing
      Output information may be incomplete.
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/129/gvfs
      Output information may be incomplete.



Post: 2022-04-05 09:58:32

Checking the usage of disk by df -h, here is a line,

Filesystem      Size  Used Avail Use% Mounted on
tmpfs           2.0G   24K  2.0G   1% /run/user/129
tmpfs           2.0G  192K  2.0G   1% /run/user/1000


  • tmpfs (short for Temporary File System) is a temporary file storage paradigm implemented in many Unix-like operating systems. It is intended to appear as a mounted file system, but data is stored in volatile memory instead of a persistent storage device. 🔗
  • /run/user/$uid is created by pam_systemd and used for storing files used by running processes for that user. 🔗

100% snap /dev/loop

$ df -h
/dev/loop1      9.0M  9.0M     0 100% /snap/canonical-livepatch/138
/dev/loop2      9.0M  9.0M     0 100% /snap/canonical-livepatch/146
/dev/loop3      114M  114M     0 100% /snap/core/13308
/dev/loop0      128K  128K     0 100% /snap/bare/5

“Having Snap images which consume 100% of their filesystem is perfectly acceptable” and “it’s supposed to work that way”, refer to 🔗



view installed fonts

# only print the font-family
$ fc-list : family
# add language selector
$ fc-list : family lang=zh
Fira Sans,Fira Sans UltraLight
Fira Sans,Fira Sans Light
Noto Serif CJK KR,Noto Serif CJK KR ExtraLight
# with format option, get the family names of all the fonts (note that the above family also specify the detailed style)
$ fc-list --format='%{family[0]}\n' :lang=zh | sort | uniq

refer to fc-list command in Linux with examples

Install Local Fonts


$ wget -c -O fonts.tar.gz
$ tar xvzf fonts.tar.gz
$ sudo mkdir -p /usr/share/fonts/truetype/custom/
$ sudo mv fonts/* /usr/share/fonts/truetype/custom/
$ sudo fc-cache -f -v


$ fc-list :lang=zh
/usr/share/fonts/truetype/custom/simhei.ttf: SimHei,黑体:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/truetype/custom/STFANGSO.TTF: STFangsong,华文仿宋:style=Regular

Some Free Fonts

Sound with Headphone

The output candidates are


  • HDMI/DisplayPort - Built-in Audio
  • Speakers - Built-in Audio
  • Headphone - LE-Bose QC35 II

and there are two profiles for Headphone

  • High Fidelity Playback (A2DP Sink)
  • Headset Head Unit (HSP/HFP)

also two profiles for Speakers

  • Analog Stereo Output
  • Analog Surround 4.0 Output

and one profile for HDMI/DisplayPort

  • Digital Stereo (HDMI) Output

There are two devices for sound input


  • Internal Microphone - Built-in Audio
  • Bluetooth Input - LE-Bose QC35 II

Here are some observations

  • The profile High Fidelity Playback is much more confortable than another profile.
  • If Output = Headphone + High Fidelity, then Input cannot be set as Bluetooth Input
  • Otherwise, if set Input as Bluetooth Input, then the Profile of Output would become to Headset Head Unit

Sometimes, no sound from the headphone, and possibly the headphone is connected to another device. Refer to Using multiple Bluetooth® connections for switching the connected devices for the headphone.

When two devices are actively connected, you can play music from either device. To switch between connected devices, pause the first device and play music from the second.

But sometimes either devices are playing sound, a less elegant way is to disconnect other devices.

see also Pair Bose QuietComfort 35 with Ubuntu over Bluetooth - Ask Ubuntu

Turn on/off Bluebooth from CLI


rfkill block bluetooth
rfkill unblock bluetooth
参考 🔗

Use Department Printer

The department printer is only accessible from the office PC, but request to switch the cable from office PC to my laptop, I can configure to use the printer from my laptop. The steps are

  1. choose LPD/LPR Host or Printer
  2. set host as

The detailed settings are


finally, the test page can be successfully printed,


If we forget the hostname, actually we can get the ip address from the panel of printer,

step 1 step 2
image image

We can validate the hostname and the ip point to the same machine,

weiya@stapc220:~$ ping
PING ( 56(84) bytes of data.

Share Printer

现有台 HP-Deskjet-1050-J410-series 打印机,通过 USB 接口。直接连接在 Ubuntu 上是可以实现打印功能的,现在想贡献给局域网内的其他设备,参考 使用Linux共享打印机,主要步骤为

  1. 安装 CUPS 服务,sudo apt-get install cups 并启动,sudo service cups start
  2. >> Advanced 勾选 Allow printing from the Internet,并保存。
  3. 打开防火墙,sudo ufw allow 631/tcp

在同一局域网内的 Windows 设备中,添加该打印机,地址即为Ubuntu中浏览器的地址,注意将 换成局域网 ip。如果顺利的话,添加后需要添加驱动程序,可以在 HP 官网下载。

Portable SSD

因为硬盘太小,而移动硬盘读写文件速度实在有点慢,然后看到有移动 SSD 硬盘,于是便入手了一个。

当然首先确定了,自己笔记本有 USB3.0 接口,虽然不是 USB3.1。(不过好像 USB3.0 也叫作 USB3.1 gen1,而真正的 USB3.1 叫做 USB3.1 gen2),这个可以通过

$ lsusb -t



Mount error: unknown filesystem type ‘exfat’


sudo apt-get install exfat-fuse exfat-utils


  1. 解压某个文件时,报出 Cannot set modif./access times,而这个在正常磁盘以及已有的移动硬盘中都能正常解压
  2. 不能创建带有 : 的文件夹,这应该是遵循 Windows 的标准,但是 Linux 命名标准没有遵循 Windows,所以造成有些文件复制不过去。

最后决定格式化为 Linux 磁盘的格式,这个其实也挺简单的,进入 gnome-disks,先 umount,然后选择格式化,这时直接选择格式化为 Linux 的 Ext4,有一篇图文介绍,不过没看时就已经自己操作了,只是让自己心安一下。


~$ sudo hdparm -Tt /dev/sdc1

 Timing cached reads:   22298 MB in  1.99 seconds = 11228.47 MB/sec
 Timing buffered disk reads: 120 MB in  3.01 seconds =  39.89 MB/sec

~$ sudo hdparm -Tt /dev/sde1

 Timing cached reads:   24390 MB in  1.99 seconds = 12281.26 MB/sec
 Timing buffered disk reads: 1318 MB in  3.00 seconds = 439.04 MB/sec

上面是普通的移动硬盘,底下是新买的移动 SSD 硬盘,差异还是很明显的。继续测试写入的速度,

~$ time dd if=/dev/zero of=/media/weiya/Extreme\ SSD/tempfile bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 2.11846 s, 507 MB/s

real    0m2.131s
user    0m0.011s
sys 0m0.543s
~$ time dd if=/dev/zero of=/media/weiya/Seagate/tempfile bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 12.4132 s, 86.5 MB/s

real    0m12.746s
user    0m0.000s
sys 0m1.551s


~$ time dd if=/media/weiya/Extreme\ SSD/tempfile of=/dev/null bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 4.01399 s, 268 MB/s

real    0m4.018s
user    0m0.000s
sys 0m0.442s
~$ time dd if=/media/weiya/Seagate/tempfile of=/dev/null bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 65.6471 s, 16.4 MB/s

real    1m5.981s
user    0m0.010s
sys 0m0.650s

移动 SSD 硬盘完胜普通的移动硬盘。


Charge Battery Adaptively

虽然一直知道插上电源充电会损耗电池容量,但是没想到竟然会损耗得那么严重,对于我正在使用的 ThinkPadT460P 来说,

~$ upower -i `upower -e | grep 'BAT'`
  native-path:          BAT0
  vendor:               SANYO
  model:                45N1767
  serial:               3701
  power supply:         yes
  updated:              Tue 01 Sep 2020 10:15:52 AM CST (106 seconds ago)
  has history:          yes
  has statistics:       yes
    present:             yes
    rechargeable:        yes
    state:               fully-charged
    warning-level:       none
    energy:              19.42 Wh
    energy-empty:        0 Wh
    energy-full:         19.58 Wh
    energy-full-design:  47.52 Wh
    energy-rate:         0 W
    voltage:             12.025 V
    percentage:          99%
    capacity:            41.2037%
    technology:          lithium-ion
    icon-name:          'battery-full-charged-symbolic'

现在的容量只有 41.2037%,一半都不到。心血来潮搜了下看看有没有什么软件能够支持自动充放电,竟然还真有,而且特别支持 ThinkPad 系列, How can I limit battery charging to 80% capacity?

不过刚开始按照回答中的解决方案操作,最后 sudo modprobe tp_smapi 并不成功,大概是说没有这个 kernel 吧。不过因为这个回答挺早的,在评论中顺藤摸瓜找到针对更新版的 ThinkPad 的解决方案,tlp for Ubuntu

sudo add-apt-repository ppa:linrunner/tlp
sudo apt update
sudo apt install acpi-call-dkms tp-smapi-dkms

其中特别指出 acpi-call-dkms 用于 ThinkPads (X220/T420 and later)


~$ sudo tlp-stat -b
--- TLP 1.3.1 --------------------------------------------

+++ Battery Features: Charge Thresholds and Recalibrate
natacpi    = inactive (no kernel support)
tpacpi-bat = active (thresholds, recalibrate)
tp-smapi   = inactive (ThinkPad not supported)

这时候按照 Battery Charge Thresholds 修改 /etc/tlp.conf,并运行

sudo tlp start



natacpi = inactive (no kernel support)

但是发现 natacpi 只有 kernel 4.17 才开始支持,而当前我的 kernel 版本为

$ uname -r

而且在 Why is my battery charged up to 100% – ignoring the charge thresholds?ThinkPad T430(s)/T530/W530/X230 (and all later models) 提到解决方案是

Install a kernel ≥ 4.19 to make natacpi available

网上搜了一圈,发现更新内核还是有风险的,比如可能造成某些接口无法使用,这让我想起之前 wifi 接口搞不定的噩梦。那就先这样吧。

而且发现其实 update & dist-upgrade 可能还是会更新内核版本,但是不会更到最新?

upgrade vs dist-upgrade vs full-upgrade

参考 What is “dist-upgrade” and why does it upgrade more than “upgrade”? upgrade 只更新已经安装包的版本,不会额外下载包或卸载包 dist-upgrade 会安装、卸载新包所依赖的包,而是更新内核版本也需要用它 full-upgrade:不太清楚,试着运行完 dist-upgrade 后,再运行它,但是没反应。

$ man apt-get
       upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently
       installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, or packages not already installed retrieved
       and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current
       version. An update must be performed first so that apt-get knows that new versions of packages are available.

       dist-upgrade in addition to performing the function of upgrade, also intelligently handles changing dependencies with new versions of packages; apt-get has a "smart" conflict
       resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary. The dist-upgrade command may therefore
       remove some packages. The /etc/apt/sources.list file contains a list of locations from which to retrieve desired package files. See also apt_preferences(5) for a mechanism
       for overriding the general settings for individual packages.
但是竟然没有看到 full-upgrade.

比如我发现 Ubuntu 18.04.5 LTS 实际上的内核版本应该是 5.0,甚至有 5.3,不过这似乎跟硬件有关,比如这里列了 linux-aws-5.0, linux-aws-5.0,不过我也看到了 linux-gke-4.15,所以还是不要乱升级的好,不然硬件不兼容又要继续折腾了。


Add Virtual Memory


# 创建大小为2G的文件swapfile
dd if=/dev/zero of=/mnt/swapfile bs=1M count=2048
# 格式化
mkswap /mnt/swapfile
# 挂载
swapon /mnt/swapfile

注意文件应为 root:root,否则会提示

insecure file owner 1000, 0 (root) suggested.

另见 How to Resolve the Insecure warning in Swapon?

为了保证开机自动加载,在 /etc/fstab 加入

/mnt/swapfile swap swap defaults 0 0

具体每一列的含义可以通过 man fstab 查看。

挂载成功后就可以通过 free -h 查看内存情况。

参考 Linux下如何添加虚拟内存

这个方法也可以解决 “virtual memory exhausted: Cannot allocate memory” 的问题。

调整 swapiness,默认值为 60,

$ cat /proc/sys/vm/swappiness

越高表示越积极使用 swap 空间。


$ sudo sysctl vm.swappiness=80

参考 linux系统swappiness参数在内存与交换分区间优化

Extend Disk

一直想扩容来着,但总是下不了决心。今天决定了,参考 google 搜索“Ubuntu 扩容”的前几条结果,便开始干了。

  1. 采用启动 U 盘,因为根目录在使用状态,幸好启动 U 盘还在。
  2. 使用 Gparted 时有个大大的 warning,说对含 /boot 分区的硬盘进行操作可能会不能正常启动,有点吓到了,最后还是狠下心继续下去了。
  3. 网上有人说,不要用 Gparted 对 Windows 进行压缩,而应该在 Windows 中进行压缩,可是此时已经开始了,想中断但怕造成更严重的后果,幸好最后启动 Windows 时只是多了步检查硬盘,并没有不能启动的状况。


see also: Why are there so many different ways to measure disk usage? - Unix & Linux Stack Exchange

Rename Portable Disk



在设置齿轮图标中选择 Edit Mount Options,修改 Mount Point。注意重新挂载后才能生效。

详见How to change hard drive name

Use Old Kernel

最近几天,T460P 经常自动重启,而且往往重启前花屏,甚至今天带着电脑去找老板,也重启了两次。在 /var/crash 目录下能发现 crash 报告,但是并不知道怎么使用

drwxr-sr-x  2 root     whoopsie     4096 Jul 22 20:10 202107222000/
drwxr-sr-x  2 root     whoopsie     4096 Jul 23 05:40 202107230539/
drwxr-sr-x  2 root     whoopsie     4096 Jul 23 08:54 202107230854/
drwxr-sr-x  2 root     whoopsie     4096 Jul 24 14:23 202107241422/
drwxr-sr-x  2 root     whoopsie     4096 Jul 26 09:03 202107260517/
drwxr-sr-x  2 root     whoopsie     4096 Jul 27 09:26 202107270926/
drwxr-sr-x  2 root     whoopsie     4096 Jul 27 23:09 202107272308/
drwxr-sr-x  2 root     whoopsie     4096 Jul 28 09:41 202107280940/
drwxr-sr-x  2 root     whoopsie     4096 Jul 28 09:44 202107280944/
drwxr-sr-x  2 root     whoopsie     4096 Jul 28 10:14 202107281014/
drwxr-sr-x  2 root     whoopsie     4096 Jul 28 11:05 202107281105/
drwxr-sr-x  2 root     whoopsie     4096 Jul 28 11:48 202107281148/
-rw-r--r--  1 kernoops whoopsie     2249 Jul 24 14:40 linux-image-4.15.0-151-generic.183202.crash
-rw-r-----  1 root     whoopsie    34940 Jul 22 20:01 linux-image-4.15.0-151-generic-202107222000.crash
-rw-r-----  1 root     whoopsie    29062 Jul 23 08:55 linux-image-4.15.0-151-generic-202107230854.crash
-rw-r-----  1 root     whoopsie    34532 Jul 24 14:23 linux-image-4.15.0-151-generic-202107241422.crash
-rw-r-----  1 root     whoopsie    35752 Jul 26 08:56 linux-image-4.15.0-151-generic-202107260517.crash
-rw-r--r--  1 kernoops whoopsie      746 Jul 28 09:40 linux-image-4.15.0-151-generic.30586.crash
-rw-r--r--  1 kernoops whoopsie      752 Jul 28 09:40 linux-image-4.15.0-151-generic.30735.crash


$ ll 202107281148
total 109160
-rw-------  1 root whoopsie     78507 Jul 28 11:48 dmesg.202107281148
-rw-------  1 root whoopsie 111683440 Jul 28 11:48 dump.202107281148

联想下最近的操作,很有可能是通过 apt upgrade 更新了次内核,查看具体细节

$ vi /var/log/apt/history.log
Start-Date: 2021-07-21  20:46:59
Commandline: aptdaemon role='role-commit-packages' sender=':1.1117'
Install: linux-headers-4.15.0-151-generic:amd64 (4.15.0-151.157, automatic), linux-modules-4.15.0-151-generic:amd64 (4.15.0-151.157, automatic), linux-image-4.15.0-151-generic:amd64 (4.15.0-151.157, automatic), linux-modules-extra-4.15.0-151-generic:amd64 (4.15.0-151.157, automatic), linux-headers-4.15.0-151:amd64 (4.15.0-151.157, automatic)
Upgrade: libnvidia-gl-460-server:amd64 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), libnvidia-gl-460-server:i386 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), linux-headers-generic:amd64 (,, linux-libc-dev:amd64 (4.15.0-147.151, 4.15.0-151.157), linux-crashdump:amd64 (,, libsystemd0:amd64 (237-3ubuntu10.48, 237-3ubuntu10.49), libsystemd0:i386 (237-3ubuntu10.48, 237-3ubuntu10.49), linux-image-generic:amd64 (,, nvidia-driver-460-server:amd64 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), containerd:amd64 (1.5.2-0ubuntu1~18.04.1, 1.5.2-0ubuntu1~18.04.2), nvidia-kernel-source-460-server:amd64 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), libnvidia-fbc1-460-server:amd64 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), libnvidia-fbc1-460-server:i386 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), nvidia-dkms-460-server:amd64 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), google-chrome-stable:amd64 (91.0.4472.164-1, 92.0.4515.107-1), nvidia-utils-460-server:amd64 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), libnvidia-decode-460-server:amd64 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), libnvidia-decode-460-server:i386 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), udev:amd64 (237-3ubuntu10.48, 237-3ubuntu10.49), nvidia-kernel-common-460-server:amd64 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), typora:amd64 (0.10.11-1, 0.11.0-1), xserver-xorg-video-nvidia-460-server:amd64 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), libnvidia-encode-460-server:amd64 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), libnvidia-encode-460-server:i386 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), nvidia-compute-utils-460-server:amd64 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), initramfs-tools-bin:amd64 (0.130ubuntu3.12, 0.130ubuntu3.13), linux-signed-generic:amd64 (,, libudev1:amd64 (237-3ubuntu10.48, 237-3ubuntu10.49), libudev1:i386 (237-3ubuntu10.48, 237-3ubuntu10.49), libnvidia-ifr1-460-server:amd64 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), libnvidia-ifr1-460-server:i386 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), libnvidia-common-460-server:amd64 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), libnss-myhostname:amd64 (237-3ubuntu10.48, 237-3ubuntu10.49), libnvidia-cfg1-460-server:amd64 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), systemd-sysv:amd64 (237-3ubuntu10.48, 237-3ubuntu10.49), libpam-systemd:amd64 (237-3ubuntu10.48, 237-3ubuntu10.49), systemd:amd64 (237-3ubuntu10.48, 237-3ubuntu10.49), libnvidia-extra-460-server:amd64 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), linux-generic:amd64 (,, initramfs-tools-core:amd64 (0.130ubuntu3.12, 0.130ubuntu3.13), initramfs-tools:amd64 (0.130ubuntu3.12, 0.130ubuntu3.13), libnvidia-compute-460-server:amd64 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1), libnvidia-compute-460-server:i386 (460.73.01-0ubuntu0.18.04.1, 460.91.03-0ubuntu0.18.04.1)
End-Date: 2021-07-21  20:51:53

Start-Date: 2021-07-22  06:31:33
Commandline: /usr/bin/unattended-upgrade
Remove: linux-headers-4.15.0-144:amd64 (4.15.0-144.148), linux-headers-4.15.0-144-generic:amd64 (4.15.0-144.148)
End-Date: 2021-07-22  06:31:36


对于 .gz 的日志文件,可以使用 zcat 直接查看。 另外注意,file.gz 解压时默认不会保存原始文件,或者指定 gunzip -k 选项,或者

gunzip < file.gz > file
详见 Unzipping a .gz file without removing the gzipped file

发现其更新时间恰恰在诸多 crash 的前一天。所以试图切换到老的内核版本。

注意到在启动时,第二个选项是 Advanced options for Ubuntu,点进去有若干个内核,我的是

4.15.0-151 (recovery mode)
4.15.0-147 (recovery mode)

选择 4.15.0-147,进去之后发现扩展屏幕无法识别,另外 Nvidia 也没有识别。于是试着重装 nvidia driver,这次选择的是 nvidia-driver-460-server,这也是此前使用的版本


重启时注意还是要选择 4.15.0-147,不如默认进的还是 151

中间误入了一次 151,结果还没登录就自动重启了,然后乖乖选择 147,但是这次还是没能识别 HDMI,不过 nvidia-smi 以及 nvidia-settings 都正常,xrandr 输出也是没有识别出显示屏。


后面在 nvidia-settings 中试了将 PRIME profilesNVIDIA (performance mode) 改成 NVIDIA on-demand,然后重启,结果竟然进不去系统了,每次输入密码回车都要求重新输入密码。

原因很可能是 PRIME 的这一改动,于是进入 tty 模式,通过命令行改回来

# 查询当前选择
$ prime-select query
# 切换至 nvidia
$ prime-select nvidia
# 切换至 intel
$ prime-select intel


注意现在每次重启都需要选择内核版本,一个自然想法是修改默认内核。参考 How Do I Change the Default Boot Kernel in Ubuntu?

/etc/default/grubGRUB_DEFAULT 修改至 1>2,其中

  • 1 代表 Advanced options for Ubuntu 的顺序,因其在第二位,顺序从 0 算起,默认值就是 0
  • >2 代表在子目录下位于第 2 位(顺序从 0 算起,即第三个)


$ sudo update-grub

重启之后可以看到自动选择了 1>2

disable update of kernel

今天竟然又重启了,有点无法理解。第一次怀疑是温度过高,因为 syslog 中重启前的一条记录信息为

Device: /dev/sdc [SAT], SMART Usage Attribute: 194 Temperature_Celsius changed from 60 to 61

然后第二次竟然发现 crash 报告竟然是 151,明明应该选择了第二个 147 呀。

$ ls /var/crash

重启时才发现竟然多了个 kernel 153!!于是第二个变成了 151,第三个才是 147。

虽然将启动选择再改成第三个应该也是可以的,但是万一以后又多了一个呢,顺序岂不又变了,所以更好的方法便是禁止 kernel 更新。另外将最新的 151 删掉。

  • 删掉 kernel

查看安装 kernel 的完整名称,

$ dpkg -l | grep linux-image | grep "^ii"


$ sudo apt purge linux-image-4.15.0-153-generic

再次重启就会发现第一项 153 消失了。

refer to Ubuntu 18.04 remove all unused old kernels

  • 禁止 kernel 更新

参考 How to I prevent Ubuntu from kernel version upgrade and notification?

sudo apt-mark hold 4.15.0-147-generic

The resulting status is hi, where the first letter implies hold.

~$ dpkg -l | grep "4.15.0-147"
ii  linux-headers-4.15.0-147                                    4.15.0-147.151                             all          Header files related to Linux kernel version 4.15.0
hi  linux-headers-4.15.0-147-generic                            4.15.0-147.151                             amd64        Linux kernel headers for version 4.15.0 on 64 bit x86 SMP
hi  linux-image-4.15.0-147-generic                              4.15.0-147.151                             amd64        Signed kernel image generic
hi  linux-modules-4.15.0-147-generic                            4.15.0-147.151                             amd64        Linux kernel extra modules for version 4.15.0 on 64 bit x86 SMP
hi  linux-modules-extra-4.15.0-147-generic                      4.15.0-147.151                             amd64        Linux kernel extra modules for version 4.15.0 on 64 bit x86 SMP


However, currently the kernel is

~$ date
Mon 13 Jun 2022 04:17:43 PM CST
~$ uname -a
Linux weiya-ThinkPad-T460p 5.4.0-110-generic #124-Ubuntu SMP Thu Apr 14 19:46:19 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

so it is outdated to hold such kernel. To undo such operation,

$ sudo apt-mark unhold 4.15.0-147-generic

Then it will be removed if we perform autoclean

~$ sudo apt autoremove --purge 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
linux-headers-4.15.0-147* linux-headers-4.15.0-147-generic* linux-image-4.15.0-147-generic* linux-modules-4.15.0-147-generic* linux-modules-extra-4.15.0-147-generic*

Note that this command will still keep one old kernel, along with the currently running one 🔗. For example,

~$ dpkg -l | grep "linux-image" | grep '^ii'
ii  linux-image-5.4.0-110-generic                               5.4.0-110.124                              amd64        Signed kernel image generic
ii  linux-image-5.4.0-117-generic                               5.4.0-117.132                              amd64        Signed kernel image generic
ii  linux-image-generic                                                             amd64        Generic Linux kernel image

However, here is a warning,


dpkg: warning: while removing linux-modules-4.15.0-147-generic, directory ‘/lib/modules/4.15.0-147-generic’ not empty so not removed

Default Software

网页文件 .html 默认用百度网盘打开,之前通过 KDE System Setting 修改了默认软件,


试着参考 Open files with other applications 的步骤进行设置

  • 右键选择 Properties
  • 然后选择 Open With
  • 选择特定软件,Set as default



Post: 2022-04-01 23:57:09

校园网突然无法打开微信图片,公众号文章也无法加载,无法 ping 通,但在服务器上可以。所以第一个自然想法是利用动态转发搭建隧道,即在本地端运行

$ ssh -D 30002 server

然后便可以通过 socks5:// 进行代理。加了代理之后,首先能够在浏览器端打开公众号文章。但想要微信本身也进行代理,并不直接,可能因为 wine 套壳的原因,后来也没有继续细究。

另一种方式便是换 wifi。除了 CUHK1x,也可以使用 eduroam,点击连接时,竟然发现连接状态下的 security 是哈佛帐号,然而我并没有利用哈佛帐号连接过 eduroam,而且帐号早已失效。其原因,很可能就是因为当时连接 Harvard Secure 时,会下载一个 JoinNow,并在本地运行 🔗

而此时所连接的 eduroam 中 security 便指向 joinnow 的两个密钥文件,

~/.joinnow/tls-client-certs$ ls

不过在该 wifi 下,不能直接访问服务器。于是想切换到学校帐号的 eduroam,但又想保留当前 profile。所以尝试直接复制 wifi profile 文件,

/etc/NetworkManager/system-connections$ sudo cp A B

然后修改每个 profile 的细节,注意 uuid 也必须修改,运行 uuid 生成,不然会视为同一个连接。修改完成后重启网络服务,

sudo systemctl restart NetworkManager

参考 🔗


Delete Hotspot

升级到 Ubuntu 18.04 后,开机自动连接到 Hotspot,每次需要手动禁止并改成 Wifi 连接,这个可以直接删除保存好的 Hotspot 连接

cd /etc/NetworkManager/system-connections/
sudo rm Hotspot

参考 How to remove access point from saved list

WiFi Hotpot (16.04)

Refer to

  1. 3 Ways to Create Wifi Hotspot in Ubuntu 14.04 (Android Support)
  2. How do I create a WiFi hotspot sharing wireless internet connection (single adapter)?


  1. 选择 mode 时,直接选择 hotpot 即可,后面也无需更改文件
  2. 设置密码时位数不能少于 8 位
  3. 连接 WiFi 时 似乎需要 enable wifi。


实验室有一支 IKBC CD 87T 蓝牙键盘,于是便想试试。



The raw records can be found here.

After replacing one of 4GB RAM with 16GB one, it throws


frequently, such as

Following the instructions

but no drops

wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet  netmask  broadcast
        inet6 fe80::def:d34:a2c:da88  prefixlen 64  scopeid 0x20<link>
        ether a4:34:d9:e8:9a:bd  txqueuelen 1000  (Ethernet)
        RX packets 17556713  bytes 20549547923 (20.5 GB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14008823  bytes 17151970123 (17.1 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

then try to enlarge net.core.rmem_max and net.core.rmem_default. The current values are

~$ sysctl net.core | grep mem
net.core.optmem_max = 20480
net.core.rmem_default = 212992
net.core.rmem_max = 212992
net.core.wmem_default = 212992
net.core.wmem_max = 212992

the update it via

~$ sudo sysctl -w net.core.rmem_default=1048576
net.core.rmem_default = 1048576
~$ sudo sysctl -w net.core.rmem_max=2097152
net.core.rmem_max = 2097152
~$ sysctl net.core | grep mem
net.core.optmem_max = 20480
net.core.rmem_default = 1048576
net.core.rmem_max = 2097152
net.core.wmem_default = 212992
net.core.wmem_max = 212992

it seems to work since much fewer warning message of 1m_ipv4_udp_receive_buffer_errors

ubuntu 连接 sftp 服务器

参考Use “Connect to Server” to connect to SFTP



install win on ubuntu



搜索 Startup 便可弹出开机自启动软件界面,


Mount with Options

By default, the Segate disk would return owner as root.


sudo umount /dev/XXX
sudo mount -o rw,user,uid=1000,dmask=007,fmask=117 /dev/XXX /media/weiya/Segate

where the first step might throw busy error, and the processes use the disk can be found via

fuser -cu /local/mnt/
ps -ef | grep XXX

refer to

Clean disk space

  • autoremove apt autoremove --purge
  • manually find unused packages: dpkg -l and apt list --installed
  • for anaconda, run conda clean -a

Connect Android Phones

If the computer does not recognize the android devices, try to use the original cable. See 🔗 for other possibilities.