who:显示当前真正登录系统中的用户(不会显示那些用su命令切换用户的登录者)
who am i: 显示当前登录时用的用户名,尽管切换了多个用户
whoami: 显示当前用户的用户名
rsync file1 file2 ... user @ host :
rsync not found
rsync: connection unexpectedly closed (0 bytes read so far)
rsync error: error in rsync protocol data stream (code 12) at io.c(165)
这个信息是说,在远端找不到 rsync 。如果远端安装了rsync , 但没在路径中 ,
用--rsync-path=path 来指定远端中它的位置。
想要完整地、递归地传输整个目录——包括符号链接、权限、模式、设备——那就用 -a 选项。
还有,如果你想复制到其他地方,而不是你的home目录,你可以在host后面加上具体地址
如果你不清楚传输过程中会发生什么,你可以使用 -nv 选项组合。-n 选项会让 rsync 进入“空跑”模式,即模拟复制而非真的复制。 -v 选项则是冗长模式,它会将涉及的文件和传输过程的细节显示出来:
rsync -nva dir host:destination_dir
默认情况下, rsync 复制文件或目录时是不关心目标目录的原本内容的。例如,如果你把一
个包含文件a和b的目录d复制到另一台机器,而该机器已有了一个目录d,并且其中包含文件c,
那么经 rsync 传输过后,目标目录就会包含有a、b、c三个文件。
所谓准确复制,就是将目标目录比源目录多出的内容清除掉,例如上例的c文件。要想实现
这种效果,你可以使用 --delete 选项:
rsync -a --delete dir host:destination_dir
警告---这样做是有点危险的,你需要检查一下会不会误删文件。记住,如果你不确定传输是否
能达到理想结果,可先以 -n 选项做一下测试,看看是否会删除文件。
排除文件与目录
rsync 有个很重要的功能,就是它可以排除某些文件与目录的传输。比如说,你想将一个本地目录src传输到host,但想排除其中叫.git的任何东西。那你可以这样做:
rsync -a --exclude=.git src host:
注意,这条命令会排除所有名为.git的文件与目录,因为这里 --exclude 获得的是模式,而非
一个绝对的文件名。要想排除一个特定的项目,那就以“ / ”开头来指定一个绝对路径,就像这样:
rsync -a --exclude=/src/.git src host:
注解 /src/.git 开头的 / 不是指你系统的home目录,而是指源目录所在的位置。
以下还有一些按模式进行排除的技巧。
--exclude 选项可以有多个。
常用的模式可保存在文本文件中(一行一个模式),并用 --exclude-from=file 。
只想排除名为item的目录,不想排除名为item的文件,可以斜杠结尾: --exclude=item/ 。
模式匹配是以一个完整的文件名为单位的,模式可包含通配符。例如,t*s能与this匹配,
但不与ethers匹配。
如果你发现你要排除的内容太多了,你也可以用 --include 来指定要包含的文件或目录。
合并、检查及冗长模式
为了提高效率, rsync 会先快速检查一下目标位置是否已包含源内容。这种快速检查只看文
件大小及最后修改时间。在你第一次将整个目录结构传输到远端时, rsync 发现远端并不存在任
何这些文件,于是它就整份传输过去。你可以用 rsync -n 来验证。
传输过一次之后,再用 rsync -v 做一次。你会发现这次的文件列表为空,那是因为目标位置
已有了源内容,并且修改时间也一致。
当源文件与目标文件不一致时, rsync 会对远端的文件进行覆写。那么,之前提到的快速检
查功能就可能不够用了,因为你可能还需要更准确地验证两边文件是否一样,以免 rsync 错误地
略过它们,又或者说你想要更多安全保障。这时,你可以求助于以下这些选项。
–checksum (缩写 -c ):通过计算文件的校验和(大部分情况下是唯一的)来检查一致性。
这会消耗更多的I/O和CPU资源,但如果你想准确地传输,又担心文件大小不足以判断一
致性,那么这个选项就是必须的。
–ignore-existing :不覆写已存在的文件。
–backup (缩写 -b ):不覆写已存在的文件,只在传输前给它们加上 ~ 后缀,为它们重命名。
–suffix=s :将 --backup 用的后缀 ~ 改为 s 。
–update (缩写 -u ):当目标文件的修改时间比源文件的更早时,才进行覆写。
在没有使用什么特别选项时, rsync 的运行会是悄无声息的,只在遇到错误时才会有输出。
你可以用 rsync -v (冗长模式)来显示传输过程的细节,甚至用 rsync -vv 来显示得更细。( v 越多
则越详细,但两个 v 通常已足够。)想在传输过后得到一些综合信息,可用 rsync --stats 。
压缩
很多人喜欢在用 -a 的时候加上 -z ,以在传输前先进行压缩:
rsync -az dir host:destination_dir
某些情况下,压缩是能加快传输速度的,例如说上行缓慢,或者说延迟很多,而你又要传输大量文件的情况时。然而,如果网络很快,那么压缩和解压的过程会占用较多CPU时间,此时反而不做压缩会传得更快些。
限制带宽
上传大量数据时,可能会堵塞上行线路。尽管这并不占用下行线路,但如果不限制上传速度,
其实也是会影响下行的。因为发出的TCP包(如HTTP请求)需要与你的文件传输争夺带宽。要
想避免这种情况,可用 --bwlimit 来给你的上行线路留点空间。例如,若要令其上行带宽的上限
为10 000Kbps,可这么做:
rsync --bwlimit=10000 -a dir host:destination_dir
1. 添加源地址 ,在/etc/apt/sources.list 里面 最后添加
deb http://downloads.sourceforge.net/project/Ubuntuzilla/mozilla/apt all main
2. 添加key
# apt-key adv --recv-keys --keyserver keyserver.ubuntu.com C1289A29
3. 更新
# apt-get update
4. 安装firefox
# apt-get install firefox-mozilla-build
提示错误
dpkg-divert: `diversion of /usr/bin/firefox to /usr/bin/firefox.ubuntu by firefox-mozilla-build' clashes with `diversion of /usr/bin/firefox to /usr/bin/firefox.real by iceweasel'
dpkg: error processing /var/cache/apt/archives/firefox-mozilla-build_15.0-0ubuntu1_amd64.deb (--unpack):
subprocess new pre-installation script returned error exit status 2
configured to not write apport reports
dpkg-divert: mismatch on divert-to
when removing `diversion of /usr/bin/firefox to /usr/bin/firefox.ubuntu by firefox-mozilla-build'
found `diversion of /usr/bin/firefox to /usr/bin/firefox.real by iceweasel'
dpkg: error while cleaning up:
subprocess new post-removal script returned error exit status 2
Errors were encountered while processing:
/var/cache/apt/archives/firefox-mozilla-build_15.0-0ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
原来是iceweasel和firefox15冲突了.新的不能覆盖掉,那就remove掉
# apt-get remove iceweasel
root@debian:/etc/apt# apt-get remove iceweasel
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
iceweasel
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/22.0 MB of archives.
After this operation, 4,092 kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ...
dpkg: warning: files list file for package `firefox-mozilla-build' missing, assuming package has no files currently installed.
(Reading database ... 126622 files and directories currently installed.)
Preparing to replace firefox-mozilla-build 15.0-0ubuntu1 (using .../firefox-mozilla-build_15.0-0ubuntu1_amd64.deb) ...
Unpacking replacement firefox-mozilla-build ...
Processing triggers for gnome-menus ...
Processing triggers for desktop-file-utils ...
(Reading database ... 126696 files and directories currently installed.)
Removing iceweasel ...
Removing 'diversion of /usr/bin/firefox to /usr/bin/firefox.real by iceweasel'
Processing triggers for menu ...
Processing triggers for hicolor-icon-theme ...
Processing triggers for man-db ...
Processing triggers for gnome-menus ...
Processing triggers for desktop-file-utils ...
Setting up firefox-mozilla-build (15.0-0ubuntu1) ...
然后打开你的电脑左上角的Application-->Internet,里面已经有firefox了
或者在终端运行命令: firefox就可以打开firefox浏览器了