0%

Linux使用的一些常见问题-不定期更新

GPG error

  • W: GPG error: http://mirrors.ustc.edu.cn bullseye-updates InRelease: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 648ACFD622F3D138 NO_PUBKEY 0E98404D386FA1D9
1
~$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0E98404D386FA1D9 648ACFD622F3D138

DEPRECATION legacy keyring

1
2
W: http://dl.google.com/linux/earth/deb/dists/stable/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.

  • list all keys
1
2
3
4
5
6
7
8
9
10
11
12
13
14
~$ apt-key --keyring /etc/apt/trusted.gpg list | grep "google" -A +5 -B +5
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
uid [ unknown] NodeSource <gpg@nodesource.com>
sub rsa4096 2014-06-13 [E]

pub rsa4096 2016-04-12 [SC]
EB4C 1BFD 4F04 2F6D DDCC EC91 7721 F63B D38B 4796
uid [ unknown] Google Inc. (Linux Packages Signing Authority) <linux-packages-keymaster@google.com>
sub rsa4096 2021-10-26 [S] [expires: 2024-10-25]

pub rsa4096 2015-04-17 [SC] [expired: 2020-04-15]
1A4C 919D B987 D435 9396 38B9 1421 9A96 E15E 78F4
uid [ expired] GitLab B.V. (package repository signing key) <packages@gitlab.com>

  • export to a new file.
    1
    2
    3
    ~$ sudo apt-key export D38B4796 | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/dl-google.gpg
    Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).

PulseAudio 设置与应用

  • 安装如下包,具体安装可参考这里

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    ~$ dpkg -l | grep "pulseaudio"
    ii gstreamer1.0-pulseaudio:amd64 1.10.4-1 amd64 GStreamer plugin for PulseAudio
    ii pulseaudio 10.0-1+deb9u1 amd64 PulseAudio sound server
    ii pulseaudio-dlna 0.5.2-1 all Stream audio to DLNA devices and Chromecasts
    ii pulseaudio-module-bluetooth 10.0-1+deb9u1 amd64 Bluetooth module for PulseAudio sound server
    ii pulseaudio-module-gconf 10.0-1+deb9u1 amd64 GConf module for PulseAudio sound server
    ii pulseaudio-module-jack 10.0-1+deb9u1 amd64 jackd modules for PulseAudio sound server
    ii pulseaudio-utils 10.0-1+deb9u1 amd64 Command line tools for the PulseAudio sound server
    ii alsa-tools 1.1.3-1 amd64 Console based ALSA utilities for specific hardware
    ii alsa-utils 1.1.3-1 amd64 Utilities for configuring and using ALSA
    ii alsamixergui 0.9.0rc2-1-10 amd64 graphical soundcard mixer for ALSA soundcard driver
  • 添加这一行load-module module-alsa-sink device=hw:1,0/etc/pulse/default.pa里面.

1
2
3
4
~$ cat /etc/pulse/daemon.conf
daemonize = yes
allow-module-loading = yes
system-instance = yes
  • 把下面的输出转到 PulseAudio.
1
2
3
4
5
6
7
8
9
10
11
12
13
~$ cat ~/.asoundrc
pcm.pulse {
type pulse
}
ctl.pulse {
type pulse
}
pcm.!default {
type pulse
}
ctl.!default {
type pulse
}
  • 启动,停止 PulseAudio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
~$ pulseaudio --kill
~$ pulseaudio --start

~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: HDMI [HDA ATI HDMI], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Generic [HD-Audio Generic], device 0: ALC887-VD Analog [ALC887-VD Analog]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 1: Generic [HD-Audio Generic], device 1: ALC887-VD Digital [ALC887-VD Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
  • 如果出现任何问题,仔细查看系统日志解决.

minicom 使用

  • Linux下的超级终端工具minicom 是命令行的工具不像 windows 下的串口工具那么直观,但是使用习惯了就一样.
  • 初次使用minicom除了一些串口的常规设置,跟其它串口工具都是一样的.
  • 在当前 Shell下输入minicom -s会出现如下界面:
1
2
3
4
5
6
7
8
9
10
11
+-----[configuration]------+
| Filenames and paths |
| File transfer protocols |
| Serial port setup |
| Modem and dialing |
| Screen and keyboard |
| Save setup as dfl |
| Save setup as.. |
| Exit |
| Exit from Minicom |
+--------------------------+
  • 选择Serial port setup 设置串口参数:
1
2
3
4
5
6
7
8
9
10
11
+-----------------------------------------------------------------------+
| A - Serial Device : /dev/ttyUSB5 |
| B - Lockfile Location : /var/lock |
| C - Callin Program : |
| D - Callout Program : |
| E - Bps/Par/Bits : 115200 8N1 |
| F - Hardware Flow Control : No |
| G - Software Flow Control : No |
| |
| Change which setting? |
+-----------------------------------------------------------------------+
  • 设置完成回车返回到一个菜单.选择Save setup as dfl 保存退出.

  • 我一般使用 minicom 的参数去连接.例如:

1
~$  minicom -o -b 115200 -D /dev/ttyUSB5

AT 命令

esptool 升级固件

  • 参考链接:

  • ESP8266 Tools

  • ESP8266 Wiki

  • ESP8266 SDK

  • 使用 Arduino 更新 ESP8266 firmware

  • ESP-01为例.

    1
    2
    3
    4
    5
    6
    7
    8
    GPIO0 --> GND
    GPIO2 --> 3V3
    CH_PD --> 3V3
    RST --> 3V3
    VCC --> 3V3
    GND --> GND
    TX --> UART(RX)
    RX --> UART(TX)
  • esptool 工具

    1
    ~$ esptool.py   -p /dev/ttyUSB5 write_flash --flash_mode dio --flash_size 8m 0x0 AiThinker_ESP8266_DIO_8M_8M_20160615_V1.5.4.bin
  • 这个升级问题折腾了我很久,今天总算是升级成功.它们的文档很杂,图与板子上的名称又不全部对应.

下面是更新部分

  • Updating ESP8266 Firmware
  • Espressif Systems
  • Update the Firmware in Your ESP8266 Wi-Fi Module
  • ESP8266 - Upgrading the Firmware
  • 这里以下载最新的v1.7.4固件为例,注意查看各个子文件目录里的README.md.
    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
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66

    TTL-USB ESP01

    RX ---> TX
    TX ---> RX
    GND ---> GND
    GND ---> GPIO0 # 烧写完成后,把它移除就进入正常模式
    3V3 ---> 3V3
    3V3 ---> CH_PD

    ~$ esptool.py flash_id
    esptool.py v3.0-dev
    Found 2 serial ports
    Serial port /dev/ttyUSB1
    Connecting....
    Detecting chip type... ESP8266
    Chip is ESP8266EX
    Features: WiFi
    Crystal is 26MHz
    MAC: 5c:cf:7f:0a:6c:b8
    Uploading stub...
    Running stub...
    Stub running...
    Manufacturer: e0
    Device: 4014
    Detected flash size: 1MB
    Hard resetting via RTS pin...

    ~$ esptool.py -p /dev/ttyUSB0 write_flash --flash_mode qio --flash_freq 40m 0x00000 boot_v1.7.bin 0x01000 at/512+512/user1.1024.new.2.bin 0xfc000 esp_init_data_default_v08.bin 0x7e000 blank.bin 0xfe000 blank.bin 0xfb000 blank.bin

    esptool.py v3.0-dev
    Serial port /dev/ttyUSB0
    Connecting....
    Detecting chip type... ESP8266
    Chip is ESP8266EX
    Features: WiFi
    Crystal is 26MHz
    MAC: 5c:cf:7f:0a:6c:b8
    Uploading stub...
    Running stub...
    Stub running...
    Configuring flash size...
    Auto-detected Flash size: 1MB
    Flash params set to 0x0020
    Compressed 4080 bytes to 2936...
    Wrote 4080 bytes (2936 compressed) at 0x00000000 in 0.3 seconds (effective 123.6 kbit/s)...
    Hash of data verified.
    Compressed 413444 bytes to 296966...
    Wrote 413444 bytes (296966 compressed) at 0x00001000 in 26.3 seconds (effective 126.0 kbit/s)...
    Hash of data verified.
    Compressed 128 bytes to 75...
    Wrote 128 bytes (75 compressed) at 0x000fc000 in 0.0 seconds (effective 85.1 kbit/s)...
    Hash of data verified.
    Compressed 4096 bytes to 26...
    Wrote 4096 bytes (26 compressed) at 0x0007e000 in 0.0 seconds (effective 4089.5 kbit/s)...
    Hash of data verified.
    Compressed 4096 bytes to 26...
    Wrote 4096 bytes (26 compressed) at 0x000fe000 in 0.0 seconds (effective 4159.4 kbit/s)...
    Hash of data verified.
    Compressed 4096 bytes to 26...
    Wrote 4096 bytes (26 compressed) at 0x000fb000 in 0.0 seconds (effective 4216.8 kbit/s)...
    Hash of data verified.

    Leaving...
    Hard resetting via RTS pin...

  • 使用minicom时注意,软硬件流控要为NO,具体设置Ctrl-A Z, -> O [Configure Minicom] -> Serial Port Setup -> F.使用putty边接,输入下面的命令
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
26
# 查看固件
at+GMR
AT version:1.7.4.0(May 11 2020 19:13:04)
SDK version:3.0.4(9532ceb)
compile time:May 27 2020 10:12:17
Bin version(Wroom 02):1.7.4
OK

# 扫AP
AT+CWLAP
+CWLAP:(4,"18575654312",-84,"cc:2d:21:64:23:40",1,63,0,4,4,7,0)
+CWLAP:(3,"lcy",-43,"20:0d:b0:40:21:8f",1,75,0,4,4,3,0)
OK

# 看地址
at+CIFSR
+CIFSR:STAIP,"192.168.2.122"
+CIFSR:STAMAC,"5c:cf:7f:0a:6c:b8"

OK

# 看内存
AT+SYSRAM?
+SYSRAM:51952

OK

转换GBK文本文件的问题

  • 有时在Linux下打开GBK编码的文件会出现乱码,优其是一些在window下载打包的源码压缩包,源码文件全都是GBK编码.在Linux下用一些文本编辑器打开全是乱码,有些甚至连目录都是乱码.
  • 下面记录一个shell脚本批量转换成UTF8格式的文件.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ cat convert.sh
#!/bin/bash
TMP_IFS=$IFS
IFS=$(echo -en "\n\b")
for f in `find . -type f`;do
org=$(file $f)
string=$(echo $org | grep "ISO-8859") ;
if [ -n "$string" ]; then
infile=$(echo $string | awk -F':' '{print $1}');
#echo $infile
iconv -f GBK -t UTF8 $infile > 1;
mv 1 $infile;
fi ;
done
IFS=$TMP_IFS
1
2
3
4
5
6
7
#!/bin/bash
TMP_IFS=$IFS
IFS=$(echo -en "\n\b")

for f in `find . \( -iname "*.txt" -o -iname "*.c" -o -iname "*.h" \)`;do
iconv -f GBK -t UTF8 -c $f > 1; mv 1 $f;
done
  • 在转换文件时,有时候路径中会包含空格,如果不按照上面的方式设置IFS变量,脚本就会出错在有空格的地方分隔,认为是两个文件.上面这个脚本只是
  • 一个很简单的处理当前目录下所有文件的转换.还可以把它写的更通用灵活.

批量清除文件名中的特定字符串

  • 有时从网站下载一些文件,资源经会把自已的名字或者网址加在文件名如: 电影名_[www.xxx.com].mkv,这样的格式
    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
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    #!/bin/bash
    TMP_IFS=$IFS
    IFS=$(echo -en "\n\b")
    sub1="www\.xxx\.com"
    sub2="www\.bbb\.com"
    sub3="www\.ccc\.com"
    #sub4="[(]www.ddd.com[)]" # 例如: fname-(www.ddd.com).pdf, sed -re "s/$sub4//g"


    # 例如:匹配 538081 SCALA学习手册.pdf 556997 Scala函数式编.pdf 这样的文件名,删除前面的6个数字
    #
    # reg='^([0-9]{6})'
    # for fname in `ls`;do
    # string=$(echo $fname)
    # if [[ $string =~ $reg ]];
    # then
    # nstr=$(echo $string | sed -r "s/${reg}//g")
    # echo $nstr
    # mv $fname $nstr
    # fi
    # done
    #
    #

    for fname in `ls`;
    do
    string=$(echo $fname)
    if [[ $string = *${sub1}* || $string = *${sub2}* || $string = *${sub3}* || $string = *${sub4}* ]];
    then
    nstring=$(echo $s | sed -e "s/${sub1}//g" -e "s/$sub2//g" -e "s/$sub3//g" -e "s/\(()\)//g/" -e "s/\[[]\]//g" )

    echo $nstring
    mv $f $nstring
    fi
    done

    IFS=$TMP_IFS

路由表内存在多个default dev的问题

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
26
~$ ip route
0.0.0.0 dev veth49bb6a8 scope link
0.0.0.0 dev eth0 scope link
default dev veth49bb6a8 scope link
default dev eth0 scope link
default via 192.168.1.1 dev br-lan onlink
169.254.0.0/16 dev eth0 proto kernel scope link src 169.254.46.34
169.254.0.0/16 dev veth49bb6a8 proto kernel scope link src 169.254.136.170
169.254.0.0/16 dev br-lan scope link metric 1000
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1
192.168.1.0/24 dev br-lan proto kernel scope link src 192.168.1.178

~$ dpkg -l | grep "avahi"
ii avahi-autoipd 0.8-10 amd64 Avahi IPv4LL network address configuration daemon
ii avahi-daemon 0.8-10 amd64 Avahi mDNS/DNS-SD daemon
ii avahi-utils 0.8-10 amd64 Avahi browsing, publishing and discovery utilities
ii libavahi-client3:amd64 0.8-10 amd64 Avahi client library
ii libavahi-common-data:amd64 0.8-10 amd64 Avahi common data files
ii libavahi-common3:amd64 0.8-10 amd64 Avahi common library
ii libavahi-core7:amd64 0.8-10 amd64 Avahi's embeddable mDNS/DNS-SD library
ii libavahi-glib1:amd64 0.8-10 amd64 Avahi GLib integration library

~$ dpkg -l | grep "connman"
ii connman 1.41-3 amd64 Intel Connection Manager daemon
ii connman-gtk 1.1.1+git20180626.b72c6ab-3 amd64 fully-featured GUI for ConnMan with systray support

  • 因为是安装了debian buster lxde-desktop版本,先是怀疑avahi问题,看了它的配置,有去配置169.254.x.x的地址,删除后,还是没有解决问题。列出本地端口时,发现有一个进程listen 127.0.0.1:53, 最终查到是connman导至的问题。

Linux 下wireless WPA加密连接

  • 确保安装了 wpasupplicant

    1
    ~$ sudo apt-get install wpasupplicant.
  • 创建/etc/wpa_supplicant.conf或者从/usr/share/doc/wpa_supplicant/examples/wpa_supplicant.conf.gz复制

  • 例如:

    1
    2
    3
    4
    network={
    ssid="ssid_name"
    psk="password"
    }
  • 手动命令行连接

1
2
~$ sudo wpa_supplicant -B -iwlan0 -c/etc/wpa_supplicant.conf -Dwext
~$ sudo dhclient wlan0

MT7601U 开启软件AP功能(非hostapd)

  • 如果安装或是编译了其它的mt7601u的驱动,需要把它卸载或者加入黑名单里,不能加载它.
    1
    2
    ~$ cat /etc/modprobe.d/blacklist-mt7601u
    blacklist mt7601u

RTL8812AU驱动(0bda:0811)

1
2
3
4
~$ lsusb -s 008 -v

Bus 008 Device 008: ID 0bda:0811 Realtek Semiconductor Corp.

  • 这块RTL8812AU的网卡是EDUP AC-1608,查看它官方驱动是法支持AP功能且还不支持nl80211的驱动,之后去到github搜索到一些驱动,有一些是只能使用网卡功能,有一些还连编译都无法通过.后来验证两个驱动如上,最后使用了aircrack-ng解决了所有的问题,不愧是黒技术的先锋.
  • 按照aircrack-ng的提示,直接make && make install或者sudo ./dkms-install.sh就直接编译并安装到内核树的驱动里.加载成功后,查看模块信息,检测到功能如下:
1
2
~$ modinfo 88XXau | grep "0811"
alias: usb:v0BDAp0811d*dc*dsc*dp*ic*isc*ip*in*
  • 查看phy的信息.
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
~$ iw list
Wiphy phy3
max # scan SSIDs: 9
max scan IEs length: 2304 bytes
max # sched scan SSIDs: 0
max # match sets: 0
max # scan plans: 1
max scan plan interval: -1
max scan plan iterations: 0
Retry short limit: 7
Retry long limit: 4
Coverage class: 0 (up to 0m)
Supported Ciphers:
* WEP40 (00-0f-ac:1)
* WEP104 (00-0f-ac:5)
* TKIP (00-0f-ac:2)
* CCMP-128 (00-0f-ac:4)
* CMAC (00-0f-ac:6)
Available Antennas: TX 0x1 RX 0x1
Supported interface modes:
* IBSS
* managed
* AP
* monitor
* P2P-client
* P2P-GO
Band 1:
Capabilities: 0x1972
HT20/HT40
Static SM Power Save
RX Greenfield
RX HT20 SGI
RX HT40 SGI
RX STBC 1-stream
Max AMSDU length: 7935 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 16 usec (0x07)
HT Max RX data rate: 150 Mbps
HT TX/RX MCS rate indexes supported: 0-7
Bitrates (non-HT):
* 1.0 Mbps
* 2.0 Mbps
* 5.5 Mbps
* 11.0 Mbps
* 6.0 Mbps
* 9.0 Mbps
* 12.0 Mbps
* 18.0 Mbps
* 24.0 Mbps
* 36.0 Mbps
* 48.0 Mbps
* 54.0 Mbps
Frequencies:
* 2412 MHz [1] (20.0 dBm)
* 2417 MHz [2] (20.0 dBm)
* 2422 MHz [3] (20.0 dBm)
* 2427 MHz [4] (20.0 dBm)
* 2432 MHz [5] (20.0 dBm)
* 2437 MHz [6] (20.0 dBm)
* 2442 MHz [7] (20.0 dBm)
* 2447 MHz [8] (20.0 dBm)
* 2452 MHz [9] (20.0 dBm)
* 2457 MHz [10] (20.0 dBm)
* 2462 MHz [11] (20.0 dBm)
* 2467 MHz [12] (20.0 dBm)
* 2472 MHz [13] (20.0 dBm)
* 2484 MHz [14] (20.0 dBm)
Band 2:
Capabilities: 0x1972
HT20/HT40
Static SM Power Save
RX Greenfield
RX HT20 SGI
RX HT40 SGI
RX STBC 1-stream
Max AMSDU length: 7935 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 16 usec (0x07)
HT Max RX data rate: 150 Mbps
HT TX/RX MCS rate indexes supported: 0-7
VHT Capabilities (0x03c03122):
Max MPDU length: 11454
Supported Channel Width: neither 160 nor 80+80
short GI (80 MHz)
SU Beamformee
+HTC-VHT
VHT RX MCS set:
1 streams: MCS 0-9
2 streams: not supported
3 streams: not supported
4 streams: not supported
5 streams: not supported
6 streams: not supported
7 streams: not supported
8 streams: not supported
VHT RX highest supported: 434 Mbps
VHT TX MCS set:
1 streams: MCS 0-9
2 streams: not supported
3 streams: not supported
4 streams: not supported
5 streams: not supported
6 streams: not supported
7 streams: not supported
8 streams: not supported
VHT TX highest supported: 434 Mbps
Bitrates (non-HT):
* 6.0 Mbps
* 9.0 Mbps
* 12.0 Mbps
* 18.0 Mbps
* 24.0 Mbps
* 36.0 Mbps
* 48.0 Mbps
* 54.0 Mbps
Frequencies:
* 5180 MHz [36] (23.0 dBm)
* 5200 MHz [40] (23.0 dBm)
* 5220 MHz [44] (23.0 dBm)
* 5240 MHz [48] (23.0 dBm)
* 5260 MHz [52] (23.0 dBm) (radar detection)
* 5280 MHz [56] (23.0 dBm) (radar detection)
* 5300 MHz [60] (23.0 dBm) (radar detection)
* 5320 MHz [64] (23.0 dBm) (radar detection)
* 5500 MHz [100] (23.0 dBm) (radar detection)
* 5520 MHz [104] (23.0 dBm) (radar detection)
* 5540 MHz [108] (23.0 dBm) (radar detection)
* 5560 MHz [112] (23.0 dBm) (radar detection)
* 5580 MHz [116] (23.0 dBm) (radar detection)
* 5600 MHz [120] (23.0 dBm) (radar detection)
* 5620 MHz [124] (23.0 dBm) (radar detection)
* 5640 MHz [128] (23.0 dBm) (radar detection)
* 5660 MHz [132] (23.0 dBm) (radar detection)
* 5680 MHz [136] (23.0 dBm) (radar detection)
* 5700 MHz [140] (23.0 dBm) (radar detection)
* 5720 MHz [144] (23.0 dBm) (radar detection)
* 5745 MHz [149] (30.0 dBm)
* 5765 MHz [153] (30.0 dBm)
* 5785 MHz [157] (30.0 dBm)
* 5805 MHz [161] (30.0 dBm)
* 5825 MHz [165] (30.0 dBm)
* 5845 MHz [169] (30.0 dBm)
* 5865 MHz [173] (30.0 dBm)
* 5885 MHz [177] (30.0 dBm)
Supported commands:
* new_interface
* set_interface
* new_key
* start_ap
* new_station
* set_bss
* join_ibss
* set_pmksa
* del_pmksa
* flush_pmksa
* remain_on_channel
* frame
* set_channel
* connect
* disconnect
Supported TX frame types:
* IBSS: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* managed: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* AP: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* AP/VLAN: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* P2P-client: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* P2P-GO: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
Supported RX frame types:
* IBSS: 0xd0
* managed: 0x40 0xb0 0xd0
* AP: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
* AP/VLAN: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
* P2P-client: 0x40 0xd0
* P2P-GO: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
WoWLAN support:
* wake up on anything (device continues operating normally)
software interface modes (can always be added):
* monitor
interface combinations are not supported
Device supports SAE with AUTHENTICATE command
Device supports scan flush.
Supported extended features:
michael@debian:~/3TB-DISK$
michael@debian:~/3TB-DISK$ iw wlan0 info
Interface wlan0
ifindex 13
wdev 0x300000001
addr e8:4e:06:5b:fa:98
type managed
wiphy 3
txpower 20.00 dBm
  • 把源码加入到dkms里,更新kernel时动态编译。
1
2
3
4
5
6
7
~ rtl8812au$ git branch
git branch
* v5.6.4.2
~ rtl8812au$ cp -R `pwd` /usr/src/rtl8812au-5.6.4
~ rtl8812au$ sudo dkms add -m rtl8812au -v 5.6.4
~ rtl8812au$ sudo dkms install -m rtl8812au -v 5.6.4

使用wpa_supplicant

  • wpa_supplicant is a WPA Supplicant for Linux, BSD, Mac OS X, and Windows with support for WPA and WPA2 (IEEE 802.11i / RSN).
  • wpa_supplicant是一个提供WPA认证的客户端,它除了可以做为网卡端提供认证外,还可以在AP模式提供认证.

AP模式

1
2
3
4
5
6
7
8
9
10
~$ cat /etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid="RPi3B"
mode=2 # AP 模式.需要网卡支持.
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="12345678"
}
  • 创建如上面的配置文件,就可以使用命令运行它成为一AP点.认证连接后,需要为客户端分配IP,具体可以在本机上安装一个udhcpd.也可以客户端手动设置IP与这边的AP端是在同一个网络里.
