SIGN IN / UP
    opened image

    Samba is an open source software suite that provides file and print services for Windows, Linux, and macOS clients. It allows Linux based servers to share files and printers with Windows based clients and vice versa. In this article, we'll show you how to set up a Samba server on Linux and connect to it from Windows Server 2019.

    Installing Samba on Linux
    You can use your distribution's package manager to install Samba on a Linux server. For example, if you are using Ubuntu or Debian, you can install Samba by running the following command in a terminal:

    sudo apt-get install samba

    If you are using CentOS or Red Hat Enterprise Linux, you can install Samba by running the following command:

    sudo yum install samba

     

    Once the installation is complete, you can start the Samba service by running the following command:

    sudo systemctl start smbd

    Setting up Samba
     

    The Samba configuration file is located in /etc/samba/smb.conf. You can modify this file to define the shares you want to make available to Windows clients.

    To create a new share, add the following section to the smb.conf file:

    [share_name]
    comment = Share description
    path = /path/to/share
    browsable = yes
    guest ok = no
    read only = no
    create mask = 0755
    directory mask = 0755

    Replace share_name with the name of the share and //path/to/share with the path to the directory you want to share.

    The comment field is an optional description of the share that will be displayed to users. The browsable field specifies whether the share is visible on the Windows network. The guest ok field allows anonymous access to the share if set to yes, and read only specifies whether clients can modify files in the share or not.

    The create mask and directory mask fields indicate the default permissions for new files and directories created on the share.

    After making changes to the smb.conf file, you can check the configuration by running the following command:

    sudo testparm

    This command will check the smb.conf file for errors and print the current Samba configuration.

     

    We also restart the smb service if the data is not pulled up:

    systemctl restart smbd

    Creating Samba Users

    Samba uses its own user database, which is separate from the system user database. To create a new Samba user, run the following command:

    sudo smbpasswd -a username

    Replace username with the username you want to create. When you run this command, you will be put into password entry mode for the user.

    But before that, you need to create a UNIX user that you want to add. Let's use the command:

    useradd user1

    Where user1 is the user we want to add for Samba.

     

    Connecting to a Samba server from Windows Server 2019

    To connect to a Samba server from Windows Server 2019, follow these steps:

    1. Open File Explorer on Windows Server 2019.
    2. Right-click on an empty area of the window and select "Network Connection".
    3. Enter the address of the Samba server in the address bar in the format \\server_address, replacing server_address with the IP address or name of the Samba server.
    4. Press "Enter". If you have set up anonymous access to a share, you can access it without authentication. Otherwise, Windows will ask you to enter the username and password you created on the Samba server.
    5. Once connected to a Samba server, you can view shares and work with files and folders as if they were on a local drive.

    Conclusion

    Samba is a powerful tool for sharing files and printers between Linux based servers and Windows based clients. Setting up a Samba server on Linux may require some knowledge of network protocols and configuration, but in general it is a fairly simple process. Connecting to a Samba server from Windows Server 2019 requires minimal configuration and allows you to work with shares on the Samba server as if they were local.