0%

Linux 杂记

本文记录 Linux 使用过程中遇到的小问题和解决方法,比较杂。

日常使用Ubuntu 18.04,服务器常用CentOS 7

Gnome

菜单管理

菜单快捷方式文件路径

1
2
global: /usr/share/application
local: /home/vc/.local/share/applications

Menu 中为 App 创建文件夹

方法一:安装插件

方法二:在 Ubuntu Software 中操作,在 install 选项卡中选中多个 app 添加到 folder

ref

部分 App 在 Menu 中不显示图标

标记文件中有个NotShowIn=GNOME选项,将其注释

Dock 启用“Minimize on Click”

1
2
# 默认为'previews'
gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize'

document viewer shortcut

  • 文档管理器切换路径输入快捷键ctrl+L
  • 在此处打开终端app+E

Gnome 桌面美化

针对 Gnome 3 的 Linux 桌面进行美化

中文字体

中文字体异常,如‘门’字显示为日文。系统级别的解决方法为,修改系统配置文件

1
sudo vi /etc/fonts/conf.d/64-language-selector-prefer.conf

<family>Noto Sans CJK CS</falimy>提到最前面。

Chrome 中可以单独对字体进行设置。

远程连接桌面

Xming: 连不上注意查看 log, 看是不是 server 的访问权限问题,

软件与命令

WPS

  1. 进入 WPS 官网 下载最新版安装包
    • 可卸载自带 office sudo apt-get remove --purge libreoffice*
  2. 终端下dpkg安装
  3. 若出现系统字体缺失问题可 下载字体库 安装,密码:pwe1
1
sudo unzip wps_symbol_fonts.zip -d /usr/share/fonts/wps-office

UFW

LInux 原始的防火墙工具 iptables 由于过于繁琐,所以 ubuntu 系统默认提供了一个基于 iptable 之上的防火墙工具 ufw。

ref:

sudo

sudo cd 命令无法进入权限 700 的目录,要通过 sudo -i/-s

类似的 cp 命令也无法正常运行

