Learn Linux, 302 (Mixed environments): Install and upgrade Samba

Get Samba up and running

Like most software, Samba must be installed before it can be used. Several methods of doing this exist, but they fall into two broad categories: compiling and installing from source code and installing pre-built binary packages. The former is the more difficult but also more flexible option, while the latter is quite easy on most Linux distributions but locks you into the decisions your distribution maintainer has made concerning supported versions, patches applied, compile-time options enabled, and so on.


Roderick W. Smith, Consultant and author

Roderick Smith author photoRoderick W. Smith is a consultant and author of over a dozen books on UNIX and Linux, including The Definitive Guide to Samba 3, Linux in a Windows World, and Linux Professional Institute Certification Study Guide. He is also the author of the GPT fdisk partitioning software. He currently resides in Woonsocket, Rhode Island.

20 April 2011

Also available in Russian Japanese Spanish

About this series

This series of articles helps you learn Linux systems administration tasks. You can also use the material in these articles to prepare for the Linux Professional Institute Certification level 3 (LPIC-3) exams.

See our developerWorks roadmap for LPIC-3 for a description of and link to each article in this series. The roadmap is in progress and reflects the current objectives (November 2010) for the LPIC-3 exams. As each article is completed, it is added to the roadmap.

In this article, learn about these concepts:

  • Install Samba packages.
  • Install Samba binaries you've compiled yourself.
  • Upgrade an existing Samba installation.

This article helps you prepare for objective 311.2 in the Linux® Professional Institute (LPI) Certification level 3 (LPIC-3) LPI-302 exam. This objective has a weight of 1.


This article assumes that you have a working knowledge of Linux command-line functions and at least a general understanding of software structure (source code versus binary code) and your distribution's package management tools. To perform the actions described in this article, you must have a working Internet connection or Linux installation disc with the Samba package.

Choosing an installation method

About the elective LPI-302 exam

Linux Professional Institute Certification (LPIC) is like many other certifications in that different levels are offered, with each level requiring more knowledge and experience than the previous one. The LPI-302 exam is an elective specialty exam in the third level of the LPIC hierarchy and requires an advanced level of Linux system administration knowledge.

To get your LPIC level 3 (LPIC-3) certification, you must pass the two first-level exams (101 and 102), the two second-level exams (201 and 202), and the LPIC-3 core exam (301). After you have achieved this level, you can take the elective specialty exams, such as LPI-302.

The method you use to install Samba depends on your Linux distribution, the tools available to you, and your needs with respect to specific Samba versions and features. You'll find that some installation methods are impossible on some Linux systems. Although the RPM Package Manager (RPM) and Debian package methods are usually the best and easiest, only installing from source code is possible on all Linux systems—and that method can require installing additional software.

Most Linux distributions are built using either the RPM or the Debian package management system. Red Hat, Fedora, OpenSUSE, Mandriva, PCLinuxOS, and several other flavors use RPMs; and Debian, Ubuntu, and several more use Debian packages. When using one of these distributions, the easiest way to install Samba is invariably to install a Samba binary package provided by the distribution maintainer. You can install such a package using one simple command (or possibly a handful of commands), and the installation process usually finishes in a few seconds. Some distributions, such as Slackware, offer easy installation from other package types, but the details differ from the RPM and Debian package instructions provided here.

Build your own feed

You can build a custom RSS, Atom, or HTML feed so you will be notified as we add new articles or update content. Go to developerWorks RSS feeds. Select Linux for the zone and Articles for the type, and type Linux Professional Institute for the keywords. Then, choose your preferred feed type.

Installation from source code enables you to customize the Samba options and optimize the compilation for your particular computer and network needs. You can also install a Samba version that might not yet be available for your distribution using source code. Source installation requires extra steps, though, and can take much longer than a binary installation. The Gentoo distribution installs most software from source code but using a streamlined procedure that's more like using an RPM or Debian package; consult Gentoo's documentation for details.

In most cases, you should install Samba from an RPM, Debian package, or other distribution-specific binary package. Source code installation makes sense mainly if this isn't possible or if you have exotic needs that require unusual customization during the build process.

Installing from source code

The previous article in this series described compiling Samba source code. If you want to install Samba from source, you should begin with that process. This article assumes that you have already compiled your source code and need only install it.

Making an initial installation

If you have compiled Samba source code, you can install it by typing the following command in the source code's build directory (typically source3 within the Samba source directory tree):

# make install

You must type this command as the root user.

Typically, this command installs Samba to the /usr/local directory tree, which is the usual location for locally compiled binaries.

