Bash, the Bourne Again Shell, provides powerful tools for network operations in Unix-like systems. These commands enable users to manage network connections, troubleshoot issues, and automate network-related tasks efficiently.
The ping
command tests network connectivity by sending ICMP echo requests to a specified host.
ping google.com
These commands display and configure network interfaces. ifconfig
is older, while ip
is the modern replacement.
ifconfig
ip addr show
Use these to display network connections, routing tables, and network interface statistics. ss
is the newer, faster alternative to netstat
.
netstat -tuln
ss -tuln
scp
securely copies files between hosts on a network using SSH.
scp file.txt user@remote_host:/path/to/destination
rsync
efficiently transfers and synchronizes files across network connections.
rsync -avz source_dir/ user@remote_host:/path/to/destination
These commands trace the route packets take to a network host, helping diagnose network issues.
traceroute google.com
tracepath google.com
Use these for querying DNS servers to obtain domain name or IP address mapping information.
nslookup google.com
dig google.com
nmap
is a powerful network scanning and discovery tool.
nmap -p 1-100 192.168.1.1
iptables
configures Linux kernel firewall rules for network security.
iptables -L
By mastering these Bash network operations, you'll be well-equipped to manage and troubleshoot network issues effectively from the command line. Remember to consult man pages or online documentation for detailed usage of each command.