Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

As part of the installation step of some software on a Ubuntu VM I'd like to create a samba share. How would I go about doing that from the command line?

share|improve this question

2 Answers 2

You can edit /etc/samba/smb.conf and enter the share name, location, and who should access it. There are several examples in the file itself.

Here's online guide for entering new shares in the smb.conf file:

share|improve this answer

Use Samba's net usershare command to share directories from the command line, IMHO this is less clunky and much safer than fiddling around in the main smb.conf file:

net usershare add share_name /home/user/somefolder "Share description" everyone:F guest_ok=y

To make these shares permanent (i.e. persist over reboots) create a file for each share under /var/lib/samba/usershares/ like this:

net usershare info --long share_name > /var/lib/samba/usershares/share_name

This has a further advantage that if you're using a desktop like KDE or GNOME/MATE/Unity the directories will show up as shared in the file manager (Dolphin, Nautilus etc.). That's cause the net username//var/lib/samba/usershares/ thing is the same mechanism that Dolphin and Nautilus use when you share directories in the GUI.

See also:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.