为linux简单配置samba共享服务

查看是否已经安装了samba服务:
[root@SeaRu ~]# rpm -qa | grep samba

安装samba服务:
[root@SeaRu ~]# yum install samba
[ubuntu@SeaRu ~]$ sudo apt-get install samba smbfs

查看samba的初始配置:
[root@SeaRu ~]# grep -v “^#” /etc/samba/smb.conf

[global]此部分是samba服务器的全局设置
workgroup = MYGROUP
server string = Samba Server Version %v
; netbios name = MYSERVER
; interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24
; hosts allow = 127. 192.168.12. 192.168.13.
; log file = /var/log/samba/%m.log
; max log size = 50
security = user
passdb backend = tdbsam
; security = domain
; passdb backend = tdbsam
; realm = MY_REALM
; password server =
; security = user
; passdb backend = tdbsam
; domain master = yes
; domain logons = yes
; logon script = %m.bat
; logon script = %u.bat
; logon path = \\%L\Profiles\%u
; logon path =
; add user script = /usr/sbin/useradd “%u” -n -g users
; add group script = /usr/sbin/groupadd “%g”
; add machine script = /usr/sbin/useradd -n -c “Workstation (%u)” -M -d /nohome -s /bin/false “%u”
; delete user script = /usr/sbin/userdel “%u”
; delete user from group script = /usr/sbin/userdel “%u” “%g”
; delete group script = /usr/sbin/groupdel “%g”
; local master = no
; os level = 33
; preferred master = yes
; wins support = yes
; wins server = w.x.y.z
; wins proxy = yes
; dns proxy = yes
load printers = yes
cups options = raw
; printcap name = /etc/printcap
; printcap name = lpstat
; printing = cups
; map archive = no
; map hidden = no
; map read only = no
; map system = no
; store dos attributes = yes

[homes]设置用户共享目录的属性
comment = Home Directories
browseable = no
writable = yes
; valid users = %S
; valid users = MYDOMAIN\%S

[printers]设置samba服务器中打印机共享资源的属性
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes

; [netlogon]
; comment = Network Logon Service
; path = /var/lib/samba/netlogon
; guest ok = yes
; writable = no
; share modes = no

; [Profiles]
; path = /var/lib/samba/profiles
; browseable = no
; guest ok = yes

; [public]
; comment = Public Stuff
; path = /home/samba
; public = yes
; writable = yes
; printable = no
; write list = +staff
[root@SeaRu ~]#

关于这些配置项含义请移步:smb.conf常见配置项及含义

新建一个用户用于访问共享
[root@SeaRu ~]# adduser smbtest
[root@SeaRu ~]# smbpasswd -a smbtest
New SMB password:12345678
Retype new SMB password:12345678

新建一个目录来共享
[root@SeaRu ~]# mkdir /home/free
[root@SeaRu ~]# chown nobody.nobody /home/free

在smb.conf文件中添加该共享资源
[free]
path = /home/free
public = yes
only guest = yes
writable yes

可以试试测试smb.conf配置文件
[root@SeaRu ~]# testparm

可以试试samba图形管理界面
[root@SeaRu ~]# yum install system-config-samba
[ubuntu@SeaRu ~]$ sudo apt-get install system-config-samba

启动samba服务器
[root@SeaRu ~]# service smb start
[ubuntu@SeaRu ~]$ sudo /etc/init.d/samba start