CloudsArk
Commands Linux

netstat Command Examples in Linux

Practice useful netstat command examples for everyday Linux administration and troubleshooting.

netstat Command Examples in Linux

Introduction

These examples show practical ways to use netstat on a Linux terminal. Each example is written so you can adapt it for administration or troubleshooting.

Example 1: Basic Usage

netstat -tuln

This is the simplest form of the command and is a good starting point before adding options.

Example 2: Common Admin Task

netstat -rn

This example reflects a common task on RHEL, Rocky Linux, AlmaLinux, or similar systems.

Example 3: Useful Option

netstat -tulpn

This option helps narrow the result, change behavior, or handle a more realistic target.

Example 4: Real-World Scenario

netstat -an | grep 443

Use this pattern when the task moves beyond a single basic command.

Example 5: Verification

netstat -s

Example output:

tcp        0      0 0.0.0.0:22        0.0.0.0:*        LISTEN

Common Mistakes

  • Assuming netstat is installed on minimal systems.
  • Using netstat by habit when ss gives clearer modern output.
  • Forgetting -n, which can slow output while names are resolved.

Quick Reference

netstat -tuln
netstat -rn
netstat -tulpn
netstat -an | grep 443
netstat -s

Summary

Good netstat usage means choosing the right option, keeping the target clear, and verifying the result with output you can explain.