Young Woman Writing Software Code
Image: Seventyfour/Adobe Stock

I’ve been working with Linux since 1997, and it’s been a rare occasion that I don’t take advantage in one way or another of Samba file sharing. With Samba, I can easily create and manage shares that are accessible to those on my LAN. After this many years of working with Samba, creating those shares is pretty much an “I can do that in my sleep” affair.

That doesn’t mean I always want to turn to the command line to handle the task. And recently I discovered an incredibly simple method of managing Samba shares — one that I’ll most likely default to in the future. That method is via the Cockpit web-based management tool.

This feature isn’t found in Cockpit by default, but it’s very easy to install and use. And that’s exactly what I’m going to show you. Let’s get to the installation and sharing.

SEE: 40+ open source and Linux terms you need to know (TechRepublic Premium)

What you’ll need

To use Cockpit for Samba shares, you’ll need a Linux machine (server or desktop) with Cockpit up and running. If you’re using an RHEL-based distribution, Cockpit is already installed and just needs to be enabled with the command sudo systemctl enable --now cockpit.socket.

If you’re using a Ubuntu server or desktop, you’ll need to first install Cockpit. Follow my instructions in How to install Cockpit on Ubuntu 22.04 for better server management. You’ll also need Samba installed on your hosting server.

With all of that ready, let’s add Samba support to Cockpit.

How to configure Samba

Before we install the necessary software, let’s configure Samba so it can work with Cockpit. This is quite simple. Log in to (or SSH in to) your hosting server and open the Samba configuration file with:

sudo nano /etc/samba/smb.conf

In the [global] section, add the following:

include = registry

Save and close the file. Restart Samba with:

sudo systemctl restart smbd

How to install the Cockpit File Sharing application

Next, we must install a third-party file-sharing application. Back at the terminal window of your hosting machine, add the 45Drives repo with:

curl -sSL https://repo.45drives.com/setup | sudo bash

You can then install the application with:

sudo apt-get install cockpit-file-sharing -y

If you’re on a machine that uses the dnf package manager — such as RHEL, AlmaLinux or Rocky Linux — you can install it with the following command:

sudo dnf install https://github.com/45Drives/cockpit-file-sharing/releases/download/v3.2.0/cockpit-file-sharing-3.2.0-1.el8.noarch.rpm

When that completes, refresh Cockpit and you see a new File Sharing entry in the left navigation (Figure A).

Figure A

Our file sharing application has been successfully installed.

How to create a new Samba share in Cockpit

Click File Sharing in the left navigation. In the resulting window (Figure B), click + to the right of Global Config.

Figure B

The Cockpit File Sharing section makes it simple to manage your shares.

In the pop-up window (Figure C), configure the share exactly as you need, making sure to select either valid users/groups who will have access to the share.

Figure C

Creating a new Samba share in Cockpit is mostly a point-and-click affair now.

Note that the users are taken from those found in the Accounts section of Cockpit, so if you haven’t added users yet, you’ll want to do so before creating a new Share.

Also note that before a user can access a Samba share to which they’ve been assigned, you must first set a Samba password for that user. To do that, select the user from the drop-down (under User Management) and click Set Samba Password. You’ll be prompted to type and verify the Samba password for that user (Figure D).

Figure D

Setting a Samba password for the user “olivia.”

If you don’t set a Samba password, the user will not have access to the shares, even though you’ve assigned them privileges.

As far as Groups are concerned, those are created and configured within the File Sharing section itself.

Once you’ve created the share, it should be accessible from any machine on your LAN. How your users access the share will depend on the platform they used.

And that’s how easy it is to create a new Samba share with the help of Cockpit. Once you get the hang of creating shares this way, you won’t want to go back to the command line.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays