Sharing Linux Folders with Windows through Samba
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
.
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 typingsmbpasswd -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 typingmkdir /root/sharedfolder
.Now using vi, open file
/etc/samba/smb.conf
by typingvi /etc/samba/smb.conf
and add the following content at the end of it. You will need to pressi
for inserting text. Herethesharedfolder
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, selectMore Choices
and click on the optionUse a different account
. There, type the username asroot
and the password the one that you had set for the userroot
for Samba.
✅ @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)✍