Use Samba to share files between Linux and Windows
Preface
FTP and NFS have always been common methods of LAN file sharing. However, after recently accessing Samba, I learned that some users need to simplify access learning costs to meet basic permission control management requirements, and supports real-time editing and saving of files, so I understand that these requirements are difficult to meet with the previous methods, while Samba can perfectly support the above requirements, although it took some time to learn when getting started, it was easy to sort out the configuration and syntax.
One of the best ways to share Unix and Windows files
Update history
April July 11, 2015-first draft
Http://wsgzao.github.io/post/samba/
Additional reading
Samba-https://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/
SAMBA server-http://vbird.dic.ksu.edu.tw/linux_server/0370samba.php
Deployment of samba enterprise-level file servers in RHEL6.5-http://yuan2.blog.51cto.com/446689/1588085
Install samba
The installation of each platform is quite simple, skipped
Configure samba
We recommend that you properly plan the Directory and user permissions and use user groups to simplify authorization management. For more information, see
# Create a directory (example) mkdir-p/data2/smchmod-R 777/data2/sm # Add a user (example) groupadd denglinguseradd-g dengling-s/sbin/nologin denglingsmbpasswd-a dengling # back up the smb configuration file and edit cd/etc/sambacp smb. conf smb. conf. bakvi smb. conf # global parameter [global] security = share lanman auth = Yes log file =/var/log/samba/log. % m idmap config *: backend = tdb guest OK = Yes hosts allow= 127 ., 172 ., 192.168.1 ., 192.168.3. cups options = raw # shared parameter [homes] comment = Home Directories read only = No browseable = No [sheji] comment = sheji path =/data2/sm/sheji valid users = share, shenwei, xuwei, shenjiamei, humengchu, rensiqiang, yeting, tongying, jinbo, zengfanan, fengpeisi read only = No create mask = 0775 directory mask = 0775 [test] comment = sheji path =/data2/sm/test valid users = test, test2, shenwei read only = No create mask = 0775 directory mask = 0775 [q2] comment = sheji path =/data2/sm/q2 valid users = xuejia, sungaoshuai, lujingjing, huangsonghe, yefei, lvwenhan, Jing, lisuitao, sunzhen, shenwei, xuwei, Jing, humengchu, rensiqiang, yeting, tongying, jinbo, zengfanan, fengpeisi, chenye, Chen, pengnan, example, chenhong, daimengyou, example, zhoujian, fenglu, linlijun, chenshuxian, linzhimin, yanyoushan, example, example, mayushu, example, example, huangyouyang, example, huyuqing, liukui read only = No create mask = 0775 directory mask = 0775 [market] comment = sheji path =/data2/sm/market valid users = zhanghuichen, shenwei, chenye, wuailing, pengnan, liangzhixue, chenhong, daimengyou, wangxiaoshuo, xuyangjing, chenshuxian, linzhimin, caoling, guogaoyan, xiehaibo, huangyouyang, jinzhibin, huyuqing read only = No create mask = 0777 directory mask = 0775 [market_finance] comment = sheji path =/data2/sm/market_finance valid users = yangqiong, shenwei, chenye, wuailing, pengnan, liangzhixue, chenhong, daimengyou, wangxiaoshuo, xiehaibo, gaofangjie, xuyangjing, chenshuxian, linzhimin, huangyouyang, jinzhibin, huyuqing read only = No create mask = 0777 directory mask = 0775 [shenwei] comment = sheji path =/data2/sm/develop/shenwei valid users = shenwei read only = No create mask = 0777 directory mask = 0775 [qijun] comment = qj path =/data2/sm/homedir/qijun valid users = qijun read only = No create mask = 0777 directory mask = 0775 guest OK = no [wenyong] comment = sheji path =/data2/sm/develop/wenyong valid users = wenyong read only = No create mask = 0777 directory mask = 0775 [wudi] comment = sheji path =/data2/sm/develop/wudi valid users = wudi read only = No create mask = 0777 directory mask = 0775 [caijiannan] comment = sheji path =/data2/sm/develop/ caijiannan valid users = caijiannan read only = No create mask = 0777 directory mask = 0775 [comment] comment = weiduan path =/data2/sm/develop/raochao/microclient valid users = wangfeng read only = No create mask = 0777 directory mask = 0775 [raochao] comment = raochao path =/data2/sm/develop/raochao read list = wangfeng, xuwei, shenjiamei, chenxianzhe, chenye, wuailing, liuyuting, dainan write list = raochao [product] comment = product path =/data2/sm/product read only = No create mask = 0777 directory mask = 0777 [jinbo] comment = JinBo path =/ data2/sm/homedir/jinbo valid users = jinbo read only = No guest OK = No [xiaoqiang] comment = xiaoqiang path =/data2/sm/homedir/xiaoqiang valid users = xiaoqiang read only = No guest OK = No [share] comment = share path =/data2/sm/homedir/share valid users = share, market, wal, qijun, zhanghua read only = No
Start samba
# Common options [shared_name] path = # File System path browseable = {yes | no} # Can public = {yes | no} be viewed? # can be read by all users? guest OK = {yes | no} # Same as public read only = yes # read-only writeable = yes # write list = user1, user2 # Writable User List @ group, + group # writable group list valid users = # whitelist invalid users = # blacklist # Check syntax testparm # restart smb service to view Status service smb restartsmbstatus
Windows Client Access
1. Access samba on Windows
In "computer", enter \ xxx. xxx \
2. Windows disconnects samba shared connection. You cannot log out or restart it.
Enter net use */del/y in Start> RUN> CMD and press Enter.
3. Map the Linux directory shared by samba to a drive letter of Windows.
Right-click computer → ing network drive → Folder \ XX. XX \]