Unix/Linux Go Back    


UNIX for Beginners Questions & Answers If you're not sure where to post a Unix or Linux question, post it here. All unix and Linux beginners welcome in this forum!

Ps command

UNIX for Beginners Questions & Answers


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 10-11-2017   -   Original Discussion by dummyx
dummyx's Unix or Linux Image
dummyx dummyx is offline
Registered User
 
Join Date: Oct 2017
Last Activity: 11 October 2017, 5:15 PM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Ps command

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!

Last edited by rbatte1; 10-12-2017 at 09:09 AM.. Reason: ICODE tags for clarity
Sponsored Links
    #2  
Old Unix and Linux 10-11-2017   -   Original Discussion by dummyx
apmcd47's Unix or Linux Image
apmcd47 apmcd47 is offline
Registered User
 
Join Date: Feb 2011
Last Activity: 12 April 2018, 11:24 AM EDT
Posts: 336
Thanks: 16
Thanked 92 Times in 87 Posts
Quote:
Originally Posted by dummyx View Post
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

Last edited by rbatte1; 10-12-2017 at 09:10 AM.. Reason: Retro-fit ICODE tags into quoted post
Sponsored Links
    #3  
Old Unix and Linux 10-11-2017   -   Original Discussion by dummyx
dummyx's Unix or Linux Image
dummyx dummyx is offline
Registered User
 
Join Date: Oct 2017
Last Activity: 11 October 2017, 5:15 PM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
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...

Last edited by rbatte1; 10-12-2017 at 09:11 AM..
    #4  
Old Unix and Linux 10-11-2017   -   Original Discussion by dummyx
wbport's Unix or Linux Image
wbport wbport is offline
Registered User
 
Join Date: Sep 2013
Last Activity: 20 April 2018, 12:09 PM EDT
Location: Mississippi
Posts: 135
Thanks: 35
Thanked 21 Times in 21 Posts
Our shop has ps -ef in a number of scripts--does that work?

Last edited by rbatte1; 10-12-2017 at 09:11 AM.. Reason: Added ICODE tags
Sponsored Links
    #5  
Old Unix and Linux 10-11-2017   -   Original Discussion by dummyx
MadeInGermany's Unix or Linux Image
MadeInGermany MadeInGermany is offline Forum Staff  
Moderator
 
Join Date: May 2012
Last Activity: 21 April 2018, 10:56 AM EDT
Location: Simplicity
Posts: 4,036
Thanks: 346
Thanked 1,356 Times in 1,222 Posts
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.
Sponsored Links
    #6  
Old Unix and Linux 10-11-2017   -   Original Discussion by dummyx
dummyx's Unix or Linux Image
dummyx dummyx is offline
Registered User
 
Join Date: Oct 2017
Last Activity: 11 October 2017, 5:15 PM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by MadeInGermany View Post
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?

Last edited by rbatte1; 10-12-2017 at 09:12 AM.. Reason: Added ICODE tags for clarity
Sponsored Links
    #7  
Old Unix and Linux 10-11-2017   -   Original Discussion by dummyx
MadeInGermany's Unix or Linux Image
MadeInGermany MadeInGermany is offline Forum Staff  
Moderator
 
Join Date: May 2012
Last Activity: 21 April 2018, 10:56 AM EDT
Location: Simplicity
Posts: 4,036
Thanks: 346
Thanked 1,356 Times in 1,222 Posts
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.)
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
SH script, variable built command fails, but works at command line oly_r Shell Programming and Scripting 8 09-14-2012 05:56 PM
passing command output from one command to the next command in cshell kaaliakahn UNIX for Dummies Questions & Answers 2 02-10-2012 04:59 PM
unix command : how to insert text at the cursor location via command line? xib.be UNIX for Advanced & Expert Users 0 12-22-2010 05:45 PM
Need help! command working ok when executed in command line, but fails when run inside a script! 4dirk1 Shell Programming and Scripting 4 12-02-2010 05:47 AM
awk/sed Command : Parse parameter file / send the lines to the ksh export command rajan_san Shell Programming and Scripting 4 11-06-2008 12:29 PM



All times are GMT -4. The time now is 03:16 PM.