/proc
Processes
Inside the/proc
directory every process has a folder, named after its process ID. For example, my nagios3
program has the following process ID:ps aux | grep [n]agios3 | awk '{ print $2 }'
3363
So it has its own special folder: /proc/3363
. Every process has a folder like /proc/$PID
where $PID is its process ID.I'll cover a few specific files of a process folder below.
exe
This is a symlink to the process binary:sudo ls -l /proc/3363/exe
lrwxrwxrwx 1 root root 0 2013-01-26 15:18 /proc/3363/exe -> /usr/sbin/nagios3
cmdline
This shows the command which started the process:(sudo cat /proc/3363/cmdline; echo) | tr "\000" " "
/usr/sbin/nagios3 -d /etc/nagios3/nagios.cfg
cwd
This is a symlink to the process current working directory:sudo ls -la /proc/3363/cwd
lrwxrwxrwx 1 root root 0 2013-01-26 15:18 /proc/3363/cwd -> /
environ
This gives us the environment of the command (yourenv
) which also shows us all the user variables and such:(sudo cat /proc/3363/environ; echo) | tr "\000" "\n"
[output truncated]
status
This gives us aps
like information overview for the process:cat /proc/3363/status
Name: nagios3
State: S (sleeping)
Tgid: 3363
Pid: 3363
PPid: 1
TracerPid: 0
[output truncated]
limits
This gives the limits the process has, which can be set and tweaked usingulimit
:sudo cat /proc/3363/limits
Limit Soft Limit Hard Limit Units
Max cpu time unlimited unlimited seconds
Max file size unlimited unlimited bytes
Max data size unlimited unlimited bytes
Max stack size 8388608 unlimited bytes
Max core file size 0 unlimited bytes
Max resident set unlimited unlimited bytes
Max processes unlimited unlimited processes
[output truncated]
Non Processes
There are also a lot of "general" files which give you system information./proc/filesystems
This gives a list of all the filesystems supported by the current kernel:cat /proc/filesystems
nodev sysfs
nodev rootfs
nodev bdev
nodev proc
nodev cgroup
When it has nodev
before it, it means it is a non-physical filesystems such as network filesystems and proc./proc/cpuinfo
This return a lot of info about the processor(s).cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 3
model name : Intel(R) Xeon(TM) CPU 2.60GHz
stepping : 9
/proc/uptime
This returns the uptime as two decimal values in seconds, separated by a space, the amount of time since the kernel was started and the amount of time that the kernel has been idle.cat /proc/uptime
3121129.58 4100521.65
/proc/cmdline
This gives the current command line passed to the running kernel (by GRUB/lilo):cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-2.6.18-21-generic-pae root=UUID=[...] ro quiet
/proc/version
This gives very detailed kernel version information. More than withuname -a
, see the comparison:cat /proc/version
Linux version 2.6.18-21-custom-pae-bfs (remy@solaris3) (gcc version 4.4.3 (Ubuntu 4.2-ubuntu5.1) ) #101-Ubuntu SMP Mon Dec 3 15:56:38 UTC 2012
uname -a
Linux solaris3 2.6.18-21-custom-pae-bfs #101-Ubuntu SMP Mon Dec 3 15:56:38 UTC 2012 i686 GNU/Linux
(Note that this is a custom kernel, hence the remy@solaris3
)./proc/modules
This returns a list of currently loaded kernel modules:cat /proc/modules
btrfs 462393 0 - Live 0xf908d000
zlib_deflate 19568 1 btrfs, Live 0xf87e9000
crc32c 2519 1 - Live 0xf8410000
/proc/scsi/scsi
This gives information on the attached SCSI devices (handy on servers, also does SAS):cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
Vendor: TEAC Model: CD-224E Rev: K.9A
Type: CD-ROM ANSI SCSI revision: 05
/proc/uptime
This gives the same result as theuptime
command, with two extra's. The fourth field consists of two numbers seperated by a slash, the first one represents the number of currently executing processes/threads. This number will not exceed the number of processors cores the system has.The second number (the one after the slash) represents the number of processes/threads currently existing on the system. The fifth field has the most reced PID created (probably of the cat
command you just did.)cat /proc/loadavg
1.02 1.43 1.40 1/132 16254
The /proc/net folder
This folder has information about the network stack./proc/net/route
This is the systems routing table, in HEX format:cat /proc/net/route
Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
eth0 0EF1D9C2 00000000 0001 0 0 0 00FFFFFF 0 0 0
eth0 00000000 0EF1D9C2 0003 0 0 100 00000000 0 0 0
/proc/net/arp
This has the system ARP table, also in HEX format. Using thearp -a
command gives more readable output.cat /proc/net/arp
IP address HW type Flags HW address Mask Device
10.0.20.3 0x1 0x2 00:11:22:33:44:55 * eth0
10.0.20.4 0x1 0x2 00:11:11:11:44:55 * eth0
/proc/net/dev
This has information about sent and received packages for all interfaces.ifconfig
gives a more readable output.cat /proc/net/dev
Inter-| Receive |Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
lo:775661077 998843 0 0 0 0 0 0 775661077 998843 0 0 0 0 0 0
eth0:2914473149 1605253769 1 0 0 1 0 0 3861718441 884372746 0 0 0 0 0 0
Comments
Post a Comment