Share files between Linux and Windows
بســـــــــــــم الله الرحمن الرحيــــــــــــــم
I finally just finished installing a dual boot XP 64bit and Ubuntu 64bit on a high end machine and shared the files between the Linux and another machine that has XP 64bit through a crossover cable. Sharing the files between linux and windows was new to me, I didn’t know that Linux cannot see windows shares without installing a special tool called Samba. In this article I will do my best to explain the process of sharing a files between linux and windows to save other people the headache of searching for the solution from different resources.
-
The basic steps – will go quickly over them
Now we have 2 machines, 1 with XP installed and the other one has Linux Ubuntu
On the windows machine select the folder that you want to share, share it and give it a share name say “WinShare”
Assign the NIC card on both the windows machine and Linux an IP Address, Subnet and default gateway.
Windows: 192.168.1.100 255.255.255.0 192.168.1.1
Linux: 192.168.1.101 255.255.255.0 192.168.1.1
Have a user name with password on the Linux and windows machine
Windows: Username: Administrator Password: Musab
Linux: Username:Musab Password:Musab OR username: root password:Musab
-
Installing Samba
now that both are connected, windows can see linux shares but the other way around so will need to install a tool called Samba
Open the terminal and log-in as root using the sudo command or sudo su on some new Ubuntu versions
Type apt-get install samba smbfs
Now that you have it installed, let’s configure it, edit the configuration file by entering the command
gedit /etc/samba/smb.conf
Find the following section in the file
####### Authentication #######
# “security = user” is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
Delete the first line that starts with #”security =
replace it with
security = user
username map = /etc/samba/smbusers
This will tell Samba to look in the smbusers file to get the list of usernames and passwords
Now let’s create a Samba user account, replace <username> with any name you prefer
smbpasswd -a <username>
in out example I will use MusabSamba –> smbpasswd -a MusabSamba
Now we will need to add that user to the smbusers file we discissed earlier
gedit /etc/samba/smbusers
In the file type the following, replacing the first username with your Linux username and the second with Samba username we created earlier
<username> = “<username>”
In out example its <Musab>=”<MusabSamba>”
I added this line too just for being paranoid o make it work <root>=”<MusabSamba>”
Now you can create the shares, next step I will walk you through the steps of mounting windows shares
-
Mounting Windows Shares:
Open the terminal, and login as root
First you will need to add some lines to the /etc/hosts files
gedit /etc/hosts
Give the windows machine any name by adding the line
192.168.1.100 anyName
Save and close the file. Create a new folder where the share will appear
mkdir /mnt/winFiles
Edit the /etc/fstab file and add the following (Notice the windows machine name we assigned and the folder we created)
//anyName/winFiles /mnt/winFiles cifs exec,credentials=/etc/cifspw 0 0
Notice the line will use a file called cifspw that contains the credentials, let create the file
gedit /etc/cifspw
In this file you need to add the username and password for the windows machine we discussed earlier
username=Administrator
password=Musab
Save and close. Now secure the file with this command
chmod 600 /etc/cifspw
finally type
mount -a
You should see the shared folder under /mnt/winFiles or under Places tab and click network.
-Enjoy



In Ubuntu 9.04, using Samba is easy as pie. Open up Places -> Network -> [the name of the windows PC] to connect to a windows computer using Samba. From here you can mount network shares automatically just by double-clicking on them.
probabilityzero
August 12, 2009