> ## Content Index
> Fetch the complete content index at: https://linuxhandbook.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Show Process Tree in Linux
- URL: https://linuxhandbook.com/show-process-tree/
- Published: 2022-11-11T10:30:10.000Z
- Updated: 2023-09-16T09:22:42.000Z
- Description: Here are multiple commands that you can use to show the process tree in the Linux command line.
- Author: Sagar Sharma
- Tags: Process Handling, Tips, #docs-col, #cli

So you [used the killall](https://linuxhandbook.com/kill-process/) command and it killed the parent process making your hours of work at waste? 

Well, I went through the same so it is always a better idea to check the parent processes, and listing the ongoing processes in tree manner is a good idea. 

## Use the ps command to show the process tree

The [ps command in Linux](https://linuxhandbook.com/ps-command/) is used to find ongoing processes in Linux and it also avails you to print the exact info in a tree manner.

You can use the `--tree` option to show the process tree with the ps command:

```
ps -ef --forest
```

![use ps command in linux](https://linuxhandbook.com/content/images/2022/11/use---tree-option--1.png)

Here,

- `-e` is used to select every process.
- `-f` gets details in full format.

## Use the pstree command to show the process tree

Personally, this is what I prefer to have as even without any options, it works fine.

But your distro may not have it pre-installed and if you're on Ubuntu-based distros, the given command should do it:

```
sudo apt install psmisc
```

Now, you can simply use the `pstree` command and it should give you the following output:

```
pstree
```

![use pstree command in linux ](https://linuxhandbook.com/content/images/2022/11/pstree-.png)

Similarly, you can use `-p` option to get process IDs:

```
pstree -p
```

![show process id in pstree command](https://linuxhandbook.com/content/images/2022/11/pstree--p.png)

## Use the tree command to show the process tree

While the [tree command](https://linuxhandbook.com/tree-command/) is mainly used to [list files recursively,](https://linuxhandbook.com/list-files-recursively/) you can look at `/proc` to get the process tree.

But it requires manual installation as it does not come pre-installed and if you're on an Ubuntu-based distro, the following command should do it:

```
sudo apt install tree
```

Now, you can use the given command to show the process tree:

```
tree /proc
```

![use tree command to show process tree](https://linuxhandbook.com/content/images/2022/11/tree-proc.png)

It showed 23665 directories and 435044 files which bloated my terminal window and you can limit the info using `-d` option as it will only show directories:

```
tree -d /proc
```

![limit tree command output to directories only](https://linuxhandbook.com/content/images/2022/11/tree--d.png)

And if you want to have full pathnames, you can use `-f` option:

```
tree -f /proc
```

![get full pathnames in tree command](https://linuxhandbook.com/content/images/2022/11/tree--f.png)

## Use the htop utility to show the process tree

[htop is similar to the top command](https://linuxhandbook.com/top-vs-htop/). And in my opinion, this is arguably the most interactive way of checking ongoing processes in the terminal.

But what if I tell you that it is also capable of showing a process tree too? But before that, let's head over to the installation part.

It does not come pre-installed and if you are on an Ubuntu-based distro, the given command should do it:

```
sudo apt install htop
```

Once you are done with the installation, use the given command to start htop:

```
htop
```

![use htop in linux to show ongoing processes](https://linuxhandbook.com/content/images/2022/11/htop.png)

Now, you just have to press `F5` and the ongoing process will be shown to you in tree format:

![show process tree in linux using htop](https://linuxhandbook.com/content/images/2022/11/show-process-tree-in-linux-using-htop.png)

## Wrapping Up

One practical example of displaying the process tree is in [checking whether your system uses systemd or not](https://linuxhandbook.com/check-if-systemd/). 

This was my take on how you can show the process tree using various utilities but there is a lot more you can do with those utilities. More on them later.

To learn more, you can always use [the man page to make the most out of utilities](https://linuxhandbook.com/man-pages/).