How to Set Up Quick and Easy File Sharing With Samba

0 0
Read Time:8 Minute, 27 Second

Use this step-by-step guide to learn how to set up Samba to create file and printer sharing to SMB/CIFS clients from a Linux server.

Samba is an incredibly powerful tool that allows you to create seamless file and printer sharing to SMB/CIFS clients from a Linux server or desktop. With Samba, you can even connect a Linux machine to a Windows Domain. But before you can tackle the more challenging aspects of Samba, you first must have it up and running.

We’re not going to deal with Windows Domain controllers yet; instead, we’ll focus on the much simpler task of joining a Windows workgroup and sharing folders to all clients on that workgroup.

Jump to:

What you will needYou don’t need much to get Samba up and running:

I’ll demonstrate this on Ubuntu Desktop 23.04, but the process works the same on most Linux distributions. First, we’ll create a folder that will allow anonymous sharing across your workgroup and then create a password-protected share.

Note: You should alter the instructions according to your distribution of choice.

How to install Samba

  • On your Linux machine, open a terminal window.
  • Install the necessary software with the command: sudo apt-get install -y samba
  • Type your sudo password, and hit Enter.
  • Allow the installation to complete.
  • Use the command sudo systemctl status smbd to check if the Samba service is started and enabled, so it will start on boot (Figure A).

Figure A

The command line will indicate whether Samba has been started and enabled.The command line will indicate whether Samba has been started and enabled.

  • If Samba is not started, use the command sudo systemctl start smbd to start it.
  • If Samba is not enabled, use the command sudo systemctl enable smbd to enable it.

That’s it — Samba will install and start.

How to configure Samba Networking: Must-read coverageThe main configuration file for Samba is /etc/samba/smb.conf. Many will advise you to back up that file and create a new file with specific contents. However, I suggest using this file, as it is better tuned for the release of Samba you’ve installed.

SEE: Discover TechRepublic Premium’s web server configuration and management policy.

1. Back up the default configuration fileTo that end, make a copy of the default configuration file, so you can safely edit the original and always have a working copy to fall back on. To back up the configuration file:

  • Issue the command: sudo cp -pf /etc/samba/smb.conf /etc/samba/smb.conf.bak
  • Now, open the /etc/samba/smb.conf file in your favorite text editor, and prepare to make some changes.
  • Look for this line: workgroup = WORKGROUP
  • Change WORKGROUP to reflect your network needs.

The next section you need to edit is way down in the Share Definitions.

2. Create a directory in Linux you want to shareBefore you configure anything with Samba, you will need to create a directory on your Linux server that you will want to share. For this example, we will use /srv/samba. To create this directory:

  • Use the command: sudo mkdir /srv/samba
  • Now, make that directory world writable and world browsable via: sudo chmod a+rwx /srv/samba
  • Go to the bottom of the file, and add the following:

[Anonymous]

path = /srv/sambabrowseable = yeswritable = yesread only = no

guest ok = yes

  • Save that file, and restart Samba with this command: sudo systemctl restart smbd

You should be able to reach those shares from any machine on your network.

3. Test the share accessSince we set that share as anonymous, users won’t have to log in to access the files and folders within. To test this, you will need the IP address of your Linux server. You can get this via the ip a command:

  • On any Windows machine on your network, browse to the shared file using File Explorer, with the syntax \\your-server-ip in the address bar and hitting the Enter key, as shown below (Figure B).

Figure B

Browse to the shared file in File Explorer on any Windows machine.Browse to the shared file in File Explorer on any Windows machine.

  • Click the Anonymous folder to access the share. Create a new file in there, and save it (Figure C).

Figure C

Create a new file to save to the shared folder.Create a new file to save to the shared folder.

  • You can then see the contents of that file from the Linux server in the /smb/samba directory (Figure D).

Figure D

