亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Table of Contents
How to Use netstat to Show Active Connections
How to Use ss for Faster and More Detailed Output
Interpreting the Output
Tips for Daily Use
Home System Tutorial LINUX How to view all active network connections with netstat or ss?

How to view all active network connections with netstat or ss?

Jun 19, 2025 am 12:48 AM
netstat Internet connection

To view active network connections on Linux, use netstat or ss. 1. Netstat is older and deprecated but still widely used; run sudo netstat -tulnp to show TCP/UDP connections, listening ports, IP addresses, and process info. 2. Ss is faster and recommended; use sudo ss -tulnp for similar output with better performance. 3. Ss supports filtering, like ss -ltnp 'sport = :ssh' for SSH connections only. Both display protocol, local/foreign addresses, port states, and processes when applicable. Use -p selectively to avoid sudo, filter via grep, or use watch for live monitoring.

How to view all active network connections with netstat or ss?

If you want to see all active network connections on a Linux system, two of the most common tools are netstat and ss. While netstat has been around longer, it's now considered deprecated — but still widely used. The ss command is faster and more efficient, and it's the recommended alternative in many modern distributions.

Here’s how to use both commands effectively to view active connections.


How to Use netstat to Show Active Connections

To list all active network connections using netstat, this basic command covers most needs:

netstat -tulnp
  • -t shows TCP connections
  • -u shows UDP connections
  • -l lists only listening ports
  • -n disables DNS lookups (shows IP addresses instead of hostnames)
  • -p shows the process ID and name (requires root privileges)

You’ll typically run this with sudo to get full visibility into processes:

sudo netstat -tulnp

This gives you a clear picture of what services are running and which connections are currently open.


How to Use ss for Faster and More Detailed Output

The ss command (short for "socket statistics") is designed to be a faster alternative to netstat.

A good starting point is:

ss -tulnp

The options are similar:

  • -t for TCP
  • -u for UDP
  • -l for listening sockets
  • -n to skip hostname resolution
  • -p to show associated processes

Like with netstat, you might need sudo to see all process details:

sudo ss -tulnp

One advantage of ss is that it can filter results directly on the command line. For example, if you want to see only SSH connections:

ss -ltnp ' sport = :ssh '

Or for HTTP traffic:

ss -ltnp ' sport = :http '

These filters make ss very powerful when troubleshooting or monitoring specific services.


Interpreting the Output

Both commands will give you a table showing:

  • Protocol (TCP/UDP)
  • Recv-Q / Send-Q (number of bytes in receive/send queues)
  • Local address and port
  • Foreign (remote) address and port
  • State (like ESTABLISHED, LISTENING)
  • Process info (if using -p)

Common states you may see:

  • LISTEN – service waiting for incoming connections
  • ESTABLISHED – active connection
  • TIME-WAIT – connection is closing gracefully

If you're scanning for unusual activity, look for unexpected foreign IPs or unknown processes tied to open ports.


Tips for Daily Use

  • If you don’t need process info, skip -p to avoid needing sudo.
  • Pipe output to grep to narrow down results:
    ss -tuln | grep ':80'
  • Use -r with netstat to resolve hostnames (but expect slower output).
  • Combine watch with these commands for live monitoring:
    watch ss -tuln

    That’s basically how you check active network connections using netstat or ss. Both tools do the job well, but ss is generally faster and more flexible, especially with filtering. Once you get used to the syntax, checking what’s connected becomes second nature.

    The above is the detailed content of How to view all active network connections with netstat or ss?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72
Why does Ubuntu have network connection but cannot access the Internet? Why does Ubuntu have network connection but cannot access the Internet? Dec 20, 2023 pm 05:26 PM

The reasons why Ubuntu has a network connection but cannot access the Internet: 1. DNS configuration problem; 2. Proxy server setting problem; 3. Network firewall setting problem; 4. Router or modem setting problem; 5. Network driver problem; 6. Network configuration file Questions; 7. Other questions. Detailed introduction: 1. DNS configuration problem. Make sure the network connection is normal. You can test whether the network connection is normal by entering "ping 8.8.8.8" in the terminal. If a normal result is returned, the network connection is stable, etc.

