Home Operation and Maintenance Linux Operation and Maintenance What are the functions of subfiles or subfolders in the Linux proc directory?

What are the functions of subfiles or subfolders in the Linux proc directory?

May 13, 2023 am 10:49 AM
linux proc

1. Linux /proc Directory Introduction
The Linux kernel provides a mechanism to access the internal data structures of the kernel and change kernel settings at runtime through the /proc file system. The proc file system is a pseudo file system that only exists in memory and does not occupy external memory space. It provides an interface for accessing system kernel data in the form of a file system.
Users and applications can obtain system information through proc and change certain parameters of the kernel. Since system information, such as processes, changes dynamically, when a user or application reads a proc file, the proc file system dynamically reads the required information from the system kernel and submits it. Not all of the files or subfolders listed below may exist on your system, depending on your kernel configuration and loaded modules. In addition, there are three very important directories under /proc: net, scsi and sys. The sys directory is writable and can be used to access or modify kernel parameters, while net and scsi depend on the kernel configuration. For example, if the system does not support scsi, the scsi directory does not exist.
In addition to the ones introduced above, there are also some directories named with numbers, which are process directories. Each process currently running in the system has a corresponding directory under /proc, with the pid number of the process as the directory name. They are the interfaces for reading process information. The self directory is the information interface for reading the process itself, which is a link.
2. The role of sub-files or sub-folders in the /proc directory
/proc/buddyinfo How many blocks are available for each order in each memory area is related to the memory fragmentation problem
/proc/cmdline Parameter information passed to the kernel at startup
/proc/cpuinfo cpu information
/proc/crypto All installed encryption passwords and details used by the kernel
/proc/devices Already Loaded devices and categories
/proc/dma List of isa dma channels registered for use
/proc/execdomains Execution domains currently supported by the Linux kernel
/proc/fb List of frame buffer devices, including number and control Its driver
/proc/filesystems The file system types currently supported by the kernel
/proc/interrupts The number of interrupts per irq in the x86 architecture
/proc/iomem The number of each physical device currently in system memory Mapping
/proc/ioports The registered port range used for the input and output of a device
/proc/kcore represents the physical memory of the system and is stored in core file format. The number of bytes displayed is equal to the ram size plus Up 4kb
/proc/kmsg records the information generated by the kernel, which can be processed through /sbin/klogd or /bin/dmesg
/proc/loadavg The load status based on the status of cpu and io in the past period of time , related to the uptime command
/proc/locks Kernel locked file list
/proc/mdstat Multiple hard drives, raid configuration information (md=multiple disks)
/proc/meminfo Ram usage related information
/proc/misc Drivers registered on other major devices (device number 10)
/proc/modules List of all modules loaded into the kernel
/proc/mounts All mounts used in the system
/proc/mtrr Memory type range registers (mtrrs) used by the system
/proc/partitions Block allocation information in the partition
/proc/pci PCI device list in the system
/proc/slabinfo System All active slab cache information
/proc/stat All cpu activity information
/proc/sysrq-trigger When using the echo command to write this file, the remote root user can execute most system request key commands. Just like executing in local terminal. To write to this file, /proc/sys/kernel/sysrq must not be set to 0. This file is also unreadable by root
/proc/uptime How long the system has been running
/proc/swaps Swap space usage
/proc/version Linux kernel version and gcc version
/proc /bus system bus (bus) information, such as pci/usb, etc.
/proc/driver driver information
/proc/fs file system information
/proc/ide ide device information
/proc/irq Interrupt request device information
/proc/net Network card device information
/proc/scsi scsi device information
/proc/tty tty device information
/proc/net/dev Display network adapter and statistical information
/proc/vmstat Virtual memory statistics
/proc/vmcore Memory image when kernel panics
/proc/diskstats Obtain disk information
/proc/schedstat Kernel scheduler statistics
/ proc/zoneinfo displays the statistical information of the memory space, which is useful for analyzing virtual memory behavior
The following is the information of process n in the /proc directory
/proc/n Process information with pid n
/proc/n /cmdline Process startup command
/proc/n/cwd Link to the current working directory of the process
/proc/n/environ Process environment variable list
/proc/n/exe Link to the execution command file of the process
/proc/n/fd contains all file descriptors related to the process
/proc/n/maps Memory mapping information related to the process
/proc/n/mem refers to the memory held by the process, Unreadable
/proc/n/root Link to the root directory of the process
/proc/n/stat The status of the process
/proc/n/statm The status of the memory used by the process
/proc/ n/status process status information, more readable than stat/statm
/proc/self links to the currently running process
3. Practical operation example
1. Column Export all files under /proc/