Note that installing Samba from source code does not install a System V (SysV) or Upstart startup script, so Samba will not start automatically when you reboot the computer. The upcoming section, Launching Samba, briefly describes this topic.

Upgrading to a new version using source code

If you've previously installed Samba from source code, following the procedure just described renames the old program files with the .old extension. Typing make revert reverts to the old versions, should you decide the new version isn't working properly.

If you want to completely remove an old version of Samba that was installed from source code, you should change into that version's source code directory and type make uninstall. This command removes the installed software. You can then install a new version (either from source code or from a binary package) without fear of conflict between the two versions.

If you've previously installed Samba from a binary package, that version and your locally compiled version can theoretically coexist on your computer; however, keeping both installed can lead to confusion, because chances are only one will run. Thus, it's best to remove the old binary packages before installing the new software. Typing rpm -e samba uninstalls an RPM package, and dpkg -r samba uninstalls a Debian package. (You may need to change the package name or uninstall multiple packages, depending on how your distribution created its Samba packages.) Before you uninstall a binary package, you may want to back up its SysV or Upstart startup script; you can probably modify this script to start your locally built version of Samba.

Installing an RPM

RPM is a popular and powerful package management system. You can install software by downloading RPM files and using the rpm command to install them, or you can use a meta-packaging system, such as the Yellowdog Updater, Modified (YUM) to handle some of the tedious details, including installing or upgrading dependencies.

Installing packages using YUM

YUM is a standard part of Red Hat, Fedora, and some other RPM-based distributions. Some RPM-based distributions provide different tools with similar functionality.

To install a package using YUM, you use the yum command as root, passing it the install subcommand and the name of the package to be installed:

# yum install samba

Note: Samba package names vary from one distribution to another. It's possible you'll need to install the package using a name other than samba, such as samba-server. The name samba works with Fedora Linux.

After you type this command, YUM checks its repositories, downloads the latest package or packages, and installs them. In some cases, this command installs more than one Samba package or installs non-Samba dependencies. On a Fedora system, for instance, installing the samba package installs samba-common and samba-client as well as samba.

Graphical YUM utilities, such as Yumex (aka Yum Extender; command name yumex), are also available. You can use such a tool to search for and install Samba or related packages, as shown in Figure 1. Yumex and other graphical user interface (GUI) tools can be particularly useful for finding packages related to Samba, such as the Samba Web Administration Tool (SWAT; samba-swat) package visible in Figure 1.

Figure 1. Yumex provides a GUI front end to package management on some RPM-based systems
Yumex provides a GUI front end to package management on some RPM-based systems

Installing packages using rpm

Sometimes, you can't use YUM, because your distribution doesn't support it. You might also want to install an RPM package you've obtained from a site that YUM doesn't support; for instance, you might have found a more recent package than the version provided by your distribution maintainer. In such cases, you may need to use the rpm utility to install your software.

If possible, you should use gpg to check your software package's authenticity before installing it, as described in the previous article in this series. When that's done—or if you can't or choose not to perform this test—you can use the --install (or -i) option to rpm to do the job. You may want to add the --verbose (-v) and --hash (-h) options to provide a display as the package is installed. The final command looks like this:

# rpm -ivh samba-3.5.6-69.fc13.x86_64.rpm

You must, of course, change the Samba package file name to match the file you've downloaded. If your attempt to install the software results in an error message, you will have to resolve the problem manually. Most commonly, you must install prerequisite software. You can do so using YUM, or you can manually locate and download the necessary software and install it before you install the Samba package or even at the same time by including multiple file name references on one rpm command line.

Upgrading to a new version using RPM

Upgrading software using RPM is a snap. If you use YUM, the process is just like installing the software; however, you can optionally use the update subcommand rather than the install subcommand. If you use rpm directly, you should use the --upgrade (-U) option rather than --install (-i). In fact, you can use --upgrade/-U to install new software, too, so some administrators use this command rather than --install/-i even for new installations.

When you use RPM to upgrade software, the RPM utilities uninstall the old software and install the new version, ensuring that any outdated files are automatically removed. You may want to check your configuration files, such as /etc/samba/smb.conf. Typically, your existing configuration files will be left unchanged, and an updated sample configuration file will appear with a similar file name, such as /etc/samba/smb.rpmnew, so that you can refer to it should there be any configuration file changes that require adjustments to your configuration. As a safety precaution, you might want to back up your original configuration files before upgrading.

Installing a Debian package

Debian packages are conceptually similar to RPM packages, but the details of the utilities involved to manipulate the packages differ. Debian and Ubuntu are the major distributions that use Debian packages, although several others also use this package type.

