How to Share Files on a Local Network in Ubuntu

Hey there! So, you’re ready to share files over your local network using Ubuntu? Trust me, once you get the hang of it, you’ll wonder why you ever used USB sticks for this. It’s super easy, and I’ve done this so many times now, I’ve practically got it down to a science.

Let’s walk through it step by step, and by the end, you’ll be sharing files like a pro. Ready? Let’s dive in.

Step 1: Prepare Your Local Network

Before we even think about sharing files, you’ll want to make sure that your devices are all connected to the same local network. Sounds basic, but trust me, you don’t want to overlook this.

Quick Checklist:

  • Make sure your computer (the one running Ubuntu) is connected to the same Wi-Fi or Ethernet network as the other devices.
  • Double-check that the devices you’ll be sharing with are also connected.

It’s like hosting a party, you can’t start until everyone’s in the room, right?

Step 2: Install Samba

Alright, here’s where we start getting into the tech stuff. To share files between Ubuntu and other systems (Windows, macOS, or other Linux distros), we’ll need to install something called Samba. It’s the magic that makes cross-platform file sharing possible.

Open the Terminal

Don’t panic, opening the terminal is like unlocking the toolbox. Just press Ctrl + Alt + T, and boom, you’re in.

Now, type the following command to install Samba:

sudo apt update
sudo apt install samba

Hit Enter, and when it asks for your password, go ahead and type it in. (Don’t worry if you can’t see the password as you type, that’s normal.) If you will be asked “Do you want to continue? Then type “Y”. Ubuntu will do its thing, and after a few seconds, Samba will be installed.

Trust me, this trick is a lifesaver when you’re sharing files between systems!

Step 3: Set Up a Shared Folder

Okay, now that Samba is ready, let’s create a shared folder. This is the folder other devices will access.

Here’s How:

Now open your terminal and follow the steps below:

  1. Create the Folder Using Your Ubuntu Terminal:
  • Open your terminal and create a folder in your Home directory or wherever you want with this command: mkdir ~/SharedFolder
  1. Set Permissions:
  • Make the folder accessible to everyone (this step will give it read, write, and execute permissions for all users): chmod 777 ~/SharedFolder
  1. Configure Samba Manually:
  • Open the Samba configuration file: sudo nano /etc/samba/smb.conf
  • Scroll to the bottom of the file and add the following lines: [SharedFolder] path = /home/yourusername/SharedFolder browseable = yes read only = no guest ok = yes Don’t forget to replace yourusername with your actual Ubuntu username.
  1. Restart Samba:
  • After saving your changes (use Ctrl + O to save and Ctrl + X to exit Nano), restart Samba with this command: sudo systemctl restart smbd

Step 4: Find Your IP Address

Now, you might be thinking, “Wait, what’s my IP address?” Good question! You’ll need it to connect to your shared folder from other devices.

What’s an IP Address?

In simple terms, an IP address is like your computer’s home address on the network. Every device connected to a network gets a unique IP address so they can communicate with each other. Think of it like sending mail; if you don’t have the right address, your letter (or in this case, your files) won’t get to the right place.

Finding Your IP Address

Here’s how you find your IP address on Ubuntu:

  1. Open the Terminal (Ctrl + Alt + T).
  2. Type the following command:
hostname -I

You’ll get a string of numbers separated by periods. That’s your local IP address.

For example, you might see something like 192.168.1.12. This number is what other devices will use to access your shared folder. Easy, right?

Step 5: Configure Samba Settings (Optional)

Now, this step is optional, but if you want a bit more control (like setting a password or restricting access), you’ll need to tweak Samba’s settings.

Edit the Samba Configuration File:

  1. Open the terminal again (Ctrl + Alt + T).
  2. Type:
sudo nano /etc/samba/smb.conf

This opens Samba’s configuration file.

  1. Scroll down to the bottom and add something like this:
[SharedFolder]
path = /home/yourusername/SharedFolder
available = yes
valid users = yourusername
read only = no
browsable = yes
public = yes
writable = yes

Replace yourusername with, well, your username, obviously. Then, press Ctrl + O to save and Ctrl + X to exit.

Trust me, if you ever want to lock down access to just you and your buddy, this little tweak comes in handy.

Step 6: Access the Shared Folder from Another Device

Now comes the fun part, accessing your shared folder from another device on the same network. If your other device is also running Linux, this is going to be super simple.

On Another Ubuntu (or Linux) System:

  1. Open the Files app.
  2. In the sidebar, click Other Locations.
  3. In the field that says Connect to Server, type:
smb://your-ip-address/SharedFolder

Replace your-ip-address with the IP address you found earlier.

On a Windows PC:

  1. Open File Explorer.
  2. In the address bar, type:
\\your-ip-address\SharedFolder

Just like that, the shared folder will pop up. You won’t believe how easy this is once you’ve done it a couple of times!

Step 7: Troubleshooting Common Issues

Okay, I’ve been there. Sometimes things don’t work as smoothly as we’d like. Here are a couple of issues I’ve run into; and how to fix them.

Firewall Blocking Samba

If your shared folder isn’t showing up, it could be that your firewall is blocking Samba. Here’s a quick fix:

sudo ufw allow samba

Can’t Find the IP Address

If you’re having trouble finding your IP address, use this command in the terminal:

ip addr show

It’ll display all the network interfaces on your computer, and you’ll be able to spot your IP address next to the section labeled inet.

FAQs

1. What happens if I skip installing Samba?

You won’t be able to share files with non-Linux devices. Without Samba, you’re limited to sharing between Linux systems only.

2. Can I share files without using passwords?

Absolutely! By enabling Guest access in the sharing settings, anyone on your network can access the files without a password.

3. What if I want to stop sharing the folder?

Easy! Just right-click on the folder, go to Properties, and uncheck the sharing options. It’s like locking the door when the party’s over.

Conclusion

That’s pretty much it! Now you know how to share files across your local network using Ubuntu. It’s a simple process once you get the hang of it, and now that you’ve set it up, file-sharing will be a breeze.

So go ahead, and share those files! You’ve got this!

Leave a Comment