Samba Server

This tutorial describes how to enable simple file sharing on a system running Clear Linux* OS and how to access the share from clients on other operating systems.


Set up file sharing

  1. Add the samba bundle, which includes the Samba binaries.

    sudo swupd bundle-add samba
  2. Create the /etc/samba directory.

    sudo mkdir /etc/samba
  3. Create a configuration file named /etc/samba/smb.conf. In this simple example, [SharedDrive] enables a folder share located in /home/clear/mysharedrive granting users samba-user-1 and samba-user-2 access.

    If valid users is not specified, then anyone with a user account on the machine and with their Samba password already set can access the folder. However, the account is only able to access files and folders for which they have appropriate permissions.

    For more advanced sharing, refer to the Samba guide.

    map to guest = Bad User
    read only = no
    guest ok = no
    browsable = yes
    valid users = samba-user-1 samba-user-2
  4. Start the Samba service and set it to start automatically on boot.

    sudo systemctl enable --now smb
  5. Verify the service started properly.

    sudo systemctl status smb
  6. Use smbpasswd to add the initial password for the user account to access the share. Be aware that Samba maintains its own list of passwords for user accounts. The Samba password list can be different from the password used to log in.

    For example:

    sudo smbpasswd -a samba-user-1

Access the shared drive

Depending on your operating system, connect to the shared drive using one of the methods belows:

  • On Clear Linux OS:

    1. Add the samba bundle.

      sudo swupd bundle-add samba
    2. List available shares.

      smbclient -L //<ip-address-of-smb-server>
    3. Connect to a shared drive.

      smbclient //<ip-address-of-smb-server>/<shared-drive> -U <user>
  • On Windows:

    1. Open File Explorer.

    2. Enter \<ip-address-of-samba-server><shared-drive> in the URL field. See Figure 1.

      Windows > File Explorer > Connect to Samba share

      Figure 1: Windows > File Explorer > Connect to Samba share

  • On macOS:

    1. Open the Finder.

    2. Press Command + K to open the dialog box for connecting to a server.

    3. Enter smb://<ip-address-of-samba-server>/<shared-drive>. in the URL field. See Figure 2.

      macOS > Finder > Connect to Samba share

      Figure 2: macOS > Finder > Connect to Samba share