前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >linux linux服务器间文件互传及共享办法

linux linux服务器间文件互传及共享办法

作者头像
葫芦
发布2019-05-09 11:44:58
2.5K0
发布2019-05-09 11:44:58
举报
文章被收录于专栏:葫芦
linux服务器间文件互传及共享办法,本次总结了5种办法包括(ftp、wget、samba、nfs、scp)以供各种不同情况下使用。 1号linux:ipaddr=10.10.10.1 2号linux:ipaddr=192.168.0.1

一、ftp

2号linux de>ftp 10.10.10.1 根据提示输入用户名密码 get 单个文件 mget 多个文件 ls 查看远端主机目录 !ls 查看本地所在目录,ftp文件下载文件后会下载到本地de> 1号linux 搭好vsftp配置可参考本站文章 VSFTP给单用户绑定多个目录内有如何搭建vsftp的配置。

二、wget

本例演示一次手动网站备份操作。 1号linux de>tar -jcvp -f ./wzwpbak.tar.bz2 ./wordpress/ /usr/local/mysql/var/wangzi/ find /usr/local/mysql/var/wangzi/ ./wordpress |wc -l 6208 tar tjf ./wzwpbak.tar.bz2 | wc -l 6208de> 对比实际文件数与打包后文件数验证完整性。 tar 所用到的参数 -f, --file [HOSTNAME:] use archive file or device F (default "-", meaning stdin/stdout) -j, --bzip2 filter archive through bzip2, use to decompress .bz2 files -t, --list list the contents of an archive -c, --create create a new archive -v, --verbose verbosely list files processed -p, --preserve-permissions extract all protection information 2号linux 下载 de>wget ftp://10.10.10.1/wordpress/wzwpbak.tar.bz2 --ftp-user=username --ftp-password=password tar tjf ./wzwpbak.tar.bz2 | wc -l 6208de>

三、samba

用samba通过mount挂载的方式实现两linux主机传输文件。 1号linux 搭建samba服务--如何搭建linux samba服务请参考本站文章。 2号linux de>mount -t cifs //10.10.10.1/project /wzmount -o username=username Password: [root@localhost /]# df 文件系统 1K-块 已用 可用 已用% 挂载点 /dev/sda2 99190032 4135624 89934416 5% / /dev/sda1 99098 12238 81743 14% /boot tmpfs 8196244 0 8196244 0% /dev/shm /dev/mapper/wangzivg-wangzilv 576279112 5828764 541177056 2% /opt //10.10.10.1/project 135960760 101810968 27243376 79% /wzmount de> 所用参数 mount -t type device dir This tells the kernel to attach the file system found on device (which is of type type) at the directory dir. The previous contents (if any) and owner and mode of dir become invisible, and as long as this file system remains mounted, the pathname dir refers to the root of the file system on device. NAME mount.cifs - mount using the Common Internet File System (CIFS) SYNOPSIS mount.cifs {service} {mount-point} [-o options] DESCRIPTION This tool is part of the samba(7) suite. mount.cifs mounts a Linux CIFS filesystem. It is usually invoked indirectly by the mount(8) command when using the "-t cifs" option. This command only works in Linux, and the kernel must support the cifs filesystem. The CIFS protocol is the successor to the SMB protocol and is supported by most Windows servers and many other commercial servers and Network Attached Storage appliances as well as by the popular Open Source server Samba. The mount.cifs utility attaches the UNC name (exported network resource) to the local directory mount-point. It is possible to set the mode for mount.cifs to setuid root to allow non-root users to mount shares to directories for which they have write permission. Options to mount.cifs are specified as a comma-separated list of key=value pairs. It is possible to send options other than those listed here, assuming that the cifs filesystem kernel module (cifs.ko) supports them. Unrecognized cifs mount options passed to the cifs vfs kernel code will be logged to the kernel log. mount.cifs causes the cifs vfs to launch a thread named cifsd. After mounting it keeps running until the mounted resource is unmounted (usually via the umount utility).

四、nfs

用nfs 通过mount挂载的方式实现两Linux间主机传输文件。 1号linux。 de>#cat /etc/exports /home/jishu 192.168.0.0/24(rw,no_root_squash) #service nfs startde> 2号Linux。 de>[root@localhost /]# showmount -e 10.10.10.1 Export list for IP: /home/jishu 192.168.0.0/24 /home/zhangjian 192.168.0.0/24 /home/wangzi 192.168.0.0/24 /tmp 192.168.0.0/24 [root@localhost /]# mount -t nfs 10.10.10.1:/home/jishu /wzmount/ [root@localhost /]# df 文件系统 1K-块 已用 可用 已用% 挂载点 /dev/sda2 99190032 4135664 89934376 5% / /dev/sda1 99098 12238 81743 14% /boot tmpfs 8196244 0 8196244 0% /dev/shm /dev/mapper/wangzivg-wangzilv 576279112 5828764 541177056 2% /opt 10.10.10.1:/home/jishu 135961088 101811712 27243008 79% /wzmountde>

五、scp

2号Linux 从远端到本地。 de>scp root@10.10.10.1:/root/wz /root/lz de> #从1号机拷贝wz文件到本机root目录并重命名为lz de>scp -P 60021 -r 10.10.10.1:/var/www/wordpress ./wzde> #执行完成后./wz文件夹下会出现/wordpress文件夹。 #-r是拷贝所有文件包括子目录 #-P设置ssh的端口号60021<- sshbr>de>find ./wz/wordpress/ | wc -l 6173de> 从本地到远端。 以上命令scp后的2、3参数对调即可。 注意:scp会覆盖原文件,使用时要谨慎。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2014/02/09 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • linux服务器间文件互传及共享办法,本次总结了5种办法包括(ftp、wget、samba、nfs、scp)以供各种不同情况下使用。 1号linux:ipaddr=10.10.10.1 2号linux:ipaddr=192.168.0.1
  • 一、ftp
  • 二、wget
  • 三、samba
  • 四、nfs
  • 五、scp
相关产品与服务
网站建设
网站建设(Website Design Service,WDS),是帮助您快速搭建企业网站的服务。通过自助模板建站工具及专业设计服务,无需了解代码技术,即可自由拖拽模块,可视化完成网站管理。全功能管理后台操作方便,一次更新,数据多端同步,省时省心。使用网站建设服务,您无需维持技术和设计师团队,即可快速实现网站上线,达到企业数字化转型的目的。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档