Monday, August 4, 2008

/dev and /proc

/dev

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

- Among other things, the /dev directory contains loopback devices, such as /dev/loop0. A loopback device is a gimmick that allows an ordinary file to be accessed as if it were a block device. This enables mounting an entire filesystem within a single large file.

- A few of the pseudo-devices in /dev have other specialized uses, such as /dev/null, /dev/zero, /dev/urandom, /dev/sda1, /dev/udp, and /dev/tcp.

- To mount a USB flash drive, append the following line to /etc/fstab. [95]
 /dev/sda1     /mnt/flashdrive    auto   noauto,user,noatime   0 0

- When executing a command on a /dev/tcp/$host/$port pseudo-device file, Bash opens a TCP connection to the associated socket.

- A socket is a communications node associated with a specific I/O port. (This is analogous to a hardware socket, or receptacle, for a connecting cable.) It permits data transfer between hardware devices on the same machine, between machines on the same network, between machines across different networks, and, of
course, between machines at different locations on the Internet.

/proc
The /proc directory is actually a pseudo-filesystem. The files in /proc mirror currently running system and kernel processes and contain information and statistics about them.

- It is even possible to control certain peripherals with commands sent to the /proc directory.


- The /proc directory contains subdirectories with unusual numerical names. Every one of these names maps to the process ID of a currently running process.

-   Within each of these subdirectories, there are a number of files that hold useful information about the corresponding process. 

- The stat and status files keep runningstatistics on the process,
- cmdline file holds the command-line arguments the process was invoked with
- exe file is a symbolic link to the complete path name of the invoking process. 



No comments: