SMB Shared Folders, Printers.

SMB SHARED FOLDERS

Note for me to remember. when i tried installing samba, i had this output:

Done
Setting up samba (2:4.15.13+dfsg-0ubuntu0.20.04.4) ...
Samba is not being run as an AD Domain Controller: Masking samba-ad-dc.service
Please ignore the following error about deb-systemd-helper not finding those services.
(samba-ad-dc.service masked)
Created symlink /etc/systemd/system/multi-user.target.wants/nmbd.service  /lib/systemd/system/nmbd.service.
Failed to preset unit: Unit file /etc/systemd/system/samba-ad-dc.service is masked.
/usr/bin/deb-systemd-helper: error: systemctl preset failed on samba-ad-dc.service: No such file or directory
Created symlink /etc/systemd/system/multi-user.target.wants/smbd.service  /lib/systemd/system/smbd.service.
samba-ad-dc.service is a disabled or a static unit, not starting it.
Processing triggers for ufw (0.36-6ubuntu1) ...
Processing triggers for systemd (245.4-4ubuntu3.20) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...

probably I need to unmask these services and then check

Anyway let’s start our lab:

Sharing Home Directories

  • Samba can provide access to user home directories

  • Each user has access to their own private folder

  • Integrates well with local Linux user accounts (we’ll see later how to do that)

First thing let’s edit the smb.conf file:

sudo vim /etc/samba/smb.conf

I will need to uncomment this to enable home directories sharing

browseable=no : Home directories are hidden by default

read only = no : Users are allowed to write to their own folder

valid users = %s : telling smb to use linux users

Printers are enabled by default:

Now i can crate a folder before i start sharing it. Technically i can share any foldr but if i am running APPARMOR or SELinux i might need to change the context to let smb access to the shared folder

the best place to create shared home directoried (folder), is under /srv

sudo mkdir -p /srv/samba/corp

cd samba

Here, you can start creating folder for different purposes like a corp ‘corporation’ folder or marketing folder or anything

Now, follow these steps:

I have created a group and added my user to it, I will change permissions too

Note: samba expect to get the password of the user account

sudo smbpasswd -a touk

Now I need to tell samba about this directory!

sudo vim /etc/samba/smb.conf

And jump to the end of the file

And you can check for typo: sudo testparm

Once we have all that configured, Let’s test it:

sudo apt install smbclient

And VOILA, i can see corp is shared.

Now i can go and create a folder and see if it is going to be shared:

You can use the smbclient to login in:

Last updated