1
2
3
4
5
6
7
8
9
10
~$ sudo wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf
# 如果加 -B 就是运行在后台模式.
Successfully initialized wpa_supplicant
# 这个错误是内核里没有选择`RF switch subsystem support`编译
rfkill: Cannot open RFKILL control device
Using interface wlan0 with hwaddr e8:xx:06:xx:xx:98 and ssid "RPi3B"
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED
wlan0: CTRL-EVENT-CONNECTED - Connection to e8:xx:06:xx:xx:98 completed [id=0 id_str=]

  • 也可把它集成到/etc/network/interfaces里,网卡开启之后自动成为一个AP点.
1
2
3
4
5
6
7
8
9
10
~$ cat /etc/network/interfaces
auto wlan0
iface wlan0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
gateway 192.168.1.1
pre-up wpa_supplicant -B -Dnl80211 -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf
post-down killall -q wpa_supplicant
wait-delay 15

RTL8169 驱动

  • No Ethernet Connection in Ubuntu 16.04/Linux Mint 18 with Realtek RTL8111/8168/8411

  • r8168 module not used by ethernet controller

  • https://github.com/fintecheando/r8168

    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
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    #  查看本机硬件信息.
    ~$ lshw -c network
    *-network UNCLAIMED
    description: Ethernet interface
    product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
    vendor: Realtek Semiconductor Co., Ltd.
    physical id: 0
    bus info: pci@0000:02:00.0
    [....]


    ~$ tree r8168-8.043.02/
    r8168-8.043.02/
    ├── dkms.conf
    ├── Makefile
    ├── r8168_asf.c
    ├── r8168_asf.h
    ├── r8168_dash.h
    ├── r8168_fiber.h
    ├── r8168.h
    ├── r8168_n.c
    ├── r8168_realwow.h
    ├── rtl_eeprom.c
    ├── rtl_eeprom.h
    ├── rtltool.c
    └── rtltool.h

    0 directories, 13 files

    # 查看系统已经添加了那些dkms包.
    ~$ cd /usr/src/
    lcy@debian:/usr/src$ dkms status
    aufs, 4.9+20161219, 4.9.0-7-amd64, x86_64: installed
    aufs, 4.9+20161219, 4.9.0-8-amd64, x86_64: installed
    nvidia, 410.48, 4.14.77-20181016-lcy-amd64, x86_64: installed
    r8168, 8.043.02, 4.9.0-8-amd64, x86_64: installed
    rtl8812au, 4.3.8.12175.20140902+dfsg, 4.14.77-20181016-lcy-amd64, x86_64: installed
    rtl8812au, 4.3.8.12175.20140902+dfsg, 4.9.0-8-amd64, x86_64: installed

    # 如果没有看到添加进来,先把源码目录复制到/usr/src/r8168-8.043.02,再用下面命令加入dkms.
    ~$ sudo dkms add -m r8168 -v 8.043.02

    # 使用dkms编译驱动包.
    ~$ sudo dkms build -m r8168 -v 8.043.02

    Kernel preparation unnecessary for this kernel. Skipping...

    Building module:
    cleaning build area...
    make -j6 KERNELRELEASE=4.14.77-20181016-lcy-amd64 -C /lib/modules/4.14.77-20181016-lcy-amd64/build M=/var/lib/dkms/r8168/8.043.02/build...(bad exit status: 2)
    Error! Bad return status for module build on kernel: 4.14.77-20181016-lcy-amd64 (x86_64)
    Consult /var/lib/dkms/r8168/8.043.02/build/make.log for more information.

    # 查看dkms编译为什么出错.
    ~$ cat /var/lib/dkms/r8168/8.043.02/build/make.log
    DKMS make.log for r8168-8.043.02 for kernel 4.14.77-20181016-lcy-amd64 (x86_64)
    Sat Dec 29 16:31:32 CST 2018
    make: Entering directory '/usr/src/linux-4.14.77'
    AR /var/lib/dkms/r8168/8.043.02/build/built-in.o
    CC [M] /var/lib/dkms/r8168/8.043.02/build/r8168_n.o
    CC [M] /var/lib/dkms/r8168/8.043.02/build/r8168_asf.o
    CC [M] /var/lib/dkms/r8168/8.043.02/build/rtl_eeprom.o
    CC [M] /var/lib/dkms/r8168/8.043.02/build/rtltool.o
    /var/lib/dkms/r8168/8.043.02/build/r8168_n.c: In function ‘rtl8168_rx_interrupt’:
    /var/lib/dkms/r8168/8.043.02/build/r8168_n.c:25418:28: error: ‘struct net_device’ has no member named ‘last_rx’
    dev->last_rx = jiffies;
    ^~
    scripts/Makefile.build:328: recipe for target '/var/lib/dkms/r8168/8.043.02/build/r8168_n.o' failed
    make[1]: *** [/var/lib/dkms/r8168/8.043.02/build/r8168_n.o] Error 1
    Makefile:1527: recipe for target '_module_/var/lib/dkms/r8168/8.043.02/build' failed
    make: *** [_module_/var/lib/dkms/r8168/8.043.02/build] Error 2
    make: Leaving directory '/usr/src/linux-4.14.77'
  • 删除原有的系统包

1
2
~$ sudo apt-get purge r8168-dkms
~$ sudo sh -c ‘echo blacklist r8169 >> /etc/modprobe.d/blacklist.conf’
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

~$ git clone https://github.com/fintecheando/r8168
~$ cd r8168
~$ sudo ./autorun.sh
# 查看内核参数
~$ lsmod | grep r8168
r8168 520192 0

# 查看网卡参数
~$ ethtool -i eth0
driver: r8168
version: 8.045.08-NAPI
firmware-version:
expansion-rom-version:
bus-info: 0000:02:00.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: yes
supports-priv-flags: no
1
2
3
4
5
~$ dmesg
[ 4.927167] iwlwifi 0000:02:00.0 wlp2s0: renamed from wlan0

~$ sudo ln -nfs /dev/null /etc/systemd/network/99-default.link
~$ sudo udevadm trigger

使用hostapd配置WIFI热点

查看网卡配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
~$ iw list | grep "Supported interface modes" -A 8
Supported interface modes:
* IBSS
* managed
* AP
* monitor
* P2P-client
* P2P-GO
Band 1:
Capabilities: 0x1862
~$ iw reg get
global
country 00: DFS-UNSET
(2402 - 2472 @ 40), (N/A, 20), (N/A)
(2457 - 2482 @ 20), (N/A, 20), (N/A), AUTO-BW, NO-IR
(2474 - 2494 @ 20), (N/A, 20), (N/A), NO-OFDM, NO-IR
(5170 - 5250 @ 80), (N/A, 20), (N/A), AUTO-BW, NO-IR
(5250 - 5330 @ 80), (N/A, 20), (0 ms), DFS, AUTO-BW, NO-IR
(5490 - 5730 @ 160), (N/A, 20), (0 ms), DFS, NO-IR
(5735 - 5835 @ 80), (N/A, 20), (N/A), NO-IR
(57240 - 63720 @ 2160), (N/A, 0), (N/A)

安装

1
2
3
~$ sudo apt-get install hostapd
~$ cp /usr/share/doc/hostapd/examples/hostapd.config.gz /etc/hostapd/
~$ gzip -d /etc/hostapd/hostapd.conf

调试配置文件错误

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 配置文件错误
~$ hostapd /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
Cannot enable IEEE 802.11d without setting the country_code
2 errors found in configuration file '/etc/hostapd/hostapd.conf'
Failed to set up interface with /etc/hostapd/hostapd.conf
Failed to initialize interface

# 缺少rfkill模块支持.
~$ sudo hostapd -dd /etc/hostapd/hostapd.conf
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
ctrl_interface_group=0
rfkill: Cannot open RFKILL control device
nl80211: RFKILL status not available

# 测试wpa_support
~$ sudo cp /usr/share/doc/wpasupplicant/examples/wpa_supplicant.conf.gz /etc/wpa_supplicant/
~$ wpa_supplicant -B -i wlan0 -D wext -c /etc/wpa_supplicant/wpa_supplicant.conf

