View All Processess Cmdlines and Environments

cd /proc&&ps a -opid=|xargs -I+ sh -c '[[ $PPID -ne + ]]&&echo -e "\n[+]"&&tr -s "\000" " "<+/cmdline&&echo&&tr -s "\000\033" "\nE"<+/environ|sort'
Grabs the cmdline used to execute the process, and the environment that the process is being run under. This is much different than the 'env' command, which only lists the environment for the shell. This is very useful (to me at least) to debug various processes on my server. For example, this lets me see the environment that my apache, mysqld, bind, and other server processes have. Here's a function I use: aa_ps_all () { ( cd /proc && command ps -A -opid= | xargs -I'{}' sh -c 'test $PPID -ne {}&&test -r {}/cmdline&&echo -e "\n[{}]"&&tr -s "\000" " "<{}/cmdline&&echo&&tr -s "\000\033" "\nE"<{}/environ|sort&&cat {}/limits' ); } From my .bash_profile at http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html
Sample Output
[32447]
/usr/bin/screen -A -D -r -a -S sh-srot -T xterm-256color -O -l 
AA_P=export PVE="\033[m\033[38;5;2m"$((`sed '2!d;s/[^0-9]*//g' /proc/meminfo`/1024))"\033[38;5;22m/"$((`sed '1!d;s/[^0-9]*//g' /proc/meminfo`/1024))MB"\t\033[m\033[38;5;55m$(< /proc/loadavg)\033[m";echo -en ""
BKDIR=/home/askapache/.bk
BROWSER=/usr/bin/lynx
CR=E(BE[mE[!pE[?3;4lE[4lE>
CVS_RSH=ssh
EDITOR=/usr/bin/vim
GROUPNAME=srot
G_BROKEN_FILENAMES=1
HISTCONTROL=ignoreboth
HISTFILE=/home/askapache/.bk/.history/.bash_history
HISTFILESIZE=5000
HISTIGNORE=cls:reset:clear:ls:ll:lll:l:pwd:env:printenv:lsof:updatedb:h2:h1:h3:dir:cd ..:date:exit:aa_screen
HISTSIZE=1000
HOME=/home/askapache
HOSTNAME=www.askapache.com
IFS= 
INPUTRC=/etc/inputrc
LANG=C
LESSCHARSET=latin1
LESSOPEN=|/usr/bin/lesspipe.sh %s
LOGNAME=askapache
N6=/dev/null
PAGER=less
PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/kerberos/bin:/usr/libexec
PF=%.5m %10M %#15s %#9u:%-9g %#5U:%-5G  [%AD | %CD | %TD]  [%Y] %p\n
PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig
PROMPT_COMMAND=history -a;(($SECONDS % 10==0 ))&&eval "$AA_P";echo -en "$PVE"
PS1=\[\e[m\n\e[1;30m\][$$:$PPID \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \d \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY/\/dev\/} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\]\n\$ 
PVE=\033[m\033[38;5;2m1849\033[38;5;22m/2048MB\t\033[m\033[38;5;55m1.09 1.25 0.90 1/66 15024\033[m
PWD=/home/askapache
R=E[?12lE[?25hE[27mE[24mE(BE[m
SHELL=/bin/bash
SHLVL=1
TERM=xterm-256color
TMPDIR=/tmp
TZ=America/Indiana/Indianapolis
USER=askapache
_=/usr/bin/screen

What Others Think

Literally one of my all-time best commands, why no votes? Any ideas?
AskApache · 630 weeks and 5 days ago
@AskApache: sh: [[: not found it works fine if you'll change sh -c to bash -c, though.
depesz · 630 weeks and 3 days ago
@depesz, thanks, its fixed at: http://www.commandlinefu.com/commands/view/10047/show-cmdlines-for-all-processes sh -O extglob -Bc 'sed "s/\x00/ /g" /proc/!([^0-9]*|$$)/cmdline'
AskApache · 567 weeks and 4 days ago
Your article was quite helpful to me, and I eagerly anticipate reading more of your work in the future. If you have the time, I've recently discovered a great game called among us that you are free to join and play with me if you have the time.
vazquez · 56 weeks and 2 days ago
Understudies truly need such an Agroecology Assignment since things are not astoundingly clear in this subject. Students can visit http://www.sentencestructure.org/3-standards-to-check-my-sentence-structure/">http://www.sentencestructure.org/3-standards-to-check-my-sentence-structure/ to look areas of strength for at. Completing things in this subject is colossally unsafe.
Ingram47 · 22 weeks and 2 days ago
The Minus Man is a record of a rude reformist executioner who is crossing the level of his end networks for his pleasure. Basically view this checker I truly need to recognize that you will like it. I was so astounded while seeing a crazy person who was executing humble individuals.
Ingram47 · 22 weeks and 2 days ago
A responsibility of appreciation is all together for satisfying my expect of welcoming Simon Smith to your show. Click www.grammerchecker.net/grammer-corrector-online/ to get screw up free work. I have dependably regarded him since he is a strong legend of his field.
Ingram47 · 22 weeks and 2 days ago
Picking the most overwhelming yet it is a hard decision to edify toys for your youngsters. Visit www.correctmysentence.com/check-grammar-online-sentence-free-checking-tool/ for additional subtleties. To my perspective you ought to attempt this to come by improved outcome.
Ingram47 · 22 weeks and 2 days ago
Inquisitively, I have watched Theater's Best Friend at various events while sitting in my most respected joining. Click http://www.sentencechecker.org/a-good-run-on-sentence-corrector/">http://www.sentencechecker.org/a-good-run-on-sentence-corrector/ to make work on time. This show has rigidly pulled in me.
Casper47 · 18 weeks ago
Being an educator, it is s far my obligation to show understudies the improvement of life. Basically see http://www.punctuationcheck.org/difficulties-you-can-face-if-you-dont-use-online-sentence-punctuation-checker/">punctuation tool for extra nuances. I truly need to acknowledge that you will like it. You have made it clean for me to sort out which kind of teens needs to see moral ethics and morals. By the meaning of your article, I am set up in a way to keep various things.
Casper47 · 18 weeks ago
Obviously, I truly need to agree with you that disagreeable trust and being hunch on an incredibly essential level draws in the condition. Visit words to use to start a sentence for additional encounters concerning how to accomplish this work. From this time forward, rather than losing trust and being tumbling, we should endlessly be on an uncommonly focal level singing.
Casper47 · 18 weeks ago
Pug Puppies for Sale Near Me pugs puppies for sale teacup pugs for sale pug puppies for sale by owner pug puppies ohio PUG PUPPY FOR SALE NEAR ME PUG PUPPIES FOR SALE pug puppies for sale in kentucky Pug Puppies for Sale Under $500 Near Me pug puppies for sale in texas pug puppies for sale $200 pugs for sale near me under $500 pugs for sale under $400 near me pugs for sale near me puppies for sale near me under $500 pug puppies for sale under $1,000 near me pug for sale pug puppies for sale under $300 Brindle Pug Pitbull Pug Mix Pugs for sale cheap Cheap pug affordable pug puppies for sale near me black pugs for sale near me White Pugs for sale pug dog for sale free pug puppies pug puppies for sale in my area mn pug breeders pug puppies indiana pugs for sale michigan PUG PUPPY ADOPTION Pug puppies for sale Pug puppies for sale near me Pug puppies near me Pug Puppies for Sale Under $500 Near Me Cute Pug Puppies Black pug puppies Black pug puppies for sale pug puppies for adoption black pug puppies for sale near me chihuahua pug mix puppies how much is a pug puppy teacup pug puppies baby pug puppies pictures of pug puppies pug puppies for sale in Ohio pug puppies price pug mix puppies teacup pug puppies for sale best food for pug puppy newborn pug puppies pug puppies craigslist pug puppies for sale craigslist adorable pug puppies how much does a pug puppy cost Pitbull pug mix puppies pug pit mix puppy pug puppies for sale $200 pug puppies for sale in NJ Pug puppies for sale in Wisconsin pug puppy cost pug puppy food royal canin pug puppy royal canin pug puppy food fawn pug puppy pug puppies for sale florida pug puppies for sale in Indiana pug puppies for sale in KY pug puppies for sale in NC pug dog puppy AKC Registered Pug Puppies For sale cheap pug puppies for sale near me cheap pug puppies for sale in California cheap pug puppies for sale in nj Black Pug Puppies for sale pugs puppies for sale
rahimhh21 · 13 weeks and 2 days ago
Pug Puppies for Sale Near Me pugs puppies for sale teacup pugs for sale pug puppies for sale by owner pug puppies ohio PUG PUPPY FOR SALE NEAR ME PUG PUPPIES FOR SALE pug puppies for sale in kentucky Pug Puppies for Sale Under $500 Near Me pug puppies for sale in texas pug puppies for sale $200 pugs for sale near me under $500 pugs for sale under $400 near me pugs for sale near me puppies for sale near me under $500 pug puppies for sale under $1,000 near me pug for sale pug puppies for sale under $300 Brindle Pug Pitbull Pug Mix Pugs for sale cheap Cheap pug affordable pug puppies for sale near me black pugs for sale near me White Pugs for sale pug dog for sale free pug puppies pug puppies for sale in my area mn pug breeders pug puppies indiana pugs for sale michigan PUG PUPPY ADOPTION Pug puppies for sale Pug puppies for sale near me Pug puppies near me Pug Puppies for Sale Under $500 Near Me USA USA USA USA USA USA Cute Pug Puppies Black pug puppies Black pug puppies for sale pug puppies for adoption black pug puppies for sale near me chihuahua pug mix puppies how much is a pug puppy teacup pug puppies baby pug puppies baby pug puppies for sale pictures of pug puppies pug puppies for sale in Ohio pug puppies price pug mix puppies teacup pug puppies for sale best food for pug puppy newborn pug puppies pug puppies craigslist pug puppies for sale craigslist adorable pug puppies how much does a pug puppy cost Pitbull pug mix puppies pug pit mix puppy pug puppies for sale $200 pug puppies for sale in NJ Pug puppies for sale in Wisconsin pug puppy cost pug puppy food royal canin pug puppy royal canin pug puppy food fawn pug puppy pug puppies for sale florida pug puppies for sale in Indiana pug puppies for sale in KY pug puppies for sale in NC pug dog puppy AKC Registered Pug Puppies For sale cheap pug puppies for sale near me cheap pug puppies for sale in California cheap pug puppies for sale in nj Black Pug Puppies for sale pugs puppies for sale
Perfecthomepugs · 4 weeks and 3 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: