分享

windows访问linux共享文件夹

 罔鸟 2022-06-08 发布于广东

1.windows的网上邻居,是通过smb协议来共享信息的,如果需要给访问linux上的共享目录被windows访问到,需要linux有smb协议

sudo apt-get install samba #安装samba服务
   sudo apt-get install smbfs #安装smbfs服务

2.安装好服务后,启动服务

harvey@harvey:/etc/samba$ service smbd restart 
stop: Rejected send message, 1 matched rules; type="method_call", sender=":1.26" (uid=1000 pid=2707 comm="stop smbd ") interface="com.ubuntu.Upstart0_6.Job" member="Stop" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init ")
start: Rejected send message, 1 matched rules; type="method_call", sender=":1.27" (uid=1000 pid=2701 comm="start smbd ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init ")
harvey@harvey:/etc/samba$ sudo vim smb.conf

3.在服务器端CTR+R 输入\IP 地址,发现可以正常连接到共享主机了,但是发现没有共享文件夹。所以现在需要在/etc/samba/smb.conf添加共享目录。

4.首先运行testparm来查看配置的信息

harvey@harvey:~$ testparm #运行testparm 查看配置
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[harveyLinux]"
Processing section "[printers]"
Processing section "[print$]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions #查看服务器所有配置

[global]
    server string = %h server (Samba, Ubuntu)
    map to guest = Bad User
    obey pam restrictions = Yes
    pam password change = Yes
    passwd program = /usr/bin/passwd %u
    passwd chat = *Entersnews*spassword:* %n
 *Retypesnews*spassword:* %n
 *passwordsupdatedssuccessfully* .
    unix password sync = Yes
    syslog = 0
    log file = /var/log/samba/log.%m
    max log size = 1000
    dns proxy = No
    usershare allow guests = Yes
    panic action = /usr/share/samba/panic-action %d
    idmap config * : backend = tdb

[harveyLinux]            #修改默认的文件夹这里是共享的文件夹的名称
    path = /home/harvey             #共享文件夹的路径
    read only = No                   #可读可写
    guest ok = Yes                       #可以通过访客访问

[printers]
    comment = All Printers
    path = /var/spool/samba
    create mask = 0700
    printable = Yes
    print ok = Yes
    browseable = No

[print$]
    comment = Printer Drivers
    path = /var/lib/samba/printers

5.以上红色的部分就是要共享文件需要添加(或者叫更改)的数据内容.

6.为了让window可以操作共享的文件夹,需要修改权限

harvey@harvey:/home$ chmod 777  harvey/ -R
harvey@harvey:/home$ ls -l
total 4
drwxrwxrwx 7 harvey harvey 4096 Apr  7 12:44 harvey

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多