配置实例

  • Hostapd
  • 下面的配置有一些网卡是不支持的,出错需注释相关行.
    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
    26
    27
    28
    29
    ~$ sudo grep -v '^#' hostapd.conf | grep -v '^$'
    interface=wlan0
    driver=nl80211
    logger_syslog=1
    logger_syslog_level=0
    logger_stdout=1
    logger_stdout_level=2
    ctrl_interface=/var/run/hostapd
    ctrl_interface_group=0
    ssid=lcy_home
    country_code=CN
    ieee80211d=1
    hw_mode=g
    channel=4
    auth_algs=3
    ignore_broadcast_ssid=0
    uapsd_advertisement_enabled=1
    ieee80211n=1
    ieee80211ac=1
    eap_server=0
    own_ip_addr=127.0.0.1
    wpa=2
    wpa_psk_file=/etc/hostapd.wpa_psk
    wpa_key_mgmt=WPA-PSK
    wpa_pairwise=TKIP
    rsn_pairwise=CCMP
    wpa_group_rekey=600
    wpa_gmk_rekey=86400

配置主机路由

1
2
root# echo "net.ipv4.ip_forward=1" > /etc/sysconf.ctl  # 这一行很重要.
root# iptables -t nat -I POSTROUTING -j MASQUERADE # 配置主机的NAT路由.确定是在第一条规则.

Linux 下是使用蓝牙串口通信

  • 如果是自编译内核要确保RFCOMM protocol support (BT_RFCOMM)是编译成模块的,而不能直接编入内核或者不编.
  • Linux下使用蓝牙工具要安装bluez软件,有一个图形配置程序blueman,使用会报一些PythonDbus的错误,还是直接修改配置文件解决使用问题.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    ~$ cat /etc/bluetooth/rfcomm.conf
    rfcomm0 {
    bind yes;
    device 00:15:83:00:43:AB
    channel 0;
    comment "Serial Port";
    }


    rfcomm1 {
    bind yes;
    device 00:14:01:22:14:49;
    channel 1;
    connment "Serial Port 1";
    }

配对蓝牙

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ bluetoothctl
[NEW] Controller 00:02:5B:0A:59:3A debian-0 [default]
[NEW] Device 00:14:01:22:14:49 lcy
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# agent on
Agent registered
[bluetooth]# pair 00:14:01:22:14:49
Attempting to pair with 00:14:01:22:14:49
[CHG] Device 00:14:01:22:14:49 Connected: yes
Request PIN code
[agent] Enter PIN code: 1234
[CHG] Device 00:14:01:22:14:49 Paired: yes
Pairing successful
[CHG] Device 00:14:01:22:14:49 Connected: no

手动连接RFCOMM串口

1
2
3
 sudo rfcomm connect /dev/rfcomm0 00:14:01:22:14:49 1
Connected /dev/rfcomm0 to 00:14:01:22:14:49 on channel 1
Press CTRL-C for hangup
  • 运行上面的命令无错,就可以使用 minicom 连接它了,sudo minicom -o -b 115200 -D /dev/rfcomm0
  • 如果运行图形配置向导,要先运行blueman-applet再运行blueman-manager,就可以配置了.

蓝牙错误

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
$ systemctl status bluetooth
● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
Active: failed (Result: signal) since Wed 2018-06-20 14:54:03 CST; 5min ago
Docs: man:bluetoothd(8)
Main PID: 772 (code=killed, signal=KILL)
Status: "Running"
michael@debian:/etc/init.d$ sudo systemctl status bluetooth
● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
Active: failed (Result: signal) since Wed 2018-06-20 14:54:03 CST; 5min ago
Docs: man:bluetoothd(8)
Main PID: 772 (code=killed, signal=KILL)
Status: "Running"

Jun 20 14:41:29 debian bluetoothd[772]: Failed to obtain handles for "Service Changed" characteristic
Jun 20 14:41:29 debian bluetoothd[772]: Sap driver initialization failed.
Jun 20 14:41:29 debian bluetoothd[772]: sap-server: Operation not permitted (1)
Jun 20 14:41:29 debian bluetoothd[772]: Endpoint registered: sender=:1.67 path=/MediaEndpoint/A2DPSource
Jun 20 14:41:29 debian bluetoothd[772]: Endpoint registered: sender=:1.67 path=/MediaEndpoint/A2DPSink
Jun 20 14:42:00 debian bluetoothd[772]: vendor 0x0 product: 0x0
Jun 20 14:43:36 debian bluetoothd[772]: vendor 0x0 product: 0x0
Jun 20 14:54:03 debian systemd[1]: bluetooth.service: Main process exited, code=killed, status=9/KILL
Jun 20 14:54:03 debian systemd[1]: bluetooth.service: Unit entered failed state.
Jun 20 14:54:03 debian systemd[1]: bluetooth.service: Failed with result 'signal'.

无法连接蓝牙音响

1
2
3
4
sudo apt install pulseaudio-module-bluetooth
pulseaudio -k
pulseaudio --start
sudo pactl load-module module-bluetooth-discover

Linux Systemctl启动服务超时设置

  • 下面用一个网络连接服务为示例,如果网络配置是 DHCP,刚好网络没有提供 DHCP 服务,这时该服务程序会重试(默认)两分钟才会报错,这里可以设置成5到10 秒,快速跳过该服务启动.
  • 在文件/lib/systemd/system/networking.service.d/network-pre.conf里添加下面两行:
1
2
[Service]
TimeoutStartSec=15
  • 可以使用下面的方式来定位整个启动时的用时。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
~$ systemd-analyze critical-chain
The time when unit became active or started is printed after the "@" character.
The time the unit took to start is printed after the "+" character.

graphical.target @1min 33.969s
└─multi-user.target @1min 33.969s
└─getty.target @1min 33.969s
└─getty@tty1.service @1min 33.968s
└─rc-local.service @1min 32.592s +1.374s
└─network-online.target @1min 32.549s
└─network.target @1min 32.549s
└─networking.service @2.374s +898ms
└─systemd-sysctl.service @2.355s +4ms
└─systemd-modules-load.service @246ms +2.089s
└─systemd-journald.socket @227ms
└─-.mount @179ms
└─-.slice @179ms

  • 如上所示,需要查一下/etc/network/interfaces里的配置,rc-local里的配置,是什么原因导致在这里启动耗时。

安装 IBus 输入法框架

  • IBus("Intelligent Input Bus")是一个输入法框架,一个输入非英语字符的系统.IBus的功能与SCIMUIM类似.在Debian下面有一个问题,如果不安装ibus-gtk3,ibus-gtk就会出现wxWidgets框架下的文本输入框无法使用Back Space,Arrown keys这些按键.安装指导
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
~$ dpkg -l | grep "ibus"
ii gir1.2-ibus-1.0:amd64 1.5.14-3 amd64 Intelligent Input Bus - introspection data
ii ibus 1.5.14-3 amd64 Intelligent Input Bus - core
ii ibus-gtk:amd64 1.5.14-3 amd64 Intelligent Input Bus - GTK+2 support
ii ibus-gtk3:amd64 1.5.14-3 amd64 Intelligent Input Bus - GTK+3 support
ii ibus-qt4 1.3.3-1 amd64 qt-immodule for ibus (QT4) (plugin)
ii ibus-table 1.9.14-3 all table engine for IBus
ii ibus-table-wubi 1.8.2-2 all ibus-table input method: Wubi
ii libgusb-dev 0.2.9-1+b1 amd64 GLib wrapper around libusb1 - development files
ii libgusb2:amd64 0.2.9-1+b1 amd64 GLib wrapper around libusb1
ii libhidapi-libusb0:amd64 0.8.0~rc1+git20140818.d17db57+dfsg-1 amd64 Multi-Platform library for communication with HID devices (libusb backend)
ii libibus-1.0-5:amd64 1.5.14-3 amd64 Intelligent Input Bus - shared library
ii libibus-1.0-dev:amd64 1.5.14-3 amd64 Intelligent Input Bus - development file
ii libibus-qt1 1.3.3-1 amd64 qt-immodule for ibus (QT4) (library)

~$ cat ~/.xinitrc
export GTK_IM_MODULE=ibus
export QT_IM_MODULE=ibus
export XMODIFIERS="@im=ibus"
  • 如果要配置locales,方法如下:
    1
    2
    3
    ~$ sudo apt-get install locales
    ~$ sudo dpkg-reconfigure locales
    ~$ sudo locale-gen

BOSSAC 烧写 Arduino-DUE 无法找到设备

1
2
3
4
5
6
./bossac -i -d --port=ttyACM0 -U false -e -w -v -b ./nuttx.bin -R

Set binary mode
Send auto-baud
Set binary mode
No device found on /dev/ttyACM0

处理方法

1
stty -F /dev/ttyACM0 speed 1200 cs8 -cstopb -parenb

Virt-Manager 虚拟机无法启动

  • 有时KVM框架虚拟机系统无法启动,错误如下:

    1
    2
    3
    4
    Error starting domain: Requested operation is not valid: network 'default' is not active

    Traceback (most recent call last):
    [...]
  • 通过如下命令启动网络即可.

1
2
3
4
5
6
7
~$ sudo virsh net-list --all
Name State Autostart Persistent
----------------------------------------------------------
default inactive no yes

~$ sudo virsh net-start default
Network default started

Virt-Manager 使用 OpenvSwitch 交换机

  • 使用 OpenvSwitch 的网络服务启动会有延迟一分钟左右.

安装 OpenvSwitch

1
2
3
~$ dpkg -l | grep "openvswitch"
ii openvswitch-common 2.6.2~pre+git20161223-3 amd64 Open vSwitch common components
ii openvswitch-switch 2.6.2~pre+git20161223-3 amd64 Open vSwitch switch implementations

创建桥接端口

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
~$ sudo ovs-vsctl add-br ovsbr0
~$ sudo ovs-vsctl add-port ovsbr0 eth0
~$ sudo ovs-vsctl show
dbeec575-be91-48b6-bffa-0894b0fa24dd
Bridge "ovsbr0"
Port "ovsbr0"
Interface "ovsbr0"
type: internal
Port "vnet0"
Interface "vnet0"
Port "eth0"
Interface "eth0"
ovs_version: "2.6.2"

~$ sudo ip addr del 192.168.1.100 dev eth0
~$ sudo ip addr add 192.168.1.100 dev ovsbr0

修改网卡启动配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
~$ cat /etc/network/interfaces
[...]

auto eth0
iface eth0 inet manual
up ip link set dev $IFACE up
down ip link set dev $IFACE down


auto ovsbr0
iface ovsbr0 inet static
up ip link set dev $IFACE up
down ip link set dev $IFACE down
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1

[...]

创建 Virt-Manager 桥接网络

  • Network_bridge
    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
    26
    27
    28
    29
    ~$ sudo cp /etc/libvirt/qemu/networks/{default.xml,ovsbr0.xml}

    # 把内容修改成如下所示
    ~$ cat /etc/libvirt/qemu/networks/ovsbr0.xml
    <!--
    WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
    OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
    virsh net-edit ovsbr0
    or other application using the libvirt API.
    -->

    <network>
    <name>ovsbr0</name>
    <uuid>fc0b3bb1-c273-49dc-b469-153dc4c452e2</uuid>
    <forward mode='bridge'/>
    <bridge name='ovsbr0'/>
    <virtualport type='openvswitch'/>
    </network>

    ~$ sudo virsh net-define /etc/libvirt/qemu/networks/ovsbr0.xml
    ~$ sudo virsh net-create /etc/libvirt/qemu/networks/ovsbr0.xml

    ~$ sudo virsh net-list --all
    Name State Autostart Persistent
    ----------------------------------------------------------
    default active yes yes
    ovsbr0 inactive no yes

    ~$ sudo virsh net-autostart ovsbr0

设置虚拟机的网络

  • 现在 KVM 虚拟机就有default,ovsbr0两个网络,添加一个连接到OpenvSwitch上的网卡如下图所示:
    ovsbr0

创建Debian Live USB系统盘

  • 如果想要试用Linux,又不想安装它,可以把它烧写到U盘里,做为启动盘或者系统恢复盘.
  • Debian 国内镜像下载链接
  • 注意: 这里一定要选择live标志的 iso 镜像下载.在 windows 下面要先下载一个叫Win32DiskImager的烧写工具,Linux 就很简单使用下面命令就能完成:
1
2
3
4
5
6
$ ls  debian-live-9.4.0-amd64-mate.iso
debian-live-9.4.0-amd64-mate.iso
$ sudo dd if=debian-live-9.4.0-amd64-mate.iso of=/dev/sdc1
4002944+0 records in
4002944+0 records out
2049507328 bytes (2.0 GB, 1.9 GiB) copied, 7.39192 s, 277 MB/s
  • 严重注意 这里的/dev/sdc1一要是你想要格式华的U盘,如果这里是当前硬盘,或者是有重要资料的盘符,就会直接覆盖它,找不回来.注意,注意,注意

开启Debian Hibernate功能

  • 有时工作进行到一个阶段,不想系统重启之后,再费时间来打开与配置环境.开启系统休眠功能非常有用.先要确保有一个swap分区,最好是两倍与系统内存的大小.

    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
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    ~$ sudo apt-get install acpi-support pm-utils
    ~$ sudo mkswap /dev/sdb1
    ~$ sudo swapon /dev/sdb1
    # 确保下面这两个文件里有这些行.
    ~$ sudo cat /etc/fstab | grep "swap"
    /dev/sdb1 none swap pri=1 0 0

    # 如果是在本机为其它机器编译内核与initramfs的,需要把resume=删除后,再make install,否则到目标机器上会panic.
    ~$ blkid
    [...]
    /dev/sdb3: UUID="ae170b9d-832a-46a7-beca-5fb7c9329b1b" TYPE="swap" PARTUUID="6daebe63-03"
    ~$ sudo cat /etc/default/grub | grep "resume"
    GRUB_CMDLINE_LINUX="resume=UUID=ae170b9d-832a-46a7-beca-5fb7c9329b1b"

    ~$cat /etc/initramfs-tools/conf.d/resume
    RESUME=UUID=ae170b9d-832a-46a7-beca-5fb7c9329b1b


    #这一操作很重要.
    ~$ update-initramfs -u -k `uname -r` ## 更新当前内核的启动镜像.
    ~$ sudo update-grub

    ~$ cat /proc/acpi/wakeup
    Device S-state Status Sysfs node
    PB31 S4 *disabled pci:0000:00:03.1
    PB32 S4 *disabled
    PB33 S4 *disabled pci:0000:00:03.3
    PB34 S4 *disabled
    SBAZ S4 *disabled pci:0000:00:14.2
    PS2K S3 *disabled
    PS2M S3 *disabled
    ECIR S4 *disabled
    P0PC S4 *disabled pci:0000:00:14.4
    OHC1 S4 *disabled pci:0000:00:12.0
    EHC1 S4 *disabled pci:0000:00:12.2
    OHC2 S4 *disabled pci:0000:00:13.0
    EHC2 S4 *disabled pci:0000:00:13.2
    OHC3 S4 *disabled
    EHC3 S4 *disabled
    OHC4 S4 *disabled pci:0000:00:14.5
    XHC0 S4 *disabled pci:0000:00:10.0
    XHC1 S4 *disabled pci:0000:00:10.1
    PE20 S4 *disabled
    PE21 S4 *disabled
    PE22 S4 *disabled
    PE23 S4 *disabled
    PWRB S3 *enabled platform:PNP0C0C:00

    # 上面是一些如何唤醒休眠的设备, 休眠中是可以通过移动鼠标或者键盘来唤醒,但是我这里把它们都关闭,让它只能通过电源按钮(PWRB)唤醒系统.

    ~$ grep "echo" /etc/rc.local
    [...]
    for i in OHC1 EHC1 OHC2 EHC2 OHC4 XHC0 XHC1;
    do
    cat /proc/acpi/wakeup | grep "$i" | grep "enabled" && echo "$i" > /proc/acpi/wakeup
    done
    [...]
  • 测试休眠功能echo disk > /sys/power/state,或者运行pm-hibernate进行休眠, 还有systemctl hibernate进行休眠.

  • 通过上面设置,系统休眠与唤醒都很符合我的预期.还有一种方法是使用一个交换文件,不需要一个独立的分区,请参考这里

  • 如果上述设置能休眠不能关机,就是休眠后马上又重启了,参照这里需要如下设置:

