Ubuntu共享文件夹主要有Samba和NFS两种方法,以下是具体步骤:
sudo apt update
和sudo apt install samba
。mkdir
命令创建,如sudo mkdir /home/username/shared
,并设置权限,如sudo chmod 777 /home/username/shared
。/etc/samba/smb.conf
,在文件末尾添加共享配置,如[shared]
,并设置path
、valid users
、read only
等参数。sudo smbpasswd -a username
,设置访问共享文件夹的用户名和密码。sudo systemctl restart smbd
和sudo systemctl restart nmbd
。sudo apt update
和sudo apt install nfs-kernel-server
。mkdir
命令创建,如sudo mkdir /srv/nfs/share
,并设置权限,如sudo chmod 777 /srv/nfs/share
。/etc/exports
,添加/path/to/shared_folder *(rw,sync,no_subtree_check)
。sudo exportfs -a
和sudo systemctl restart nfs-kernel-server
。