
<p itemprop="description">未打算写该篇,文件共享是个很简单的功能,也有很多web应用也集成了该功能,但是还有一些小伙伴不了解,工具嘛,要灵活掌握为已所用,所以又拎出来单独再讲一下.<br/></p><p itemprop="description">文件共享的方法有很多,如ftp、samba、nfs、tftp....这里介绍下比较常见的<br/></p><p itemprop="description"><strong>一、samba文件共享</strong><br/></p><p itemprop="description">Samba是在Linux和UNIX系统上实现SMB协议的一个免费软件,由服务器及客户端程序构成。常用于linux与windows之间的共享。<br/></p><p itemprop="description">A.安装samba<br/></p><p itemprop="description">apt install -y samba</p><p itemprop="description"><img alt="星际魔盒系列之局域网文件共享篇samba、nfs、tftp" src="https://qnam.smzdm.com//19/616e6ee501eb95620.png_e1080.jpg" title="" /></p><p itemprop="description"><strong>B.</strong>配置samba</p><p itemprop="description">cat >>/etc/samba/smb.conf << EOF</p><p itemprop="description">[NAS2]</p><p itemprop="description">comment = NAS2</p><p itemprop="description">path = /mnt/h1/</p><p itemprop="description">writable = yes</p><p itemprop="description">EOF</p><p itemprop="description"><img alt="星际魔盒系列之局域网文件共享篇samba、nfs、tftp" src="https://qnam.smzdm.com//19/616e6ef53f.png_e1080.jpg" title="" /></p><p itemprop="description"><strong>C.</strong>创建用户密码</p><p itemprop="description">smbpasswd -a root</p><p itemprop="description">输入你的共享访问密码</p><p itemprop="description"><img alt="星际魔盒系列之局域网文件共享篇samba、nfs、tftp" src="https://qnam.smzdm.com//19/616e6efd51b.png_e1080.jpg" title="" /></p><p itemprop="description"><strong>D.</strong>重启SMB服务,完成配置</p><p itemprop="description">service smbd restart</p><p itemprop="description"><strong>E.</strong>windows访问共享<br/></p><p itemprop="description">开始--运行 输入 samba服务器IP 输入samba用户名及密码即可访问</p><p itemprop="description"><img alt="星际魔盒系列之局域网文件共享篇samba、nfs、tftp" src="https://qnam.smzdm.com//19/616e6f0.png_e1080.jpg" title="" /></p><p itemprop="description"><strong>F.</strong>移动终端访问samba服务</p><p itemprop="description">IOS与android系统可以安装应用 es文件浏览器</p><p itemprop="description">在ES文件浏览器设置---网络---局域网,新建</p><p itemprop="description">服务器 填写玩客云IP地址</p><p itemprop="description">用户名 填写设置的共享账户名</p><p itemprop="description">密码 填写共享访问密码</p><p itemprop="description"><img alt="星际魔盒系列之局域网文件共享篇samba、nfs、tftp" src="https://qnam.smzdm.com//19/616e6f.png_e1080.jpg" title="" /></p><p itemprop="description"><strong>G.</strong>WIN10共享访问错误解决办法:</p><p itemprop="description">错误提示:你不能访问此共享文件夹,因为你组织的安全策略阻止未经身份验证的来宾访问,这些策略可帮助保护你的电脑免受网络上不安全设备或者恶意设备的威胁</p><p itemprop="description">开始--运行--gpedit.msc--计算机配置--管理模板--网络--Lanman<br/></p><p itemprop="description">双击右窗口内“启用不安全的来宾登录” --改为“已启用” 确定即可解决!</p><p itemprop="description"><strong>其他小分享:</strong><br/></p><p itemprop="description">星际魔盒挂载win10共享文件夹</p><p itemprop="description">由于win10默认未安装SMB1.0协议,需要先在win10控制面板-程序和功能-启用或关闭windows功能-勾选上SMB1.0/CIFS File Sharing Support,安装后需重启电脑。共享文件夹方法就不用说了吧。</p><p itemprop="description">魔盒端挂载命令如下yourname、yourpassword分别改为你win10电脑的用户名密码,ip改为你win10共享文件夹路径,挂载点改为你需要的挂载点</p><p itemprop="description">mount -t cifs -o username=yourname,password=yourpassword //192.168.2.11/tools /mnt/smb</p><p itemprop="description">星际魔盒挂载玩客云局域网访问samba,命令一样要修改后用哦。<br/></p><p itemprop="description">mount -t cifs -o user=root,password=,vers=1.0 //192.168.2.232/5603/ /mnt/smb</p><p itemprop="description">详细samba安装说参见我的其他发布<br/></p><p itemprop="description"><strong>二、NFS文件共享服务</strong><br/></p><p itemprop="description">全称Network File Service,常用于linux系统间的文件共享,NFS客户端可以像访问本地文件一样访问远端NFS服务器上的文件。</p><p itemprop="description"><strong>A.</strong>安装<br/></p><p itemprop="description">服务器端nfs-kernel-server 客户端nfs-common</p><p itemprop="description">apt install -y nfs-kernel-server nfs-common</p><p itemprop="description"><img alt="星际魔盒系列之局域网文件共享篇samba、nfs、tftp" src="https://qnam.smzdm.com//19/616e6f4c6f0e77970.png_e1080.jpg" title="" /></p><p itemprop="description"><strong>B.</strong>配置</p><p itemprop="description">服务器共享目录配置</p><p itemprop="description">cat >>/etc/exports << EOF</p><p itemprop="description">#允许单机访问/mnt/hdd1/nfs目录,且授于读写权限</p><p itemprop="description">/mnt/hdd1/nfs 192.168.2.230(rw,sync,no_subtree_check)</p><p itemprop="description">#允许局域网访问/mnt/hdd1/nfs目录,且授于读写等权限</p><p itemprop="description">/mnt/hdd1/nfs 192.168.2.0/255.255.255.0(rw,sync,no_subtree_check)</p><p itemprop="description">/mnt/hdd1/nfs 192.168.2.0/24(rw,sync,no_subtree_check)</p><p itemprop="description">EOF</p><p itemprop="description">常用命令</p><p itemprop="description">exportfs [-adfhioruvs] [host:/path]</p><p itemprop="description">exportfs -v #查看所有共享目录</p><p itemprop="description">exportfs -rv #使配置生效</p><p itemprop="description">exportfs -au #取消所有共享目录</p><p itemprop="description"><strong>C.</strong>重启NFS服务<br/></p><p itemprop="description">service nfs-kernel-server restart</p><p itemprop="description"><strong>D.</strong>客户机挂载<br/></p><p itemprop="description">mount ip:/mnt/hdd1/nfs /nfs /本地挂载点</p><p itemprop="description"><strong>E.</strong>常见参数<br/></p><p itemprop="description">ro:共享目录只读;</p><p itemprop="description">rw:共享目录可读可写</p><p itemprop="description">sync:同步,将数据同步写入缓冲区与磁盘中,效率低,但可以保证数据的一致性;</p><p itemprop="description">async:异步,将数据先保存在内存缓冲区中,必要时才写入磁盘,效率高,但有丢失数据的风险;</p><p itemprop="description">wdelay(默认):如果有多个客户端要对同一个共享目录进行写操作,则将这些操作集中执行。对有很多小的IO写操作时,使用该选项可以有效地提高效率;</p><p itemprop="description">no_wdelay:如果有多个客户端要对同一个共享目录进行写操作则立即写入。当设置了async选项时,no_wdelay选项无效,应与sync配合使用;</p><p itemprop="description">root_squash(默认):将来访的root用户映射为匿名用户或用户组;</p><p itemprop="description">no_root_squash:来访的root用户保持root帐号权限;</p><p itemprop="description">all_squash:所有访问用户都映射为匿名用户或用户组;</p><p itemprop="description">no_all_squash(默认):访问用户先与本机用户匹配,匹配失败后再映射为匿名用户或用户组;</p><p itemprop="description">anonuid=<UID>:指定匿名访问用户的本地用户UID,默认为nfsnobody(65534);</p><p itemprop="description">anongid=<GID>:指定匿名访问用户的本地用户组GID,默认为nfsnobody(65534);</p><p itemprop="description">secure(默认):限制客户端只能从小于1024的tcp/ip端口连接服务器;</p><p itemprop="description">insecure:允许客户端从大于1024的tcp/ip端口连接服务器;</p><p itemprop="description">subtree_check :若输出目录是一个子目录,则nfs服务器将检查其父目录的权限;</p><p itemprop="description">no_subtree_check(默认) :即使输出目录是一个子目录,nfs服务器也不检查其父目录的权限,这样可以提高效率;</p><p itemprop="description">hide:共享一个目录时,不共享该目录的子目录;</p><p itemprop="description">no_hide:共享子目录;</p><p itemprop="description"><strong>F.</strong>卸载nfs软件包<br/></p><p itemprop="description">apt autoremove -y nfs-kernel-server nfs-common</p><p itemprop="description">apt autopurge -y nfs-kernel-server nfs-common</p><p itemprop="description"><img alt="星际魔盒系列之局域网文件共享篇samba、nfs、tftp" src="https://qnam.smzdm.com//19/616e6f6d06ce8574.png_e1080.jpg" title="" /></p><p itemprop="description"><strong>三、TFTP文件共享</strong></p><p itemprop="description">全称Trivial File Transfer Protocol,用途广泛,常用于嵌入式系统从服务器上下载文件升级。</p><p itemprop="description"><strong>A.</strong>安装</p><p itemprop="description">服务器端tftpd-hpa 客户端tftp-hpa</p><p itemprop="description">apt install -y tftp-hpa tftpd-hpa </p><p itemprop="description"><img alt="星际魔盒系列之局域网文件共享篇samba、nfs、tftp" src="https://qnam.smzdm.com//19/616e6f770d75f2252.png_e1080.jpg" title="" /></p><p itemprop="description"><strong>B.</strong>创建TFTP共享目录及配置</p><p itemprop="description">mkdir -p /mnt/hdd1/tftp #创建用于TFTP共享的服务器目录</p><p itemprop="description">chmod -Rf 777 /mnt/hdd1/tftp #授权读写执行权限</p><p itemprop="description">修改/etc/default/tftpd-hpa配置文件中TFTP_DIRECTORY="/srv/tftp"为你的TFTP共享目录</p><p itemprop="description"><strong>C.</strong>重启服务<br/></p><p itemprop="description">service tftpd-hpa restart</p><p itemprop="description"><strong>D.</strong>使用<br/></p><p itemprop="description">例:连接到远程TFTP服务器192.168.2.11上下载123.txt ,上传456.txt</p><p itemprop="description">tftp 192.168.2.11</p><p itemprop="description">get 123.txt</p><p itemprop="description">put 456.txt</p><p itemprop="description"><strong>E.</strong>常见参数<br/></p><p itemprop="description">connect:连接到远程tftp服务器</p><p itemprop="description">mode:文件传输模式</p><p itemprop="description">put:上传文件</p><p itemprop="description">get:下载文件</p><p itemprop="description">quit:退出</p><p itemprop="description">verbose:显示详细的处理信息</p><p itemprop="description">tarce:显示包路径</p><p itemprop="description">status:显示当前状态信息</p><p itemprop="description">binary:二进制传输模式</p><p itemprop="description">ascii:ascii传送模式</p><p itemprop="description">rexmt:设置包传输的超时时间</p><p itemprop="description">timeout:设置重传的超时时间</p><p itemprop="description">help:帮助信息</p><p itemprop="description">?:帮助信息</p><p itemprop="description"><strong>F.</strong>卸载tftp服务器软件包<br/></p><p itemprop="description">apt autoremove -y tftp-hpa tftpd-hpa</p><p itemprop="description">apt autopurge -y tftp-hpa tftpd-hpa</p><p itemprop="description"><img alt="星际魔盒系列之局域网文件共享篇samba、nfs、tftp" src="https://qnam.smzdm.com//19/616e6f884aea85690.png_e1080.jpg" title="" /></p><p itemprop="description">至此,常见的linux下常见文件共享方法就结束了,欢迎小伙伴们交流!</p> <input type="hidden" id="isDetail"> <input type="hidden" id="channelID" value="11"> <input type="hidden" id="channel_name" value="yuanchuang"> <input type="hidden" id="articleIdBang" value=""> <input type="hidden" id="articleID" value=""> <input type="hidden" id="articleHashid" value="amxz50lk"> <input type="hidden" id="picUrl" value=""> <input type="hidden" id="articleContent" value=""> <input type="hidden" id="J_channel_name" value="yuanchuang"> <input type="hidden" id="J_article_name" value="星际魔盒系列之局域网文件共享篇samba、nfs、tftp"> <input type="hidden" id="content_remove_external_card" value="0"> <input type="hidden" id="groupId" value=""> <input type="hidden" id="groupName" value=""> <input type="hidden" id="publish_time_toupiao" value="2021-10-23">
讯享网

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/200508.html