Results 1 to 7 of 7

Thread: how to share a directory with Windows clients using command line?

  1. #1
    Join Date
    Jan 2009
    Beans
    98

    how to share a directory with Windows clients using command line?

    This has be done by command line (SSH) because I'm running Ubuntu Server and have no access to the GUI. Right now I have no files being shared.

  2. #2
    Join Date
    Jun 2011
    Beans
    417
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: how to share a directory with Windows clients using command line?

    Hi

    Which server release are you using? In case 10.04.4

    sudo apt-get install samba smbfs winbind

    and then edit /etc/samba/smb.conf

  3. #3
    Join Date
    Jan 2009
    Beans
    98

    Re: how to share a directory with Windows clients using command line?

    thanks! smb.conf is pretty big, how about a quick pointer on where to add the line to share a particular directory?

  4. #4
    Join Date
    Dec 2009
    Beans
    5,713

    Re: how to share a directory with Windows clients using command line?

    Creating a share from CLI:

    Quote Originally Posted by Morbius1 View Post
    Yes there is and it's usually associated with a GUI only application.

    Let's use as an example the Documents folder in your home directory: /home/morbius/Documents

    To create a share:
    Code:
    net usershare add documents /home/morbius/Documents "morbius  documents" everyone:F guest_ok=y
    net usershare add = is the command sequence to add
    documents = is the name of the share
    /home/morbius/Documents = is the path to the directory you wish to share
    "morbius documents" = is the comments next to the share
    everyone:F = this will allow users the ability to read / write (F) to the share. If you only want to allow read access then substitute R for F.
    guest_ok=y = will allow guest access. If you want only authenticated useres then change that to guest_ok=n"

    The only thing left to do is change the permissions on the target directory to allow "guests" to actually write to that share:
    Code:
    chmod 0777 /home/morbius/Documents
    To verify the share definition run the following command:
    Code:
    net usershare info --long
    In this particular case you should get the following output:
    [documents]
    path=/home/morbius/Documents
    comment=morbius documents
    usershare_acl=Everyone:F,
    guest_ok=y
    If it doesn't work or you want to delete it:
    Code:
    net usershare delete documents
    Note: This will the delete the sharing of th Documents folder not delete the folder itself.
    Depending on who you are logged in as and who owns the folder you are trying to share you may need to preface the command with a sudo.

  5. #5
    Join Date
    Jan 2009
    Beans
    98

    Re: how to share a directory with Windows clients using command line?

    Thanks, although all I did was added this syntax at the end of the file.
    Code:
    [sharename]
    path = ...
    writeable = Yes
    It seems to work. I'm not sure when we need to use the "net" command.

  6. #6
    Join Date
    Dec 2009
    Beans
    5,713

    Re: how to share a directory with Windows clients using command line?

    I misread your original post. I thought you wanted to create a Samba share using one line from the terminal.

  7. #7
    Join Date
    Jan 2009
    Beans
    98

    Re: how to share a directory with Windows clients using command line?

    Quote Originally Posted by Morbius1 View Post
    I misread your original post. I thought you wanted to create a Samba share using one line from the terminal.
    I see, yes I can run editors from the command line, I just don't have GUI. Thanks for the information!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •