Linux.com

Home Learn Linux Linux Tutorials Quick and dirty Samba setup

Quick and dirty Samba setup

Most current Linux distributions, including Slackware 11, have Samba already installed and running after the system boots. This article assumes that Samba has been installed. The commands work for Slackware version 11 and 10.2, and likely many other Linux distros.

The first step is to create a share folder on your hard drive; for instance, /disk2/data. After that, you need to edit the smb.conf file, found in /etc/samba, and make it look something like this:

# Global parameters
[global]
       workgroup = HOME
       netbios name = SAMBA
       server string = Samba Server %v
       map to guest = Bad User
       log file = /var/log/samba/log.%m
       max log size = 50
       socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
       preferred master = No
       local master = No
       dns proxy = No
       security = User

# Share
[Data]
       path = /disk2/data
       valid users = joel
       read only = No
       create mask = 0777
       directory mask = 0777

You can copy and paste this into your conf file or make changes to your existing one.

The workgroup name needs to be the workgroup of your Windows computers, or your domain name. The netbios name is what will appear when you access the Linux computer from Windows. I am currently running a Windows domain with this setup, so I have the preferred master and local master set to no to avoid both servers from attempting to be the master browser. This will eliminate network conflicts on your Windows computers that can cause network-related outages.

For the share details, specify the valid users, or set them up later. In that section you can allow users to create their own folder and files for all to access.

The next step is to add users by the following command:

# useradd -c "Joel Nahrgang" joel
# smbpasswd -a joel
New SMB password: secret
Reenter SMB password: secret
Added user joel

Next, run the testparm command to ensure that the conf file is valid. If it returns no errors, restart Samba with the command /etc/rc.d/rc.samba restart. You should also make Samba executable when the server is rebooted with the command chmod 755 /etc/rc.d/rc.samba.

If you would like to tidy up your smb.conf file, the following commands will back up the file, then remove all the comments for easier reading:
# cd /etc/samba
# cp -a smb.conf smb.conf.master
# testparm -s smb.conf.master > smb.conf

Now you're ready to test Samba. On a Windows computer, you can either map a drive to the Samba server or access the drive using the Start-Run command and typing \\Samba\data, "Samba" being the server name and "data" being the shared folder.

One disclaimer: this setup serves a small network or a home network. For a larger user base and more complex network configuration, you may want to use the documentation provided on the Samba Web site.

 

Comments

Subscribe to Comments Feed
  • Emu Mantoid Said:

    Great quick and dirty tutorial. Saved me a ton of time. But I think you should change a few things. You should make it clear that if you don't have Samba installed, just install it with "apt-get install samba" You should also mention that smbpasswd needs to be run as root. One last thing, to stop and start the smbd you should use "survice smbd stop/start/restart" But, considering this article is 7 years old I guess I can't complain.

  • Randy Said:

    Shouldn't that be service and not survice?

  • dre Said:

    This is awesome. It got my samba setup running in less than 5 minutes on Debian 7. Thanks!

  • crainweb2000 Said:

    Thanks. This was pretty straightforward direction, but didn't work the first time. Looking through the smbpasswd help got me to try the -e option (for enabling the user). BAM! Don't know if it was specific to my situation, but your post got me there.

  • David Said:

    Thanks for adding the how to get samba part, but it did not work for me. I got ... -sh: apt-get: command not found. I am running Linux_image_for_SD_Intel_Galileo_v0.75 Clanton for the Arduino board. I find most commands don't work.

  • Jacob Said:

    perfect! this is a delight in the jungle of samba tutorials. one shot and it works.

Upcoming Linux Foundation Courses

  1. LFD320 Linux Kernel Internals and Debugging
    03 Nov » 07 Nov - Virtual
    Details
  2. LFS416 Linux Security
    03 Nov » 06 Nov - Virtual
    Details
  3. LFS426 Linux Performance Tuning
    10 Nov » 13 Nov - Virtual
    Details

View All Upcoming Courses

Become an Individual Member
Check out the Friday Funnies

Sign Up For the Linux.com Newsletter


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board