Before jumping into the topic, let me ask you a couple of questions. How you transfer your files from your one pc to another or pc to phone? You're probably gonna say about using a USB cable or Pendrive? Yeah, it's very common. But if I ask you how to share it through your local network where your every device is connected to your high-performance router with WiFi or LAN Cable. Can you share your files with one device to another simultaneously by using this local network? Can you stream and watch your favorite movie from your pc to your phone? I'll say yes, you can.
Some popular network protocol exists with this ability and maybe you've already heard of one or used one on your Windows PC or laptop already. Windows has a handy feature of drive sharing or a particular folder sharing across the local network which can be accessed from another device or the phone's also if they are on the same network. And Windows uses the SMB networking protocol or in short SAMBA. Using Samba on Windows is very easy with a couple of clicks and it'll up.
Accessing from Linux is also very easy but can we create this network in Linux? Yes, and it's not so tough because I'm here to break it down step by step. I'll only cover Ubuntu in this article because it's very popular and beginner-friendly. But if you need it on another distribution, you can comment me below and I'll glad to cover it. So, let's start with a basic definition of Samba.
Samba is a free software re-implementation of the SMB(Server Message Block) networking protocol which was originally developed by Andrew Tridgell. It is the standard Windows interoperability suite of programs for Linux and Unix. Samba provides secure, stable, and fast file and print services for all clients using the SMB(Server Message Block)/CIFS(Common Internet File System) protocol.
- Update repository cache
💲 sudo apt update
- Install Samba package
💲 sudo apt install samba
- Creating a folder for share
💲 mkdir /home/<username>/sambashare/
- Opening config file in terminal
💲 sudo nano /etc/samba/smb.conf
- Config for sharing previously created folder
- Add this config at the end of the file
[sambashare] comment = Samba on Ubuntu path = /home/<username>/sambashare read only = no browsable = yes
- Start the service
💲 sudo service smbd restart
- Add Samba allowance in UFW (Uncomplicated Firewall)
💲 sudo ufw allow samba
- Since Samba doesn’t use the system account password, we need to set up a Samba password for our user account.
- Username used must belong to a system account, else it won’t save.
- Setting up User Accounts and Connecting to Share
💲 sudo smbpasswd -a <username>
- I'm using ifconfig to know my local IP
Solution for ifconfig command not found in the system
💲 sudo apt install net-tools
💲 sudo systemctl status smbd
- Write your devices IP address in the red marked area following this format
💘 Connection successful
Share your opinion in the discussion section below and of course the questions if any. Don't forget to follow us.