How to share directory using SMB

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.

  • First, we install Samba:
$ sudo apt install samba
  • Samba uses its own list of users and passwords. To reduce confusion, assume we want the current Linux username to be used to access this share. Set the Samba password for this user, say joe:
$ sudo smbpasswd -a joe
  • Check that the user has permissions to read and write to the directory you want to share. Else give him those permissions:
$ sudo chown joe /path/to/share
$ sudo chown :joe /path/to/share
  • Open the Samba configuration file for editing:
$ sudo vim /etc/samba/smb.conf
  • Add a section at the end of the file for your share. You will need to provide it a name:
    path = /path/to/share
    available = yes
    valid users = joe
    read only = no
    browseable = yes
    public = yes
    writable = yes
  • Restart the Samba server to enable this share:
$ sudo service smbd restart


$ sudo service samba restart
  • You can access this shared directory from any computer in the network. For example, if the IP address of the computer is, then type this into the address bar of Nautilus: smb:// You will be asked to provide the username and password to access the share.

Tried with: Ubuntu 14.04

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.