As a system administrator , you always have to download some software package . For this purpose you can use web browser or command line . You can use web browser in graphical mode . When you are using ssh or other command line application , then you rely on command line . In this article you will learn how to download a file from command line .

It’s true that command line is a good option to download a file because you can download all files you need at one time with the help of script .

If you want to know important commands used in linux . you should read article 50 most popular linux commands

We use wget command to download file from command line .

How to install wget in your system

It is installed by default in many linux distribution . If it is not installed in your system , you can install it with the help of following command –

For Red Hat , Fedora , CentOS

For Ubuntu , Debian

Download a file from command line

If you want to download any file from command line , you should know URL of that file . Without URL you will not able to download that file .

You can download a file from command line using following syntax . Through this command you can download a single file .

I the above example , you saw how we download a file from command line using wget command . This file is downloaded in your current working directory .

To check version of wget , use command given below –

To download a file in background

You can download a file in background using wget command with -b flag

To download multiple file

You can download multiple files with the help of wget command .

You can put several option together like –

wget -drc URL

This is equivalent of –

wget -d -r -c URL

To rename downloaded file

you can save downloaded files with different name . For this you can use wget with -O flag

To Read URL from file

You save all url in a text file and download them using wget with -i flag . For this first you have to create a file and put all url in that file .

To resume partially download file

In some condition , if download stop due to some reason , you can resume your download using wget command with -c flag.

In this article i explained how to download a file from command line . I hope this is useful for you .