rcp代表"remote file copy"(遠程文件拷貝)。
(1)用法:
用法: rcp [參數] [源文件] [目標文件]
(2)功能:
功能: rcp命令用於在計算機之間拷貝文件。
rcp命令使在兩台Linux主機之間的文件復制操作更簡單。通過適當的配置,在兩台Linux主機之間復制文件而無需輸入密碼,就像本地文件復制一樣簡單。
rcp命令有兩種格式。第一種格式用於文件到文件的拷貝;第二種格式用於把文件或目錄拷貝到另一個目錄中。
配置rcp命令的使用環境:
1)如果系統中有 /etc/hosts 文件,系統管理員應確保該文件內包含要與之進行通信的遠程主機的項:
[root@localhost etc]# cat hosts //hosts文件的內容 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 [root@localhost etc]#
介紹/etc/hosts:
hosts文件是Linux主機名和ip配置文件,The static table lookup for host name(主機名查詢靜態表)。可以介紹本機或其他主機的主機名和IP地址。不同的Linux版本,其配置文件名可能不一樣,比如Debian的對應文件時/etc/hostname。
hosts配置文件對於在網絡中作為服務器的Linux主機擁有極大作用。它記載了本地主機或遠程主機的IP地址、域名和主機名的對應關系。因此我們可以通過輸入域名或主機名訪問IP,而不必輸入難記的數字IP地址。而主機名多用來區分在同一局域網下的不同主機。
host文件每一行的意思是:第一部分:網絡IP地址;第二部分:主機名或域名;第三部分:主機名的別名。當然每行也可以是兩部分,即主機IP地址和主機名。
主機名(hostname)和域名(domain)的區別:
主機名通常在局域網內使用,通過hosts文件,主機名就被解析到對應IP;
域名通常在INTERNET上使用,但如果本機不想使用internet上的域名解析,這時就可以更改hosts文件,加入自己的域名解析。
hosts文件可以解決的問題:
1.遠程登錄linux主機過慢:有時候客戶端想要遠程登錄一台linux主機,但每次登錄輸入密碼后都會等很長一段時間才會進入,這是因為linux主機在返回信息時需要解析IP,如果在linux主機的hosts文件事先就加入客戶端的IP地址,這時再從客戶端遠程登錄linux就會很快。
2.雙機互聯:當兩台主機只是雙機互連時,這時兩台主機都需要設置自己的ip,同時在對方的hosts文件里加入自己的ip和主機名。
主機名修改工具hostname的使用:
hostname命令用於顯示和設置系統的主機名稱。環境變量HOSTNAME也保存了當前的主機名。在使用hostname命令設置主機名后,系統並不會永久保存新的主機名,重新啟動機器之后還是原來的主機名。如果需要永久修改主機名,需要同時修改/etc/hosts和/etc/sysconfig/network的相關內容。
hostname---show or set the system's host name [root@localhost etc]# hostname //顯示主機名 localhost.localdomain [root@localhost etc]# hostname -a //顯示所有hosts配置信息 localhost.localdomain localhost4 localhost4.localdomain4 localhost.localdomain localhost6 localhost6.localdomain6 [root@localhost etc]# hostname -i //顯示已配置的IP地址 ::1 127.0.0.1 [root@localhost etc]# hostname sunmeng [root@localhost etc]# hostname sunmeng
2)修改兩台Linux主機的hosts文件:(host文件里的內容就相當於一個用戶DNS服務器,將主機名解釋為對應IP地址)
在這里我實現的是CentOS7.0與Unbuntu14.04之間的連接,它們的信息如下:
Unbuntu: IP地址:192.168.0.11 //用ifconfig命令獲得 主機名:Unbuntu //用hostname主機名修改工具獲得 CentOS: IP地址:192.168.0.15 主機名:CentOS
在兩者的hosts文件中加上對方的信息:
Unbuntu: root@SJM:/home/sunjimeng#cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 SJM 192.168.0.15 CentOS
#The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters CentOS: [root@localhost ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.0.11 Unbuntu
3)在root用戶的根目錄下創建.rhosts文件,加入遠端主機的主機名和要連接的用戶名:
.rhosts 文件是 /etc/hosts.equiv 文件的用戶等效文件。此文件包含主機-用戶組合列表,而不包含一般意義的主機。如果此文件中列出了主機-用戶組合,則指定用戶將被授予從指定主機登錄而不必提供口令的權限。
在.rhosts文件和hosts.equiv文件中,真正起作用的是后者。但在不同系統中,都寫上終歸不會錯。
Unbuntu: //配置允許CentOS上的用戶root和sunmeng免密碼登錄 root@Unbuntu:/home/sunjimeng# cat /etc/hosts.equiv # /etc/hosts.equiv: list of hosts and users that are granted "trusted" r # command access to your system CentOS sunmeng CentOS root root@Unbuntu:/home/sunjimeng# cat /root/.rhosts CentOS sunmeng CentOS root CentOS: //配置允許Unbuntu上的用戶root和sunjimeng免密碼登錄 [root@CentOS sunmeng]# cat /root/.rhosts Unbuntu sunjimeng Unbuntu root [root@CentOS sunmeng]# cat /etc/hosts.equiv Unbuntu sunjimeng Unbuntu root //需要注意的一點是:從CentOS主機上登錄Unbuntu,不能直接用Unbuntu的root登錄。而從Unbuntu上均可。(Unbuntu不允許遠端用戶直接獲得root權限,應該先登錄用戶,再用su命令)
而且.rhosts文件得權限最好進行如下配置:(.rhosts 文件存在嚴重的安全問題。任何用戶都可以創建 .rhosts 文件,從而可以在系統管理員不知情時對其選擇的任何人授予訪問權限。)
root@Unbuntu:/home/sunjimeng# ls -l /root/.rhosts -rw-r--r-- 1 root root 37 6月 24 12:48 /root/.rhosts root@Unbuntu:/home/sunjimeng# chmod 600 $HOME/.rhosts root@Unbuntu:/home/sunjimeng# ls -l /root/.rhosts -rw------- 1 root root 37 6月 24 12:48 /root/.rhosts
4)啟動rsh服務(rcp命令的實現實際上是系統調用rsh服務實現的)
CentOS:
1.檢查系統是否安裝rsh和rsh-server軟件包:
CentOS //已經安裝好,如果沒有安裝,使用yum install rsh和yum install rsh-server安裝 [root@localhost sunmeng]# rpm -aq |grep "rsh" rsh-0.17-76.el7_1.1.x86_64 rsh-server-0.17-76.el7_1.1.x86_64
2.檢查系統是否安裝xinetd守護進程:
[root@localhost xinetd.d]# rpm -qa |grep xinetd xinetd-2.3.15-12.el7.x86_64
xinetd的配置文件:xinetd.conf:
[root@localhost etc]# cat xinetd.conf # # This is the master xinetd configuration file. Settings in the # default section will be inherited by all service configurations # unless explicitly overridden in the service configuration. See # xinetd.conf in the man pages for a more detailed explanation of # these attributes. defaults { # The next two items are intended to be a quick access place to # temporarily enable or disable services. # # enabled = # disabled = # Define general logging characteristics. log_type = SYSLOG daemon info log_on_failure = HOST log_on_success = PID HOST DURATION EXIT # Define access restriction defaults # # no_access = # only_from = # max_load = 0 cps = 50 10 instances = 50 per_source = 10 # Address and networking defaults # # bind = # mdns = yes v6only = no # setup environmental attributes # # passenv = groups = yes umask = 002 # Generally, banners are not used. This sets up their global defaults # # banner = # banner_fail = # banner_success = } includedir /etc/xinetd.d //這里說明xinetd啟動時將/etc/xinetd.d文件夾下的文件包含進來
3.在/etc/xinetd.d目錄下查找是否有rsh和rlogin,如果沒有按照下面文件得內容創建一份,注意紅色的部分為no。
[root@localhost xinetd.d]# cat rlogin #default:on # description: rlogind is the server for the rlogin(1) program. The server # provides a remote login facility with authentication based on # privileged port numbers from trusted hosts. service login {
disable = no socket_type = stream wait = no user = root log_on_success += USERID log_on_failure += USERID server = /usr/sbin/in.rlogind
} [root@localhost xinetd.d]# cat rsh #default:on # description: The rshd server is the server for the rcmd(3) routine and, # consequently, for the rsh(1) program. The server provides # remote execution facilities with authentication based on # privileged port numbers from trusted hosts. service shell { disable = no socket_type = stream wait = no user = root log_on_success += USERID log_on_failure += USERID server = /usr/sbin/in.rshd }
然后最好用service xinetd restart命令重啟一下守護進程。
4.編輯/etc/securetty,確保存在rexec、rsh、rlogin三行
[root@localhost etc]# cat /etc/securetty console vc/1 vc/2 vc/3 vc/4 vc/5 vc/6 vc/7 vc/8 vc/9 vc/10 vc/11 tty1 tty2 tty3 tty4 tty5 tty6 tty7 tty8 tty9 tty10 tty11 ttyS0 ttysclp0 sclp_line0 3270/tty1 hvc0 hvc1 hvc2 hvc3 hvc4 hvc5 hvc6 hvc7 hvsi0 hvsi1 hvsi2 xvc0 rexec //如果沒有自己添加 rsh rlogin
5.此時用setup命令查看系統服務,已經包含了rsh和rlogin,並且默認啟動:(之前是沒有的)

