Howto: Use wget Recursively Download All FTP Directories

I would like to copy all of my files and directories from UNIX server to Linux workstation. How do I use wget command to recursively download whole FTP directories stored at /home/tom/ from to local directory called /home/tom/backup?

GNU Wget is a free Linux / UNIX utility for non-interactive download of files from the Web or and FTP servers, as well as retrieval through HTTP proxies. GNU/wget has been designed for robustness over slow dialup internet or unstable network connections. If a download fails due to a network problem, it will keep retrying until the whole file has been retrieved. If the server supports regetting, it will instruct the server to continue the download from where it left off.

wget Recursive Example

You can use the -r ( recursive retrieving ) option as follows. You can also pass your ftp username and password to the wget command. First, make a backup directory in your $HOME directory:

mkdir ~/backup/
cd ~/backup/

Now, use wget command as follows:

wget -r
wget -r
wget -r

wget recursive ftp with mirroring option

The -m option turns on mirroring i.e. it turns on recursion and time-stamping, sets infinite recursion depth and keeps FTP directory listings:

wget -m
wget -m

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 4 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
4 comments… add one
  • Ravi Jan 25, 2013 @ 22:22

    the mirroring option is not retaining the time stamp of directories but only of the files in those directories…can you think of a solution where someone would want to retain the directory structure of the same.

  • disney May 22, 2013 @ 2:04

    it assumes the current directory as root so we dont need to specify, but I have a parent directory in parallel to root as var
    the below only works and pulls data from root/var/tests and not /var/tests
    wget64 -r ftp://root:root@
    any suggestions?

  • disney May 22, 2013 @ 2:07

    sorry my pwd is root, so how do I change that for wget64?

  • Jason Huebel Dec 23, 2014 @ 19:57

    I also like to drop the directories that it will normally create when using this command. So, starting with the examples above:

    wget -r

    This command would create a local directory structure that looks like this:


    So, I like to add the following command-line options:

    wget -r -nH –cut-dirs=2

    -nH removes the root directory from the local copy. –cut-dirs=2 removes /home/username from the local copy. So you end up with everything being saved to the current directory (and recursively copying folders from the remote /home/username folder.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum