Basic Networking Commands: A Quick Reference Guide

Master essential networking commands with our quick reference guide. Learn the basics of network configuration, diagnostics, and troubleshooting
E
Edtoks4:21 min read

Here are some basic network commands in Unix with detailed explanations and examples:

1. ping Command:

The ping command is used to test network connectivity between your computer and a remote host using the Internet Control Message Protocol (ICMP).

Basic Usage:

ping [options] host

host: The hostname or IP address of the remote host to ping.

options: Optional flags to modify the behavior of ping.

Example:

ping www.google.com

Explanation:

This command sends ICMP echo request packets to www.google.com to check if it's reachable and measure the round-trip time for responses.

Common Options:

  • -c count: Specify the number of packets to send (default is infinite).
  • -s size: Set the size of the ICMP packets.
  • -i interval: Set the interval between sending packets.
  • -t timeout: Set the maximum time to wait for a response.

2. ifconfig Command:

The ifconfig (interface configuration) command is used to display and configure network interfaces on your system.

Basic Usage:

ifconfig [interface] [options]

interface: The name of the network interface to configure or display.

options: Optional flags to control the behavior of ifconfig.

Example:

ifconfig eth0

Explanation:

This command displays network configuration information for the eth0 network interface.

Common Options:

  • -a: Display all interfaces (including inactive ones).
  • interface IP_ADDRESS: Configure the IP address of a network interface.
  • interface down: Disable a network interface.
  • interface up: Enable a network interface.

3. netstat Command:

The netstat (network statistics) command is used to display network-related information, such as open network connections, routing tables, and network interface statistics.

Basic Usage:

netstat [options]

options: Optional flags to specify what network information to display.

Example:

netstat -tuln

 Explanation:

This command displays a list of all listening (bound) TCP and UDP network services and their associated port numbers.

Common Options:

  • -t: Display TCP connections.
  • -u: Display UDP connections.
  • -l: Display listening sockets.
  • -n: Display numerical addresses instead of resolving hostnames.
  • -r: Display the routing table.
  • -i: Display network interfaces and their statistics.

4. ssh Command:

The ssh (Secure Shell) command is used to establish secure remote shell sessions and securely transfer files between systems over a network.

Basic Usage (Remote Shell):

ssh [user@]host [command]

user: The username to use for the remote session (optional).

host: The hostname or IP address of the remote server.

command: A command to execute on the remote server (optional).

Example (Remote Shell):

ssh user@hostname

Explanation:

This command establishes a secure shell session with the remote host hostname using the user as the username.

Basic Usage (File Transfer):

scp [options] [source] [destination]

options: Optional flags to modify the behavior of scp.

source: The source file or directory to copy from.

destination: The destination file or directory to copy to.

Example (File Transfer):

scp myfile.txt user@hostname:/path/to/destination

Explanation:

This command securely copies myfile.txt from the local system to the remote server hostname in the specified destination directory.

Common Options (Remote Shell):

  • -p port: Specify a custom SSH port.
  • -i identity_file: Use a specific SSH private key for authentication.

Common Options (File Transfer):

  • -r: Recursively copy directories.
  • -P port: Specify a custom SCP port.

These basic network commands are essential for troubleshooting, configuring, and managing network connections and resources in Unix-like operating systems. They provide valuable insights into network status and enable secure remote communication and file transfers.

Let's keep in touch!

Subscribe to keep up with latest updates. We promise not to spam you.