Linux_Samba详解

Samba Server

Samba是在Linux和UNIX系统上实现SMB协议的一个免费软件,C/S架构,可用于用于Linux和Windows共享文件。SMB(Server Messages Block,信息服务块)是一种在局域网上共享文件和打印机的一种通信协议,它为局域网内的不同计算机之间提供文件及打印机等资源的共享服务。客户机通过该协议可以访问服务器上的共享文件系统、打印机及其他资源。通过设置”NetBIOS over TCP/IP”使得Samba不但能与局域网络主机分享资源,还能与全世界的电脑分享资源。 
Samba:File share service(windows <–> linux),support edit(on-line) file’s content.Can be prevent the infection virus on windows OS. 
You can setup the Samba server on Window or Linux. 
Linux OS: 
Protocol:SMB(Server message Block) Protocol 
Port:TCP139 UDP137 
Window OS: 
Protocol:CIFS(Common Internet File System) Protocol 
Port: TCP445 UDP138

Parameter

Program: smbd(Commonly used)\umdbd(Rarely used) 
Software: 
samba-3.033-3.28.el5 
samba-common 
samba-client(Web GUI management samba service,Rarely used) 
configure file: 
/etc/samba/smb.conf 
Tools for Check configure:testparm

Configuration file explain

Vim /etc/samba/smb.conf

#Section:
[global]                 #Global Setting
workgroup =              #work group name
security = [share|user|server]            #select one out of three
                    #share --> don't need the authentication
                    #user --> login the samba server share directory by local samba user authentication
                    #server --> user authentication by network
log file =  #log file store url

[homes]              #share /home directory

[printers]           #Printers set

[userShare]          #user-defined share directory
comment =            #description of share directory
path =               #share directory path
browseable = [yes|no]           #samba service share directory whether show in the Network Neighborhood of windows OS.General the value is "yes"
guest ok = [yes|no]     #share directory whether can access by anonymous user
                         #yes --> support anonymous user access
                         #no --> access by authentication
valid users = userName,@groupName           #Allow user who can login share directory
writable = [yes|no]           #User whether have permission to write in the share directory
write list = userName,@groupName              #Allow user who have write permission in the share directory
public = [yes|no]             #whether support anonymous user to login the share directory
create mode = 0644            #Set the default permissions of file when you create a new file in the share directory
directory mode = 0755         #Set the default permissions of directory when you create a new sub-directory in the share directory
#Attention: If you want to write into the share directory, you have to meet two condition.
#        1.Set option "writable = yes" into the config file
#        2.The share directory have permissions of writable(rw-rw-rw-)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29

Check samba config file: 
1.Use command grep:

grep -V "^#" smb.conf | grep -V "^;" | grep -V ^$
  • 1
  • 1

2.Use command supported by samba service

testparm  #Check and read the config file
  • 1
  • 1

Setup the Samba Server

Step1. Install samba and check the config file

yum in stall -y samba samba-common samba-client
grep -V "^#" /etc/samba/samba.conf | grep -V "^;" | grep -V ^$    #Look up the configuration file
testparm
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

Step2. Edit samba service config file. 
vim /etc/samba/smb.conf

#Example:
        [global]
            security = user
            hosts allow = 127. 192.168.8. 10.20.0.  #limit access from IP address, Only allow access from network-segment with (127./192.168.8./10.20.0.)
            hosts deny = 172.16.8.                  #Deny every access from 172.16.8.
        [myshare]
            comment = Jmilk share driectory
            path = /tmp/myshare      #share dir with /tmp/myshare
            browseable = yes
            guest ok = no
            valid users = jmilk,@jmilkGroup
            writable = yes
            write list = jmilk,@jmilkGroup
            create mode = 0644
            public = no
            directory mode = 0755
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

**Step3.**change the permission for share directory

chmod 757 /tmp/myshare     #ensure the share directory have writable permissions
  • 1
  • 1

Step4. Create samba user in local, and setting not support login the OS for samba user. 
Precondition:samba userName have to the same as OS userName.

useradd -M -s /sbin/nologin jsamba
pdbedit -a -u jsamba
        #-a create
        #-u userName
smbpasswd jsamba    #change the password for samba user
pdbedit -Lv jsamba  #list samba user detailed info
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

Step4. Start samba service

service smbd restart
  • 1
  • 1

Access the samba shareDirectory from other linux OS

Samba Server:Linux 
Samba Client:Linux 
Step1. List the share directory

smbclient -L SambaServerIP
  • 1
  • 1

Step2. Login the samba server’s share directory 
1.Anonymous user login

smbclient //sambaServerIP/shareDirectoryName
            #get --> download the file into local from samba server.
            #put --> upload the file into samba server from local
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

2.Samba user authentication login

smbclient //sambaServerIP/shareDirectoryName -u sambaUserName
mount -o userName=jsamba,passwd fanguiju //sambaServerIP/shareDirectory /mnt
  • 1
  • 2
  • 1
  • 2

Access the windows OS samba shareDirectory from Linux

**Samba Server**Windows 
Samba Client:Linux 
Step1.

smbclient -L sambaServerIP -u administrator   #login sambaServer(win) by adminstrator identity
smbclient -u administrator //sambaServerIP
  • 1
  • 2
  • 1
  • 2

step2. Mount share dirctory into local

mount -o userName=administrator //sambaServerIP(wim)/d$ /mnt/winShare
  • 1
  • 1

vim /etc/fstab #realize permanent mount

Attention:在同一个可以互通的网络中,只要有一台SambaSrever,那受到此SambaServer影响的LinuxOS和windowsOS都可以实现与sambaServer之间实现文件共享。