Ubuntu:
1.安裝rsh-client和rsh-server軟件包:
root@Unbuntu:/home/sunjimeng# apt-get install rsh //在Unbuntu的軟件包庫中沒有rsh軟件。 正在讀取軟件包列表... 完成 正在分析軟件包的依賴關系樹 正在讀取狀態信息... 完成 E: 未發現軟件包 rsh root@Unbuntu:/home/sunjimeng# apt-get install rsh-client //rsh-client相當於CentOS(Red Hat系列)的rsh 正在讀取軟件包列表... 完成 正在分析軟件包的依賴關系樹 正在讀取狀態信息... 完成 rsh-client 已經是最新的版本了。 升級了 0 個軟件包,新安裝了 0 個軟件包,要卸載 0 個軟件包,有 588 個軟件包未被升級。 root@Unbuntu:/home/sunjimeng# apt-get install rsh-server 正在讀取軟件包列表... 完成 正在分析軟件包的依賴關系樹 正在讀取狀態信息... 完成 rsh-server 已經是最新的版本了。 升級了 0 個軟件包,新安裝了 0 個軟件包,要卸載 0 個軟件包,有 588 個軟件包未被升級。
2.安裝守護進程xinetd:
root@Unbuntu:/home/sunjimeng# apt-get install xinetd 正在讀取軟件包列表... 完成 正在分析軟件包的依賴關系樹 正在讀取狀態信息... 完成 xinetd 已經是最新的版本了。 升級了 0 個軟件包,新安裝了 0 個軟件包,要卸載 0 個軟件包,有 588 個軟件包未被升級。
Unbuntu的xinetd守護進程的配置文件xinetd.conf:
root@Unbuntu:/etc# cat xinetd.conf # Simple configuration file for xinetd # # Some defaults, and include /etc/xinetd.d/ defaults { # Please note that you need a log_type line to be able to use log_on_success # and log_on_failure. The default is the following : # log_type = SYSLOG daemon info } includedir /etc/xinetd.d //也要求包含/etc/xinetd.d目錄下的文件
3.在/etc/init.d文件夾下新建rsh、rlogin和rexec文件:(如果之前沒配置)
root@Unbuntu:/etc/xinetd.d# cat rsh # default: on # descrīption: The rshd server is the server for the rcmd(3) routine and, # consequently, for the rsh(1) program. The server provides # remote execution facilities with authentication based on # privileged port numbers from trusted hosts. service shell { disable = no socket_type = stream wait = no user = root log_on_success += USERID log_on_failure += USERID server = /usr/sbin/in.rshd } root@Unbuntu:/etc/xinetd.d# cat rlogin ##################################################### #default:on # descrīption: rlogind is the server for the rlogin(1) program. The server # provides a remote login facility with authentication based on # privileged port numbers from trusted hosts. service login { disable = no socket_type = stream wait = no user = root log_on_success += USERID log_on_failure += USERID server = /usr/sbin/in.rlogind } root@Unbuntu:/etc/xinetd.d# cat rexec #default:off # descrīption: Rexecd is the server for the rexec(3) routine. The server # provides remote execution facilities with authentication based # on user names and passwords. service exec { disable = no socket_type = stream wait = no user = root log_on_success += USERID log_on_failure += USERID server = /usr/sbin/in.rexecd }
4.重啟xinetd服務:
root@Unbuntu:/etc# /etc/init.d/xinetd restart * Stopping internet superserver xinetd [ OK ] * Starting internet superserver xinetd [ OK ]
5)rsh服務的簡單測試:(實現用CentOS登錄Unbuntu列出Unbuntu的home目錄和Unbuntu登錄CentOS列出CentOS的home目錄)
CentOS的home目錄: [root@localhost home]# ll total 4 drwx------. 14 sunmeng sunmeng 4096 Jun 28 01:47 sunmeng Unbuntu的home目錄: sunjimeng@Unbuntu:/home$ ll 總用量 12 drwxr-xr-x 3 root root 4096 6月 24 13:36 ./ drwxr-xr-x 23 root root 4096 6月 24 10:37 ../ drwxr-xr-x 20 sunjimeng sunjimeng 4096 6月 28 14:54 sunjimeng/
CentOS登錄Unbuntu:
[root@localhost home]# rsh Unbuntu //等價於rsh 192.168.0.11 Password: Login incorrect Unbuntu login: sunjimeng Password: Last login: Tue Jun 28 18:09:24 CST 2016 from CentOS on pts/4 Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-32-generic x86_64) * Documentation: https://help.ubuntu.com/ sunjimeng@Unbuntu:~$ ls -l /home 總用量 4 drwxr-xr-x 20 sunjimeng sunjimeng 4096 6月 28 14:54 sunjimeng
Unbuntu登錄CentOS: sunjimeng@Unbuntu:/home$ rsh CentOS //等價於rsh 192.168.0.15 Password: Password: Login incorrect CentOS login: sunmeng Password: Last failed login: Tue Jun 28 03:26:40 PDT 2016 from Unbuntu on pts/2 There was 1 failed login attempt since the last successful login. Last login: Tue Jun 28 01:27:45 from ::ffff:192.168.0.18 [sunmeng@CentOS ~]$ ls /home sunmeng
遠程登錄時可能會出現下面的問題:
sunjimeng@Unbuntu:~$ rsh CentOS
CentOS: No route to host
有兩種原因:1.遠程機沒有安裝並啟動rsh-server服務;2.防火牆阻止了本地機對遠程機rsh服務端口(無論是rsh還是rlogin都是513端口) 。
對於第二個問題:你可以選擇關閉遠程機防火牆,也可以讓防火牆開啟tcp連接的513端口,對外部所有IP開放訪問。(同時,你還可以修改rsh和rlogin的端口,不用513號端口)
在CentOS中使用iptables命令操作防火牆,也可以用圖形界面,類似telnet命令中開放23號端口的那樣。

