• Contact
  • About Me
  • Privacy Policy
  • Disclaimer
DefenceDev
  • Home
  • Linux
    • Bash Scripting
      • Bash Scripting Lessons
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Tools
No Result
View All Result
  • Home
  • Linux
    • Bash Scripting
      • Bash Scripting Lessons
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Tools
No Result
View All Result
DefenceDev
No Result
View All Result
Home Linux Commands&Tips

How to Configure SMB Share on Ubuntu 22.04 – Step-by-Step Guide

by neo
September 3, 2026
in Commands&Tips
0
Solutions: Configure SMB Share on Ubuntu 22.04

Solutions: Configure SMB Share on Ubuntu 22.04

0
SHARES
42
VIEWS
Share on FacebookShare on LinkedIn
Table of Contents
  • Configure SMB Share
    • Prerequisites for Samba Installation
    • Install Samba on Ubuntu
    • Edit Configuration and Add Share
    • Add User Which will use SMB Share
    • Restart Service
    • Change Ownership
  • Conclusion

Configure SMB Share

Welcome to the post “How to Configure SMB Share on Ubuntu 22.04 – Step-by-Step Guide”! In this post, you’ll learn how to configure an SMB (Server Message Block) share on Ubuntu 22.04. SMB is a powerful protocol that allows for seamless file and printer sharing across networks, making it ideal for environments where Linux and Windows systems interact.

By following the steps outlined, you’ll quickly set up SMB shares, enabling users to access files and resources from different platforms. We’ll guide you through the process step by step, ensuring a smooth configuration for optimal performance. Let’s get started and configure your SMB share with ease!

Prerequisites for Samba Installation

To install and configure Samba on Ubuntu, you need to meet a few prerequisites:

  • Root or Sudo Privileges: To install packages and make configuration changes, you need a user account with root or sudo privileges.
  • Internet Access: Verify that you have an active internet connection to download the Samba package and its dependencies.

Install Samba on Ubuntu

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install samba samba-common-bin

This command installs the Samba software, which is required to set up SMB file shares. The samba package provides the server daemon and client utilities necessary for file and printer sharing over the SMB/CIFS protocol. The samba-common-bin package includes essential tools, such as smbclient for interacting with SMB shares and other utilities for managing Samba shares.

Edit Configuration and Add Share

Configuration is stored under:

sudo nano /etc/samba/smb.conf
[share-name]
path = /opt/downloads
writable = yes
create mask = 0777
directory mask = 0777
public = yes
browsable = yes
guest ok = yes
valid users = defencedev-user
write list = defencedev-user

More information about create mask and directory mask you cna find at the link.

This Samba configuration defines a shared directory named “share-name” with the following settings:

  • [share-name]: Specifies the name of the shared resource. Clients will use “y2v” to access the share.
  • path = /opt/downloads: Sets the path of the shared directory. In this case, it is “/opt/downloads.”
  • create mask = 0777: Defines permissions for newly created files. Files will have full read, write, and execute permissions for all users.
  • directory mask = 0777: Sets permissions for newly created directories. Directories will also have full permissions for all users.
  • public = yes: Makes the share publicly accessible without any user authentication.
  • browsable = yes: Makes the share visible in network browsers, allowing users to find it without knowing the exact name.
  • guest ok = yes: Enables guest access, allowing users to connect without needing a password.
  • valid users = defencedev-user: Restricts the share to the user account named “user.” Only this account can access the share.
  • write list = defencedev-user: Grants the “user” account write access. Other users can read the files but cannot modify them.

Add User Which will use SMB Share

The command sudo smbpasswd -a pi adds a new user to the Samba system and sets a password for the user.

Here’s a breakdown of the command:

  • sudo: You use this to run the command with root privileges, giving you permission to modify system configurations.
  • smbpasswd: This utility lets you manage Samba user accounts and passwords. It specifically handles user authentication in Samba.
  • -a: This option tells smbpasswd to add a new user to the Samba system.
  • pi: This refers to the username you’re adding. In this case, it’s the default Raspberry Pi user, but you can replace it with any valid system username.
sudo smbpasswd -a defencedev-user

Restart Service

