Setting up Samba on Ubuntu 22.04 is essential for enabling file sharing across different operating systems within a local network. This guide provides detailed instructions for installing and configuring Samba, ensuring that even newcomers can follow along easily. The process includes creating shared directories, configuring Samba, setting up user accounts, and troubleshooting potential issues. The following steps assume you are using the root user and do not require the sudo command.

Step 1: Deploying a Cloud Instance on Shape.host

  • Log in to Shape.host Dashboard:
  • Navigate to the Shape.host website and log in to your account.
  • Create a New Instance:
  • Click on the “Create” button located at the top right corner of the dashboard.
  • From the dropdown menu, select “Instances”.
Shape.host Resources dashboard showing the Create menu and instance rebuild controls.
  • Select Instance Location:
  • Choose the desired location for your server. For this tutorial, we’ll select “New York, USA”.
Shape.host Create New Instance form with the available data center locations.
  • Choose a Plan:
  • Select a plan that fits your requirements. For example, you might choose a plan with 2 cores CPU, 2 GB Memory, and 50 GB SSD disk space.
  • Select an Operating System:
  • Scroll down to the “Choose an image” section and select “Ubuntu 22.04”.
Shape.host instance form with a server plan and Ubuntu image selected.
  • Configure Additional Options:
  • (Optional) You can configure additional options like User Data Configuration and IPv6 Networking.
  • Enter a hostname for your instance, e.g., “Tutorial Ubuntu”.
  • Click on the “Create instance” button to deploy the instance.
Shape.host instance form showing hostname, instance count and the Create Instance button.

Step 2: Connecting to Your Instance

  • Retrieve SSH Credentials:
  • Note the IP address of your newly created instance from the Shape.host dashboard.
  • Connect via SSH:
  • Open a terminal on your local machine.
  • Use the following command to connect to your instance:
    ssh root@your_instance_ip
  • Replace your_instance_ip with the actual IP address of your instance.

Step 3: Update System Packages

Before installing Samba, ensure your system packages are up-to-date:

apt update
apt upgrade -y
Terminal showing apt commands or output during Update System Packages.

Step 4: Install Samba

Install Samba using the following command:

apt install samba -y
Terminal showing APT package management commands and output.

To verify the installation, you can check the location of Samba:

whereis samba
Terminal showing Samba executable location information.

The output should include directories like /usr/sbin/samba, /etc/samba, and others.

Step 5: Create a Shared Directory

Create a directory that you want to share over the network. For this example, we’ll create a directory named shared in the /srv directory:

mkdir -p /srv/shared
chmod -R 0775 /srv/shared
chown -R nobody:nogroup /srv/shared
Terminal showing file ownership or permission commands.

Step 6: Configure Samba

Open the Samba configuration file with a text editor:

nano /etc/samba/smb.conf
Terminal showing the command to edit the Samba configuration.

Add the following configuration at the end of the file:

[shared]
   comment = Samba on Ubuntu
   path = /srv/shared
   read only = no
   browsable = yes
   guest ok = no
Terminal showing go commands or output during Configure Samba.

Save and close the file by pressing Ctrl+O, Enter, and Ctrl+X.

Step 7: Set Up Samba User

Create a Samba user and set a password. The user must already exist on the system. If the user doesn’t exist, create it first:

adduser your_username
Terminal showing Linux user account management commands.

Then add the user to Samba:

smbpasswd -a your_username
smbpasswd -e your_username
Terminal showing the Samba user password setup command.

Replace your_username with the actual username.

Step 8: Restart Samba Services

Restart Samba to apply the new configuration:

systemctl restart smbd
systemctl restart nmbd
Terminal showing systemd service management commands or output.

Enable the services to start on boot:

systemctl enable smbd
systemctl enable nmbd
Terminal showing systemd service management commands or output.

Step 9: Adjust the Firewall

Ensure the firewall allows Samba traffic:

ufw allow samba
ufw allow ssh
Terminal showing firewall configuration commands and rules.

Step 10: Access the Samba Share

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

\\your_server_ip\shared

Replace your_server_ip with the IP address of your Ubuntu server.

Windows File Explorer displaying the Samba network share.

For enhanced performance and reliability, consider using Shape.Host’s Linux SSD VPS services. Shape.Host offers robust solutions for hosting your Samba server in the cloud, providing high availability, security, and scalability for your file sharing needs. Explore more about their services at Shape.Host.