大家好,又见面了,我是你们的朋友全栈君
要达到的目标:对公司的不同部门建立不同的文件共享,不同的用户访问同一个共享目录具有不同的权限.
安装samba 查看自己的服务器中是否安装了samba服务: # rpm -aq|grep samba 没有直接运行以下命令: # yum install samba samba-client samba-swat 运行后,依赖包(samba-common、samba-winbind-clients、libsmbclient)将直接自动安装.
建用户,建共享文件夹并设置文件权限及归属 1> 添加用户: [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
2> 为用户设置samba密码:
# smbpasswd -a devadmin
New SMB password:
Retype new SMB password:
Added user devadmin.
3> 新建共享目录:
# 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
4> 设置项目权限:
# 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
配置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
关闭,启动samba服务 # systemctl stop smb //关闭smb # systemctl start smb //开启smb # systemctl status smb //查看smb状态
设置samba开机重启: # chkconfig smb on
参考链接: http://blog.csdn.net/houqd2012/article/details/8880635
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/193455.html原文链接:https://javaforall.cn