1
2
3
4
/etc/systemd/sleep.conf.d/hibernatemode.conf

[Sleep]
HibernateMode=shutdown
  • 如果不能使用界的System->Shut Down->Hibernate的进行休眠,但是可以直接使用sudo pm-hibernate.需要重装下面的包试试.

    1
    ~$ apt-get install --reinstall pm-utils mate-power-manager-common hibernate upower
  • 如果休眠后恢复系统不能使用usb wifi(rtl8812au) 网卡.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    ~$ sudo  lshw -C network | grep "wlan" -A +3 | grep "driver"
    configuration: broadcast=yes driver=rtl8812au ip=192.168.5.190 multicast=yes wireless=IEEE 802.11
    # 创建如下文件
    ~$ sudo cat /etc/pm/config.d/unload_modules
    SUSPEND_MODULES="$SUSPEND_MODULES rtl8812au"
    # 创建成功,要加上运行权限.
    ~$ sudo cat /etc/pm/sleep.d/10_resume_wifi
    #!/bin/sh

    case "${1}" in
    resume|thaw)
    nmcli r wifi off && nmcli r wifi on;
    esac

程序找不到链接库位置

  • Python ImportError,这种错误是因为在PYTHONPATH路径中找不相就的模块.

    1
    2
    3
    4
    5
    6
    7
    ~$ ./modes_rx
    Traceback (most recent call last):
    File "./modes_rx", line 27, in <module>
    import air_modes
    ImportError: No module named air_modes

    ~$ PYTHONPATH=../lib/python2.7/dist-packages ./modes_rx #指定的环境变量对了就可以了.
  • 本地库链接错误

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    ~$ ldd /usr/local/bin/rtl_tcp
    linux-vdso.so.1 (0x00007fff3d3eb000)
    librtlsdr.so.0 => not found  # 默认位置/lib/x86_64-linux-gnu找不该库.
    libusb-1.0.so.0 => /lib/x86_64-linux-gnu/libusb-1.0.so.0 (0x00007f3d0b328000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f3d0b108000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3d0ad68000)
    libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007f3d0b6d8000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f3d0b548000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f3d0ab60000)

    ~$ ls /usr/local/lib/librtlsdr.so.0  # 这个位置有这个库
    /usr/local/lib/librtlsdr.so.0
  • 上面的错误有两种方法可以解决:

    • /usr/local/lib加入到/etc/ld.so.conf里,再执行一次ldconfig就可以链接这个库了.
    • 使用LD_LIBRARY_PATH环境变量指位置,这样运行:
      1
      2
      3
      4
      5
      6
      7
      8
      ~$ LD_LIBRARY_PATH=/usr/local/lib  rtl_tcp
      Found 1 device(s).
      Found Rafael Micro R820T tuner
      Using ezcap USB 2.0 DVB-T/DAB/FM dongle
      Tuned to 100000000 Hz.
      listening...
      Use the device argument 'rtl_tcp=127.0.0.1:1234' in OsmoSDR (gr-osmosdr) source
      to receive samples in GRC and control rtl_tcp parameters (frequency, gain, ...).

在内核树里编译单个模块

  • 比如,上面缺少一个rfkill的模块,现在可以在不重编整个内核的前提下,可以单独编译这个内核.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    ~$ cd /lib/modules/$(uname -r)/build/net/rfkill
    ~$ sudo make -C /lib/modules/$(uname -r)/build M=`pwd` modules # 要先在.config 把这一个模块选中为`编译`状态.
    make: Entering directory '/usr/src/linux-4.14.77'
    CC [M] /lib/modules/4.14.77-20181016-lcy-amd64/build/net/rfkill/core.o
    LD [M] /lib/modules/4.14.77-20181016-lcy-amd64/build/net/rfkill/rfkill.o
    Building modules, stage 2.
    MODPOST 1 modules
    CC /lib/modules/4.14.77-20181016-lcy-amd64/build/net/rfkill/rfkill.mod.o
    LD [M] /lib/modules/4.14.77-20181016-lcy-amd64/build/net/rfkill/rfkill.ko
    make: Leaving directory '/usr/src/linux-4.14.77'
    ~$ sudo mkdir /lib/modules/$(uname -r)/kernel/net/rfkill
    ~$ sudo cp rfkill.ko /lib/modules/$(uname -r)/kernel/net/rfkill/
    ~$ sudo depmod -a # 计算依赖关系
    ~$ modprobe -v rfkill # 加载模块.
  • 如果每次重启,某一个网块或蓝牙都是Soft Blocked的话,尝试一下用命令nmcli r wifi on.

编译carl9170出错问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
michael@debian:/usr/src/linux-5.5.11/drivers/net/wireless/ath/carl9170$ sudo make -C /lib/modules/$(uname -r)/build  M=`pwd`  modules
make: Entering directory '/usr/src/linux-5.5.11'
[....]
Building modules, stage 2.
MODPOST 1 modules
ERROR: "ath_regd_init" [/usr/src/linux-5.5.11/drivers/net/wireless/ath/carl9170/carl9170.ko] undefined!
ERROR: "__ieee80211_get_assoc_led_name" [/usr/src/linux-5.5.11/drivers/net/wireless/ath/carl9170/carl9170.ko] undefined!
ERROR: "led_classdev_register_ext" [/usr/src/linux-5.5.11/drivers/net/wireless/ath/carl9170/carl9170.ko] undefined!
ERROR: "ath_is_mybeacon" [/usr/src/linux-5.5.11/drivers/net/wireless/ath/carl9170/carl9170.ko] undefined!
ERROR: "ath_is_world_regd" [/usr/src/linux-5.5.11/drivers/net/wireless/ath/carl9170/carl9170.ko] undefined!
ERROR: "ath_reg_notifier_apply" [/usr/src/linux-5.5.11/drivers/net/wireless/ath/carl9170/carl9170.ko] undefined!
ERROR: "ath_regd_get_band_ctl" [/usr/src/linux-5.5.11/drivers/net/wireless/ath/carl9170/carl9170.ko] undefined!
ERROR: "__ieee80211_get_tx_led_name" [/usr/src/linux-5.5.11/drivers/net/wireless/ath/carl9170/carl9170.ko] undefined!
ERROR: "led_classdev_unregister" [/usr/src/linux-5.5.11/drivers/net/wireless/ath/carl9170/carl9170.ko] undefined!
make[1]: *** [scripts/Makefile.modpost:94: __modpost] Error 1
make: *** [Makefile:1607: modules] Error 2
make: Leaving directory '/usr/src/linux-5.5.11'
  • 像上面错误,后续不能在内核树编译驱动模块,因为选中该驱动中的子选项SoftLED Support(ONFIG_CARL9170_LEDS)是不支持单独编译成.ko或者包含在这个.ko里,它必须编译进内核.所以碰到这种问题,只能重新编译整个内核.

创建大于 2TB 的分区

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
~$parted /dev/sda
WARNING: You are not superuser. Watch out for permissions.
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: ATA ST2000DM008-2FR1 (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
(parted) mklabel gpt
(parted) print
Model: ATA ST2000DM008-2FR1 (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags

(parted) mkpart primary 0GB 2000GB

(parted) print
Model: ATA ST2000DM008-2FR1 (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 1049kB 2000GB 2000GB primary
(parted) quit
~$ sudo fdisk -l /dev/sda
Disk /dev/sda: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 224F4012-9C49-4331-87F5-77B5CF6C28F5

Device Start End Sectors Size Type
/dev/sda1 2048 3907028991 3907026944 1.8T Linux filesystem


~$ sudo mkfs.ext4 /dev/sda1
mke2fs 1.43.4 (31-Jan-2017)
/dev/sda1 contains a ext3 file system
created on Thu Aug 30 09:33:27 2018
Proceed anyway? (y,N) y

~$ sudo blkid
/dev/sda1: UUID="3d6c0885-cacf-41f8-911d-cdf4bd666a49" TYPE="ext4" PARTLABEL="primary" PARTUUID="daeb01c4-ceb5-4227-80d8-d70bfc266317"
~$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
UUID=3d6c0885-cacf-41f8-911d-cdf4bd666a49 /data ext4 defaults 0 2

Linux 下修复(屏蔽)磁盘坏块

SmartCtl

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
~$ sudo  smartctl -H /dev/sdaX
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

~$ ~$ sudo smartctl -a /dev/sda | grep '^ID#' -A 27
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000f 077 049 006 Pre-fail Always - 55337314
3 Spin_Up_Time 0x0003 098 096 000 Pre-fail Always - 0
4 Start_Stop_Count 0x0032 099 099 020 Old_age Always - 1081
5 Reallocated_Sector_Ct 0x0033 100 100 010 Pre-fail Always - 0
7 Seek_Error_Rate 0x000f 084 060 045 Pre-fail Always - 248843209
9 Power_On_Hours 0x0032 092 092 000 Old_age Always - 7744 (71 178 0)
10 Spin_Retry_Count 0x0013 100 100 097 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 099 099 020 Old_age Always - 1081
183 Runtime_Bad_Block 0x0032 100 100 000 Old_age Always - 0
184 End-to-End_Error 0x0032 100 100 099 Old_age Always - 0
187 Reported_Uncorrect 0x0032 084 084 000 Old_age Always - 16
188 Command_Timeout 0x0032 099 099 000 Old_age Always - 5 5 14
189 High_Fly_Writes 0x003a 100 100 000 Old_age Always - 0
190 Airflow_Temperature_Cel 0x0022 062 053 040 Old_age Always - 38 (Min/Max 30/39)
191 G-Sense_Error_Rate 0x0032 100 100 000 Old_age Always - 0
192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always - 75
193 Load_Cycle_Count 0x0032 099 099 000 Old_age Always - 3229
194 Temperature_Celsius 0x0022 038 047 000 Old_age Always - 38 (0 13 0 0 0)
195 Hardware_ECC_Recovered 0x001a 077 064 000 Old_age Always - 55337314
197 Current_Pending_Sector 0x0012 100 100 000 Old_age Always - 8
198 Offline_Uncorrectable 0x0010 100 100 000 Old_age Offline - 8
199 UDMA_CRC_Error_Count 0x003e 200 200 000 Old_age Always - 0
240 Head_Flying_Hours 0x0000 100 253 000 Old_age Offline - 6259h+10m+59.473s
241 Total_LBAs_Written 0x0000 100 253 000 Old_age Offline - 15449989789
242 Total_LBAs_Read 0x0000 100 253 000 Old_age Offline - 33054634173
[...]

# 我这边是希捷硬盘ST4000DM000
SMART Error Log Version: 1
ATA Error Count: 16 (device log contains only the most recent five errors)
CR = Command Register [HEX]
FR = Features Register [HEX]
SC = Sector Count Register [HEX]
SN = Sector Number Register [HEX]
CL = Cylinder Low Register [HEX]
CH = Cylinder High Register [HEX]
DH = Device/Head Register [HEX]
DC = Device Command Register [HEX]
ER = Error register [HEX]
ST = Status register [HEX]
Powered_Up_Time is measured from power on, and printed as
DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes,
SS=sec, and sss=millisec. It "wraps" after 49.710 days.

Error 16 occurred at disk power-on lifetime: 7630 hours (317 days + 22 hours)
When the command that caused the error occurred, the device was active or idle.

After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
40 51 00 ff ff ff 0f Error: UNC at LBA = 0x0fffffff = 268435455

Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
-- -- -- -- -- -- -- -- ---------------- --------------------
25 d5 08 ff ff ff 4f 00 5d+06:43:53.155 READ DMA EXT
25 d5 08 ff ff ff 4f 00 5d+06:43:53.114 READ DMA EXT
b0 d5 01 01 4f c2 00 00 5d+06:40:32.613 SMART READ LOG
b0 d5 01 06 4f c2 00 00 5d+06:40:32.545 SMART READ LOG
b0 d0 01 00 4f c2 00 00 5d+06:40:32.455 SMART READ DATA
  • 上面分析结果Current_Pending_Sector显示代表有8处坏块.

使用Short Test

1
2
3
~$ smartctl -t short /dev/sda
# 查看测试结果
~$ smartctl -l selftest /dev/sda

使用Long Test

  • 如果短测试没有发现问题,可能要使用长测试,耗时根据硬盘容量决定,ST4000DM000使用了大概480分钟.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    ~$ smartctl -t long /dev/sda
    # 查看测试结果
    ~$ smartctl -x /dev/sda
    [...]
    SMART Extended Self-test Log Version: 1 (1 sectors)
    Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
    # 1 Short offline Completed without error 00% 7757 -
    # 2 Short offline Completed without error 00% 7757 -
    # 3 Extended offline Completed without error 00% 7752 -
    # 4 Short offline Completed without error 00% 7744 -
    # 5 Short offline Completed: read failure 90% 7744 5341719016
    # 6 Short offline Completed without error 00% 7744 -
    # 7 Extended offline Completed without error 00% 3769 -
    # 8 Extended offline Completed without error 00% 3746 -
    1 of 1 failed self-tests are outdated by newer successful extended offline self-test # 3
    [...]

NVMe的固态硬盘

防止/etc/resolve.conf 被 DHCP 自动修改

1
2
3
4
5
6
7
~# cat /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile
dns=none

[ifupdown]
managed=true
  • 或者用chattr +i /etc/resolve.conf锁定修改它.

apt-get使用 Socks5代理

1
2
3
4
5
6
7
~$ sudo apt-get install proxychains

~$ cat /etc/proxychains.conf
socks5 127.0.0.1 1080

~$ sudo proxychains apt-get update
~$ sudo proxychains apt-get dist-upgrade -y

Git使用问题

  • 统计工程代码数量.
    1
    ~$ git log --since="2018-03-01" --before="2019-01-09" --author="username" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }'

脚本配置git Socks5代理

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
26
~$ cat /usr/local/bin/gitproxy
#!/bin/bash
case $1 in

on)
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
;;

off)
git config --global --unset http.proxy
git config --global --unset https.proxy
;;

status)
git config --get http.proxy
git config --get https.proxy
;;
esac
exit 0

# 打开
~$ gitproxy on

# 关闭
~$ gitproxy off

Git 错误 error: refs/remotes/origin/rpi-4.19.y does not point to a valid object!

使用Intel AX200网卡

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
~$ hwinfo --netcard --bluetooth | grep -v "Config S"
06: PCI 300.0: 0282 WLAN controller
[Created at pci.386]
Unique ID: y9sn.yLXDVFQHSM7
Parent ID: W_nd.YYC8aCLnN82
SysFS ID: /devices/pci0000:00/0000:00:03.4/0000:03:00.0
SysFS BusID: 0000:03:00.0
Hardware Class: network
Model: "Intel WLAN controller"
Vendor: pci 0x8086 "Intel Corporation"
Device: pci 0x2723
SubVendor: pci 0x8086 "Intel Corporation"
SubDevice: pci 0x008c
Revision: 0x1a
Driver: "iwlwifi"
Driver Modules: "iwlwifi"
Device File: wlan0
Features: WLAN
Memory Range: 0xfe800000-0xfe803fff (rw,non-prefetchable)
IRQ: 50 (no events)
HW Address: 34:13:e8:b7:1d:76
Permanent HW Address: 34:13:e8:b7:1d:76
Link detected: yes
WLAN channels: 1 2 3 4 5 6 7 8 9 10 11 12 13 36 40 44 48 52 56 60 64 100 104 108 112 116 120 124 128 132 136 140
WLAN frequencies: 2.412 2.417 2.422 2.427 2.432 2.437 2.442 2.447 2.452 2.457 2.462 2.467 2.472 5.18 5.2 5.22 5.24 5.26 5.28 5.3 5.32 5.5 5.52 5.54 5.56 5.58 5.6 5.62 5.64 5.66 5.68 5.7
WLAN encryption modes: WEP40 WEP104 TKIP CCMP
WLAN authentication modes: open sharedkey wpa-psk wpa-eap
Module Alias: "pci:v00008086d00002723sv00008086sd0000008Cbc02sc80i00"
Driver Info #0:
Driver Status: iwlwifi is active
Driver Activation Cmd: "modprobe iwlwifi"
Attached to: #19 (PCI bridge)

