Samba on Linux


Samba on CentOS Stream

dnf install samba and then create a folder sambashare under /


mkdir sambashare
useradd -m linda
chown linda:linda sambashare/
chmod 777  sambashare/

samba config to be set up in /etc/samba/smb.conf add below entry


[sambatest]
comment = My Share
path = /sambashare
browseable = yes
read only = yes
guest ok = no
write list = linda

set smbpasswd -a linda to set the samba password for user linda

also allow samba through firewall firewall-cmd --add-service samba --permanent and firewall-cmd --reload

for persistence mount add below in /etc/fstab


//ipaddressofserver/sambatest   /sambashare       cifs           _netdev,username=linda,password=password    0  0
mount -a   # this should not give errors

make sure share name is entered in /etc/fstab and it points to the actual directory location

smbpassword -a linda # where linda is the user

logs to be checked are /var/log/samba/log.smbd and /var/log/audit/audit.log

SE linux also caused problems set it to permissive and see if it works and check logs


semanage f_context -a -t  samba_share_t 'sambashare'

restorecon -v 'sambashare'

setsebool -P samba_export_all_rw 1

after the above steps enable enforcing setenforce 1 and reboot and check if it works

Samba on Ubuntu Linux


apt install samba
systemct status samba
ufw allow samba and restart ufw using systemctl restart ufw
mkdir sambashare
useradd -m linda
chown linda:linda sambashare/
chmod 777  sambashare/

add below in /etc/samba/smb.conf

[sambatest]
comment = My Share
path = /sambashare
browseable = yes
read only = yes
guest ok = no
write list = linda

set password using smbpassword - a linda
login using linda  su - linda
$ smbclient  //ipaddress/sambatest and enter password for linda

do a ls to see if retrieval is working then do mkdir to create a folder this indicates it is successful

to make this persistent add this in  /etc/stab

//lpaddress/sambatest    sambashare      cifs       _netdev,username=linda,password=password    0   0

then do mount -a to check there are no errors