一、下载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地址
[email protected]virtual-machine:/etc/samba$ ifconfig ens33 Link encap:Ethernet HWaddr 00:0c:29:95:2e:c1 inet addr:111.186.98.93 Bcast:111.186.98.127 Mask:255.255.255.128 inet6 addr: 2001:da8:8006:125:56eb:6ca9:8682:51a3/64 Scope:Global inet6 addr: fe80::8dfa:48e3:4e6b:1df0/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:48479 errors:0 dropped:0 overruns:0 frame:0 TX packets:1927 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:4277804 (4.2 MB) TX bytes:161866 (161.8 KB) Interrupt:19 Base address:0x2000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:882 errors:0 dropped:0 overruns:0 frame:0 TX packets:882 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:58273 (58.2 KB) TX bytes:58273 (58.2 KB)
在windows主机上进行访问
打开运行
点击确定
此时可以进行正常访问了。
时间: 2024-11-05 17:29:51