Samba主要用于Windows 和linux 之间的文件共享。
Samba的配置比较多,下面从实用的角度为大家做一些简单的说明。供初学者参考。
2.1 安装samba
一般的Linux都会安装samba程序,如果没有安装,可以去samba的官网下载安装软件,自己进行安装。 网站地址:http://www.samba.org/
2.2 简单说明
Samba 有两个守护进程:smbd 和nmbd,它们是Samba的核心进程。
nmbd进程使其他计算机浏览Linux服务器.
Smbd进程在SMB服务请求到达时对它们进行处理,并且为使用或共享的资源进行协调.
Samba的的配置文件信息写在: /etc/samba/smb.conf 文件中,如果我们要共享某些文件夹,可以在这个文件里添加相关的内容,在重启一下samba服务即可。 先看一下文件的内容:
[root@localhost ~]# more /etc/samba/smb.conf
......中间是一些其他的配置,我们就不看了,我们看最后一个配置....
复制代码 代码如下:
#====Share Definitions =======
idmap uid = 16777216-33554431
idmap gid = 16777216-33554431
template
shell = /bin/false
winbind use default domain = no
[homes]
comment = Home Directories
browseable = no
writable = yes
; valid users = %S
; valid users = MYDOMAIN/%S
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
# Un-comment the following and create the netlogon directory for Domain Logons
; [netlogon]
; comment = Network Logon Service
; path = /var/lib/samba/netlogon
; guest ok = yes
; writable = no
; share modes = no
# Un-comment the following to provide a specific roving profile share
# the default is to use the user's home directory
; [Profiles]
; path = /var/lib/samba/profiles
; browseable = no
; guest ok = yes
# A publicly accessible directory, but read only, except for people in
# the "staff" group
; [public]
; comment = Public Stuff
; path = /home/samba
; public = yes
; writable = yes
; printable = no
; write list = +staff
这段是关于添加共享的一些配置。
重启Samba服务
[root@localhost oracle]#/etc/rc.d/init.d/smb restart
或
[root@localhost oracle]# service smb restart
2.3 2个实例
2.3.1 windows 访问Linux 共享
在samba的配置文件( /etc/samba/smb.conf )里添加 /u01 的共享。把如下代码添加到sbm.conf就可以了:
复制代码 代码如下:
[global]
workgroup=MYGROUP -- 这个自己随便写
sercurity=share -- 这里要注意,因为默认是USER
[public]
path = /tmp/aaaa------这个aaaa目录要在linux中存在
public = yes
guest ok = yes
writable = yes
;printable = no
;[myshare]
; comment = Mary's and Fred's stuff
; path = /usr/somewhere/shared
; valid users = mary fred
; public = no
; writable = yes
; printable = no
; create mask = 0765
[oracle]
path = /tmp/data
public = yes
guest ok = yes
writable = yes
[log]
path = /tmp/log
public = yes
guest ok = yes
writable = yes
重启Samba 服务:
[root@localhost oracle]# service smb restart
Shutting down SMB services: [ OK ]
Shutting down NMB services: [ OK ]
Starting SMB services: [ OK ]
Starting NMB services: [ OK ]
最后在window 平台下输入: 192.168.55.34 就可以访问Linux的共享内容了,并且还具有写的权限。
这里为了方便,没有按用户来进行设置,如果按用户的话要麻烦一点。 所以安全性也比较差。