How to check Internet is working or not in Linux command line. Here is how to check internet connection in Ubuntu terminal.
Check Network Connectivity Using the Ping Command
The PING command is used for sending and receiving packages from and to external/remote server. It is used to verify the connection status in realtime.
In technical terms, ping uses the ICMP protocol’s mandatory ECHO_REQUEST datagram to elicit an ICMP ECHO_RESPONSE from a host or gateway.
You can use the following command to chech the network connectivity via ping comamnd:
ping -c 3 google.com
-c count is used for ping command and it specifies to stop after sending count ECHO_REQUEST packets. With deadline option, ping waits for count ECHO_REPLY packets, until the timeout expires.
The c follows the number of packages to send alongwith ping request.
Check Network Connectivity Using the Curl Command
We all know that the CURL command is used to download, upload, or transfer the data over the network from or to the server.
You can check the internet connection through the CURL command:
curl -I https://sourcedigit.com/
The curl is used to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP).
The curl command is designed to work without user interaction.