itsmeit.bizitsmeit.biz
  • Home
  • Windows
    • Windows Software
  • Ubuntu & Linux
    Ubuntu & Linux
    The top blog articles on Ubuntu and Linux, featuring valuable tips and tricks, empower you to master these operating systems and enhance your experience.
    Show More
    Top News
    How to Remove Ubuntu Dual boot Windows 11 UEFI and Legacy
    How to Remove Ubuntu Dual boot Windows 11 UEFI and Legacy
    November 10, 2023
    How to install php7.4 on Ubuntu & Config php7.4-fpm - itsmeit.biz
    How to install php7.4 on Ubuntu 22.04 | 20.04 LTS
    November 10, 2023
    Install Ubuntu dual boot Windows 11 | 10 UEFI And Legacy
    Install Ubuntu dual boot Windows 11 | 10 UEFI & Legacy
    November 10, 2023
    Latest News
    How to install Composer on Ubuntu 20.04 | 22.04 & Linux
    November 13, 2023
    How to Configure Redis Cache to Speed ​​Up WordPress Site
    November 15, 2023
    Install Ibus-bamboo or Ibus-unikey for Accented Letters on Ubuntu 22.04
    November 11, 2023
    How to install MariaDB on Ubuntu 22.04, 20.04 and Debian
    November 11, 2023
  • Web developer
    • Wordpress Theme
      • Blog News
      • Fashion Theme
      • Theme Elementor
      • WooCommerce Theme
    • Wordpress Plugin
    • Magento Developer
Reading: How to use netstat command in Linux or Ubuntu 22.04 + Examples
Share
Font ResizerAa
itsmeit.bizitsmeit.biz
Font ResizerAa
  • Linux & Ubuntu
  • Windows
    • Tips & Trick
    • Windows Software
  • Web developer
    • Magento Developer
    • Wordpress Plugin
    • WP Blog Theme
    • WP Fashion Theme
    • WooCommerce Theme
  • Log Out
Have an existing account? Sign In
Follow US
Copyright © 2022. All Rights Reserved.
Ubuntu & Linux

How to use netstat command in Linux or Ubuntu 22.04 + Examples

duyanh
Last updated: November 10, 2023
By duyanh Published May 4, 2023
Share
SHARE

Table of contents

  1. Install and Use the Netstat Command in Linux, Ubuntu or CentOS with examples
    1. How to Install and Use Netstat Command in Linux and Ubuntu or CentOS
    2. Some examples and explanations of netstat command in Ubuntu or Linux Debian
      1. netstat -a;
      2. netstat -t;
      3. netstat -p;
      4. netstat -s;
      5. netstat -n;
      6. netstat -i;
      7. netstat -r;
      8. netstat -g;
      9. netstat -c;

In this article, ItsmeIT introduces how to use the Netstat command in Linux, Ubuntu, or CentOS. Detailed explanations of basic Netstat commands, along with advanced options and illustrated examples, are provided to help users gain a better understanding of this tool and use it effectively in network management.

Install and Use the Netstat Command in Linux, Ubuntu or CentOS with examples

How to Install and Use the Netstat Command in Linux and Ubuntu or CentOS with examples

How to Install and Use Netstat Command in Linux and Ubuntu or CentOS

Netstat in Linux is an essential utility to help administrators troubleshoot network connectivity problems by providing detailed information about network connection status, ports in use, and data transfer between applications. If the netstat command is not available on your Ubuntu or Linux system, you can use the command to install it, the net-tools package also includes additional utilities such as arp, ifconfig, rarp, nameif and route.

sudo apt install net-tools

Or with centOS:

sudo yum install net-tools

Some examples and explanations of netstat command in Ubuntu or Linux Debian

netstat -a;

The netstat command Linux display all open connections and sockets on the system. It is useful for troubleshooting network connectivity problems and monitoring running applications.

Example of command netstat -a on Linux or Ubuntu (illustration)
Example of command netstat -a on Linux or Ubuntu (illustration)