1
2
sudo cp -R /var/lib/docker/* /home/vc/Docker/lib/
cp: cannot stat '/var/lib/docker/*': No such file or directory

参考

You can get an interactive shell running as root using any of the following methods (these are the full commands just run as is from an existing shell and they will give you a root shell).

  • sudo -i: Gives you a root prompt with a new shell environment (as if root did a login). Does a cd to root’s home directory as well.
  • sudo sh or sudo bash: Gives a basic root shell spawned in the environment of the calling user (sanitized by sudo).
  • sudo -s -H: Gives a shell and resets $HOME, but doesn’t cd to $HOME like sudo -i.
  • sudo su: Uses the normal su method of becoming root but doesn’t need a root password.

Basically I use either sudo -i or sudo -s -H in most cases depending on if I wanted to end up in root’s home directory or not.

存储管理

根目录扩展

  1. 查看硬盘使用情况:df -lh
  2. 安装 gparted: sudo apt-get install gparted
  3. 打开 gparted 后会发现,有许多小钥匙标识无法去掉,也无法进行分区操作。

因为分区已经挂载了,没法再当前系统下进行重新分配空间,所以得准备一个 Ubuntu 启动盘,在 live 系统中进行操作
搜索 gparted 并打开,小钥匙标识还没有消除!依次选中你要操作的两个分区(我的是”/“和"/home")以及 linux-swap,右键选择** unmount**,即可对其进行改变大小的操作。

  1. 从/home 分区中分出 20G,如果这个空闲的 20G 不在根目录"/"的下方,则需要向上调整大小,直到调整到根目录的下方。这时就可以对根目录进行操作,resize 根目录的大小,将空闲的 20G 合并进去。
  2. 最后,一定要记得应用到整个系统,即选择菜单栏 >> Edit >> Apply all Operations >> Apply

成功!

参考

snap 安装目录迁移

参考:https://askubuntu.com/questions/1029562/move-snap-packages-to-another-location-directory/1029948

外设

蓝牙耳机连接

配对后无法连接,运行

1
2
3
sudo apt-get install pulseaudio-module-bluetooth(已安装)

pactl load-module module-bluetooth-discover(执行后成功连接)

添加添加 2560×1440 分辨率

前段时间购入了戴尔 U2515 2K 显示器,分辨率为 2560×1440, 不过发现在 Ubuntu 中找不到 2560×1440 分辨率设置,最大的只有 2560×1600 分辨率。查了下,通过 xrandr 命令可解决。

1)通过 xrandr 即可查看当前显示器所有分辨率,其中 Virtual1 是是当前显示器名称:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
jeff@jeff-virtual-machine:~$ xrandr
Screen 0: minimum 1 x 1, current 2560 x 1440, maximum 16384 x 16384
Virtual1 connected primary 2560x1440+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
2560x1440 60.00*+
2560x1600 59.99
1920x1440 60.00
1856x1392 60.00
1792x1344 60.00
1920x1200 59.88
1600x1200 60.00
1680x1050 59.95
1400x1050 59.98
1280x1024 60.02
1440x900 59.89
1280x960 60.00
1360x768 60.02
1280x800 59.81
1152x864 75.00
1280x768 59.87
1024x768 60.00
800x600 60.32
640x480 59.94

2)接着敲入:

1
2
3
$ cvt 2560 1440
# 2560x1440 59.96 Hz (CVT 3.69M9) hsync: 89.52 kHz; pclk: 312.25 MHz
Modeline "2560x1440_60.00" 312.25 2560 2752 3024 3488 1440 1443 1448 1493 -hsync +vsync

添加我们的 2K 分辨率。

3)在显示器分辨率列表中添加上面得到的分辨率设置:

1
xrandr --newmode "2560x1440_60.00"  312.25  2560 2752 3024 3488  1440 1443 1448 1493 -hsync +vsync

4)添加该模式,其中 Virtual1 是第一步中得到的显示器名称:

1
xrandr --addmode HDMI-1 "2560x1440_60.00"

最后就可以在分辨率设置中找到该分辨率了,用命令行设置

1
xrandr --output HDMI-1 --mode "2560x1440_60.00"

保持副屏旋转和位置

1
xrandr --output VGA-1 --rotate left --pos 2560x0

汇总

1
2
3
4
5
cvt 2560 1440
xrandr --newmode "2560x1440_60.00" 312.25 2560 2752 3024 3488 1440 1443 1448 1493 -hsync +vsync
xrandr --addmode HDMI-1 "2560x1440_60.00"
xrandr --output HDMI-1 --mode "2560x1440_60.00"
xrandr --output VGA-1 --rotate left --pos 2560x0

多屏管理

https://wiki.archlinux.org/index.php/multihead

psychtoolbox 里有一些 po

使用 windows 共享打印机

  • 安装 samba
  • 设置/设备/打印机 中添加

https://blog.csdn.net/xindablack/article/details/95182327

网络

DNS

ubuntu 18.04 的 DNS 似乎是由 service systemd-resolved 控制,重启这个服务以后,/etc/resolv.conf 会被重置

重启 systemd 解析服务

1
2
sudo systemctl is-active systemd-resolved.service
sudo systemd-resolve --flush-caches

重启 DNSMasq 缓存服务,Dnsmasq 是轻量级的 DHCP 和 DNS 缓存名称服务器。

1
2
sudo systemctl restart dnsmasq.service
sudo service dnsmasq restart

ubuntu zjuvpn

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
default dev ppp0 
default via 10.12.45.1 dev enp3s0 proto static metric 20100
10.0.0.0/8 via 10.12.45.1 dev enp3s0
10.5.1.0/24 via 10.12.45.1 dev enp3s0
10.10.0.0/24 via 10.12.45.1 dev enp3s0
10.12.45.0/24 dev enp3s0 proto kernel scope link src 10.12.45.78 metric 100
58.196.192.0/19 via 10.12.45.1 dev enp3s0
58.196.224.0/20 via 10.12.45.1 dev enp3s0
58.200.100.0/24 via 10.12.45.1 dev enp3s0
169.254.0.0/16 dev enp3s0 scope link metric 1000
210.32.0.0/20 via 10.12.45.1 dev enp3s0
210.32.128.0/19 via 10.12.45.1 dev enp3s0
210.32.160.0/21 via 10.12.45.1 dev enp3s0
210.32.168.0/22 via 10.12.45.1 dev enp3s0
210.32.172.0/23 via 10.12.45.1 dev enp3s0
210.32.176.0/20 via 10.12.45.1 dev enp3s0
222.205.0.0/17 via 10.12.45.1 dev enp3s0

10.5.1.0/24 via 10.12.45.1 dev enp3s0

直接改 lns 地址没法联网,改完路由表可以联网但是只能下载不能上传,待续。…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
IPv4 路由表
===========================================================================
活动路由:
网络目标 网络掩码 网关 接口 跃点数
0.0.0.0 0.0.0.0 10.12.45.1 10.12.45.78 4506
0.0.0.0 0.0.0.0 在链路上 222.205.29.215 26
10.0.0.0 255.0.0.0 10.12.45.1 10.12.45.78 4251
10.0.2.72 255.255.255.255 10.12.45.1 10.12.45.78 4251
10.12.45.0 255.255.255.0 在链路上 10.12.45.78 4506
10.12.45.78 255.255.255.255 在链路上 10.12.45.78 4506
10.12.45.255 255.255.255.255 在链路上 10.12.45.78 4506
127.0.0.0 255.0.0.0 在链路上 127.0.0.1 4556
127.0.0.1 255.255.255.255 在链路上 127.0.0.1 4556
127.255.255.255 255.255.255.255 在链路上 127.0.0.1 4556
210.32.0.0 255.255.240.0 10.12.45.1 10.12.45.78 4251
210.32.128.0 255.255.192.0 10.12.45.1 10.12.45.78 4251
222.205.0.0 255.255.128.0 10.12.45.1 10.12.45.78 4251
222.205.29.215 255.255.255.255 在链路上 222.205.29.215 281
224.0.0.0 240.0.0.0 在链路上 127.0.0.1 4556
224.0.0.0 240.0.0.0 在链路上 10.12.45.78 4506
224.0.0.0 240.0.0.0 在链路上 222.205.29.215 26
255.255.255.255 255.255.255.255 在链路上 127.0.0.1 4556
255.255.255.255 255.255.255.255 在链路上 10.12.45.78 4506
255.255.255.255 255.255.255.255 在链路上 222.205.29.215 281
===========================================================================

deepin wine

为了在 Linux 下使用 QQ 和微信,安装 deepin 魔改过的 wine

安装

deepin wine 的安装参照 deepin-wine-ubuntudeepin-winel 两个就行。实践中花了很多时间解决依赖问题是因为上一条提到的proposed仓库的问题,导致报了很多依赖问题。

中文乱码问题

参考 1 解决了 TIM 的乱码,但 WeChat 依旧乱码。微信现在主要适用网页版,先不处理了,心累。

其他参考 2/3/4

界面的中文正常,输入框的中文依然乱码(气泡模式)。

根据参考 3:

  • step 1

# 经验证这步不做也行

系统语言非中文时,中文全显示成方块,需要在/opt/deepinwine/tools/run.sh中将 WINE_CMD 那一行修改为:

WINE_CMD=“LC_ALL=zh_CN.UTF-8 deepin-wine”

  • step2

#1. 添加字体
cp msyh.ttc ~/.deepinwine/Deepin-WeChat/drive_c/windows/Fonts
#2. 修改系统注册表
edit ~/.deepinwine/Deepin-WeChat/system.reg
#修改以下两行
“MS Shell Dlg”=“msyh”
“MS Shell Dlg 2”=“msyh”

2019-09-11 更新:又 GG 了,把sim*, ms*字体复制到 wine 的 Fonts 目录,解决。

winecfg

如果是 QQ 用下面的命令执行 WINEPREFIX=~/.deepinwine/Deepin-QQ deepin-wine winecfg 其他应用修改 WINEPREFIX 的值就好了。

Wine-QQ-TIM

提供在 Linux 上运行最新版腾讯 QQ 与 TIM 的解决方案 Easiest Way to Run QQ&TIM on Linux

Ubuntu 镜像源 channel 之间的关系

ubuntu 官方说明

Proposed updates

IconsPage/stop.png

Enabling the proposed updates repository can break your system. It is not recommended for inexperienced users.

The proposed updates are updates which are waiting to be moved into the recommended updates queue after some testing. They may never reach recommended or they may be replaced with a more recent update.

Enabling this is reasonable if you want to participate in testing minor updates, or know that your specific problem has been solved here but the package hasn’t reached recommended yet.

proposed为测试版,尽量不要开启。在安装deepin-wine的过程中发现因为以前开过proposed,把一下包升级到了较高版本(amd64),在安装相应的 i386 包的时候就不得不使用proposed,否则会找不到依赖。因此以后慎用这个仓库。

尝试 降级 成功