yafang@qa:~$ ls /proc/
1      16819  21242  2180   2494  8768         interrupts    partitions
116    16820  21244  2181   2524  885          iomem         sched_debug
11740  17901  21245  21810  2525  acpi         ioports       scsi
11742  17903  21247  21812  3     asound       irq           self
11743  17904  2131   21813  39    buddyinfo    kallsyms      slabinfo
13452  18362  21319  21923  4     bus          kcore         stat
13454  18364  2132   2193   41    cgroups      key-users     swaps
13455  18365  2139   21933  42    cmdline      kmsg          sys
149    19451  2142   2209   5     cpuinfo      kpagecount    sysrq-trigger
150    19453  21572  2212   5330  crypto       kpageflags    sysvipc
151    19454  21574  2219   596   devices      loadavg       timer_list
152    2      21575  2243   597   diskstats    locks         timer_stats
15771  2083   2158   2260   6     dma          meminfo       tty
15773  2092   21625  2261   617   driver       misc          uptime
15774  2101   21627  2262   619   execdomains  modules       version
16232  21112  21628  2263   7     fb           mounts        vmallocinfo
16234  21115  2165   2264   804   filesystems  mtrr          vmstat
16235  21116  2167   2265   8765  fs           net           zoneinfo
16811  2112   2177   2338   8767  ide          pagetypeinfo
Copy after login

2. View system information and kernel parameters

yafang@qa:~$ ls /proc/sys
debug  dev  fs  kernel  net  vm[code]
Copy after login

3. 查看网卡设备信息

[code]yafang@qa:~$ ls /proc/net
anycast6   ip6_flowlabel  netfilter  raw6       sockstat6     udplite
arp        ip6_mr_cache   netlink    route      softnet_stat  udplite6
dev        ip6_mr_vif     netstat    rt6_stats  stat          unix
dev_mcast  ip_mr_cache    packet     rt_acct    tcp           vlan
dev_snmp6  ip_mr_vif      protocols  rt_cache   tcp6          wireless
if_inet6   ipv6_route     psched     snmp       tr_rif
igmp       mcfilter       ptype      snmp6      udp
igmp6      mcfilter6      raw        sockstat   udp6
Copy after login

4. 查看scsi设备信息

yafang@qa:~$ ls /proc/scsi
device_info  scsi
Copy after login

5. 查看所有加载到内核的模块列表

root@bdsp-a-2-1-2:~# cat /proc/modules
bdspboard 8486 2 dspcontrol, live 0xe134c000
dspcontrol 9575 1 clkmon, live 0xe135b000
clkmon 6765 1 - live 0xe136c000
diagint 6635 1 - live 0xe1379000
bdsprio 10775 2 srioif,tsi577, live 0xe9389000
tsi577 17998 1 srioif, live 0xe939e000
srioif 7329 0 - live 0xe93b2000
linux_kernel_bde 54666 1 linux_user_bde, live 0xf1417000 (p)
linux_user_bde 17849 0 - live 0xf1427000 (p)
root@bdsp-a-2-1-2:~#
Copy after login

6. 查看已经加载的设备并分类

root@bcnmb-a:~# cat /proc/devicescharacter 
devices:  1 mem  2 pty  3 ttyp  4 /dev/vc/0  4 tty  4 ttys  5 /dev/tty  5 /dev/console  5 /dev/ptmx  7 vcs 10 misc 13 input 89 i2c 90 mtd116 linux-user-bde2117 linux-kernel-bde2126 linux-user-bde127 linux-kernel-bde128 ptm136 pts180 usb189 usb_device245 ext_alarm251 ipmidev252 usb_endpoint253 usbmon254 rtcblock devices:  1 ramdisk  8 sd 31 mtdblock 65 sd 66 sd 67 sd 68 sd 69 sd 70 sd 71 sd128 sd129 sd130 sd131 sd132 sd133 sd134 sd135 sd
root@bcnmb-a:~#
Copy after login

7. 查看分区中的块分配信息

root@bdsp-a-2-1-2:~# cat /proc/partitions
major minor  #blocks  name
  31        0        512 mtdblock0
  31        1        512 mtdblock1
  31        2     123904 mtdblock2
  31        3       4096 mtdblock3
  31        4       1024 mtdblock4
  31        5       1024 mtdblock5
  31        6        512 mtdblock6
  31        7        512 mtdblock7
  31        8     123904 mtdblock8
  31        9       4096 mtdblock9
  31       10       1024 mtdblock10
  31       11       1024 mtdblock11
  31       12    1048576 mtdblock12
root@bdsp-a-2-1-2:~#
Copy after login

8. 查看linux内核版本和gcc版本

root@bdsp-a-2-1-2:~# cat /proc/version
linux version 2.6.34.6-wr4.0.0.0_standard (satomi@charliebrown) (gcc version 4.4.1 (wind river linux sourcery g++ 4.4-291) ) #1 smp preempt fri nov 26 16:07:47 cst 2010
root@bdsp-a-2-1-2:~#
Copy after login