For example, if you are having trouble connecting to a MySQL database, you can use the command netstat -a on Linux or Ubuntu to determine which TCP connections are waiting for the port MySQL is using (usually port 3306). If you see a lot of TCP connections waiting for this port, it is possible that the MySQL server is overloaded and does not have enough resources to handle the new connection requests.

Thereby you can use the netstat command in linux to find and fix the problem by increasing server resources or optimizing the database to reduce the load on MySQL .

netstat -t;

The netstat command in Linux shows only active TCP netstat -t connections. It is useful when you want to check the TCP connections established on the system and help identify network connection problems on the TCP protocol.

how to use netstat command linux or ubuntu centos 4

For example, to check the connection to MySQL on TCP port 3306 in Linux or Ubuntu, we can use the netstat -t command and filter the results using grep, which helps check the network connection status of the ports and application on the system.

netstat -t | grep 3306

The results will show all active connections to port 3306, including established connections and pending connections, when using the netstat command in linux. If any connections are blocked, you can check your firewall configurations or other security software to make sure they are not blocking connections to TCP port 3306.

netstat -p;

This command shows the process using connections and ports. The command netstat -p in Ubuntu or in is very useful to determine which applications are using your network connection and ports on your system.

Use the Netstat command in Linux and Ubuntu with option -p (illustration)
Use the Netstat command in Linux and Ubuntu with option -p (illustration)

netstat -s;

The command netstat -s is used to display statistics of network statistics such as TCP, UDP, ICMP, IP protocols, network errors and more. Here are some specific examples of using the command netstat -s on Ubuntu and Linux servers:

How to use the netstat -s command in Linux and Ubuntu or CentOS (illustration)
How to use the netstat -s command in Linux and Ubuntu or CentOS (illustration)
  • Display statistics for TCP protocol:
netstat -s | grep TCP
  1. Display statistics for UDP protocol:
netstat -s | grep UDP
  1. Display statistics for ICMP protocol:
netstat -s | grep ICMP

netstat -n;

This command displays all active connections and sockets on your system, but does not perform IP address resolution to domain names. It is useful when you want to see the real IP address of the network connections on your system.

The command example netstat in Linux with options -n and screenshot below shows the 5 connections shown, including:

how to use netstat command linux or ubuntu centos 7
  • A TCP connection is in “CLOSING” state, the local IP address is 192.168.1.141, the local port is 42626, the remote connection partner’s IP address is 35.174.127.31 and the port is remote is 443.
  • Four TCP6 connections are active on different IPv6 addresses, including “TIME_WAIT”, “ESTABLISHED” and “CLOSE_WAIT” states.

netstat -i;

This command will display statistics about network interfaces. Using the netstat command in linux with the option -i, you can view the number of packets sent and received over each interface, the total amount of data transferred over each interface, the number of errors that occurred, and other information related to the network interface. regarding network interfaces. This command helps you to monitor and manage the performance of network interfaces.

How to use the Netstat command in Linux and Ubuntu or CentOS (illustration)
How to use the Netstat command in Linux and Ubuntu or CentOS (illustration)

The result of the “netstat -i” command displays a statistics table of network interfaces on the computer, including information such as:

  • Iface: the name of the network interface
  • MTU: the maximum size of the packet transmitted over that interface
  • RX-OK: number of packets received without error
  • RX-ERR: number of packets received in error
  • RX-DRP: number of packets rejected due to error or buffer overload
  • RX-OVR: number of packets rejected due to buffer overflow
  • TX-OK: number of packets sent successfully
  • TX-ERR: number of packets sent in error
  • TX-DRP: number of packets rejected due to error or buffer overload
  • TX-OVR: number of packets rejected due to buffer overflow
  • flg: interface flags

In the example in the screenshot above, there are two interfaces listed: eno1 and lo.

netstat -r;

This command will display the computer’s routing table. When using netstat command in ubuntu with -r this option you can see the list of current routes on your computer. This command is useful when you want to determine the path of packets and helps you to check the correctness of the routing table.

how to use netstat command linux or ubuntu centos 9

netstat -g;

