我们经常要对服务器上面的文件进行上传或下载,有什么比较简单的方法可以实现吗?我们可以利用rz和sz可以实现上面的目的。rz和sz是Linux/Unix同Windows进行ZModem文件传输的命令行工具。
rz命令—上传本地文件到服务器端
即是接收文件(SecureCRT接收),SecureCRT就会弹出文件选择对话框,选好文件之后关闭对话框,文件就会上传到当前目录;
使用方法为:[root@localhost yum.repos.d]# rz 就可以。
sz命令—从服务器端下载文件到本地
sz file1 file2就是发文件到windows上(保存的目录是可以配置);
使用方法为:[[root@localhost yum.repos.d]# sz 就可以。
要是我们在命令行下使用rz或sz提示命令不对,是因为你的linux/unix服务器上面没有安装lrzsz包。
安装lrzsz包的方法如下:
[root@localhost yum.repos.d]# yum -y install lrzsz
Loading “installonlyn” plugin
Loading “rhnplugin” plugin
Loading “security” plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
–> Populating transaction set with selected packages. Please wait.
—> Package lrzsz.i386 0:0.12.20-22.1 set to be updated
–> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
lrzsz i386 0.12.20-22.1 base 81 k
Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 81 k
Downloading Packages:
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: lrzsz ######################### [1/1]
Installed: lrzsz.i386 0:0.12.20-22.1
Complete!
至此安装完成,然后直接在命令行下就可以使用”rz”或”sz”了。
安装lrzsz包,即执行命令”yum -y install lrzsz” 之前,要先把yum 的配置文件配置好,否则就会提示安装失败;
在RHEL5上面,rhel5系统安装的时候其实已经有yum了,只是因为如果用官方的网站更新的话除非你是用钱买的rhel5.否则它会提示注册之类的。所以只要把 yum的更新地址改成开源的就行了。而限定yum更新地址的文件在/etc/yum.repos.d/里。先把它们改成备份文件,即在后面加.bak。
[root@killgoogle ~]# mv /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/rhel-debuginfo.repo.bak
[root@killgoogle ~]# mv /etc/yum.repos.d/rpmforge.repo.rpmnew /etc/yum.repos.d/rpmforge.repo.rpmnew.bak
建立新的配置文件:
[root@killgoogle ~]# cd /etc/yum.repos.d
[root@killgoogle ~]# touch rhel-debuginfo.repo
[root@killgoogle ~]# touch mirrors-rpmforge
[root@killgoogle ~]# touch rpmforge.repo
往新的配置文件写东西:
[root@killgoogle ~]#vi rhel-debuginfo.repo
[base]
name=CentOS-5 – Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever5&arch=$basearch&
repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://ftp.sjtu.edu.cn/centos/5/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#released updates
[update]
name=CentOS-5 – Updates
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updates
baseurl=http://ftp.sjtu.edu.cn/centos/5/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#packages used/produced in the build but not released
[addons]
name=CentOS-5 – Addons
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=addons
baseurl=http://ftp.sjtu.edu.cn/centos/5/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#additional packages that may be useful
[extras]
name=CentOS-5 – Extras
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=extras
baseurl=http://ftp.sjtu.edu.cn/centos/5/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5 – Plus
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=centosplus
baseurl=http://ftp.sjtu.edu.cn/centos/5/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#contrib – packages by Centos Users
[contrib]
name=CentOS-5 – Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=contrib
baseurl=http://ftp.sjtu.edu.cn/centos/5/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
# vi dag.repo
[dag]
name=Dag RPM Repository for RHEL5
baseurl=http://ftp.riken.jp/Linux/dag/redhat/el5/en/$basearch/dag/
enabled=1
gpgcheck=1
gpgkey=http://ftp.riken.jp/Linux/dag/packages/RPM-GPG-KEY.dag.txt
修改第二个配置文件:
[root@killgoogle ~]vi mirrors-rpmforge
http://apt.sw.be/redhat/el5/en/$ARCH/dag
http://archive.cs.uu.nl/mirror/dag.wieers/redhat/el5/en/$ARCH/dag
http://ftp2.lcpe.uni-sofia.bg/freshrpms/pub/dag/redhat/el5/en/$ARCH/dag
#http://ftp.heanet.ie/pub/freshrpms/pub/dag/redhat/el5/en/$ARCH/dag
http://ftp-stud.fht-esslingen.de/dag/redhat/el5/en/$ARCH/dag
http://mirror.cpsc.ucalgary.ca/mirror/dag/redhat/el5/en/$ARCH/dag
http://mirrors.ircam.fr/pub/dag/redhat/el5/en/$ARCH/dag
http://rh-mirror.linux.iastate.edu/pub/dag/redhat/el5/en/$ARCH/dag
http://rpmfind.net/linux/dag/redhat/el5/en/$ARCH/dag
http://wftp.tu-chemnitz.de/pub/linux/dag/redhat/el5/en/$ARCH/dag
http://www.mirrorservice.org/sites/apt.sw.be/redhat/el5/en/$ARCH/dag
修改第三个配置文件:
[root@killgoogle ~]# vi rpmforge.repo
# Name: RPMforge RPM Repository for Red Hat Enterprise 5 – dag
# URL: http://rpmforge.net/
[rpmforge]
name = Red Hat Enterprise $releasever – RPMforge.net – dag
#baseurl = http://apt.sw.be/redhat/el5/en/$basearch/dag
mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1
=====================================
补充:
RHEL5 配置YUM源
cd /etc/yum.repos.d/
cp rhel-debuginfo.repo rhel-debuginfo.repo.bak
先删除rhel-debuginfo.repo文件中所有内容,然后添加以下内容:
[base]
name=CentOS-5 – Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever5&arch=$basearch&
repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://ftp.sjtu.edu.cn/centos/5/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#released updates
[update]
name=CentOS-5 – Updates
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updates
baseurl=http://ftp.sjtu.edu.cn/centos/5/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#packages used/produced in the build but not released
[addons]
name=CentOS-5 – Addons
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=addons
baseurl=http://ftp.sjtu.edu.cn/centos/5/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#additional packages that may be useful
[extras]
name=CentOS-5 – Extras
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=extras
baseurl=http://ftp.sjtu.edu.cn/centos/5/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5 – Plus
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=centosplus
baseurl=http://ftp.sjtu.edu.cn/centos/5/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#contrib – packages by Centos Users
[contrib]
name=CentOS-5 – Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=contrib
baseurl=http://ftp.sjtu.edu.cn/centos/5/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
# vi dag.repo
[dag]
name=Dag RPM Repository for RHEL5
baseurl=http://ftp.riken.jp/Linux/dag/redhat/el5/en/$basearch/dag/
enabled=1
gpgcheck=1
gpgkey=http://ftp.riken.jp/Linux/dag/packages/RPM-GPG-KEY.dag.txt
然后导入key
rpm –import http://ftp.sjtu.edu.cn/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
更新:
yum update
文档资料参考:
http://www.blogjava.net/Skynet/archive/2009/04/29/268105.html
http://bocai2015.javaeye.com/blog/649577
本文为【爱上梁坤,爱上你】版权所有,欢迎转载。本站所有文章,未经说明,均为原创文章,转载敬请保留出处非常感谢。 本文链接:”http://www.liangkun.net/archives/232.html“
如果你觉得这篇文章对你有用,而且你又有自己的网站或者博客,请不要吝啬把本站加到你的友情链接,已经加入友情链接的朋友,请在本站留言说明,我也会在我的网站加入你的友情链接。
随机推荐文章
- « 上一篇:linux的chmod与chown命令使用及区别
- vim和vi的区别:下一篇 »

发表于 2010年08月23日 4:20 下午
朋友推荐,来看看。真的很不错。
[回复]
zhang 回复:
八月 24th, 2010 at 8:28 下午
@物价机票查询, 多谢,没事经常过来看看,有什么不好地方多提建议,哈
[回复]
发表于 2010年08月16日 3:06 下午
嘿嘿,喜欢你的博客哦!!!
[回复]
zhang 回复:
八月 21st, 2010 at 4:46 下午
多谢~
[回复]
发表于 2010年08月15日 10:35 下午
在好姐妹的推荐下!使用了产品!效果不错!
[回复]
发表于 2010年08月11日 5:35 下午
写的很好啊!!
[回复]
发表于 2010年08月10日 2:24 上午
赚钱的好技术,你需要吗?
[回复]
发表于 2010年08月9日 4:30 上午
有些时日没有过来看看了.
[回复]
发表于 2010年08月7日 9:59 下午
鲜花送人,余香满手,
博主好文,感谢分享,
本人路过,顺致安好!
[回复]
发表于 2010年08月5日 12:55 下午
博客写的不错!!
咱的小站:http://www.webshop1688.com
[回复]
发表于 2010年08月4日 3:03 上午
上海生活论坛http://www.shsh114.com 谢谢博主分享!
[回复]