在Ubuntu中创建共享文件夹并支持Windows访问和修改
在Ubuntu系统中,我们可以使用Samba服务来创建一个共享文件夹,以便其他操作系统(如Windows)可以访问和修改该文件夹,本文将详细介绍如何在Ubuntu中创建共享文件夹并支持Windows访问和修改。
1、安装Samba服务
我们需要在Ubuntu系统中安装Samba服务,打开终端,输入以下命令:
sudo aptget update sudo aptget install samba
2、配置Samba服务
安装完成后,我们需要对Samba服务进行配置,创建一个用于共享的文件夹,我们创建一个名为“shared”的文件夹:
mkdir /home/your_username/shared
接下来,我们需要为该文件夹设置权限,输入以下命令:
chmod R 777 /home/your_username/shared
我们需要编辑Samba配置文件,输入以下命令:
sudo nano /etc/samba/smb.conf
在打开的文件中,找到以下行:
workgroup = WORKGROUP
将其更改为:
workgroup = YOUR_WORKGROUP_NAME
将YOUR_WORKGROUP_NAME
替换为您的工作组名称,接下来,在文件末尾添加以下内容:
[shared] path = /home/your_username/shared available = yes valid users = your_username read only = no browsable = yes public = yes writable = yes
将your_username
替换为您的用户名,保存并关闭文件。
3、重启Samba服务
配置完成后,我们需要重启Samba服务以使更改生效,输入以下命令:
sudo service smbd restart
4、在Windows中访问共享文件夹
现在,您可以在Windows系统中访问刚刚创建的共享文件夹,确保两台计算机连接到同一个网络,在Windows计算机上打开文件资源管理器,输入以下地址:\your_ubuntu_ipshared
,其中your_ubuntu_ip
是您的Ubuntu计算机的IP地址,您应该能看到共享的“shared”文件夹,双击该文件夹以访问其内容,默认情况下,您需要输入Ubuntu计算机上的用户名和密码才能访问该文件夹,如果您希望无需输入用户名和密码即可访问,请参考下一节。
5、允许匿名访问共享文件夹(可选)
如果您希望允许未经身份验证的用户访问共享文件夹,可以在Samba配置文件中进行设置,找到以下行:
security = user
将其更改为:
security = share
找到以下行:
map to guest = bad user
将其更改为:
map to guest = bad user # Do not change this line. It is required by Samba. However, you can remove the "#" character at the beginning of the line to enable anonymous access. Anonymous access should be disabled on shared folders that contain sensitive data. If you want to allow anonymous access, create a separate shared folder for public use. Remember to set the appropriate permissions and security settings for this folder. For example: path = /home/your_username/public available = yes valid users = +@users read only = no browsable = yes public = yes writable = yes guest ok = yes force group = users create mask = 0777 directory mask = 0777 force user = nobody force group = nobody directory security mask = 0777 force create mode = 0666 force directory mode = 0777 file security mask = 0777 force directory security mask = 0000 unix extensions = no follow symlinks = yes hide dot files = no case sensitive = no local echo = no printable = no locking = no strict locking = no wide links = no acl support = yes xattr support = yes store dos attributes = yes vfs objects = catia fruit streams_xattr = yes fruit:metadata = auto fruit:model = Macintosh hartleydfs_disable = yes hartleydfs_enable = no hartleydfs_supported_versions = none hartleydfs_required_versions = none hartleydfs_strict_ordering = no hartleydfs_forced_versions = none hartleydfs_blacklisted_versions = none hartleydfs_whitelisted_versions = none hartleydfs_min_port = 49152 hartleydfs_max_port = 65535 hartleydfs_timeout = 300 hartleydfs_retry_count = 3 hartleydfs_retry_delay = 1 hartleydfs_multiplier = 2 hartleydfs_randomize_directory_listings = no hartleydfs_use_fruit_dosattributes = no hartleydfs_use_fruit_timestamps = no hartleydfs_use_fruit_posixacls = no hartleydfs_use_fruit_macmetadata = no hartleydfs_use_fruit_resourceforks = no hartleydfs_use_fruit_windowsattributes = no hartleydfs_use_fruit_unixextensions = no hartleydfs_use_fruit_dosfiletimes = no hartleydfs_use_fruit_networkfullnameattribute = no hartleydfs_use_fruit_networkpathattribute
原创文章,作者:未希,如若转载,请注明出处:https://www.kdun.com/ask/677236.html
本网站发布或转载的文章及图片均来自网络,其原创性以及文中表达的观点和判断不代表本网站。如有问题,请联系客服处理。
发表回复