Linux Network Commands Cheat Sheet
Last Updated :
21 May, 2024
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?
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
|
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.
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
SED command in Linux | Set 2
We have discussed some of the SED command options in Sed Command in Linux/Unix with examples SED is used for finding, filtering, text substitution, replacement and text manipulations like insertion, deletion search, etc. It's a one of the powerful utilities offered by Linux/Unix systems. We can use
8 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
Basic Shell Commands in Linux
Anyone using Linux should become an expert in the essential shell commands, as they form the backbone of working with the Linux terminal. These commands enable you to navigate the system, manage files, handle processes, and configure settings effectively. The Linux shell serves as an interface for u
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
Using the Cat Command in Python
The cat command is a Linux shell command. It is the shorthand for concatenate. It is placed among the most often used shell commands. It could be used for various purposes such as displaying the content of a file on the terminal, copying the contents of a given file to another given file, and both a
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
chvt command in Linux with examples
'chvt' command in Linux systems is used to switch between the different TTY (TeleTYpewriter) terminals available. These are essentially Virtual Terminals, which are toggled when the keys "Ctrl + Alt + FunKey(1-6)" are pressed. There are usually 6 TTY terminals, and the 'chvt' command is used to swit
3 min read