In the next article we are going to take a look at how a user can check if a website is up or down from Ubuntu terminal. Many of the commands that we are going to see I am sure that most of the people already know them, because they are especially useful for various things. Some of them are ping, curl or wget, among others.
It must be clear is that in case the user wants to receive alerts in real time about when his website / s does not work / n, it is best to use a tool for monitoring websites in real time. These commands, in principle, are not designed for that.
Check if a website is active or inactive
Using the ping command
El ping command is a network utility used to test the availability or connectivity of a host on a network. In essence, Ping is a command or a diagnostic tool that allows to verify the status of a certain connection from a local host with at least one remote computer within a TCP / IP type network.
This utility summarizes the statistical results based on packets transmitted, packets received, or packet loss. Generally includes min / avg / max times. To check if a website is active, we would only have to type in the terminal (Ctrl + Alt + T):
ping -c 4 ubunlog.com
Using the wget command
El wget command is a Free and open source command line download tool that recovers files using HTTP, HTTPS, FTP, and the most widely used Internet protocols.
If you don't have this tool, it can be installed by opening a terminal (Ctrl + Alt + T) and typing:
sudo apt install wget
For the example that concerns us, this tool should be used as follows:
wget -S --spider https://ubunlog.com
Using the curl command
El curl command is a tool to transfer data from a server or server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SFTP, SMTP, SMTPS, TELNET and TFTP). This command is designed to work without user interaction.
If you don't have this tool on your system, you can install it by opening a terminal (Ctrl + Alt + T) and typing:
sudo apt install curl
Now it can be used as follows:
curl -I https://ubunlog.com
Using the fping command
fping it's a little command-line tool that uses the Internet Control Message Protocol echo request (ICMP) to determine if a destination host is responding. It is similar to ping, but with much higher performance by being able to ping multiple hosts.
This tool differs totally from ping in that allows users to define any number of hosts on the command line, or specify a file with the list of IP addresses / hosts to ping. Fping sends an ICMP echo request and moves to the next target, does not wait for the target host to respond.
If a target host responds, it is noted as active and removed from the target list for verification. If a target does not respond within a certain time limit and / or retry limit, it is designated as unreachable.
If you don't have fping in Ubuntu, you can install it by typing in the terminal (Ctrl + Alt + T):
sudo apt install fping
Once available, it can be used as follows:
fping ubunlog.com linuxadictos.com blog.desdelinux.net
Using the httpie command
HTTPie es a modern command line http client tool that makes the CLI interact with web services.
It will offer us a simple http command, which allows us to send HTTP requests using a simple syntax and which will show us the colored results. HTTPie can be used to test, debug and generally interact with HTTP servers.
If you don't have it, it can be installed in Ubuntu by typing in the terminal (Ctrl + Alt + T):
sudo apt install httpie
To use it, you just have to type:
http ubunlog.com
Using lynx
Lynx es a highly configurable text-based web browser for use in the terminal. It is the oldest web browser and is still in active development.
If you don't have this browser, you can install it by opening a terminal (Ctrl + Alt + T) and typing the command:
sudo apt install lynx
Now to use it, you just have to write something like:
lynx -head -dump https://ubunlog.com
With these simple commands, any user will be able to quickly check if a website is active or inactive from the Ubuntu terminal.