Debian使用问题

系列 - Start Use Debian

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

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

1
useradd -s /bin/bash username

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

1
username:x:1002:1003::/home/username:/bin/sh

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

1
username:x:1002:1003::/home/username:/bin/bash

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

1
usermod -s /bin/bash username
  1. 查看启动速度:

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

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

    1
    2
    3
    4
    5
    6
    7
    8
    
    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, 比如:

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

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

  • 使用alsamixer命令直接调节。

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

    1
    
    sudo apt-get install kdemultimedia kmix
    

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

  1. 安装laptop-mode:

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

    1
    
    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模式:

    1
    
    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:

1
sudo apt install firmware-linux

对于Ubuntu:

1
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.

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

1
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  1. root身份登录系统时, 无法运行某些软件 (如Google Chrome) , 而普通用户可以打开;

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

以Google Chrome为例:

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

参考System time#Time standard:

时间标准

时间表示有两个标准: localtime 和 UTC(Coordinated Universal Time) 。UTC 是与时区无关的全球时间标准。尽管概念上有差别, UTC 和 GMT (格林威治时间) 是一样的。localtime 标准则依赖于当前时区。

时间标准由操作系统设定, Windows 默认使用 localtime, Mac OS 默认使用 UTC 而 UNIX 系列的操作系统两者都有。使用 Linux 时, 最好将硬件时钟设置为 UTC 标准, 并在所有操作系统中使用。这样 Linux 系统就可以自动调整夏令时设置, 而如果使用 localtime 标准那么系统时间不会根据夏令时自动调整。

如果机器上安装多个操作系统, 硬件使用的是本地时间, 可能多个操作系统都进行 夏令时调整, 导致时间错乱。计算机在多个时区切换时, 也会出现问题。 所以建议多系统用户统一使用 UTC 时间。

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

所以, 让Linux使用localtime更好一些。毕竟:

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

通过timedatectl命令可以查看设置系统时间。通过下面命令查看当前硬件时钟的时间标准:

1
2
$ timedatectl | grep local
RTC in local TZ: no

将硬件时间设置为localtime:

1
timedatectl set-local-rtc 1

硬件时间设置成UTC:

1
timedatectl set-local-rtc 0

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

1
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磁盘挂载到Linux后, 有时处于只读状态。

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

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

  • 或者禁用快速启动。

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

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

在Windows上使用Paragon ExtFS for Windows