How to Fix Roblox 403 Forbidden Error on Google Chrome How to Fix Roblox 403 Forbidden Error on Google Chrome May 19, 2023 pm 01:49 PM

Many Windows users have recently encountered an unusual error called Roblox403 Forbidden Error while trying to access website URLs in Google Chrome browser. Even after restarting the Chrome app multiple times, they were unable to do anything. There could be several potential causes for this error, some of which we've outlined and listed below. Browsing history and other cache of Chrome and corrupted data Unstable internet connection Incorrect website URLs Extensions installed from third-party sources After considering all the above aspects, we have come up with some fixes that can help users resolve this issue. If you encounter the same problem, check out the solutions in this article. Fix 1

What to do if the network connection folder is empty What to do if the network connection folder is empty Mar 13, 2024 am 11:27 AM

1. First click [Start Menu], then click the [Settings] button. 2. In the [Settings] interface, click the [Network and Internet] option. 3. Scroll down to the bottom of the page, find the [Network Reset] option, and click the [Reset Now] option.

The network connection is unstable and keeps disconnecting and reconnecting. The network connection is unstable and keeps disconnecting and reconnecting. Feb 18, 2024 pm 07:05 PM

The LOL network is normal but keeps reconnecting. In recent years, e-sports has developed rapidly and attracted a large number of players to join it. One of the most popular games is League of Legends (LOL). However, like other online games, network problems can occur in LOL. One of the more common problems is that the network connection is unstable, causing players to constantly reconnect. First, let’s analyze the reasons that cause LOL network connection to be unstable and cause constant reconnection. on the one hand,

What to do if there is an Xbox network connection error? Solution to Xbox network connection abnormality What to do if there is an Xbox network connection error? Solution to Xbox network connection abnormality Mar 15, 2024 am 09:00 AM

In Xbox, players can experience a large number of games, and various types of games can be found. However, many players also report that a network connection error is prompted in Xbox. How to solve the Xbox network connection error? Let’s take a look at some reliable solutions. Solution 1: Check the network connection status. According to the error message details sent by the Xbox host system, the problem may be that the player's local network connection is not normal. The editor recommends that you open the network list of Xbox first, check the network status, reconnect to the network, confirm that the network is normal, and then start the game on the Xbox console. Solution 2: Use acceleration tools If players have determined that the Xbox console is connected to the Internet

How to solve the problem that win11 virtual machine cannot connect to the network How to solve the problem that win11 virtual machine cannot connect to the network Jan 04, 2024 pm 07:00 PM

Many users have installed virtual machines on the win11 system after updating it, but many of them will be unable to connect to the network. So today I will bring you the solution to the problem that the win11 virtual machine cannot connect to the network. Come and see how to solve it. . What to do if the win11 virtual machine cannot connect to the network 1. First open the virtual machine and click "Edit - Virtual Network Editor - Restore Default Settings" in order. After doing this, it can be used. 2. In fact, in many cases it is due to changes in the network driver that the network cannot operate normally. You only need to reinstall the network module once! 3. If you encounter the problem that the network is suddenly cut off during use, even if the adapter has been configured correctly, the network will still be displayed.

What's going on when the network can't connect to the wifi? What's going on when the network can't connect to the wifi? Apr 03, 2024 pm 12:11 PM

1. Check the wifi password: Make sure the wifi password you entered is correct and pay attention to case sensitivity. 2. Confirm whether the wifi is working properly: Check whether the wifi router is running normally. You can connect other devices to the same router to determine whether the problem lies with the device. 3. Restart the device and router: Sometimes, there is a malfunction or network problem with the device or router, and restarting the device and router may solve the problem. 4. Check the device settings: Make sure the wireless function of the device is turned on and the wifi function is not disabled.

GitLab troubleshooting and recovery features and steps GitLab troubleshooting and recovery features and steps Oct 27, 2023 pm 02:00 PM

GitLab's troubleshooting and recovery functions and steps Introduction: In the process of software development, the version control system is one of the indispensable tools. As a popular version control system, GitLab provides rich functions and powerful performance. However, GitLab can experience glitches for various reasons. In order to keep the team working properly, we need to learn how to troubleshoot and restore the system. This article will introduce the specific steps of GitLab troubleshooting and failure recovery functions, and provide corresponding code examples. one

See all articles