Code Yarns ‍👨‍💻
Tech BlogPersonal Blog


How to share directory using SMB

📅 2014-Jul-07 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ smb ⬩ 📚 Archive

This post shows the basic steps to share a directory over the network using SMB on the commandline. If you prefer a GUI program, see the post about using Samba Server Configuration tool.

$ sudo apt install samba smbclient
$ sudo smbpasswd -a joe

Check if the username is listed in the database of Samba users:

$ sudo pdbedit -L -v
$ sudo chown joe /path/to/share
$ sudo chown :joe /path/to/share
$ sudoedit /etc/samba/smb.conf

Add a section at the end of the file for your share. You will need to provide it a name:

[joe-share]
    path = /path/to/share
    available = yes
    valid users = joe
    read only = no
    browseable = yes
    public = yes
    writable = yes

To ensure your entry to smb.conf is correct, check if the share we added is listed in the output of this command:

$ testparm -s
$ sudo service smbd restart

or

$ sudo service samba restart

To check status of the shares and see which computers are connected to the shares:

$ sudo smbstatus

To check if the shares are visible locally to a Samba client:

$ smbclient -L localhost -U joe

Tried with: Samba 4.19.5 and Ubuntu 24.04


© 2026 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 Mastodon🦋 Bluesky📧 Email