Friday, September 17, 2010

How to Setup Samba in Linux

Make sure we have the Samba package installed. For example, we want to share the /tmp directory in Linux so that we can access it from our Windows or from another Linux client (NFS is better for Linux to Linux file sharing), we need to do the following:
1. Edit /etc/samba.conf add the following lines
    comment = Test
    path = /tmp
    writable = Yes
    public = Yes
2. Add a Samba user.
smbpasswd -a sambauser
Enter the password.
3. We need to open firewall for the following ports:
- 137 (netbios-ns)
- 138 (netbios-dgm)
- 139 (netbios-ssn)
- 445 (microsoft-ds)
For more info, see /etc/services
3. Restart smb daemon.
/etc/init.d/smb restart

For Windows client to access the shared directory:
1. Go to Run and enter \\[ip_address]\tmp
2. Enter the Samba username and password.

For Linux client to access the shared directory:
mount -t cifs // -o username=sambauser,password=password samba/

No comments:

Post a Comment