12

I am reading the Unix Power Tools book, and came across the ps command. The output of command ps x as given in the book is:

PID TTY STAT TIME COMMAND 18034 tty2 S 0:00 -zsh 18059 ? S 0:01 ssh-agent 18088 tty2 S 0:00 sh /usr/X11R6/bin/startx 18096 tty2 S 0:00 xinit /etc/X11/xinit/xinitrc -- :0 -auth /home/jpeek/ 18101 tty2 S 0:00 /usr/bin/gnome-session 18123 tty2 S 0:33 enlightenment -clientId default2 18127 tty2 S 0:01 magicdev --sm-client-id=default12 18141 tty2 S 0:03 panel --sm-client-id default8 18145 tty2 S 0:01 gmc --sm-client-id default10 18166 ? S 1:20 gnomepager_applet --activate-goad-server gnomepager_a 18172 tty2 S 0:01 gnome-terminal 18174 tty2 S 0:00 gnome-pty-helper 18175 pts/0 S 0:00 zsh 18202 tty2 S 0:49 gnome-terminal 18203 tty2 S 0:00 gnome-pty-helper 18204 pts/1 S 0:01 zsh 18427 pts/1 T 0:00 man zshjp 18428 pts/1 T 0:00 sh -c /bin/gunzip -c /home/jpeek/.man/cat1/zshjp.1.gz 18430 pts/1 T 0:03 /usr/bin/less -is 18914 pts/1 T 0:02 vi upt3_changes.html 1263 pts/1 T 0:00 vi urls.html 1511 pts/1 T 0:00 less coding 3363 pts/1 S 0:00 vi 1007.sgm 4844 tty2 S 0:24 /usr/lib/netscape/netscape-communicator -irix-session 4860 tty2 S 0:00 (dns helper) 5055 pts/1 R 0:00 ps x 

Can someone help in decoding this output? What is meant by pts/0 and pts/1?

  1. All I could find was that pts stands for "pseudo terminal slave", but couldn't understand the difference behind pts/0 and pts/1.
  2. Why is there a ? in TTY column? Why is the tty unknown for that process?
  3. What is the meaning of various Gnome applications such as gnome-pty-helper and gnomepager_applet?

Many Thanks.

2 Answers 2

6

Back in the days, terminals were physical devices connected to a serial port each. These show up in UNIX as 'device files' in /dev.

You are running Linux, by the looks of your output, and thus there are two different types of 'virtual' terminal. The first set are those connected via your display. Linux creates a bunch of them, and you can toggle between them using Ctrl+Alt+Fn . These are tty0, tty1, etc.

Then there is the concept of a pseudo terminal. One is required for each ssh session that you use to connect to your system, and one for each (Gnome) X terminal session. These are the 'pts/n' names. Search for 'pseudo terminal' to learn more.

Thus the above output tells me that: your graphical session is tied to the 2nd virtual terminal ( Ctrl+Alt+F2 ). You have two gnome terminals, pts/0 and pts/1.

Try opening a new VT using Ctrl+Alt+F1 and log in there, and repeat on terminals 3 and 4. Each time you do this ps -ef will show the processes running with that terminal.

Background processes do not have a terminal attached, and will show ? in the TTY column.

6
  1. They are different instances of a pseudo terminal. E.g. they are different tabs in a Terminal window.
  2. There is no TTY. This process has detached from the tty. Using the TIOCNOTTY ioctl(), or setsid(). This is traditionally done to become a background process a.k.a. "daemon", which will not automatically be killed by SIGHUP when logging out from a terminal. (If it is a gnome process as in this example, it will likely be expected to terminate by some other mechanism).

    Alternatively it may never have had a TTY to start with, as with processes started for a systemd service for example.

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.