folder shareing between ubuntu16 and windows

发布时间:2020-07-23 22:57:05 作者:lhjdark
来源:网络 阅读:208

//linux rw windows share folder

  1. temporary mount, lose this mount point if restart

sudo mkdir /home/sharefolder

sudo mount -t cifs -o username=username,password=pwd //ip/sharefoldername /home/sharefolder


2. auto mount point when system start

sudo gedit /etc/fstab

add 2 line:

//ip/sharename /home/sharefolder cifs defaults,username=usrname,password=share 0 2

or(if everyone is ok)

//ip/sharename /home/sharefolder cifs defaults  0 2 

//ip/sharename /home/sharefolder nfs defaults  0 2


3.smbclient

sudo apt-get install smbclient

smbclinet --user=username //ip/sharename

Enter share's password:(enter password)

//operae like ftp command

smb:/>help

exit get getfacl geteas hardlink help history iosize lcd link

smb:/help command    //details



//windows rw linux share folder

//install samba ,ubuntu16 share folder for windows user

sudo apt-get install samba

sudo apt-get install smbclient

sudo mkdir -p /home/sharefolder

sudo chmod 777 /home/sharefolder //sharefolder permissions. default is 755 . Owner can write only

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak   //backup before edit

sudo gedit /etc/samba/smb.conf  


//config smb.conf

usershare owner only = false      //add this line after Global Setting 

//add follow at bottom of smb.conf

[sharefolder]

    path = /home/sharefolder

    browseable = yes

    write = yes

    public = yes

    comment = smb share folder test


//restart samba service

sudo service smbd restart


//client test

smbclient -L //localhost/sharefolder   //linux client test

\\ip\sharefolder     //windows client test


//User access control

sudo useradd username    //a1 , a2 , b1, b2 , c1,c2

sudo groupadd groupname   //aa, bb, cc

sudo usermod -g groupname username   //(a1,a2->aa)(b1,b2->bb)(c1,c2->cc)

sudo mkdir /home/share/foldera    //foldera,folderb,folderc folderd,foldere

sudo chomd 777 /home/share/*

sudo gedit /etc/samba/smb.conf

[sharefoldera]

    comment=sharefoldera,(r)a1,b1,@aa,(w)@aa

    path=/home/share/foldera

    public=no

    valid users= a1,b1,@aa

    write list = @aa

[sharefolderb]

    comment=sharefolderb,(r)a1,@cc,@bb(w)@bb

    path=/home/share/folderb

    public=no

    valid users= a1,@cc,@bb

    write list = @bb

[sharefolderc]

    comment=sharefolderc,(r)@bb,@cc(w)@cc

    path=/home/share/folderc

    public=no

    valid users = @bb,@cc

    write list = @cc

[sharefolderd]

    comment=sharefolderd,all users read only

    path=/home/share/folderd

    public = yes

    readonly = yes

[sharefoldere]

    comment=sharefoldere,(rw)all user

    path=/home/share/foldere

    public = yes

    writable = yes


//share folder configuration 

[share] # 该共享的共享名

        comment = smb share test # 该共享的备注

        path = /home/share # 共享路径

        allow hosts = host(subnet) # 设置该Samba服务器允许的工作组或者域

        deny hosts = host(subnet) # 设置该Samba服务器拒绝的工作组或者域

        available = yes|no # 设置该共享目录是否可用

        browseable = yes|no # 设置该共享目录是否可显示

        writable = yes|no # 指定了这个目录缺省是否可写,也可以用readonly = no来设置可写

        public = yes|no # 指明该共享资源是否能给游客帐号访问,guest ok = yes其实和public = yes是一样的

        user = user, @group # user设置所有可能使用该共享资源的用户,也可以用@group代表group这个组的所有成员,不同的项目之间用空格或者逗号隔开

        valid users = user, @group # 指定能够使用该共享资源的用户和组

        invalid users = user, @group # 指定不能够使用该共享资源的用户和组

        read list = user, @group # 指定只能读取该共享资源的用户和组

        write list = user, @group # 指定能读取和写该共享资源的用户和组

        admin list = user, @group # 指定能管理该共享资源(包括读写和权限赋予等)的用户和组

        hide dot files = yes|no # 指明是否像UNIX那样隐藏以“.”号开头的文件

        create mode = 0755 # 指明新建立的文件的属性,一般是0755

        directory mode = 0755 # 指明新建立的目录的属性,一般是0755

        sync always = yes|no # 指明对该共享资源进行写操作后是否进行同步操作

        short preserve case = yes|no # 指明是否区分文件名大小写

        preserve case = yes|no # 指明是否保持大小写

        case sensitive = yes|no # 指明是否对大小写敏感,一般选no,不然可能引起错误

        mangle case = yes|no # 指明混合大小写

        default case = upper|lower # 指明缺省的文件名是全部大写还是小写

        force user = testuser # 强制把建立文件的属主是谁。如果我有一个目录,让guest可以写,那么guest就可以删除,如果我用force user= testuser强制建立文件的属主是testuser,同时限制create mask = 0755,这样guest就不能删除了

        wide links = yes|no # 指明是否允许共享外符号连接,比如共享资源里面有个连接指向非共享资源里面的文件或者目录,如果设置wide links = no将使该连接不可用

        max connections = 100 # 设定最大同时连接数

        delete readonly = yes|no # 指明能否删除共享资源里面已经被定义为只读的文件




推荐阅读:
  1. samba共享目录及多台客户端挂载
  2. 跟小段一起学Solaris(16)---Samba文件共享

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

samba fstab etc

上一篇:hbase删除表报错的解决方法

下一篇:1.3 开发第一个Android应用

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》