44: USB 00.1: 11500 Bluetooth Device
[Created at usb.122]
Unique ID: Ue9G.qmlouffvxgF
Parent ID: 9Cfs.erpEvbsFWX1
SysFS ID: /devices/pci0000:00/0000:00:13.0/usb10/10-2/10-2:1.1
SysFS BusID: 10-2:1.1
Hardware Class: bluetooth
Model: "Intel Bluetooth Device"
Hotplug: USB
Vendor: usb 0x8087 "Intel Corp."
Device: usb 0x0029
Revision: "0.01"
Driver: "btusb"
Driver Modules: "btusb"
Speed: 12 Mbps
Module Alias: "usb:v8087p0029d0001dcE0dsc01dp01icE0isc01ip01in01"
Driver Info #0:
Driver Status: btusb is active
Driver Activation Cmd: "modprobe btusb"
Attached to: #45 (Hub)

~# modinfo -p iwlwifi
debug:debug output mask (uint)
swcrypto:using crypto in software (default 0 [hardware]) (int)
11n_disable:disable 11n functionality, bitmap: 1: full, 2: disable agg TX, 4: disable agg RX, 8 enable agg TX (uint)
amsdu_size:amsdu size 0: 12K for multi Rx queue devices, 2K for AX210 devices, 4K for other devices 1:4K 2:8K 3:12K 4: 2K (default 0) (int)
fw_restart:restart firmware in case of error (default true) (bool)
antenna_coupling:specify antenna coupling in dB (default: 0 dB) (int)
nvm_file:NVM file name (charp)
uapsd_disable:disable U-APSD functionality bitmap 1: BSS 2: P2P Client (default: 3) (uint)
enable_ini:Enable debug INI TLV FW debug infrastructure (default: 0 (bool)
bt_coex_active:enable wifi/bt co-exist (default: enable) (bool)
led_mode:0=system default, 1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0) (int)
power_save:enable WiFi power management (default: disable) (bool)
power_level:default power save level (range from 1 - 5, default: 1) (int)
fw_monitor:firmware monitor - to debug FW (default: false - needs lots of memory) (bool)
disable_11ac:Disable VHT capabilities (default: false) (bool)
remove_when_gone:Remove dev from PCIe bus if it is deemed inaccessible (default: false) (bool)
disable_11ax:Disable HE capabilities (default: false) (bool)

~$ modinfo iwlwifi | grep "firmware"
[....]
firmware: iwlwifi-8000C-36.ucode
firmware: iwlwifi-9260-th-b0-jf-b0-46.ucode
firmware: iwlwifi-9000-pu-b0-jf-b0-46.ucode
firmware: iwlwifi-ty-a0-gf-a0-52.ucode
firmware: iwlwifi-so-a0-gf-a0-52.ucode
firmware: iwlwifi-so-a0-hr-b0-52.ucode
firmware: iwlwifi-so-a0-jf-b0-52.ucode
firmware: iwlwifi-cc-a0-52.ucode
firmware: iwlwifi-QuQnj-b0-jf-b0-52.ucode
firmware: iwlwifi-QuZ-a0-jf-b0-52.ucode
firmware: iwlwifi-QuZ-a0-hr-b0-52.ucode
[...]

~$ tree /sys/class/net
/sys/class/net
├── eth0 -> ../../devices/pci0000:00/0000:00:03.3/0000:02:00.0/net/eth0
├── lo -> ../../devices/virtual/net/lo
└── wlan0 -> ../../devices/pci0000:00/0000:00:03.4/0000:03:00.0/net/wlan0
thermal thermal_zone0: failed to read out thermal zone (-61)
  • 测试不同的加载参数,下面参数等于echo "options iwlwifi 11n_disable=8" > /etc/modprobe.d/iwlwifi.conf.只是要重启生效

    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
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    ~$ sudo rmmod iwlmvm
    ~$ sudo rmmod iwlwifi
    ~$ sudo modprobe iwlwifi 11n_disable=8

    # 对应的参数说明是

    ~$ modinfo iwlwifi
    [...]
    parm: swcrypto:using crypto in software (default 0 [hardware]) (int)
    parm: 11n_disable:disable 11n functionality, bitmap: 1: full, 2: disable agg TX, 4: disable agg RX, 8 enable agg TX (uint)
    parm: amsdu_size:amsdu size 0: 12K for multi Rx queue devices, 2K for AX210 devices, 4K for other devices 1:4K 2:8K 3:12K 4: 2K (default 0) (int)
    parm: fw_restart:restart firmware in case of error (default true) (bool)
    parm: antenna_coupling:specify antenna coupling in dB (default: 0 dB) (int)
    parm: nvm_file:NVM file name (charp)
    parm: uapsd_disable:disable U-APSD functionality bitmap 1: BSS 2: P2P Client (default: 3) (uint)
    parm: enable_ini:Enable debug INI TLV FW debug infrastructure (default: 0 (bool)
    parm: bt_coex_active:enable wifi/bt co-exist (default: enable) (bool)
    parm: led_mode:0=system default, 1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0) (int)
    parm: power_save:enable WiFi power management (default: disable) (bool)
    parm: power_level:default power save level (range from 1 - 5, default: 1) (int)
    parm: fw_monitor:firmware monitor - to debug FW (default: false - needs lots of memory) (bool)
    parm: disable_11ac:Disable VHT capabilities (default: false) (bool)
    parm: remove_when_gone:Remove dev from PCIe bus if it is deemed inaccessible (default: false) (bool)
    parm: disable_11ax:Disable HE capabilities (default: false) (bool)

    # 查看当前驱动的参数
    ~# systool -m iwlwifi -av
    Module = "iwlwifi"

    Attributes:
    coresize = "282624"
    initsize = "0"
    initstate = "live"
    refcnt = "1"
    srcversion = "4E773ECBB9682B55D952A3C"
    taint = ""
    uevent = <store method only>

    Parameters:
    11n_disable = "0"
    amsdu_size = "0"
    antenna_coupling = "0"
    bt_coex_active = "Y"
    debug = "0"
    disable_11ac = "N"
    disable_11ax = "N"
    enable_ini = "N"
    fw_monitor = "N"
    fw_restart = "Y"
    led_mode = "0"
    nvm_file = "(null)"
    power_level = "0"
    power_save = "N"
    remove_when_gone = "N"
    swcrypto = "0"
    uapsd_disable = "3"
    [....]
    # 对应映射到系统的位置.
    ~$ ls /sys/module/iwlwifi/parameters/
    11n_disable antenna_coupling disable_11ac enable_ini fw_restart nvm_file power_save swcrypto
    amsdu_size bt_coex_active disable_11ax fw_monitor led_mode power_level remove_when_gone uapsd_disable

  • 最终参照这里,开启优化设置如下:

1
2
3
4
5
6
7
8
9
~$  cat /etc/modprobe.d/iwlwifi.conf
options iwlwifi 11n_disable=8
options iwlwifi swcrypto=1
options iwlwifi bt_coex_active=0
options iwlwifi power_save=0
options iwlwifi d0i3_disable=0
options iwlwifi amsdu_size=3
options iwlmvm power_scheme=3
options iwldvm force_cam=0
  • hcitool 连接蓝牙
1
2
3
4
5
6
7
8
9
10
~$ hcitool scan
Scanning ...
00:14:01:22:14:49 lcy
B8:AD:3E:91:70:02 LG HBS500
98:D3:36:00:CC:BF lcy_HC-05

~$ hcitool cc B8:AD:3E:91:70:02
Can't create connection: Operation not permitted

~$ sudo setcap cap_net_raw+eip `which hcitool`
  • 无法检测到蓝牙控制器
1
2
~$ bluetoothctl show
No default controller available
  • 尝试重装一下它的驱动
1
2
3
4
5
~# rmmod btusb
~# rmmod btintel

~# modprobe btintel
~# modprobe btusb

