一、下载samba软件包,不用安装其他的了,因为它会自动帮我们下载所需要的其他依赖包

sudo apt-get install samba

二、修改/etc/samba目录下的配置文件,smb.conf

以下所有操作需要切换到root用户

su - root

修改文件

gedit smb.conf

在[gloabal]栏目下添加

#======================= Global Settings =======================

[global]

## Browsing/Identification ###

# Change this to the workgroup/NT-domain name your Samba server will part of
workgroup = WORKGROUP
security = user

在-------share Defination------下添加共享栏目

[pc]
comment = All Printers
browseable = yes
path = /home/pc/work
read only = no
valid users = @pc

三、添加samba用户

该用户需要是ubuntu16.4的现有用户,如果没有需要创建,本系统中已有用户pc

添加samba用户pc

smbpasswd -a pc

激活samba用户pc

smbpasswd -e pc

四、重启samba服务

systemctl restart smbd.service nmbd.service

五、检测是否成功

查看虚拟机ip地址

pc@pc-virtual-machine:/etc/samba$ ifconfig
ens33 Link encap:Ethernet HWaddr :0c:::2e:c1
inet addr:111.186.98.93 Bcast:111.186.98.127 Mask:255.255.255.128
inet6 addr: :da8:::56eb:6ca9::51a3/ Scope:Global
inet6 addr: fe80::8dfa:48e3:4e6b:1df0/ Scope:Link
UP BROADCAST RUNNING MULTICAST MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (4.2 MB) TX bytes: (161.8 KB)
Interrupt: Base address:0x2000 lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::/ Scope:Host
UP LOOPBACK RUNNING MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (58.2 KB) TX bytes: (58.2 KB)

在windows主机上进行访问

打开运行

ubuntu16.4中安装samba服务-LMLPHP

点击确定

ubuntu16.4中安装samba服务-LMLPHP

此时可以进行正常访问了。

05-11 19:50