🖌️
Linux命令大全
  • Linux 命令大全
  • 命令
    • vgchange
    • ack
    • login
    • help
    • unset
    • pstree
    • emacs
    • route
    • fg
    • uupick
    • uniq
    • exportfs
    • jed
    • cd
    • bc
    • ab
    • gunzip
    • halt
    • readelf
    • fold
    • ss
    • nologin
    • users
    • unzip
    • head
    • xinit
    • dd
    • chkconfig
    • apropos
    • spell
    • rpmverify
    • ssh
    • seinfo
    • tcpreplay
    • dpkg-preconfigure
    • mkinitrd
    • patch
    • lilo
    • xclip
    • rmmod
    • nm
    • lprm
    • look
    • reject
    • ifdown
    • ifcfg
    • gcc
    • yes
    • mysqlimport
    • ed
    • nslookup
    • ispell
    • nisdomainname
    • rsh
    • ifconfig
    • inotifywait
    • whoami
    • rpmbuild
    • e2label
    • wget
    • sendmail
    • crontab
    • setfacl
    • nl
    • rename
    • jwhois
    • sort
    • lsof
    • passwd
    • exit
    • lvresize
    • cmp
    • smbpasswd
    • tree
    • elm
    • tr
    • kill
    • times
    • pgrep
    • axel
    • gdb
    • fc
    • lha
    • pfctl
    • mknod
    • bind
    • bzdiff
    • nice
    • dpkg-statoverride
    • systool
    • gpasswd
    • tar
    • slocate
    • dpkg-deb
    • file
    • zcat
    • ngrep
    • gpm
    • arptables
    • sshd
    • ipcalc
    • sar
    • basename
    • tmux
    • ftpwho
    • uuto
    • false
    • builtin
    • cksum
    • pwconv
    • rexec
    • rev
    • rm
    • source
    • fdisk
    • sync
    • killall
    • lsb_release
    • id
    • tput
    • repquota
    • uncompress
    • cut
    • ldconfig
    • mysql
    • pidof
    • sesearch
    • shift
    • openssl
    • ftp
    • vgconvert
    • nohup
    • dig
    • iostat
    • strings
    • set
    • type
    • expand
    • cancel
    • chsh
    • gzip
    • umask
    • hping3
    • logsave
    • ltrace
    • pathchk
    • nmcli
    • lscpu
    • zipsplit
    • printf
    • rpmquery
    • zip
    • diffstat
    • runlevel
    • sftp-server
    • find
    • less
    • chown
    • col
    • ifup
    • uname
    • named-checkzone
    • mke2fs
    • pssh
    • disown
    • lftpget
    • scp
    • mii-tool
    • pstack
    • lsattr
    • joe
    • ld
    • chgrp
    • dris
    • xhost
    • xauth
    • userdel
    • unarj
    • ssh-agent
    • lpstat
    • cupsenable
    • grub
    • lynx
    • ipcs
    • write
    • logrotate
    • csplit
    • seq
    • rcp
    • touch
    • lpc
    • quotaoff
    • mail
    • mpstat
    • vgreduce
    • hwclock
    • arp
    • rlogin
    • break
    • mysqlshow
    • syslog
    • gzexe
    • semanage
    • ip6tables-save
    • startx
    • pvchange
    • rpm2cpio
    • chattr
    • grep
    • volname
    • who
    • last
    • lnstat
    • read
    • atq
    • lftp
    • setsebool
    • ssh-keygen
    • bzcat
    • iptables-save
    • jobs
    • arch
    • shutdown
    • shopt
    • sh
    • more
    • iconv
    • chcon
    • od
    • nc
    • lsusb
    • squidclient
    • pwd
    • dircolors
    • which
    • fsck
    • expr
    • partprobe
    • wait
    • dpkg-split
    • get_module
    • chmod
    • vgremove
    • rcconf
    • export
    • nano
    • stat
    • blkid
    • pvdisplay
    • dump
    • elinks
    • atop
    • restorecon
    • showmount
    • suspend
    • apk
    • telint
    • supervisord
    • groups
    • ssh-add
    • fgrep
    • setpci
    • dnf
    • pwunconv
    • swapoff
    • resize
    • kexec
    • insmod
    • install
    • cpio
    • hostname
    • kernelversion
    • ex
    • at
    • unlink
    • let
    • dpkg-divert
    • egrep
    • unexpand
    • popd
    • lsmod
    • slabtop
    • dpkg-trigger
    • vi
    • colrm
    • ftptop
    • depmod
    • cdrecord
    • swapon
    • mailq
    • ping
    • mktemp
    • cu
    • as
    • uucico
    • test
    • man
    • losetup
    • strace
    • dhcrelay
    • tload
    • batch
    • split
    • parted
    • chage
    • dos2unix
    • lsblk
    • locate
    • du
    • bzip2recover
    • arj
    • ar
    • bzless
    • tty
    • exec
    • mount
    • ifstat
    • mkswap
    • grpconv
    • edquota
    • lvreduce
    • tempfile
    • init
    • fishshell
    • dstat
    • logger
    • php
    • tail
    • return
    • htdigest
    • arpwatch
    • dnsdomainname
    • iftop
    • ntpdate
    • renice
    • fping
    • quotacheck
    • quota
    • lvdisplay
    • mapfile
    • dirname
    • ntsysv
    • pwck
    • unalias
    • usermod
    • sftp
    • apt-key
    • dhclient
    • ipcrm
    • quotaon
    • vgrename
    • perl
    • sleep
    • w
    • domainname
    • vdfuse
    • ssh-keyscan
    • dpkg-reconfigure
    • info
    • mtools
    • lvremove
    • tftp
    • zfore
    • modprobe
    • vgscan
    • date
    • mysqldump
    • sysctl
    • cat
    • tac
    • bzgrep
    • nmap
    • tailf
    • bmodinfo
    • useradd
    • whatis
    • make
    • atrm
    • true
    • ftpshut
    • pvck
    • top
    • mkbootdisk
    • chfn
    • htop
    • service
    • trap
    • md5sum
    • ftpcount
    • firewall-cmd
    • ip6tables-restore
    • time
    • bzmore
    • sudo
    • tcpdump
    • iptables-restore
    • awk
    • apt-sortpkgs
    • cp
    • xargs
    • mysqladmin
    • vgcreate
    • wc
    • indent
    • screen
    • groupdel
    • comm
    • tee
    • pmap
    • free
    • curl
    • mkisofs
    • mesg
    • history
    • ip6tables
    • getenforce
    • pigz
    • talk
    • protoize
    • iptables
    • setsid
    • clockdiff
    • vgextend
    • mkfs
    • paste
    • mailstat
    • dhcpd
    • cupsdisable
    • logwatch
    • smbclient
    • bzip2
    • vmstat
    • git
    • iperf
    • wall
    • ppp-off
    • squid
    • join
    • getsebool
    • xset
    • htpasswd
    • logout
    • rmdir
    • grpunconv
    • poweroff
    • pvremove
    • iptraf
    • sed
    • mv
    • finger
    • netstat
    • skill
    • xlsclients
    • whereis
    • fuser
    • eject
    • consoletype
    • usernetctl
    • yum
    • ethtool
    • vgdisplay
    • newusers
    • blockdev
    • alias
    • hdparm
    • host
    • nethogs
    • dmesg
    • accept
    • dpkg
    • uptime
    • lvscan
    • lspci
    • chroot
    • updatedb
    • rpm
    • watch
    • logname
    • hexdump
    • zipinfo
    • nfsstat
    • continue
    • ls
    • iotop
    • ip
    • mkdir
    • aptitude
    • dirs
    • lvcreate
    • dmidecode
    • diff3
    • apt-get
    • stty
    • clock
    • pkill
    • ypdomainname
    • restore
    • ulimit
    • findfs
    • pv
    • znew
    • cal
    • ssh-copy-id
    • lpr
    • bzcmp
    • lastlog
    • bye
    • bg
    • unprotoize
    • convertquota
    • pico
    • diff
    • grpck
    • apachectl
    • env
    • fmt
    • ncftp
    • xlsfonts
    • rpmdb
    • reboot
    • lpq
    • clear
    • echo
    • pvs
    • rsync
    • arpd
    • ldd
    • lastb
    • umount
    • systemctl
    • lvextend
    • bunzip2
    • speedtest-cli
    • iptstate
    • lp
    • traceroute
    • rpmsign
    • pvscan
    • enable
    • objdump
    • command
    • arping
    • badblocks
    • gcov
    • hostid
    • local
    • ps
    • xlsatoms
    • dpkg-query
    • groupmod
    • lpadmin
    • sum
    • chpasswd
    • xz
    • groupadd
    • su
    • pr
    • e2fsck
    • unrar
    • telnet
    • ln
    • declare
    • df
    • compress
    • tracepath
    • pvcreate
    • pushd
    • readonly
