Samba: How do you install and set up Samba in linux? [Redhat Enterprise(RHEL), CentOS, Fedora]


Setting up Samba “can” be complicated at times. Especially if you are looking for instructions online where there are WAY too many tutorials which go in to details about what configuration does what, etc. Well, this post is nothing like that. Here I just show you quick and easy way to install Samba, configure it, and set up the drive letter on your XP/Vista. NOTE: for using Samba with Vista, please see my previous post in which I talk about changing settings in Vista so you can connect to your Samba share: Windows Vista Installation

NOTE: This set up is very “open” and should not be used on servers which are facing the world. This is for private network where you trust all the computers and its users.

Installing Samba (using yum on CentOS and Fedora): yum install samba
Installing Samba (using rpm):

  1. Obtain Samba rpm from rhn.redhat.com
  2. rpm -ivh samba*.rpm

Configuring Samba:
cd /etc/samba
mv smb.conf smb.conf.backup
vi smb.conf

Paste content below in to your vi:

[global]
workgroup = wrkgrp
netbios name = smbserver
security = SHARE
load printers = No
default service = global
path = /home
available = No
encrypt passwords = yes
[share]
writeable = yes
admin users = smbuser
path = /home/share
force user = root
valid users = smbuser
public = yes
available = yes

save and exit

adduser smbuser #add unix account
passwd smbuser #set unix account password
smbpasswd -a smbuser #lets create same user account on samba
<put same password as your unix account password>
/etc/init.d/smb restart

Now let us setup drive letter on our Windows so we can easily access these files.

Start -> run -> cmd <enter>

At the prompt type: net use z: \\ip_of_your_samba_server\share /user: smbuser password_you_assigned

That is it! At this point you have successfully set up Samba under Linux and are now successfully connected to your share from your Windows machine.