9. /proc/sys/fs/file-max
该文件指定了可以分配的文件句柄的最大数目。如果用户得到的错误消息声明由于打开文件数已经达到了最大值,从而他们不能打开更多文件,则可能需要增加该值。可将这个值设置成有任意多个文件,并且能通过将一个新数字值写入该文件来更改该值。默认设置时4096。
改变内核的参数,用vi编辑或echo参数重定向到文件中。

# cat /proc/sys/fs/file-max
4096
# echo 8192 > /proc/sys/fs/file-max
# cat /proc/sys/fs/file-max
8192
Copy after login

如果优化了参数,则可以把它们写成添加到文件rc.local中,使它在系统启动时自动完成修改。

其它例子:

1:[root@gechong proc]# more /proc/cmdline
显示了内核启动的命令行
2:[root@gechong proc]# cat /proc/cpuinfo
显示了cpu信息
3:[root@gechong proc]# cat /proc/devices
显示了字符和块设备的主设备号以及分配到这些设备号的设备名称
4:[root@gechong proc]# cat /proc/dma
显示了驱动程序保留的dma通道和保留它们的驱动程序名称
5:[root@gechong proc]# more /proc/filesystems
显示了可供使用的文件系统类型,一种类型一行
6:[root@gechong proc]# more /proc/interrupts
每一行都有一个保留的中断,内容是:中断号 中断次数 登记中断的驱动程序名称
7:[root@gechong proc]# more /proc/ioports
显示了i/o相关的设备驱动器例如磁盘驱动器、以太网卡、声卡设备等

The above is the detailed content of What are the functions of subfiles or subfolders in the Linux proc directory?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

deepseek web version entrance deepseek official website entrance deepseek web version entrance deepseek official website entrance Feb 19, 2025 pm 04:54 PM

DeepSeek is a powerful intelligent search and analysis tool that provides two access methods: web version and official website. The web version is convenient and efficient, and can be used without installation; the official website provides comprehensive product information, download resources and support services. Whether individuals or corporate users, they can easily obtain and analyze massive data through DeepSeek to improve work efficiency, assist decision-making and promote innovation.

How to install deepseek How to install deepseek Feb 19, 2025 pm 05:48 PM

There are many ways to install DeepSeek, including: compile from source (for experienced developers) using precompiled packages (for Windows users) using Docker containers (for most convenient, no need to worry about compatibility) No matter which method you choose, Please read the official documents carefully and prepare them fully to avoid unnecessary trouble.

How to solve the permissions problem encountered when viewing Python version in Linux terminal? How to solve the permissions problem encountered when viewing Python version in Linux terminal? Apr 01, 2025 pm 05:09 PM

Solution to permission issues when viewing Python version in Linux terminal When you try to view Python version in Linux terminal, enter python...

BITGet official website installation (2025 beginner's guide) BITGet official website installation (2025 beginner's guide) Feb 21, 2025 pm 08:42 PM

BITGet is a cryptocurrency exchange that provides a variety of trading services including spot trading, contract trading and derivatives. Founded in 2018, the exchange is headquartered in Singapore and is committed to providing users with a safe and reliable trading platform. BITGet offers a variety of trading pairs, including BTC/USDT, ETH/USDT and XRP/USDT. Additionally, the exchange has a reputation for security and liquidity and offers a variety of features such as premium order types, leveraged trading and 24/7 customer support.

Get the gate.io installation package for free Get the gate.io installation package for free Feb 21, 2025 pm 08:21 PM

Gate.io is a popular cryptocurrency exchange that users can use by downloading its installation package and installing it on their devices. The steps to obtain the installation package are as follows: Visit the official website of Gate.io, click "Download", select the corresponding operating system (Windows, Mac or Linux), and download the installation package to your computer. It is recommended to temporarily disable antivirus software or firewall during installation to ensure smooth installation. After completion, the user needs to create a Gate.io account to start using it.

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Ouyi okx installation package is directly included Ouyi okx installation package is directly included Feb 21, 2025 pm 08:00 PM

Ouyi OKX, the world's leading digital asset exchange, has now launched an official installation package to provide a safe and convenient trading experience. The OKX installation package of Ouyi does not need to be accessed through a browser. It can directly install independent applications on the device, creating a stable and efficient trading platform for users. The installation process is simple and easy to understand. Users only need to download the latest version of the installation package and follow the prompts to complete the installation step by step.

Ouyi Exchange Download Official Portal Ouyi Exchange Download Official Portal Feb 21, 2025 pm 07:51 PM

Ouyi, also known as OKX, is a world-leading cryptocurrency trading platform. The article provides a download portal for Ouyi's official installation package, which facilitates users to install Ouyi client on different devices. This installation package supports Windows, Mac, Android and iOS systems. Users can choose the corresponding version to download according to their device type. After the installation is completed, users can register or log in to the Ouyi account, start trading cryptocurrencies and enjoy other services provided by the platform.

See all articles