UbuntuUbuntu Based

How To Install Samba on Ubuntu 24.04 LTS

Install Samba on Ubuntu 24.04

In this tutorial, we will show you how to install Samba on Ubuntu 24.04 LTS. Samba is a powerful open-source software suite that enables seamless file and printer sharing between Linux and Windows systems in a network environment. It allows Linux servers to integrate with Windows domains, providing a cost-effective and reliable solution for cross-platform resource sharing. Ubuntu 24.04 LTS, the latest long-term support release of the popular Linux distribution, offers a stable and secure platform for running Samba.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Samba on Ubuntu 24.04 (Noble Numbat). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.

Prerequisites

  • A server running one of the following operating systems: Ubuntu and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • Basic familiarity with the command line interface.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies.
  • An Ubuntu 24.04 system with root access or a user with sudo privileges.

Install Samba on Ubuntu 24.04

Step 1. Updating the Package Repository.

Before installing Samba, it’s crucial to update your system packages to their latest versions. Open a terminal and run the following command:

sudo apt update
sudo apt upgrade

This command synchronizes the package index files from their sources, ensuring that you have access to the most recent package versions.

Step 2. Installing Samba.

Now, install Samba by running the following command:

sudo apt install samba

This command installs the Samba package along with its dependencies. The installation process may take a few minutes, depending on your internet connection speed.

Once the installation is complete, verify that Samba is installed correctly by checking its version:

samba -V

Additionally, you can check the location of the Samba binaries using the whereis command:

whereis samba

To ensure that the Samba services are running, use the following command:

systemctl status smbd

Step 3. Configuring Samba.

  • Configure Firewall for Samba

To allow Samba traffic through the firewall, run the following command:

sudo ufw allow samba

This command adds a firewall rule that permits incoming Samba traffic. Configuring the firewall is essential to ensure the security of your Samba setup.

  • Create a Shared Directory

Create a directory that will serve as the shared folder for Samba. For example, let’s create a directory named “SambaShare” in the “/home” directory:

sudo mkdir /home/SambaShare

Set the appropriate permissions for the shared directory to allow Samba to access it:

sudo chown -R nobody:nogroup /home/SambaShare
sudo chmod -R 0775 /home/SambaShare

These commands change the ownership and permissions of the “SambaShare” directory, granting necessary access rights to Samba.

  • Edit Samba Configuration File

Open the Samba configuration file using a text editor with sudo privileges:

sudo nano /etc/samba/smb.conf

In the configuration file, locate the [global] section and make sure the following parameters are set:

[global]
   workgroup = WORKGROUP
   server string = %h server (Samba, Ubuntu)

The workgroup parameter specifies the Windows workgroup or domain name, while the server string parameter sets a descriptive name for your Samba server.

Next, add a new section at the end of the file to define your shared directory:

[SambaShare]
   path = /home/SambaShare
   browseable = yes
   read only = no
   guest ok = no

This section specifies the path to the shared directory, makes it browseable, allows write access, and disables guest access. Save the changes and exit the text editor.

Step 4. Add Samba User.

To access the Samba shared directory, you need to create a Samba user. Run the following command, replacing username with your desired username:

sudo smbpasswd -a username

You will be prompted to enter a password for the Samba user. Choose a strong password and confirm it.

Step 5. Testing Samba Setup

With Samba installed and configured, it’s time to test the setup to ensure everything is working as expected.

  • Testing from Linux Client

On another Linux machine in your network, open a file manager and navigate to the “Network” or “Browse Network” section. You should see your Samba server listed. Click on it and enter the Samba username and password when prompted. If the authentication is successful, you should be able to access the shared directory.

  • Testing from Windows Client

On a Windows machine, open File Explorer and click on the “Network” icon in the left sidebar. Your Samba server should be visible. Double-click on it and enter the Samba username and password when prompted. Upon successful authentication, you will be able to access the shared directory.

If you encounter any connection issues, double-check your firewall settings and ensure that the Samba services are running on your Ubuntu server.

Step 6. Monitoring Samba Performance.

You can monitor Samba performance using various tools and commands. For example, use the smbstatus command to view current Samba connections and locked files. The htop command provides real-time information about system resource usage, helping you identify any performance bottlenecks.

Congratulations! You have successfully installed Samba. Thanks for using this tutorial for installing the Samba on the Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the official Samba website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button