Skip to content
Home ยป Creating a Share

Creating a Share

Creating a Share in Samba Server


1. Introduction

Creating a Samba share means making a directory on a Linux system accessible over the network so that other systems (Windows/Linux) can read, write, and manage files.

๐Ÿ‘‰ In simple words:
Samba share = Folder shared over network


2. Prerequisites

Before creating a share:

  • Samba must be installed
  • Service should be running
  • Root or sudo access required

3. Steps to Create a Samba Share


Step 1: Create a Directory to Share

sudo mkdir -p /srv/samba/shared

Step 2: Set Permissions

sudo chmod 777 /srv/samba/shared

๐Ÿ“Œ (For testing; in real use, use restricted permissions)


Step 3: Create Samba User

Create Linux User

sudo useradd user1
sudo passwd user1

Add Samba Password

sudo smbpasswd -a user1

Step 4: Configure Samba

Edit configuration file:

sudo vi /etc/samba/smb.conf

Add Share Configuration

[shared]
   path = /srv/samba/shared
   browseable = yes
   writable = yes
   guest ok = no
   valid users = user1

Step 5: Restart Samba Service

sudo systemctl restart smbd

Step 6: Configure Firewall

sudo ufw allow samba

Step 7: Access the Share

From Windows

\\192.168.1.10\shared

From Linux

smbclient //192.168.1.10/shared -U user1

4. Explanation of Configuration

ParameterMeaning
[shared]Share name
pathDirectory location
browseableVisible in network
writableAllow write access
guest okAllow guest users
valid usersAllowed users

5. Types of Samba Shares

1. Public Share

guest ok = yes

2. Private Share

valid users = user1

6. Testing Configuration

testparm

7. Common Issues & Solutions

IssueSolution
Access deniedCheck permissions
Cannot see shareCheck firewall
Login failedVerify smbpasswd
Service not runningRestart Samba

8. Best Practices

  • Avoid 777 permissions in production
  • Use specific user/group access
  • Disable guest access if not needed
  • Monitor logs

9. Real-World Example

  • Office network:
    • Shared folder for employees
    • Access controlled by users
    • Centralized file storage

10. Conclusion

Creating a Samba share allows Linux systems to act as powerful file servers in a network. Proper configuration ensures secure, efficient, and cross-platform file sharing, making Samba an essential tool in system administration.