Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

pstree

Show the running processes as a tree: who started whom.

Niveau
Dagelijks Linux
Groep
Processen en jobs
Root nodig
Nee
Pakket
psmisc

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

pstree draws the processes from systemd (PID 1) down. Identical children are compacted: httpd───5*[httpd] means five httpd children. Use -p for PIDs and -a for the full command lines.

Zo schrijf je het

pstree [OPTION]... [PID | USER]

Opties 20

Meest gebruikt

-p
Show PIDs (turns off compaction).
-a
Show the command line arguments.
-u
Show user changes, like (apache).
-s
Show the parents of the given PID.
-h
Highlight the current process and its parents.
-H PID
Highlight this process.
-n
Sort by PID.
-c
Do not compact identical subtrees.
-l
Long lines (no cut).
-g
Show process group IDs.
-t
Full names of threads.
-T
Hide threads.
-A
ASCII lines.
-G
VT100 lines.
-U
UTF-8 lines.
-C age
Color by age.
-N TYPE
One tree per namespace (ipc, mnt, net, pid, user, uts, cgroup, time).
-S
Show namespace changes.
-Z
Show the SELinux context.
-V
Show the version.

Voorbeelden 10

$ als gewone gebruiker# als root (of met sudo)

  1. 1The whole tree

    pstree | head
    systemd─┬─NetworkManager───3*[{NetworkManager}]
            ├─chronyd
            ├─sshd───sshd───sshd───bash───pstree

    {…} are threads.

  2. 2With PIDs

    pstree -p | head

    Find the PID of a parent quickly.

  3. 3Tree of one process

    pstree -p 1010

    Only the sshd master and its sessions.

  4. 4Where does my shell come from?

    pstree -s -p $$
    systemd(1)───sshd(1010)───sshd(2210)───sshd(2215)───bash(2216)

    The chain of parents.

  5. 5Show the user of each part

    pstree -u

    (apache) shows where a process changed to another user.

  6. 6Full command lines

    pstree -a | less

    Shows the options of each program.

  7. 7Processes of one user

    pstree lisa

    All trees owned by lisa.

  8. 8Find odd children of a web server (security)

    pstree -p -a $(pgrep -o httpd)

    A shell (bash, sh) under httpd can mean a web shell attack.

  9. 9Do not compact

    pstree -c -p | grep httpd

    Every child on its own line.

  10. 10Container namespaces

    pstree -N pid

    Separate trees for each PID namespace (containers).

Exitcodes

0 :: Done. 1 :: Error.

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man pstree