好资料,有时间翻译。 Linux System Configuration and the proc filesystem The /proc filesystem /proc文件系统是被用来存储许多系统配置参数。它是一个基于内核内存的虚拟文件系统。在该文件系统中有些文件是不能被root用户进行写的包括/proc/sys。下面的一些信息是来自于man页。/proc文件系统包括以下元素:
The /proc filesystem is used to store many system configuration parameters. It is a virtual filesystem that resides in the kernels memory. Some of the areas in this filesystem cannot be written to by the root user including /proc/sys. Much information here is based on the proc man page. Fro more information refer to that page. Elements of the proc filesystem include:
在/proc下,每个进程都存在一个以pid为名称的目录。下面是每个进程目录中包含的
1. cmdline - 该进程被调用时使用的命令行
2. cwd - 一个指向进程当前工作路径的链接
3.environ - 进程的环境
4.exe - 一个指向被运行的二进制文件的链接
5.fd - 一个目录,包含进程打开的标准输入,标准输出,标准错误
6.maps - 包含当前映射内存区域和他们的访问权限 格式如下:
address perms offset dev idnode filename 08048000-0804e000 r-xp 00000400 0302 192233 /sbin/init 0804e000-0804f000 rw-p 00005000 0302 192233 /sbin/init Permission s=private, s=shared
Numerical subdirectories exist for every process. The following files or directories are contained in each processes directory:
cmdline - The command line the process was invoked with cwd - A link to the current working directory of the process environ - The process environment exe - A pointer appearing as a symbolic link to the binary that was executed. fd - A subdirectory with one entry per file that the process has open. 0-std input, 1-std output, 2-std err. maps - Contains the currently mapped memory regions and their access permissions. The format is: address perms offset dev idnode filename 08048000-0804e000 r-xp 00000400 0302 192233 /sbin/init 0804e000-0804f000 rw-p 00005000 0302 192233 /sbin/init Permission s=private, s=shared
mem - The memory of the process that accesses the /dev/mem device root - Points to the root filesystem stat - Status information about the process used by the ps(1) command. Fields are:
pid - Process id comm - The executable filename state - R (running), S(sleeping interruptable), D(sleeping), Z(zombie), or T(stopped on a signal). ppid - Parent process ID pgrp - Process group ID session - The process session ID. tty - The tty the process is using tpgid - The process group ID of the owning process of the tty the current process is connected to. flags - Process flags, currently with bugs minflt - Minor faults the process has made cminflt - Minor faults the process and its children have made. majflt cmajflt utime - The number of jiffies (processor time) that this process has been scheduled in user mode stime - in kernel mode cutime - This process and its children in user mode cstime - in kernel mode counter - The maximum time of this processes next time slice. priority - The priority of the nice(1) (process priority) value plus fifteen. timeout - The time in jiffies of the process's next timeout. itrealvalue - The time in jiffies before the next SIGALRM is sent to the process because of an internal timer. starttime - Time the process started after system boot vsize - Virtual memory size rlim - Current limit in bytes of the rss of the process. startcode - The address above which program text can run. endcode - The address below which program text can run. startstack - The address of the start of the stack kstkesp - The current value of esp for the process as found in the kernel stack page. kstkeip - The current 32 bit instruction pointer, EIP. signal - The bitmap of pending signals blocked - The bitmap of blocked signals sigignore - The bitmap of ignored signals sigcatch - The bitmap of catched signals wchan - The channel in which the process is waiting. The "ps -l" command gives somewhat of a list. apm - A file containing the string "1.9 1.2 0x07 0x01 0xff 0x80 -1% -1 ?" on my system. bus - A directory
cmdline - The command line at system startup. My file contains "auto BOOT_IMAGE=rhl ro root=302". cpuinfo - CPU architecture information devices - Text listing of major numbers and device groups dma - A list of ISA direct memory access channels in use. fb - On my system, this file is empty filesystems - A text listing of the filesystems compiled into the kernel. The file on my system: ext2 nodev proc iso9660 nodev autofs nodev devpts vfat nodev ncpfs fs - A directory
nfs - A directory
exports - A file containing information similar to that in the /etc/exports file. My listing: # Version 1.0 # Path Client(Flags) # IPs /tftpboot/lts/ltsroot linux1(ro,no_root_squash,async,wdelay) # 192.168.200.201 /tftpboot/lts/ltsroot linux3(ro,no_root_squash,async,wdelay) # 192.168.200.203 /tftpboot/lts/ltsroot linux2(ro,no_root_squash,async,wdelay) # 192.168.200.202 time-diff-margin - A file containing a numerical string value. On my system it is "10". ide - A directory containing information on ide devices.
interrupts - The number of interrupts per IRQ. ioports - A list of currently registered input-output port regions that are in use. kcore - Represents the physical memory of the system stored in the core format. kmsg - This file can be used to log system messages. ksyms - Holds the kernel exported symbol definitions used by the modules(X) tools to dynamically link and bind loadable modules. loadavg - Load average numbers malloc - Present if CONFIGDEBUGMALLOC was defined during kernel compilation. locks - The file on my system: 1: POSIX ADVISORY WRITE 853 03:02:260062 0 2147483647 c228ba40 00000000 c228b5c0 00000000 00000000 2: POSIX ADVISORY WRITE 766 03:02:324064 0 0 c228b5c0 c228ba40 c228b560 00000000 00000000 3: POSIX ADVISORY WRITE 755 03:02:323503 0 0 c228b560 c228b5c0 c3ef6de0 00000000 00000000 4: POSIX ADVISORY WRITE 735 03:02:260034 0 2147483647 c3ef6de0 c228b560 c3ef6ba0 00000000 c3103f44 4: -> POSIX ADVISORY WRITE 734 03:02:260034 0 2147483647 c3103f44 00000000 00000000 00000000 c2837f44 4: -> POSIX ADVISORY WRITE 733 03:02:260034 0 2147483647 c2837f44 00000000 00000000 00000000 c2345f44 4: -> POSIX ADVISORY WRITE 737 03:02:260034 0 2147483647 c2345f44 00000000 00000000 00000000 c233bf44 4: -> POSIX ADVISORY WRITE 738 03:02:260034 0 2147483647 c233bf44 00000000 00000000 00000000 c2331f44 4: -> POSIX ADVISORY WRITE 739 03:02:260034 0 2147483647 c2331f44 00000000 00000000 00000000 c2325f44 4: -> POSIX ADVISORY WRITE 740 03:02:260034 0 2147483647 c2325f44 00000000 00000000 00000000 c2305f44 4: -> POSIX ADVISORY WRITE 743 03:02:260034 0 2147483647 c2305f44 00000000 00000000 00000000 c230ff44 4: -> POSIX ADVISORY WRITE 742 03:02:260034 0 2147483647 c230ff44 00000000 00000000 00000000 c231bf44 4: -> POSIX ADVISORY WRITE 741 03:02:260034 0 2147483647 c231bf44 00000000 00000000 00000000 c3ef6de0 5: FLOCK ADVISORY WRITE 0 03:02:51547 0 2147483647 c3ef6ba0 c3ef6de0 c3ef6a80 00000000 00000000 6: FLOCK ADVISORY WRITE 0 03:02:259912 0 2147483647 c3ef6a80 c3ef6ba0 c3ef6a20 00000000 00000000 7: POSIX ADVISORY WRITE 459 03:02:259911 0 2147483647 c3ef6a20 c3ef6a80 00000000 00000000 00000000 mdstat - The file on my system: Personalities : read_ahead not set md0 : inactive md1 : inactive md2 : inactive md3 : inactive meminfo - Used by free(1) to report memory usage. misc - The file on my system: 135 rtc 134 apm 1 psaux modules - A list of kernel modules loaded by the system mounts - Shows mounted filesystems. Shows device, mount point, filesystem type, permissions, and two flags. The file on my system: /dev/root / ext2 rw 0 0 /proc /proc proc rw 0 0 /dev/hdb1 /data vfat rw 0 0 /dev/hda1 /dos vfat rw 0 0 /dev/hda3 /slackw ext2 rw 0 0 none /dev/pts devpts rw 0 0 automount(pid640) /mnt autofs rw 0 0 ENG_SRV/MYUSER /eng_srv ncpfs rw 0 0 mtrr - The file on my system: reg00: base=0x000a0000 ( 0MB), size= 128kB: write-combining, count=1 reg01: base=0x000c0000 ( 0MB), size= 256kB: uncachable, count=1 reg03: base=0x000a8000 ( 0MB), size= 32kB: write-combining, count=1 reg07: base=0x00000000 ( 0MB), size= 64MB: write-back, count=1 net - Various network pseudo files. The netstat(8) command suite provides cleaner access to these files. Files:
arp - The kernel address resolution protocol table. dev - Network device status information ipx ipx_route rarp - used to provide rarp(8) services. raw - A dump of the RAW socket table route - Looks like route(8). snmp - Holds the ASCII databases used for the IP, ICMP, TCP, and UDP management information bases for an snmp agent. tcp - A dump of the TCP socket table. udp - A dump of the UDP socket table unix - Lists UNIX domain sockets and their status. partitions - Lists the partitions and their device major and minor numbers. The file on my system: major minor #blocks name 3 0 6250230 hda 3 1 208813 hda1 3 2 3068415 hda2 3 3 2843505 hda3 3 4 128520 hda4 3 64 6250230 hdb 3 65 6249253 hdb1 22 64 1073741823 hdd pci - A listing of all PCI devices that the system is aware of. rtc - A file containing clock information. The file on my system: rtc_time : 20:15:03 rtc_date : 2000-05-07 rtc_epoch : 1900 alarm : 16:29:44 DST_enable : no BCD : yes 24hr : yes square_wave : no alarm_IRQ : no update_IRQ : no periodic_IRQ : no periodic_freq : 1024 batt_status : okay scsi - A directory with scsi files and driver directories.
scsi - A list of all scsi devices known to the kernel drivername - Various scsi driver brand names self - Refers to the /proc filesystem. slabinfo - The file on my system slabinfo - version: 1.0 kmem_cache 29 42 pio_request 0 0 tcp_tw_bucket 0 42 tcp_bind_bucket 41 127 tcp_open_request 0 0 skbuff_head_cache 64 147 sock 150 242 dquot 0 0 filp 1505 1512 signal_queue 0 0 buffer_head 566 1428 mm_struct 65 93 vm_area_struct 2527 3528 dentry_cache 4704 4743 files_cache 72 99 uid_cache 4 127 size-131072 0 0 size-65536 0 0 size-32768 0 0 size-16384 16 16 size-8192 0 1 size-4096 3 8 size-2048 151 176 size-1024 20 32 size-512 37 72 size-256 33 70 size-128 546 700 size-64 192 210 size-32 1080 1197 slab_cache 78 126 stat - kernel statistics subdirectory
cpu - Jiffies spent in user mode, user mode with low priority, system mode, and idle. disk - Four disk entries not yet implemented page - The number of pages the system paged in and out. swap - Swap pages that have been brought in and out. intr - The number of interrupts received form the system boot ctxt - The number of context switches that the system underwent. btime - Boot time in seconds since Jan 1, 1970. swaps - A file defining swap partitions. The file on my system: Filename Type Size Used Priority /dev/hda4 partition 128516 7600 -1 sys - Directory corresponding to kernel variables
debug dev fs kernel
domainname file-max file-nr hostname inode-max inode-nr osrelease ostype panic real-root-dev securelevel version net proc sunrpc vm tty
uptime version
The sysctl tool
This tool is worth mentioning in this section since it is used to manipulate kernel parameters. If you type "sysctl -a |more" you will see a long list of kernel parameters. You can use this sysctl program to modify these parameters. However, I have been unable to add new parameters.