Pstree : lister ses process sous forme d'arbre

From / Bloc Notes Informatique
Jump to: navigation, search

1 Introduction

Iff you're using a system which has a lot of users, and you'd like to see who has started a particular script, daemon, or binary, then the pstree utility is very helpful. It draws a tree of all currently running processes - allowing you to see which processes are related.

In much the same way as the tree command isn't likely to be generally useful, this command might seem a little pointless if you're on a single-user machine, and you essentially start everything yourself. But even so it can be helpfull to see where processes have come from.

2 Examples

The most basic usage would look something like this:

Command pstree
$  pstree
     |         |-ata/0
     |         |-ata_aux
     |         |-kblockd/0
     |         |-khubd
     |         |-kjournald
     |         |-kmirrord
     |         |-kseriod
     |         |-kswapd0
     |         |-2*[pdflush]
     |         |-xenbus
     |         `-xenwatch
     |             `-mysqld---16*[{mysqld}]
     |      `-sshd---sshd---bash---pstree

Here we can see several kernel processes running, (aio, ata, kseriod, etc.), several system daemons (syslog-ng, qpsmtpd, etc), as well as the ssh processes open for my current user.

There aren't many ways of customising the output of the display, although you can modify several things such as the display of command line arguments with :

Command pstree
pstree -a
  |-screen -S foo
  |   `-bash
  |-screen -S bar
  |   `-bash
  |-syslog-ng -p /var/run/
  |-udevd --daemon
  |-vino-session --sm-client-id default5
  |   `-{xenconsoled}
  `-xenstored --pid-file /var/run/

For all the available options please read the manpage via "man pstree".

If you don't have the pstree command available then you may find it in the psmisc package, and it may be installed by apt-get, or aptitude in the usual manner.

3 References