Contents


Learn Linux, 302 (Mixed environments)

Install and upgrade Samba

Get Samba up and running

Comments

Content series:

This content is part # of # in the series: Learn Linux, 302 (Mixed environments)

Stay tuned for additional content in this series.

This content is part of the series:Learn Linux, 302 (Mixed environments)

Stay tuned for additional content in this series.

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.

Prerequisites

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

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.

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
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
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.


Downloadable resources


Related topics


Comments

Sign in or register to add and subscribe to comments.

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Linux
ArticleID=649228
ArticleTitle=Learn Linux, 302 (Mixed environments): Install and upgrade Samba
publish-date=04202011