Written in Perl and easy to install and use, Stow is simple yet effective for organizing and managing various software installations on a Linux box. Stow is handy for arranging different software packages in a well-organized directory tree structure. This not only helps keep files that belong to a particular software package separate from others, but also gives users the freedom to store or install the software package at any desired location while making the software appear to be installed at the location required by the software package or the OS.
Note: An intermediate-level knowledge of Linux and experience installing Linux applications will be helpful in understanding this article. For this article, we are using Stow version 1.3.3 and Perl version 5.005.
Software installation management for Linux
Before getting acquainted with Stow, let's first take a look at software installation management, also known as package management. Software installation management describes collectively the activities of installing, uninstalling, updating, and organizing software applications, or packages, on a system. Among these activities, organizing applications is an especially important activity. Installing, upgrading, and uninstalling applications on a Linux box become easier and more convenient if the applications are organized neatly.
On Linux systems, most applications are required to be installed in some specific directory (which is usually /usr/local/), to run and function properly; the requirement comes either from Linux or from the application itself. This does not pose any serious problem if there are few applications installed on a Linux system and their respective files can be easily distinguished from one another.
For real life scenarios, however, where there may be a large number of applications installed in the same directory, that directory soon gets messy. Imagine installing an application that accidentally overwrites a file belonging to another application, and then you have to replace the file. Or imagine, before uninstalling and deleting an application, trying to determine which files belong to that application. Alternatively, you might want to find and prune an application's unnecessary files. All of these scenarios would take lot of effort, time, and a strong memory for file names.
To overcome such problems, software installation management utilities are used with Linux systems. They not only help organize and arrange numerous software installations but also make it possible to change such arrangements effortlessly, as needed, any number of times. Stow is one such utility for Linux.
Although some Linux flavors such as Red Hat and Debian come with their own package management utilities (rpm and apt-get, respectively) that are as efficient as Stow, they work only on specific packaging formats (.rpm and .deb, respectively). When it comes to managing applications simply packaged in .tar files, Stow is the best bet.
In addition, for people working on Linux distributions besides Red Hat and Debian or looking for cheap or free alternatives to their existing package management utilities or just wanting to take everything under their own control, Stow is a good option. Stow is free software licensed under the GNU GPL (General Public License), and flexible, customizable with ample user support and resources available.
Stow manages different applications by storing and organizing the applications' installation files into their own individual directories, known as package directories, thus keeping them separate from each other. These package directories reside inside a stow directory, a parent directory containing package directories of all stowed applications.
Stow gives users the freedom to install and store the applications and their associated files in package directories at any desired location (by specifying that location as a stow directory), other than the common location for locally installed applications (the /usr/local/ directory) or default location specified by the application itself. This approach helps keep the /usr/local/ directory uncluttered, and applications arranged in a neat directory tree structure are easy to locate.
Note: The default stow directory is Stow's own directory, located in /usr/local/bin; this can be changed while installing Stow (see Installing Stow).
Along with organizing an application in the stow directory tree, Stow also creates corresponding symlinks (symbolic links) at the default location, where the application was originally required to be installed. This default location is called the target directory in Stow terminology. By default, the target directory is the parent directory of the stow directory. Although it is common practice to make /usr/local/stow a stow directory and /usr/local a target directory common to all stowed applications, the user is free to specify other locations for both the stow directory and the target directory (see stow command). An application's package directory tree inside the stow directory should be the same as the desired tree inside the target directory.
An application's corresponding symlinks, situated inside the application's target directory, point to the actual location of the application (its package directory) inside the stow directory. A symlink is somewhat similar to Windows shortcuts or MacOS aliases, which can represent an image of an application that resides in another location, perhaps a different drive or directory. These symlinks are then used to invoke or run the application. This gives the impression of the application itself being installed in and run from the target directory itself. This approach is useful when other applications need to invoke or interact with the application in question and expect it to be residing at its default location.
Note:
- Stow creates relative symlinks; that is, symlinks denote a path to the package directory relative to their own location.
- Stow tries to create the least number of symlinks for each application -- only one for one whole subdirectory tree within the package directory if possible. The process of creating this single symlink is called tree folding.
Stow may also be used to perform multiple installations of the same application. The different installations can reside at different locations, and Stow can be used to create and update a single set of the application's symlinks to point to any of those locations as desired.
Stow can not only organize software installations, but it can also change any previous arrangement of software installations any number of times, as required. Stow will never delete any files or directories in a stow directory, even during uninstallations. It simply updates or removes the symlinks in target tree pointing to the application installation, so it is always possible to install an uninstalled application again by simply stowing it again.
Installing Stow is very simple indeed. The only requirements to install and run Stow are Stow itself and Perl version 5.005 or higher.
- The latest version of Stow can be downloaded from the GNU FTP site (see Resources for a link). This article uses version 1.3.3, the latest at the time the article was being written.
- Perl is part of the standard installation of all major Linux distributions. To see which version you have, use command
perl -v. More information on Perl and its latest versions can be obtained from perl.com (see Resources for a link).
You need to log in as root on Linux system to install Stow. After downloading the Stow source file (stow-1.3.3.tar.gz), the following commands will untar and install Stow.
Listing 1. Installing Stow
# tar -zxvf stow-1.3.3.tar.gz # cd stow-1.3.3 #./configure # make # make install prefix=/usr/local/stow |
The default location for Stow installation is the /user/local/bin directory. This can be changed by specifying the desired location (as an absolute directory path) as the value of the prefix option of the make install command in the listing above.
Stow is now installed in its own directory tree under /usr/local/stow. That is, Stow executables now reside inside the /usr/local/stow/bin directory, Stow man files inside the /usr/local/stow/man directory, and info files inside the /usr/local/stow/info directory. Stow is now ready to stow applications.
Note:
- After untarring the Stow source, the resulting stow-1.3.3 folder contains a file named INSTALL containing useful installation instructions.
- After installing Stow, add the absolute path to the stow directory to the $PATH variable.
Stow provides a special command, stow, which can be executed with various options to invoke Stow for software installation management. The general syntax of the stow command is as follows:
$ stow [options] application-name
Various stow options are described below:
- -v or --verbose[=n] : Displays verbose output describing what Stow is doing. n denotes verbosity levels that can be 0, 1, 2, or 3; default is 0. Using -v or --verbose increases the verbosity level by one; using --verbose=n sets it to n.
- -d directory or --dir=directory : Sets the stow directory to directory (absolute path to desired directory) instead of the current directory. This also has the effect of making the parent of directory the default target directory.
- -t directory or --target=directory : Sets the target directory to directory (absolute path to desired directory) instead of the parent of the current stow directory.
- -D or --delete : Deletes application's symlinks from the target directory, i.e. unstows application.
- -R or --restow : Restows applications (first unstow, then stow again). This option is useful for updating symlinks and removing obsolete ones from the target tree after updating application by making changes into its package directory.
- -c or --conflicts : Searches for all conflicts that might arise from an actual stow operation. This option is used along with another option -n (see below). But there is a possibility of false conflicts being reported (see Resources for a link to the section on conflicts in the Stow manual).
- -n or --no : Does not perform any stow operation, just shows what would happen. Since no actual operations are performed,
stow -ncould report non-existent conflicts (see Resources for a link to the section on conflicts in the Stow manual) along with actual conflicts that are bound to take place. - -V or --version : Shows the Stow version number.
- -h or --help : Shows the stow command syntax.
To learn how to use Stow, let's stow an imaginary application, app-1.4. Let's assume that the application source is app-1.4.tar.gz, and it is required to be installed in /usr/local/bin. To install the application, we need to log in as root.
First, we need to unpack the tarred source, say into a directory named source:
[root@linuxbox source]# tar -zxvf app-1.4.tar.gz
This will create a directory, app-1.4, containing the source of app-1.4, inside directory source. Now, we change to the app-1.4 directory:
[root@linuxbox source]# cd app-1.4
We first need to install the application under the stow directory. Let's assume its location is /usr/local/stow. We shall follow the normal configure, make, and make install routine for this installation, as follows:
[root@linuxbox app-1.4]# ./configure --prefix=/usr/local/stow/app-1.4 [root@linuxbox app-1.4]# make [root@linuxbox app-1.4]# make install |
Now, we will stow the application installation and create corresponding symlinks inside the target directory, /usr/local/bin, using Stow. We need not log in as root to perform this task. First, let's change to the stow directory and execute the stow command from there.
[userX@linuxbox app-1.4]$ cd /usr/local/stow/ [userX@linuxbox stow]$ stow -t /usr/local/bin app-1.4 |
The application app-1.4 now resides inside its own package directory, app-1.4, inside the stow directory, and its corresponding symlinks are placed inside the target directory, /usr/local/bin.
If we need to upgrade or reconfigure app-1.4, we can simply make changes to its package directory and after updating the application, restow it to update corresponding symlinks:
[userX@linuxbox stow]#$ stow -R app-1.4
To uninstall this application, we simply need to unstow app-1.4:
[userX@linuxbox stow]#$ stow -D app-1.4
Stow will simply remove the links pointing to the application installation and never delete any installation files. Therefore it is possible later to stow the application once again to use it.
Stow is a free, simple, and easy to use software installation management utility for Linux systems. Stow is ideal for applications installed directly from their tar sources, instead of standard packaging formats like .rpm or .deb. Stow manages application installations by keeping them in their own separate directories at any desired location, while making them appear to be installed at their required locations.
Software installation management with Stow offers many advantages, such as easy installing and uninstalling of applications, easy tracking of installed applications and their associated file, ease of upgrading, and ease of reconfiguring stowed applications.
- Visit the Stow home page for links to related information at Stow's GNU official site.
- Download the latest version of Stow from the GNU FTP site.
- Refer to the Stow manual page for general information as well as a section on how Stow handles naming conflicts.
- Read this useful article on Stow by Allan Peda, "Simple Package Management With Stow" at Linux Gazette.
- For information on Perl and downloads of its latest version, visit perl.com.
- For an overview of Red Hat's package management utility, read our three-part series. Part 1 covers how to use RPM, Part 2 covers software patches and distributing RPMs, and Part 3 covers running scripts during installation and uninstallation.
- If you need to manage software distribution across an entire enterprise, Tivoli can help. Check out the Tivoli Configuration Manager on IBM.com.
Mugdha Vairagade is a developer working with various organizations on wireless application development and specializing in component architectures. She has a special interest in open source projects. Mugdha has been associated with the Linux Documentation Project, Forum Nokia (WAP developers' forum), and W3C. She also writes technical articles on Linux and XML technologies. You can contact Mugdha at vmugdha@indiatimes.com.
Comments (Undergoing maintenance)





