Linux (Manjaro) 配置Samba 共享文件夹

共享文件夹可以方便的通过局域网在其他设备打开文件或播放视频,在Windows下可以直接右键共享,然而在Manjaro中默认并无此选项,我们可以自行使用Samba达到文件共享的目的。

安装软件

sudo pacman -S samba gvfs-smb thunar-shares-plugin-manjaro

Manjaro 配置

安装 manjaro-settings-samba,安装这个软件后会自动做一些配置:

sudo pacman -S manjaro-settings-samba

编辑smb配置文件 /etc/samba/smb.conf, 下面前面的部分都是自动生成的,最后一部分[m_share]是自定义的。

[global]
   workgroup = WORKGROUP
   dns proxy = no
   log file = /var/log/samba/%m.log
   max log size = 1000
   client min protocol = SMB2
   server role = standalone server
   passdb backend = tdbsam
   obey pam restrictions = yes
   unix password sync = yes
   passwd program = /usr/bin/passwd %u
   passwd chat = *New*UNIX*password* %n\n *ReType*new*UNIX*password* %n\n *passwd:*all*authentication*tokens*updated*successfully*
   pam password change = yes
   map to guest = Bad Password
   usershare allow guests = yes
   name resolve order = lmhosts bcast host wins
   security = user
   guest account = nobody
   usershare path = /var/lib/samba/usershare
   usershare max shares = 100
   usershare owner only = yes
   force create mode = 0070
   force directory mode = 0070

[homes]
   comment = Home Directories
   browseable = no
   read only = yes
   create mask = 0700
   directory mask = 0700
   valid users = %S

[printers]
   comment = All Printers
   browseable = no
   path = /var/spool/samba
   printable = yes
   guest ok = no
   read only = yes
   create mask = 0700

[print$]
   comment = Printer Drivers
   path = /var/lib/samba/printers
   browseable = yes
   read only = yes
   guest ok = no

[m_share]
   comment = MShare Directories
   path = /media/share  # 自定义要分享文件的目录 
   browseable = yes
   read only = no
   create mask = 0700
   directory mask = 0700

read only 属性设置为 no 是为了有写入文件权限

添加分享用户并设置密码

gpasswd sambashare -a username  # 将用户<username>添加到 `sambashare` 组 
smbpasswd -a username  # 设置smb分享用户的密码

启用smaba 服务

systemctl enable smb nmb
systemctl start smb nmb

参考

Manjaro 配置Samba 共享文件夹
Using Samba in your File Manager
Thunar - ArchLinux Wiki

添加新评论