The Linux command netstat with the option -g will display information about the multicast groups in use on the computer. Using this command, you can view the list of multicast groups on your computer and the IP addresses of the group members. The netstat command in linux -g helps you manage multicast groups on your network.

How to use the netstat -g command in Linux and Ubuntu or CentOS (illustration)
How to use the netstat -g command in Linux and Ubuntu or CentOS (illustration)

netstat -c;

This command will display the results continuously and automatically update every second. Using this command, you can view changes related to the network connections on your computer. This command is useful for monitoring network activity and detecting network connectivity problems.

how to use netstat command linux or ubuntu centos 11

For example, to use the netstat command in Linux or Ubuntu with the option to -c continuously view the current active TCP connections on the system, we can use the following command:

netstat -c -t
how to use netstat command linux or ubuntu centos 12

The results will be displayed continuously and updated every second, helping us to monitor the active connections on the system quickly and conveniently.

Those are some shares and tutorials on how to use the netstat command in Linux (include Ubuntu and CentOS) and specific examples to help network administrators and sysadmins to check and analyze network connections on the system. system more effectively. Mastering how to use this netstat command helps detect and resolve network connection problems quickly and accurately.

– Advertising –

Share this Article
Facebook Twitter Pinterest LinkedIn Reddit Telegram
Leave a comment Leave a comment
Subscribe
Connect with
Login
Notify of
guest
Connect with
guest
0 Comments
Inline Feedbacks
View all comments
Previous Article Configure VPS Security for Ubuntu and Linux Website How to Safely Configure Security for Linux VPS and Ubuntu Server
Next Article How to use grep command in Linux or Ubuntu and examples How to use grep command in Linux or Ubuntu and examples

You Might Also Like

How to install Composer on Ubuntu 20.04 | 22.04 & Linux

How to Configure Redis Cache to Speed ​​Up WordPress Site

Install Ibus-bamboo or Ibus-unikey for Accented Letters on Ubuntu 22.04

How to install MariaDB on Ubuntu 22.04, 20.04 and Debian

How to Install Android Studio on Ubuntu 22.04 or 20.04

Stay Connected

Facebook Like
Twitter Follow
Pinterest Pin
Telegram Follow

Popular Posts

Download WPBakery v7.2 Drag and Drop WordPress Page Builder Plugins
WPBakery v7.2 Drag and Drop WordPress Page Builder Plugins
December 4, 2023 21 Views
Download IDM FULL Crack v6.42.1 + Repack (Fix fake serial)
Download IDM FULL Crack v6.42.1 + Repack (Fix fake serial)
November 24, 2023 665 Views
Download Plugin Product Video Gallery for Woocommerce v1.5.0
Plugin Product Video Gallery for Woocommerce v1.5.0
November 17, 2023 9 Views
Download Prevent Spam Register Plugin - Block WordPress Spam Accounts
Prevent Spam Register Plugin – Block WordPress Spam Accounts
November 17, 2023 14 Views
Elementor PRO v3.17.0 Plugin (Full Templates Pack + Demo)
Download Plugin Elementor PRO 3.17.0 (+Full Templates Pack)
November 17, 2023 36 Views
Download Newspaper v12.6.1 - WordPress theme News Magazine
Download Newspaper v12.6.1 – WordPress theme News Magazine
November 17, 2023 17 Views
We provide tips and tricks on Internet technology, computers, servers as well as share experiences for developers and website designers.

DMCA.com Protection Status

Quick Link

  • Linux | Ubuntu
  • Windows & Software
  • Magento Developer
  • Wordpress Plugin
  • Wordpress Theme

General Policy

  • About US
  • Contact US
  • Disclaimer
  • Privacy Policy
  • Terms of Service

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

itsmeit.bizitsmeit.biz
Follow US
Copyright © 2023. All Rights Reserved.
  • WP Blog Theme
  • WP Fashion Theme
  • WooCommerce Theme
  • Wordpress Plugin
Welcome Back!

Sign in to your account

Continue with Google
Continue with TikTok
Continue with GitHub
Register Lost your password?