Here’s a list of some useful Linux network commands along with brief explanations:
- ifconfig
Description: Displays or configures network interface parameters such as IP addresses, netmasks, and interfaces. (Deprecated in favor of ip command in newer distributions)
root@insectechs:~#ifconfig # Display network interface configuration
- ip
Description: A more modern and flexible command to configure networking (replaces ifconfig). It shows network interface information, adds routes, etc.
root@insectechs:~#ip addr show # Display IP address information
root@insectechs:~#ip link show # Display link-layer information (network interfaces)
- ping
Description: Sends ICMP Echo Request packets to a network host to check if the host is reachable.
root@insectechs:~#ping insectechs.in # Pings Google’s server
- netstat
Description: Displays network connections, routing tables, and network interface statistics. (Note: replaced by ss in some systems)
root@insectechs:~#netstat -tuln # Show all listening ports and associated IP addresses
- ss
Description: A more powerful and faster tool than netstat to display socket statistics and network connections.
root@insectechs:~#ss -tuln # Show listening ports with socket information
- traceroute
Description: Traces the path packets take to reach a remote host, showing each hop along the way.
root@insectechs:~#traceroute insectechs.in # Trace the route to Google’s servers
- dig
Description: A DNS lookup tool to query domain name servers for information about domains, such as IP addresses.
root@insectechs:~#dig insectechs.in # Get DNS information for google.com
- nslookup
Description: Queries the Domain Name System (DNS) to find IP addresses associated with domain names.
root@insectechs:~#nslookup insectechs.in # Get IP address information for google.com
- curl
Description: A tool for transferring data to or from a server using various protocols (HTTP, FTP, etc.). Commonly used to download files or interact with APIs.
root@insectechs:~#curl http://insectechs.in # Fetch a webpage
root@insectechs:~#curl -O http://insectechs.in/file.zip # Download a file
- wget
Description: A command-line utility to download files from the web using HTTP, HTTPS, and FTP protocols.
root@insectechs:~#wget http://insectechs.in/file.zip # Download a file from the web
- route
Description: Displays or modifies the routing table in Linux, used to determine how packets are forwarded across networks.
root@insectechs:~#route -n # Display the routing table
- hostname
Description: Shows or sets the system’s hostname (the name of the computer on the network).
root@insectechs:~#hostname # Display the system’s hostname
root@insectechs:~#hostname newname # Change the system’s hostname
- ip route
Description: Displays or manipulates the IP routing table (used to control the network routing of data packets).
root@insectechs:~#ip route show # Show the current routing table
- arp
Description: Displays or manipulates the system’s ARP (Address Resolution Protocol) cache, which stores the mapping between IP addresses and MAC addresses.
root@insectechs:~#arp -a # Display the ARP table
- tcpdump
Description: A packet analyzer tool used to capture and inspect network traffic.
root@insectechs:~#tcpdump -i eth0 # Capture packets on the eth0 interface
- netcat (nc)
Description: A powerful networking tool used for reading and writing data across network connections, useful for debugging and setting up network services.
root@insectechs:#nc -l 1234 # Start a listener on port 1234
root@insectechs:~#nc google.com 80 # Connect to Google on port 80
- mtr
Description: A network diagnostic tool that combines the functionality of traceroute and ping to give real-time information about network latency and packet loss.
root@insectechs:~#mtr insectechs.in # Trace the route to Google with real-time statistics
- ip link
Description: Displays or manages the state of network interfaces (up/down).
root@insectechs:~#ip link set eth0 up # Bring the eth0 interface up
root@insectechs:~#ip link set eth0 down # Bring the eth0 interface down
- ip addr
Description: Displays and configures IP addresses on network interfaces.
root@insectechs:~#ip addr show eth0 # Show IP address information for eth0
- iwconfig
Description: Displays or configures wireless network interfaces.
root@insectechs:~#iwconfig wlan0 # Show wireless settings for wlan0
- ss -tuln
Description: Displays listening ports and associated network connections. It’s faster and more reliable than netstat.
root@insectechs:~#ss -tuln # Show listening TCP/UDP sockets
- ufw
Description: A frontend for managing firewall rules in Linux. It’s an easy-to-use tool to configure firewall settings.
root@insectechs:~#ufw allow 80/tcp # Allow incoming connections on port 80 (HTTP)
root@insectechs:~#ufw enable # Enable the firewall
These network commands are essential for managing and troubleshooting network configurations, diagnosing connectivity issues, and understanding network traffic on a Linux system.