You are on page 1of 21

04/04/2019 networking - How to display network traffic in the terminal?

- Ask Ubuntu

How to display network traffic in the terminal? Ask Question

how to display the actual network traffic (wireless) in a terminal?

Additionally: Is it possible to add this info to the chart of  top ?


363
networking

edited Aug 26 '17 at 4:06


201
新疆改造中
Ciro Santilli
⼼ 六四事件 法轮功
10.4k 4 48 51

asked Feb 17 '13 at 10:32


IndexOutOfBoundsExce
ption
2,299 5 13 22

2 Any solutions for the "Is it possible to add this info to the chart of  top ?"
part? :) – Janaka Bandara Dec 25 '15 at 2:57

1 @JanakaBandara check out Glances. – ESala Mar 7 '17 at 18:00 

18 Answers

Here are some nice tools in the Ubuntu repositories for command
line network traffic monitoring:
403 bmon - shows multiple interfaces at once

https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 1/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu

slurm - has nice colored graphs

https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 2/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu

tcptrack - A favorite. Tells how much bandwidth is being used and


also what protocol (service/port) and destination the transmission is
taking place to. Very helpful when you want to know exactly what is
using up your bandwidth

edited Jun 13 '16 at 11:31

answered Feb 17 '13 at 13:19


tomodachi
9,467 4 22 41

7 bmon is really cool! has a graph like slurm but not colorful. – EtherealJan
10 '14 at 21:27

21 sudo apt-get install bmon slurm tcptrack  – Nabil Kadimi Oct 6


'15 at 17:44

1 nload  deserves mentioning for better separation of upload and


download (also not colourful) – Chris Apr 2 '16 at 1:17

1 tcptrack is cool! – Robert Apr 9 '16 at 10:56


https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 3/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu

sudo apt install ethstatus  – isync Jan 5 '18 at 18:14

It's quite easy! install "iftop" with:

130 sudo apt-get install iftop

Then run

sudo iftop

from any terminal!

Enjoy!

edited Aug 26 '17 at 3:28


新疆改造中
Ciro Santilli
⼼ 六四事件 法轮功
10.4k 4 48 51

answered Feb 17 '13 at 11:45


Tribaal
1,479 1 7 3

6 To see anything, I have to run (Ubuntu using wifi): $ sudo iftop -i wlan0 –
 russian_spy Jun 3 '15 at 20:08 

does  iftop  also record or log the network bandwidth from time to time?
Currently I'm using both  vnstat  and  iftop  for different usage,
and vnstat  logs the bandwidth usage. It would be excessive and add
more loads to my server if  iftop  does it too. – Oki Erie Rinaldi Oct 10
'18 at 4:52 

https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 4/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu

Someone should also have mentioned  nethogs .

The thing that's different and maybe is cooler about this one is that it
118 shows traffic per process, like the image shows

Take a look at the page

edited Dec 1 '17 at 9:14


Alex
211 3 11

answered Jan 17 '14 at 12:20


arsaKasra
1,945 1 11 16

8 To install:  sudo apt-get -y install nethogs  then  sudo


nethogs – bmaupin Sep 2 '14 at 15:18

Very useful utility, just note that you may need to take a few extra steps
installing to make it work on 14.04
as askubuntu.com/a/729560/79176describes. – Huge May 18 '17 at 13:56

For those with Debian Jessie who happen to come here, too: A working

https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 5/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu
version is in Backports:  apt-get install nethogs/jessie-
backports  (you need to add jessie-backports first). – Tino Feb 10 '18 at
19:46

There is a nice tool called speedometer that displays a graph in the