51 Responses to “ Samba: How do you install and set up Samba in linux? [Redhat Enterprise(RHEL), CentOS, Fedora] ”

  1. Phillip Weingart
    May 31st, 2007 | 11:48 am

    Worked like a champ. Had it configured in less then 10 minutes

  2. September 5th, 2007 | 4:52 pm

    Thank you very much. Your Instructions were excellent.

    Thank you.

    Nick

  3. October 2nd, 2007 | 3:28 am

    cd /etc/samba
    mv smb.conf smb.conf.backup
    vi smb.conf

    Quick update, you might wanna do a CP instead of an MV, or the above series of commands won’t work. :-)

  4. December 10th, 2007 | 12:01 pm

    Michael, yes they do. done it many times.

  5. Tyler
    March 6th, 2008 | 1:00 am

    Great instructions!
    I’m having password issues even after resetting passwd and smbpasswd multiple times, any ideas? iptables set to allow…

  6. March 6th, 2008 | 10:39 am

    Tyler,
    Can you:
    tail /var/log/messages
    and see what errors you are getting. Are you using windows XP? or vista? how are you mapping the drive? via explorer or cmd prompt?

  7. March 26th, 2008 | 12:54 am

    I think michael was right.. it won’t work if you move the configuration file. What will it read if there’s no smb.conf?

  8. March 27th, 2008 | 10:25 pm

    You should try it out Jon. Works fine. Thats why you do “vi smb.conf”

  9. May 1st, 2008 | 9:44 pm

    make sure the directory you are sharing exists /home/share and set with the proper security settings.

    great instructions!

  10. Robert Swan
    July 9th, 2008 | 9:27 pm

    Forcing samba users to be root???

    That is a BAD idea!

  11. July 10th, 2008 | 12:47 pm

    Robert, of course it is bad to force root but as i said in the post: NOTE: This set up is very “open” and should not be used on servers which are facing the world. This is for private network where you trust all the computers and its users.

    This is for people to get samba setup and working and take it from there.

  12. jp
    August 16th, 2008 | 3:36 am

    I have followed above smb.conf and i restarted the smb server after that i tried to access from win xp machine. I opened my network places it shows Wrkgrb i.e name of the work group we mentioned in the smb.conf file It shows error message like “wrkgrp is not accessible. you might not have permission to use this resource……………The device not connected.

    I tried in the explorer typing \\ipaddress of linux box . it tells windows can not find.

    As mentioned in the via cmd it says

    C:\Documents and Settings\smbuser>net use z:\\10.0.0.100\share /user:smbuser
    System error 67 has occurred.

    The network name cannot be found.

    I tried so mamy times but failed.

    Please find out my mistake

  13. Jon
    August 23rd, 2008 | 10:58 am

    I’ve following the above instructions, except the net use; to check if the share exists I used \\, to see if there are any shares however, from my WinXP maching I’m getting an error:
    \\
    Network path not found.

    The same IP address is returning a ping reply. Any ideas?

  14. August 23rd, 2008 | 12:57 pm

    Jon, just type net use

    Nothing should follow after use

  15. Jon
    August 23rd, 2008 | 1:11 pm

    Thanks for correcting my typo. Still can’t access samba share though.

  16. Paul B.
    September 13th, 2008 | 7:28 am

    Yes, it looks curious to start with, but we are not *editing* the config file, but writing a whole *new* one with only the skeleton commands!

    KISS philosophy.

    I’m presently having problems getting SMB to work on Fedora 9. It’s running, share mode, null passwords, suitable workgroup, but just can’t be seen in N. Neighbourhood.

  17. Brandon
    March 3rd, 2009 | 11:44 am

    I had a ton of issues connecting… “wrkgrp is not accessible. you might not have permission to use this resource…The device not connected.

    My fix was actually disabling the SELinux in the firewall.

    system-config-securitylevel-tui (Opens the firewall)
    - Disabled
    - SELinux – disabled

  18. Jimbo
    May 11th, 2009 | 2:30 pm

    Thanks, this was very helpful.

  19. June 22nd, 2009 | 9:51 pm

    [...] configuring Samba in a Linux machine to share the data with other OSs is pretty easy. Please refer Samba: How do you install and set up Samba in linux? [Redhat Enterprise(RHEL), CentOS, Fedora] | Tec… that should help! __________________ Who am [...]

  20. Muc
    July 10th, 2009 | 1:22 pm

    Hi:

    I’m having a problem with this tutorial, I configured the samba server and it seems to be working, but when I try to access it from a WinXP I get a logon failure: unknon user name o bad password. I’m trying to enter as smbuser.
    It gets better :) . I’m using a VM running RHEL 5 on a WinXP host and I’m trying to access a particular directory from the physical machine to the VM… any ideas? Thanks!
    P.S.: The other way around is working just fine. I believe it must be a pwd problem, but I just can’t figure it out…

  21. mehnaz
    July 15th, 2009 | 12:39 am

    i have followed the instructions up to /etc/init.d/smb restart, at this point i am getting error no such file or directory. i have checked init.d but am not able fo find any thing related to samba there lika smb or samba,,i have no idea what should i do as a am totally newbie in linux:(

  22. dinesh rana
    August 25th, 2009 | 8:17 pm

    i want to install linux services eg samba plz how to install samba

  23. harpreet
    September 1st, 2009 | 8:19 pm

    Works great, make sure you have smae work group name in both linux and windows configuration

  24. jessem
    September 24th, 2009 | 8:42 pm

    I keep getting the error:

    system error 64 has occured.

    The specified name is no longer available.

    is this a netbios issue with vista?

  25. September 24th, 2009 | 9:58 pm
  26. October 20th, 2009 | 10:38 am

    For people getting persistent password errors please be sure that you are using the net use command correctly. If it prompts you for the username then windows will submit it incorrectly.

  27. Raxxal
    March 15th, 2010 | 6:46 pm

    The net use command is not working for me, I am using Windows 7. However, I was able to map the share folder using Mycomputer, right click on it, etc.

  28. Shirish.linux
    April 13th, 2010 | 2:09 am

    heis,

    try this!!

    1>ensure u had insatlled all 3 samba rpm , better do everything installation
    2>off firewall in linux
    3>off firewall in windows … for who who don’t know deny allow etc..
    4>configure /etc/samba/smb.conf
    5>touch smbpasswd .. in same pwd
    6>addsamab user it’ nessary to have a valid linux user
    7>smbpasswd -a username
    8>be ensure to add password path in smb.conf file
    smb passwd file = /etc/samba/smbpasswd
    encrypt passwords = yes
    9>use testparm … to know morew about smb.conf values
    10>start below services
    service smb restart
    testparm
    for safty purpose start network servic to
    services network start

    11>In windows do below
    a>in firewall setting –>advanced tab–> select lan connection and enable file share option to clicked … check now

    ensure ur ipaddress in same class and netmaked and workgroup
    is to be same
    in windows-my computer–>property–>computer name –>change–>computer name and workgroup

    do –>run->cmd
    net view
    …will she shares u will see all shares if u done above correctly u are lucky to have ur linux shared folder name with detail
    my network palce–> \\linuxworkgroup <–

    have a fun!!
    doubt mail me or print here ur query!!

  29. sandy
    May 16th, 2010 | 5:01 pm

    if I am using a domain can I use the domain name as workgroup. I have not build one yet I am planning to host a linux DNA, DHCP apache and email server with xp , windows 7 and vista each. will the instruction above work in the setting.

  30. Neil
    July 24th, 2010 | 1:10 pm

    Just one small issue. I have just downloaded Samba 3.5.4. It is taking hours to install. Seriously, it is quicker to re-install Fedora or Red Hat.

    [ Oh, by the way, the phrase is "worked like a charm" not a "champ" ]

  31. Bobby
    August 4th, 2010 | 8:22 am

    I can see the share from my Windows machine but when I go to open it I am asked for a password and it does not authenticate. Any suggestions?

  32. 1337ingDisorder
    September 29th, 2010 | 12:26 pm

    Following the above guide produces an error when I try to connect.

    Connecting from a Windows desktop I get the error:

    “No network provider accepted the given network path.”

    When I try smbclient -L -U from the samba server machine, it successfully lists the available samba shares.

    however when I try smbclient ///share -U it then gives me this error:

    “tree connect failed: NT_STATUS_BAD_NETWORK_NAME”

    What am I doing wrong?

  33. September 29th, 2010 | 12:45 pm

    Do you have firewall turned on? read the comments and see if something helps there.

  34. October 2nd, 2010 | 9:45 pm

    [...] restart This entry was posted in Uncategorized. Bookmark the permalink. ← CentOS boot in text [...]

  35. October 12th, 2010 | 6:36 am

    [...] with command yum install samba I then followed the steps which i got by some googling on http://crazytoon.com/2007/05/22/samb…centos-fedora/ this site which contains steps like: cd /etc/samba mv smb.conf smb.conf.backup vi smb.conf Paste [...]

  36. October 21st, 2010 | 4:10 am

    [...] Samba issues I'm attempting to setup a simple samba share as per instructions below. however when i try to access the share i cannot log in from windows machine. my samba log says "authorise_login: rejected invalid user nobody" is there a something wrong with the documentation below? Samba: How do you install and set up Samba in linux? [Redhat Enterprise(RHEL), CentOS, Fedora] | Tec… [...]

  37. ben
    December 22nd, 2010 | 10:00 am

    awesome post, had it setup so quickly its good to get stuff that works right off the bat and no scrambling around.

    great stuff.

  38. Swapnil
    January 2nd, 2011 | 11:27 pm

    Simple and nice trick……….

    But we have to disable iptables & selinux

  39. May 3rd, 2011 | 10:47 am
  40. May 4th, 2011 | 6:34 pm

    What do you have to do next after you have done this step?

  41. melissa dewar
    June 11th, 2011 | 6:26 pm

    what should i try if yum install samba command doesn’t work?

  42. naresh reddy sanku
    June 21st, 2011 | 8:23 am

    thank u very much.. it was very helpfull

  43. December 25th, 2011 | 1:25 am

    I was searching comprehensive site for Samaba configuration and was struggling to configure samab
    this article helps me a lot
    thanxxxxxxxxxxxx

  44. krishnakumar
    December 29th, 2011 | 9:44 am

    Friends i need to share some of the folders of Redhat linux5.3 through SAMBA to windows machines ,Istruck up with a situation that SAMBA shared folders are visible in windows xp machine but i am unable to open the folder with samba user name and password, please help

  45. yubaraj
    January 24th, 2012 | 2:44 am

    “A network provider cannot given to network path please contact administrator ”
    what does it mean

  46. February 20th, 2012 | 4:27 pm

    Hi,
    Nice tutorial and guidelines. I have installed and configured samba on rhel 6. refer to this post :
    http://www.ehowstuff.com/how-to-install-and-configure-samba-server-on-rhel-6/

  47. G.lopez
    February 25th, 2012 | 9:43 am

    thanks

  48. Pako
    July 27th, 2012 | 3:41 am

    [root@localhost ~]# cd /etc/samba
    [root@localhost samba]# ls
    lmhosts passdb.tdb secrets.tdb smb.conf
    [root@localhost samba]# mv smb.conf smb.conf.$$
    [root@localhost samba]# ls
    lmhosts passdb.tdb secrets.tdb smb.conf.5941
    [root@localhost samba]#
    [root@localhost samba]#
    [root@localhost samba]# vi smb.conf
    [root@localhost samba]#
    [root@localhost samba]# adduser smbuser
    [root@localhost samba]# passwd smbuser
    Changing password for user smbuser.
    New UNIX password:
    BAD PASSWORD: it is based on a dictionary word
    Retype new UNIX password:
    passwd: all authentication tokens updated successfully.
    [root@localhost samba]#
    [root@localhost samba]# smbpasswd -a smbuser
    New SMB password:
    Retype new SMB password:
    startsmbfilepwent_internal: file /etc/samba/smbpasswd did not exist. File successfully created.
    Added user smbuser.
    [root@localhost samba]# /etc/init.d/smb restart
    bash: /etc/init.d/smb: No such file or directory
    [root@localhost samba]#

  49. Pako
    July 27th, 2012 | 3:45 am

    Please help with this error: bash: /etc/init.d/smb: No such file or directory

    I followed your instructions

  50. March 2nd, 2014 | 3:58 am

    The other day, while I was at work, my cousin stole my iphone and
    tested to see if it can survive a 40 foot drop, just so she can be a youtube sensation.
    My iPad is now destroyed and she has 83 views.
    I know this is totally off topic but I had to share it with
    someone!

  51. March 8th, 2014 | 4:52 am

    Leather jackets from the 1950s are specially well-known and in substantial desire.
    For a whopping $24,000 you get oodles of tools, protective gear, cases,
    and weapons equipment. That seems to be the case with Facebook, which, as
    reported by Tech – Crunch’s Erick Schonfeld, has removed a piece of fine commercial
    ingenuity from its site.

Leave a reply

*
To prove that you're not a bot, enter this code
Anti-Spam Image