目录

Debian使用问题

系列 - Use Debian

在新建的用户下使用命令终端, 出现方向键无法调出历史命令、tab键也无法补全输入命令等现象, 总之很不正常。

新建用户时忘记指定用户运行shell:

bash

useradd -s /bin/bash <UserName>

查看/etc/passwd, 发现该新建用户使用的shell/bin/sh, 比如:

text

<UserName>:x:1002:1003::/home/<UserName>:/bin/sh

而一般使用的shell/bin/bash, 所以将该用户的/bin/sh修改为/bin/bash即可:

text

<UserName>:x:1002:1003::/home/<UserName>:/bin/bash

推荐直接使用usermod指定用户运行shell:

bash

usermod -s /bin/bash <UserName>
  1. 查看启动速度:

    bash

    systemd-analyze
  2. 查看各个自启动服务占用时间:

    bash

    systemd-analyze blame
  3. 禁用启动服务, 比如:

    bash

    sudo systemctl disable snapd.service
    sudo systemctl disable snapd.seeded.service
    sudo systemctl disable snapd.apparmor.service
    sudo systemctl disable snapd.socket
    sudo systemctl disable NetworkManager-wait-online.service
    sudo systemctl disable networkd-dispatcher.service
    sudo systemctl disable ModemManager.service
    sudo systemctl disable pppd-dns.service

    有些服务systemctl disable无效, 需要使用systemctl mask, 比如:

    bash

    sudo systemctl mask avahi-daemon.service
  4. 另外, 检查开机启动项/etc/xdg/autostart/

在有声音输出的前提下, 无法调节音量。

  • 使用alsamixer命令直接调节。

  • 或者安装Kmix音量调节器:

    bash

    sudo apt-get install kdemultimedia kmix

参考解决ubuntu合盖后无法唤醒

  1. 安装laptop-mode:

    bash

    sudo apt install laptop-mode-tools
  2. 判断Laptop是否启用了laptop_mode模式, 如果显示结果为0, 则表示未启动, 如果为非0的数字则表示启动了:

    bash

    cat /proc/sys/vm/laptop_mode
  3. 启动laptop_mode:

    修改配置文件/etc/default/acpi-support, 更改ENABLE_LAPTOP_MODE=true

    未找到?

    有些用户在/etc/default/acpi-support中未找到ENABLE_LAPTOP_MODE=true被注释的项.看文件最后一行的提示用户在/etc/laptop-mode/laptop-mode.conf中进行配置。

    于是在该文件中查找ENABLE_LAPTOP_MODE_ON_BATTERYENABLE_LAPTOP_MODE_ON_ACENABLE_LAPTOP_MODE_WHEN_LID_CLOSED, 分别是当用电池外接电源合上显示屏的时候是否启用LAPTOP_MODE, 全部设置为 1 就可以了。

  4. 执行sudo laptop_mode start启动laptop_mode之后, 在Ubuntu挂起后, 基本上就不会遇到无法唤醒的情况了。

  5. 再次判断Laptop是否启用了laptop_mode模式:

    bash

    cat /proc/sys/vm/laptop_mode
报错

Possible missing firmware /lib/firmware/rtl_nic/rtl8168e-2.fw for module r8169

Possible missing firmware /lib/firmware/i915/glk_dmc_ver1_04.bin for module i915

参考Possible missing firmware /lib/firmware/i915/* for module i915

对于Debian:

bash

sudo apt install firmware-linux

对于Ubuntu:

bash

sudo apt install linux-firmware
dpkg报错

dpkg: warning: ’ldconfig’ not found in PATH or not executable.

dpkg: warning: ‘start-stop-daemon’ not found in PATH or not executable.

dpkg: error: 2 expected programs not found in PATH or not executable.

Note: root’s PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin.

编辑 环境变量配置文件, 添加以下内容:

bash

if [ "$(id -u)" -eq 0 ]; then
    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
    PATH="/usr/local/bin:/usr/bin:/bin"
fi
if [ -d "$HOME/bin" ]; then
    PATH="$HOME/bin:$PATH"
fi
if [ -d "$HOME/.local/bin" ]; then
    PATH="$HOME/.local/bin:$PATH"
fi
export PATH
  1. root身份登录系统时, 无法运行某些软件 (如Google Chrome), 而普通用户可以打开;

  2. 某些软件普通用户也无法运行 (如PicGo的AppImage)。

以Google Chrome为例:

  1. 找到usr/share/applications中的Google Chrome启动文件, 右击用文本编辑器打开;
  2. Exec=typora %U后面添加 --no-sandbox (注意--的前面有个空格)。

我只用UTC+8Asia/Shanghai这一个时区, 而且中国也不用夏令时, 所以我选择使用localtime

此外, Ubuntu及其衍生发行版会在安装时检测计算机上是否存在Windows, 若存在则会默认使用localtime。这是为了让Windows用户能够在不修改注册表的情况下, 在Ubuntu内看到正确的时间。

更多信息参考System time#Time standard

通过timedatectl命令可以查看设置系统时间。运行timedatectl命令查看当前硬件时钟的时间标准, 如果输出中有:

text

RTC in local TZ: no

表示硬件时钟使用UTC。

将硬件时间设置为localtime:

bash

timedatectl set-local-rtc 1

将硬件时间改回使用UTC:

bash

timedatectl set-local-rtc 0

修改Windows硬件时钟为UTC时间:

以管理员身份打开PowerShell, 运行以下命令:

shell

reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation" /v RealTimeIsUniversal /d 1 /t REG_DWORD /f

或者打开注册表编辑器, 定位到计算机\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation目录下, 新建一个DWORD类型, 名称为RealTimeIsUniversal的键, 并修改键值为1即可。

Windows 使用UTC后, 请记得禁用Windows的时间同步功能, 以防Windows错误设置硬件时间。

Windows磁盘挂载到Linux后, 有时处于只读状态。

  • 从grub界面进入Windows, 然后从Windows重启, 而不是直接关机。

    虽然不方便, 但这也是解决问题的最快方法, 不需要像其他解决方法那样长期更改任何内容。Windows重启时, 不会在下次启动时使用“快速启动”功能。这意味着它不会进入休眠状态、获取系统运行状态的快照或将任何内存数据保存到磁盘。分区上没有休眠数据, 这意味着可以安全地写入到分区上, Linux会识别出这一点。

  • 或者禁用快速启动。

    如果常常需要从Linux写入到Windows分区上, 可以选择这个方法。缺点是Windows需要更长的开机引导时间。要禁用快速启动, 可以在设置或者控制面板里面找电源选项

以上两种方法是安全的做法, 更多信息参考Dual boot with Windows#Fast Startup and hibernation

在Windows上使用Paragon ExtFS for Windows