查看WIFI的地区代码.

  • iwconfig wlan0 txpower 30mW - not working
  • How to create custom Linux Wi-Fi regulatory database to unlock 30db/1000mWDFS是为了使无线产品主动探测军方使用的频率,并主动选择另一个频率,以避开军方频率.所以上面那个链接说,在美国解除限制是违法.
    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
    26
    27
    28
    29
    30
    31
    32
    ~$ regdbdump /lib/crda/regulatory.bin
    ~$ iw reg get
    phy#0 (self-managed)
    country CN: DFS-UNSET
    (2402 - 2437 @ 40), (6, 22), (N/A), AUTO-BW, NO-HT40MINUS, NO-80MHZ, NO-160MHZ
    (2422 - 2462 @ 40), (6, 22), (N/A), AUTO-BW, NO-80MHZ, NO-160MHZ
    (2447 - 2482 @ 40), (6, 22), (N/A), AUTO-BW, NO-HT40PLUS, NO-80MHZ, NO-160MHZ
    (5170 - 5190 @ 160), (6, 22), (N/A), NO-OUTDOOR, AUTO-BW, IR-CONCURRENT, NO-HT40MINUS, PASSIVE-SCAN
    (5190 - 5210 @ 160), (6, 22), (N/A), NO-OUTDOOR, AUTO-BW, IR-CONCURRENT, NO-HT40PLUS, PASSIVE-SCAN
    (5210 - 5230 @ 160), (6, 22), (N/A), NO-OUTDOOR, AUTO-BW, IR-CONCURRENT, NO-HT40MINUS, PASSIVE-SCAN
    (5230 - 5250 @ 160), (6, 22), (N/A), NO-OUTDOOR, AUTO-BW, IR-CONCURRENT, NO-HT40PLUS, PASSIVE-SCAN
    (5250 - 5270 @ 160), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, PASSIVE-SCAN
    (5270 - 5290 @ 160), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, PASSIVE-SCAN
    (5290 - 5310 @ 160), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, PASSIVE-SCAN
    (5310 - 5330 @ 160), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, PASSIVE-SCAN
    (5490 - 5510 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, PASSIVE-SCAN
    (5510 - 5530 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, PASSIVE-SCAN
    (5530 - 5550 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, PASSIVE-SCAN
    (5550 - 5570 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, PASSIVE-SCAN
    (5570 - 5590 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, PASSIVE-SCAN
    (5590 - 5610 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, PASSIVE-SCAN
    (5610 - 5630 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, PASSIVE-SCAN
    (5630 - 5650 @ 240), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, PASSIVE-SCAN
    (5650 - 5670 @ 80), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, NO-160MHZ, PASSIVE-SCAN
    (5670 - 5690 @ 80), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, NO-160MHZ, PASSIVE-SCAN
    (5690 - 5710 @ 80), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40MINUS, NO-160MHZ, PASSIVE-SCAN
    (5710 - 5730 @ 80), (6, 22), (0 ms), DFS, AUTO-BW, NO-HT40PLUS, NO-160MHZ, PASSIVE-SCAN
    (5735 - 5755 @ 80), (6, 22), (N/A), AUTO-BW, IR-CONCURRENT, NO-HT40MINUS, NO-160MHZ, PASSIVE-SCAN
    (5755 - 5775 @ 80), (6, 22), (N/A), AUTO-BW, IR-CONCURRENT, NO-HT40PLUS, NO-160MHZ, PASSIVE-SCAN
    (5775 - 5795 @ 80), (6, 22), (N/A), AUTO-BW, IR-CONCURRENT, NO-HT40MINUS, NO-160MHZ, PASSIVE-SCAN
    (5795 - 5815 @ 80), (6, 22), (N/A), AUTO-BW, IR-CONCURRENT, NO-HT40PLUS, NO-160MHZ, PASSIVE-SCAN
    (5815 - 5835 @ 20), (6, 22), (N/A), AUTO-BW, IR-CONCURRENT, NO-HT40MINUS, NO-HT40PLUS, NO-80MHZ, NO-160MHZ, PASSIVE-SCAN
  • 也可以在/etc/default/crda设置区域代码.
1
2
3
dmesg | grep "cfg80211"
[ 6.756930] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[ 6.756935] cfg80211: failed to load regulatory.db

编译wireless-regdb

1
2
3
4
5
6
# python2 required
~$ pip install M2Crypto
~$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git

~$ cd wireless-regdb && make
~$ make install

编译crda

1
~$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/crda.git

创建Linux路由器(支持IPv6-PD)

  • 链接:

  • 一般来说,可以使用Linux来做一个完全路由(OpentWrt),这里讲的是如何在自己工作的台式电脑内安装路由(含WiFi)功能.一般是台机是只有一个以太网卡,外接一个USB Wifi网卡来做无线路由,当然也可以有这些组合:eth0(WAN)–>wlan0(LAN), eth0(WAN)–>eth1(LAN),wlan0(WAN)–>wlan1(lan). 一般卖的小家用路由器是:一个WAN口,外加4个交换机LAN口,可能还有一个Wifi功能.其实这些低成本的路由器只有一个物理网卡,使用VLAN把它分成两个子网(WAN,LAN),其实也就是单臂路由.如:eth0.0(WAN)-->br-lan(eth0.1,wlan)使用桥接(bridge)功能把wifi与4个LAN口交换机绑定成一个内局域网内.

  • 下面这里是把两个wifi组成一个无线路由,wlan0(WAN)--wlan1(LAN),wlan0是从连接上层路由(外部ISP)相当于是WAN,wlan1是内部子网相当于是LAN.之前一般配置是,开启内核转发net.ipv4.ip_forward = 1,再配置一个hostapd,dnsmasq就能对外提供一个简单在IPv4的路由服务了.

系统配置

1
2
3
4
5
6
7
8
9
10
11
12
~$ cat /etc/sysctl.conf
# ipv4转发功能,必须开启,才能让本地ipv4地址上网
net.ipv4.ip_forward=1
# 开启接的路由广告功能
net.ipv6.conf.all.accept_ra = 2
net.ipv6.conf.default.accept_ra = 2
net.ipv6.conf.wlan0.accept_ra = 2

# IPv6转发,在IPv6时代,不需要NAT转发,全局地址可以直接访问到对方.
net.ipv6.conf.wlan0.forwarding = 1
net.ipv6.conf.all.forwarding = 1
net.ipv6.conf.default.forwarding = 1

DHCP&DNS服务器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
~$ sudo apt-get instal dnsmasq

# 具体配置说明可以使用 man dnsmasq查看.
~$ cat /etc/dnsmasq.conf # grep -v '^#\|^$' /etc/dnsmasq.conf
domain-needed
bogus-priv
server=2606:4700:4700::1001
server=8.8.8.8
no-resolv
server=192.168.1.1
interface=wlan1
except-interface=wlan0
listen-address=192.168.2.1
no-dhcp-interface=wlan0,lo
dhcp-range=192.168.2.50,192.168.2.150,12h
# 下面两行很重要,开启ipv6路由广告,指定接口提供PD.
enable-ra
dhcp-range=tag:wlan1,::1,ra-names,slaac,constructor:wlan1,64,12h
dhcp-ignore-names=tag:dhcp_bogus_hostname
dhcp-rapid-commit
domain=lan
server=/lan/
#log-facility=/var/log/dnsmasq.log

DHCP客户端

  • 如果只是ipv4路由服务,是不需安装下面这些DHCP客户端的.这里使用的是dhcpcd5,功能:DHCPv4, IPv6RA and DHCPv6 client with IPv4LL support.还有如:wide-dhcpv6-client,dibbler-client.这里是以dhcpcd5为示例,具体详细配置可以通过man dhcpcd.conf查看.

DHCPCD5

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
~$ sudo apt-get instal dhcpcd5

~$ cat /etc/dhcpcd.conf # 可以这样过滤注释 grep -v '^#\|^$' /etc/dhcpcd.conf
hostname
# logfile /var/log/dhcpcd.log 不指定它,就输出到/var/log/syslog
duid
noipv6rs # 先要全局禁止ipv6请求.
waitip 6
persistent
option rapid_commit
option domain_name_servers
option classless_static_routes
option interface_mtu
require dhcp_server_identifier
# debug
slaac private

# 这里开始,配置wlan0接口 WAN
interface wlan0
ipv6rs
#ia_na 1
ia_pd 1 wlan1/0 # 为 wlan1(LAN)请求 Prefix-delegated 地址.

~$ systemctl start dhcpcd

Wide-dhcpv6-client

  • wide-dhcpv6-client与dhcpcd二者不能同时运行.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    ~$ sudo apt-get install wide-dhcpv6-client
    ~$ cat /etc/wide-dhcpv6/dhcp6c.conf
    # Default dhpc6c configuration: it assumes the address is autoconfigured using
    # router advertisements.
    interface wlan0 {
    send ia-pd 0;
    send rapid-commit;
    request domain-name-servers;
    script "/sbin/dhcp6c-state";
    };

    id-assoc pd 0 {
    prefix-interface wlan1 {
    sla-id 0;
    sla-len 0;
    };
    };

    ~$ sudo /etc/init.d/wide-dhcpv6-client start
  • 启动/etc/init.d/dhcpcd restart,获取PD信息根据网络质量,可能会有不到十几秒的延时,现在查看接口会显示类似如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    ~$ ifconfig wlan1
    wlan1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    inet 192.168.2.1 netmask 255.255.255.0 broadcast 192.168.2.255
    inet6 2409:8a55:xxxx:xxxx::1 prefixlen 64 scopeid 0x0<global> # 这里是通过wlan1从上游ISP获取的PD.
    inet6 fe80::705c:99ff:feda:9f46 prefixlen 64 scopeid 0x20<link>
    ether 72:5c:99:da:9f:46 txqueuelen 1000 (Ethernet)
    RX packets 174 bytes 21784 (21.2 KiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 401 bytes 76160 (74.3 KiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Wifi客户端

HOSTAPD

  • wiki/Hostapd

  • 不幸的,intel iwlwifi它在hostapd不支持AC 5G的热点功能。

    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
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    ~$ sudo apt-get install hostapd
    ~$ cat /etc/hostapd/hostapd.conf
    interface=wlan1
    # bridge=br-lan
    driver=nl80211
    logger_syslog=-1
    logger_syslog_level=2
    logger_stdout=-1
    logger_stdout_level=2
    ctrl_interface=/var/run/hostapd
    ctrl_interface_group=0
    ssid=lcy
    country_code=US
    hw_mode=g # b,g,a三种模式,5G 是ac模式
    channel=1
    beacon_int=100
    dtim_period=2
    macaddr_acl=0
    auth_algs=1
    wmm_enabled=1
    wmm_ac_bk_cwmin=4
    wmm_ac_bk_cwmax=10
    wmm_ac_bk_aifs=7
    wmm_ac_bk_txop_limit=0
    wmm_ac_bk_acm=0
    wmm_ac_be_aifs=3
    wmm_ac_be_cwmin=4
    wmm_ac_be_cwmax=10
    wmm_ac_be_txop_limit=0
    wmm_ac_be_acm=0
    wmm_ac_vi_aifs=2
    wmm_ac_vi_cwmin=3
    wmm_ac_vi_cwmax=4
    wmm_ac_vi_txop_limit=94
    wmm_ac_vi_acm=0
    wmm_ac_vo_aifs=2
    wmm_ac_vo_cwmin=2
    wmm_ac_vo_cwmax=3
    wmm_ac_vo_txop_limit=47
    wmm_ac_vo_acm=0
    # ieee80211n=1 # 开启11N模式
    # ht_capab=[HT40+][SHORT-GI-20][SHORT-GI-40]
    wpa=2
    wpa_psk_file=/etc/hostapd/hostapd.wpa_psk
    wpa_key_mgmt=WPA-PSK
    wpa_pairwise=TKIP
    rsn_pairwise=CCMP
    wpa_group_rekey=600

    ~$ systemctl start hostapd

WPASUPPLICANT

1
2
3
4
5
6
7
8
9
10
~$ sudo apt-get install wpasupplicant
~$ cat /etc/wpa_supplicant/lcy_wifi.conf
network={
ssid="lcy"
mode=2 # 2为AP模式.
#psk="xxxxxx"
psk=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
}

~$ wpa_supplicant -B -Dnl80211 -iwlan1 -c/etc/wpa_supplicant/lcy_wifi.conf
  • 上面这些工具,都可以是运行为独立的服务,可以像要下面一样,通过网卡事件脚本来控制.

    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
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    ~$ cat /etc/network/interfaces

    auto wlan1
    allow-hotplug wlan1
    iface wlan1 inet static
    address 192.168.2.1
    netmask 255.255.255.0
    network 192.168.2.0
    #up ifconfig ovsbr0 down
    # 使用wpa_supplicant 开启AP模式,提供wifi访问.
    pre-up wpa_supplicant -B -Dnl80211 -i$IFACE -c/etc/wpa_supplicant/lcy_wifi.conf \
    -P/var/run/wpa_supplicant.$IFACE.pid
    # 在这里 hostapd与wpa_supplicant二选一提供AP认证服务
    #post-up /usr/sbin/hostapd -B -P/var/run/hostapd.$IFACE.pid /etc/hostapd/hostapd.conf
    post-up /usr/sbin/dnsmasq --conf-file=/etc/dnsmasq.conf \
    --pid-file=/var/run/dnsmasq.$IFACE.pid
    post-up /etc/init.d/dhcpcd restart
    wait-delay 15
    pre-down cat /var/run/dnsmasq.$IFACE.pid | xargs kill
    pre-down cat /var/run/wpa_supplicant.$IFACE.pid | xargs kill
    #pre-down cat /var/run/hostapd.$IFACE.pid | xargs kill

    auto wlan0
    iface wlan0 inet static
    #up ip link set dev ovsbr0 down
    #up ifconfig ovs-system down
    #up ifconfig ovsbr0 down
    address 192.168.1.100
    netmask 255.255.255.0
    network 192.168.1.0
    gateway 192.168.1.1
    # 这里也很重要,WAN口需要固定一个MAC地址,
    # pre-up ip link set dev $IFACE addr 34:13:xx:xx:xx:76
    # 使用wpa_supplicant去连接上游的wifi.
    pre-up wpa_supplicant -B -Dnl80211 -i$IFACE -c/etc/wpa_supplicant/wpa_supplicant.conf \
    -P/var/run/wpa_supplicant.$IFACE.pid
    post-up /etc/init.d/dhcpcd start # 简单可以直接 dhcpcd $IFACE
    wait-delay 15
    post-down /etc/init.d/dhcpcd stop
    pre-down cat /var/run/wpa_supplicant.$IFACE.pid | xargs kill
  • 也可以使用下面wpa_supplicant方式连接认证wifi.用wpa_passphrase生成要连接的ssid与密钥.

    1
    2
    3
    4
    5
    6
    ~$ wpa_passphrase my_ssid 12345678
    network={
    ssid="my_ssid"
    #psk="12345678"
    psk=b63bb73550b08933c709bbff538af08d29024cbf0790981c116a3210391fe2d0
    }
  • 使用systemd控制

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
26
27
28
29
~$ cat /etc/systemd/system/network-wireless@.service:
[Unit]
Description=Wireless network connectivity (%i)
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device

[Service]
Type=oneshot
RemainAfterExit=yes

ExecStart=/usr/sbin/ip link set dev %i up
ExecStart=/usr/sbin/wpa_supplicant -B -i %i -c /etc/wpa_supplicant/wpa_supplicant.conf
#ExecStart=/usr/sbin/dhclient %i

ExecStop=/usr/sbin/ip link set dev %i down

[Install]
WantedBy=multi-user.target


~$ ln -s /etc/systemd/system/network-wireless@.service \
/etc/systemd/system/multi-user.target.wants/network-wireless@wlan0.service


~$ systemctl daemon-reload
~$ systemctl start network-wireless@wlan0.service

  • 最终的生成的数据如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    ~$ cat /etc/wpa_supplicant/wpa_supplicant.conf
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    p2p_disabled=1
    network={
    ssid="my_ssid"
    #psk="12345678"
    psk=b63bb73550b08933c709bbff538af08d29024cbf0790981c116a3210391fe2d0
    #COUNTRY=US
    proto=RSN
    key_mgmt=WPA-PSK
    pairwise=CCMP TKIP
    group=CCMP TKIP
    }
  • 如上所示,在/etc/network/interfaces的接口内加入pre-up wpa_supplicant -B -Dnl80211 -i$IFACE -c/etc/wpa_supplicant/wpa_supplicant.conf方式连接.如果要查看一些调试信息,加上-dd命令行中.

  • 查看状态

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    ~$ wpa_cli  status
    Selected interface 'wlan0'
    bssid=22:76:93:00:xx:xx
    freq=5200
    ssid=my_ssid
    id=0
    mode=station
    pairwise_cipher=CCMP
    group_cipher=CCMP
    key_mgmt=WPA2-PSK
    wpa_state=COMPLETED
    ip_address=192.168.1.100
    address=44:af:28:32:xx:xx
    uuid=d52e74ae-991c-5d82-ab4f-80a9f2417de5
    ieee80211ac=1
  • 使用手机连接到该wifi热点上,从手机信息的菜单项查看,是否获取一个240x开头的IPv6地址.如果有,说明可以使用IPv6访问网络了,打开test-ipv6.com测试一下.

  • 如果LAN的客户端能够正常获取一个PD+MAC全局地址,但是不能访问IPv6网络.这就要仔细查看与调试各级路由了.我在此因为设置了动态MAC,所以造成的路由问题.一般这里上游路由表如下:

    1
    2
    3
    4
    5
    6
    ~$ ip -6 route
    # 上游路由取得的PD是 2409:xxxx:xxxx:4fc0::/60
    default from 2409:xxxx:xxxx:4fc0::/60 via fe80::e681:84ff:fe44:a40f dev pppoe-wan proto static metric 512 pref medium
    2409:8a55:2416:4fc0::/64 dev br-lan proto static metric 1024 pref medium
    # 这里有一条静态的路由,去到这一级的WAN(wlan0)口的链路地址 fe80::xxxx:xxxx:21ba:6d93,这一条路由可以修改,但是这个客户端断开后,它又会重写回去.
    2409:8a55:xxxx:xxxx::/64 via fe80::xxxx:xxxx:21ba:6d93 dev br-lan proto static metric 1024 pref medium
  • 刚好我又在这个Linux内安装了macchanger这个工具脚本,它链接网卡的启停脚本.所以本机系统每个网卡MAC会因为每次up|down后随机产生一个新的地址,所以依赖于MAC计算出来的本地链路地址也变了,对于LAN口(wlan1)的地址改变其实没有什么影响,但是WAN口(wlan0)的地址改变就会影响到上游路由表无法到更新后的链路地址.或者说:本地WAN(wlan0)的链路地址改变,需同步更改上游路由表,否则本级路由下LAN(wlan)不能正常访问网络.

1
2
3
4
5
6
7
8
9
10
11
/etc/network$ tree if-pre-up.d/
if-pre-up.d/
├── bridge -> /lib/bridge-utils/ifupdown.sh
├── ethtool
├── hostapd -> ../../hostapd/ifupdown.sh
├── macchanger -> ../../macchanger/ifupdown.sh
├── openvswitch -> /usr/share/openvswitch/scripts/ifupdown.sh
├── uml-utilities
├── vlan
├── wireless-tools
└── wpasupplicant -> ../../wpa_supplicant/ifupdown.sh
  • macchanger可以查看硬件真实的MAC,也可生成随机MAC并修改它.这里需要在WAN口(wlan0)固定硬件地址的随机更改.如果要防止它每次重启后随机变动.一种方法确保有下面配置:
    1
    2
    3
    4
    ~$ cat /etc/NetworkManager/NetworkManager.conf
    [....]
    [device]
    wifi.scan-rand-mac-address=no
  • 或者使用macchanger,ip/etc/network/interfaces的里脚本里固定它.修改硬件地址先要关闭硬件功能,有时运行了如:ifdown wlan0 或者 ifconfig wlan0 down,还是没有关闭硬件,导致无法修改MAC,此时肯定还有其守护程序在运行,如:wicd,可以运行systemctl stop wicd再尝试修改.

Wifi Direct(p2p mode)

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
~$ cat /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
device_name=debian
device_type=2-0050F204-1
p2p_go_intent=15
p2p_go_ht40=1
#p2p_disabled=1
network={
ssid="OpenWrt-5G"
#psk="xxxxxxxxxxxxxxxxxx"
psk=d5c46754b57b318f213eae32eefa61a602f28df87af6f5fd83c5297b775b6b82

#COUNTRY=US
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
}


~$ wpa_supplicant -B -Dnl80211 -i$IFACE -dd -c/etc/wpa_supplicant/wpa_supplicant.conf
[....]
Using existing control interface directory.
ctrl_interface_group=113 (from group name 'netdev')
P2P: Add operating class 81
P2P: Channels - hexdump(len=13): 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d
P2P: Own listen channel: 81:6
P2P: Random operating channel: 81:1
P2P: initialized
P2P: channels: 81:1,2,3,4,5,6,7,8,9,10,11,12,13
P2P: cli_channels:
p2p-dev-wlan0: Added interface p2p-dev-wlan0
p2p-dev-wlan0: State: INACTIVE -> DISCONNECTED
nl80211: Set p2p-dev-wlan0 operstate 0->0 (DORMANT)
netlink: Operstate: ifindex=0 linkmode=-1 (no change), operstate=5 (IF_OPER_DORMANT)
p2p-dev-wlan0: Determining shared radio frequencies (max len 2)
p2p-dev-wlan0: Shared frequencies (len=0): completed iteration
P2P: Add operating class 81
P2P: Channels - hexdump(len=13): 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d
P2P: Update channel list
P2P: channels: 81:1,2,3,4,5,6,7,8,9,10,11,12,13
P2P: cli_channels:
Daemonize..
sending commands to master dhcpcd process
sending commands to master dhcpcd process

~$ sudo wpa_cli -i p2p-dev-wlan0

> p2p_find 10
OK
<3>CTRL-EVENT-SCAN-STARTED
<3>CTRL-EVENT-SCAN-STARTED
<3>CTRL-EVENT-SCAN-STARTED
<3>CTRL-EVENT-SCAN-STARTED
<3>P2P-DEVICE-FOUND be:30:xx:xx:19:a1 p2p_dev_addr=be:30:xx:xx:19:a1 pri_dev_type=7-0050F204-1 name='客厅的小米电视' config_methods=0x188 dev_capab=0x24 group_capab=0x0 wfd_dev_info=0x00112b441132 vendor_elems=1 new=0
<3>CTRL-EVENT-SCAN-STARTED
<3>CTRL-EVENT-SCAN-STARTED
<3>CTRL-EVENT-SCAN-STARTED
<3>P2P-FIND-STOPPED
<3>P2P-DEVICE-LOST p2p_dev_addr=be:30:xx:xx:19:a1
p2p_peers
be:30:xx:xx:19:a1
> p2p_connect be:30:xx:xx:19:a1 pin intent 15
55577670
<3>P2P-GO-NEG-SUCCESS role=GO freq=2412 ht40=1 peer_dev=be:30:xx:xx:19:a1 peer_iface=be:30:xx:xx:99:a1 wps_method=Display
<3>P2P-GROUP-FORMATION-SUCCESS
<3>P2P-GROUP-STARTED p2p-wlan0-0 GO ssid="DIRECT-vV" freq=2412 passphrase="BqbrqD4l" go_dev_addr=44:af:28:32:4f:de
<3>AP-STA-CONNECTED be:30:xx:xx:99:a1 p2p_dev_addr=be:30:xx:xx:19:a1

VirtualBox虚拟机与主机的复制与粘贴

  • 一般来说,如果虚拟机(Guest)安装的是Windows系统,只要安装VBoxGuestAddions.iso里的驱动,再在菜单里选择Devices-->Shared Clipboard方式,就可以与主机(Host)之前的共享复制粘贴了.如果GuestLinux系统,安装完成VBoxGuestAddions.iso且设置了Shared Clipboard,然而不能复制的话,可以在Guest里,运行sudo VBoxClient --clipboard之后,再尝试上述操作.

VirtualBox在AMD Ryzen 7运行出现Oops

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
~$ dpkg -l | grep "virtualbox"
ii virtualbox 6.1.28-dfsg-1~fto11+1 amd64 x86 virtualization solution - base binaries
ii virtualbox-dkms 6.1.28-dfsg-1~fto11+1 amd64 x86 virtualization solution - kernel module sources for dkms
ii virtualbox-ext-pack 6.1.28-1~fto11+1 all extra capabilities for VirtualBox, downloader.
ii virtualbox-guest-utils 6.1.28-dfsg-1~fto11+1 amd64 x86 virtualization solution - non-X11 guest utilities
ii virtualbox-guest-x11 6.1.28-dfsg-1~fto11+1 amd64 x86 virtualization solution - X11 guest utilities
ii virtualbox-qt 6.1.28-dfsg-1~fto11+1 amd64 x86 virtualization solution - Qt based user interface

~$ dmesg
[...]
[ 16.592665] systemd-journald[405]: File /var/log/journal/b41279e62373e95aba7f576b5274305b/user-1000.journal corrupted or uncleanly shut down, renaming and replacing.
[ 127.593723] SUPR0GipMap: fGetGipCpu=0x3b
[ 128.190967] kernel tried to execute NX-protected page - exploit attempt? (uid: 1000)
[ 128.190973] BUG: unable to handle page fault for address: ffffb050839f7000
[ 128.190975] #PF: supervisor instruction fetch in kernel mode
[ 128.190976] #PF: error_code(0x0011) - permissions violation
[ 128.190978] PGD 800100000067 P4D 800100000067 PUD 80010006a067 PMD 8003265ad067 PTE 8000800105ad6161
[ 128.190981] Oops: 0011 [#1] PREEMPT SMP NOPTI
[ 128.190982] CPU: 14 PID: 5557 Comm: EMT-0 Tainted: P OE 5.15.14-20220112 #1
[ 128.190985] Hardware name: ASUS System Product Name/TUF GAMING B550M-PLUS (WI-FI), BIOS 1401 12/03/2020
[ 128.190987] RIP: 0010:0xffffb050839f7000
[ 128.190989] Code: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <00> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[ 128.190990] RSP: 0018:ffffb0508388fe08 EFLAGS: 00010283
[ 128.190992] RAX: ffffb050839120f0 RBX: ffffb05083a8f010 RCX: ffffb05083891000
[ 128.190993] RDX: ffffb05083911370 RSI: 0000000000000000 RDI: ffff8d0d83852790
[ 128.190994] RBP: ffffb0508388fe98 R08: 0000000000000001 R09: ffffedc080000000
[ 128.190995] R10: ffffffffc306a6e0 R11: 00008003265ae007 R12: 0000000000000024
[ 128.190996] R13: ffffffffc306a6e0 R14: 0000000000000000 R15: ffff8d0d83852790
[ 128.190997] FS: 00007f8f925fc700(0000) GS:ffff8d148eb80000(0000) knlGS:0000000000000000
[ 128.190998] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 128.190999] CR2: ffffb050839f7000 CR3: 0000800105990000 CR4: 0000000000350ee0
[ 128.191000] Call Trace:
[ 128.191001] <TASK>
[ 128.191004] ? supdrvIOCtl+0x3465/0x38b0 [vboxdrv]
[ 128.191018] VBoxDrvLinuxIOCtl_6_1_32+0x149/0x240 [vboxdrv]
[ 128.191028] __x64_sys_ioctl+0xa8/0xe0
[ 128.191032] do_syscall_64+0x3b/0x80
[ 128.191036] entry_SYSCALL_64_after_hwframe+0x44/0xae
[ 128.191038] RIP: 0033:0x7f8fc040dcc7
[ 128.191040] Code: 00 00 00 48 8b 05 c9 91 0c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 99 91 0c 00 f7 d8 64 89 01 48
[ 128.191041] RSP: 002b:00007f8f925fac78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[ 128.191043] RAX: ffffffffffffffda RBX: 00007f8f7c1e1480 RCX: 00007f8fc040dcc7
[ 128.191044] RDX: 00007f8f7c1e1480 RSI: 0000000000005684 RDI: 0000000000000007
[ 128.191044] RBP: 00007f8f925fac80 R08: 0000000000000000 R09: 00000000fffffffc
[ 128.191045] R10: 0000000000000000 R11: 0000000000000246 R12: 00007f8fb051b7df
[ 128.191046] R13: 00007f8f925fb0e0 R14: 00007f8f925fade0 R15: 0000000000000000
[ 128.191048] </TASK>
[ 128.191049] Modules linked in: ctr(E) ccm(E) rfcomm(E) squashfs(E) zstd_decompress(E) iptable_nat(E) xt_MASQUERADE(E) nf_nat(E) vboxnetadp(OE) vboxnetflt(OE) nf_conntrack(E) vboxdrv(OE) nf_defrag_ipv6(E) cmac(E) nf_defrag_ipv4(E) algif_hash(E) bpfilter(E) algif_skcipher(E) af_alg(E) overlay(E) bnep(E) cpufreq_ondemand(E) 8021q(E) cpufreq_powersave(E) cpufreq_conservative(E) garp(E) stp(E) cpufreq_userspace(E) mrp(E) llc(E) uinput(E) binfmt_misc(E) xfs(E) nls_ascii(E) nls_cp437(E) vfat(E) fat(E) dm_multipath(E) sd_mod(E) sg(E) btusb(E) btrtl(E) btbcm(E) btintel(E) bluetooth(E) jitterentropy_rng(E) sha512_ssse3(E) sha512_generic(E) drbg(E) ansi_cprng(E) ecdh_generic(E) ecc(E) nvidia_drm(POE) iwlmvm(E) drm_kms_helper(E) mac80211(E) edac_mce_amd(E) snd_hda_codec_realtek(E) kvm_amd(E) cec(E) snd_hda_codec_generic(E) syscopyarea(E) ledtrig_audio(E) snd_hda_codec_hdmi(E) sysfillrect(E) sysimgblt(E) kvm(E) snd_hda_intel(E) fb_sys_fops(E) snd_intel_dspcfg(E) libarc4(E) nvidia_modeset(POE)
[ 128.191082] snd_hda_codec(E) iwlwifi(E) snd_hwdep(E) snd_hda_core(E) snd_pcm_oss(E) irqbypass(E) crc32_pclmul(E) snd_mixer_oss(E) ghash_clmulni_intel(E) cfg80211(E) snd_pcm(E) ahci(E) joydev(E) libahci(E) aesni_intel(E) libaes(E) libata(E) dm_mod(E) crypto_simd(E) snd_timer(E) wmi_bmof(E) cryptd(E) snd(E) rapl(E) scsi_mod(E) sp5100_tco(E) pcspkr(E) ccp(E) watchdog(E) soundcore(E) k10temp(E) i2c_piix4(E) scsi_common(E) acpi_cpufreq(E) button(E) wmi(E) nvidia(POE) drm(E) sunrpc(E) tcp_bbr(E) loop(E) fuse(E) configfs(E) ip_tables(E) x_tables(E) autofs4(E) ext4(E) crc16(E) mbcache(E) jbd2(E) raid10(E) raid456(E) libcrc32c(E) crc32c_generic(E) async_raid6_recov(E) async_memcpy(E) async_pq(E) evdev(E) hid_generic(E) usbhid(E) hid(E) raid6_pq(E) async_xor(E) xor(E) async_tx(E) raid1(E) raid0(E) multipath(E) linear(E) md_mod(E) xhci_pci(E) xhci_hcd(E) nvme(E) crc32c_intel(E) usbcore(E) nvme_core(E) t10_pi(E) crc_t10dif(E) crct10dif_generic(E) crct10dif_pclmul(E) crct10dif_common(E)
[ 128.191118] usb_common(E) gpio_amdpt(E) gpio_generic(E)
[ 128.191121] CR2: ffffb050839f7000
[ 128.191122] ---[ end trace e93fcec97286f2fd ]---
[ 128.191124] RIP: 0010:0xffffb050839f7000
[ 128.191125] Code: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <00> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[ 128.191126] RSP: 0018:ffffb0508388fe08 EFLAGS: 00010283
[ 128.191127] RAX: ffffb050839120f0 RBX: ffffb05083a8f010 RCX: ffffb05083891000
[ 128.191128] RDX: ffffb05083911370 RSI: 0000000000000000 RDI: ffff8d0d83852790
[ 128.191129] RBP: ffffb0508388fe98 R08: 0000000000000001 R09: ffffedc080000000
[ 128.191129] R10: ffffffffc306a6e0 R11: 00008003265ae007 R12: 0000000000000024
[ 128.191130] R13: ffffffffc306a6e0 R14: 0000000000000000 R15: ffff8d0d83852790
[ 128.191131] FS: 00007f8f925fc700(0000) GS:ffff8d148eb80000(0000) knlGS:00000
  • 虽然设置了CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=y,还是可以通过设置kernel command line去关闭它的,这里修改如下:
1
2
3
4
5
6
7
8
~$ grep -v '^#\|^$'  /etc/default/grub

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="splash"
GRUB_CMDLINE_LINUX=".... mem_encrypt=off"
GRUB_GFXPAYLOAD_LINUX=keep
  • 关闭AMD SME之后,重启系统再次运行VirtualBox就能正常使用了, 关于AMD SME/SEVQEMU-KVM虚拟机支持的非常好。

Android连接USB时,MTP挂载错误.

  • 有时会出现如:error no such interface 'org.gtk.vfs.mount' on object at path /org/gtk/vfs/mount/1,可以重启系统,也可以尝试如下:
    • GNOME: killall nautilus
    • MATE: killall caja
    • Cinnamon: killall nemo

Samba4 共享问题(SMB/CIFS)

  • Samaba
  • SMB4与前面的版本有一些改动,如:原security = share改成了security = user ; map to guest = Bad User的组合.服务端与客户端的协议版本如果不匹配,也会无法握手连接.可以通过min protocol,client min|max protocol等参数定制.
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
26
grep -v '^#\|^$\|^;\|.*;' /etc/samba/smb.conf
[global]
workgroup = WORKGROUP
netbios name = debian(buster)
# Or set min protocol to NT1, SMB2/3
min protocol = LANMAN2
ea support = yes
interfaces = 127.0.0.0/8 192.168.1.0/24
hosts allow = 127.0.0.1/8 192.168.0.0/16
log file = /var/log/samba/log.%m
log level = 10
max log size = 1000
logging = file
#server role = standalone server
security = user
map to guest = Bad User
[Movies]
comment = Home Directories
path = /home/michael/3TB-DISK/AmuleDir/Incoming/
browseable = yes
available = yes
guest ok = yes
guest only = yes
public = yes
read only = yes

  • 重启,查看服务.

    1
    2
    3
    systemctl restart smbd nmbd
    systemctl status smbd nmbd

  • testparm查验配置文件.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    ~$ testparm
    Registered MSG_REQ_POOL_USAGE
    Registered MSG_REQ_DMALLOC_MARK and LOG_CHANGED
    Load smb config files from /etc/samba/smb.conf
    Processing section "[Movies]"
    Loaded services file OK.
    Server role: ROLE_STANDALONE

    Press enter to see a dump of your service definitions
  • 使用smbclient查看,可以加入-d<number 0-10>调试输出.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
smbclient -m SMB3 -N  -L 192.168.1.100
Unable to initialize messaging context
Anonymous login successful

Sharename Type Comment
--------- ---- -------
Movies Disk Home Directories
IPC$ IPC IPC Service (Samba 4.9.5-Debian)
Reconnecting with SMB1 for workgroup listing.
Anonymous login successful

Server Comment
--------- -------

Workgroup Master
--------- -------
WORKGROUP DEBIAN(BUSTER)

  • 调式smbd,nmbd输出,可以配置smb.conf里面的log level = <0-100>详细级别.
    1
    2
    ~$ smbd  -i -l -S
    ~$ nmbd -i -l -S
  • 错误Error NT_STATUS_IO_TIMEOUT,这个错误最终发现是因服务端系统设置造成的,Samba的配置并在服务端使用smbclient测试都OK,而且在Android手机端是可以查看共享,但是在Win10端与IPad不能连接.最后发现是服务端禁止了ping入造成的.修改成net.ipv4.icmp_echo_ignore_all = 0就可以连接了.

无法进虚拟终端的问题(Ctrl-Alt-f[1-6])

  • NVIDIA
  • NVIDIA/Tips and tricks
  • Kernel mode setting
  • The Framebuffer Console
  • 有时新安装了新的(Nvidia)显卡驱动后,发现无法切换到虚拟的终端里,只能使用Ctrl-Alt-F7的终端.确认一下/etc/default/grub内有如内容:
    1
    2
    3
    4
    5
    6
    7
    grep -v '^#\|^$' /etc/default/grub
    GRUB_DEFAULT=0
    GRUB_TIMEOUT=5
    GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
    GRUB_CMDLINE_LINUX_DEFAULT="splash"
    GRUB_CMDLINE_LINUX="resume=UUID=ae170b9d-832a-46a7-beca-5fb7c9329b1b nomodeset"
    GRUB_GFXPAYLOAD_LINUX=keep
  • 加入nomodeset,开启GRUB_GFXPAYLOAD_LINUX=keep后运行update-grub,重启系统可能会解决此问题.

一起无法重启networking服务的问题

1
2
3
~$ sudo systemctl restart networking.service
Job for networking.service failed because the control process exited with error code.
See "systemctl status networking.service" and "journalctl -xe" for details.
  • status
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
~$ sudo systemctl status networking.service
● networking.service - Raise network interfaces
Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2021-04-14 22:42:17 CST; 48s ago
Docs: man:interfaces(5)
Process: 10535 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
Main PID: 10535 (code=exited, status=1/FAILURE)

Apr 14 22:42:17 debian ifup[10535]: run-parts: executing /etc/network/if-up.d/avahi-autoipd
Apr 14 22:42:17 debian ifup[10535]: run-parts: executing /etc/network/if-up.d/dhcpcd
Apr 14 22:42:17 debian ifup[10535]: run-parts: executing /etc/network/if-up.d/ethtool
Apr 14 22:42:17 debian ifup[10535]: run-parts: executing /etc/network/if-up.d/ip
Apr 14 22:42:17 debian ifup[10535]: run-parts: executing /etc/network/if-up.d/mountnfs
Apr 14 22:42:17 debian ifup[10535]: run-parts: executing /etc/network/if-up.d/uml-utilities
Apr 14 22:42:17 debian ifup[10535]: run-parts: executing /etc/network/if-up.d/wpasupplicant
Apr 14 22:42:17 debian systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Apr 14 22:42:17 debian systemd[1]: networking.service: Failed with result 'exit-code'.
Apr 14 22:42:17 debian systemd[1]: Failed to start Raise network interfaces.

  • journatctl

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    sudo journalctl -u networking.service
    [...]
    Apr 14 19:26:20 debian ifup[916]: dnsmasq: failed to create listening socket for port 53: Address already in use
    Apr 14 19:26:20 debian dnsmasq[7338]: failed to create listening socket for port 53: Address already in use
    Apr 14 19:26:20 debian dnsmasq[7338]: FAILED to start up
    Apr 14 19:26:20 debian ifup[916]: ifup: failed to bring up wlan1
    [...]

    Apr 14 19:26:20 debian ifup[916]: run-parts: executing /etc/network/if-pre-up.d/wpasupplicant
    Apr 14 19:26:20 debian ifup[916]: /sbin/ip addr add 192.168.3.1/255.255.255.0 broadcast 192.168.3.255 dev wlan2 label wlan2
    Apr 14 19:26:20 debian ifup[916]: Cannot find device "wlan2"
    Apr 14 19:26:20 debian ifup[916]: ifup: failed to bring up wlan2
    Apr 14 19:26:20 debian ifup[916]: ifup: configuring interface br-lan=br-lan (inet)
    Apr 14 19:26:20 debian ifup[916]: ifup: missing required variable: address
    Apr 14 19:26:20 debian ifup[916]: ifup: missing required configuration variables for interface br-lan/inet
    Apr 14 19:26:20 debian ifup[916]: ifup: failed to bring up br-lan
    Apr 14 19:26:20 debian ifup[916]: ifup: configuring interface wlan0=wlan0 (inet)

  • search 53 service

    1
    2
    3
    4
    5
    ~$ sudo netstat -unlp | grep "53"
    udp 0 0 224.0.0.251:5353 0.0.0.0:* 27555/brave --type=
    udp 0 0 224.0.0.251:5353 0.0.0.0:* 27555/brave --type=
    udp 0 0 127.0.0.1:53 0.0.0.0:* 1/init
    udp6 0 0 ::1:53 :::* 1/init
1
2
3
4
5
6
7
8
 systemctl list-sockets | grep "53"
127.0.0.1:53 kresd.socket kresd@1.service
127.0.0.1:53 kresd.socket kresd@1.service
127.0.0.1:853 kresd-tls.socket kresd@1.service
[::1]:53 kresd.socket kresd@1.service
[::1]:53 kresd.socket kresd@1.service
[::1]:853 kresd-tls.socket kresd@1.service

  • 查看系统启动时的所有错误
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    ~$ systemctl --no-pager --all --state=failed
    UNIT LOAD ACTIVE SUB DESCRIPTION
    ● dokku-retire.service loaded failed failed Dokku retire service
    ● networking.service loaded failed failed Raise network interfaces
    ● rc-local.service loaded failed failed /etc/rc.local Compatibility
    ● systemd-modules-load.service loaded failed failed Load Kernel Modules

    LOAD = Reflects whether the unit definition was properly loaded.
    ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
    SUB = The low-level unit activation state, values depend on unit type.

    4 loaded units listed.
    To show all installed unit files use 'systemctl list-unit-files'.

让远端的GUI运行到本机界面

SSH X Forwarding

  • 这个比较简单,在/etc/ssh/sshd_config要有如下设置,再用要ssh -X user@<remote_host>登录,运行一个类X的程序,就会出现在本机.
1
2
3
AllowTcpForwarding yes
X11Forwarding yes
X11UseLocalhost yes
  • 一般以查看<remote_host>里的echo $DISPLAY变量是localhost:10.0.

X Server tcp

  • 这里以lightdm为例,其它:GDM,XDM类似.确保/etc/lightdm/lightdm.conf里有以下行

    1
    2
    3
    4
    5
    6
    7
    8
    ~$ grep -v '^#\|^$' /etc/lightdm/lightdm.conf
    [LightDM]
    [Seat:*]
    xserver-allow-tcp=true
    [XDMCPServer]
    enabled=true
    port=177
    [VNCServer]
  • 重启本机的lightdm服务.就会有发现Xservertcp listen. 一般来说使用SSH X Fowarding就可以满足很多场景需求.下面这个例就必须使用Xserver tcp,如果使用SSH X Forwarding就出现gtk initialization failed.

    1
    docker run  --device /dev/kvm    -e RAM=6 -p 50922:10022 -v $XAUTH:/root/.Xauthority -e DISPLAY=<remote_host>:0.0 docker-osx:latest
  • 上面两个方式还是提示无权连接时,在本机运行xhost +再测试.

Linux下IPv6路由丢失

  • Debian下面遇到过种,不知道过了多久,系统内wlan0网卡的IPv6路由不见,但是IPv6的地址还在.后来发现是sysctl配置的问题,配置成下面就解决了:
    1
    2
    net.ipv6.conf.default.autoconf = 0
    net.ipv6.conf.wlan0.autoconf = 0

Knot DNS缓存问题

  • 之前使用dnsmasqdhcp+dns同时还支持IPv6,不知何时dnsmasq启动时,提示53端口被占,检查发现还是被1/init进程占住.这里无法通过/proc/1/cmdline查找.通过find /usr/lib/systemd/system -exec grep -nH "127.0.0.1:53" {} \;发现在kresd.socket文件内有如下设置.
1
2
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      1/init
tcp 0 0 127.0.0.1:853 0.0.0.0:* LISTEN 1/init

Debian 10使用systemed运行/etc/rc.local开机自启命令

  • 创建systemed服务描述文件.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    ~$ cat>/etc/systemd/system/rc-local.service<<EOF
    [Unit]
    Description=/etc/rc.local Compatibility
    Documentation=man:systemd-rc-local-generator(8)
    ConditionFileIsExecutable=/etc/rc.local
    ConditionPathExists=/etc/rc.local
    [Service]
    Type=forking
    ExecStart=/etc/rc.local start
    TimeoutSec=0
    RemainAfterExit=yes
    StandardOutput=tty
    SysVStartPriority=99
    [Install]
    WantedBy=multi-user.target
    EOF
  • 创建运行脚本文件,可以把需要运行的命令加入到exit 0之前.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    ~$cat>/etc/rc.local<<EOF
    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.

    exit 0
    EOF
  • 分配运行权限,与开机自运行命令

    1
    2
    3
    4
    ~$ chmod +x /etc/rc.local
    ~$ systemctl enable rc-local
    ~$ systemctl start rc-local

Linux下安装Xrdp服务

  • Ubuntu 18.04: Connect to MATE desktop environment via XRDP
    1
    ~$ apt-get install xrdp
  • xRDP uses the /etc/ssl/private/ssl-cert-snakeoil.key
    file which belongs to the ssl-cert group. As such we need to add the xRDP user to that group:
    1
    ~$ sudo adduser xrdp ssl-cert
  • 如果出现Could not acquire name on session bus. 需要如下设置:
    1
    2
    3
    4
    cat <<EOF> ~/.xsession
    unset DBUS_SESSION_BUS_ADDRESS
    mate-session
    EOF

Linux下运行x11vnc

  • X11vnc

  • x11vnc可以支持共享与控制的功能.简单运行如下

    1
    ssh -t -L 5900:localhost:5900 remote_vnchost 'VNC_PASSWORD=123456 x11vnc -localhost -display :0'
  • 如遇到下面的错误.

    1
    2
    3
    4
    5
    27/09/2021 20:47:05 Xinerama: no blackouts needed (screen fills rectangle)
    27/09/2021 20:47:05
    27/09/2021 20:47:05 shmget(fullscreen) failed.
    27/09/2021 20:47:05 shmget: No space left on device

  • 查看内核设置

    1
    2
    3
    4
    5
    6
    7
    sudo sysctl -a | grep "shm"
    kernel.shm_next_id = -1
    kernel.shm_rmid_forced = 0
    kernel.shmall = 18446744073692774399
    kernel.shmmax = 18446744073692774399
    kernel.shmmni = 4096
    vm.hugetlb_shm_group = 0
  • 需要把kernel.shmmni增加到8192.

systemd

1
2
3
4
5
6
7
8
~$ cat /etc/systemd/system/x11vnc.service
[Service]
ExecStart=
ExecStart=/usr/bin/x11vnc -many -display :0 -auth /var/run/lightdm/root/:0

[Install]
WantedBy=graphical.target

rime同文输入法

  • Rime是一个跨平台的输入框架.它的核心(或者说’后端’)是librime引擎,不同平台的前端实现共用这个后端.目前在GitHub RIME组织中维护的前端实现有三个:
    用于 Windows 的 Weasel 「小狼毫」;
    用于 macOS 的 Squirrel 「鼠须管」;
    用于 Linux 的 ibus-rime 「中州韵」——Rime 本身的中文名字也叫「中州韵输入法引擎」.

  • 同步之后可以看到文件夹下的相关配置,基本上和桌面版的RIME是一致的:
    default.yaml,各输入方案共享的全局配置
    default.custom.yaml,(可选)对 default.yaml 的修改,不会随着客户端的更新而被覆盖,所以对default的修改可以通过patch的方式放入该配置文件
    xxx.schema.yaml,xxx 输入方案的配置
    xxx.custom.yaml,(可选)对 xxx.schema.yaml 的自定义修改
    xxx.dict.yaml, xxx 输入方案的词库(字典)

  • 这里主要是记录网上链接,各种配置与词库都是热心网友供献,你可以稍作修改,或者不作修改都能有很好的体验.如果自已有空也可以定制出自已的风格,且可以同步各种平台上使用.

  • Android 上的 RIME 输入法 trime 同文输入法使用

  • 使用 Trime 在 Android 上输入五笔

  • 同文安卓輸入法平臺/Trime: Rime IME for Android

  • RIME | 中州韻輸入法引擎

  • Rime 定製指南

  • Rime 输入法指北

Youtube-dl使用

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash

# youtube-dl -i --playlist-reverse -j --flat-playlist 'https://www.youtube.com/playlist?list=$1' | jq -r '.id + " # " + .title' | sed 's_^_https://youtube.com/v/_'
TMP_IFS=$IFS
IFS=$(echo -en "\n\b")
export UA='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/0123456789 Safari/537.36'
export https_proxy=http://127.0.0.1:8123
export http_proxy=http://127.0.0.1:8123
export DL=/usr/local/bin/youtube-dl
export SUBLANG="en"
alias ylp="/usr/local/bin/youtube-dl --user-agent '${UA}'"


function get_info()
{
${DL} --user-agent "${UA}" -F $1
}

function download_file()
{
echo "start download file from URL $1 with sub lang $SUBLANG"
URL=$(echo "$1" | awk -F'#' '{print $1}')
TITLE=$(echo "$1" | awk -F'#' '{print $2}')".mp4"
INFO=$(get_info ${URL})
AUDIO=$(printf "${INFO}" | grep "audio only"| awk 'END{print $1}')
VIDEO=$(printf "${INFO}" | grep "x1080" | awk 'END{print $1}')
AV=${VIDEO}+${AUDIO}
${DL} --user-agent "${UA}" -f $AV --sub-lang ${SUBLANG} --write-auto-sub --convert-subs=srt --external-downloader aria2c --external-downloader-args '-c -j 16 -x 16 -s 16 -k 10M' "$URL"
}

function download_list()
{
GET_PLAYLIST=$(${DL} -i --playlist-reverse -j --flat-playlist "https://www.youtube.com/playlist?list=$1" | jq -r '.id + "#" + .title')
echo "${GET_PLAYLIST}"
for line in ${GET_PLAYLIST};
do
download_file $line
done
}

if [[ -z $2 ]]; then
SUBLANG=$2
fi
case "${#1}" in
11) download_file $1;;
34) download_list $1;;
*)
echo "got wrong url length, exit.....";;
esac
IFS=$TMP_IFS

通过ADB安装程序到小米电视机

  • 一般旧的电视视MiTv通过设置设置-->账号与安全-->允许安装未知来源的应用后,再把相应的apk复现到U盘接入后,可以直选择到文件,进行安装。还有另一种方式,稍微麻烦一的。

  • 开启debug调式模式:设置-->关于-->产品型号遥控连续按5下OK键.打开后,界面有提示。再通过设置设置-->账号与安全-->允许ADB调试允许调试。下面就是adb的操作了。如:本电视机的IP是192.168.1.130

1
2
3
4
5
6
~$ adb connect 192.168.1.130:5555

$ adb devices
List of devices attached
192.168.1.130:5555 device

  • adb shell

  • 上传程序

1
~$ adb push kodi-20.1-Nexus-armeabi-v7a.apk /mnt/sdcard/Download
  • 安装程序
1
~$ adb install kodi-20.1-Nexus-armeabi-v7a.apk
  • 出现错误Failure [INSTALL_FAILED_OLDER_SDK],说明系统版本太旧,SDK不能兼容,旧的电视机只能安装降低版本的apk

HP笔记本TouchPad问题

  • Dell Precision 7550 physical mouse buttons behaving like clickpad

  • Clickpad left click not working on Ubuntu 20.04 when touchpad is not touched

  • 新装有笔记本的电脑的TouchPad不能轻敲代替点击,需要按下物理键才行。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    ~$ xinput list
    \u23a1 Virtual core pointer id=2 [master pointer (3)]
    \u239c \u21b3 Virtual core XTEST pointer id=4 [slave pointer (2)]
    \u239c \u21b3 SYNA30AA:00 06CB:CDEB Mouse id=12 [slave pointer (2)]
    \u239c \u21b3 SYNA30AA:00 06CB:CDEB Touchpad id=13 [slave pointer (2)]
    \u23a3 Virtual core keyboard id=3 [master keyboard (2)]
    \u21b3 Virtual core XTEST keyboard id=5 [slave keyboard (3)]
    \u21b3 Power Button id=6 [slave keyboard (3)]
    \u21b3 Video Bus id=7 [slave keyboard (3)]
    \u21b3 Video Bus id=8 [slave keyboard (3)]
    \u21b3 Power Button id=9 [slave keyboard (3)]
    \u21b3 Sleep Button id=10 [slave keyboard (3)]
    \u21b3 HP HD Camera: HP HD Camera id=11 [slave keyboard (3)]
    \u21b3 AT Translated Set 2 keyboard id=14 [slave keyboard (3)]
1
2
3
4
~$ xinput list-props "SYNA30AA:00 06CB:CDEB Touchpad" | grep -i click
Synaptics ClickPad (352): 1
Synaptics Click Action (364): 1, 0, 0

  • Synaptics ClickPad设置为0.就能正常使用了。
    1
    102  xinput set-prop "SYNA30AA:00 06CB:CDEB Touchpad" "Synaptics ClickPad" 0

Vim无法使用YouCompleteMe的插件

  • 已经进入到目录里并且安装:~/.vim/bundle/YouCompleteMe && ./install.py --all,但是运行还是出现如下的错误。
1
2
3
4
~$ vim
YouCompleteMe unavailable: requires Vim compiled with Python (3.8.0+) support.
Press ENTER or type command to continue

  • 进入vim,运行::echo has("python_dynamic"),:echo has("python_dynamic")都是返回0,说明没有加载到python,可以运行::help python-dynamic查看相关的帮助文档。
  • 运行vim --version查看详情
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
~$ vim --version
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled May 04 2023 10:24:44)
Included patches: 1-1378, 1499
Modified by team+vim@tracker.debian.org
Compiled by team+vim@tracker.debian.org
Huge version without GUI. Features included (+) or not (-):
+acl +file_in_path +mouse_urxvt -tag_any_white
+arabic +find_in_path +mouse_xterm -tcl
+autocmd +float +multi_byte +termguicolors
+autochdir +folding +multi_lang +terminal
-autoservername -footer -mzscheme +terminfo
-balloon_eval +fork() +netbeans_intg +termresponse
+balloon_eval_term +gettext +num64 +textobjects
-browse -hangul_input +packages +textprop
++builtin_terms +iconv +path_extra +timers
+byte_offset +insert_expand -perl +title
+channel +ipv6 +persistent_undo -toolbar
+cindent +job +popupwin +user_commands
-clientserver +jumplist +postscript +vartabs
-clipboard +keymap +printer +vertsplit
+cmdline_compl +lambda +profile +vim9script
+cmdline_hist +langmap -python +viminfo
+cmdline_info +libcall -python3 +virtualedit
+comments +linebreak +quickfix +visual
+conceal +lispindent +reltime +visualextra
+cryptv +listcmds +rightleft +vreplace
+cscope +localmap -ruby +wildignore
+cursorbind -lua +scrollbind +wildmenu
+cursorshape +menu +signs +windows
+dialog_con +mksession +smartindent +writebackup
+diff +modify_fname +sodium -X11
+digraphs +mouse -sound -xfontset
-dnd -mouseshape +spell -xim
-ebcdic +mouse_dec +startuptime -xpm
+emacs_tags +mouse_gpm +statusline -xsmp
+eval -mouse_jsbterm -sun_workshop -xterm_clipboard
+ex_extra +mouse_netterm +syntax -xterm_save
+extra_search +mouse_sgr +tag_binary
-farsi -mouse_sysmouse -tag_old_static
system vimrc file: "/etc/vim/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -Wdate-time -g -O2 -ffile-prefix-map=/build/vim-JA6Vy9/vim-9.0.1378=. -fstack-protector-strong -Wformat -Werror=format-security -DSYS_VIMRC_FILE=\"/etc/vim/vimrc\" -DSYS_GVIMRC_FILE=\"/etc/vim/gvimrc\" -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lm -ltinfo -lselinux -lsodium -lacl -lattr -lgpm

  • 上面显示-python,-python3. 安装apt-get install vim-nox vim-youcompleteme就能正常使用了。

谢谢支持