2

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 1

3

See man ps

By default, ps selects 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.

8
  • 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 terminal Commented Jan 27, 2022 at 19:52
  • @honcho I did not write anything about a different user, but your processes are associated with different terminals. Commented 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? Commented Jan 27, 2022 at 19:58
  • 1
    Each distinct username has a different UID. The id command shows this like uid=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 other ps options that give the kind of report that a SysAdmin might need to look at all the activities on a system. Commented Jan 27, 2022 at 20:03
  • 1
    @honcho regarding EUID: en.wikipedia.org/wiki/User_identifier Commented Jan 27, 2022 at 20:08

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.