Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Shell Scripting
  • Kali Linux
  • Ubuntu
  • Red Hat
  • CentOS
  • Docker in Linux
  • Kubernetes in Linux
  • Linux interview question
  • Python
  • R
  • Java
  • C
  • C++
  • JavaScript
  • DSA
Open In App
Next Article:
Linux System Monitoring Commands and Tools
Next article icon

Linux Network Commands Cheat Sheet

Last Updated : 21 May, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Linux is a very popular operating system. Many people use it. Developers and network admins need to know Linux network commands well. This article will going explains most of the common Linux network commands in a very easy way and It also has a cheat sheet about these commands. The cheat sheet tells you what each command does and how you use it.

Linux Network Commands Cheat Sheet

  • What Are Networking Commands in Linux?
  • Linux Networking Commands Cheat Sheet
  • Network Configuration Commands
  • Network Connectivity Commands
  • DNS and Name Resolution Commands
  • Network Information Commands
  • Network Testing and Monitoring Commands
  • Network Analysis and Monitoring Commands
  • Remote Access Commands
  • Security Commands
  • Utility Commands

What Are Networking Commands in Linux?

Networking commands in Linux allow users to manage network connections. These commands let users set up networks, fix connection issues, and view network traffic. Users can also check network status, change settings, and control network programs with these commands. The commands use basic words that are easy for beginners to understand.

Linux Networking Commands Cheat Sheet

This list of Linux networking commands will help you work with network connections. You can use these commands to set up the networks, fix connection problems, and see the information about the network. If you are an experienced network admin or just starting to learn the Linux networking commands this command list will be a useful tool for you.

Network Configuration Commands

Command

Description

Example

hostname

Shows the Hostname of the current computer system.

hostname

Displays the hostname of the current system.

ip

Displays and allows you to configure network interfaces, routing, and tunnels.

ip addr show 

Shows the IP addresses assigned to network interfaces.

iwconfig

Shows and lets you set up wireless network interfaces.

iwconfig wlan0 essid "WiFiName"

Connects the wlan0 interface to the WiFi network named "WiFiName".

netplan

Sets up network interfaces using YAML configuration files.

netplan apply

Applies network settings from the YAML files.

ifconfig

Shows and configures the network interfaces on the current system.

ifconfig eth0

Displays information about the eth0 interface.

ifquery

Checks the current setup and settings of network interfaces.

ifquery --list

Lists all network interfaces and their settings.

nmcli

Reports the network status, manages and configures the network connections and controls the NetworkManager tool.

nmcli dev wifi list

Lists available WiFi networks.

netplan

This Defines the network interfaces, IP addresses, gateways, DNS servers, and the other network related settings in the YAML config file.

(Example covered in description)

ifup

This will Activates a network interface that is currently inactive or down.

ifup eth0

Activates the eth0 network interface.

ifdown

Deactivates a network interface that is currently active or up.

ifdown wlan0

Deactivates the wlan0 wireless interface.

dhcclient

Automatically gets an IP address and other network configuration details from a DHCP server.

dhclient eth0

Requests an IP address for the eth0 interface from a DHCP server.

Network Connectivity Commands

Command

Description

Example

arp

Maps IP addresses to MAC addresses on a local network and manages the ARP cache.

arp

Shows the current ARP cache entries.

arp -a

Prints the ARP table entries.

(Example covered in description)

arp -a -d

Removes all entries from the ARP table.

arp -d 192.168.1.100

Deletes the ARP entry for IP 192.168.1.100.

arp -s

Adds a new entry to the ARP table.

arp -s 192.168.1.10 00:11:22:33:44:55

Adds a static ARP entry for IP 192.168.1.10 and MAC 00:11:22:33:44:55.

netstat

Shows active network connections, routing information, and other network statistics.

netstat -antp

Lists all active network connections and the processes using them.

netstat -r

Prints the kernel's routing table.

(Example covered in description)

ping

Tests network connectivity between a host/client and server by sending data packets and measuring the response time.

ping 8.8.8.8

Tests connectivity to the Google DNS server at 8.8.8.8.

route

Configures the kernel's routing table entries.

route add default gw 192.168.1.1

Sets the default gateway to 192.168.1.1.

route flush

Removes all routes from the routing table.

(Example covered in description)

traceroute

Displays the path and hops that packets take to reach a remote server.

traceroute www.example.com

Traces the route taken to reach www.example.com.

telnet

