# Ps command

**URL:** <https://community.unix.com/t/ps-command/368751>\
**Category:** UNIX for Beginners Q & A\
**Created:** [October 11, 2017, 9:52am UTC](https://community.unix.com/t/ps-command/368751 "2017-10-11T09:52:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dummyx](https://community.unix.com/letter_avatar/dummyx/32/6_22734026db12803ebb3e059622ac3534.png) [@dummyx](https://community.unix.com/u/dummyx)\
**Post date:** [October 11, 2017, 9:52am UTC](https://community.unix.com/t/ps-command/368751/1 "2017-10-11T09:52:06Z")

</div>

Hi,  
I'm trying to learn Unix and I've yet the first problems on a basic command like ps.

If I have 2 different parameters, one more "restrictive" than the other, which of those controls? Let me explain:  
`-a` : Select all processes except both session leaders and processes not associated with a terminal.  
`-d` : Select all processes except session leaders.  
If I use `ps -ad` is the same thing that use `ps -da` ? If the more "restrictive is `a` , is the `d` parameter superfluous?

a command like `ps -edaf` what processes will show?

Thank you!

---

<div class="post-metadata">

**Author:** ![apmcd47](https://community.unix.com/letter_avatar/apmcd47/32/6_22734026db12803ebb3e059622ac3534.png) [@apmcd47](https://community.unix.com/u/apmcd47)\
**Post date:** [October 11, 2017, 10:03am UTC](https://community.unix.com/t/ps-command/368751/2 "2017-10-11T10:03:38Z")

</div>

> [@dummyx](#):
>
> Hi,  
> I'm trying to learn Unix and I've yet the first problems on a basic command like ps.
> 
> If I have 2 different parameters, one more "restrictive" than the other, which of those controls? Let me explain:  
> `-a` : Select all processes except both session leaders and processes not associated with a terminal.  
> `-d` : Select all processes except session leaders.  
> If I use `ps -ad` is the same thing that use `ps -da` ? If the more "restrictive is `a` , is the `d` parameter superfluous?
> 
> a command like `ps -edaf` what processes will show?
> 
> Thank you!

Assuming you have access to a Unix or Linux machine, why not try all combinations and find out? Assuming the output is one process listed per line you could pipe the output of `ps` into `wc -l` just to see how long each listing would be. Then you can draw your own conclusions.

Andrew

---

<div class="post-metadata">

**Author:** ![dummyx](https://community.unix.com/letter_avatar/dummyx/32/6_22734026db12803ebb3e059622ac3534.png) [@dummyx](https://community.unix.com/u/dummyx)\
**Post date:** [October 11, 2017, 10:09am UTC](https://community.unix.com/t/ps-command/368751/3 "2017-10-11T10:09:36Z")

</div>

I tried, but I didn't understand.  
I tried, for example, ps -e, then ps -ed and the list was shorter than the first. So I thought it was depending on the `d` parameter, more restrictive, but I tried `ps -d` and the list was shorter again, so the `-d` parameter alone was more restrictive...  
I tried other combinations, but had the same, confusing, results...

---

<div class="post-metadata">

**Author:** ![wbport](https://community.unix.com/letter_avatar/wbport/32/6_22734026db12803ebb3e059622ac3534.png) [@wbport](https://community.unix.com/u/wbport)\
**Post date:** [October 11, 2017, 10:16am UTC](https://community.unix.com/t/ps-command/368751/4 "2017-10-11T10:16:30Z")

</div>

Our shop has `ps -ef` in a number of scripts--does that work?

---

<div class="post-metadata">

**Author:** ![MadeInGermany](https://community.unix.com/letter_avatar/madeingermany/32/6_22734026db12803ebb3e059622ac3534.png) [@MadeInGermany](https://community.unix.com/u/MadeInGermany)\
**Post date:** [October 11, 2017, 4:45pm UTC](https://community.unix.com/t/ps-command/368751/5 "2017-10-11T16:45:34Z")

</div>

The result of conflicting options depends on the ps version and should be documented in `man ps` .  
The order of options should never matter, `ps -ad` is indentical with `ps -da` .  
Please note that if you compare `ps -e` then `ps -ed` on an active system then it can differ because the number of processes have changed in between.

---

<div class="post-metadata">

**Author:** ![dummyx](https://community.unix.com/letter_avatar/dummyx/32/6_22734026db12803ebb3e059622ac3534.png) [@dummyx](https://community.unix.com/u/dummyx)\
**Post date:** [October 11, 2017, 5:15pm UTC](https://community.unix.com/t/ps-command/368751/6 "2017-10-11T17:15:30Z")

</div>

> [@madeingermany](#):
>
> The result of conflicting options depends on the ps version and should be documented in `man ps` .  
> The order of options should never matter, `ps -ad` is indentical with `ps -da` .  
> Please note that if you compare `ps -e` then `ps -ed` on an active system then it can differ because the number of processes have changed in between.

Thanks. So instead of using `ps -ed` I'd use `ps -d` obtaining the same result, correct?

---

<div class="post-metadata">

**Author:** ![MadeInGermany](https://community.unix.com/letter_avatar/madeingermany/32/6_22734026db12803ebb3e059622ac3534.png) [@MadeInGermany](https://community.unix.com/u/MadeInGermany)\
**Post date:** [October 11, 2017, 6:24pm UTC](https://community.unix.com/t/ps-command/368751/7 "2017-10-11T18:24:11Z")

</div>

No, `-e` and `-d` conflict, so consult your man page or try it out on the command line.  
And if you try it out, be aware that the number of processes on the system can change any time. Even your ps command makes a process, and there is a race condition: the process table can be listed \*before\* or \*after\* the ps process appears in it.  
(Tools like pgrep or pidof are safer, they take care to not list themselves.)
