How to Install and Configure Samba in Ubuntu

Spread the love

Samba is an effective tool for sharing files and printers across networks, particularly in mixed environments with Windows and Linux systems. In this guide, I will explain to you How to install and configure samba in Ubuntu  so you can share folders across your network. I have also shared in a previous article about how to block certain file extensions on samba.

Install Samba

Before we start, make sure that Samba is installed on your Ubuntu system. If not already installed, you can install it by running the following commands in your terminal:

Create a Shared Directory

First, make a directory that you intend to share. For example, let us create a directory called “samba”:

Edit Samba Configuration

Open the Samba configuration file for editing sudo vim /etc/samba/smb.conf   and Scroll to the end of the `smb.conf` file and add the following configuration for your share 

 Adjust the “path” and other options as needed for your setup. Save and Close ( Escape :wq and Enter) to exit the editor.

Here are some options for customizing the share block in Samba configuration to meet your needs. These options give you more control and customization over your Samba shares, allowing you to define specific behaviors, access restrictions, and visibility rules based on your needs and security policies. Adjust these options to tailor the shared folder’s behavior to your environment.

Path: Indicates the path to the directory you want to share.

Guest OK: Allows guests to access the shared folder without requiring a username and password.

Public: Similar to guest ok, this allows public access without authentication.

Valid Users: Determines which users are permitted to access the shared folder. These users will be the only ones with access.

Read Only: Specifies whether the shared folder is read-only or allows write access.

Writable: Like read-only, this specifies whether the folder can be written to. It provides an alternative to reading only.

Browseable: Shows whether the shared folder is visible when browsing the network.

Create Mask: This specifies the default permissions for newly created files.

Directory Mask: Sets the default permissions for newly created directories.

Force User: Assigns all file and directory ownership to the specified user.

Force Group: Assigns group ownership of all files and directories to the specified group.

Available: Indicates whether the share is currently available. If set to no, the share will not be accessible.

Veto Files: Disallows certain files or directories from being visible or accessible in the share.

Create a Samba User

Make a Samba user and set a password for accessing the shared folder. Replace ‘username’ with the desired username:

To set the password for the Samba user, follow the prompts.

See also  How to create Animated GIFs with Peek on Ubuntu

Restart Samba Service

After modifying the configuration, restart the Samba service to apply the new settings:

Accessing Shared Folder

From Windows:

Open File Explorer and enter \\<Ubuntu_IP_Address> in the address bar. You should see the `shared_folder`. Enter the Samba username and password when prompted.

From Linux:

 Open your file manager and enter smb://<Ubuntu_IP_Address> in the address bar. Enter the Samba username and password to access the shared folder.

Following these steps, you have successfully set up a Samba server on Ubuntu to share folders across your network. Customize the configurations to meet your specific needs and security policies.

Leave a Comment

PHP Code Snippets Powered By : XYZScripts.com