在Unbuntu中使用了iptables的升級命令ufw命令操作防火牆。
root@Unbuntu:/home/sunjimeng# ufw status //顯示防火牆狀態 狀態:不活動 root@Unbuntu:/home/sunjimeng# ufw allow 513 //開放513號端口 防火牆規則已更新 規則已更新(v6) root@Unbuntu:/home/sunjimeng# ufw disable //關閉防火牆
(3)選項參數:
1) -r 遞歸地把源目錄中的所有內容拷貝到目的目錄中。要使用這個選項,目的必須是一個目錄。
2) -p 試圖保留源文件的修改時間和模式,忽略umask。
3) -x 為傳送的所有數據打開DES加密。
4) -D 指定遠程服務器的端口號。
5) -r 遞歸處理,將指定目錄下的文件與子目錄一並處理
(4)實例:
1)root@Unbuntu:/home/sunjimeng# rsh -l root CentOS rsh指定用戶名登錄
root@Unbuntu:/home/sunjimeng# rsh -l root CentOS Password: Last failed login: Tue Jun 28 03:54:33 PDT 2016 from Unbuntu on pts/2 There were 2 failed login attempts since the last successful login. Last login: Tue Jun 28 03:53:19 from Unbuntu [root@CentOS ~]#
在集群的所有節點都已經配置好了.rhosts和/etc/hosts的信息,並且rsh服務已經打開,防火牆已經關閉。rsh hostname已經通過測試,但是使用rsh hostname rcmd 來執行命令,未能通過,出現no route to host錯誤:
root@Unbuntu:/etc# rsh -l root CentOS ls -l /home/sunmeng //Unbuntu登錄CentOS
CentOS: No route to host
[root@localhost sunmeng]# rsh -l sunjimen Unbuntu /bin/ls -l /home //CentOS登錄Unbuntu poll: protocol failure in circuit setup
解決方法:
1.修改SELinux的配置文件(目的是關閉SELinux):
[root@localhost selinux]# cd /etc/selinux [root@localhost selinux]# ll total 12 -rw-r--r--. 1 root root 547 Jun 21 11:15 config -rw-r--r--. 1 root root 2321 Jun 9 2014 semanage.conf drwxr-xr-x. 6 root root 4096 Jun 23 01:50 targeted [root@localhost selinux]# vi config [root@localhost selinux]# cat config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. #SELINUX=enforcing //oringin version SELINUX=disabled //after modifying # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
修改之后並無明顯作用,但最好關閉。
2.讓防火牆開放端口513,514和1021-1023:(直接把兩台主機的防火牆都關了也行)
CentOS:

Unbuntu:ufw allow 513 514 1021 1022 1023
原因:(http://goodluck1982.blog.sohu.com/134666734.html)
直接使用 rsh <host> 命令方式和使用 rsh <host> <cmd> 命令方式,其實本質上是不一樣的:前者實質上調用的是 rlogin 程序,而后者才是真正意義上的 remote shell。所以,前者對應的是 rlogin 服務的端口,為 513;后者對應的才是 remote shell 服務的端口 514。
而使用 rsh <host> <cmd> 命令方式時,具體過程還是有些特殊的:本地機先鏈接服務端的 514 端口,然后服務端還要以約定好的端口(1021~1023)與客戶端相連,所以要順利執行該命令的話,即要求服務端允許 514 端口鏈接,還要求本地機允許1021~1023端口的鏈接,這樣就必須正確配置防火牆。
如果沒有在本地機允許1021~1023端口,則會出現如下錯誤: poll: protocol failure in circuit setup。
2)以rsh [host] [command]的方式登錄遠程主機並執行命令:
CentOS登錄Unbuntu並執行命令: [root@localhost sunmeng]# rsh Unbuntu ls -l /home/sunjimeng total 48 -rw-r--r-- 1 sunjimeng sunjimeng 8980 Jun 24 10:26 examples.desktop drwxr-xr-x 2 root root 4096 Jun 24 12:12 vm drwxr-xr-x 2 sunjimeng sunjimeng 4096 Jun 28 21:12 下載 drwxr-xr-x 2 sunjimeng sunjimeng 4096 Jun 24 10:43 公共的 drwxr-xr-x 2 sunjimeng sunjimeng 4096 Jun 24 10:43 圖片 drwxr-xr-x 2 sunjimeng sunjimeng 4096 Jun 24 10:43 文檔 drwxr-xr-x 4 sunjimeng sunjimeng 4096 Jun 28 14:42 桌面 drwxr-xr-x 2 sunjimeng sunjimeng 4096 Jun 24 10:43 模板 drwxr-xr-x 2 sunjimeng sunjimeng 4096 Jun 24 10:43 視頻 drwxr-xr-x 2 sunjimeng sunjimeng 4096 Jun 24 10:43 音樂 Unbuntu登錄CentOS並執行命令: root@Unbuntu:/home/sunjimeng# rsh CentOS ls -l /home/sunmeng total 4 drwxr-xr-x. 2 sunmeng sunmeng 6 Jun 23 02:29 Desktop drwxr-xr-x. 2 sunmeng sunmeng 4096 Jun 27 20:18 Documents drwxr-xr-x. 2 sunmeng sunmeng 6 Jun 21 03:31 Downloads drwxr-xr-x. 2 sunmeng sunmeng 6 Jun 21 03:31 Music drwxr-xr-x. 2 sunmeng sunmeng 6 Jun 21 03:31 Pictures drwxr-xr-x. 2 sunmeng sunmeng 6 Jun 21 03:31 Public drwxr-xr-x. 2 sunmeng sunmeng 6 Jun 21 03:31 Templates -rw-rw-r-- 1 sunmeng sunmeng 0 Jun 28 05:45 text.c drwxr-xr-x. 2 sunmeng sunmeng 6 Jun 21 03:31 Videos drwxr-xr-x 7 sunmeng sunmeng 155 Jun 28 04:34 桌面
3)將文件拷貝到遠端機,或者把遠端機上的文件拷貝到本地
將Unbuntu的 /home/sunjimeng/下載 目錄下的text文件拷貝到CentOS的 /home/sunmeng文件夾下: //1.拷貝前的文件信息: [root@localhost sunmeng]# ll 總用量 4 drwxr-xr-x. 2 sunmeng sunmeng 6 6月 23 02:29 Desktop drwxr-xr-x. 2 sunmeng sunmeng 4096 6月 27 20:18 Documents drwxr-xr-x. 2 sunmeng sunmeng 6 6月 21 03:31 Downloads drwxr-xr-x. 2 sunmeng sunmeng 6 6月 21 03:31 Music drwxr-xr-x. 2 sunmeng sunmeng 6 6月 21 03:31 Pictures drwxr-xr-x. 2 sunmeng sunmeng 6 6月 21 03:31 Public drwxr-xr-x. 2 sunmeng sunmeng 6 6月 21 03:31 Templates -rw-rw-r-- 1 sunmeng sunmeng 0 6月 28 05:45 text.c drwxr-xr-x. 2 sunmeng sunmeng 6 6月 21 03:31 Videos drwxr-xr-x 7 sunmeng sunmeng 155 6月 28 04:34 桌面 //2.在Unbuntu終端執行: root@Unbuntu:/home/sunjimeng/下載# vi text root@Unbuntu:/home/sunjimeng/下載# cat text This is from Unbuntu! root@Unbuntu:/home/sunjimeng/下載# rcp text CentOS:/home/sunmeng //3.拷貝后的文件信息 [root@localhost sunmeng]# ll 總用量 8 drwxr-xr-x. 2 sunmeng sunmeng 6 6月 23 02:29 Desktop drwxr-xr-x. 2 sunmeng sunmeng 4096 6月 27 20:18 Documents drwxr-xr-x. 2 sunmeng sunmeng 6 6月 21 03:31 Downloads drwxr-xr-x. 2 sunmeng sunmeng 6 6月 21 03:31 Music drwxr-xr-x. 2 sunmeng sunmeng 6 6月 21 03:31 Pictures drwxr-xr-x. 2 sunmeng sunmeng 6 6月 21 03:31 Public drwxr-xr-x. 2 sunmeng sunmeng 6 6月 21 03:31 Templates -rw-r--r-- 1 root root 23 6月 28 18:33 text -rw-rw-r-- 1 sunmeng sunmeng 0 6月 28 05:45 text.c drwxr-xr-x. 2 sunmeng sunmeng 6 6月 21 03:31 Videos drwxr-xr-x 7 sunmeng sunmeng 155 6月 28 04:34 桌面 [root@localhost sunmeng]# cat text This is from Unbuntu!
--------------------------------------------------------------------------------------------------------------------------------- 將CentOS的 /home/sunmeng 下的text.c拷貝到Unbuntu的 /home/sunjimeng/下載: //1.拷貝文件之前: root@Unbuntu:/home/sunjimeng/下載# ll 總用量 12 drwxr-xr-x 2 sunjimeng sunjimeng 4096 6月 29 09:32 ./ drwxr-xr-x 20 sunjimeng sunjimeng 4096 6月 29 08:27 ../ -rw-r--r-- 1 root root 23 6月 29 09:32 text //2.在CentOS主機上執行下面的命令: [root@localhost sunmeng]# vi text.c [root@localhost sunmeng]# cat text.c This is form CentOS! [root@localhost sunmeng]# rcp text.c Unbuntu:/home/sunjimeng/下載 //3.拷貝文件之后: root@Unbuntu:/home/sunjimeng/下載# ll 總用量 16 drwxr-xr-x 2 sunjimeng sunjimeng 4096 6月 29 09:42 ./ drwxr-xr-x 20 sunjimeng sunjimeng 4096 6月 29 08:27 ../ -rw-r--r-- 1 root root 23 6月 29 09:32 text -rw-r--r-- 1 root root 22 6月 29 09:42 text.c root@Unbuntu:/home/sunjimeng/下載# cat text.c This is form CentOS!
(5)其他:
在這個命令學習時遇到的問題:
1)要實現Unbuntu14.04虛機與win10物理機的數據傳輸,虛機需要安裝VMware Tools工具:
1.在VMware Workstations的虛擬機菜單下選擇安裝VMware Tools:

