Linux / Unix ncftp: Upload Directory Tree To Remote FTP Server Recursively

last updated in Categories Howto, Linux, UNIX

When you host your web site remotely and and the ftp server is the only way to upload all files including subdirectroies. You need to use special file transfer program such as ncftpget or ncftpput for recursive remote ftp server uploading and downloading purpose. Ncftp is considered as an improved FTP client. Ncftp’s improvements include support for command line editing, command histories, recursive gets/puts, automatic anonymous logins, and much more.


Install ncftp client

Type the following apt-get command under Debian / Ubuntu Linux to install ncftp client, run:
$ sudo apt-get install ncftp
Sample outputs:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
Need to get 588 kB of archives.
After this operation, 1,307 kB of additional disk space will be used.
Get:1 squeeze/main ncftp amd64 2:3.2.4-1 [588 kB]
Fetched 588 kB in 2s (199 kB/s)
Selecting previously deselected package ncftp.
(Reading database ... 274906 files and directories currently installed.)
Unpacking ncftp (from .../ncftp_2%3a3.2.4-1_amd64.deb) ...
Processing triggers for menu ...
Processing triggers for man-db ...
Setting up ncftp (2:3.2.4-1) ...
update-alternatives: using /usr/bin/ncftp3 to provide /usr/bin/ncftp (ncftp) in auto mode.
Processing triggers for menu ...

If you are RHEL / CentOS / Fedora Linux user, type the following yum command to install ncftp client (first turn on EPEL repo):
# yum install ncftp

Syntax and examples

The syntax is as follows:

ncftpput ftp-host-name /path/to/remote/dir /path/to/local/dir
ncftpput -options ftp-host-name /path/to/remote/dir /path/to/local/dir

Try the ncftpput client command as follows:

ncftpput -R -v -u "username" /nixcraft/forum /tmp/phpbb


  • -u "username" : Ftp server username
  • -v : Verbose i.e. show upload progress
  • -R : Recursive mode; copy whole directory trees.
  • : Remote ftp server (use FQDN or IP).
  • /nixcraft/forum : Remote ftp server directory where all files and subdirectories will be uploaded.
  • /tmp/phpbb : Local directory (or list of files) to upload remote ftp server directory /nixcraft/forum

You can pass the password with -p option:

ncftpput -R -v -u "username" -p "passwordHere" /nixcraft/forum /tmp/phpbb

You can use port number 2021 instead of the default FTP service port # 21 as follows:

ncftpput -R -v -u "username" -p "passwordHere" -P 2021 /nixcraft/forum /tmp/phpbb
See also
  • See ftptreeupload.bash script to copy all files and subdirectories recursively and upload them to remote FTP server (copy local all directories/tree to remote ftp server).
  • ncftpput client can be downloaded from and works with FreeBSD, Solaris and all most all UNIX like variant.


Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

10 comment

  1. Thanks for this – saved me an age.

    Just for those who dont work it out themselves, you can not copy and paste the command line as the – (minus/dash) sign is not the correct type. You will need to replace them with a dash from your keyboard. Something to do with the way the web formats them I guess.

  2. Jupp, saved my day uploading 300GB of data to a new repository with only ftp available…
    Works fine with symbolic link in the filesystem.

  3. Hi, I am trying to upload a wordpress folder which contains some sub folders… but your command uploads everything in the root folder and is not creating any folders. …

  4. This doesn’t work when executed from Crontab or when the script is double-clicked in the File browser.

    Have a question? Post it on our forum!