12 TIPS for you to use COMMAND curl as a NINJA
curl is a command/library(libcurl) available on most Unix-based systems.
curl is a command/library(libcurl) available on most Unix-based systems. It is used as an abbreviation for “Client URL”. It is used for several purposes such as: navigation, data insertion via the web, download, data transfer and among others. It supports several protocols.
To install curl you can use your distro’s package manager, but before installing make sure it is already installed with the command:
which curl, examples:
After installation, check that everything is ok, for example, by looking at the version:
Tip 1. Filling out a website form via the command line
Tip 2. Uploading files via the command line
In this case we need to inform the URL of the file path that will be responsible for receiving the file, in this case I know it is
upload.php, but it could be at the root of the host, remembering that, as I said, it redirects to ‘m/’without changing the URL.
Tip 3. Download Files
Download with the same name as the original file that is on the server: The
--remote-name parameter indicates that the source file is binary, so if you don’t pass it, curl will not be able to download it.
- % - Shows the total in PERCENTAGE of the download;
- Total - Shows the total in MEGABYTES of the download;
If you want it not to show data, use the
curl --silent givingsoup.org/downloads/distro.iso
If you miss the file name, curl will download the 404 file, so it is always good to check the size of the file
du -lhs distro.iso, if it is incorrect see what the server’s response was:
cat distro.iso(can be it a server error if it is not 404, for example, 301), so the ideal is to HASH the post downloaded file
Note: There is still no parameter to save without overwriting the file if it exists, so you need to create a solution in the shell, example:
Tip 4. Download the file saving with a name you defined:
Tip 5. Resume an interrupted download
Tip 6. Download multiple files
Tip 7. Download URLs from a file
Tip 8. Limit download speed
Tip 9. Download with progress bar
Tip 10. Query HTTP headers
Not all sites allow this query.
Tip 11. Specify a User Agent
Tip 12. Apache authentication
See all the tips worked in the video below. Remembering that the tutorial is in Portuguese, but you can use the subtitles (which are not fully translated, but the beginning and several other parts are)
The video has English subtitles native to the video itself and with the correct translation. To enable, use the settings in the footer of the video itself, according to the images shown here below.
CLICK ON IMAGES TO VIEW INTO LARGER RESOLUTION.