2.此時虛擬機將默認掛載虛擬CD/DVD驅動器,里面含有VMware Tools的安裝包,默認權限是只可讀。

3.把安裝包拷貝一份到用戶具有讀寫權限的目錄下,用tar命令解壓:
root@SJM:/home/sunjimeng/桌面# tar -ztvf VMwareTools-10.0.0-2977863.tar.gz root@SJM:/home/sunjimeng/桌面# ll 總用量 69864 drwxr-xr-x 3 sunjimeng sunjimeng 4096 6月 28 09:49 ./ drwxr-xr-x 19 sunjimeng sunjimeng 4096 6月 28 10:10 ../ -rw-rw-r-- 1 sunjimeng sunjimeng 71524872 8月 12 2015 VMwareTools-10.0.0-2977863.tar.gz drwxr-xr-x 9 root root 4096 8月 12 2015 vmware-tools-distrib/
4.然后進入解壓后自動生成的文件夾,執行安裝軟件的腳本:
root@SJM:/home/sunjimeng/桌面# cd vmware-tools-distrib root@SJM:/home/sunjimeng/桌面/vmware-tools-distrib# ll 總用量 524 drwxr-xr-x 9 root root 4096 8月 12 2015 ./ drwxr-xr-x 3 sunjimeng sunjimeng 4096 6月 28 09:49 ../ drwxr-xr-x 2 root root 4096 8月 12 2015 bin/ drwxr-xr-x 5 root root 4096 8月 12 2015 caf/ drwxr-xr-x 2 root root 4096 8月 12 2015 doc/ drwxr-xr-x 5 root root 4096 8月 12 2015 etc/ -rw-r--r-- 1 root root 279342 8月 12 2015 FILES -rw-r--r-- 1 root root 2538 8月 12 2015 INSTALL drwxr-xr-x 2 root root 4096 8月 12 2015 installer/ drwxr-xr-x 15 root root 4096 8月 12 2015 lib/ drwxr-xr-x 3 root root 4096 8月 12 2015 vgauth/ -rwxr-xr-x 1 root root 243 8月 12 2015 vmware-install.pl* -rwxr-xr-x 1 root root 205572 8月 12 2015 vmware-install.real.pl* root@SJM:/home/sunjimeng/桌面/vmware-tools-distrib# ./vmware-install.pl* //必須要帶./
接下來就是安裝過程。
5.檢查是否啟動虛擬機與物理機共享剪貼板:(安裝VMware Tools的主要目的)

