okecity.com

Setting up Samba on your Ubuntu 20.04

Setting up Samba on your Ubuntu 20.04

Setting up Samba on your Ubuntu 20.04 for share file to other windows OS

 

1. The first thing that we must do before we setup a SMB/CIFS share on our Raspberry Pi is to make sure everything is up to date.

We can update the package list and all our packages by running the following two commands.

sudo apt-get update
sudo apt-get upgrade

2. Now that we have our Raspbian operating system entirely up to date, we can now proceed on to installing the Samba software to our Raspberry Pi.

We can install the packages that we require to setup Samba by running the following command.

sudo apt-get install samba samba-common-bin

3. Before we set up our network storage on our Pi, we need to first create a folder that we will share.

This folder can be located anywhere, including on a mounted external hard drive. For this tutorial, we will be creating the directory within the “pi” users home directory.

Create this folder by running the following command.

mkdir /home/pi/shared

4. Now we can share this folder using the Samba software. To do this, we need to modify the samba config file.

The “smb.conf” configuration file is where you will store all your settings for your shares.

We can begin modifying the config file by running the command below.

sudo nano /etc/samba/smb.conf

5. Within this file, add the following to the bottom. This text defines various details of our share.

[openShare]
    comment = OPEN TO ALL USER
    path = /home/orangepi/Downloads
    read only = no
    guest ok = yes

[privateShare]
    valid users = orangepi
    # We restrict access to the user '' smbuser ''
    #valid users = @smbusers
    #Alternative can also be restricted to a user group
    path = /media/extdisk
    public = no
    writable = yes
    comment = REGISTERED USER smb restricted share
    printable = no
    guest ok = no
    create mask = 0600
    directory mask = 0700

[privateShareHeri]
    valid users = heri
    # We restrict access to the user '' smbuser ''
    #valid users = @smbusers
    #Alternative can also be restricted to a user group
    path = /media/extdisk
    public = no
    writable = yes
    comment = REGISTERED USER smb restricted share
    printable = no
    guest ok = no
    create mask = 0600
    directory mask = 0700

[homeshare]” – This defines the share itself, the text between the brackets is the point at which you will access the share. For example, ours will be at the following address: //raspberrypi/pimylifeupshare

 

path” – This option is the path to the directory on your Raspberry Pi that you want to be shared.

writeable” – When this option is set to “Yes“, it will allow the folder to be writable.

create mask” and “directory mask” – This option defines the maximum permissions for both files and folders. Setting this to 0777 allows users to read, write, and execute.

public” – If this is set to “no” the Pi will require a valid user to grant access to the shared folders.

6. With the changes made to the file, you can now go ahead and save it by pressing CTRL + X then Y followed by ENTER.

7. Next, we need to set up a user for our Samba share on the Raspberry Pi. Without it, we won’t be able to make a connection to the shared network drive.

In this example, we will be creating a Samba user called “pi” with the password set to “raspberry“.

Run the following command to create the user. You will be prompted afterward to enter the password.

sudo smbpasswd -a pi

8. Finally, before we connect to our Raspberry Pi Samba share, we need to restart the samba service so that it loads in our configuration changes.

sudo systemctl restart smbd

on windows brows on network

\\hostname

Enter

 

Share With Authentication

To Add user Samba

sudo adduser heri

Set password for samba

$ sudo smbpasswd -a heri

If you want user to sudoer

sudo usermod -aG sudo heri

Done 

Category: Tekno

Share: