To change the default proc mount options in Ubuntu Linux, edit the /etc/fstab file and modify the line mounting proc. Replace or append the desired options, such as removing hidepid=2, then run sudo mount -o remount proc to apply the changes immediately without a reboot.
Understanding Proc Mount Options
Theproc filesystem is a pseudo-filesystem in Linux that provides an interface to kernel data structures. It is typically mounted at /proc and allows user-space programs to interact with the kernel. By default, Ubuntu mounts this filesystem with specific options that control visibility and access permissions. One common option encountered in server environments, particularly those with security hardening, is hidepid=2. This option hides process information from users who do not own the process, effectively preventing them from seeing other users' processes via /proc. While this enhances security by limiting information disclosure, it can break applications that rely on reading global process statistics or require access to all process IDs. Understanding these options is crucial before making modifications, as incorrect settings can lead to system instability or application failures.
Locating the Proc Entry in Fstab
The configuration for how filesystems are mounted at boot time is stored in the/etc/fstab file. To modify the proc mount options, you must first locate the relevant entry in this file. Open a terminal and use a text editor with root privileges. The command sudo nano /etc/fstab is a standard choice for this task. Once the file is open, search for the line that begins with proc. It usually looks something like:
proc /proc proc defaults 0 0
Or, if hidepid is already set, it might appear as:
proc /proc proc defaults,hidepid=2 0 0
This line defines the source (proc), the mount point (/proc), the filesystem type (proc), and the options. The fourth column contains the options string. This is where you will make your changes. Be careful not to alter other parts of the line, especially the last two columns which indicate dump and pass numbers. Incorrectly modifying these can prevent the system from booting correctly or cause filesystem checks to fail.
Editing the Options Safely
When editing the options, you need to decide whether to removehidepid=2 entirely or add new options. If you wish to revert to default behavior where all users can see all processes, simply remove hidepid=2 from the options string. Ensure there are no trailing commas or spaces that could cause parsing errors. For example, change defaults,hidepid=2 to just defaults. If you want to keep some security restrictions but allow broader access, you might use hidepid=1, which hides process names but still shows PIDs. Always verify that the syntax is correct before saving. In nano, you can save changes by pressing Ctrl+O and exiting with Ctrl+X.
Applying the Changes
After saving the modified/etc/fstab file, you must apply the changes to the running system. The most straightforward way to do this is to remount the proc filesystem. Run the following command in your terminal:
sudo mount -o remount proc
This command tells the system to unmount and remount /proc using the new options specified in /etc/fstab. If the command executes without error, the new settings are active immediately. You can verify the current mount options by checking the contents of /proc/mounts or by running cat /proc/mounts | grep proc. The output should reflect your changes. For instance, if you removed hidepid=2, the options column should no longer list it.
Handling Errors During Remount
If themount command fails, it is likely due to a syntax error in /etc/fstab. Check the terminal output for specific error messages. Common issues include missing commas, invalid option names, or typos. If the system becomes unstable or you cannot recover easily, you may need to boot into recovery mode or use a live USB to edit /etc/fstab again. Always ensure you have a backup of the original /etc/fstab file before making changes. A simple copy command like sudo cp /etc/fstab /etc/fstab.bak creates a safety net.
Verifying the New Configuration
Once the remount is successful, verify that the new behavior matches your expectations. Try listing processes using commands likeps aux or checking /proc directories. If you removed hidepid=2, you should now be able to see processes owned by other users. If you are managing a VPS, consider the security implications. Hiding process details can protect against certain types of reconnaissance attacks. However, for development or debugging purposes, full visibility might be necessary. Balance security needs with operational requirements.
For more information on related system configurations, see MS-CHAP Authentication Failing When Connecting Draytek LTP/IPSec VPN on Ubuntu Linux AWS EC2 Instance and Port Forwarding VM via OpenVPN: A Comprehensive Guide.
Frequently Asked Questions
What happens if I remove hidepid=2?
Removinghidepid=2 allows all users on the system to view process information belonging to other users. This includes process IDs, command lines, and memory usage details. While this breaks some security hardening measures, it enables tools that require global process visibility to function correctly.
Can I use hidepid=1 instead?
Yes,hidepid=1 is a middle-ground option. It hides the executable name and command-line arguments of processes owned by other users, but still shows their PIDs. This provides some privacy while allowing scripts that only need PID lists to work.
How do I revert the changes if something goes wrong?
You can revert changes by restoring the original/etc/fstab file from your backup. Use sudo cp /etc/fstab.bak /etc/fstab and then remount proc again. If the system is unbootable, use a live USB to perform the restoration.
Does this change affect running services?
Remountingproc affects the entire system immediately. Running services that rely on /proc data may temporarily lose access to that information. Most modern services handle this gracefully, but some might restart or behave unexpectedly during the remount process.
Is it safe to edit fstab on a production server?
Editing/etc/fstab carries risks because it controls critical mount points. Always create a backup before editing. Test changes in a non-production environment first if possible. Ensure you have console access to the server in case the GUI or SSH fails after a bad edit.