The command line will preview the contents of the file saved to the Samba directory.The command line will preview the contents of the file saved to the Samba directory. Adding password-secured sharesWe’ve just added an anonymous share that anyone could access. If you want to add a folder (we’ll use /samba/shares as an example) that is password protected, follow these steps:

  • Open a terminal window on your Samba server.
  • Create a new group with the command sudo addgroup smbgrp.
  • Create a new user with the command sudo useradd shares -G smbgrp.
  • Create a Samba password for the user with the command sudo smbpasswd -a shares.
  • Type and verify a password for the user.
  • Create the folder with the command sudo mkdir -p /srv/samba-secured.
  • Change the permissions of the folder with the command sudo chmod -R 0770 /srv/samba-secured.
  • Change the ownership of the folder with the command sudo chown root:smbgrp /srv/samba-secured.
  • Now, open the /etc/samba/smb.conf file, and add the following under the Share Definitions or at the bottom of the file:

[SECURED]

path = /srv/samba-securedvalid users = @smbgrpbrowseable = yeswritable = yesread only = no

  • Save the file, and restart Samba with the command sudo service smbd restart.

You now have a password-protected Samba share ready to use. Anyone that needs access to the share will log in with username shares and the password you set when you issued the command sudo smbpasswd -a shares.

In Windows, you will be prompted to enter the credentials you created above (Figure E). Once you do, you will have access to the folder.

Figure E

Windows will ask you to verify your network credentials to access the shared folder.Windows will ask you to verify your network credentials to access the shared folder.One important note is that if you connected to the anonymous share above, Windows may not let you log in to the secured share. To remedy that, reboot the Windows computer, and try again.

Bend it to fitOne of the great things about Samba is it allows you to bend it to fit your needs. You can create as many shares as you want (password protected or not), share out printers and even join Windows Domains. This is just the beginning when it comes to using Samba. Follow our guides to learn how to:

Keep in mind that Samba is one of many ways to share resources between Linux and Windows.  If you find this to be overkill for your needs, you may want to consider the more traditional file-sharing approach that makes use of SSH and SFTP on the Linux side and FileZilla on the Windows side.

02

Simple Range Testing For LoRa Modules

WiFi and Bluetooth have their use cases, but both have certain demands on things like battery life and authentication that make them unsuitable for a lot of low-power use cases. They’re also quite limited in range. There are other standards out there more suitable for low-power and wide area work, and thankfully, LoRa is one of them. Having created some LoRa pagers, [Moser] decided to head out and test their range.

Now, we’ve done range tests before. Often this involves sending one party out with a radio while the other hangs back at base. Cellphones serve as a communications link while the two parties go back and forth, endlessly asking “Is it working now? Hang on, I’ll take a few steps back — what about now?”

It’s a painful way to do a range test. [Moser]’s method is much simpler; set a cellphone to log GPS position, and have the pager attempt to send the same data back to the base station. Then, go out for a drive, and compare the two traces. This method doesn’t just report straight range, either — it can be used to find good and bad spots for radio reception. It’s great when you live in an area full of radio obstructions where simple distance isn’t the only thing affecting your link.

Build details on the pagers are available, and you can learn more about LoRa here. While you’re at it, check out the LoRa tag for more cool builds and hacks.

03

Easy-To-Use Music Player Relies On RFID

Microwaves used to be simple to use. Set the dial for the desired time, and hit start. Then, everything went digital and the average microwave now takes between four and six button presses in precise order just to start heating. Music players have gone down a similar path, and those that grew up in the era of vinyl records can find modern digital media simply too hard to work with. To solve this problem, [ananords] whipped up Juuke, a music player focused on ease of use.

The Juuke has a simplistic interface intended to be as easy to use as possible. Songs are selected using printed cards with embedded RFID tags – placing them on the Juuke triggers playback. Volume is controlled with a simple knob, and the only two buttons are for play/pause and shuffle mode.

Underneath, an Arduino Uno runs the show, hooked up to a RC522 RFID interface board. Music is handled by the DFPlayer mini, which loads tracks off a microSD card. The DFPlayer can be hooked up to a speaker directly, but there’s also a 3.5mm jack output if the device is to be used with an external amplifier.

It’s a tidy project, and one that actually looks pretty fun to use. Obviously, there’s some time investment required to prepare the SD card and produce the RFID cards, but the final product could be fun to use at a party, too. We’ve seen similar builds before, as well. Video after the break.

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %
Previous post Get help with Cannabis Blunt Boxes to make your brand stand out
Next post user interface

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Your email address will not be published. Required fields are marked *