偶尔使用但常常忘记的命令集
服务器
Lastmod: 2025-01-07
Published: 2024-12-31

偶尔使用但由于很少使用而常常忘记的命令记录在此。

系统相关

Ubuntu的升级

# apt update
# apt upgrade
# apt dist-upgrade

# do-release-upgrade
  • 安装 do-release-upgrade
# apt install update-manager-core

update-alternatives

  • 设置 Python 的默认路径
# update-alternatives --install /usr/bin/python python /usr/bin/python3 1
  • 设置默认的编辑器
# update-alternatives --config editor

时区的设置

  • 使用 systemd 的情况下
# timedatectl set-timezone Asia/Tokyo
  • 手动设置的情况下
# ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

文件系统相关

SD 卡或 HDD 的映像挂载

  • 将设备分配给 loop
# losetup -f --show -P sdcard.img

此时可以看到 /dev/loop0p1 等分区,并进行挂载。

  • 释放 loop 设备
# losetup -d /dev/loopN

网络相关

查询 NIC 的驱动程序

# udevadm info -a -p /sys/class/net/eth0
# ethtool -i eth0

检查 NIC 的卸载

# ethtool -k eth0

检查 NIC 特有的设置

# ethtool --show-priv-flags eth0

检查收发器的信息

# ethtool -m eth0

以原始方式转储收发器的 EEPROM

# ethtool -e eth0 raw on | hexdump -C

包管理相关

安装 apt-fast

# add-apt-repository ppa:apt-fast/stable
# apt update
# apt install apt-fast

安装 add-apt-repository

# apt install software-properties-common