List environment variables
To list the environment variables of a process you can issue the command:
ps ewww pid
E.g.:
ahlam@oxygen:~/test/malloc$ ps ewww 4752
PID TTY STAT TIME COMMAND
4752 pts/2 Ss+ 0:00 bash USER=ahlam HOME=/home/ahlam DESKTOP_SESSION=default GDM_XSERVER_LOCATION=loca
l GTK_IM_MODULE=gcin LOGNAME=ahlam USERNAME=ahlam GDM_LANG=en_HK.UTF-8 PATH=/usr/local/sbin:/usr/local/bin:/u
sr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games DISPLAY=:0.0 LANG=en_HK.UTF-8 XMODIFIERS=@im=gcin XAUTHOR
ITY=/home/ahlam/.Xauthority SHELL=/bin/bash GDMSESSION=default QT_IM_MODULE=gcin PWD=/home/ahlam SSH_AUTH_SOC
K=/tmp/ssh-nRdglP4521/agent.4521 SSH_AGENT_PID=4563 DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-ix9My5o6
DJ,guid=8abd2646dc897f03d1cfb07e3a3d4b00 GTK_RC_FILES=/etc/gtk/gtkrc:/home/ahlam/.gtkrc-1.2-gnome2 SESSION_MA
NAGER=local/oxygen:/tmp/.ICE-unix/4521 GNOME_KEYRING_SOCKET=/tmp/keyring-fXmYul/socket GNOME_DESKTOP_SESSION_
ID=Default TERM=xterm COLORTERM=gnome-terminal WINDOWID=31457489
List out the threads of a process
ps ms pid
E.g:
ahlam@oxygen:~/test/malloc$ ps ms 4752
UID PID PENDING BLOCKED IGNORED CAUGHT STAT TTY TIME COMMAND
1000 4752 0000000000000000 - - - - pts/2 0:00 bash
1000 - 0000000000000000 0000000000000000 0000000000384004 000000004b813efb Ss+ - 0:00 -
Print the memory map
To list the memory map of a process, you can use the
pmap
command. It lists out the mapped memory regions and the purpose of the memory regions. It also lists out the .so files loaded by the process.pmap pid
E.g:
ahlam@oxygen:~/test/malloc$ pmap 4752
4752: bash
08048000 644K r-x-- /bin/bash
080e9000 20K rw--- /bin/bash
080ee000 1804K rw--- [ anon ]
b7c94000 36K r-x-- /lib/tls/i686/cmov/libnss_files-2.4.so
b7c9d000 8K rw--- /lib/tls/i686/cmov/libnss_files-2.4.so
b7c9f000 32K r-x-- /lib/tls/i686/cmov/libnss_nis-2.4.so
b7ca7000 8K rw--- /lib/tls/i686/cmov/libnss_nis-2.4.so
b7ca9000 72K r-x-- /lib/tls/i686/cmov/libnsl-2.4.so
b7cbb000 8K rw--- /lib/tls/i686/cmov/libnsl-2.4.so
b7cbd000 8K rw--- [ anon ]
b7cbf000 28K r-x-- /lib/tls/i686/cmov/libnss_compat-2.4.so
b7cc6000 8K rw--- /lib/tls/i686/cmov/libnss_compat-2.4.so
b7cd7000 204K r---- /usr/lib/locale/en_HK.utf8/LC_CTYPE
b7d0a000 4K r---- /usr/lib/locale/en_HK.utf8/LC_NUMERIC
b7d0b000 4K r---- /usr/lib/locale/en_HK.utf8/LC_TIME
b7d0c000 860K r---- /usr/lib/locale/en_HK.utf8/LC_COLLATE
b7de3000 8K rw--- [ anon ]
b7de5000 1204K r-x-- /lib/tls/i686/cmov/libc-2.4.so
b7f12000 8K r---- /lib/tls/i686/cmov/libc-2.4.so
b7f14000 8K rw--- /lib/tls/i686/cmov/libc-2.4.so
b7f16000 12K rw--- [ anon ]
b7f19000 8K r-x-- /lib/tls/i686/cmov/libdl-2.4.so
b7f1b000 8K rw--- /lib/tls/i686/cmov/libdl-2.4.so
b7f1d000 220K r-x-- /lib/libncurses.so.5.5
b7f54000 32K rw--- /lib/libncurses.so.5.5
b7f5c000 4K rw--- [ anon ]
b7f5d000 4K r---- /usr/lib/locale/en_HK.utf8/LC_MONETARY
b7f5e000 4K r---- /usr/lib/locale/en_HK.utf8/LC_MESSAGES/SYS_LC_MESSAGES
b7f5f000 4K r---- /usr/lib/locale/en_HK.utf8/LC_PAPER
b7f60000 4K r---- /usr/lib/locale/en_HK.utf8/LC_NAME
b7f61000 4K r---- /usr/lib/locale/en_HK.utf8/LC_ADDRESS
b7f62000 4K r---- /usr/lib/locale/en_HK.utf8/LC_TELEPHONE
b7f63000 4K r---- /usr/lib/locale/en_HK.utf8/LC_MEASUREMENT
b7f64000 28K r--s- /usr/lib/gconv/gconv-modules.cache
b7f6b000 4K r---- /usr/lib/locale/en_HK.utf8/LC_IDENTIFICATION
b7f6c000 8K rw--- [ anon ]
b7f6e000 100K r-x-- /lib/ld-2.4.so
b7f87000 8K rw--- /lib/ld-2.4.so
bfa1c000 88K rw--- [ stack ]
ffffe000 4K ----- [ anon ]
total 5528K
/proc/pid
In
proc/pid
directory, it contains much information of a process.
ahlam@oxygen:~/test/malloc$ ls -l /proc/4752
total 0
dr-xr-xr-x 2 ahlam ahlam 0 2007-04-19 20:17 attr
-r-------- 1 ahlam ahlam 0 2007-04-19 20:17 auxv
-r--r--r-- 1 ahlam ahlam 0 2007-04-19 19:57 cmdline
-r--r--r-- 1 ahlam ahlam 0 2007-04-19 20:17 cpuset
lrwxrwxrwx 1 ahlam ahlam 0 2007-04-19 18:20 cwd -> /home/ahlam/test/malloc
-r-------- 1 ahlam ahlam 0 2007-04-19 19:58 environ
lrwxrwxrwx 1 ahlam ahlam 0 2007-04-19 20:17 exe -> /bin/bash
dr-x------ 2 ahlam ahlam 0 2007-04-19 19:57 fd
-r--r--r-- 1 ahlam ahlam 0 2007-04-19 20:06 maps
-rw------- 1 ahlam ahlam 0 2007-04-19 20:17 mem
-r--r--r-- 1 ahlam ahlam 0 2007-04-19 20:17 mounts
-r-------- 1 ahlam ahlam 0 2007-04-19 20:17 mountstats
-rw-r--r-- 1 ahlam ahlam 0 2007-04-19 20:17 oom_adj
-r--r--r-- 1 ahlam ahlam 0 2007-04-19 20:17 oom_score
lrwxrwxrwx 1 ahlam ahlam 0 2007-04-19 20:17 root -> /
-rw------- 1 ahlam ahlam 0 2007-04-19 20:17 seccomp
-r--r--r-- 1 ahlam ahlam 0 2007-04-19 20:17 smaps
-r--r--r-- 1 ahlam ahlam 0 2007-04-19 19:57 stat
-r--r--r-- 1 ahlam ahlam 0 2007-04-19 20:17 statm
-r--r--r-- 1 ahlam ahlam 0 2007-04-19 19:57 status
dr-xr-xr-x 3 ahlam ahlam 0 2007-04-19 20:17 task
-r--r--r-- 1 ahlam ahlam 0 2007-04-19 20:17 wchan
For details, please
man proc
.
No comments:
Post a Comment