terminal using Unicode block characters, colors, and even adds
labels to each peak in the graph.
47
$ sudo apt-get install speedometer
$ speedometer -l -r wlan0 -t wlan0 -m $(( 1024 * 1024 * 3

It has several options, can monitor multiple interfaces, can show


multiple graphs in several rows or columns, and can even monitor
the download speed of a single file (by watching the file size on
disk).

answered Jun 18 '15 at 17:01


Denilson Sá Maia

https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 6/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu
1,936 18 20

1 This is by far the nicest visiual graph i've ever seen in a plain text display.
I will be looking into the gui library by the same author
now: urwid.org(source code and author: github.com/wardi) –
 ThorSummoner Dec 11 '15 at 23:25

@ThorSummoner: This is getting off-topic, but urwid is the library used by


the awesome PuDB Python debugger. – Denilson Sá Maia Dec 13 '15 at
1:53

This just sits at "waiting for <interface> to be created". – felwithe Apr 4 '18


at 4:18 

@felwithe That probably means you passed the wrong network interface
name. Try changing  wlan0  in that command to  eth0  or to whatever is
the name of the network interface in your system. See
also:unix.stackexchange.com/a/125406 – Denilson Sá Maia Apr 8 '18 at
22:53

@DenilsonSáMaia I did not; I checked that. I tried the other interfaces as


well. That was all the time I had to fiddle with it. I was having network
problems and had to find a tool that worked ASAP. I used one of the
simple ones, and it turned out that the problem wasn't bandwidth
anyway.– felwithe Apr 9 '18 at 20:07 

iptraf
42 IPTraf is a console-based network statistics utility for Linux. It
gathers a variety of figures such as TCP connection packet and
byte counts, interface statistics and activity indicators, TCP/UDP
traffic breakdowns, and LAN station packet and byte counts.

Features

An IP traffic monitor that shows information on the IP traffic


passing over your network. Includes TCP flag information, packet
and byte counts, ICMP details, OSPF packet types. General and
https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 7/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu

detailed interface statistics showing IP, TCP, UDP, ICMP, non-IP


and other IP packet counts, IP checksum errors, interface activity,
packet size counts. A TCP and UDP service monitor showing
counts of incoming and outgoing packets for common TCP and
UDP application ports A LAN statistics module that discovers
active hosts and shows statistics showing the data activity on
them TCP, UDP, and other protocol display filters, allowing you to
view only traffic you're interested in. Logging Supports Ethernet,
FDDI, ISDN, SLIP, PPP, and loopback interface types. Utilizes
the built-in raw socket interface of the Linux kernel, allowing it to
be used over a wide range of supported network cards. Full-
screen, menu-driven operation.

Protocols Recognized

IP TCP UDP ICMP IGMP IGP IGRP OSPF ARP RARP

Non-IP packets will simply be indicated as "Non-IP" and, on


Ethernet LAN's, will be supplied with the appropriate Ethernet
addresses.

Supported Interfaces

Local loopback All Linux-supported Ethernet interfaces All Linux-


supported FDDI interfaces SLIP Asynchronous PPP
Synchronous PPP over ISDN ISDN with Raw IP encapsulation
ISDN with Cisco HDLC encapsulation Parallel Line IP

Source http://iptraf.seul.org/about.html

Installation

With  apt :

apt-get install iptraf

Or download the source:

https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 8/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu

http://iptraf.seul.org/download.html

Screenshots

Current Connections:

Current Ports:

https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 9/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu

Summary of all Interfaces:

Detailed per Interface:

https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 10/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu

Source http://iptraf.seul.org/shots.html

edited Aug 29 '14 at 7:40

answered Aug 29 '14 at 6:23


jpillora
521 4 5

tcpdump -i eth0

25 That will give you a streaming information of all the data flowing from
that interface (your ethernet card). Similar to wireshark.

Use  ifconfig  to see a list of your machines interfaces.

answered May 16 '13 at 9:05


wardr
929 2 13 21

https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 11/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu

This will certainly display the network information... Not a very user-
friendly interface, nor does it have aggregate stats. Definitely think of this
like wireshark. – user2943160 Jul 6 '16 at 18:25

I think  ifconfig [interface]  will do that. Like:

22 gevorg@gevorg-TravelMate-3260:~$ ifconfig wlan0


wlan0 Link encap:Ethernet HWaddr 00:18:de:89:52:71
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

gevorg@gevorg-TravelMate-3260:~$ ifconfig eth0


eth0 Link encap:Ethernet HWaddr 00:16:36:bf:92:e3
inet addr:192.168.10.100 Bcast:192.168.10.255 Mask
inet6 addr: fe80::216:36ff:febf:92e3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:342765 errors:0 dropped:0 overruns:0 frame
TX packets:306183 errors:0 dropped:0 overruns:0 carri
collisions:0 txqueuelen:1000
RX bytes:373934806 (373.9 MB) TX bytes:39111569 (39
Interrupt:16

It shows RX bytes:73934806 (373.9 MB) and TX bytes:39111569


(39.1 MB).

answered Feb 17 '13 at 10:34


hingev
5,014 4 31 58

2 but this is only the over-all statistic for this session. I would see if the
connection is active or not. –  IndexOutOfBoundsException  Feb 17 '13 at
10:38 

6 netstat -t -u -c  ? – hingev Feb 17 '13 at 10:41

https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 12/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu

Install ’vnstat’ it can show traffic for an interface. You can install
some plotting packages to get some nice graphs.
13 answered Feb 17 '13 at 11:33
McNisse
1,465 1 12 15

1 This seems to be the best option to get a usage


history:askubuntu.com/questions/1459/… –
新疆改造中⼼ 六四事件 法轮功
 Ciro Santilli  Aug 26 '17 at 3:53

Another useful tool is sar. Install it,

13 apt install sysstat

How to use it:

sar -n DEV 1

https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 13/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu

And Brendan's amazing graph guide: 

References

http://www.brendangregg.com/linuxperf.html
Linux Performance Observability: sar

edited May 19 '17 at 18:50


slm
1,770 1 18 24

answered Mar 9 '17 at 16:41


firo
954 8 10

+1 for mentioning  sar , which does the job and is included (and enabled)
by default with most if not all distros. – vladr Mar 29 '18 at 18:06

https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 14/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu

Also you could use  iftop  utility


11 answered Feb 17 '13 at 11:42
failor
233 1 6

If you are looking for something extremely simple, but still useful,
try  ifstat
11
$ sudo apt-get install ifstat
$ ifstat
eth0 wlan0
KB/s in KB/s out KB/s in KB/s out
0.00 0.00 0.96 4.79
0.00 0.00 0.04 0.14

It monitors all interfaces at once, printing a new line every second.


Useful to pipe into another script, or to leave running and observe
the bandwidth usage over time. Not as pretty as other tools, but it
gets the job done.

There are some useful options listed in the manpage:

-z Hides interface which counters are null, eg interfaces


not used.
-n Turns off displaying the header periodically.
-t Adds a timestamp at the beginning of each line.
-T Reports total bandwith for all monitored interfaces.
-S Keep stats updated on the same line if possible (no sc
wrapping).
-b Reports bandwith in kbits/sec instead of kbytes/sec.

edited Oct 18 '15 at 13:45

answered Jun 18 '15 at 16:14


Denilson Sá Maia
https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 15/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu
1,936 18 20

1 I love this command:  ifstat -zntS , which outputs only network


interface that are not null, with timestamps, without header showing
periodically and with results in only one line (I love man pages). –
 Igor V.Oct 17 '15 at 19:12 

Ifstat is good tool and it will give you all the interface network usage
with respect to time.
8
sudo apt-get install ifstat

edited Sep 21 '18 at 19:39

answered Nov 7 '16 at 8:40


GNK
1,076 1 8 13

Another possible tool is


https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 16/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu

called  nload .http://linux.die.net/man/1/nload


4 Similar to  slurm  or  bmon , but a little more simplistic.

answered Apr 2 '16 at 1:20


Chris
141 5

This is not specific to networking, but Glances can display network


traffic of different interfaces.
4

Install it with one of those commands :

sudo snap install glances


sudo apt install glances

edited Feb 21 at 4:11

https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 17/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu
answered Nov 23 '18 at 0:19
NatoBoram
203 1 12

According to ifconfig man:

3 This program is obsolete! For replacement check ip addr and ip


link. For statistics use ip -s link.

So using ip command:

$ ip -s link

We can get network stats:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue stat


DEFAULT group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
RX: bytes packets errors dropped overrun mcast
173654497900 26078946 0 0 0 0
TX: bytes packets errors dropped carrier collsns
173654497900 26078946 0 0 0 0
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
UP mode DEFAULT group default qlen 1000
link/ether 12:34:56:78:90:00 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
3650412438854 399476618 0 2551849 0 0
TX: bytes packets errors dropped carrier collsns
617437624480 321390259 0 0 0 0

Or

$ ip -s -h link

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue stat


DEFAULT group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 18/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu
addrgenmode eui64
RX: bytes packets errors dropped overrun mcast
174G 26.1M 0 0 0 0
TX: bytes packets errors dropped carrier collsns
174G 26.1M 0 0 0 0 2: ens3:
<BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fas
DEFAULT group default qlen 1000
link/ether 12:34:56:78:90:00 brd ff:ff:ff:ff:ff:ff pro
addrgenmode eui64
RX: bytes packets errors dropped overrun mcast
3.65T 399M 0 2.55M 0 0
TX: bytes packets errors dropped carrier collsns
617G 321M 0 0 0 0

answered Nov 30 '17 at 8:23


Ruslan
261 2 4

I recently discovered  wavemon  which can easily be installed


using  apt-get install wavemon .
2 This tool provides information especially on the signal level of the
wireless network.

answered Dec 24 '14 at 10:13


IndexOutOfBoundsExce
ption
2,299 5 13 22

And this is a blog showing a list of command to monitor bandwidth:

http://www.binarytides.com/linux-commands-monitor-network/
2
UPDATE:

I've been using NetHogs for about two months. It shows you total


bandwidth usage. With the following setting you can additionally get
https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 19/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu

bandwidth usage for each program


sudo nethogs -v 3

edited Apr 5 '18 at 18:22

answered Nov 27 '17 at 18:48


Asme Just
344 2 9

There's also conky.

You might have the package listed in your system's currently used
1 repositories. Try running:

sudo apt-get install conky-all

Some basic configuration info: Ubuntu Community Docs: Configuring


Conky. CAUTION: The info on that site may be out of date, so
please verify the steps listed there apply to your system.

Of course, a basic conky is very boring to look at, so here's a good


conky theme to get you started:

Harmattan

Just follow the instructions on that page for setup; to install a


particular theme, copy the  .conkyrc  file from the corresponding
folder for the theme in the  .harmattan-themes  folder to your home
directory.

Then, edit the file according to the instructions on the linked page.

TIP

https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 20/21
04/04/2019 networking - How to display network traffic in the terminal? - Ask Ubuntu

Modify the file after copying it to your home folder, this way you get
to keep the original un-altered files in case you need to re-copy
the  .conkyrc  file for a theme.

answered Apr 7 '17 at 15:35


ThisIsNotAnId
105 3 17

https://askubuntu.com/questions/257263/how-to-display-network-traffic-in-the-terminal 21/21

You might also like