Why This Matters
By default, Linux systems allow all local users to see information about all processes running on the system, including processes from other users. This could include sensitive details like:- Command line arguments (which may contain passwords or tokens)
- Environment variables
- Open files and network connections
- Process owners and activity
hidepid option to /proc, we can prevent users from seeing other users’ process information.
Configuration
Add hidepid mount option
Add this line to Or use this command:
/etc/fstab to mount /proc with hidepid=2:Understanding hidepid Options
Thehidepid mount option accepts these values:
| Value | Behavior |
|---|---|
hidepid=0 | Default - all users can see all processes |
hidepid=1 | Users cannot access /proc/<pid> directories of processes they don’t own (limited information hiding) |
hidepid=2 | Users cannot see processes they don’t own at all (recommended) |
Verification
After applying the configuration:-
As a normal user, try to list processes:
You should only see your own processes.
-
Check the mount options:
You should see
hidepid=2in the options.
Troubleshooting
systemd Services Failing
Some systemd services may need access to/proc information for all processes. If services fail after enabling hidepid=2, you have a few options:
- Use hidepid=1 instead (less restrictive)
-
Create a group exception (systemd 232+):
Then add service users to the
proc_monitorgroup. -
Revert the changes if critical services break:
The most commonly affected services are monitoring tools (like Nagios, Zabbix) and process managers that need to see all system processes.
What This Does
Withhidepid=2 configured:
- Users can only see their own processes in tools like
ps,top, and/proc - Sensitive information in process arguments is hidden from other users
- System users and services with elevated privileges can still see all processes
- Attackers who compromise a user account have less reconnaissance information
Security Benefits
Information Hiding
Prevents users from seeing sensitive data in other users’ process arguments
Reduced Reconnaissance
Limits what attackers can learn about the system through a compromised account
Privacy
Users can’t spy on what other users are running
Defense in Depth
Adds another layer of isolation between user accounts