At any given time when using your PC which is connected to a router, you will be part of a network. Whether you are in an office environment or simply working from home, your computer will be in a network.
What is a Computer Network?
A computer network is defined as a group of 2 or more computers that are connected and can electronically communicate with each other. The computers are identified using their hostnames, IP, and mac addresses.
A simple home or office network is referred to as a LAN, short for Local Area Network. A LAN covers a small area such as a home, office, or restaurant network. In contrast, a WAN (Wide Area Network) spans a large geographical region. WAN is mostly used to connect various sites such as office buildings in different locations.
1. hostname Command
The hostname command displays the hostname of a Linux system. This is usually set or configured during the installation.
It also is a name that is given to a computer that attached to the network that uniquely identifies over a network and thus allows it to be accessed without using its IP address. To check the hostname, run the command:
The basic syntax for the hostname command is:
If the host name can be resolved, you can display the network address(es) (IP address) of the host name with the -i flag and the -I option establishes all configured network interfaces and shows all network addresses of the host.
an other useful hostname command option :
2. ping Command
Short for packet internet groper, with ping command we can use to check connectivity between 2 systems or servers.
It sends out an ICMP echo request to a remote host and waits for a reply. If the host is up, the echo request bounces off the remote host and is sent back to the source informing the user that the host is up or available.
The ping command takes the syntax shown.
Tips : You can specify the number of ECHO_REQUEST’s to be sent after which ping exits, using the -c flag as shown (in this case the ping test will stop after sending 5 packets).
Tips : The -i flag allows you to set interval in seconds between sending each packet, the default value is one second.
3. traceroute Command
The traceroute command displays the route that an ICMP ping packet takes from your device to the destination host or server. It displays the IP addresses of devices that the packet hops through before getting to the remote destination.
In line 2 the output shows an asterisk sign
* in the round trip. This is an indicator that the packet was dropped and no response was received. This shows that the ping packet was dropped by the router, and this could be for a variety of reasons such as network congestion.
Traceroute command is a cool diagnostic command that you can use to troubleshoot the network where the ping command gives you failed results. It shows the device at which the packets are being dropped.
4. mtr Command
The mtr (my traceoute) command combines the functionalities of the ping and traceroute command. with the mtr command, we can display a host of statistics including the host that each packet travels through, and response times for all the network hops. (read more here about mtr command)
5. ifconfig Command
With the ifconfig command, we can see a list of the network interfaces attached to the PC along with other statistics such as the IP addresses associated with each interface, subnet mask, and MTU to mention just a few.