分类: LINUX
2014-10-16 14:40:20
Linux中,可以通过/proc文件系统访问到许多内核的内部信息。/proc文件系统最初的设计也是用于方便地访问进程相关的信息,因此命名为proc。现在这个文件系统已用于反映系统中方方面面的信息,例如/proc/modules是模块的列表,/proc/meminfo则是内存使用的统计。/proc文件系统中的目录并非持久存储的信息,也就是说,其目录并不“真实”地存在于磁盘,而是在访问时动态生成。
我们感兴趣的是/proc文件系统中关于进程的信息。每一个进程在/proc文件系统中有一个目录即(/proc/
ps命令和top命令从/proc文件系统中读取进程信息并显示出来。因此,如果一个进程的进程号没有在/proc文件系统中反映出来,则这个进程被“隐藏”了,“隐藏”进程在ps或top命令的输出不出现。
该选项定义了一个Linux用户可以查看到多少其它用户的信息。保护级别分0、1、2三个等级,由底到高防御增强。
通过下面命令可令配置立即生效:
# mount -o remount,rw,hidepid=2 /proc
编辑/etc/fstab文件,使配置在服务器启动时自动生效
# vi /etc/fstab
proc /proc proc defaults,hidepid=2 0 0
保存退出。
下面是一个例子
$ ssh vivek@cbz-test $ ps -ef $ sudo -s # mount -o remount,rw,hidepid=2 /proc $ ps -ef $ top $ htop
gif动画: hidepid 实战
You need to use gid=VALUE_HERE option:
gid=XXX defines a group that will be able to gather all processes' info (as in hidepid=0 mode). This group should be used instead of putting nonroot user in sudoers file or something. However, untrusted users (like daemons, etc.) which are not supposed to monitor the tasks in the whole system should not be added to the group.
So add the user called see process information and mount /proc as follows in /etc/fstab:
proc /proc proc defaults,hidepid=2,gid=admin 0 0
原文: 译文: 转载请保留链接