27.08.2015 Views

Advanced Bash−Scripting Guide

Advanced Bash-Scripting Guide - Nicku.org

Advanced Bash-Scripting Guide - Nicku.org

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 28. /dev and /proc<br />

A Linux or UNIX machine typically has two special−purpose directories, /dev and /proc.<br />

28.1. /dev<br />

The /dev directory contains entries for the physical devices that may or may not be present in the hardware.<br />

[57] The hard drive partitions containing the mounted filesystem(s) have entries in /dev, as a simple df<br />

shows.<br />

bash$ df<br />

Filesystem 1k−blocks Used Available Use%<br />

Mounted on<br />

/dev/hda6 495876 222748 247527 48% /<br />

/dev/hda1 50755 3887 44248 9% /boot<br />

/dev/hda8 367013 13262 334803 4% /home<br />

/dev/hda5 1714416 1123624 503704 70% /usr<br />

Among other things, the /dev directory also contains loopback devices, such as /dev/loop0. A loopback<br />

device is a gimmick that allows an ordinary file to be accessed as if it were a block device. [58] This enables<br />

mounting an entire filesystem within a single large file. See Example 13−6 and Example 13−5.<br />

A few of the pseudo−devices in /dev have other specialized uses, such as /dev/null, /dev/zero and<br />

/dev/urandom.<br />

28.2. /proc<br />

The /proc directory is actually a pseudo−filesystem. The files in the /proc directory mirror currently<br />

running system and kernel processes and contain information and statistics about them.<br />

bash$ cat /proc/devices<br />

Character devices:<br />

1 mem<br />

2 pty<br />

3 ttyp<br />

4 ttyS<br />

5 cua<br />

7 vcs<br />

10 misc<br />

14 sound<br />

29 fb<br />

36 netlink<br />

128 ptm<br />

136 pts<br />

162 raw<br />

254 pcmcia<br />

Block devices:<br />

1 ramdisk<br />

2 fd<br />

3 ide0<br />

9 md<br />

Chapter 28. /dev and /proc 311

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!