Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a possibility to temporarily share a directory per Samba?

With python3 i can serve the current directory per HTTP using:

python -m http.server.

I'd like to do the same thing with Samba.

share|improve this question
Is the net share add command what you're looking for? – derobert Nov 13 '12 at 17:14
Or possibly net usershare... – derobert Nov 13 '12 at 17:15

There doesn't appear to be a way to create an ad-hoc share similar to the way exportfs does it for NFS on Linux and share does it on Solaris. Reasons may vary but you could technically do something like described in the page for Running Multiple Servers on the same machine and with the custom smb.conf accomplish what you need to do.

There is also an option to create and delete shares dynamically using SWAT, which will require changes to smb.conf to allow this to happen see sections on add share command and delete share command

Personally if you want to have a share dynamic you might want to share your home directory and use dynamic home shares via samba discussed in many places including Ubuntu forums, and Samba mailing list.

share|improve this answer

Depending on how old your samba daemon is, and the config options used when it was built, you may still have the option of defining a "dynamic" share in your smb.conf, pointed at say /var/dynamic/, see below, and then simply adding a symbolic link to the directories you temporarily want to share into the directory.

This hack require the wide links option to be set to yes, to allow samba to follow links outside of the shares root. Unfortunately a couple of years back the Samba crew tweaked their default config to prevent wide shares, as it could be exploited. Google for: Samba and "wide links" for the history and work arounds.

    comment = Somewhere to park dynamic shares 
    path = /var/dynamic
    read only = Yes
    inherit acls = Yes
    follow symlinks = yes
    wide links = yes

A quick test should see if your good e.g.

mkdir -p /var/dynamic/test
cd /var/dynamic
ln -s test a_link
ln -s /tmp/  tmp_test
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.