Linux Related
Subdirectories of Root Directory in Linux
Several subdirectories exist in the root directory. Some of them are listed below.
Directory | Description |
---|---|
/bin | It contains the essential binary files which are necessary for booting the system and running the basic commands. |
/boot | It contains the files needed for booting the system. |
/dev | It contains the device files for system devices such as hard drives, printers, and input-output devices. |
/etc | It contains system configuration files for various applications and services. |
/home | It contains the home directories of regular users. |
/lib | It contains the shared library files needed to run the programs on the system. |
/mnt | It is typically used as a mount point for temporarily mounting filesystems such as external hard drives, USB drives, and network file systems. |
/opt | It contains optional application software packages installed by the system administrator. |
/root | It contains the home directory of the root user. |
/sbin | It contains system binaries that are used for system administration tasks. |
/temp | It contains temporary files created by various programs and services on the system. |
/var | It contains variable data files such as log files and temporary files created by various programs and services on the system. |
dialout
sudo usermod -a -G dialout ${USERNAME}
根据标识符连接USB设备
-
查找设备的唯一标识符: 使用
udevadm
命令来查找设备的唯一标识符(如供应商 ID、产品 ID 和序列号)。udevadm info --name=/dev/ttyUSB0 --attribute-walk
这将显示设备的所有属性。查找包含
idVendor
、idProduct
和serial
的条目。 -
创建 udev 规则: 创建一个新的 udev 规则文件,例如 /etc/udev/rules.d/99-usb-serial.rules,并添加以下内容:
SUBSYSTEM=="tty", ATTRS{idVendor}=="XXXX", ATTRS{idProduct}=="YYYY", ATTRS{serial}=="ZZZZ", SYMLINK+="my_special_device"
将 XXXX 替换为设备的供应商 ID,将 YYYY 替换为设备的产品 ID,将 ZZZZ 替换为设备的序列号。my_special_device 是您希望为设备创建的符号链接名称。
-
重新加载 udev 规则: 重新加载 udev 规则并触发设备:
sudo udevadm control --reload-rules sudo udevadm trigger
-
在代码中使用符号链接: 在代码中使用符号链接名称来访问设备,而不是使用
/dev/ttyUSBX
。