How To Share Files Between Unix and Windows Using Samba

Sharing files between computers is easy when both the computers is Windows. If we want to share or transfer files from Windows to Unix we need to do some file sharing configuration like Samba or NFS in the Unix box. In this post we will see How To Share Files Between Computers more specifically between Unix and Windows machine using Samba.

Samba is a freely available SMB server for UNIX and its an easy file share option between Unix and Windows machines. You can read about it hereConfiguring Samba on Solaris is easy and it helps a lot if you want to share files frequently between Unix and Windows machines. Here we will see how to configure Samba on a Solaris-x86 box in the network.

This is our Solaris box:
root@redcoral#uname -a
SunOS 5.10 Generic_147441-01 i86pc i386 i86pc

Solaris 10 comes with Samba installed as part of the operating system. We can check the version with the following command:
root@redcoral#/usr/sbin/smbd --version
Version 3.5.8

We can also check the packages for Samba that are installed:
root@redcoral#pkginfo  -i | grep -i smb
system      SUNWsmbac               samba - A Windows SMB/CIFS fileserver for UNIX (client)
system      SUNWsmbar               samba - A Windows SMB/CIFS fileserver for UNIX (Root)
system      SUNWsmbau               samba - A Windows SMB/CIFS fileserver for UNIX (Usr)

Check if the process is running:
root@redcoral#ps -ef | grep smb | grep -v "grep"
No process for Samba running!

We can also see the service status with the following command:
root@redcoral#svcs -a | grep samba
disabled       Dec_23   svc:/network/samba:default

The actual configuration is just editing the smb.conf file and starting the service. The Samba configuration file is located at: /etc/samba/smb.conf-example
We can of-course find this example conf file with the Solaris pkgchk command also.

Step 1: Make a copy of smb.conf from the example file:
root@redcoral#cp /etc/samba/smb.conf-example /etc/samba/smb.conf

Step 2: Open the file smb.conf with some editor, e.g. #vi /etc/samba/smb.conf
Change security = user to security = share
# Security mode. Defines in which mode Samba will operate. Possible
# values are share, user, server, domain and ads. Most people will want
# user level security. See the Samba-HOWTO-Collection for details.
   security = share

And add the following at the end of file and then save and exit:
   path = /opt/smbshare
   public = yes
   guest ok = yes
   writable = yes
   printable = no
   force user = nobody
   force group = nogroup

Step 3: Create the directory:
root@redcoral#mkdir /opt/smbshare

Note that here I am sharing the folder to all users in my network, no user account/authentication is required to access the folder. The entry "security = share" is used for sharing to everyone.
Give appropriate permissions for the directory as per the user created for Samba access.

Step 4: Now start Samba service and then check if service is running:
root@redcoral#svcadm enable samba
root@redcoral#svcs -a | grep samba
online          0:40:22 svc:/network/samba:default

Now from our windows box:
Click Start -> Run and type \\\smbtest in order to access the files. Or do a Windows to Unix file transfer by just copying a file in there.

Thats it, pretty easy, right?
Now we can easily share large files between the computers just like Windows file sharing. Go ahead and share all your songs and photos to your colleagues ;)

For NFS share between Unix machines refer here.

No comments:

Post a Comment