pmap命令来自英文词组“process memory map”的缩写,其功能是用于显示进程的内存映像信息。pmap命令能够显示进程映像的起始地址、虚拟内存大小、进程访问地址空间的权限以及内存映像文件等信息,而我们只需告知进程号码即可。

语法格式:pmap [参数] 进程ID

常用参数:

-c读取默认配置
-d显示内存映射文件的偏移值、主次设备号等信息
-h显示帮助信息
-n创建新的配置
-N创建新的配置并保存到文件
-p显示文件的完整路径
-q静默执行模式
-V显示版本信息
-x显示物理内存大小、未同步磁盘页面数量等信息

参考示例

显示进程的内存映像概况:

[root@linuxcool ~]# pmap 1098
1098:   /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc -oMACs=hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512 -oGSSAPIKexAlgorithms=gss-gex-sha1-,gss-group14-sha1- -oKexAlgorithms=curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-
000055e5b8d58000    808K r-x-- sshd
000055e5b9021000     16K r---- sshd
000055e5b9025000      4K rw--- sshd
………………省略部分输出信息………………

显示进程的地址空间等信息:

[root@linuxcool ~]# pmap -x 1098
1098:   /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc -oMACs=hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512 -oGSSAPIKexAlgorithms=gss-gex-sha1-,gss-group14-sha1- -oKexAlgorithms=curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-
Address           Kbytes     RSS   Dirty Mode  Mapping
000055e5b8d58000     808     656       0 r-x-- sshd
000055e5b9021000      16      16      16 r---- sshd
000055e5b9025000       4       4       4 rw--- sshd
………………省略部分输出信息………………
Author

这篇优质的内容由TA贡献而来

刘遄

《Linux就该这么学》书籍作者,RHCA认证架构师,教育学(计算机专业硕士)。