更新当前软件
sudo apt-get upgrade
sudo apt-get update
sudo apt-get dist-upgrade
安装samba服务
sudo apt-get install samba samba-common
配置共享目录
这里将用户目录作为共享目录,修改配置文件/etc/samba/smb.conf
# Un-comment the following (and tweak the other settings below to suit)
# to enable the default home directory shares. This will share each
# user's home directory as \\server\username
[homes]
comment = Home Directories
browseable = yes
# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
read only = no
# File creation mask is set to 0700 for security reasons. If you want to
# create files with group=rw permissions, set next parameter to 0775.
create mask = 0755
# Directory creation mask is set to 0700 for security reasons. If you want to
# create dirs. with group=rw permissions, set next parameter to 0775.
directory mask = 0755
# By default, \\server\username shares can be connected to by anyone
# with access to the samba server.
# Un-comment the following parameter to make sure that only "username"
# can connect to \\server\username
# This might need tweaking when using external authentication schemes
valid users = %S
添加samba访问账户及密码
添加的用户需要在系统账号中存在,否则添加失败,例如添加的用户名是lhy,命令如下:
sudo smbpasswd -a lhy
接下来根据提示,输入密码即可。
重启samba服务
sudo service smbd restart
在windows中访问samba服务
接下来在windows中通过映射网络驱动器访问samba。