How to test a link use command in Linux
Published on Aug. 22, 2023, 12:14 p.m.
To test a link, you can use the curl command. curl is a command line tool with extensive functionality that can communicate using various network protocols such as HTTP, HTTPS, FTP, etc. The following is an example command to test a link using curl:
curl http://www.example.com/
The above command will send a GET request to the specified URL and output the server’s response to standard output. If you want to save the response to a file, you can use the “-o” or “-O” option:
curl -o filename http://www.example.com/
This will save the server’s response to a file named “filename”. If you want to save the response using the file name provided by the server, you can use the “-O” option:
curl -O http://www.example.com/file.txt
This command will download the “file.txt” file from the server and save it to the current directory with the same file name specified on the server.
Yes, you can also use the wget command to test a link. wget is another command line tool that can be used to download files from the web. To test a link, you can use the following command:
wget http://www.example.com/
This will download the file at the specified URL and save it to the current directory. If you want to specify a different location for the downloaded file, you can use the “-P” option:
wget -P /path/to/directory http://www.example.com/
This will save the downloaded file to the directory specified by “/path/to/directory”. Additionally, if you want to download the file using a specific protocol, you can specify it using the “-O” option, like this:
wget -O myfile.txt http://www.example.com/myfile.txt
This will download the file “myfile.txt” from the specified URL and save it to the current directory with the name “myfile.txt”. Finally, to test a link multiple times, you can use the “-tries” option, like this:
wget -tries=5 http://www.example.com/
This will make wget try to download the file 5 times before giving up.