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.
β΄οΈ What is 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.
β‘οΈ Installation
- Update repository cache ```shell
π² sudo apt update
* Install Samba package
```shell
π² sudo apt install samba
β‘οΈ Configurations
- Creating a folder for share ```shell
π² mkdir /home//sambashare/
* Opening config file in terminal
```shell
π² 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 ```shell
π² sudo service smbd restart
---
###β‘οΈ **Configuring Firewall**
* Add Samba allowance in [UFW (Uncomplicated Firewall)](https://wiki.ubuntu.com/UncomplicatedFirewall)
```shell
π² sudo ufw allow samba
β‘οΈ Setting up a user account for 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 ```shell
π² sudo smbpasswd -a
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/jf7tehtfqoyajfbk31i1.png)
---
###β‘οΈ **Find your local IP**
* I'm using ifconfig to know my local IP
> Solution for ifconfig command not found in the system
```shell
π² sudo apt install net-tools
β‘οΈ Samba status
π² sudo systemctl status smbd
β‘οΈ Paste some file in the folder
β‘οΈ Connect from Windows
- Write your devices IP address in the red marked area following this format
\\IP_ADDRESS\\<FOLDER_NAME>
\\192.168.1.41\sambashare
π Connection successful
Share your opinion in the discussion section below and of course the questions if any. Don't forget to follow us.
π‘ AND SUBSCRIBING to our YouTube TechLearnersInc and Telegram t.me/TechLearners will be amazing.
Top comments (3)
Would the steps be same for Manjaro?
Not exactly same.
Um.. only apt would be replaced with pacman in install sambashare, maybe something like this->
sudo pacman -Syu
sudo pacman -Syy
sudo pacman -S sambashare