How to Set Up Samba File Sharing on Ubuntu 26.04

Setting up Samba file sharing on Ubuntu 26.04 enables seamless file exchange between Linux and Windows systems on your local network. Samba implements the SMB/CIFS protocol, allowing Ubuntu to act as a file server that Windows, macOS, and other Linux machines can access natively. In this tutorial, you will perform a complete samba setup on Ubuntu 26.04, covering installation, share configuration, user management, and firewall rules.

In this tutorial you will learn:

  • How to install and enable the Samba service
  • How to create public and private Samba shares
  • How to manage Samba users and passwords
  • How to configure UFW firewall rules for Samba
  • How to access Samba shares from Linux and Windows clients
Setting up Samba for cross-platform file sharing on Ubuntu 26.04

Software Requirements

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu 26.04 Resolute Raccoon
Software Samba
Other Privileged access to your Linux system as root or via the sudo command. A Windows or Linux client on the same network for testing.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user
TL;DR
Install Samba on Ubuntu 26.04 and configure shares for cross-platform file access.

Quick Steps to Set Up Samba File Sharing
Step Command/Action
1. Install Samba sudo apt install samba
2. Configure shares Edit /etc/samba/smb.conf and add share definitions
3. Add Samba user sudo smbpasswd -a linuxconfig
4. Open firewall sudo ufw allow Samba

Install Samba on Ubuntu 26.04

The first step in the samba setup on Ubuntu 26.04 is to install the Samba package from the default repositories. Update your package index and install Samba along with the client tools:

$ sudo apt update
$ sudo apt install samba smbclient

The samba package provides the server components, while smbclient provides a command-line tool for testing connections to SMB shares. After installation, verify that the Samba service is running:

$ sudo systemctl status smbd

The smbd daemon handles file sharing and authentication. Note that Ubuntu 26.04 ships with disable netbios = yes in the default smb.confmeaning the nmbd service for legacy NetBIOS name resolution is not required. The smbd service is enabled automatically upon installation. You can additionally verify the installed Samba version with:

$ smbd --version
Terminal output showing the smbd service active and running on Ubuntu 26.04 with Samba version 4.23.6 displayed
Confirming that the smbd service is active and running after Samba installation

Create a Samba Share Directory

Before configuring Samba, create the directories that will serve as shared folders. In this example, we will create two shares: a public share accessible to all network users without authentication and a private share requiring login credentials.

  1. Create the public share directory:
    $ sudo mkdir -p /srv/samba/linuxconfig_share
    $ sudo chmod 0777 /srv/samba/linuxconfig_share
    $ echo "Greetings from LinuxConfig.org!" | sudo tee /srv/samba/linuxconfig_share/welcome.txt
    

    The 0777 permission allows any user to read, write, and execute within the public directory. This is appropriate for a guest-accessible share where convenience takes priority over strict access control. The test file will help verify that the share is working correctly later.

  2. Create the private share directory:
    $ sudo mkdir -p /srv/samba/linuxconfig_private
    $ sudo chown linuxconfig:linuxconfig /srv/samba/linuxconfig_private
    $ sudo chmod 0770 /srv/samba/linuxconfig_private
    $ echo "Private data from LinuxConfig.org" | sudo tee /srv/samba/linuxconfig_private/confidential.txt
    $ sudo chown linuxconfig:linuxconfig /srv/samba/linuxconfig_private/confidential.txt
    

    The private directory is owned by the linuxconfig user and restricts access to the owner and group members only. The test file will confirm that authenticated access works as expected.

Configure Samba Shares on Ubuntu 26.04

The main Samba configuration file is /etc/samba/smb.conf. Before making changes, create a backup of the original configuration:

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

Now open the configuration file in your preferred text editor and add share definitions at the end of the file:

$ sudo nano /etc/samba/smb.conf

Add the following share blocks at the bottom of the file:

[linuxconfig_share]
   comment = LinuxConfig Public Share
   path = /srv/samba/linuxconfig_share
   browseable = yes
   read only = no
   guest ok = yes
   force user = nobody

[linuxconfig_private]
   comment = LinuxConfig Private Share
   path = /srv/samba/linuxconfig_private
   browseable = yes
   read only = no
   guest ok = no
   valid users = linuxconfig
   create mask = 0660
   directory mask = 0770

Here is what each directive does in the share definitions:

  • comment – A human-readable description of the share.
  • path – The filesystem path to the shared directory.
  • browseable – Controls whether the share appears in network browse lists.
  • read only – Set to no to allow write access.
  • guest ok – When set to yesno password is required to connect.
  • force user – All file operations in the public share are performed as the nobody user.
  • valid users – Restricts access to the listed users only.
  • create mask and directory mask – Control the permissions assigned to newly created files and directories.

After saving the file, validate the configuration syntax using the testparm utility:

$ testparm
Terminal output showing testparm validating the Samba configuration with Loaded services file OK message on Ubuntu 26.04
The testparm utility confirms the smb.conf configuration is syntactically correct

If testparm reports no errors, your configuration is syntactically correct. Consequently, restart the Samba services to apply the changes:

$ sudo systemctl restart smbd

Set Up Samba Users

Samba maintains its own user database, separate from the system password file. However, each Samba user must first exist as a system user. If the linuxconfig user does not already exist on your system, add the user first:

$ sudo adduser linuxconfig

Then set a Samba password for the user. This password is used exclusively for SMB authentication and can differ from the system login password:

$ sudo smbpasswd -a linuxconfig

You will be prompted to enter and confirm the new Samba password. After setting the password, enable the user in the Samba database:

$ sudo smbpasswd -e linuxconfig

To list all registered Samba users, run:

$ sudo pdbedit -L

MANAGING SAMBA USERS