The sudo systemctl restart smbd command is used to restart the Samba service (smbd) on your system.

sudo systemctl restart smbd

Change Ownership

chgrp -R samba /opt/downloads
chown -R defencedev-user:defencedev-user*

chmod -R 2775 /opt/downloads

Explanation of the chmod -R 2775 /opt/downloads command

Let me break down the permission string “drwxrwsr-x“:

  • d: This indicates that it is a directory.
  • rwx: The owner (user) has read, write, and execute permissions.
  • rws: The group has read, write, and execute permissions, with the setgid bit set.
  • r-x: Others have read and execute permissions.
  • The 2 at the beginning of the octal mode corresponds to the setgid bit, which ensures that new files and subdirectories created within this directory inherit the group ownership of the parent directory.
  • The -R option makes the chmod command apply the changes recursively to all files and subdirectories within the specified directory.

Conclusion

Configuring an SMB share on Ubuntu 22.04 allows you to easily share files and resources across Linux and Windows systems, making it an essential tool for mixed network environments. By following the step-by-step guide in this post, you have successfully installed Samba, configured an SMB share, and ensured appropriate permissions for users accessing the share.

With the configuration complete, your Ubuntu machine is now capable of acting as an SMB file server, offering seamless access to shared resources. Whether you’re managing file access for a small network or a larger enterprise, SMB provides a reliable and straightforward method for file sharing.

For more detailed information on configuring Samba and troubleshooting common issues, be sure to explore other related guides on our site. If you run into any problems or have further questions, feel free to leave a comment below – we’re here to help!

Tags: linuxnetworkingubuntu
Previous Post

Send E-Mail from Linux Terminal – Quick & Easy Guide

Next Post

Add and Mount New HDD or SSD on Ubuntu – Easy Tutorial

neo

Related Posts

10+ Useful Linux find Command Examples You Should Know
Commands&Tips

10+ Useful Linux find Command Examples You Should Know

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)
Commands&Tips

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)

Timeshift on Linux: How to Create and Restore System Snapshots
Commands&Tips

Timeshift on Linux: How to Create and Restore System Snapshots

Remote Desktop Access to Ubuntu 24.04 from Windows
Commands&Tips

Remote Desktop Access to Ubuntu 24.04 from Windows

Fix "blk_update_request: critical target error" on Ubuntu Server (dev sdb, DISCARD Operation)
Commands&Tips

Fix “blk_update_request: critical target error” on Ubuntu Server with SSD (dev sdb, DISCARD Operation)

Passwordless SSH Login on Ubuntu: Secure Server Access
Commands&Tips

Passwordless SSH Login on Ubuntu: Secure Server Access

Next Post
Solutions: Add New Hard Drive (HDD or SSD) to Ubuntu

Add and Mount New HDD or SSD on Ubuntu – Easy Tutorial

Recommended

Immich: Resource Usage & Monitoring for 4 Users

Immich: Resource Usage & Monitoring for 4 Users

GitHub: How to Add a Script or a Folder to Your Repository

GitHub: How to Add a Script or a Folder to Your Repository

Briefly unavailable for scheduled maintenance. Check back in a minute.

WordPress Stuck in Maintenance Mode After Plugin Update

Promox Telegram Alert Example

Configure Telegram Notifications in Proxmox VE Using Webhooks

Fix Proxmox VM Snapshot “Out of Space” Errors

Fix Proxmox VM Snapshot “Out of Space” Errors

Categories

  • Linux
    • Bash Scripting
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Web Tools

DefenceDev Tutorials

defencedev Logo

Whether you’re just starting or looking to expand your skills, I hope you find useful information and engaging discussions here. Let me take you through my journey and the goals behind this space!

Follow Us

Recent News

Briefly unavailable for scheduled maintenance. Check back in a minute.

WordPress Stuck in Maintenance Mode After Plugin Update

Promox Telegram Alert Example

Configure Telegram Notifications in Proxmox VE Using Webhooks

  • Site Map
  • Privacy Policy
  • Facebook Page
  • GitHub
  • Disclaimer
  • Contact
  • About Me

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Linux
    • Bash Scripting
      • Bash Scripting Lessons
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Tools

© 2025 defencedev.com - All rights reserved.