search
HomeOperation and MaintenanceLinux Operation and MaintenanceWhat are the functions of subfiles or subfolders in the Linux proc directory?

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

2. View system information and kernel parameters

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

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

4. 查看scsi设备信息

yafang@qa:~$ ls /proc/scsi
device_info  scsi

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:~#

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:~#

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:~#

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:~#

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

如果优化了参数,则可以把它们写成添加到文件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
This article is reproduced at:亿速云. If there is any infringement, please contact admin@php.cn delete
Linux Operations: System Administration and MaintenanceLinux Operations: System Administration and MaintenanceApr 15, 2025 am 12:10 AM

The key steps in Linux system management and maintenance include: 1) Master the basic knowledge, such as file system structure and user management; 2) Carry out system monitoring and resource management, use top, htop and other tools; 3) Use system logs to troubleshoot, use journalctl and other tools; 4) Write automated scripts and task scheduling, use cron tools; 5) implement security management and protection, configure firewalls through iptables; 6) Carry out performance optimization and best practices, adjust kernel parameters and develop good habits.

Understanding Linux's Maintenance Mode: The EssentialsUnderstanding Linux's Maintenance Mode: The EssentialsApr 14, 2025 am 12:04 AM

Linux maintenance mode is entered by adding init=/bin/bash or single parameters at startup. 1. Enter maintenance mode: Edit the GRUB menu and add startup parameters. 2. Remount the file system to read and write mode: mount-oremount,rw/. 3. Repair the file system: Use the fsck command, such as fsck/dev/sda1. 4. Back up the data and operate with caution to avoid data loss.

How Debian improves Hadoop data processing speedHow Debian improves Hadoop data processing speedApr 13, 2025 am 11:54 AM

This article discusses how to improve Hadoop data processing efficiency on Debian systems. Optimization strategies cover hardware upgrades, operating system parameter adjustments, Hadoop configuration modifications, and the use of efficient algorithms and tools. 1. Hardware resource strengthening ensures that all nodes have consistent hardware configurations, especially paying attention to CPU, memory and network equipment performance. Choosing high-performance hardware components is essential to improve overall processing speed. 2. Operating system tunes file descriptors and network connections: Modify the /etc/security/limits.conf file to increase the upper limit of file descriptors and network connections allowed to be opened at the same time by the system. JVM parameter adjustment: Adjust in hadoop-env.sh file

How to learn Debian syslogHow to learn Debian syslogApr 13, 2025 am 11:51 AM

This guide will guide you to learn how to use Syslog in Debian systems. Syslog is a key service in Linux systems for logging system and application log messages. It helps administrators monitor and analyze system activity to quickly identify and resolve problems. 1. Basic knowledge of Syslog The core functions of Syslog include: centrally collecting and managing log messages; supporting multiple log output formats and target locations (such as files or networks); providing real-time log viewing and filtering functions. 2. Install and configure Syslog (using Rsyslog) The Debian system uses Rsyslog by default. You can install it with the following command: sudoaptupdatesud

How to choose Hadoop version in DebianHow to choose Hadoop version in DebianApr 13, 2025 am 11:48 AM

When choosing a Hadoop version suitable for Debian system, the following key factors need to be considered: 1. Stability and long-term support: For users who pursue stability and security, it is recommended to choose a Debian stable version, such as Debian11 (Bullseye). This version has been fully tested and has a support cycle of up to five years, which can ensure the stable operation of the system. 2. Package update speed: If you need to use the latest Hadoop features and features, you can consider Debian's unstable version (Sid). However, it should be noted that unstable versions may have compatibility issues and stability risks. 3. Community support and resources: Debian has huge community support, which can provide rich documentation and

TigerVNC share file method on DebianTigerVNC share file method on DebianApr 13, 2025 am 11:45 AM

This article describes how to use TigerVNC to share files on Debian systems. You need to install the TigerVNC server first and then configure it. 1. Install the TigerVNC server and open the terminal. Update the software package list: sudoaptupdate to install TigerVNC server: sudoaptinstalltigervnc-standalone-servertigervnc-common 2. Configure TigerVNC server to set VNC server password: vncpasswd Start VNC server: vncserver:1-localhostno

Debian mail server firewall configuration tipsDebian mail server firewall configuration tipsApr 13, 2025 am 11:42 AM

Configuring a Debian mail server's firewall is an important step in ensuring server security. The following are several commonly used firewall configuration methods, including the use of iptables and firewalld. Use iptables to configure firewall to install iptables (if not already installed): sudoapt-getupdatesudoapt-getinstalliptablesView current iptables rules: sudoiptables-L configuration

Debian mail server SSL certificate installation methodDebian mail server SSL certificate installation methodApr 13, 2025 am 11:39 AM

The steps to install an SSL certificate on the Debian mail server are as follows: 1. Install the OpenSSL toolkit First, make sure that the OpenSSL toolkit is already installed on your system. If not installed, you can use the following command to install: sudoapt-getupdatesudoapt-getinstallopenssl2. Generate private key and certificate request Next, use OpenSSL to generate a 2048-bit RSA private key and a certificate request (CSR): openss

See all articles

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)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment