Bash Networking Commands | Linux

The Bash shell provides various commands for managing and troubleshooting network connectivity. Here's an explanation of some essential commands with examples:

Connectivity Testing

  1. ping:Checks if a host is reachable by sending packets and measuring response times. Example: ping (pings Google DNS server)
  2. traceroute:Traces the route packets take to reach a host, identifying hops along the way. Example: traceroute
  3. mtr:Combines ping and traceroute, showing detailed response times and packet loss at each hop. Example: mtr

Network Information

  1. ifconfig/ip addr:Displays information about network interfaces, including IP addresses, MAC addresses, and subnet masks. Example: ifconfig
  2. route:Shows the routing table, indicating how packets are directed to different networks. Example: route -n
  3. netstat:Lists active network connections, including local and remote addresses, ports, and protocols. Example: netstat -atup

Domain Name System (DNS)

  1. dig:Queries DNS servers for information about domain names, including IP addresses and other records. Example: dig
  2. host:Similar to dig, but provides a simpler output. Example: host
  3. nslookup:Another tool for DNS lookups, with options for different record types. Example: nslookup -type=A

Remote Access

  1. ssh:Enables secure remote login to another machine using a command-line interface. Example: ssh
  2. scp:Securely copies files between machines over SSH. Example: scp file.txt
  3. rsync:Efficiently synchronizes files and directories between machines, handling updates and deletions. Example: rsync -avz /local/folder

Network Services

  1. telnet:Connects to a remote server on a specific port (text-based, less secure than SSH). Example: telnet 25 (connects to SMTP server)
  2. netcat:Versatile tool for network communication, can be used for various purposes like creating simple servers or testing connections. Example: nc -l 8080 (listens on port 8080)

Here are some commonly used networking commands in Bash:

ifconfig (Interface Configuration)

This command is used to configure network interfaces.

ifconfig eth0

ip (IP Configuration)

The ip command is a powerful tool for network configuration.

ip addr show

ping (Packet Internet Groper)

Used to test the reachability of a host on an Internet Protocol (IP) network.


traceroute (Trace Route)

Shows the route that packets take to reach a destination.


netstat (Network Statistics)

Displays network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.

netstat -a

route (View and Manipulate IP Routing Table)

Used to view and manipulate the IP routing table.

route -n

nslookup (Name Server Lookup)

Queries DNS servers to obtain domain name or IP address mapping or for any other DNS record.


wget (Retrieve Content from Web)

Downloads files from the web using HTTP, HTTPS, or FTP protocols.


curl (Client for URLs)

Used for making requests to servers using various protocols, including HTTP, HTTPS, FTP, and more.


ssh (Secure Shell)

Allows secure remote access to a system over a network.

ssh username@remote_host

scp (Secure Copy)

Securely copies files between hosts on a network.

scp local_file.txt username@remote_host:/path/to/destination/

A command-line interface in Unix-like operating systems, various networking commands facilitate network configuration and management. Examples include 'ifconfig' for interface configuration, 'ip' for IP configuration, 'ping' for testing host reachability, 'traceroute' for displaying packet routes, 'netstat' for network statistics, 'route' for viewing and manipulating the IP routing table, and 'nslookup' for DNS queries.

Additionally, 'wget' and 'curl' download content from the web, 'ssh' provides secure remote access, and 'scp' securely copies files. Some commands may require root privileges (use sudo). These are just a few examples, and many other networking commands exist for specific tasks. Always consult the man pages for detailed information and usage instructions for each command.


Bash networking commands in Unix-like systems, such as 'ifconfig,' 'ping,' and 'ssh,' facilitate network configuration, testing, and secure remote access. These commands cover a range of tasks from basic interface configuration to advanced functionalities, and users should refer to the respective man pages for detailed usage instructions.