logo

CodeHiRise

3 Linux network analyze commands you must know

2ish minutes read

linuxnetworking
3 Linux network analyze commands you must know cover

Hi everyone,

We will discuss the top 3 useful Linux network commands in this article.

These commands are quite useful in debugging network issues in systems and also

To get a better understanding of the networking systems you are working with.

Let's begin without further ado.

ip

As first in the list ip command . IP is a popular tool for viewing and manipulating network objects on your Linux system, such as IP addresses, routes, and ARP tables. This tool can be used to configure a network as well as to troubleshoot network problems.

View network interface details

ip address command allows you to lis all network interfacern in your systsm.

list interfaces

Show network statistics

Show network statistics like received / transmitted bytes by network interface.

ip -s -h l show dev <interface name>

Argument breakdown

  • -s display networking statistics

  • -h display in human readable format

  • l show dev show for speficied network interface

show network stats

netstat

The netstat command-line network utility displays network connections, routing tables, and a number of statistics related to network protocols and network interfaces.

Since I have a fresh Ubuntu installation it does not come with netstat so we need to install , and suggested by apt for our conveenicance.

netstat pakcage not found error

Run the following commands to install netstat.

sudo apt update
sudo apt install net-tools

List open ports

You can use netstat to check open ports in your system.

netstat -lnptu

Argument breakdown

  • l listning services

  • p process name

  • t tcp

  • u udp

  • n dont resolve port name

In the below output we can see open tcp and udp ports with their respective program name / pid.

Here you can see ssh port open in port 22 which we are using yo connect to this very instance.

netstat list open ports

We need sudo permission to list program name / pid .

dig

The dig command-line tool is an administrative tool that allows you to query the Domain Name System using the command line. The dig tool can be useful for both troubleshooting network problems and for debugging activities.

Check dns record

We can use the below command to query DNS and get an answer for that domain name.

dig codehirise.com
dig query

Here we can get ip resolved for the domain name , and also query cache time as 300 seconds and also record type as A record.

Thank you for reading.

CodeHiRise

All rights reserved 2023