Establishes the connection to the remote server or system through a TCP/IP network using the Telnet protocol.

telnet 192.168.1.10 22

Connects to the SSH server on 192.168.1.10 via Telnet.

w

This will Shows the information about users currently logged into the system.

(Example covered in description)

mail

Sends and receives email messages via the command line interface.

mail -s "Hello" [email protected]

Sends an email with subject "Hello" to [email protected].

ngrep

Displays and filters network packet data based on a given regular expression pattern.

ngrep -W byline "^GET"

Captures and prints HTTP GET requests.

iw

Displays and configures wireless network interface settings.

iw dev wlan0 scan

Scans for available wireless networks on the wlan0 interface.

DNS and Name Resolution Commands

Command

Description

Example

nslookup

Performs DNS lookups to resolve hostnames, IP addresses, mappings, or any specific DNS record.

nslookup example.com 

Resolves the IP address for example.com

host

Performs DNS lookups to resolve hostnames or IP addresses.

host google.com 

Resolves the IP address for google.com

dig

Performs DNS lookups to query information about DNS name servers.

dig @8.8.8.8 example.org 

Queries Google's DNS server for information about example.org

Network Information Commands

Command

Description

Example

finger

Displays user login information on a remote system.

finger [email protected] 

Shows login information for user on example.com

whois

Retrieves information about domain ownership from various WHOIS servers.

whois example.org 

Shows ownership details for example.org

Network Testing and Monitoring Commands

Command

Description

Example

hping

Assembles and analyzes TCP/IP packets, sends packets to a remote host, and examines the responses.

hping3 -S -p 80 example.com 

Sends SYN packets to port 80 on example.com

mtr

Combines functionalities of traceroute and ping commands, continuously sends packets and shows the ping time for each hop.

mtr google.com 

Traces the route to google.com and shows ping times

nc / netcat / ncat

Allows reading and writing data across network connections.

nc -l -p 8080 

Listens on port 8080 for incoming connections

smokeping

Measures network latency and packet loss between two hosts, performs checks at set intervals.

smokeping example.com 

Monitors latency and packet loss to example.com

socat

Facilitates data transfer between two bidirectional byte streams.

socat TCP4-LISTEN:8080,fork EXEC:/bin/bash 

Opens a remote shell on port 8080

speedometer

Displays bandwidth usage in real-time.

speedometer eth0 

Shows bandwidth usage on eth0 interface

speedtest-cli

Measures network performance by conducting a speed test.

speedtest-cli 

Runs a speed test to measure download/upload speeds

ss

Shows active network connections, socket statistics, and other network-related information.

ss -tulpn 

Lists all listening TCP/UDP sockets with process information

tracepath

Traces the route packets take, discovering the MTU along the path.

tracepath example.net 

Traces the path to example.net, showing MTU

Network Analysis and Monitoring Commands

Command

Description

Example

tcpdump

Captures and inspects network traffic in real-time for analysis.

tcpdump -i eth0 port 80 

Captures traffic on eth0 interface for port 80

nmap

Discovers active hosts and services on a network, useful for security audits.

nmap -sV example.com 

Scans example.com for open ports and services

bmon

Displays real-time bandwidth consumption for individual network interfaces.

bmon 

Shows bandwidth usage per interface

bwm-ng

Monitors the current bandwidth utilization across multiple network interfaces.

bwm-ng 

Displays bandwidth usage for all interfaces

iftop

Shows real-time bandwidth usage broken down by individual connections.

lsof -i 

Lists all open network connections

iperf

Measures the network performance and throughput between two systems.

iperf -c example.com 

Tests network performance to example.com

iptraf-ng

Monitors and displays network traffic flows in real-time.

iptraf-ng 

Shows real-time network traffic statistics

nethogs

Tracks network traffic and bandwidth usage per process or application.

nethogs 

Displays bandwidth usage per process/application

vmstat

Keeps historical records of network traffic statistics for selected interfaces, displaying hourly, daily, and monthly summaries.

vnstat -i eth0 

Shows traffic statistics for eth0 interface

Remote Access Commands

Command

Description

Example

ssh

Establishes a secure encrypted shell session with a remote system over the SSH protocol.

ssh [email protected] 

Opens an SSH session to example.com as user

scp

This will Securely copies files between the local and remote systems using the SSH protocol.

scp file.txt [email protected]:/path/to/dir 

Copies file.txt to example.com

sftp

