All commands to manage networks

Commands for network diagnostics and technical support

ping

All operating systems support this command and it is used for the same purpose: to determine if a host is accessible or reachable. In real life, the user with basic knowledge would use the ping command to corroborate if the web page to which he cannot access does indeed have problems. Here is an example:

ping redeszone.net

Now, let’s look at the same command “Ping” but with a couple of additions to expand its default function.

  • -c: to determine the number of packets that the ping will perform.
  • -i: to set the time interval between each package. Said interval that comes by default is one second. In the example, it is set to 2 seconds.
  • -s: to delimit the size of the packages.

ping -s 40 -i 2 -c 5 redeszone.net

Note: Whenever we execute commands and have to add parameters, they are added in stack. That is, the first parameter that we add will remain as the last. Our example shows that the first parameter indicated (-c), is “stepped on” by -i and the latter, for -s.

traceroute

It is one of the most necessary basic commands to find out if there is a problem with the route of the packages, considering the information it provides. Through this command, it is possible to determine the path taken by a package from the source (our computer) to the destination. Likewise, it shows us the latency generated during this entire journey and the amount of data loss, if any.

traceroute -4 10 redeszone.net

If you need to trace to reach the default gateway, run the following command:

traceroute -g 192.168.1.1 redeszone.net

Note: The example gateway address can, of course, be replaced by the IP address we need to indicate.

traceroute -4 10 redeszone.net

The 4 It represents that we will be using IPv4 packets, in case you need to use IPv6 instead of IPv4, we must simply indicate a «-6», if you need to do a traceroute to a domain using the IPv6 protocol.

whois

whois redeszone.net

This command gives us detailed information regarding the domain consulted. It works as a client for the protocol of the same name «whois» and provides information on network resources thanks to its large database. Above, is the example of the command that displays in the console, as we mentioned, information of network resources on the host that we indicate. As in the first instance, it provides too much information at once, a parameter can be added so that it only displays the data we need to know. We show you below:

whois redeszone.net | grep -i "Domain ID"

Network Policy Management

ip

It is a simple and fast command that has a variety of parameters to manipulate issues related to the IP addresses of the network interfaces, the network interfaces themselves, routing policies on the Linux machine, manage VPN tunnels and much more. One of the classic examples is to add the addr parameter to know the ip address of each of the network interfaces.

ip addr show

Another way to parameterize the command is to add one that displays information only from enabled (powered) interfaces:

ip link ls up

You can do more! Assign an IP address of your choice to a specific interface:

ip addr 192.168.1.64/24 dev eth0

There are a lot of commands within “ip” to manage the entire network, we recommend visit this website where you will find all the information and tutorials step by step.

nslookup

It is a command that allows us to obtain domain names and / or IP addresses based on what is registered in the DNS. For example:

nslookup redeszone.net

You can also allow the deployment of any DNS record related to that domain:

nslookup -type=any redeszone.net

hostname

With this it is possible to obtain or set a hostname (hostname) or DNS domain names. Generally, this command is used to configure dynamic hosts or obtain information regarding a specific host. No need to write more, with hostname It is possible to have information from your current host.

hostname

However, if you want to have the IP address of your host, you must add -i:

hostname -i

Now, if you want to replace your current host, type the following:

hostname NEW_HOST_NAME

Network Interface Management

ifconfig

This command is currently considered deprecated, but it is still used by a large number of network administrators. This command allows us to enter IP addresses, manage interfaces, configure interfaces and everything related to the network itself.

ifconfig

Without any parameters, this command displays all the information of all network interfaces. However, you can add the parameter next to it -s so you can display information about particular interfaces. Instead of using «ifconfig», it is recommended to use the following command that belongs to the iproute2 suite:

ip link show

iwconfig

It is used to configure specifically the wireless network interfaces. For example, network cards. It can be used to configure various wireless network parameters such as SSID and frequency. If with the previous command, ifconfig, you set up a wireless interface with the name «tutorialredeszone» you can use the wireless interfaces command to obtain information about it. You should do it like this:

iwconfig tutorialredeszone

In this case, we are in the same scenario as with ifconfig, it is advisable to always use “ip link show” of the iproute2 suite.

Communication in general

sendmail

This command consists of a utility that allows the sending of emails directly from the terminal. Generally, this is especially useful when used on remote servers, where in many cases, there is no availability of a browser or email clients for sending emails.

How do I send a message? As follows:

echo "Subject: Test" | sendmail test@redeszone.net < mail.txt

write

With this, communication between different users that are involved in each of the Linux servers is possible. This communication is given through terminal sessions. As this is an interactive utility, it is not possible to use this network command to include it in scripts.

write user [tty]

In the example shown above, a conversation begins with the user «tty». Then, in square brackets, you must insert the username with whom you wish to communicate.

w

This command lets you know which users are currently connected to your Linux server. In addition, it has several commands to obtain even more specific information.

w --ip-addr

The example shown above shows information related to the IP addresses of the users connected to the server. This command has a wide variety of parameters that, if you are interested, you can discover them in more detailed manuals.

BONUS: Basic commands for data transfer

ftp

The FTP protocol is for file transfer. This Linux utility is widely used for uploading and downloading files that are hosted on remote hosts. It is possible to add this command to scripts that automate FTP sessions very quickly and efficiently.

The first thing you should do is create an interactive FTP session. It is possible to add several parameters to have more functionalities and perform more specific actions via FTP. For example, remote connection to a host.

ftp ftp>

Note: In any Linux command, if you type the word "–help" or "help" you can call the help to indicate what parameters we have available.

Below, we show you an example of how to connect remotely to a host and start mutual file transfer.

ftp hostname

scp

The acronym that constitutes this command means Secure Copy, that is, secure copy. Basically, it serves to copy files securely between two systems that are connected to a network. Implements secure authentication using the popular SSH protocol, using commands. You can copy files and directories (sets of folders) to machines by remote connection using scp.

scp FILE nombre-usuario@host-remoto:/algun/directorio

Above is an example of this command:

  • FILE indicates that a copy of a certain file or directory will be made.
  • username, you must indicate the name of the user to whom you will give the copy.
  • remote-host, is the host where the user is located.
  • The rest of the command represents the path (path) destination where the file or directory will be stored.

Would you like more detailed command guides? Maybe some advanced commands? Recommend us what you need to know and we will undoubtedly develop a guide for it. The list of basic Linux commands (and not so basic ones) can be considered almost infinite. Guides like these help greatly to learn and organize the commands according to their functionalities and purposes.

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments