Linux操作系统 Samba服务器配置与使用
Linux操作系统 Samba服务器配置与使用
Samba是在Linux和UNIX系统上实现SMB协议的一个免费软件,由服务器及客户端程序构成。
SMB(Server Messages Block,信息服务块)是一种在局域网上共享文件和打印机的一种通信协议,它为局域网内的不同计算机之间提供文件及打印机等资源的共享服务。
SMB协议是客户机/服务器型协议,客户机通过该协议可以访问服务器上的共享文件系统、打印机及其他资源。
配置Samba服务,实现与windows 系统文件共享
OS:RHEL6.4 - 64

1 查看相关服务
排除防火墙和selinux的影响,先禁用selinux和防火墙
禁用selinux 配置文件中SELINUX设置为disabled,重启操作系统查看
[root@rhel64 ~]# getenforce
[root@rhel64 ~]# cat /etc/sysconfig/selinux

禁用防火墙
[root@rhel64 ~]# service iptables stop[root@rhel64 ~]# chkconfig iptables off
[root@rhel64 ~]# service iptables status
[root@rhel64 ~]# chkconfig --list iptables

2 查看软件安装情况
[root@rhel64 ~]# rpm -qa | grep samba

[root@rhel64 ~]# yum grouplist | grep file

[root@rhel64 ~]# yum groupinfo 'CIFS file server'

[root@rhel64 ~]# yum groupinstall 'CIFS file server'

[root@rhel64 ~]# rpm -qa | grep samba

3 创建共享目录
此处共享/software文件系统 用来存放Oracle软件包
[root@rhel64 ~]# df -Th

4 编辑配置文件
追加写入用户自定义共享
[root@rhel64 ~]# vi /etc/samba/smb.conf

执行testparm命令可以查看当前配置
[root@rhel64 ~]# testparm

5 启动samba 服务 并设置系统启动时服务自动启动
[root@rhel64 ~]# service smb start
[root@rhel64 ~]# service nmb start
[root@rhel64 ~]# chkconfig smb on
[root@rhel64 ~]# chkconfig nmb on
[root@rhel64 ~]# chkconfig --list smb
[root@rhel64 ~]# chkconfig --list nmb

6 查看监听端口及本地主机名解析
[root@rhel64 ~]# netstat -lntup | grep mbd

[root@rhel64 ~]# cat /etc/hosts

7 操作系统普通用户 转化为samba用户
[root@rhel64 ~]# id tom
[root@rhel64 ~]# smbpasswd -a tom

[root@rhel64 ~]# pdbedit -L

8 windows客户端查看访问
windows端可以关闭防火墙,排除影响




修改共享目录权限
[root@rhel64 ~]# chmod a+w /software/
[root@rhel64 ~]# ls -ld /software/

windows中新建文件夹成功

9 上传数据库软件包
利用samba服务 将1of7 2of7两个压缩文件上传到/software/db

[root@rhel64 ~]# df -Th /software/
[root@rhel64 ~]# du -sh /software/db
[root@rhel64 ~]# ls -lh /software/db/

10 linux客户端查看samba共享
[root@rhel64 ~]# smbclient -L 192.168.6.101

[root@rhel64 ~]# smbclient -U tom //192.168.6.101/oraclesoft

11 linux客户端挂载samba方法
11.1 临时挂载方法
[root@rhel64 ~]# mount //192.168.6.101/oraclesoft /mnt/samba -o username=tom

[root@rhel64 ~]# umount /mnt/samba
[root@rhel64 ~]# df -Th

11.2 开机自动挂载方法
[root@rhel64 ~]# vi /etc/fstab

[root@rhel64 ~]# mount -a
[root@rhel64 ~]# df -Th

------------------------------------分割线------------------------------------
------------------------------------分割线------------------------------------
Samba 的详细介绍:请点这里
Samba 的下载地址:请点这里