1. 程式人生 > >linux共享文件夾Samba

linux共享文件夾Samba

samba共享

一、服務端

1.安裝samba軟件包

yum -y install samba

2.添加samba賬號

useradd -s /sbin/nologin harry

pdbedit -a harry //輸入2次密碼

3.修改配置

vim /etc/samba/smb.conf

在末行添加

[common]

path = /common


二、客戶端

  1. 安裝客戶端軟件:smb-client

  2. 查看服務端共享的文件夾:smbclient -L //172.25.0.11 密碼不輸入,直接按回車

  3. 命令行查看:smbclient -U harry //172.25.0.11/common

    註意,這裏selinux阻止了查看和讀寫權限,需要設置

    [root@server0 ~]# getsebool -a | grep samba

    samba_export_all_ro --> on

    samba_export_all_rw --> on

一般使用掛載查看:所需要的軟件包:cifs-utils

_netdev :開啟網絡服務後再掛載該設備

修改配置文件:

vim /etc/fstab

//172.25.0.11/common /mnt/samba cifs user=zsq,pass=123,_netdev 0 0

驗證:

mount -a

df -h

如果要設置讀寫,則在服務端samba.conf後面加上

write list = zsq

然後再設置zsq的本地讀寫權限,建議使用setfacl

####################################

multiuser多用戶訪問

客戶端修改配置文件:

//172.25.0.11/common /mnt/samba cifs user=zsq,pass=123,_netdev,multiuser,sec=ntlmssp 0 0

重新掛載

umount /mnt/samba

mount -a

驗證:

su - student

cd /mnt/samba

cifscreds add -u zsq 172.25.0.11 輸入密碼

touch c.txt



linux共享文件夾Samba