Ubuntu Samba安装使用教程【亲测可用】

Linux samba安装使用教程

Samba是在Linux系统上实现的SMB(Server Messages Block,信息服务块)协议的一款免费软件。它实现在局域网内共享文件和打印机,是一个客户机/服务器型协议。客户机通过SMB协议访问服务器上的共享文件系统。可以实现Windows系统访问Linux系统上的共享资源
本安装教程是基于Ubuntu 14.04实测的,在Ubuntu18.04上也实测可用

 1 更新软件源列表

  • 打开“终端窗口”,输入”sudo su”->回车->”输入当前用户管理员密码”->输入” apt-get update”->回车->回车

  • 2 安装Samba

  • 打开"终端窗口",输入"apt-get install samba samba-common"–>回车–>输入"y"–>回车–>安装完成。

3 新建共享目录并设置权限

该共享目录可自行创建,一般公司使用服务器的话就会为您新建一个共享目录,而私人电脑的话,我一般就把整个home目录设置为共享目录,方便Windows下访问我的虚拟机上的文件。

1、打开"终端窗口",输入"sudo mkdir /home/share"–>回车–>共享目录share新建成功。
2、输入"sudo chmod 777 /home/share -R"–>回车,这样用户就对共享目录有了写权限。

4 修改Samba文件配置

Ubuntu上的Samba的配置文件为/etc/samba/smb.conf,该文件记录相关的规则及共享信息,是Samba非常核心的配置文件,修改前建议备份一份。

  • 1.备份Samba配置配置文件:

  • 在这里插入图片描述

  • 2.增加内容如下,首先在[global]下增加security项

  • 在这里插入图片描述

  • 3.其次在smb.conf文件的末尾添加如下配置信息并保存即可:

  •   [Ubuntu14.04]
         comment = My Share Directories
         browseable = yes
         path = /home/share/
      
      # By default, the home directories are exported read-only. Change the
      # next parameter to 'no' if you want to be able to write to them.
         read only = no	
         writable = yes
      
      # File creation mask is set to 0700 for security reasons. If you want to
      # create files with group=rw permissions, set next parameter to 0775.
         create mask = 0777
      
      # Directory creation mask is set to 0700 for security reasons. If you want to
      # create dirs. with group=rw permissions, set next parameter to 0775.
         directory mask = 0777
      
      # By default, \\server\username shares can be connected to by anyone
      # with access to the samba server.
      # Un-comment the following parameter to make sure that only "username"
      # can connect to \\server\username
      # This might need tweaking when using external authentication schemes
      ;   valid users = %S
    

    4.设置window系统登入共享文件夹的用户名和密码,其中用户名必须为Ubuntu中的用户。本例子中使用用户“smbuser”,在该过程中需要二次输入密码。
    在这里插入图片描述

  • 5.重新启动smb服务。

  • 在这里插入图片描述

  • 6.查看安装samba服务的虚拟机的ip地址,windows下需要通过该ip地址访问共享文件夹。

  • 在这里插入图片描述

  • 5 访问共享名为myshare的共享目录

  • 在"运行"窗口中输入"\192.168.88.11"–>回车–>双击打开myshare–>回车–>输入用户名和密码–>回车–>访问成功。
  • 在这里插入图片描述
  • 在这里插入图片描述
  • 在这里插入图片描述
  •  
发布了187 篇原创文章 · 获赞 5 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/aa804738534/article/details/104478357