Access the samba shareDirectory of LinuxOS by winOS

**Server:**Linux 
**Client:**Windows

Ctrl+R(run) //LinuxSambaServerIP #And then enter the user authentication 
CMD.exe command below:

net use * /del /y   #clear the user login cache

转载:http://blog.csdn.net/jmilk/article/details/50384975

时间: 2024-09-14 18:54:30

Linux_Samba详解的相关文章

详解Python中的type()方法的使用

  这篇文章主要介绍了详解Python中的type()方法的使用,是Python入门中的基础知识,需要的朋友可以参考下 type()方法返回传递变量的类型.如果传递变量是字典那么它将返回一个字典类型. 语法 以下是type()方法的语法: ? 1 type(dict) 参数 dict -- 这是字典 返回值 此方法返回传递变量的类型. 例子 下面的例子显示type()方法的使用 ? 1 2 3 4 #!/usr/bin/python   dict = {'Name': 'Zara', 'Age'

【转】java枚举使用详解

在实际编程中,往往存在着这样的"数据集",它们的数值在程序中是稳定的,而且"数据集"中的元素是有限的. 例如星期一到星期日七个数据元素组成了一周的"数据集",春夏秋冬四个数据元素组成了四季的"数据集". 在Java中如何更好的使用这些"数据集"呢?因此枚举便派上了用场,以下代码详细介绍了枚举的用法. Java代码   package com.ljq.test;      /**   * 枚举用法详解   *

状态模式(state pattern) 详解

状态模式(state pattern): 允许对象在内部状态改变时改变它的行为, 对象看起来好像修改了它的类. 建立Context类, 包含多个具体状态(concrete state)类的组合, 根据状态的不同调用具体的方法, state.handle(), 包含set\get方法改变状态. 状态接口(state interface), 包含抽象方法handle(), 具体状态类(concrete state)继承(implement)状态类(state), 实现handle()方法; 具体方法

kafka详解一、Kafka简介

背景:      当今社会各种应用系统诸如商业.社交.搜索.浏览等像信息工厂一样不断的生产出各种信息,在大数据时代,我们面临如下几个挑战: 如何收集这些巨大的信息 如何分析它        如何及时做到如上两点      以上几个挑战形成了一个业务需求模型,即生产者生产(produce)各种信息,消费者消费(consume)(处理分析)这些信息,而在生产者与消费者之间,需要一个沟通两者的桥梁-消息系统.      从一个微观层面来说,这种需求也可理解为不同的系统之间如何传递消息. Kafka诞生

Cocos2d-x win7 + vs2010 配置图文详解

Cocos2d-x win7 + vs2010 配置图文详解(亲测)   下载最新版的cocos2d-x.打开浏览器,输入cocos2d-x.org,然后选择Download,本教程写作时最新版本为cocos2d-1.01-x-0.9.1,具体下载位置如下图: 下载完之后,解压到当前文件夹.我把下载的程序放在F盘根目录,解压完毕之后,双击打开文件夹,看看里面有什么东西,红圈部分就是我们要安装使用的文件: 接下来,我们正式安装cocos2d-x到win7中去. 首先,双击上图中的cocos2d-w

ip-《TCP/IP 详解卷一》中90页中讲到,“由于子网号不相同,代理ARP不能使用”,这怎么理解?

问题描述 <TCP/IP 详解卷一>中90页中讲到,"由于子网号不相同,代理ARP不能使用",这怎么理解? <TCP/IP 详解卷一>中90页中讲到,"由于子网号不相同,代理ARP不能使用",这怎么理解? 解决方案 ARP主要用在一个子网中,用MAC地址来通信.数据链路层 不同子网,需要通过三层路由 解决方案二: 比如 N1 <-> GW <-> N2,N1和N2是同一个子网,GW上开启arp代理的效果是,N1和N2上

JS表格组件神器bootstrap table详解(基础版)_javascript技巧

一.Bootstrap Table的引入 关于Bootstrap Table的引入,一般来说还是两种方法: 1.直接下载源码,添加到项目里面来. 由于Bootstrap Table是Bootstrap的一个组件,所以它是依赖Bootstrap的,我们首先需要添加Bootstrap的引用. 2.使用我们神奇的Nuget 打开Nuget,搜索这两个包 Bootstrap已经是最新的3.3.5了,我们直接安装即可. 而Bootstrap Table的版本竟然是0.4,这也太坑爹了.所以博主建议Boot

网页文字该多大?文字字号详解

网页|详解 文字在网页上的应用: (只看小标题您就能知道这一部分要说什么了,为了避免罗嗦,在此文发布前决定把此处300余字删除,只保留了下面这一句.) 对于一个设计的好的网站来说,用户浏览时间最长的是文章正文. 中文网页文字的现状: 中文网页普遍使用12px和14px的宋体(simsun),这两种文字都可以加粗(font-weight: bold).这个规范似乎也成了网页设计师的基本 常识. 中国的网页设计师有这4种可供选择的文字表现方式,仅仅是4种,只有这4种,4种很小的文字.其中12px的宋

php-fpm配置详解

 这篇文章主要介绍了php-fpm配置详解,需要的朋友可以参考下 php5.3自带php-fpm   代码如下: /usr/local/php/etc/php-fpm.conf     pid = run/php-fpm.pid pid设置,默认在安装目录中的var/run/php-fpm.pid,建议开启   error_log = log/php-fpm.log 错误日志,默认在安装目录中的var/log/php-fpm.log   log_level = notice 错误级别. 可用级别