如果此時共享剪貼板還不能用,就重啟一下虛擬機。
2)在首次登錄Unbuntu的終端時,su切換用戶的命令不能使用:
原因: Unbuntu剛安裝后,不能在terminal中運行su命令,因為root沒有默認密碼,需要手動設定。
以安裝unbuntu時輸入的用戶名登陸,該用戶在admin組中,有權限給root設定密碼。(默認打開終端就已登錄)
root@SJM:/# sudo password [root] sudo:password: command not found //注意是"passwd"而不是"password" root@SJM:/# sudo passwd [root] 輸入新的 UNIX 密碼: 重新輸入新的 UNIX 密碼: passwd:已成功更新密碼
3)Unbuntu默認不開啟xinetd守護進程:
apt-get install xinetd //安裝守護進程服務軟件 /etc/init.d/xinetd start //啟動xinetd服務
4)在Unbuntu中如何查看系統服務:
在Unbuntu中安裝一個工具:sysv-rc-conf:
root@SJM:/home/sunjimeng/下載# apt-get install sysv-rc-conf 正在讀取軟件包列表... 完成 正在分析軟件包的依賴關系樹 正在讀取狀態信息... 完成 sysv-rc-conf 已經是最新的版本了。 升級了 0 個軟件包,新安裝了 0 個軟件包,要卸載 0 個軟件包,有 588 個軟件包未被升級。
