码迷,mamicode.com
首页 > 其他好文 > 详细

搭建samba服务

时间:2019-10-11 18:22:01      阅读:91      评论:0      收藏:0      [点我收藏+]

标签:gre   bin   ble   use   mba   direct   共享文件   dmi   localhost   

1. 安装samba 
查看自己的服务器中是否安装了samba服务: 
# rpm -aq|grep samba 
没有直接运行以下命令: 
# yum install samba samba-client samba-swat 
运行后,依赖包(samba-common、samba-winbind-clients、libsmbclient)将直接自动安装.

2. 建用户,建共享文件夹并设置文件权限及归属 
添加用户: 
[root@localhost samba]# useradd -s /sbin/nologin devadmin 
[root@localhost samba]# useradd -s /sbin/nologin testadmin 
[root@localhost samba]# useradd -s /sbin/nologin uiadmin 
[root@localhost samba]# useradd -s /sbin/nologin hradmin 
[root@localhost samba]# useradd -s /sbin/nologin prodadmin 
[root@localhost samba]# useradd -s /sbin/nologin optsadmin 
[root@localhost samba]# useradd -s /sbin/nologin admin 
添加用户并设置用户所属组: 
[root@localhost samba]# useradd -g devadmin -s /sbin/nologin d 
[root@localhost samba]# useradd -g hradmin -s /sbin/nologin h 
[root@localhost samba]# useradd -g prodadmin -s /sbin/nologin p 
[root@localhost samba]# useradd -g optsadmin -s /sbin/nologin o

3. 为用户设置samba密码:
# smbpasswd -a devadmin
New SMB password:
Retype new SMB password:
Added user devadmin.

4. 新建共享目录:
# mkdir company
# cd company
# mkdir DEV TEST HR share
# ll
total 0
drwxr-xr-x 2 root root 6 Jun 30 14:26 DEV
drwxr-xr-x 2 root root 6 Jun 30 14:26 HR
drwxr-xr-x 2 root root 6 Jun 30 14:26 share
drwxr-xr-x 2 root root 6 Jun 30 14:26 TEST
设置项目权限:
# chown devadmin.devadmin DEV/ && chown hradmin.hradmin HR && chown testadmin.testadmin TEST/
# ll
total 0
drwxr-xr-x 2 devadmin devadmin 6 Jun 30 14:26 DEV
drwxr-xr-x 2 hradmin hradmin 6 Jun 30 14:26 HR
drwxr-xr-x 2 root root 6 Jun 30 14:26 share
drwxr-xr-x 2 testadmin testadmin 6 Jun 30 14:26 TEST
# chmod -R 0775 share/
# ll | grep share
total 0
drwxrwxr-x 2 root root 6 Jun 30 14:26 share
# cd share
# mkdir DEV HR TEST Tools
# chown devadmin.devadmin DEV/ && chown hradmin.hradmin HR && chown testadmin.testadmin TEST/ && chown admin.admin Tools/ 
# ll
total 0
drwxr-xr-x 2 devadmin devadmin 6 Jun 30 14:52 DEV
drwxr-xr-x 2 hradmin hradmin 6 Jun 30 14:52 HR
drwxr-xr-x 2 testadmin testadmin 6 Jun 30 14:52 TEST
drwxr-xr-x 2 admin admin 6 Jun 30 14:52 Tools
# chmod 1770 DEV/ HR TEST/
# ll
total 0
drwxrwx--T 2 devadmin devadmin 6 Jun 30 14:26 DEV
drwxrwx--T 2 hradmin hradmin 6 Jun 30 14:26 HR
drwxr-xr-x 2 admin admin 6 Jun 30 14:26 Tools
drwxrwx--T 2 testadmin testadmin 6 Jun 30 14:26 TEST

6. 配置samba 
设置: 
# ———————– Standalone Server Options ——————- 
security = user 
passdb backend = tdbsam 
# ———————– Share Definitions ——————- 
[DEV] 
comment = This is a directory of Project. 
path = /company/DEV/ 
public = no 
admin users = devadmin 
valid users = @devadmin 
writable = yes 
create mask = 0777 
directory mask = 0775

[TEST]
comment = This is a directory of TEST.
path = /company/TEST/
public = no
admin users = testadmin
valid users = @testadmin
writable = yes
create mask = 0750
directory mask = 0750

[HR]
comment = This is a directory of HR.
path = /company/HR/
public = no
admin users = hradmin
valid users = @hradmin
writable = yes
create mask = 0750
directory mask = 0750

[SHARE]
comment = This is a share directory.
path = /company/share/
public = no
;admin users = admin
valid users = admin,@devadmin,@hradmin,@testadmin
writable = yes
create mask = 0755
directory mask = 0755

7. 关闭,启动samba服务 
# systemctl stop smb //关闭smb 
# systemctl start smb //开启smb 
# systemctl status smb //查看smb状态
设置samba开机重启: 
# systemctl enable smb

  

搭建samba服务

标签:gre   bin   ble   use   mba   direct   共享文件   dmi   localhost   

原文地址:https://www.cnblogs.com/The-day-of-the-wind/p/11655621.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!