Linux with coffee
Image: MohamadFaizal/Adobe Stock

Ubuntu 22.04 (Jammy Jellyfish) has arrived, and it offers plenty of exciting new features that are sure to win over hardcore Linux users as well as those new to the world of open source. As usual, the developers of Ubuntu have gone out of their way to make everything not only “just work” but do so with ease.

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

Case in point: the sharing of directories to your LAN. This is one area where Ubuntu has always been heads above the competition. In fact, you’d be hard-pressed to find a Linux distribution that makes sharing folders as easy as Ubuntu.

And that’s exactly what I’m going to show you how to do … share a directory to your LAN, so other users can access the contents within.

What you’ll need

To make this work, you’ll need a running instance of Ubuntu Desktop 22.04 that is connected to a local area network (LAN). That’s it, let’s get to work.

How to share a directory to the LAN using Ubuntu

Log into your instance of Ubuntu Desktop 22.04 and then open the File Manager application. Right-click the Public folder and select Local Network Share (Figure A).

Figure A

Sharing the Public folder to your LAN can be done through the right-click context menu in the File Manager application.
Sharing the Public folder to your LAN can be done through the right-click context menu in the File Manager application.

In the resulting popup (Figure B), click the checkbox for Share This Folder.

Figure B

The Folder Sharing options for the Public folder.
The Folder Sharing options for the Public folder.

Because Ubuntu Desktop 22.04 doesn’t ship with Samba pre-installed, you’ll be prompted to install the Windows networks sharing service. Click Install Service (Figure C).

Figure C

Installing the sharing service is but a click away.
Installing the sharing service is but a click away.

When prompted, click Install again and, if prompted, type your user password. After the installation completes, Samba will be running, and you can continue configuring the share. Give the share a name, an optional comment and then set the permissions. If you want other users to be able to create and share files within the directory, click the checkbox associated with that option. If you are the only user on that desktop machine, you’ll need to grant Guest access to the share.

After configuring everything, click Create Share, and you’re done. Do note: If you grant access to other users to create and share files, or give access to guests, you’ll be prompted to allow the system to automatically set the permission (which you should allow).

Troubleshooting sharing with Ubuntu

If you find that users are unable to access the share, the problem is that the GUI tool isn’t capable of adding a Samba password for the system to use. This is one of those sticking points that has troubled Ubuntu for some time. However, the fix for this is quite simple. All you need to do is open a terminal window and issue the command:

sudo smbpasswd -a USER

Where USER is the name of the user account on your system.

What’s kind of annoying about this hiccup is that it might well prevent guest access. Because of that, if you want to share the folder with anyone, you’ll need to create a guest account. You can go back to the terminal window and add the user with the command:

sudo adduser guest

Answer the necessary questions (giving the guest user a strong password). Once you’ve created the user, you’ll then need to add them with the smbpasswd command like so:

sudo smbpasswd -a guest

Follow this with the command:

sudo smbpasswd -e guest

At this point, you could give the guest credentials to anyone who needs access to that Public folder, and they should be able to reach it from any machine on your LAN.

If that doesn’t work, you’ll need to add the share to the Samba configuration file. Open that file with the command:

sudo nano /etc/samba/smb.conf

In that file, add the following to the bottom:

[Public]
path = /home/USER/Public
browsable = yes
writable = yes
read only = no

Where USER is your user name. Save and close the file.

And if that doesn’t grant access to other registered users, you might have to add the guest account to the group associated with the share. Say, for example, the share is found in /home/jack/Public (which means it is owned by user/group jack. You could add the guest account to the jack group with the command:

sudo usermod -aG jack guest

After that, any user that belongs to the group jack should be able to access the Public directory that has been shared to the LAN.

I would love to see, in future releases of Ubuntu (or any desktop Linux release), a much more simplistic approach to successfully sharing directories to a LAN without having to go through all of the extra troubleshooting steps.

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