This will Securely transfers files between the hosts using the SFTP (SSH File Transfer Protocol).

sftp [email protected] 

Opens an SFTP session to example.com as user

Security Commands

Command

Description

Example

iptables

The firewall utility that manages the packet filtering and the Network Address Translation (NAT) rules.

iptables -L 

Lists all current iptables rules

snort

An intrusion detection system that analyzes the network traffic for the suspicious activities.

snort -dev 

Runs Snort in packet logging mode

wireshark

Captures and analyzes network traffic data in a formatted text output.

wireshark 

Starts Wireshark for packet capturing and analysis

ufw

Manages the system's firewall, allowing you to add, delete, modify, or reset packet filtering rules.

ufw allow 22/tcp 

Allows incoming connections on port 22/TCP

Utility Commands

Command

Description

Example

curl

Transfers data to or from a server over various protocols.

curl https://example.com 

Fetches the website example.com

aria2

Supports multiple protocols for downloading files from the internet.

aria2c https://example.com/file.zip 

Downloads file.zip from example.com

ethtool

Modifies and queries settings of network interfaces, such as speed and other parameters.

ethtool -s eth0 speed 1000 

Sets eth0 interface speed to 1000Mbps

wget

A command-line utility for downloading files from the web.

wget https://example.com/file.zip 

Downloads file.zip from example.com

Conclusion

In summary, this shows important Linux commands for working with networks. These commands help you see and fix network problems. The commands let you check network traffic, bandwidth usage, security issues, and more. Beginners may gonna find this network commands list very helpful for learning the Linux networking basics.


Next Article
Linux System Monitoring Commands and Tools
author
kalpeshsk007
Improve
Article Tags :
  • Linux-Unix

Similar Reads

  • Linux Commands Cheat Sheet
    Linux, often associated with being a complex operating system primarily used by developers, may not necessarily fit that description entirely. While it can initially appear challenging for beginners, once you immerse yourself in the Linux world, you may find it difficult to return to your previous W
    13 min read
  • Linux Security Command Cheat Sheet
    Maintaining a secure and hardened Linux system is crucial in today's threat-laden digital landscape. This comprehensive Linux Security Command Cheat Sheet serves as an invaluable resource for system administrators and security professionals, providing a concise reference to essential commands spanni
    7 min read
  • Linux Process Management Command Cheat Sheet
    On Linux computers there are special commands to control the programs that are running. These commands are called process management commands. With the help of process management commands you can look at the list of the programs that are currently running on your computer. You can also start new pro
    6 min read
  • Linux System Monitoring Commands and Tools
    Monitoring the performance and health of a Linux system is essential for maintaining its stability and optimizing resource utilization. Linux provides a variety of commands and tools to facilitate system monitoring, enabling administrators to track key metrics, identify potential issues, and ensure
    5 min read
  • List out all the Shells Using Linux Commands
    When you're operating out of a Linux environment, the shell is your primary tool for interacting with the OS. It's your command interpreter — it translates what you type into what the OS can interpret and carry out. From basic operations like looking at files to running complex scripts, the shell ma
    4 min read
  • Linux vs Windows Commands
    Most of us think that Linux has terminal and we can use a command-line interface only in Linux but it is just a myth. There is a PowerShell and a command prompt in windows as well where we may execute the commands easily. But Windows and Linux have commands with the same name as well. .linux-vs-wind
    2 min read
  • Chaining Commands in Linux
    Chaining commands in Linux is a powerful technique that allows you to execute multiple commands sequentially or simultaneously through the terminal. This approach resembles writing short shell scripts that can be directly executed in the terminal, enhancing the efficiency of your workflow. By using
    7 min read
  • chage command in Linux with examples
    The 'chage' command in Linux is a powerful tool used to manage user password expiry and account aging information. It is particularly useful in environments where user access needs to be controlled over time, such as when login access is time-bound or when it’s necessary to enforce regular password
    4 min read
  • What is a Command?
    A command typically refers to an order given to a computer program or operating system to perform a specific task. It's usually entered via a command line interface or a terminal. Commands can vary widely depending on the context, the operating system being used, and the specific program or utility
    5 min read
  • apt command in linux with examples
    apt provides a high-level Command Line Interface (CLI) for the APT package management system, offering a user-friendly interface intended for interactive use. It simplifies common tasks like installation, upgrades, and removal, with better defaults than more specialized tools like apt-get and apt-ca
    5 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences