Linux Network Commands Cheat Sheet
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 |
---|---|---|
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. |
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. |
Shows and configures the network interfaces on the current system. |
ifconfig eth0 Displays information about the eth0 interface. |
|
Checks the current setup and settings of network interfaces. |
ifquery --list Lists all network interfaces and their settings. |
|
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) |
This will Activates a network interface that is currently inactive or down. |
ifup eth0 Activates the eth0 network interface. |
|
Deactivates a network interface that is currently active or up. |
ifdown wlan0 Deactivates the wlan0 wireless interface. |
|
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 |
---|---|---|
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. |
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) |
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. |
|
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) |
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. |
|
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) |
|
Sends and receives email messages via the command line interface. |
mail -s "Hello" user@example.com Sends an email with subject “Hello” to user@example.com. |
Displays and filters network packet data based on a given regular expression pattern. |
ngrep -W byline "^GET" Captures and prints HTTP GET requests. |
|
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 |
---|---|---|
Performs DNS lookups to resolve hostnames, IP addresses, mappings, or any specific DNS record. |
nslookup example.com
Resolves the IP address for example.com |
|
Performs DNS lookups to resolve hostnames or IP addresses. |
host google.com Resolves the IP address for google.com |
|
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
Network Testing and Monitoring Commands
Command |
Description |
Example |
---|---|---|
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 |
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 |
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 |
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 |
---|---|---|
Captures and inspects network traffic in real-time for analysis. |
tcpdump -i eth0 port 80
Captures traffic on eth0 interface for port 80 |
|
Discovers active hosts and services on a network, useful for security audits. |
nmap -sV example.com Scans example.com for open ports and services |
|
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 |
Shows real-time bandwidth usage broken down by individual connections. |
lsof -i
Lists all open network connections |
|
Measures the network performance and throughput between two systems. |
iperf -c example.com Tests network performance to example.com |
|
Monitors and displays network traffic flows in real-time. |
iptraf-ng
Shows real-time network traffic statistics |
|
Tracks network traffic and bandwidth usage per process or application. |
nethogs Displays bandwidth usage per process/application |
|
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 |
---|---|---|
Establishes a secure encrypted shell session with a remote system over the SSH protocol. |
ssh user@example.com
Opens an SSH session to example.com as user |
|
This will Securely copies files between the local and remote systems using the SSH protocol. |
scp file.txt user@example.com:/path/to/dir Copies file.txt to example.com |
|
This will Securely transfers files between the hosts using the SFTP (SSH File Transfer Protocol). |
sftp user@example.com
Opens an SFTP session to example.com as user |
Security Commands
Command |
Description |
Example |
---|---|---|
The firewall utility that manages the packet filtering and the Network Address Translation (NAT) rules. |
iptables -L Lists all current iptables rules |
|
An intrusion detection system that analyzes the network traffic for the suspicious activities. |
snort -dev Runs Snort in packet logging mode |
|
Captures and analyzes network traffic data in a formatted text output. |
wireshark Starts Wireshark for packet capturing and analysis |
|
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 |
---|---|---|
Transfers data to or from a server over various protocols. |
curl https://example.com Fetches the website example.com |
|
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 |
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.
Linux Network Commands Cheat Sheet – FAQs
How can I check if my internet connection is working on the Linux?
The “ping” command is use to test if you can reach the website or the server. For example “ping www.google.com” will send the data packets and it will show if the connection is successful or not.
How do I find out my computers IP address on the Linux?
The “ip addr show” or “ifconfig” command is use to display the information about the your network interfaces including the IP addresses that are assigned to them.
I am having the trouble connecting to the WiFi network. What Linux command will help me?
The “iwconfig” command is allows you to view and configure the wireless network interfaces. You can use it to scan for the available networks connect to the specific network and troubleshoot the issues.
How can I see that what other devices or computers are connected to the my local network?
The “arp -a” command will used to display the ARP (Address Resolution Protocol) table which will maps the IP addresses to the MAC addresses for the devices onto the your local network.
My internet is really slow. Is there a command to check my network bandwidth usage?
Yes The “iftop” or “bwm-ng” commands is use to show you the bandwidth being used by the different connections or the applications in the real time.