How to access linux files from windows in a network using SAMBA

SAMBA allows users to share folders on their Linux system that can be accessible by a Windows system. On a Windows, it will look like a normal Windows directory, although what you are seeing is actually a Linux system. Linux administrators can specify what permissions (read/write) to give to which users. This ensures the security of the Linux file system.

Before we dig into the codes and commands, I would like to lay the necessary requirements needed for SAMBA to work properly.

1. You should try to get a static IP-address for your Linux box. (it will be so much less headache with static ip address)
2. Your windows system should be in the same network as your Linux box
3. You need to be connected to your internet.
4. I’m using Ubuntu 8.04 for this tutorial.
If you do not have a SAMBA client installed in your Linux box, open up your client and type:

sudo apt-get install samba
in case of any errors while installing samba try
sudo apt-get update
and then try installing samba

Configuring your SAMBA client

First, we need to make sure that SAMBA is not running.

sudo /etc/init.d/samba stop

We need to create a new template for this tutorial. But before doing so, we’ll need to rename the old template so as to prevent a write over of the old one.

sudo /etc/samba/smb.conf /etc/samba/smb.conf.original

Next, lets create a new file to put in our codes.

sudo touch /etc/samba/smb.conf

Finally, we need to open the file in an editor. You can use nano, gedit or whatever editer you wanna use. Here, I’ll go for gedit.

sude gedit /etc/samba/smb.conf

Copy and paste the contents below into your new smb.conf file.

; General server settings
netbios name = YOUR_HOSTNAME
server string =
workgroup = YOUR_WORKGROUP
announce version = 5.0

passdb backend = tdbsam
security = user
null passwords = true
username map = /etc/samba/smbusers
name resolve order = hosts wins bcast

wins support = yes

printing = CUPS
printcap name = CUPS

syslog = 1
syslog only = yes

; NOTE: If you need access to the user home directories uncomment the
; lines below and adjust the settings to your hearts content.
;valid users = %S
;create mode = 0600
;directory mode = 0755
;browseable = no
;read only = no
;veto files = /*.{*}/.*/mail/bin/

; NOTE: Only needed if you run samba as a primary domain controller.
; Not needed as this config doesn’t cover that matter.
;path = /var/lib/samba/netlogon
;admin users = Administrator
;valid users = %U
;read only = no

; NOTE: Again – only needed if you’re running a primary domain controller.
;path = /var/lib/samba/profiles
;valid users = %U
;create mode = 0600
;directory mode = 0700
;writeable = yes
;browseable = no

; NOTE: Inside this place you may build a printer driver repository for
; Windows – I’ll cover this topic in another HOWTO.
path = /var/lib/samba/printers
browseable = yes
guest ok = yes
read only = yes
write list = root
create mask = 0664
directory mask = 0775

path = /tmp
printable = yes
guest ok = yes
browseable = no

; Uncomment if you need to share your CD-/DVD-ROM Drive
;[DVD-ROM Drive]
;path = /media/cdrom
;browseable = yes
;read only = yes
;guest ok = yes

path = /media/samba/
browseable = yes
read only = no
guest ok = no
create mask = 0644
directory mask = 0755
force user = YOUR_USERNAME
force group = YOUR_USERGROUP

##****END of COPY*********

You will need to change certain lines from the codes above to configure SAMBA to your network. Firstly you have to tell SAMBA your network configuration so that it can communicate with your Windows box. For this tutorial, I’m going to make a dummy network for myself. You can change the network names, computer names and share folder names to your own desired settings.

Let say I have a workgroup called mynetwork and a Windows computer called wincom. The Linux box that I use as the server is called linuxcom with an account called firdooze. Change the settings as shown:

netbios name = linuxcom ; your desired hostname
workgroup = mynetwork ; your workgroup name

To find the name of your workgroup in Windows, you’ll need to do as follow:

1. hold the windows key + pause/break key (this will pop out the system settings).
2. Go to the “computer name” tab and look for your workgroup name.

wins support = yes

If you don’t have a static ip-address and you cannot configure your router/server to provide you with a fixed dhcp-lease, change this configuration parameter to “no”.

Towards the bottom of the codes, [MyFiles] is the name of the share name that you want Windows to use to access the files in your server directory. Under this heading is all the properties of your share files and folders. You can rename it to whatever you want for example, instead of MyFiles, you can change it to mainsharedfolder or limitedsharedfolder. Most importantly, do not use more than 31 characters and avoid spaces!

path = /media/hdb1/share ; the path of your shared folder on Linux

It is advisable to keep your shared folder on another partition or hard disk. Try not to share folders in your home folder. And of course this is just an example. You can use any path name as you wish.

force user = firdooze ; the name of your Linux login
force group = firdooze ; the name of your Linux login

There! You’ve already completed editing the smb.conf file. Save the file and close it.

Now in the command prompt type

sudo smbpasswd username

(where username is the name of the user)

sudo password for [username]:   (type your password)

Next, there is still the last part in configuring the Windows OS so as to allow it to access the Linux machine. This will be much simpler than what you’ve gone through so far.

Firstly open your Network Connections. Right click the connection that you use to connect to the web (active connection) and click on properties.
General Tab > Find & click Internet Protocol (TCP/IP) > Properties …. next ….
General Tab> Advanced button > WINS > ADD

Under TCP/IP WINS server type in the local IP address of your Linux box.
For example :
Then check on the radio button > Enable NetBIOS over TCP/IP

You will need to restart your computer first before the settings take into effect.

Finally, there are a few ways that you can access your Ubuntu machine.
1. Mapping network drive (Permanent):

Right click My Computer > Map Network Drive > Choose a letter for the drive.
Under folder, type in the hostname/IP address and share folder.
i.e //linuxcom/MyFiles (if you have WINS support) or //

2. Entering address on the Explorer bar (Temporary Access):
Enter your hostname/IP address and share folder into the explorer bar.
i.e \\linuxcom\MyFiles or \\\MyFiles
There you have it! A simple (but not 100% secure) way of sharing folders using Linux.


About saysprasad

Im a freedom lover.
This entry was posted in Network File Access and tagged , , . Bookmark the permalink.

4 Responses to How to access linux files from windows in a network using SAMBA

  1. oes tsetnoc says:

    Hi, Just like to tell you that this piece of info is one quick to the point, no nonsense, workable and effective way to have directories shared in my RHEL as fast as possible. It worked for me and thank you for the effort. Keep up the good work.

  2. jitendra says:

    compaq f733au head phone problem

  3. jitendra says:

    compaq f733au saund driver problem

  4. It’s really a great and helpful piece of info. I’m happy that you
    just shared this useful info with us. Please keep us informed like this.
    Thank you for sharing.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s