Linux ncftp Command

Linux 命令大全Linux Command Collection

The Linux ncftp command is used for transferring files.

FTP allows users to download files stored on the server host, as well as upload files to a remote host.

Compared with the traditionalftpcommand,ncftpit provides more features and a better user experience. It supports advanced features such as resuming broken transfers, automatic reconnection, bookmarks, and recursive directory downloads, making it very suitable for users who frequently use FTP.

Installation

On most Linux distributions,ncftpit can be easily installed via the package manager.

The following are installation commands for several common distributions:

Debian/Ubuntu:

sudo apt-get install ncftp

CentOS/RHEL:

sudo yum install ncftp

Fedora:

sudo dnf install ncftp

Arch Linux:

sudo pacman -S ncftp

After installation, you can check whether the installation was successful with the following command:

ncftp --version

Syntax

ncftp [主机或IP地址]

Parameter description:

  • -u<username> Specify the username for logging in to the FTP server
  • -p<password> Set the user password
  • -P<port> Specify the FTP port number, default is 21
  • -j<account> Specify the account
  • -h Help information
  • -v Version information

Examples

1. Connect to an FTP server

To connect to an FTP server, you can use the following command:

ncftp ftp.example.com

Whereftp.example.comis the address of the FTP server you want to connect to. After a successful connection, the system will prompt you to enter a username and password.

2. Anonymous login

If the FTP server you want to connect to supports anonymous login, you can directly use the following command:

ncftp -u anonymous ftp.example.com

The system will prompt you to enter a password; you can usually enter your email address as the password.

3. Download files

To download files, you can usegetcommand. For example, to download a file namedfile.txtfile:

get file.txt

The file will be downloaded to the current working directory.

4. Upload files

To upload files, you can useputcommand. For example, to upload a file namedfile.txtfile:

put file.txt

The file will be uploaded to the current directory on the FTP server.

5. Recursively download directories

ncftpIt supports recursively downloading all files in a directory and its subdirectories. Use theget -Rcommand:

get -R directory_name

This will downloaddirectory_namethe directory and all its subdirectories and files.

6. Resume broken transfers

ncftpIt supports resuming broken transfers. If the connection is interrupted during the download, you can use theget -Ccommand to continue downloading:

get -C file.txt

This will continue downloading the file from where it was last interrupted.

7. Exit ncftp

To exitncftp, you can use thequitorexitcommand:

quit

Or:

exit

Advanced Features

1. Bookmark feature

ncftpIt provides a bookmark feature that allows you to save connection information for frequently used FTP servers for quick connection. To add a bookmark, use the following command:

bookmark add mybookmark

Wheremybookmarkis the name of the bookmark. The system will prompt you to enter the FTP server address, username, and password.

To connect using a bookmark, you can use the following command:

ncftp mybookmark

2. Auto reconnect

ncftpIt supports auto reconnect. If the connection is interrupted,ncftpit will automatically try to reconnect. To enable auto reconnect, you can use the-Aoption:

ncftp -A ftp.example.com

3. Batch download

ncftpIt supports batch download. You can use thegetcommand to download multiple files:

get file1.txt file2.txt file3.txt

Or use wildcards to download matching files:

get *.txt

Linux 命令大全Linux Command Collection

Other Extensions