Stop losing track of which namespace your processes are hiding in
Container Basics On Linux (Namespaces/Cgroups)
Stop losing track of which namespace your processes are hiding in
🧩 The Challenge
You ever dive into a containerized mess and realize you have no clue if you are looking at the host process list or the one inside a specific mount namespace? I’ve wasted way too much time staring at ps aux outputs trying to figure out why I can’t see the processes I know are running.
💡 The Fix
Just peek at the readlink of the task’s namespace file in proc to confirm exactly which bucket the kernel has stuck that process in. It saves you from guessing if your container isolation is actually doing what you think it’s doing.
ls -l /proc/<PID>/ns/mnt
⚙️ Why It Works
Each entry in that directory is a symbolic link pointing to a unique identifier for that namespace; if the ID matches the one from your shell, you’re both in the same room.
🚀 Pro-Tip: Pipe it to readlink -f if you want to skip the symlink clutter and just grab the ID for a script.
Linux Tips & Tricks | © ngelinux.com | 8/10/2026
