标签 shell 下的文章

“”

添加 WiFi 连接配置
wpa_passphrase {SSID} {PASSWORD} > /etc/wpa_supplicant/{SSID}.conf

其中 {SSID} 为无线网络的名称(即WiFi名称),{PASSWORD} 为 WiFi 密码。

连接无线网络
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/{SSID}.conf -B
看到 Successfully 字样就表示连接成功啦!

配置 DHCP 自动分配 IP
dhclient wlan06
查看是否连接成功
ifconfig

看到 wlan0 中已经有正常的 IP 地址了,说明网络连接已经建立。

验证能否正常上网
ping www.baidu.com -c 4

响应正常,说明可以正常上网了!

Referenced from:https://cloud.tencent.com/developer/article/1494772

将二进制数据放入文件中,然后将其作为消息发送:

mosquitto_pub -t test -f file

使用test.mosquitto.org测试数据发送

mosquitto_pub -L mqtt://test.mosquitto.org:1883/LSTS/debug -f doc/buf.bin -d

Client mosq-ZRfknutaDJCvdaPpYI sending CONNECT
Client mosq-ZRfknutaDJCvdaPpYI received CONNACK (0)
Client mosq-ZRfknutaDJCvdaPpYI sending PUBLISH (d0, q0, r0, m1, 'LSTS/debug', ... (35 bytes))
Client mosq-ZRfknutaDJCvdaPpYI sending DISCONNECT

订阅消息

mosquitto_sub -L mqtt://test.mosquitto.org:1883/LSTS/debug -d

Client mosq-Jrrv1j2it7SnqvdTVa sending CONNECT
Client mosq-Jrrv1j2it7SnqvdTVa received CONNACK (0)
Client mosq-Jrrv1j2it7SnqvdTVa sending SUBSCRIBE (Mid: 1, Topic: LSTS/debug, QoS: 0, Options: 0x00)
Client mosq-Jrrv1j2it7SnqvdTVa received SUBACK
Subscribed (mid: 1): 0
Client mosq-Jrrv1j2it7SnqvdTVa received PUBLISH (d0, q0, r0, m0, 'LSTS/debug', ... (35 bytes))

打印文件的十六进制数据用hexdump就可以了。也可以使用xxd.

示例:

hexdump -C certs/accert/ac.oer 

