This is a cache of http://www.yisu.com/ask/82784824.html. It is a snapshot of the page as it appeared on 2025-08-02T09:02:25.297+0200.
<strong>linux</strong>文件管理怎样共享文件夹资源 - 问答 - 亿速云
温馨提示×

linux文件管理怎样共享文件夹资源

小樊
42
2025-07-25 21:33:07
栏目: 智能运维

linux中,有多种方法可以共享文件夹资源。以下是一些常用的方法:

使用Samba共享文件夹

Samba是一个开源软件,允许linux系统与Windows系统共享文件和打印机。

  1. 安装Samba
sudo apt update
sudo apt install samba
  1. 配置Samba: 编辑Samba配置文件 /etc/samba/smb.conf
sudo nano /etc/samba/smb.conf

在文件末尾添加以下内容:

[shared_folder]
path = /path/to/your/folder
available = yes
valid users = @sambashare
read only = no
browsable = yes
public = yes
writable = yes

/path/to/your/folder 替换为你想要共享的文件夹路径。 3. 创建Samba用户

sudo adduser sambashare
sudo smbpasswd -a sambashare

输入并确认密码。 4. 重启Samba服务

sudo systemctl restart smbd

使用NFS共享文件夹

NFS(Network File System)允许linux系统之间共享文件。

  1. 安装NFS服务器
sudo apt update
sudo apt install nfs-kernel-server
  1. 配置NFS共享: 编辑 /etc/exports 文件:
sudo nano /etc/exports

添加以下内容:

/path/to/your/folder 192.168.1.0/24(rw,sync,no_subtree_check)

/path/to/your/folder 替换为你想要共享的文件夹路径,192.168.1.0/24 替换为你的网络IP范围。 3. 导出共享目录

sudo exportfs -a
  1. 重启NFS服务器
sudo systemctl restart nfs-kernel-server

使用SSHFS共享文件夹

SSHFS允许你通过SSH协议挂载远程文件系统。

  1. 安装SSHFS
sudo apt update
sudo apt install sshfs
  1. 挂载远程文件夹
sshfs username@remote_host:/path/to/remote/folder /path/to/local/mount_point

username 替换为远程主机的用户名,remote_host 替换为远程主机的IP地址或域名,/path/to/remote/folder 替换为远程文件夹路径,/path/to/local/mount_point 替换为你本地想要挂载的文件夹路径。 3. 卸载远程文件夹

fusermount -u /path/to/local/mount_point

使用FTP/SFTP共享文件夹

FTP(File Transfer Protocol)和SFTP(Secure File Transfer Protocol)用于文件传输。

  1. 安装vsftpd
sudo apt update
sudo apt install vsftpd
  1. 配置vsftpd: 编辑 /etc/vsftpd.conf 文件:
sudo nano /etc/vsftpd.conf

确保以下行未被注释:

local_enable=YES
write_enable=YES
chroot_local_user=YES
allow_writeable_chroot=YES
  1. 重启vsftpd服务
sudo systemctl restart vsftpd
  1. 使用FTP/SFTP客户端连接: 你可以使用FileZilla、WinSCP等FTP/SFTP客户端连接到你的linux服务器。

0