& Lt; Describe the proc file system in linux & gt;

Source: Internet
Author: User

 

The role of the proc file system is to access system kernel information.
Proc is not a real file system. It does not occupy the system's external storage space. It only provides interfaces for users to access Linux kernel data in the form of files,
Because the system kernel is always dynamic, we only capture the moment of system kernel changes.

 

[Root @ apache ~] # Cd/proc/
[Root @ apache proc] # ls
1 1428 1645 28 867 ioports partitions
10 1448 1648 29 9 irq sched_debug
1073 15 1652 3 912 kallsyms schedstat
11 1526 1689 30 acpi kcore scsi
1127 1538 17 31 asound keys self
1171 1539 18 345 buddyinfo key-users
Open the proc directory and you can see many directory file names. You can also see the pid of the process running in the current system,
You can even find the running file by using the pid ..

 

Next we can see that it has been changing.
[Root @ apache proc] # ps aux | grep vi
Root 1726 0.0 0.1 4336 732 pts/0 S + grep vi
[Root @ apache proc] # ps aux | grep vi
Root 1728 0.0 0.1 4336 732 pts/0 S + grep vi
[Root @ apache proc] # ps aux | grep vi
Root 1730 0.0 0.1 4336 732 pts/0 S + grep vi
[Root @ apache proc] # ps aux | grep vi
Root 1732 0.0 0.1 4336 732 pts/0 S + grep vi

Let's take a look:

[Root @ apache proc] # ls-l/proc/1774/exe // query the program lrwxrwxrwx executed by vim. 1 root 0 Jun 12/proc/1774/exe->/usr/bin/vim

[Root @ apache proc] # ls-l/proc/1774/cwd // query the current vim working directory. Do not follow/
Lr:
[Root @ apache proc] # ls-l/proc/1774/cwd // view the files in the vim working directory, which is indeed the root directory
Total 44wxrwxrwx. 1 root 0 Jun 12/proc/1774/cwd->/root

-Rw -------. 1 root 1215 May 24 anaconda-ks.cfg
-Rw-r --. 1 root 25032 May 24 :22 install. log
-Rw-r --. 1 root 7345 May 24 install. log. syslog

[Root @ apache proc] # ls-l/proc/1774/environ // view the current running environment of vim
-R --------. 1 root 0 Jun 12/proc/1774/environ

 

Of course, the proc directory is not as small as we think. It is very powerful.
[Root @ apache proc] # cat/proc/cpuinfo // view the cpu information of our system
Processor: 0
Vendor_id: GenuineIntel
Cpu family: 6
Model: 58
Model name: Intel (R) Core (TM) i5-3210M CPU @ 2.50 GHz
Stepping: 9
Cpu MHz: 2494.379 // second-level cache
Cache size: 3072 KB // Level 3 cache
========== Many and many

[Root @ apache proc] # cat/proc/meminfo // you can also find our memory information
MemTotal: 443692 kB
MemFree: 307832 kB
Buffers': 11892 kB
Cached: 63692 kB
SwapCached: 0 kB
Active: 36008 kB
Inactive: 53752 kB
Active (anon): 14400 kB
Inactive (anon): 8 kB
================

[Root @ apache proc] # cat/proc/modules // view the modules loaded by the current system. You can also use lsmod
Autofs4 20981 3-Live 0xdd7cd000
Sunrpc 215000 1-Live 0xdd776000
Ipt_REJECT 1867 2-Live 0xdd6e9000
Nf_conntrack_ipv4 7694 2-Live 0xdd6dd000
Nf_defrag_ipv4 1039 1 nf_conntrack_ipv4, Live 0xdd6d0000
Iptable_filter 2173 1-Live 0xdd6c4000
Ip_tables 9567 1 iptable_filter, Live 0xdd6b8000
Ip6t_REJECT 3987 2-Live 0xdd6a5000
Nf_conntrack_ipv6 7207 2-Live 0xdd699000
Nf_defrag_ipv6 9873 1 nf_conntrack_ipv6, Live 0xdd68b000
Xt_state 1064 4-Live 0xdd67e00

==================================
When talking about the module, we can also view the specific information of the module:
[Root @ apache proc] # modinfo sg // Add the command module to display the module information
Filename:/lib/modules/2.6.32-279. el6.i686/kernel/drivers/scsi/sg. ko
Alias: char-major-21 -*
Version: 3.5.34
License: GPL
Description: SCSI generic (sg) driver
Author: Douglas Gilbert
Srcversion: BD5E4FC33B6E0ABE20D3FB4
Depends:
Of course, modinfo can only be used in this way, and there are many ways to play it.
-Author of a display module
-N: name of the display module
-V display module version
There are a lot of interesting examples ====================
========================================================== ======

We all know that the following command can be used to view the current system version.
[Root @ apache proc] # cat/etc/issue
Red Hat Enterprise Linux Server release 6.3 (Santiago)
Kernel \ r on an \ m

In fact, the proc directory also stores our version information.
[Root @ apache proc] # cat/proc/version
Linux version 2.6.32-279. el6.i686 (mockbuild@x86-010.build.bos.redhat.com)
(Gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) #1 SMP Wed Jun 13 18:23:32 EDT 2012

[Root @ apache proc] # cat/proc/partitions // view the partition information that has taken effect for the current system. Do you know what to ask if you want to use partx-d-a to refresh the partition? This cannot be seen without refreshing

Major minor # blocks name

8, 0, 20971520, sda
8 1 8192000 sda1
8 2 204800 sda2
8, 3, 1024000, sda3
253 0 5120000 dm-0

The/proc/interrupts directory is very important. some information about our system after it is down is saved in this directory.
[Root @ apache proc] # cat/proc/interrupts
CPU0
0: 161 IO-APIC-edge timer
1: 8 IO-APIC-edge i8042
3: 1 IO-APIC-edge
4: 1 IO-APIC-edge
7: 0 IO-APIC-edge parport0
8: 1 IO-APIC-edge rtc0
9: 0 IO-APIC-fasteoi acpi
12: 110 IO-APIC-edge i8042
14: 0 IO-APIC-edge ata_piix
==========================================
This directory stores the file system information used by the current system.
[Root @ apache proc] # cat/proc/filesystems
Nodev sysfs
Nodev rootfs
Nodev bdev
Nodev proc
Nodev cgroup
Nodev cpuset
Nodev tmpfs
Nodev devtmpfs
Nodev binfmt_misc
Nodev debugfs
Nodev securityfs
Nodev sockfs
Nodev usbfs
Nodev pipefs
Nodev anon_inodefs
Nodev inotifyfs
Nodev devpts

 

 

 

 

 

 

 

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.