00000000 80 03 00 83 08 c7 95 5d 5e b0 fb 26 29 50 80 00 |.......]^..&)P..|
00000010 00 51 55 74 42 7f 2b 52 98 fe 6c 71 44 ba 00 0a |.QUtB.+R..lqD...|
00000020 21 0b b1 40 84 00 a9 83 01 01 80 00 9c 01 02 00 |!..@............|
00000030 01 6f 00 01 70 80 84 21 83 52 53 01 bc c2 2f 17 |.o..p..!.RS.../.|
00000040 d9 10 60 5a 03 32 3a e9 d4 eb 72 d7 f5 c1 15 bd |..`Z.2:...r.....|
00000050 99 84 a2 c2 27 a9 21 8e c0 84 40 ba 8d b1 6c 92 |....'.!...@...l.|
00000060 c6 41 b4 24 44 0d be ae 2e d4 4f 22 47 af 1b c2 |.A.$D.....O"G...|
00000070 bb 58 8b a2 db e8 b5 c7 03 20 b5 aa 15 22 53 83 |.X....... ..."S.|
00000080 73 22 7c f2 13 68 c9 2b 1f b5 22 37 f5 2e 30 81 |s"|..h.+.."7..0.|
00000090 55 a0 74 b1 38 d8 8b e2 f7 f4 d7 |U.t.8......|

xxd -p -u certs/accert/ac.oer 

8003008308C7955D5EB0FB262950800000515574427F2B5298FE6C7144BA
000A210BB1408400A983010180009C010200016F00017080842183525301
BCC22F17D910605A03323AE9D4EB72D7F5C115BD9984A2C227A9218EC084
40BA8DB16C92C641B424440DBEAE2ED44F2247AF1BC2BB588BA2DBE8B5C7
0320B5AA1522538373227CF21368C92B1FB52237F52E308155A074B138D8
8BE2F7F4D7

xxd -p -u -i certs/accert/ac.oer 

unsigned char certs_accert_ac_oer[] = {
0X80, 0X03, 0X00, 0X83, 0X08, 0XC7, 0X95, 0X5D, 0X5E, 0XB0, 0XFB, 0X26,
0X29, 0X50, 0X80, 0X00, 0X00, 0X51, 0X55, 0X74, 0X42, 0X7F, 0X2B, 0X52,
0X98, 0XFE, 0X6C, 0X71, 0X44, 0XBA, 0X00, 0X0A, 0X21, 0X0B, 0XB1, 0X40,
0X84, 0X00, 0XA9, 0X83, 0X01, 0X01, 0X80, 0X00, 0X9C, 0X01, 0X02, 0X00,
0X01, 0X6F, 0X00, 0X01, 0X70, 0X80, 0X84, 0X21, 0X83, 0X52, 0X53, 0X01,
0XBC, 0XC2, 0X2F, 0X17, 0XD9, 0X10, 0X60, 0X5A, 0X03, 0X32, 0X3A, 0XE9,
0XD4, 0XEB, 0X72, 0XD7, 0XF5, 0XC1, 0X15, 0XBD, 0X99, 0X84, 0XA2, 0XC2,
0X27, 0XA9, 0X21, 0X8E, 0XC0, 0X84, 0X40, 0XBA, 0X8D, 0XB1, 0X6C, 0X92,
0XC6, 0X41, 0XB4, 0X24, 0X44, 0X0D, 0XBE, 0XAE, 0X2E, 0XD4, 0X4F, 0X22,
0X47, 0XAF, 0X1B, 0XC2, 0XBB, 0X58, 0X8B, 0XA2, 0XDB, 0XE8, 0XB5, 0XC7,
0X03, 0X20, 0XB5, 0XAA, 0X15, 0X22, 0X53, 0X83, 0X73, 0X22, 0X7C, 0XF2,
0X13, 0X68, 0XC9, 0X2B, 0X1F, 0XB5, 0X22, 0X37, 0XF5, 0X2E, 0X30, 0X81,
0X55, 0XA0, 0X74, 0XB1, 0X38, 0XD8, 0X8B, 0XE2, 0XF7, 0XF4, 0XD7
};
unsigned int certs_accert_ac_oer_len = 155;

linux使用shell获取unix时间。
UNIX时间,或称POSIX时间是UNIX或类UNIX系统使用的时间表示方式:从UTC1970年1月1日0时0分0秒起至现在的总秒数,不考虑闰秒。 在多数Unix系统上Unix时间可以透过date +%s指令来检查。

date +%s

1630900618

查看任意时间的unixtime

date -s '2021-09-06 12:00:00' && date +%s
Mon Sep 6 12:00:00 CST 2021
1630900800

查看2004-1-1 00:00:00 的unixtime

date -s '2004-01-01 00:00:00' && date +%s

Thu Jan 1 00:00:00 CST 2004
1072886400

date 格式化时间

date '+%Y-%m-%d %H:%m:%S'

2021-09-06 11:09:48

date '+%F %H:%m:%S'

2021-09-06 11:09:57

date '+%F %T'

2021-09-06 12:00:43

date +%s.%N
where (GNU Coreutils 8.24 Date manual)

+%s, seconds since 1970-01-01 00:00:00 UTC
+%N, nanoseconds (000000000..999999999) since epoch

date +%s.%N

1630907594.542788384

apt-get install lm-sensors

sensors coretemp-isa-0000

coretemp-isa-0000
Adapter: ISA adapter
Package id 0: +41.0°C (high = +100.0°C, crit = +100.0°C)
Core 0: +39.0°C (high = +100.0°C, crit = +100.0°C)
Core 1: +39.0°C (high = +100.0°C, crit = +100.0°C)
Core 2: +39.0°C (high = +100.0°C, crit = +100.0°C)
Core 3: +38.0°C (high = +100.0°C, crit = +100.0°C)
Core 4: +40.0°C (high = +100.0°C, crit = +100.0°C)
Core 5: +39.0°C (high = +100.0°C, crit = +100.0°C)