Before You Start
This guide creates a share with no authentication. Every device on the local network can read, write, and delete files in the shared folder. This is intentional — the goal is a simple, password-free file drop for a trusted network.
If you need per-user access control, Active Directory integration, or any form of authenticated access, this is not the guide for that. Authenticated Samba shares involve significantly more configuration and are a different topic entirely.
This guide assumes you are starting from a Fedora 44 Server minimal install. Every command is run as a regular user with sudo. If you are still logging in as root, see Adding a New User on Fedora 44+ first.
The guide uses /data as the mount point for a dedicated storage disk and /data/shares/public as the shared directory. Adjust the paths to match your setup.
TL;DR
The full setup, condensed. Each section below explains what these commands do and why.
sudo dnf upgrade --refresh -y
sudo dnf install cockpit cockpit-storaged samba policycoreutils-python-utils -y
sudo firewall-cmd --add-service=cockpit --permanent
sudo firewall-cmd --add-service=samba --permanent
sudo firewall-cmd --reload
sudo systemctl enable --now cockpit.socket
sudo mkdir /data
# Set up your storage disk via Cockpit or /etc/fstab, then:
sudo mkdir -p /data/shares/public
sudo semanage fcontext -a -t samba_share_t "/data(/.*)?"
sudo restorecon -Rv /data/
sudo useradd pubshare -s /usr/sbin/nologin
sudo smbpasswd -a pubshare
sudo chown pubshare /data/shares/public/
# Edit /etc/samba/smb.conf (see below), then:
sudo systemctl enable --now smbStep 1 — Update the System
Start by bringing the system fully up to date. This ensures you have the latest package versions and security patches before installing anything new.
sudo dnf upgrade --refresh -yStep 2 — Install Required Packages
sudo dnf install cockpit cockpit-storaged samba policycoreutils-python-utils -y- cockpit and cockpit-storaged — a web-based management console for the server. The storage module makes it easy to partition and format disks, configure mount points, and manage
/etc/fstabentries without editing files by hand. You can skip these two packages if you prefer to manage storage from the command line. - samba — the SMB/CIFS file server.
- policycoreutils-python-utils — provides the
semanagecommand, which you will need to tell SELinux that your data directory is a Samba share.
Step 3 — Open the Firewall
Fedora's firewall blocks incoming connections by default. Open the ports for both Cockpit and Samba.
sudo firewall-cmd --add-service=cockpit --permanent
sudo firewall-cmd --add-service=samba --permanent
sudo firewall-cmd --reload- --permanent writes the rule to the persistent configuration so it survives a reboot.
- --reload activates the new rules immediately without dropping existing connections.
The cockpit service opens TCP port 9090. The samba service opens TCP 445 and 139, plus UDP 137 and 138. If you skipped Cockpit in Step 2, skip the cockpit firewall rule here as well.
Step 4 — Enable Cockpit
Start Cockpit and set it to launch on boot.
sudo systemctl enable --now cockpit.socketCockpit is now available at https://your-server-ip:9090 in any browser. Log in with your normal Linux credentials.
Cockpit uses a self-signed certificate by default. Your browser will warn you about this — accept the exception to proceed. If this server will be managed long-term, consider adding a proper certificate later.
Step 5 — Set Up Storage
Create the mount point for your data disk.
sudo mkdir /dataNow attach and mount your storage disk. You have two options:
- Cockpit — log into the web console, go to Storage, select your disk, format it, and configure a mount point at
/data. Cockpit will handle the/etc/fstabentry for you. - Command line — partition the disk with
fdiskorparted, format it withmkfs.xfs(or your preferred filesystem), add an entry to/etc/fstab, and mount it.
Reboot after configuring storage to confirm the disk mounts automatically on boot.
sudo rebootStep 6 — Configure SELinux
SELinux is enabled by default on Fedora and will block Samba from accessing files outside its expected directories. Tell SELinux that everything under /data is a Samba share.
sudo semanage fcontext -a -t samba_share_t "/data(/.*)?"
sudo restorecon -Rv /data/- semanage fcontext adds a persistent rule mapping the path pattern to the
samba_share_ttype. This rule survives relabels and reboots. - restorecon -Rv applies the new context to all existing files and directories under
/dataimmediately.
Do not disable SELinux. Many older guides suggest setting SELinux to permissive or disabled as a "fix" for Samba access problems. The two commands above are all you need. Disabling SELinux to make a file share work is removing a security layer to avoid a two-line configuration.
Step 7 — Create the Shared Directory
sudo mkdir -p /data/shares/publicThis is the directory that will be exposed over the network. You can create additional directories alongside public later if you want more shares.
Step 8 — Configure Samba
Back up the default configuration file, then replace it.
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.origEdit /etc/samba/smb.conf with your preferred editor and replace the contents with the following:
[global]
workgroup = WORKGROUP
security = user
map to guest = bad user
min protocol = SMB3
passdb backend = tdbsam
[Public]
path = /data/shares/public
browsable = yes
writable = yes
read only = no
guest ok = yes
force user = pubshareWhat Each Setting Does
[global] Section
- workgroup = WORKGROUP — the NetBIOS workgroup name.
WORKGROUPis the Windows default. Change this only if your network uses a different workgroup name. - security = user — Samba's default security mode. Clients must present a username and password, but the
map to guestdirective below handles unauthenticated access. - map to guest = bad user — if a client connects with a username that does not exist in the Samba user database, map the connection to the guest account instead of rejecting it. This is what makes the share work without passwords — Windows clients that send their logged-in username are silently mapped to guest.
- min protocol = SMB3 — reject connections using SMB1 or SMB2. SMB1 has known security vulnerabilities and has been disabled by default in Windows since 2017. SMB2 has been superseded. There is no reason to allow either on a new deployment.
- passdb backend = tdbsam — store the Samba password database in a local TDB file. This is the default and the right choice for a standalone server.
[Public] Section
- path — the directory on disk to share.
- browsable = yes — the share appears in network browsing (e.g. when you open "Network" in Windows Explorer).
- writable = yes and read only = no — both are needed to ensure write access. They are complementary directives; setting both avoids ambiguity.
- guest ok = yes — allow connections without a valid Samba account.
- force user = pubshare — all file operations on this share run as the
pubshareLinux user, regardless of who connected. This keeps file ownership consistent and avoids permission problems when multiple clients write to the same directory.
Step 9 — Create the Samba Service User
Create a local Linux user that Samba will use for file operations on the public share. This user does not need a password or a login shell — it exists only as a file ownership identity.
sudo useradd pubshare -s /usr/sbin/nologinAdd the user to the Samba password database. When prompted for a password, just press Enter twice — the password does not matter because the share uses guest access, but Samba requires the user to exist in its database.
sudo smbpasswd -a pubshareSet ownership of the shared directory to the new user.
sudo chown pubshare /data/shares/public/Step 10 — Start Samba
Enable and start the Samba service.
sudo systemctl enable --now smbSamba is now running and will start automatically on boot.
Connect from Another Machine
From a Windows machine on the same network, open File Explorer and type the following in the address bar:
\your-server-ip\PublicFrom a Linux machine, you can mount it or browse it with your file manager. To test from the command line:
smbclient //your-server-ip/Public -NFrom a macOS machine, open Finder, press Cmd+K, and enter:
smb://your-server-ip/PublicTroubleshooting
Verify Samba Configuration
Samba ships with testparm, which parses smb.conf and reports any errors.
testparmIf the output ends with "Loaded services file OK," your configuration is syntactically valid.
Check SELinux Denials
If clients can connect but cannot read or write files, SELinux is the most likely cause. Check the audit log for denials:
sudo ausearch -m avc -ts recentIf you see denials involving smbd and your data path, re-run the semanage and restorecon commands from Step 6.
Check Firewall
Confirm the Samba service is active in the firewall:
sudo firewall-cmd --list-servicesThe output should include samba. If it does not, re-run the firewall commands from Step 3.
Check Samba Service Status
sudo systemctl status smbLook for "active (running)". If the service failed to start, the output will include the reason — most commonly a syntax error in smb.conf.