File Management

Using Sys FileSystem In Linux

Using Sys FileSystem In Linux

Like a virtual proc file system, there is another file system called the “sysfs” file system in which the information has been exported in the Linux operating system. We can use this virtual file system for udev like programs for getting data regarding access devices and information regarding device drivers. Since most of the hardware knowledge being transferred through proc to sysfs, the advent of sysfs assisted in clearing up the proc system files. The sysfs file system has been deployed and configured on the /sys directory. We will take a look at some top-level directories of the sys file system. We have been using the Ubuntu 20.04 Linux system for the usage of the sysfs system. You can use any of the Linux operating systems to do so, as all the below queries will work on any distribution of Linux. Ensure you have the sudo user privileges to use your Linux operating system while using the sysfs file system. A short overview of each folder and directories is given  as follows:

/sys/block:

Each block device throughout the framework has an entry in this folder. Representational connections in the physical interface tree refer to the hardware machine to which the machine corresponds. Open the command-line shell using the “Ctrl+Alt+T” shortcut key to find out the information. The characteristics for the sda disks, for instance, are stored in the corresponding directory as shown in the query below. The output shows you the list of all the sda devices and their characteristics, e.g., usernames, privileges, names of files and folders, and many more.

$ ls -l  /sys/block/sda/

/sys/bus:

Every physical bus category provided by the kernel has its subdirectory in this folder. There are two sub-folders to every bus category: devices as well as drivers. Devices identified on that sort of bus are mentioned in the devices folder. Every device driver associated with the bus category has its directory in the driver's folder. The specifications of the driver could be interpreted and modified. For instance, to get a list of virtual system drivers, you have to type the below directory instruction in the terminal within the “Xen” directory. The output shows zero for the virtual system drivers because our Linux system has no virtual device driver.

$ ls -lR /sys/bus/xen/drivers

/sys/class:

Each device class associated mostly with the kernel can be found in this folder. A device class defines an operational category of a system. Input and network devices, block devices are only a few exceptions. There are many more found in it. Let's try the below simple path query to check. The output is showing us the list of input and output class directories.

$ ls -l /sys/class/

/sys/devices:

The global computer classification of all systems on the server is stored in this folder. There is also a framework folder and a device folder within that directory. Platform-specific peripheral devices, including certain computer controllers, are mentioned in the platform folder. Non-peripheral machines like CPUs or APICs are included in the system folder. Let's list all the information regarding devices using the below query in the shell.

$ ls -l /sys/devices/

/sys/firmware:

The firmware directory shows us the attributes and objects of firmware within the subdirectories of the firmware. Let's try the below instruction in the terminal shell to check for it. The output is showing only three subdirectories for firmware details and information.

$ ls -l /sys/firmware/

/sys/module:

If a Linux user wants to see the modules that are being loaded into the Linux kernel, they can use the module path for the sys file system. So, try out the below path query for the /sys/module to check it. The output below is showing the loaded module in the Linux kernel.

$ ls -l /sys/module/

/sys/module/xen*:

Going to the inner level of subdirectories, here is the more clear view of modules that are being loaded in the kernel. The below query output has been showing all the “Xen” modules that are loaded in the kernel.

$ ls -l /sys/module/xen*

To check each sub-module separately, try the below queries to do so. To check for “xen_netfront”, use the below query.

$ ls -l /sys/module/xen_netfront

To check for “xen_blkfront”, use the below query.

$ ls -l /sys/module/xen_blkfront

/sys/power:

This folder allows you to monitor the system's power level. The disk parameter regulates the mechanism through which the machine suspends disk storage. A mechanism will reach a low-power level using the state parameter. So, type the below query in the shell and hit the Enter button to see the details for power. The snapshot output shows the list of sys files showing the power information in the Linux operating system.

$ ls -l /sys/power

The sysctl package:

In the /proc/sys folder, users can use the sysctl function to display or change the values in the writable documents. Type the below command in the shell terminal and tap on the Enter key to get a list of all the latest kernel options. The output image is showing information regarding cdroms, their speed, their partitions, and many more.

$ sysctl -a

/proc/sys/abi:

Let's check for the “abi” folder using the simple list command. The below query has been used to list the files and folders of the “abi” directory in the proc/sys/ file system.

If somebody wants to see the separate information for each document in the specific directory “abi,” they can do so by using the cat command as below. This command has been checking the information held in the document “vsyscall32”. The output image is showing “1” as the content of a file vsyscall32.

$  cat /proc/sys/abi/vsyscall32

Conclusion:

This tutorial helps you see the internal information regarding the different aspects of the Linux operating system using the sysfs file system, e.g., Linux kernel information, hard disks information, power usage, and information, and firmware and system bus information, network, and input-output devices data, and drivers details, etc.

Jak używać Xdotool do stymulacji kliknięć myszą i naciśnięć klawiszy w systemie Linux?
Xdotool to darmowe i otwarte narzędzie wiersza poleceń do symulacji kliknięć myszą i naciśnięć klawiszy. Ten artykuł zawiera krótki przewodnik dotyczą...
5 najlepszych ergonomicznych myszy komputerowych dla systemu Linux
Czy długotrwałe korzystanie z komputera powoduje ból nadgarstka lub palców?? Cierpisz na sztywne stawy i ciągle musisz uścisnąć dłonie? Czy czujesz pa...
Jak zmienić ustawienia myszy i touchpada za pomocą Xinput w systemie Linux?
Większość dystrybucji Linuksa jest domyślnie dostarczana z biblioteką „libinput” do obsługi zdarzeń wejściowych w systemie. Może przetwarzać zdarzenia...