• Contact
  • About Me
  • Privacy Policy
  • Disclaimer
DefenceDev
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools
No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools
No Result
View All Result
DefenceDev
No Result
View All Result
ADVERTISEMENT
Home Solutions

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

neo by neo
September 11, 2025
in Solutions
0
Solutions: Configure SMB Share on Ubuntu 22.04

Solutions: Configure SMB Share on Ubuntu 22.04

0
SHARES
22
VIEWS
Share on FacebookShare on Twitter
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.

ADVERTISEMENT
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

ADVERTISEMENT

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!

About The Author

neo

See author's posts

ADVERTISEMENT
Previous Post

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

Next Post

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

neo

neo

Related Posts

Automatic Windows Service Monitoring and Restart Script
Solutions

Automatic Windows Service Monitoring and Restart Script

Host a Website on Raspberry Pi – Real Benchmark Tests
Solutions

Host a Website on Raspberry Pi – Real Benchmark Tests

My Ultimate Docker Command Cheat Sheet (2025 Edition)
Docker

My Ultimate Docker Commands Cheat Sheet (2025 Edition)

Protect Docker-Hosted Application from HTTP Flood (DDoS) Attacks Using a Bash Script
Docker

Protect Docker-Hosted Application from HTTP Flood (DDoS) Attacks Using a Bash Script

Raspberry Pi Monitoring with Monit: Docker, Temperature, Network & More
Solutions

Raspberry Pi Monitoring with Monit: Docker, Temperature & More

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)
Docker

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

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

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

Recommended

Linux Files Operation: find Temp Files and Execute Commands on Found Files

How to Find Temporary Files in Linux and Execute Commands on Them

Check Disk Usage on the Linux with du Command

Check Disk Usage on the Linux with du Command

View & Copy Image Metadata Online – Camera & GPS Info

View & Copy Image Metadata Online – Camera & GPS Info

Online WebP to JPG Converter

Online WebP to JPG Converter

Image Metadata Remover – Clean EXIF and GPS Info Securely

Image Metadata Remover – Clean EXIF and GPS Info Online

Categories

  • Blog
  • Cloud
    • Private
  • Linux Tutorials
    • Bash Scripting Tutorials
    • Commands
    • Networking
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Solutions
    • Docker
  • Video Tutorials
    • MikroTik Videos
  • Web Tools
ADVERTISEMENT

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

View & Copy Image Metadata Online – Camera & GPS Info

View & Copy Image Metadata Online – Camera & GPS Info

Online WebP to JPG Converter

Online WebP to JPG Converter

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

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools

© 2025 defencedev.com - All rights reserved.