• 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
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
No Result
View All Result
DefenceDev
No Result
View All Result
ADVERTISEMENT
Home Solutions

Solutions: Configure SMB Share on Ubuntu 22.04

neo by neo
May 27, 2025
in Solutions
0
Solutions: Configure SMB Share on Ubuntu 22.04

Solutions: Configure SMB Share on Ubuntu 22.04

0
SHARES
16
VIEWS
Share on FacebookShare on Twitter
ADVERTISEMENT

Configure SMB Share

Welcome to the post “Solutions: Configure SMB Share on Ubuntu 22.04″! 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:

ADVERTISEMENT
  • [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

ADVERTISEMENT
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.

About The Author

neo

See author's posts

ADVERTISEMENT
Previous Post

Solutions: Send E-Mail from Linux Terminal

Next Post

Solutions: Add and Mount New Hard Drive (HDD or SSD) to Ubuntu

neo

neo

Related Posts

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)

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

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

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)
Docker

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

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

Solutions: Add and Mount New Hard Drive (HDD or SSD) to Ubuntu

Recommended

Solutions: Send E-Mail from Linux Terminal

Solutions: Send E-Mail from Linux Terminal

MikroTik: Export Configuration in Text File

MikroTik: Export Configuration in Text File

My Way to Organize a Git Repository for Bash, Mikrotik, FortiGate and other Scripts

My Way to Organize a Git Repository for Bash, Mikrotik, FortiGate and other Scripts

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)

My Ultimate Docker Command Cheat Sheet (2025 Edition)

My Ultimate Docker Commands Cheat Sheet (2025 Edition)

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
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

My Way to Organize a Git Repository for Bash, Mikrotik, FortiGate and other Scripts

My Way to Organize a Git Repository for Bash, Mikrotik, FortiGate and other Scripts

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)

  • 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

© 2025 defencedev.com - All rights reserved.