Linux Samba文件共享服务配置

一、Samba 安装

user03g@local:~$ sudo apt update
user03g@local:~$ sudo apt install samba

二、Samba配置

1、修改 samba 配置文件
user03g@local:~$ sudo vim /etc/samba/smb.conf 

2、在 /etc/samba/smb.conf 文件后面新增内容

[Home]
	comment = Home Share
	path = /home/user03
	public = yes
	browseable = yes
	read only = no
	valid users = user03
	create mask = 0777
	directory mask = 0777 
	force user = user03
	force group = user03
	available = yes

3、重启 samba 服务

user03@local:~$ sudo systemctl restart smbd

4、设置 samba 用户名和密码

user03@local:~$ sudo smbpasswd -a user03
New SMB password:
Retype new SMB password:
Added user deng.

三、实现Windows主机访问Samba服务器:

1、  在“运行”中输入Samba服务器的IP地址,并回车

2、 在弹出的登录界面中输入Samba的账户st02及密码:
3、 访问Samba服务器成功:

四、Linux主机访问Windows共享文件

1、 在Windows主机中创建共享目录
2、 使用sbmclient命令来连接Windows共享目录
  使用来宾账号Guest(密码为空)来登录访问Windows的共享资源
# smbclient //192.168.1.254/share -U Guest
Password:
Domain=[XULAU] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
smb: /> dir
.                               D            0  Wed Jun 10 05:46:45 2009
..                              D            0  Wed Jun 10 05:46:45 2009
360safefixavi.exe                     A   402952  Sun May 31 07:49:21 2009
avseq03.wmv                          A  8062020  Sat Jun  6 03:11:22 2009
EasyInstallMakerV2.2_XiaoSD.exe   A  1341058  Sat May 30 08:46:03 2009
FireFox 3.0.8.exe                     A  7339968  Mon Apr 20 07:18:42 2009
kav8.0.0.506sch.exe                 A 38302992  Thu Dec  4 20:22:00 2008
mysql-5.1.35.tar.gz                  A 35152597  Fri Jun  5 23:51:45 2009
                         53615 blocks of size 1048576. 5523 blocks available
smb: /> exit
3、 使用mount命令挂载Windows共享目录
# mkdir /winshare
# ll /winshare
total 0
# mount -t smbfs -o username=Guest //192.168.1.254/share /winshare
Password:
# ll /winshare
total 88480
-rwxr-xr-x  1 root root   402952 May 31 07:49 360safefixavi.exe
-rwxr-xr-x  1 root root  8062020 Jun  6 03:11 avseq03.wmv
-rwxr-xr-x  1 root root  1341058 May 30 08:46 EasyInstallMakerV2.2_XiaoSD.exe
-rwxr-xr-x  1 root root  7339968 Apr 20 07:18 FireFox 3.0.8.exe
-rwxr-xr-x  1 root root 38302992 Dec  4  2008 kav8.0.0.506sch.exe
例子:
[homes]
        comment = Home Directories
        browseable = no
        writable = yes
[public_share]
        comment = This is my share
        path = /home/public_share
        browseable = yes
        writable = yes
        public = yes
        guest ok = yes
[Company_File]
        comment = This is company share
        path = /home/CompanyFile
        browseable = yes
        writeable = yes
        public = yes
        guest ok = yes挂载成功!
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

戴国进

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值