How to setup Samba on Fedora the easy way?

Change the first line to whatever your share path is:

SMB_SHARE="/home/myusername/Downloads"

@vgaetera, as far as I know chcon changes SELinux context only temporarely:

Fedora’s user guide for SELinux says:

The chcon command changes the SELinux context for files. These changes do not survive a file system relabel, or the /sbin/restorecon command.

The same guide suggests using semanage fcontext for persisting changes, and that’s what I’ve always done.

Then you need to change this line:

chcon --recursive --type=“samba_share_t” “${SMB_SHARE}”

to:

sudo semanage fcontext -a -t samba_share_t "${SMB_SHARE}(/.*)?"
sudo restorecon -Rv "${SMB_SHARE}"
2 Likes

Hi @delacosta78, this is how I do it:

  1. install samba

sudo dnf install samba`

  1. tell SELinux and Firewall that samba is OK

sudo setsebool -P samba_export_all_rw on
sudo firewall-cmd --add-service=samba --permanent
sudo firewall-cmd --reload`

  1. setup your share

cat<<EOF | sudo tee /etc/samba/smb.conf
[global]
workgroup = WORKGROUP
netbios name = DOWNLOADS
wins support = yes

[downloads]
comment = Downloads
path = /home/myusername/Downloads
read only = yes
guest ok = yes
EOF

  1. enable and start samba services

sudo systemctl enable smb
sudo systemctl start smb

I hope that helps.

2 Likes

Yes!, it worked! but I changed one thing, I didn’t use WORKGROUP but another word I use for my LAN.

I also removed the netbios name = DOWNLOADS to keep the name my computer already has.

Thank you so much, this is what I was looking for, an easy way to setup this, bummer there is not a GUI.

Basically you need:
writable = yes
create mode = 0644
directory mode = 0755

and you also need to remove:

read only = yes

Thank you for your reply, one last question though: What if I want to share more folders? should I add another line for each folder I want to share where “path=” is?

@delacosta78, you need to add another block like this for each of the folders you want to share (with settings specific to this share ).

Sections names (in square brackets) should be unique for each section / block, that’s the samba share name you see when connecting to this server, and all the settings that follow are specific to this samba share.

I wonder what are this for?

Got it!, thank you for clarifying.

These are for the files and folder that get created by your samba clients to be readable and writable for all on this machine. This is for the folder where any samba client can write files, not just read as in your downloads example, along with writable = yes.

And of course you can have one samba share read only, another writable by all the clients, third one accessible only by specific user (with username and password you’ve set up), and fourth readable by all but writable only by that one user – you can configure them in any way you want, all alike or all differently.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.