Skip to content

Instantly share code, notes, and snippets.

@daniel-perry
Created December 15, 2016 22:43
Show Gist options
  • Save daniel-perry/717d069c6c8b04c34f6061382e1e43ca to your computer and use it in GitHub Desktop.
Save daniel-perry/717d069c6c8b04c34f6061382e1e43ca to your computer and use it in GitHub Desktop.
#usage: lsprocs [username]
lsprocs(){
uid=`id -u`
if [ -z ${1+x} ];
then
uid=`id -u`
else
uid=`id -u $1`
echo "uid for $1 is $uid"
fi
for f in `ls -d /proc/+([0-9])`;
do
uidline=`cat $f/status | grep Uid`;
if [[ $uidline == *"$uid"* ]];
then
echo "=============";
cat $f/status | grep Name;
cat $f/status | grep Uid;
cat $f/status | grep Pid;
echo "cmdline:"
cat $f/cmdline; echo "";
fi;
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment