Krótka strona o informatykowaniu

Create samba share on Ubuntu 22.04.4 LTS

1. Update the package index:

$ sudo apt update

2. Install Samba:

$ sudo apt install samba

3. Edit the Samba configuration file:

$ sudo nano /etc/samba/smb.conf

4. Add the following configuration at the end of the file (smb.conf) to share:

[sample_folder1]
path = /home/data/sample_folder1
valid users = @sambashare
read only = no
browsable = yes

[sample_folder2]
path = /home/data/sample_folder2
valid users = @sambashare
read only = no
browsable = yes

5. Create a new system user (if not already existing):

$ sudo adduser sambauser

6. Add the user to the Samba group:

$ sudo usermod -aG sambashare sambauser

7. Set the Samba password for the user:

$ sudo smbpasswd -a sambauser

8. Enable the Samba user:

$ sudo smbpasswd -e sambauser

9. Set the ownership of the directories to the Samba group:

$ sudo chown -R :sambashare /home/data/sample_folder1
$ sudo chown -R :sambashare /home/data/sample_folder2

10. Set the appropriate permissions:

$ sudo chmod -R 2770 /home/data/sample_folder1
$ sudo chmod -R 2770 /home/data/sample_folder2

11. Restart the Samba service to apply the changes:

$ sudo systemctl restart smbd

Access the Shared Folders from the Client Machine

1. Install the Samba client package:

$ sudo apt install smbclient cifs-utils

2. Create mount points for the shared directories:

$ sudo mkdir -p /mnt/sample_folder1
$ sudo mkdir -p /mnt/sample_folder2

3. Mount the shared directories using the Samba user credentials:

$ sudo mount -t cifs -o username=sambauser,password=<password> //IP_ADRESS/sample_folder1 /mnt/sample_folder1

$ sudo mount -t cifs -o username=sambauser,password=<password> //IP_ADRESS/sample_folder2 /mnt/sample_folder2

4. Create CIFS credentials file

$ sudo su
$ cd /root
$ nano .smbcredentials

Supply the username and password for CIFS storage as follows:

user=<cifsusername>
password=<password>

And save the newly created .smbcredentials file.

5. Fstab Entry

$ sudo nano /etc/fstab

Add the following content at the bottom of the file:

$ //IP_ADRESS/sample_folder1  /mnt/sample_folder1        cifs    credentials=/root/.smbcredentials,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0

$ //IP_ADRESS/sample_folder2  /mnt/sample_folder2        cifs    credentials=/root/.smbcredentials,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0


6. Mount the SAMBA / CIFS storage

$ sudo mount -a
$ df -h





Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany. Wymagane pola są oznaczone *