Powered by GitBook
On this page

Was this helpful?

Last updated 5 years ago

Was this helpful?

使在两台Linux主机之间的文件复制操作更简单

补充说明

rcp命令 使在两台Linux主机之间的文件复制操作更简单。通过适当的配置,在两台Linux主机之间复制文件而无需输入密码,就像本地文件复制一样简单。

语法

选项

同名用户的主目录。如果没有给出远程用户名,就使用当前用户名。如果远程机上的路径包含特殊shell字符,需要用反斜线\\、双引号""或单引号''括起来,使所有的shell元字符都能被远程地解释。需要说明的是,rcp不提示输入口令,它通过rsh命令来执行拷贝。

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

参数

源文件:指定要复制的源文件。源文件可以有多个。

实例

rcp命令使用条件

如果系统中有/etc/hosts文件,系统管理员应确保该文件包含要与之进行通信的远程主机的项。配置过程:

只对root用户生效

1、在双方root用户根目录下建立rhosts文件,并将双方的hostname加进去。在此之前应在双方的/etc/hosts文件中加入对方的ip和hostname 2、把rsh服务启动起来,redhat默认是不启动的。 方法:用执行ntsysv命令,在rsh选项前用空格键选中,确定退出。然后执行service xinetd restart即可。 3、到/etc/pam.d/目录下,把rsh文件中的auth required /lib/security/pam_securetty.so一行用“#”注释掉即可。(只有注释掉这一行,才能用root用户登录)

