# Linux commands: traceroute

> Learn how the Linux traceroute command maps every router hop your packets take to reach a host, showing the IP and timing of each, and tuning samples with -q.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2020-10-12 | Topics: [CLI](https://flaviocopes.com/tags/cli/) | Canonical: https://flaviocopes.com/linux-command-traceroute/

When you try to reach a host on the Internet, you go through your home router, then you reach your ISP network, which in turn goes through its own upstream network router, and so on, until you finally reach the host.

Have you ever wanted to know what are the steps that your packets go through to do that?

The `traceroute` command is made for this.

You invoke

```bash
traceroute <host>
```

and it will (slowly) gather all the information while the packet travels.

In this example I tried reaching for my blog with `traceroute flaviocopes.com`:

![Terminal showing traceroute flaviocopes.com output with 13 hops and 3 timing samples per router](https://flaviocopes.com/images/linux-command-traceroute/Screen_Shot_2020-09-09_at_16.32.01.png)

Not every router travelled returns us information. In this case, `traceroute` prints `* * *`. Otherwise, we can see the hostname, the IP address, and some performance indicator.

For every router we can see 3 samples, which means traceroute tries by default 3 times to get you a good indication of the time needed to reach it. This is why it takes this long to execute `traceroute` compared to simply doing a `ping` to that host.

You can customize this number with the `-q` option:

```bash
traceroute -q 1 flaviocopes.com
```

![Terminal showing traceroute -q 1 flaviocopes.com output with 13 hops and only 1 timing sample per router](https://flaviocopes.com/images/linux-command-traceroute/Screen_Shot_2020-09-09_at_16.36.07.png)

The `traceroute` command works on Linux, macOS, WSL, and anywhere you have a UNIX environment