You can disable a Samba user without deleting them using sudo smbpasswd -d linuxconfig. To remove a user entirely from the Samba database, use sudo smbpasswd -x linuxconfig. These operations do not affect the underlying system account.

Terminal output showing Samba user creation with smbpasswd and user listing with pdbedit on Ubuntu 26.04
Adding and enabling a Samba user with smbpasswd and verifying with pdbedit

Configure Firewall for Samba

If UFW is active on your Ubuntu 26.04 system, you need to allow the necessary ports for Samba traffic. UFW includes a pre-defined application profile for Samba, which makes this straightforward:

$ sudo ufw allow Samba

Verify the rule was added:

$ sudo ufw status

The Samba UFW profile opens TCP ports 139 and 445 along with UDP ports 137 and 138. However, since Ubuntu 26.04 disables NetBIOS by default (disable netbios = yes in smb.conf), only TCP port 445 is strictly required. If you prefer to open just the necessary port rather than using the application profile, you can run:

$ sudo ufw allow 445/tcp

SECURITY CONSIDERATION

Only enable Samba on trusted networks. If your server is exposed to the internet, consider restricting access by source IP using sudo ufw allow from 192.168.178.0/24 to any app Samba to limit connections to your local subnet.

Test and Access Samba Shares

With Samba configured and the firewall open, you can now test access to your shares. There are several methods to connect from both Linux and Windows clients.

Test from the Server Using smbclient

Use smbclient to test the public share locally without authentication:

$ smbclient //localhost/linuxconfig_share -N

The -N flag suppresses the password prompt for guest access. If the connection is successful, you will see the smb: \> prompt. Type ls to list files and exit to disconnect.

To test the private share with authentication:

$ smbclient //localhost/linuxconfig_private -U linuxconfig

Enter the Samba password when prompted. A successful connection confirms that both authentication and share access are working correctly.

Terminal output showing smbclient connecting to both public and private Samba shares on Ubuntu 26.04 with test files visible
Verifying public and private Samba share access using smbclient

Access from a Linux Client

From another Linux machine on the same network, you can mount the Samba share using the cifs-utils package. First, install the required package on the client:

$ sudo apt install cifs-utils

Then mount the private share:

$ sudo mkdir -p /mnt/linuxconfig_private
$ sudo mount -t cifs //192.168.178.79/linuxconfig_private /mnt/linuxconfig_private -o username=linuxconfig

You will be prompted for the Samba password. After mounting, you can access the shared files at /mnt/linuxconfig_private.

Terminal output from a Linux client mounting and accessing the private Samba share from Ubuntu 26.04 server at 192.168.178.79
Mounting and reading the private Samba share from a remote Linux client

Access from a Windows Client

On a Windows machine, open File Explorer and type the following in the address bar:

\\192.168.178.79\linuxconfig_private

Windows will prompt you for credentials. Enter linuxconfig as the username and the Samba password you set earlier. For the public share, navigate to \\192.168.178.79\linuxconfig_sharewhich should be accessible without credentials.

Alternatively, you can map the share as a network drive by right-clicking “This PC” in File Explorer, selecting “Map network drive,” and entering the share path. This provides persistent access to the share across reboots.

Conclusion

You have successfully completed a samba setup on Ubuntu 26.04, creating both public and authenticated file shares accessible from Linux and Windows clients. The configuration covered Samba installation, share directory creation, smb.conf configuration, user management, and firewall rules. For more advanced configurations, including domain integration and printer sharing, consult the official Samba documentation.

Frequently Asked Questions

  1. How do I make a Samba share persist across reboots on a Linux client? Add an entry to /etc/fstab on the client machine. For example: //192.168.178.79/linuxconfig_private /mnt/linuxconfig_private cifs credentials=/home/linuxconfig/.smbcredentials,uid=1000,gid=1000 0 0. Store the username and password in the credentials file with restricted permissions (chmod 600).
  2. Why can I not connect to the Samba share from another machine? First, verify the Samba service is running with sudo systemctl status smbd. Then check that your firewall allows Samba traffic using sudo ufw status. Additionally, confirm the client and server are on the same network segment and can ping each other.
  3. How do I restrict a Samba share to specific IP addresses? Add the hosts allow directive to the share definition in /etc/samba/smb.conf. For example, hosts allow = 192.168.178.0/24 restricts access to clients on the 192.168.178.x subnet. Restart the Samba services after making changes.
  4. Can I use Samba alongside NFS on the same server? Yes, Samba and NFS can coexist on the same Ubuntu 26.04 server and even share the same directories. Samba is typically preferred for Windows clients, while NFS is commonly used in Linux-only environments due to its lower overhead.

PakarPBN

A Private Blog Network (PBN) is a collection of websites that are controlled by a single individual or organization and used primarily to build backlinks to a “money site” in order to influence its ranking in search engines such as Google. The core idea behind a PBN is based on the importance of backlinks in Google’s ranking algorithm. Since Google views backlinks as signals of authority and trust, some website owners attempt to artificially create these signals through a controlled network of sites.

In a typical PBN setup, the owner acquires expired or aged domains that already have existing authority, backlinks, and history. These domains are rebuilt with new content and hosted separately, often using different IP addresses, hosting providers, themes, and ownership details to make them appear unrelated. Within the content published on these sites, links are strategically placed that point to the main website the owner wants to rank higher. By doing this, the owner attempts to pass link equity (also known as “link juice”) from the PBN sites to the target website.

The purpose of a PBN is to give the impression that the target website is naturally earning links from multiple independent sources. If done effectively, this can temporarily improve keyword rankings, increase organic visibility, and drive more traffic from search results.

Jasa Backlink

Download Anime Batch

Leave a Reply

Your email address will not be published. Required fields are marked *