将当前目录下的 test1 复制到名为 webserver1 的远程系统:

在这种情况下,test1 被复制到远程子目录 test3下,名称仍为 test1 。如果仅提供了远程主机名,rcp 将把 test1 复制到远程主目录下,名称仍为 test1 。

还可以在目的目录中包含文件名。例如,将文件复制到名为 webserver1的系统中:

在这种情况下,将 test1 复制到远程目录root 下并将其命名为 test3。

从远程系统复制文件:要将远程系统中的文件复制到本地目录下:

将远程系统 webserver1中的 test2 复制到当前目录:

.是“当前目录”的简写形式。在这种情况下,远程目录中的 test2 被复制到当前目录下,名称仍为 test2 。

如果希望用新名称复制文件,请提供目标文件名。如果希望将 test2 复制到本地系统中的其他目录下,请使用以下绝对或相对路径名:

或者,如果希望用其他文件名将文件复制到其他目录下:

将目录复制到远程系统:

要将本地目录及其文件和子目录复制到远程系统,请同时使用 rcp 和 -r(递归)选项。

如果当前目录下没有 local_dir,则除本地目录名外,还需要提供相对路径名(自当前目录开始)或绝对路径名(自 / 顶级目录开始)。另外,如果主目录下没有 remote_dir,则 remote_dir 将需要一个相对路径(自主目录开始)或绝对路径(自 / 开始)。

要将名为 work 的子目录完整地复制到 webserver1远程计算机中的主目录下名为 products 的目录,请键入以下内容:

此命令在webserver1:/home/root/products下创建名为 work 的目录及其全部内容(假定/home/root/products已存在于 webserver1中)。

本示例假定用户处于包含 work 的本地目录下。否则,必须提供该目录的相对或绝对路径,如/home/root/work。

从远程系统复制目录:

要将远程目录及其所有文件和子目录复制到本地目录,请在以下语法中使用 rcp 和 -r(递归)选项。

要将名为 work 的远程目录复制到当前目录,请键入以下内容:

.表示当前目录。将在此目录下创建 work 目录。

rcp(选项)(参数)
-p:保留源文件或目录的属性,包括拥有者、所属群组、权限与时间;
-r:递归处理,将指定目录下的文件与子目录一并处理;
-x:加密两台Linux主机间传送的所有信息。
-D:指定远程服务器的端口号。
rcp test1 webserver1:/home/root/test3
rcp test1 webserver1:/home/root/test3
rcp remote_hostname:remote_file local_fileEnter
rcp webserver1:/home/root/test2 .Enter
rcp webserver1:/home/root/test2 otherdir/ Enter
rcp webserver1:/home/root/test2 otherdir/otherfile Enter
rcp -r local_dir remote_hostname:remote_dir Enter
rcp -r work webserver1:/home/root/products Enter
rcp –r remote_hostname:remote_dir local_dir Enter
rcp –r webserver1:/home/root/work .Enter
  1. 命令

rcp

PreviousseqNexttouch
  • 补充说明
  • 语法
  • 选项
  • 参数
  • 实例