Please help Ukrainian armed forces! Official Fundraising

How To Upload Directory Tree To Remote FTP Server Recursively in Linux

1 1 1 1 1 How To Upload Directory Tree To Remote FTP Server Recursively in Linux5.00Rating 5.00 (636 Votes)

When you host your web site remotely 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.

1. Install ncftp client

Type the following command under Debian/Ubuntu Linux to install ncftp client:
$ 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:
  ncftp
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 http://debian.osuosl.org/debian/ 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

 

2. Usage 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" ftp.nixcraft.biz /nixcraft/forum /tmp/phpbb
 

Where,

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

You can pass the password with -p option:

 
ncftpput -R -v -u "username" -p "passwordHere" ftp.mysite.biz /forum /tmp
 

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 ftp.mysite.biz /forum /tmp

Source

 
Monday the 9th.