7 Useful Linux Networking Commands - page 2
ifconfig, iwconfig, ethtool
tcpdump for sniffing network packets
This isn't just a simple tool; its a network sniffer or analyzer. It can capture the packets traveling through your interfaces and on the network. You can inspect the raw packets or review statistics. The tool is often used by other GUI programs, but can also be useful in a terminal. Here are some command options to get you started:
- -i: Specifies the interface to capture on, such as eth0 or ath0.
- -n: Stops replacing IP addresses with hostnames.
- -nn: Stops resolving hostnames or port names.
- -s : Maximum bytes to display for each packet. Default is 68. Use 0 to display entire packets.
- v, -vv, and -vvv: Steps up the amount of details printed along with the packets, such as the total length and options in an IP packet, fully decoded SMB packets, and telnet details.
- -x: Displays the packet contents in the HEX format.
- -X: Prints the packet contents in the ASCII format.
Ping, your network sonar
Start pinging an IP address or a host/domain name:
To stop the pinging, hit Ctrl + C.
Here are a few options that you might want to use:
- -c: Count, or number, of packets to send
- -i: Wait interval; number of seconds between packets
- -s: Packet size of pings; default is 56 (64 with ICMP)
- -w: Waitsecs or how long in seconds to perform pinging
Netstat for reviewing network statistics
The netstat (or network statistics) tool can display details of your network connections, interface statistics, routing tables, masquerade connections, and multicast memberships. Here are a few commands that might interest you:
View a list of open sockets:
Display a table of all the network interfaces:
Display the summary statistics for each protocol:
Hostname lets you view and change your hostname
If you're an administrator, you know what a hostname is. For everyone else: a hostname helps identify network devices in a more user-friendly (alphabetic) way rather just by a crude IP address. Linux distros usually include a simple tool called hostname to view and temporarily change your hostname.
View the current hostname setting:
Temporarily change the hostname (until restart):
To permanently change the hostname, you'll have to edit the /etc/hostname or /etc/sysconfig/network files.
Eric Geier is the Founder and CEO of NoWiresSecurity, which helps businesses easily protect their Wi-Fi with enterprise-level encryption by offering a hosted RADIUS/802.1X authentication service. He is also the author of many networking and computing books for brands like For Dummies and Cisco Press.
- 1Linux Top 3: Fedora 24, Peppermint 7 and Solus 1.2
- 2Linux Top 3: Alpine Linux 3.4, deepin 15.2 and Linux Lite 3.0
- 3Linux 4.7 Set to Boost Live Patching, Security and Power Management
- 4Linux 4.6 Charred Weasel adds USB 3.1 Support
- 5Linux Top 3: OpenIndiana 2016.04, Ubuntu 16.04 and Debian's New Leader