`
yuanlanjun
  • 浏览: 1181100 次
文章分类
社区版块
存档分类
最新评论

linux间文件移动 -- ftp/scp/rcp/nfs

 
阅读更多

1、ftp

基本命令格式

ftp -v -d -i -n -g [主机名] 

参数说明

-v 显示远程服务器的所有响应信息
-n 限制ftp的自动登录,即不使用;.n etrc文件
-d 使用调试方式
-g 取消全局文件名

ftp内部命令

1.![cmd[args]]:在本地机中执行交互shell,exit回到ftp环境,如:!ls*.zip

2.$ macro-ame[args]: 执行宏定义macro-name。

3.account[password]: 提供登录远程系统成功后访问系统资源所需的补充口令。

4.append local-file[remote-file]:将本地文件追加到远程系统主机,若未指定远程系统文件名,则使用本地文件名。

5.ascii:使用ascii类型传输方式。

6.bell:每个命令执行完毕后计算机响铃一次。

7.bin:使用二进制文件传输方式。

8.bye:退出ftp会话过程。

9.case:在使用mget时,将远程主机文件名中的大写转为小写字母。

10.cd remote-dir:进入远程主机目录。

11.cdup:进入远程主机目录的父目录。

12.chmod mode file-name:将远程主机文件file-name的存取方式设置为mode,如:chmod 777 a.out。

13.close:中断与远程服务器的ftp会话(与open对应)。

14.cr:使用asscii方式传输文件时,将回车换行转换为回行。

15.delete remote-file:删除远程主机文件。

16.debug[debug-value]:设置调试方式, 显示发送至远程主机的每条命令,如:deb up 3,若设为0,表示取消debug。

17.dir[remote-dir][local-file]:显示远程主机目录,并将结果存入本地文件

18.disconnection:同close。

19.form format:将文件传输方式设置为format,缺省为file方式。

20.get remote-file[local-file]: 将远程主机的文件remote-file传至本地硬盘的local-file。

21.glob:设置mdelete,mget,mput的文件名扩展,缺省时不扩展文件名,同命令行的-g参数。

22.hash:每传输1024字节,显示一个hash符号(#)。

23.help[cmd]:显示ftp内部命令cmd的帮助信息,如:help get。

24.idle[seconds]:将远程服务器的休眠计时器设为[seconds]秒。

25.image:设置二进制传输方式(同binary)。

26.lcd[dir]:将本地工作目录切换至dir。

27.ls[remote-dir][local-file]:显示远程目录remote-dir, 并存入本地文件local-file。

28.macdef macro-name:定义一个宏,遇到macdef下的空行时,宏定义结束。

29.mdelete[remote-file]:删除远程主机文件。

30.mdir remote-files local-file:与dir类似,但可指定多个远程文件,如 :mdir *.o.*.zipoutfile 。

31.mget remote-files:传输多个远程文件。

32.mkdir dir-name:在远程主机中建一目录。

33.mls remote-file local-file:同nlist,但可指定多个文件名。

34.mode[modename]:将文件传输方式设置为modename, 缺省为stream方式。

35.modtime file-name:显示远程主机文件的最后修改时间。

36.mput local-file:将多个文件传输至远程主机。

37.newer file-name: 如果远程机中file-name的修改时间比本地硬盘同名文件的时间更近,则重传该文件。

38.nlist[remote-dir][local-file]:显示远程主机目录的文件清单,并存入本地硬盘的local-file。

39.nmap[inpattern outpattern]:设置文件名映射机制, 使得文件传输时,文件中的某些字符相互转换, 如:nmap $1.$2.$3[$1,$2].[$2,$3],则传输文件a1.a2.a3时,文件名变为a1,a2。该命令特别适用于远程主机为非UNIX机的情 况。

40.ntrans[inchars[outchars]]:设置文件名字符的翻译机制,如ntrans1R,则文件名LLL将变为RRR。

41.open host[port]:建立指定ftp服务器连接,可指定连接端口。

42.passive:进入被动传输方式。

43.prompt:设置多个文件传输时的交互提示。

44.proxy ftp-cmd:在次要控制连接中,执行一条ftp命令,该命令允许连接两个ftp服务器,以在两个服务器间传输文件。第一条ftp命令必须为open,以首先建立两个服务器间的连接。

45.put local-file[remote-file]:将本地文件local-file传送至远程主机。

46.pwd:显示远程主机的当前工作目录。

47.quit:同bye,退出ftp会话。

48.quote arg1,arg2...:将参数逐字发至远程ftp服务器,如:quote syst.

49.recv remote-file[local-file]:同get。

50.reget remote-file[local-file]:类似于get, 但若local-file存在,则从上次传输中断处续传。

51.rhelp[cmd-name]:请求获得远程主机的帮助。

52.rstatus[file-name]:若未指定文件名,则显示远程主机的状态, 否则显示文件状态。

53.rename[from][to]:更改远程主机文件名。

54.reset:清除回答队列。

55.restart marker:从指定的标志marker处,重新开始get或put,如:restart 130。

56.rmdir dir-name:删除远程主机目录。

57.runique:设置文件名只一性存储,若文件存在,则在原文件后加后缀.1, .2等。

58.send local-file[remote-file]:同put。

59.sendport:设置PORT命令的使用。

60.site arg1,arg2...:将参数作为SITE命令逐字发送至远程ftp主机。

61.size file-name:显示远程主机文件大小,如:site idle 7200。

62.status:显示当前ftp状态。

63.struct[struct-name]:将文件传输结构设置为struct-name, 缺省时使用stream结构。

64.sunique:将远程主机文件名存储设置为只一(与runique对应)。

65.system:显示远程主机的操作系统类型。

66.tenex:将文件传输类型设置为TENEX机的所需的类型。

67.tick:设置传输时的字节计数器。

68.trace:设置包跟踪。

69.type[type-name]:设置文件传输类型为type-name,缺省为ascii,如:type binary,设置二进制传输方式。

70.umask[newmask]:将远程服务器的缺省umask设置为newmask,如:umask 3

71.user user-name[password][account]:向远程主机表明自己的身份,需要口令时,必须输入口令,如:user anonymous my@email。

72.verbose:同命令行的-v参数,即设置详尽报告方式,ftp 服务器的所有响 应都将显示给用户,缺省为on.

73.?[cmd]:同help.

注:ftp的内部命令有很多,在使用中应该多使用help(或?)命令来判断使用什么样的命令。

sftp简介

sftp 是一个交互式文件传输程式。它类似于 ftp, 但它进行加密传输,比FTP有更高的安全性。

例如:

[root@CentOS /]#
[root@CentOS /]# sftp root@10.15.62.78
Connecting to 10.15.62.78...
root@10.15.62.78's password:
sftp> ?
Available commands:
bye                                Quit sftp
cd path                            Change remote directory to 'path'
chgrp grp path                     Change group of file 'path' to 'grp'
chmod mode path                    Change permissions of file 'path' to 'mode'
chown own path                     Change owner of file 'path' to 'own'
df [-hi] [path]                    Display statistics for current directory or
                                   filesystem containing 'path'
exit                               Quit sftp
get [-P] remote-path [local-path]  Download file
help                               Display this help text
lcd path                           Change local directory to 'path'
lls [ls-options [path]]            Display local directory listing
lmkdir path                        Create local directory
ln oldpath newpath                 Symlink remote file
lpwd                               Print local working directory
ls [-1aflnrSt] [path]              Display remote directory listing
lumask umask                       Set local umask to 'umask'
mkdir path                         Create remote directory
progress                           Toggle display of progress meter
put [-P] local-path [remote-path]  Upload file
pwd                                Display remote working directory
quit                               Quit sftp
rename oldpath newpath             Rename remote file
rm path                            Delete remote file
rmdir path                         Remove remote directory
symlink oldpath newpath            Symlink remote file
version                            Show SFTP version
!command                           Execute 'command' in local shell
!                                  Escape to local shell
?                                  Synonym for help
sftp>
sftp>

2、scp

scp全称Secure Copy,主要用于在网络主机之间复制文件(或文件夹),使用ssh进行认证,从而能够安全的在网络主机之间进行文件的拷贝。

基本命令格式

scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
[-l limit] [-o ssh_option] [-P port] [-S program]
[[user@]host1:]file1 [...] [[user@]host2:]file2
参数说明

-1 强制scp命令使用协议ssh1
-2 强制scp命令使用协议ssh2
-4 强制scp命令只使用IPv4寻址
-6 强制scp命令只使用IPv6寻址
-B 使用批处理模式(传输过程中不询问传输口令或短语)
-C 允许压缩(将-C标志传递给ssh,从而打开压缩功能)
-p 保留原文件的修改时间,访问时间和访问权限
-q 不显示传输进度条
-r 递归复制整个目录
-v 详细方式显示输出,scp和ssh(1)会显示出整个过程的调试信息,这些信息用于调试连接,验证和配置问题
-c cipher 以cipher将数据传输进行加密,这个选项将直接传递给ssh
-F ssh_config 指定一个替代的ssh配置文件,此参数直接传递给ssh
-i identity_file 从指定文件中读取传输时使用的密钥文件,此参数直接传递给ssh
-l limit 限定用户所能使用的带宽,以Kbit/s为单位
-o ssh_option 如果习惯于使用ssh_config(5)中的参数传递方式
-P port  注意是大写的P, port是指定数据传输用到的端口号
-S program 指定加密传输时所使用的程序。此程序必须能够理解ssh(1)的选项
实际应用

1)从本地服务器复制到远端服务器、

-- 复制文件

命令格式:

scp local_file remote_username@remote_ip:remote_folder  #指定用户名和文件夹,文件名称不变
scp local_file remote_username@remote_ip:remote_file    #指定用户名和文件的名称
scp local_file remote_ip:remote_folder                  #指定文件夹,文件名称不变
scp local_file remote_ip:remote_file                    #指定文件名称
示例:

scp /home/linux/soft/scp.zip root@www.mydomain.com:/home/linux/others/soft
scp /home/linux/soft/scp.zip root@www.mydomain.com:/home/linux/others/soft/scp2.zip
scp /home/linux/soft/scp.zip www.mydomain.com:/home/linux/others/soft
scp /home/linux/soft/scp.zip www.mydomain.com:/home/linux/others/soft/scp2.zip
-- 复制目录

命令格式:

scp -r local_folder remote_username@remote_ip:remote_folder  #指定用户名
scp -r local_folder remote_ip:remote_folder                  #未指定用户名

示例:

scp -r /home/linux/soft/ root@www.mydomain.com:/home/linux/others/
scp -r /home/linux/soft/ www.mydomain.com:/home/linux/others/

2)从远端服务器复制到本地服务器

与1)中从本地服务器复制到远端服务器的操作相似,只需调换地址即可。示例如下:

scp root@www.mydomain.com:/home/linux/soft/scp.zip /home/linux/others/scp.zip  #复制文件
scp www.mydomain.com:/home/linux/soft/ -r /home/linux/others/                  #复制目录

3、rcp

rcp全称Remote File Copy,用于在不同机器上进行文件和目录的拷贝。

基本命令格式

rcp [-px] [-k realm] file1 file2
rcp [-px] [-r] [-k realm] file directory
每个文件或目录参数既可以是远程文件名也可以是本地文件名。远程文件名具有如下形式:rname@rhost:path,其中rname是远程用户名,rhost是远程计算机名,path是这个文件的路径。

参数说明

-r 递归地把源目录中的所有内容拷贝到目的目录中。要使用这个选项,目的必须是一个目录。
-p 试图保留源文件的修改时间和模式,忽略umask。
-k 请求rcp获得在指定区域内的远程主机的Kerberos 许可,而不是获得由krb_relmofhost(3)确定的
   远程主机区域内的远程主机的Kerberos许可。
-x 为传送的所有数据打开DES加密。这会影响响应时间和CPU利用率,但是可以提高安全性。

4、nfs



=====================================

参考文献:

http://blog.csdn.net/manbujingxin/article/details/6893633

http://blog.csdn.net/tglg/article/details/4040929

http://www.cnblogs.com/xuxm2007/archive/2010/08/04/1792179.html

http://www.lupaworld.com/tutorial-view-aid-10154.html



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics