Debian使用问题
1 新建用户下终端难用
在新建的用户下使用命令终端, 出现方向键无法调出历史命令、tab键也无法补全输入命令等现象, 总之很不正常。
1.1 原因
新建用户时忘记指定用户运行shell
:
useradd -s /bin/bash <UserName>
1.2 解决方法
查看/etc/passwd
, 发现该新建用户使用的shell
为/bin/sh
, 比如:
<UserName>:x:1002:1003::/home/<UserName>:/bin/sh
而一般使用的shell
为/bin/bash
, 所以将该用户的/bin/sh
修改为/bin/bash
即可:
<UserName>:x:1002:1003::/home/<UserName>:/bin/bash
推荐直接使用usermod
指定用户运行shell
:
usermod -s /bin/bash <UserName>
2 Linux开机速度慢
2.1 解决方法
查看启动速度:
systemd-analyze
查看各个自启动服务占用时间:
systemd-analyze blame
禁用启动服务, 比如:
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
, 比如:sudo systemctl mask avahi-daemon.service
另外, 检查开机启动项
/etc/xdg/autostart/
。
3 无法调节音量
3.1 场景
在有声音输出的前提下, 无法调节音量。
3.2 解决方法
使用
alsamixer
命令直接调节。或者安装Kmix音量调节器:
sudo apt-get install kdemultimedia kmix
4 锁屏后黑屏/合盖后无法唤醒
4.1 解决方法
安装laptop-mode:
sudo apt install laptop-mode-tools
判断Laptop是否启用了laptop_mode模式, 如果显示结果为0, 则表示未启动, 如果为非0的数字则表示启动了:
cat /proc/sys/vm/laptop_mode
启动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_BATTERY
、ENABLE_LAPTOP_MODE_ON_AC
、ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED
, 分别是当用电池、外接电源、合上显示屏的时候是否启用LAPTOP_MODE, 全部设置为 1 就可以了。执行
sudo laptop_mode start
启动laptop_mode之后, 在Ubuntu挂起后, 基本上就不会遇到无法唤醒的情况了。再次判断Laptop是否启用了laptop_mode模式:
cat /proc/sys/vm/laptop_mode
5 缺失firmware
5.1 场景
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
5.2 解决方法
参考Possible missing firmware /lib/firmware/i915/* for module i915。
对于Debian:
sudo apt install firmware-linux
对于Ubuntu:
sudo apt install linux-firmware
6 配置环境变量
6.1 场景
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.
6.2 解决方法
编辑 环境变量配置文件, 添加以下内容:
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
7 软件无法启动
7.1 场景
root身份登录系统时, 无法运行某些软件 (如Google Chrome), 而普通用户可以打开;
某些软件普通用户也无法运行 (如PicGo的AppImage)。
7.2 解决方法
以Google Chrome为例:
- 找到
usr/share/applications
中的Google Chrome启动文件, 右击用文本编辑器打开; - 在
Exec=typora %U
后面添加--no-sandbox
(注意--
的前面有个空格)。
8 双系统时间不一致
我只用UTC+8
的Asia/Shanghai
这一个时区, 而且中国也不用夏令时, 所以我选择使用localtime
。
此外, Ubuntu及其衍生发行版会在安装时检测计算机上是否存在Windows, 若存在则会默认使用localtime
。这是为了让Windows用户能够在不修改注册表的情况下, 在Ubuntu内看到正确的时间。
更多信息参考System time#Time standard。
8.1 Linux时间
通过timedatectl
命令可以查看设置系统时间。运行timedatectl
命令查看当前硬件时钟的时间标准, 如果输出中有:
RTC in local TZ: no
表示硬件时钟使用UTC。
将硬件时间设置为localtime:
timedatectl set-local-rtc 1
将硬件时间改回使用UTC:
timedatectl set-local-rtc 0
8.2 Windows时间
修改Windows硬件时钟为UTC时间:
以管理员身份打开PowerShell, 运行以下命令:
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错误设置硬件时间。
9 双系统磁盘读写问题
9.1 Windows磁盘挂载到Linux
9.1.1 场景
Windows磁盘挂载到Linux后, 有时处于只读状态。
9.1.2 解决方法
从grub界面进入Windows, 然后从Windows重启, 而不是直接关机。
虽然不方便, 但这也是解决问题的最快方法, 不需要像其他解决方法那样长期更改任何内容。Windows重启时, 不会在下次启动时使用“快速启动”功能。这意味着它不会进入休眠状态、获取系统运行状态的快照或将任何内存数据保存到磁盘。分区上没有休眠数据, 这意味着可以安全地写入到分区上, Linux会识别出这一点。
或者禁用快速启动。
如果常常需要从Linux写入到Windows分区上, 可以选择这个方法。缺点是Windows需要更长的开机引导时间。要禁用快速启动, 可以在设置或者控制面板里面找电源选项。
以上两种方法是安全的做法, 更多信息参考Dual boot with Windows#Fast Startup and hibernation
9.2 Linux磁盘挂载到Windows
9.2.1 解决方法
在Windows上使用Paragon ExtFS for Windows。