实例:

    常用的共享目录选项:

        [SHARENAME] 共享名

        comment =

        path = 

        borwseable =

        public =

        read only =

        writable =

        write list =  

        valid users =  

        invalid users = 

     


    1.将/share/test共享为tools,允许所有人访问,目录可写


        #vim /etc/samba/smb.conf

            [tools]

            comment = some tools

            path = /share/test

            browseable = yse

            public = yes

            writable = yse


    2.将系统用户添加为samba账号

        #useradd smbuser 创建用户

        #passwd smbuser  创建密码

        #smbpasswd -a smbuser 将smbuser添加为samba账户

            new smb password samba密码


    3.修改smbuser对/share/test的权限

        此时smbuser对tools还没有写权限,因为只在smb.conf中定义,smbuser对系统文件没有写权限。

        #setfacl  -m u:smbusder:rwx /share/test


    4.访问windows共享,假设ip为172.16.100.66,共享目录名为test2,用户名为shareman

        #smbclient  //172.16.100.66/test2  -U shareman

        smb:\>


    5.访问linux共享,假设ip为172.16.100.1,共项目名为tools,用户名为smbuser

        #smbclient //172.16.100.1/tools -U smbuser

        smb:\>


    6.查看某个服务器上的共享

        #smbclient -L 172.16.110.66


    7.将服务器的共项目录tools挂在到本机/share下,假设ip为172.16.100.1,用户名为smbuser

        #mount -t cifs //172.16.100.1/tools  /share -o username=smbuser


    8.开机自动挂载共享

        #vim /etc/fstab

            //172.16.100.1/tools /share cifs credentials /etc/samba/smbupwd 0 0

        #vim /etc/samba/smbupwd

            username=smbuser

            password=smbuser

        #chmod o=--- /etc/samba/smbupwd

        #chown root:root /etc/samba/smbupwd


    9.修改配置文件,要求如下:共享目录tools,开放给组smbgrp读写权限,其他用户只有读权限。

        #vim /etc/samba/smb.conf

            [tools]

            comment = some tools

            path = /share/test

            browseable = yse

            public = yes

            write list = @smbgrp


        #setfacl -m g:smbgrp:rwx /share/test


    10.基于ip的访问控制

        服务器ip为 172.16.100.1,允许172.16.100.66和192.168网段访问

        #vim /etc/samba/smb.conf

            host allow = 172.16.100.66 192,168.