If you want to monitor a running system in real time, and view things
like physical memory and CPU information, or identify drives, read the /proc virtual
filesystem. Use only cat to read
/proc, or utilities designed
expressly for it, such as sysctl,
lspci, ps, and top. The syntax is the same as for reading
any file:
$ cat /proc/
filenameYou can explore /proc just
like any filesystem and easily find the information you want. Look to
the named folders for hardware information:
$ ls /proc
bus cmdline cpuinfo devices dma driver filesystems ide kcore kmsg ksyms loadavg
meminfo misc modules mounts mtrr partitions pci scsi swaps sys ttyFor example, to show CPU information, use:
$ cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 6
model : 3
model name : AMD Duron Processor
stepping : 1
cpu MHz : 801.442
...To show physical memory and swap usage, use:
$ cat /proc/meminfo
total: used: free: shared: buffers: cached:
Mem: 262746112 237740032 25006080 0 11575296 150138880
Swap: 534601728 81661952 452939776
MemTotal: 256588 kB
MemFree: 24420 kB
...To tell all about an IDE hard drive, use:
$ cat /proc/ide/via
-------VIA BusMastering IDE Configuration---------
Driver Version: 3.37
South Bridge: VIA vt82c686a
Revision: ISA 0x22 IDE 0x10
Highest DMA rate: UDMA66
BM-DMA base: 0xd400
PCI clock: 33.3MHz
...To see disk geometry, both real and logical, use:
$ cat /proc/ide/ide0/hda/geometry
physical 39870/16/63
logical 2501/255/63$ cat /proc/ide/ide0/hda/model
IBM-DTLA-305020To show driver versions for all IDE drivers, use:
$ cat /proc/ide/drivers
de-scsi version 0.93
ide-cdrom version 4.59-ac1
ide-floppy version 0.99.newide
ide-disk version 1.17
ide-default version 0.9.newideTo show capabilities of CD drives, use:
$ cat /proc/sys/dev/cdrom/info
CD-ROM information, Id: cdrom.c 3.12 2000/10/18
drive name: sr1 sr0
drive speed: 40 32
...
Can read multisession: 1 1
Can read MCN: 1 1
Reports media changed: 1 1
Can play audio: 1 1
Can write CD-R: 1 0
Can write CD-RW: 1 0
Can read DVD: 0 1
Can write DVD-R: 0 0
Can write DVD-RAM: 0 0To show SCSI devices, using the following command. Note that it does not differentiate between devices attached to the SCSI bus and IDE devices using the SCSI-emulation subsystem. These are IDE CD drives:
$ cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: TOSHIBA Model: DVD-ROM SD-M1202 Rev: 1020
Type: CD-ROM ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 01 Lun: 00
Vendor: LITE-ON Model: LTR-24102B Rev: 5S54
Type: CD-ROM ANSI SCSI revision: 02This following command is just plain fun and has absolutely no practical value. It requires a functioning sound system. Warning: it's noisy—this is the sound of your CPU in action. Ctrl-C stops it:
# cat /proc/kcore > /dev/dspDisk geometry, as expressed by /proc or any other utility, is largely a
fiction. Modern drives are far more complex than the old "heads
sectors cylinders" model.
As mentioned earlier, to read /proc use only cat or
utilities designed expressly for it, such as sysctl, lspci, ps, and top.
Pagers like less and
more give a different picture,
because they re-read /proc with
each page. And you don't want to use a text editor, or any utility
with write powers, because you can mess up your system in a
heartbeat.
Linux information can be found scattered in man pages, texinfo files, and source code comments, but the best source is the experts who have built up a working knowledge of managing Linux systems. The Linux Cookbook's tested techniques distill years of hard-won experience into practical cut-and-paste solutions to everyday Linux dilemmas. Use just one recipe from this collection of real-world solutions, and the hours of tedious trial-and-error saved will more than pay for the cost of the book. It's more than a time-saver; it's a sanity saver.




Help





