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