While I have two terminals open, when I run [program name] & in one terminal, why is it that when I then run ps on both terminals, only the one I have used to run the program shows the processes?
1 Answer
See man ps
By default,
psselects all processes with the same effective user ID (euid=EUID) as the current user and associated with the same terminal as the invoker.
You are probably running the ps command in both terminals as the same user, but these are two different terminals. As the documentation states, ps will by default only show processes associated with the same terminal.
You can see the ID of the terminal using the tty command.
To see processes associated with specific terminals, you could use option -t.
-
I don't understand, if it selected all with same ID why does one terminal recognise the program I opened and the other does not? Do you mean the second terminal differs in ID? What ID and how can I view the ID's of both? Also, does this have anything to do with TTY being different in each terminalhoncho– honcho2022-01-27 19:52:53 +00:00Commented Jan 27, 2022 at 19:52
-
@honcho I did not write anything about a different user, but your processes are associated with different terminals.Bodo– Bodo2022-01-27 19:56:55 +00:00Commented Jan 27, 2022 at 19:56
-
Where does your definiton of ps come from? I feel like there is more of a reason and your mention of a EUID, where can I find this?honcho– honcho2022-01-27 19:58:35 +00:00Commented Jan 27, 2022 at 19:58
-
1Each distinct username has a different UID. The
idcommand shows this likeuid=1000(paul) gid=1000(paul) ...followed by some other group information. Each terminal session is a controlling terminal for a group of processes that were initiated from it. If I am working on several tasks at once in different terminals, I only want each terminal to tell me about its local tasks. There are otherpsoptions that give the kind of report that a SysAdmin might need to look at all the activities on a system.Paul_Pedant– Paul_Pedant2022-01-27 20:03:30 +00:00Commented Jan 27, 2022 at 20:03 -
1@honcho regarding EUID: en.wikipedia.org/wiki/User_identifierBodo– Bodo2022-01-27 20:08:03 +00:00Commented Jan 27, 2022 at 20:08