Register now for better personalized quote!

How to create Samba share on Linux for guests to access on your network

Oct, 03, 2023 Hi-network.com
Mihaita Costin/500px/Getty Images

Samba is a great way to share folders from your Linux desktop with other users on your network. For example, you might have documents that others need to access -- or perhaps you have photos, video, or just about any type of file to share. Samba makes it possible to share those files and folders to any device on your network and do so with a required username and password. 

I've already explained how Samba can be set up in this way. But this time around I want to demonstrate how you can create a share thatdoesn'trequire a username or password for users to access, so you can make those files available to anyone connected to your network.

Also: Two tricks that make using the Linux command line a lot easier

One thing to keep in mind is that you should never share files with sensitive information in this way. For those types of files you want to ensure your shares are set up for authentication; otherwise, that sensitive information could wind up in the wrong hands. In other words, use caution when doing this.

Before you jump into creating the guest folder, make sure to read through the piece linked above, so you can get Samba installed and understand how it works. In that piece, you create a password-protected share that can only be accessed by those who have accounts on the machine sharing the directory.

Once you're familiar with Samba, it's time to create the guess-accessible directory.

How to create your guest share with Samba

What you'll need:To make this work, you'll need a Linux machine running Samba and a user with sudo privileges. That's it. Let's get to work.

1. Create a new directory

The first thing we'll do is create the directory that will house the files/folders accessible by guests on your network. To do that, open your terminal window and issue the following command:

sudo mkdir /home/share

2. Give the folder the proper permissions

We now must change the permissions for the folder, such that anyone can access it with the command:

3. Open the Samba configuration file

Next, we need to open the Samba configuration file with the following command:

sudo nano /etc/samba/smb.conf

Also: How to share a printer on Linux with CUPS and Samba

4. Configure the network interface

Since we're making this share available to anyone, we want to lock down Samba such that it's only accessible from your internal network. To do this, you must change two lines. Before doing this, you must locate the name associated with your network interface, which can be done with the command:

ip a

You should see a name for that interface, such as enp0s3.

The first thing you must change is this:

; interfaces = 127.0.0.0/8 eth0

Change that to:

interfaces = 127.0.0.0/8 NAME

Where NAME is the name of your network interface.

Next, locate the following line:

; bind interfaces only = yes

Change that to:

bind interfaces only = yes

5. Add the share

At the bottom of the smb.conf file, add the following:

[public]path = /home/sharepublic = yesguest only = yeswritable = yesforce create mode = 0666force directory mode = 0777browseable = yes

The above configuration defines the path to the share; makes it public, guest only, and writable; sets the permission mode for file creation and directories; and makes it browsable.

Also: Linux distro hopping is a fun way to find the perfect desktop operating system

Save and close the file with the Ctrl+X key combination.

6. Restart Samba

Finally, you can restart Samba so the guest share takes effect. To do that, issue the command:

sudo systemctl restart smbd

Once Samba has restarted, you should be able to access that share as a guest, without having to type a username or password. 

This is a great way to allow any user on your network access to a specific directory. Just remember not to add sensitive files to that location; otherwise, they could wind up in the wrong hands.

Linux

The best Linux laptops for consumers and developersWant to save your aging computer? Try these 5 Linux distributionsThe best distros for beginnersHow to enable Linux on your Chromebook (and why you should)
  • The best Linux laptops for consumers and developers
  • Want to save your aging computer? Try these 5 Linux distributions
  • The best distros for beginners
  • How to enable Linux on your Chromebook (and why you should)

tag-icon Hot Tags : Tech Our process Services & Software Operating Systems LINUX

Copyright © 2014-2024 Hi-Network.com | HAILIAN TECHNOLOGY CO., LIMITED | All Rights Reserved.