Linux file structure - information and settings related to network interface devices

1. Linux file structure

  • /bin : Stores binary files of executable commands.
  • /boot : stores the kernel and boot files needed to start the system.
  • /dev : Contains device files for interacting with hardware devices.
  • /etc : stores the configuration files of the system.
  • /home : Every user's home directory is located here.
  • /lib : store system library files for use by executable programs.
  • /media : The default mount point, used to temporarily mount removable media devices, such as CDs, USB drives, etc.
  • /mnt : Used to temporarily mount other file systems.
  • /opt : Holds optional components for third-party applications.
  • /proc : A virtual filesystem that provides information about running processes.
  • /root : The home directory of the superuser (root).
  • /sbin : Stores binary files for system management commands.
  • /srv : Stores data related to a specific service.
  • /tmp : Store temporary files.
  • /usr : Stores shareable read-only data, including user applications, library files, and documents.
  • /var : Store frequently changing data, such as log files, cache, and mail.
  • /sys: Interface for storing information about the system and device drivers. It provides access to the system kernel and allows users and applications to interact with the system hardware.

2. sys directory

  • /sys/block: This directory contains information about block devices (such as hard disks), and each device exists in the form of a subdirectory.
  • /sys/class: This directory contains category information of various devices, such as network devices, input devices, USB devices, etc.
  • /sys/devices: This directory contains the hierarchical structure information of all devices on the system, and each device exists in the form of a subdirectory.
  • /sys/bus: This directory contains information on different types of buses, such as PCI, USB, etc.
  • /sys/fs: This directory contains information related to the file system, such as the parameter settings of the root file system, etc.
  • /sys/kernel: This directory contains information related to the kernel, such as kernel configuration options, debugging interfaces, etc.
  • /sys/power: This directory contains information related to power management.

3. sys/class directory

  • /sys/class/net: This directory stores the information of all network devices in the system. For example, network interfaces such as eth0 and wlan0 will have a corresponding subdirectory under this directory.
  • /sys/class/block: This directory stores information about all block devices (such as hard disks and flash drives) in the system. Each block device will have a corresponding subdirectory. The name of the subdirectory starts with the letter "sd", followed by a letter, such as sda, sdb, etc.
  • /sys/class/gpio: This directory is used to access general-purpose input/output (GPIO) pins. Each GPIO pin has a corresponding subdirectory. The name of the subdirectory starts with gpio, followed by the specific pin number, such as gpio1, gpio2, etc.
  • /sys/class/power_supply: This directory stores the information of all power supply devices in the system. For example, AC adapters and batteries will have a corresponding subdirectory in this directory.

4. The sys/class/net directory (used to store information related to network devices, will contain subdirectories for each network interface, and the name of each subdirectory corresponds to a specific network interface)

Within each subdirectory, the following files and directories are typically included:

  • address: This file contains the physical address (MAC address) of the network interface.
  • carrier: This file indicates the link connection status of the network interface, 1 means connected, 0 means not connected.
  • dev_id: This file contains the device ID of the network interface.
  • dev_port: This directory contains port information related to network interfaces.
  • duplex: This file identifies the working mode of the network interface, such as full duplex (full) or half duplex (half).
  • ifalias: This file contains alias settings for network interfaces.
  • ifindex: This file contains the index number of the network interface.
  • mtu: This file contains the maximum transmission unit (MTU) size of the network interface.
  • operstate: This file indicates the operational state of the network interface, such as up (enabled) or down (disabled).
  • speed: This file contains the speed information of the network interface.

example

/sys/class/net/eth0
/sys/class/net/wlan0
/sys/class/net/lo
eth0indicates the Ethernet interface, wlan0indicates the wireless LAN interface, and loindicates the loopback interface (localhost). These subdirectories contain files and directories related to the corresponding interface, such as configuration files, status information, and so on.

5. /sys/class/net/eth0 (usually contains information and configuration related to the network interface "eth0")

  • address: Contains the physical address (MAC address) of the Ethernet interface eth0.
  • carrier: Indicates whether the Ethernet interface is connected to the network (1 means connected, 0 means not connected).
  • device: A symbolic link pointing to the device associated with the ethernet interface eth0.
  • duplex: Indicates the duplex mode (full duplex or half duplex) of the Ethernet interface eth0.
  • flags: List the flags and status information of the Ethernet interface eth0, such as UP (enabled), BROADCAST (broadcast), etc.
  • ifalias: Alias ​​for Ethernet interface eth0 (if any).
  • mtu: The maximum transmission unit (Maximum Transmission Unit) size of the Ethernet interface eth0.
  • operstate: Indicates the operating status of the Ethernet interface eth0, such as UP, DOWN, UNKNOWN, etc.
  • speed: The connection speed of the Ethernet interface eth0.

6. /sys/class/net/eth0/device directory (stores eth0information and settings related to network interface devices)

  • driver: This directory contains information about the driver, such as the path to the driver module, version number, etc.
  • uevent: This file contains event information about the device, such as notifications for plugging in or removing the device.
  • irq: This file indicates the Interrupt Request (IRQ) number associated with the device.
  • resource: This file contains information about the resources used by the device, such as memory addresses and I/O ports.
  • power: This directory contains files and subdirectories related to device power management, which can control the power state of the device.
  • modalias: This file contains an identifier that identifies the device's type and vendor information.
  • dev: This file contains the major and minor device numbers for the device.
  • subsystem: This directory contains information related to the subsystem to which the device belongs.

Guess you like

Origin blog.csdn.net/weixin_45981798/article/details/131842343