Skip to content
-
Subscribe to our newsletter & never miss our best posts. Subscribe Now!
The Server Admin
The Server Admin
  • Home
  • Linux
  • Windows
  • About
  • What Powers The Server Admin
  • Home
  • Linux
  • Windows
  • About
  • What Powers The Server Admin
Close

Search

  • https://www.facebook.com/
  • https://twitter.com/
  • https://t.me/
  • https://www.instagram.com/
  • https://youtube.com/
Subscribe
Linux

Install Samba in Debian

By Anthony
May 5, 2025 3 Min Read
0

Here’s a concise guide to install and configure Samba on Debian to share files with Windows, Linux, or macOS clients over a network. This assumes you’re using a recent Debian version (e.g., Debian 12 Bookworm) and have root or sudo privileges.

  1. Update the package index:
sudo apt update

2. Install Samba and its dependencies:

sudo apt install samba samba-common-bin

Configure Samba

Edit the Samba configuration file: The main configuration file is /etc/samba/smb.conf. Back it up first:

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak

Then, edit the file using a text editor like nano:

sudo nano /etc/samba/smb.conf

Basic global settings:

Ensure the [global] section includes these settings (modify as needed):

[global]
workgroup = WORKGROUP
server string = %h server
security = user
map to guest = bad user

workgroup: Set to match your network’s workgroup (default is WORKGROUP for Windows networks). security = user: Requires authentication for access.
map to guest = bad user: Allows guest access for invalid users (optional).

Create a shared folder: Add a share definition at the end of smb.conf.
Example for a share named myshare:

[myshare]
path = /srv/samba/share
writable = yes
browsable = yes
guest ok = yes
create mask = 0777
directory mask = 0777

path: The directory to share.
writable: Allows write access.
guest ok: Allows access without a password (remove for authenticated access).
create mask/directory mask: Sets permissions for new files and folders.

Create the shared directory:
Create the directory specified in the path and set permissions:

sudo mkdir -p /srv/samba/share
sudo chmod -R 0777 /srv/samba/share
sudo chown nobody:nogroup /srv/samba/share

For guest access, nobody:nogroup ownership with 0777 permissions is simplest. For restricted access, adjust ownership and permissions accordingly.

Save and exit: Save the smb.conf file (in nano, press Ctrl+O, Enter, then Ctrl+X).

Test the configuration: Verify the syntax of smb.conf:

testparm

Step 3: Set Up Samba Users (Optional for Authenticated Access)

If you want to restrict access to specific users (instead of guest access):

  1. Add a Samba user (must be an existing system user):
sudo adduser username
sudo smbpasswd -a username

Follow prompts to set a Samba password for username.
Modify the share in smb.conf to require authentication:

[myshare]
path = /srv/samba/share
writable = yes
browsable = yes
guest ok = no
valid users = username

Restart Samba after changes.

Step 4: Start and Enable Samba Services

Restart Samba to apply changes:

sudo systemctl restart smbd
sudo systemctl restart nmbd

Enable Samba to start on boot:

sudo systemctl enable smbd
sudo systemctl enable nmbd

Check service status:

sudo systemctl status smbd
sudo systemctl status nmbd

Access the Share

  1. From Windows:
    • Open File Explorer and type \\<debian-ip-address>\myshare in the address bar (replace <debian-ip-address> with your server’s IP, e.g., \\192.168.1.100\myshare).
    • If using guest access, it should connect directly. For user access, enter the Samba username and password.
  2. From Linux:
    • Use a file manager (e.g., Nautilus) and enter smb://<debian-ip-address>/myshare.
  3. Or mount manually:
sudo mount -t cifs //192.168.1.100/myshare /mnt -o username=username

Step 6: Firewall Configuration (if applicable)
If a firewall is active (e.g., UFW):

Allow Samba Traffic

sudo ufw allow Samba

That is it! Your Samba server is up and running with a global / everybody share, and your private folder shared. Please let me know if this doesn’t work, or you have qustions.

Author

Anthony

Follow Me
Other Articles
Previous

How to Zip and Unzip a directory and its files in Linux

Next

Vnstat

Search

Need a Virtual Server for sysctl testing? Check out our plans!

Popular Posts

  • Mount sFTP folder as local drive
    by Anthony
    June 9, 2026
  • Robocopy Examples
    by Anthony
    February 12, 2026
  • Rsync Command Examples
    by Anthony
    February 10, 2026

Trending

  • Mount sFTP folder as local drive
    by Anthony
    June 9, 2026
  • Adding a GUI to a Server or VPS
    by Anthony
    August 27, 2024
  • Back up to a shared folder with Time Machine on Mac
    by Anthony
    January 4, 2025
  • Backup Your Databases
    by Anthony
    March 24, 2024

Editors Picks

    Send an email:
    mail@example.com

    Call me:
    123-456-7890

    • Facebook
    • Twitter
    • Instagram
    • TikTok
    • LinkedIn
    • Behance
    Copyright 2026 — The Server Admin. All rights reserved. Blogsy WordPress Theme