Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know the ftp username, password, and directory of the source.

I just want to download the whole thing to a new server.

Simple download.

The username is not root. So I wonder how I would specify the directory name? Should I give the /home/username/public_html or should I give it as ~username/public_html

share|improve this question
This is completely dependent on how the server is configured. – Ignacio Vazquez-Abrams Jan 10 '13 at 9:40
I used cpanel. We got ftp server and stuff. – Jim Thio Jan 10 '13 at 15:35
all I want is to download a directory to my server – Jim Thio Jan 10 '13 at 15:37
up vote 2 down vote accepted


Use wget as follow

wget --mirror --no-parent --user=<ftpuser> --password=<ftppassword> ftp://server/<directory path>

It will download the whole directory recursively.

Option --no-parent

Do not ever ascend to the parent directory when retrieving recursively. This is a useful option, since it guarantees that only the files below a certain hierarchy will be downloaded.

So the following

wget --mirror --no-parent --user=<ftpuser> --password=<ftppassword> ftp://server/home/username/public_html

will only download directory structure starting with public_html.

Directory path

You should login ftp server once to confirm the path. Depending on how ftp server is configure, the path may actually start within the home directory. In that case, the directory path will be /public_html only.

Changing Directory Ownership

Change the user and group of the downloaded directory with following command

chown -R <user>:<group> public_html

If you want to change to user www-data and group www-data

chown -R www-data:www-data public_html

You may also want to remove write permission for others/anybody

chmod -R o-w public_html

-R = recursively

Category (can assign multiple without space)
u = user
g = group
o = others = anybody

"-" sign = remove permission following the sign, from category before the sign
"+" sign = add permission following the sign, to category before the sign

Permission (can assign multiple without space)
r = read permission
w = write permission
x = execute permission

ug+w = add write permission to user and group
ugo-wx = remove write and execute permission from user, group and others
share|improve this answer
who will own the downloaded file? root? – Jim Thio Jan 11 '13 at 1:58
Files will be owned by user downloading them. If you use root to download, then yes, root owns them. I added instruction to change ownership after download. – John Siu Jan 11 '13 at 2:13
mget ~/public_html

This should download everything from /home/username/public_html directory.

share|improve this answer
what does prompt do? – Jim Thio Jan 10 '13 at 20:00
By default mget runs in interactive mode i.e it will ask you if it is fine to copy over xyz file/dir and you have to respond with either y or n. To turn this feature off, prompt command needs to be executed. It toggles the Interactive Mode of FTP client. – Soumyadip DM Jan 10 '13 at 20:16
will this be recursive? – Jim Thio Jan 11 '13 at 1:57
Yes, of course. Test it for yourself :) – Soumyadip DM Jan 11 '13 at 22:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.