You can share a folder on an Ubuntu Linux system with Windows systems using Server Message Block (SMB) by installing Samba, a free and open-source software package. If Samba isn't installed, you can install it as a Debian package with the following commands:
sudo apt update
sudo apt install samba
You can verify that the Samba service is running with the command
sudo systemctl status smbd; you should see "active (running)".
alice@Wonderland:~$ sudo systemctl status smbd ● smbd.service - Samba SMB Daemon Loaded: loaded (/usr/lib/systemd/system/smbd.service; enabled; preset: ena> Active: active (running) since Sat 2026-09-12 17:09:53 EDT; 4min 16s ago Invocation: 4c72abe09deb445d91cb063be76afc0b Docs: man:smbd(8) man:samba(7) man:smb.conf(5) Main PID: 540371 (smbd) Status: "smbd: ready to serve connections..." Tasks: 3 (limit: 151234) Memory: 10M (peak: 11.1M) CPU: 161ms CGroup: /system.slice/smbd.service ├─540371 /usr/sbin/smbd --foreground --no-process-group ├─540388 "smbd: notifyd" . └─540389 "smbd: cleanupd " Sep 12 17:09:52 Wonderland systemd[1]: Starting smbd.service - Samba SMB Daemon... Sep 12 17:09:53 Wonderland update-apparmor-samba-profile[540361]: grep: /etc/appa> Sep 12 17:09:53 Wonderland update-apparmor-samba-profile[540367]: diff: /etc/appa> Sep 12 17:09:53 Wonderland systemd[1]: Started smbd.service - Samba SMB Daemon. alice@Wonderland:~$
Once Samba is installed, you will need to edit the Samba configuration file, smb.conf, to define the shared folder. Follow these steps:
Configure the Samba Share
Edit the /etc/samba/smb.conf file with a
text editor, such as
nano,
pico, or
vi
E.g. sudo nano /etc/samba/smb.conf. Add a section similar
to the following to the end of the file.
[MyShare] path = /path/to/your/folder available = yes guest ok = no valid users = your_username read only = no browsable = yes ; public = yes writable = yes
Replace /path/to/your/folder with the actual path of the directory you want to share and your_username with your Ubuntu username.
Set Directory Permissions
Ensure that the directory you want to share is owned by the user you
referenced in the "valid users" line above and the appropriate group name
for that user, which you can see with a command like
ls -l /path/to/your/folder. If it isn't, you can change the
permissions with a command like sudo chown your_username:your_group
/path/to/your/folder. replacing your_username:your_group
with the relevant username and group.
Create the Samba User
If you aren't using accounts in a
Windows domain, add
your Ubuntu username to the Samba database with a command like
sudo smbpasswd -a your_username. If your Samba server is
joined directly to an
Active Directory domain (using
Winbind or
SSSd),
you typically do not add domain users to a local Samba database manually.
Instead, set security = ADS in the global section in
/etc/samba/smb.conf so Samba authenticates
accounts directly against the Active Directory
Domain
Controller.
-x option, i.e.,
sudo smbpasswd -x your_username.
If you would like to see a list of the accounts in the Samba account
database, you can use the command sudo pdbedit -L. You can
see detailed information by adding the -v option, i.e.,
sudo pdbedit -L -v.
Restart the Samba service to apply the the changes with sudo
systemctl restart smbd.
alice@Wonderland:~$ sudo systemctl restart smbd alice@Wonderland:~$
Firewall Configuration
If you have the
Uncomplicated
Firewall (UFW) running, you will need to allow the Samba network traffic
through the firewall. You can do that with sudo ufw allow Samba.
Related: