linux常用命令(持续更新)

网络相关

nmcli

1. 显示网卡信息:

xxxxxxxx:~$ nmcli
usb0: 已连接 到 有线连接 2
        "Huawei ANA-AN00"
        ethernet (rndis_host), CA:70:96:XX:XX:D1, 硬件, mtu 1500
        ip4 默认, ip6 默认
        inet4 192.168.42.44/24
        route4 0.0.0.0/0
        route4 192.168.42.0/24
        route4 169.254.0.0/16
        inet6 2409:8902:9344:fb2f:4910:c7fe:32bf:518f/64
        inet6 2409:8902:9344:fb2f:2ec5:a811:ddcf:d609/64
        inet6 fe80::b6cd:757c:3c7a:f90/64
        route6 2409:8902:9344:fb2f::/64
        route6 ::/0
        route6 ff00::/8
        route6 fe80::/64

docker0: 已连接 到 docker0
        "docker0"
        bridge, 02:42:80:BA:00:8F, 软件, mtu 1500
        inet4 172.18.0.1/16
        route4 172.18.0.0/16

enp2s0: 已断开
        "Realtek RTL8111/8168/8411"
        1 连接可用
        ethernet (r8169), 6C:4B:90:XX:XX:32, 硬件, mtu 1500

lo: 未托管
        "lo"
        loopback (unknown), 00:00:00:00:00:00, 软件, mtu 65536

DNS configuration:
        servers: 192.168.42.129
        interface: usb0

        servers: 2409:8902:9344:fb2f::49
        interface: usb0

使用 "nmcli device show" 获取关于已知设备的完整信息,以及 
"nmcli connection show" 获取活动连接配置集的概述。

完整的用法细节,可参考 nmcli(1) 和 nmcli-examples(7) 手册页。

2. 查看网络接口信息

xxxxxxxx:~$ nmcli con
NAME        UUID                                  TYPE      DEVICE  
有线连接 2  2e4db35a-baf1-367d-942d-831cd2870f64  ethernet  usb0    
docker0     ddef3eb8-2150-4aad-9580-664a0e533007  bridge    docker0 
有线连接 1  58487337-73c4-31b9-b473-40a5b50d5e4d  ethernet  --    
xxxxxxxxxx:~$ nmcli con show --active
NAME        UUID                                  TYPE      DEVICE  
有线连接 2  2e4db35a-baf1-367d-942d-831cd2870f64  ethernet  usb0    
docker0     ddef3eb8-2150-4aad-9580-664a0e533007  bridge    docker0 

3. 启动关闭网络

xxxxxxxxxxx:~$ nmcli con up 有线连接\ 1
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/6)

xxxxxxxxxxx:~$ nmcli con show --active
NAME        UUID                                  TYPE      DEVICE  
有线连接 2  2e4db35a-baf1-367d-942d-831cd2870f64  ethernet  usb0    
有线连接 1  58487337-73c4-31b9-b473-40a5b50d5e4d  ethernet  enp2s0  
docker0     ddef3eb8-2150-4aad-9580-664a0e533007  bridge    docker0 

xxxxxxxxxxx:~$ nmcli con down 有线连接\ 1
成功停用连接 "有线连接 1"(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/6)

xxxxxxxxxxx:~$ nmcli con show --active
NAME        UUID                                  TYPE      DEVICE  
有线连接 2  2e4db35a-baf1-367d-942d-831cd2870f64  ethernet  usb0    
docker0     ddef3eb8-2150-4aad-9580-664a0e533007  bridge    docker0 

输入设备管理

xinput

1. xinput/xinput list 列出input设备

xxxxxxxxxxxxxxxxxxx$ xinput
⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ Elan Lenovo USB Optical Mouse           	id=10	[slave  pointer  (2)]
⎜   ↳ uinput-custom-dev                       	id=14	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ Power Button                            	id=6	[slave  keyboard (3)]
    ↳ Video Bus                               	id=7	[slave  keyboard (3)]
    ↳ Power Button                            	id=8	[slave  keyboard (3)]
    ↳ Sleep Button                            	id=9	[slave  keyboard (3)]
    ↳ LiteOn Lenovo Traditional USB Keyboard  	id=11	[slave  keyboard (3)]
    ↳ LiteOn Lenovo Traditional USB Keyboard System Control	id=12	[slave  keyboard (3)]
    ↳ LiteOn Lenovo Traditional USB Keyboard Consumer Control	id=13	[slave  keyboard (3)]
    ↳ uinput-custom-dev                       	id=15	[slave  keyboard (3)]

