Quantcast
Channel: Recent Gists from 84adam
Viewing all articles
Browse latest Browse all 34

check namespaces plus associated processes and users

$
0
0
check-namespaces.sh
#!/bin/bash
echo "Listing processes and their associated user namespaces:"
for pid in $(ls /proc | grep '^[0-9]*$'); do
if [ -e /proc/$pid/ns/user ]; then
# Get the process command line
cmdline=$(cat /proc/$pid/cmdline | tr '\0' ' ')
# Get the process owner
owner=$(ps -o user= -p $pid)
# Get the user namespace inode
namespace_inode=$(ls -l /proc/$pid/ns/user | awk '{print $11}')
# Get the process name
process_name=$(ps -p $pid -o comm=)
echo "PID: $pid"
echo "Process Name: $process_name"
echo "Command Line: $cmdline"
echo "Owner: $owner"
echo "Namespace Inode: $namespace_inode"
echo "----------------------------------------"
fi
done

Viewing all articles
Browse latest Browse all 34

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>