/bin/ps: -p , -ppid difference

In my WSL, there are currently 4 init process running.

Let’s see these all with ps -p. i.e.) by specifying process IDs.

$ ps wwwo pid,args -p $(pgrep init)
    1 /init ro
 5478 /init ro
 5479 /init ro
 5481 /init ro

Now, let’s see child process for all of these 4 ‘init’ in one scoop.

$ ps -fH --ppid $(pgrep init|tr '\n' ','|sed 's/,$//')
root      5481     1  0 08:19 tty7     00:00:00 /init ro
kinoue    5482  5481  0 08:19 tty7     00:00:00   -bash
root      5479     1  0 08:19 tty6     00:00:00 /init ro
kinoue    5483  5479  0 08:19 tty6     00:00:01   -bash
root      5478     1  0 08:19 tty5     00:00:00 /init ro
kinoue    5480  5478  0 08:19 tty5     00:00:00   -bash

I used hierarchical/tree format option so that parent/child relationship is easier to see.

Please notice that process ID list format is different between “-p”, “–pid”, “–ppid”.   Looks like “–ppid” requires comma delimited list while space works for “-p”.

PAGER env var and less alias

I guess a lot of people defines alias for /usr/bin/less in ~/.bashrc or ~/.bash_profile. But I guess a large percentage of those people forget to propagate(synchronize) the less alias definition to PAGER environment variable.

I just set it today like below 🙂  and testd.  ‘man’ command reads PAGER env. var .


$ unset PAGER
$ man bash
$ alias less='less -I -j 3 -X'
$ export PAGER=${BASH_ALIASES[less]}
$ man bash

If you look at last 10 lines carefully in above, you notice ‘less’ behaved differently because of options, i.e. “-j -3 -X”.

I hope this synchronization will be defined by default in future distribution, maybe Ubuntu. This is so easy to be overlooked.