Installing using APT

The Advanced Package Tools (APT) suite provides network-enabled package management, including dependency resolution, similar to the YUM suite used by many RPM-based distributions. (APT is also available for many RPM-based distributions, and at least one—PCLinuxOS—uses APT by default.)

Before installing Samba, it's best to force APT to obtain the latest package lists. You can do this using apt-get and its update subcommand:

# apt-get update

Typing this command causes APT to check with its configured repositories to obtain the latest list of available packages, so that you will install the latest version of Samba available for your system. To install a package using the command-line APT tools, you can use the apt-get utility and its install subcommand:

# apt-get install samba

The result will be a summary of the packages that will be installed, removed, and upgraded as well as suggestions of optional packages that you might want to install. If you approve of the changes, you can type Y at the prompt. The utility then downloads the necessary packages and installs them using lower-level Debian package management tools.

If you prefer using a GUI tool, the Synaptic utility (command name synaptic), shown in Figure 2, will do the job. As with Yumex, Synaptic is particularly helpful if you're not sure of the exact name of the package you want to install or if you need to locate ancillary packages.

Figure 2. Synaptic provides a GUI front end to package management on most Debian-based and some RPM-based systems
Synaptic provides a GUI front-end to package management on most Debian-based and some RPM-based systems

Installing using dpkg

If you can't or don't want to use APT to install Samba, you can do so with the lower-level dpkg utility, which operates on Debian package files (with .deb file name extensions) you can download from the Internet or transfer from one computer to another in some other way. If possible, it's best to verify your package's authenticity using gpg, as described in the previous article. You can install a new package using the --install (-i) option:

# dpkg -i samba_2:3.5.4~dfsg-1ubuntu8.1_i386.deb

Assuming that all depended-upon packages are already installed, this command installs the relevant Samba package. If dependencies are not satisfied, dpkg will complain. You must then install the relevant packages, either using APT or manually via dpkg. (You can install multiple packages using one dpkg command, if you like.)

Upgrading to a new version using Debian packages

You can upgrade Samba using apt-get or dpkg in exactly the same way you would install Samba initially using these tools. Unlike the RPM tools, there's no separate option for upgrading software. As when using RPM, you should check your configuration files to be sure they haven't been changed and to look for new sample files in case the new version includes new options you might want to use.

If you're using APT, be sure to upgrade your database of available software by typing apt-get update before you use the install subcommand. You can also upgrade all the software on your computer by typing apt-get upgrade or apt-get dist-upgrade. (The latter command performs more sophisticated dependency resolution checks, which can result in some outdated packages being removed.)

Launching Samba

If you install Samba using a binary package designed for your distribution, it will include a SysV or Upstart startup script to launch Samba when you restart the computer. This script might or might not be active when you first install the package, though. You should use your local startup management tools, such as chkconfig (common on Fedora and related distributions), rc-update (common on Debian-based systems), or manual inspection of SysV startup links or Upstart configuration files, to determine in which Runlevels Samba will start.

Note: Although it's possible to run Samba via a super server such as inetd or xinetd, such configurations are rare and create performance problems.

If you've installed Samba from source code, you will have to create your own SysV or Upstart startup script or launch the server via an entry in a local startup script, such as /etc/rc.d/rc.local or /etc/init.d/rc.local. Typically, you'll want to launch both the smbd and nmbd servers and pass them both the -D option, which causes the servers to run as daemons. A minimal configuration looks like this:

/usr/local/sbin/nmbd -D
/usr/local/sbin/smbd -D

Of course, you must adjust the path to the binaries to suit your configuration. You may also want to launch associated servers, such as SWAT, in a similar manner.

Moving forward

The LPIC-3 312.1 objective—and the next article in this series—describe the basics of Samba configuration, including the structure of the Samba configuration file, setting basic Samba options, and debugging common problems.



Get products and technologies

  • Download Samba and find additional information at the Samba website.
  • Evaluate IBM products in the way that suits you best: Download a product trial, try a product online, use a product in a cloud environment, or spend a few hours in the SOA Sandbox learning how to implement Service Oriented Architecture efficiently.


  • Get involved in the My developerWorks community. Connect with other developerWorks users while exploring the developer-driven blogs, forums, groups, and wikis.


developerWorks: Sign in

Required fields are indicated with an asterisk (*).

Need an IBM ID?
Forgot your IBM ID?

Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.


All information submitted is secure.

Dig deeper into Linux on developerWorks

ArticleTitle=Learn Linux, 302 (Mixed environments): Install and upgrade Samba