Sharing Linux Folders with Windows through Samba

in technology •  6 years ago  (edited)

If you use a Linux VPS, sometimes you would want to make a folder in it accessible from Windows. One of the best ways to do that is to use Samba. In this article, we are going to see how to do that. We assume here that you are logged into your Linux VPS, as user root.


Image source

  • Make sure you allow access to ports 445 and 139 on your Linux VPS, as Samba uses those ports. So, adjust your Firewall settings accordingly.

  • Check if Samba is already installed and running on the Linux VPS by typing service smbd status. If you get a not found message, it means Samba is not installed. So, install it by typing the following.

    apt-get update
    apt-get install samba
  • Now add user root and give a password to it for accessing shared folders, by typing smbpasswd -a root.

  • Now create the folder you want to share if it doesn't already exist. Let us assume, you want to share the folder /root/sharedfolder. In that case, you will first create it by typing mkdir /root/sharedfolder.

  • Now using vi, open file /etc/samba/smb.conf by typing vi /etc/samba/smb.conf and add the following content at the end of it. You will need to press i for inserting text. Here thesharedfolder is the name by which you would access the folder /root/sharedfolder from your Windows computer.

    [thesharedfolder]
    path = /root/sharedfolder
    available = yes
    valid users = root
    read only = no
    browsable = yes
    public = yes
    writable = yes
  • Restart the Samba service by typing service smbd restart.

  • Now you should be able to access this folder from your Windows computer. To do that, create a new shortcut and type \\ip_address_of_the_node\thesharedfolder as location. ip_address_of_the_node here is the IP address of the node where you created the shared folder. When Windows prompt your for credentials, select More Choices and click on the option Use a different account. There, type the username as root and the password the one that you had set for the user root for Samba.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

@hmushtaq Thank you for sharig this valuable information. sharing your thoughts and commenting can help. :)
Please give advice for betterment of each other.
@sbanerjee0017 (Shyamal Banerjee[Age:62] Kolkata,INDIA)✍