FTP and SFTP 用法
来源:互联网 发布:十大网络推广公司排名 编辑:程序博客网 时间:2024/05/22 13:13
1. Connect to a FTP site
Connect to a particular FTP server using ftp command as shown below.
Syntax:
$ ftp IP/hostnameor $ ftpftp> open IP/hostname
You can directly open connection with a remote host using it’s IP or host name from the command line. You can also go to ftp prompt and use open command to connect with remote host.
It will ask you for the user name and password to login. On some public domain FTP server, you can use “anonymous” username with any email address as the password to connect.
2. Download a file using ftp
Use the get command to download file from a remote ftp server as shown below.
ftp> get FILENAME
You have to be in the right mode to download files. i.e binary or ascii mode. Use ascii mode for transferring text files, and binary mode for all other type of files.
Download the file and save it with another name. In the following example, index.html file will be downloaded and saved as my.html on the local server.
ftp> get index.html my.htmlFetching /home/groups/index.html to my.html/home/groups/index.html 100% 2886 1.4KB/s 00:02
3. Changing FTP Mode to binary or ascii
Go to ftp Ascii mode
ftp> ascii200 Type set to A.
Go to ftp Binary mode
ftp> binary200 Type set to I.
4. Uploading a file to FTP server
Use put command to upload a file to a remote ftp server as shown below.
ftp> put filename
5. Changing the remote and local directory
Apart from downloading or uploading a file, you may want to change either the remote or local directory, which you can do using cd and lcd respectively.
Change the remote server current directory using cd command
ftp> pwd257 "/myftpserver" is current directory.ftp> cd dir1250 CWD command successful. "/myftpserver/dir1" is current directory.ftp> pwd257 "/myftpserver/dir1" is current directory.
Change the local machine current directory using lcd command
ftp> !$ pwd/home/sathiya/FTP$ exitexitftp> lcd /tmpLocal directory now /tmpftp> !$ pwd/tmp
Note:
- executing ! takes you to the shell.
- prompt starts with ftp> is ftp prompt.
- prompt starts with $ is shell command line.
6. Listing the contents of remote directory from FTP
You can view the content of a remote directory using the ls / dir command.
ftp> ls
7. FTP Help
Type help or ? to view list of all available ftp commands.
For a detailed help on a particular ftp command use:
ftp> help COMMAND
8. Downloading multiple files with mget command
mget is for fetching multiple files from ftp server. You can use globs to download multiple files. For example, *.html will download all html files. The glob expansion are done on the remote server. So, it depends on the operating system of the remote server.
ftp> mget *.htmlFetching /ftptest/features.html to features.html/ftptest/features.html 100% 2256 2.2KB/s 00:01 Fetching /ftptest/index.html to index.html/ftptest/index.html 100% 2886 2.8KB/s 00:01 Fetching /ftptest/othertools.html to othertools.html/ftptest/othertools.html 100% 2282 2.2KB/s 00:01 Fetching /ftptest/samplereport.html to samplereport.html/ftptest/samplereport.html 100% 15KB 7.3KB/s 00:02 Fetching /ftptest/usage.html to usage.html/ftptest/usage.html 100% 2340 2.3KB/s 00:01
To view the file names before downloading, you can also use mls command as shown below.
ftp> mls *.html -/ftptest/features.html /ftptest/index.html /ftptest/othertools.html /ftptest/samplereport.html /ftptest/usage.html
9. Uploading multiple files with mput command
Use mput to upload multiple files together. This works similar to the mget command. The following example uploads all the *.html file from local server to remote server.
ftp> mput *.html
10. Close a FTP connection
Without exiting the ftp prompt you may want to open a connection to another server. In that case, execute close command.
ftp> open ftp.your_server.comAlready connected to NNN.com, use close first.ftp> close221 Goodbye.ftp> open ftp.your_server.com
- FTP and SFTP 用法
- sftp与ftp用法
- SFTP,FTP
- sftp用法
- SFTP用法
- sftp用法
- Sftp和Ftp
- ftp以及sftp使用
- FTP、FTPS和SFTP
- SFTP & FTP Upload
- ftp、sftp常用命令
- FTP,SFTP命令
- ftp与sftp
- Phpstorm FTP sftp
- Sublime 安装 FTP/SFTP
- FTP与SFTP
- java 实现FTP sftp
- FTP,SFTP,FTPS区别
- 【SpringMVC-003】idea创建SpringMVC项目傻瓜教程-URL传值
- PPEasy(P2P+流媒体)传输系统简介
- iOS 11 新API的多种代码示例
- HDU_6069 Counting Divisors 【数论】
- ListView详解
- FTP and SFTP 用法
- 取消ORACLE11g用户密码过期期限
- ubuntu14.04+cuda8.0(TX2宿主机)安装opencv3.0
- 布隆过滤器
- robo3t 1.1在ubuntu 16.04中无法打开的解决方案
- MySQL学习笔记——20170809
- 在 Fedora24/25/26 中轻松安装 gcc 4.9
- POJ 2891 Strange Way to Express Integers
- LeetCode Weekly Contest 44解题思路