2. xinput list-props 12 查看id=12的设备状态

xxxxxxxxxxxxxxxxxxxxxxxxxx$ xinput list-props 12
Device 'LiteOn Lenovo Traditional USB Keyboard System Control':
	Device Enabled (183):	1
	Coordinate Transformation Matrix (185):	1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
	libinput Send Events Modes Available (305):	1, 0
	libinput Send Events Mode Enabled (306):	0, 0
	libinput Send Events Mode Enabled Default (307):	0, 0
	Device Node (308):	"/dev/input/event6"
	Device Product ID (309):	6127, 24729

3. xinput disable 12 禁用设备

4. xinput enable 12 启用设备

查看与event对应的设备信息

xxxxxxxxxxxxxxxxxxxxx$ cat /proc/bus/input/devices
I: Bus=0019 Vendor=0000 Product=0003 Version=0000
N: Name="Sleep Button"
P: Phys=PNP0C0E/button/input0
S: Sysfs=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0E:00/input/input0
U: Uniq=
H: Handlers=kbd event0 
B: PROP=0
B: EV=3
B: KEY=4000 0 0

I: Bus=0019 Vendor=0000 Product=0001 Version=0000
N: Name="Power Button"
P: Phys=PNP0C0C/button/input0
S: Sysfs=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input1
U: Uniq=
H: Handlers=kbd event1 
B: PROP=0
B: EV=3
B: KEY=10000000000000 0

I: Bus=0019 Vendor=0000 Product=0001 Version=0000
N: Name="Power Button"
P: Phys=LNXPWRBN/button/input0
S: Sysfs=/devices/LNXSYSTM:00/LNXPWRBN:00/input/input2
U: Uniq=
H: Handlers=kbd event2 
B: PROP=0
B: EV=3
B: KEY=10000000000000 0

I: Bus=0019 Vendor=0000 Product=0006 Version=0000
N: Name="Video Bus"
P: Phys=LNXVIDEO/video/input0
S: Sysfs=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/LNXVIDEO:00/input/input3
U: Uniq=
H: Handlers=kbd event3 
B: PROP=0
B: EV=3
B: KEY=3e000b00000000 0 0 0

I: Bus=0003 Vendor=17ef Product=608d Version=0111
N: Name="Elan Lenovo USB Optical Mouse"
P: Phys=usb-0000:00:14.0-8/input0
S: Sysfs=/devices/pci0000:00/0000:00:14.0/usb1/1-8/1-8:1.0/0003:17EF:608D.0001/input/input4
U: Uniq=
H: Handlers=mouse0 event4 
B: PROP=0
B: EV=17
B: KEY=70000 0 0 0 0
B: REL=903
B: MSC=10

I: Bus=0003 Vendor=17ef Product=6099 Version=0111
N: Name="LiteOn Lenovo Traditional USB Keyboard"
P: Phys=usb-0000:00:14.0-9/input0
S: Sysfs=/devices/pci0000:00/0000:00:14.0/usb1/1-9/1-9:1.0/0003:17EF:6099.0002/input/input5
U: Uniq=
H: Handlers=sysrq kbd event5 leds 
B: PROP=0
B: EV=120013
B: KEY=1000000000007 ff9f207ac14057ff febeffdfffefffff fffffffffffffffe
B: MSC=10
B: LED=7

I: Bus=0003 Vendor=17ef Product=6099 Version=0111
N: Name="LiteOn Lenovo Traditional USB Keyboard System Control"
P: Phys=usb-0000:00:14.0-9/input1
S: Sysfs=/devices/pci0000:00/0000:00:14.0/usb1/1-9/1-9:1.1/0003:17EF:6099.0003/input/input6
U: Uniq=
H: Handlers=kbd event6 
B: PROP=0
B: EV=13
B: KEY=c000 10000000000000 0
B: MSC=10

使用hexdump读取input设备

xxxxxxxxxxxxxxxxxx$ sudo hexdump /dev/input/event4
0000000 3d8d 6058 0000 0000 09ca 000f 0000 0000
0000010 0002 0001 ffff ffff 3d8d 6058 0000 0000
0000020 09ca 000f 0000 0000 0000 0000 0000 0000
0000030 3d8d 6058 0000 0000 290c 000f 0000 0000
0000040 0002 0001 ffff ffff 3d8d 6058 0000 0000
0000050 290c 000f 0000 0000 0000 0000 0000 0000
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值