Categories
shellinfo tips

WGET with examples

The wget command is a free utility in the Linux command-line interface for non-interactive download of files from the web. It supports HTTP, HTTPS, and FTP protocols, and can retrieve files through HTTP proxies. In this blog post, we’ll delve into the wget command, providing a comprehensive understanding with practical examples.
Understanding the ‘wget’ Command

The wget command is primarily used to download files from the internet. The basic syntax of the wget command is as follows:

wget [option]... [URL]...

Downloading Files with ‘wget’

To download a file from a URL, you simply provide the URL as an argument:

wget https://example.com/file.txt

This command will download the file file.txt from https://example.com.
Downloading in the Background with ‘wget’

If you’re downloading a large file, you may want to run wget in the background. You can do this with the -b (background) option:

wget -b https://example.com/large-file.zip

This command will download large-file.zip in the background.
Limiting the Download Rate with ‘wget’

To prevent wget from using all available bandwidth, you can limit the download rate with the –limit-rate option:

wget --limit-rate=200k https://example.com/large-file.zip

This command will limit the download rate to 200 KB/s.
Downloading Multiple Files with ‘wget’

To download multiple files, you can provide multiple URLs:

wget https://example.com/file1.txt https://example.com/file2.txt

This command will download file1.txt and file2.txt.
Conclusion

The wget command is a powerful tool for downloading files in Linux. Whether you’re downloading a single file, running in the background, limiting the download rate, or downloading multiple files, wget provides a flexible way to download files directly from the command line. With the examples provided in this guide, you’re well on your way to mastering the wget command.

Categories
shellinfo tips

Using the Linux ‘curl’ Command

The curl command is a versatile tool in the Linux command-line interface, used for transferring data to or from a server. It supports a multitude of protocols, including HTTP, HTTPS, FTP, and more. In this blog post, we’ll delve into the curl command, providing a comprehensive understanding with practical examples.
Understanding the ‘curl’ Command

The curl command is primarily used to download or upload data. The basic syntax of the curl command is as follows:

curl [options] [URL...]

Downloading Data with ‘curl’

To download data from a URL, you simply provide the URL as an argument:

curl https://example.com

This command will send a GET request to https://example.com and print the response to the standard output.

If you want to save the response to a file, you can use the -o (output) option followed by the filename:

curl -o example.html https://example.com

This command will save the response to example.html.
Sending POST Requests with ‘curl’

The curl command can also send POST requests. To do this, you can use the -d (data) option followed by the data you want to send:

curl -d "param1=value1¶m2=value2" https://example.com

This command will send a POST request to https://example.com with the data param1=value1&param2=value2.
Sending Headers with ‘curl’

To send headers with your request, you can use the -H (header) option:

curl -H "Content-Type: application/json" -d '{"param1":"value1","param2":"value2"}' https://example.com

This command will send a POST request to https://example.com with a JSON payload and the Content-Type: application/json header.
Conclusion

The curl command is a powerful tool for data transfer in Linux. Whether you’re downloading a webpage, sending a POST request, or setting headers, curl provides a flexible way to interact with servers directly from the command line. With the examples provided in this guide, you’re well on your way to mastering the curl command.