系统城装机大师 - 固镇县祥瑞电脑科技销售部宣传站!

当前位置:首页 > 系统教程 > Linux教程 > 详细页面

installation and configuration of Samba on Ubuntu.

时间:2020-09-06来源:www.pcxitongcheng.com作者:电脑系统城

https://ubuntu.com/server/docs/samba-file-server

File Server

One of the most common ways to network Ubuntu and Windows computers is to configure Samba as a File Server. This section covers setting up a Samba server to share files with Windows clients.

The server will be configured to share files with any client on the network without prompting for a password. If your environment requires stricter Access Controls see Securing File and Print Server.

Installation

The first step is to install the samba package. From a terminal prompt enter:

sudo apt install samba

That’s all there is to it; you are now ready to configure Samba to share files.

Configuration

The main Samba configuration file is located in /etc/samba/smb.conf. The default configuration file has a significant number of comments in order to document various configuration directives.

Note

Not all the available options are included in the default configuration file. See the smb.conf man page or the Samba HOWTO Collection for more details.

First, edit the following key/value pairs in the [global] section of /etc/samba/smb.conf:

   workgroup = EXAMPLE
   ...
   security = user

The security parameter is farther down in the [global] section, and is commented by default. Also, change EXAMPLE to better match your environment.

Create a new section at the bottom of the file, or uncomment one of the examples, for the directory to be shared:

[share]
    comment = Ubuntu File Server Share
    path = /srv/samba/share
    browsable = yes
    guest ok = yes
    read only = no
    create mask = 0755
  • comment: a short description of the share. Adjust to fit your needs.

  • path: the path to the directory to share.

    This example uses /srv/samba/sharename because, according to the Filesystem Hierarchy Standard (FHS)/srv is where site-specific data should be served. Technically Samba shares can be placed anywhere on the filesystem as long as the permissions are correct, but adhering to standards is recommended.

  • browsable: enables Windows clients to browse the shared directory using Windows Explorer.

  • guest ok: allows clients to connect to the share without supplying a password.

  • read only: determines if the share is read only or if write privileges are granted. Write privileges are allowed only when the value is no, as is seen in this example. If the value is yes, then access to the share is read only.

  • create mask: determines the permissions new files will have when created.

Now that Samba is configured, the directory needs to be created and the permissions changed. From a terminal enter:

sudo mkdir -p /srv/samba/share
sudo chown nobody:nogroup /srv/samba/share/

Note

The -p switch tells mkdir to create the entire directory tree if it doesn’t exist.

Finally, restart the samba services to enable the new configuration:

sudo systemctl restart smbd.service nmbd.service

Warning

Once again, the above configuration gives all access to any client on the local network. For a more secure configuration see Securing File and Print Server.

From a Windows client you should now be able to browse to the Ubuntu file server and see the shared directory. If your client doesn’t show your share automatically, try to access your server by its IP address, e.g. \\192.168.1.1, in a Windows Explorer window. To check that everything is working try creating a directory from Windows.

To create additional shares simply create new [dir] sections in /etc/samba/smb.conf, and restart Samba. Just make sure that the directory you want to share actually exists and the permissions are correct.

Note

The file share named “[share]” and the path /srv/samba/share are just examples. Adjust the share and path names to fit your environment. It is a good idea to name a share after a directory on the file system. Another example would be a share name of [qa] with a path of /srv/samba/qa.

Resources


What Doesn't Kill Me Makes Me Stronger
分享到:

相关信息

  • linux 文件权限怎么解析

    常用权限linux系统内有档案有三种身份 u:拥有者 g:群组 o:其他人这些身份对于文档常用的有下面权限:r:读权限,用户可以读取文档的内容,如用cat,more查看w:写权限,用户可以编辑文档x...

    2024-07-07

  • 如何使用WPSeku找出 WordPress 安全问题?

    然而,如果我们遵循通常的 WordPress 最佳实践,这些安全问题可以避免。在本篇中,我们会向你展示如何使用 WPSeku,一个 Linux 中的 WordPress 漏洞扫描器,它可以被用来找出你安装...

    2024-07-03

系统教程栏目

栏目热门教程

人气教程排行

站长推荐

热门系统下载