家庭NAS搭建实战之samba共享

在这里插入图片描述

一、系统环境

root@onecloud:~# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root@onecloud:~# 

二、配置仓库源

1.备份原有仓库源

cp  /etc/apt/sources.list  /etc/apt/sources.listbak   #备份原有配置文件

2.配置新debain源

deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb http://mirrors.aliyun.com/debian-security stretch/updates main
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
#deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
#deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib

3.更新debain源

apt-get update

二、安装samba软件

1.安装软件

root@onecloud:/var/lib/dpkg# apt-get install -y   samba

2.设置共享目录

mkdir -p /data/NAS/nas

3.设置共享目录权限

root@onecloud:~# chmod 777 /data/NAS/nas/
root@onecloud:~# ls -ld /data/NAS/nas/
drwxrwxrwx 3 root root 4096 Jan 24 22:53 /data/NAS/nas/

4.新建samba用户


root@onecloud:~# groupadd it
root@onecloud:~# useradd -g it admin
root@onecloud:~# sabpasswd -a admin


root@onecloud:~# smbpasswd -a admin
New SMB password:
root@onecloud:~# smbpasswd -a admin
New SMB password:
Retype new SMB password:
Added user admin.

5.查看smba用户列表

root@onecloud:~# pdbedit -L
admin:1003:
root@onecloud:~# 

三、修改samba配置文件

root@onecloud:~# vim /etc/samba/smb.conf
[share]
      path = /data/NAS/nas/
      browseable = yes
      write list = @it
      hosts allow = 192.168.3.0/24

四、测试配置文件

root@onecloud:~# testparm /etc/samba/smb.conf 
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[share]"
Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

# Global parameters
[global]
	idmap config * : backend = tdb


[share]
	path = /data/NAS/nas/
	hosts allow = 192.168.3.0/24
	write list = @it
root@onecloud:~# 

五、设置开机自启服务

root@onecloud:~# systemctl start smbd
root@onecloud:~# systemctl enable smbd
Synchronizing state of smbd.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable smbd
root@onecloud:~# 

六、测试登录

windows电脑登录
在这里插入图片描述

在这里插入图片描述

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

江湖有缘

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

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

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

打赏作者

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

抵扣说明:

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

余额充值