【小技巧】Win10主机和Ubuntu虚拟机/服务器的文件传输
2015-09-17 14:37
344 查看
每次我们在服务器或者虚拟机编译完代码,需要传输镜像文件回主机,最开始一直采用文件夹界面虚拟机拖拽,或者FilZilla,
或者WinScap
i
这些都只需要图形化界面拖拽,后来,好奇查了下,linux shell 界面的ftp
ile Transfer Protocol (FTP) is a network protocol used to copy a file from one computer to another over the Internet or LAN. FTP follows a client-server architecture which utilizes separate
control and data connections between the ftp client and server. The default port for ftp is 21.
Use the following syntax to connect to transfer files to and from a remote network ftp site:
You must know ftp username and password for user-based password authentication or with anonymous user access use ftp as both username and password. In this example, you are connecting to
ftp.freebsd.org with anonymous user access (open the terminal and type the following command):
Sample session:
When you enter your own loginname and password for the ftp.example.com server, it returns the prompt ftp>
You need to type all commands in front of the ftp> prompt.
To copy one file at a time from the remote ftp server to the local system use get command:
In this example, download file resume.pdf in the current remote directory to (or on top of) a file with the same name, resume.pdf, in your current local directory:
Sample outputs:
In this example, copies file data.tar.gz in the current remote directory to (or on top of) a file named backup.tar.gz in your current local directory:
To change directory on your local system, enter:
Sample outputs:
Print local directory:
Sample outputs:
The lpwd command prints current download directory for local systems. However, to find out the pathname of the current directory on the remote ftp server, enter:
Sample outputs:
You need to use mget command as follows to copy multiple files from the remote ftp server to the local system. You may be prompted for a yes/no (Y/N) answer before transferring each file
(you can disable prompt by passing the -i option to ftp client). To download all files, enter:
To download all perl files (ending with .pl extension), enter:
The ftp command prompt sets interactive prompting; "on" which enables prompting so that you can verify of each step of the multiple commands, "off" allows the commands to act unimpeded:
To delete a file in the current remote directory use delete command:
To copy one file at a time from the local systems to the remote ftp server, enter:
In this example, upload logo.jpg, enter:
To copy multiple files from the local system to the remote ftp server use mput command. Again, you may be prompted for a yes/no (y/n) answer before transferring each file. In this example,
upload all files from the current system:
To set the mode of file transfer to ASCII, enter:
Please note that ascii is the default and good for text files. To set the mode of file transfer to binary, enter:
The binary mode is recommended for almost all sort of files including images,
zip files and much more. The binary mode provides less chance of a transmission error.
To open a connection with another ftp server, enter:
The above command opens a new FTP connection with ftp.nixcraft.net.in. You must provide a username and password for a ftp.nixcraft.net.in account. However, a username and password can be
skipped for an anonymous FTP connection.
Type quit or bye, enter:
Type ? or help to get more information about the FTP commands:
To get a short description about each command, enter:
用了一段时间的shell 下ftp 命令,然后又想到可不可以试着写一个脚本去直接传输kerne.img 和resource.img,只要修改第一行的用户名密码,就好了。我的主机FTP服务器设置了任何人都可以读写,所以用户名得是anonymous
编译完kernel,只要./f1就可以实现两个镜像文件的传输了。
或者WinScap
i
这些都只需要图形化界面拖拽,后来,好奇查了下,linux shell 界面的ftp
ile Transfer Protocol (FTP) is a network protocol used to copy a file from one computer to another over the Internet or LAN. FTP follows a client-server architecture which utilizes separate
control and data connections between the ftp client and server. The default port for ftp is 21.
Use the following syntax to connect to transfer files to and from a remote network ftp site:
ftp ftp.example.com ftp 1.2.3.4 ftp user@ftp.example.com
You must know ftp username and password for user-based password authentication or with anonymous user access use ftp as both username and password. In this example, you are connecting to
ftp.freebsd.org with anonymous user access (open the terminal and type the following command):
$ ftp ftp.freebsd.org[code]
Sample session:
Trying 87.51.34.132... Connected to ftp.freebsd.org. 220 ftp.beastie.tdk.net FTP server (Version 6.00LS) ready. Name (ftp.freebsd.org:vivek): ftp 331 Guest login ok, send your email address as password. Password: 230 Guest login ok, access restrictions apply. Remote system type is UNIX. Using binary mode to transfer files. ftp>
When you enter your own loginname and password for the ftp.example.com server, it returns the prompt ftp>
You need to type all commands in front of the ftp> prompt.
Task: Download / Copy file
To copy one file at a time from the remote ftp server to the local system use get command:get fileName get fileName newFileName
In this example, download file resume.pdf in the current remote directory to (or on top of) a file with the same name, resume.pdf, in your current local directory:
ftp> get resume.pdf [code]
Sample outputs:
local: resume.pdf remote: resume.pdf 229 Entering Extended Passive Mode (|||55093|) 150 Opening BINARY mode data connection for 'resume.pdf' (53077 bytes). 100% |*********************************************************************| 53077 12.58 KiB/s 00:00 ETA 226 Transfer complete. 53077 bytes received in 00:04 (12.57 KiB/s)
In this example, copies file data.tar.gz in the current remote directory to (or on top of) a file named backup.tar.gz in your current local directory:
ftp> get data.tar.gz backup.tar.gz
Change Local Directory
To change directory on your local system, enter:ftp> lcd /path/to/new/dir ftp> lcd /tmp[code]
Sample outputs:
Local directory now: /tmp
Print local directory:
ftp> lpwd 打印本地(Local)的路径[code]
Sample outputs:
/tmp
The lpwd command prints current download directory for local systems. However, to find out the pathname of the current directory on the remote ftp server, enter:
ftp> lpwd 打印FTP端的路径地址
Sample outputs:
Remote directory: /pub/FreeBSD
Task: Download Multiple Files
You need to use mget command as follows to copy multiple files from the remote ftp server to the local system. You may be prompted for a yes/no (Y/N) answer before transferring each file(you can disable prompt by passing the -i option to ftp client). To download all files, enter:
ftp> mget *[code]
To download all perl files (ending with .pl extension), enter:
ftp> mget *.pl
Task: Turn On / Off Interactive Prompting
The ftp command prompt sets interactive prompting; "on" which enables prompting so that you can verify of each step of the multiple commands, "off" allows the commands to act unimpeded:ftp> prompt on ftp> mput *.php ftp> prompt off ftp> mget *.py
Task: Delete File
To delete a file in the current remote directory use delete command:ftp> delete fileName ftp> delete output.jpg
Task: Upload One File
To copy one file at a time from the local systems to the remote ftp server, enter:ftp> put fileName[code]
In this example, upload logo.jpg, enter:
ftp> put logo.jpg
Task: Upload Multiple Files
To copy multiple files from the local system to the remote ftp server use mput command. Again, you may be prompted for a yes/no (y/n) answer before transferring each file. In this example,upload all files from the current system:
ftp> mput * ftp> mput *.pl
Task: Set The Mode Of File Transfer
To set the mode of file transfer to ASCII, enter:ftp> ascii[code]
Please note that ascii is the default and good for text files. To set the mode of file transfer to binary, enter:
ftp> binary[code]
The binary mode is recommended for almost all sort of files including images,
zip files and much more. The binary mode provides less chance of a transmission error.
Task: Connect To Another FTP Server
To open a connection with another ftp server, enter:ftp> open ftp.nixcraft.net.in[code]
The above command opens a new FTP connection with ftp.nixcraft.net.in. You must provide a username and password for a ftp.nixcraft.net.in account. However, a username and password can be
skipped for an anonymous FTP connection.
Task: Exit the FTP Session
Type quit or bye, enter:ftp> quit OR ftp> bye
How Do I Find Out More Information About The FTP Commands?
Type ? or help to get more information about the FTP commands:ftp> ? ftp> help
To get a short description about each command, enter:
ftp> help commandName ftp> help chmod
用了一段时间的shell 下ftp 命令,然后又想到可不可以试着写一个脚本去直接传输kerne.img 和resource.img,只要修改第一行的用户名密码,就好了。我的主机FTP服务器设置了任何人都可以读写,所以用户名得是anonymous
编译完kernel,只要./f1就可以实现两个镜像文件的传输了。
相关文章推荐
- android studio Gradle: 警告:编码 GBK 的不可映射字符的 ...
- 深入Java单例模式
- javascript自定义事件
- C#类库中log4net的配置
- Cookies和Session
- C++学习笔记
- iconfont 随意变换字体
- poj2686Traveling by Stagecoach(状态压缩)
- 资料
- 《黑马程序员》Java网络编程 GUI 正则表达式
- 敏捷开发二——极限编程
- HDU 1896 Stones (Priority_queue)
- 潜龙(CHLoong)软件使用及功能说明
- 营销型网站和普通型企业网站有什么不同?
- 齐家网要做透明的家装O2O平台?不,其目的是金融
- july的谱聚类
- 输入输出之转换流InputStreamReader&OutputStreamWriter
- 常用socket函数详解
- 数字签名的定义及在K2 BPM业务流程管理中的应用
- 在一个GameObject上进行多个AudioSource的控制