Home > System Tutorial > LINUX > How To Install And Manage Software From Source Using GNU Stow In Linux

How To Install And Manage Software From Source Using GNU Stow In Linux

William Shakespeare
Release: 2025-03-16 10:51:11
Original
617 people have browsed it

This tutorial explains how GNU Stow simplifies managing software installed from source in Linux. It uses symbolic links to keep installations organized, preventing conflicts and making updates/removal easy.

What is GNU Stow?

GNU Stow is a symlink manager streamlining source code software installation on Linux and Unix-like systems. It organizes files, enabling efficient management and maintenance by creating symbolic links from a central location to the actual software files. This prevents conflicts between multiple packages. It's especially useful for users managing their own installations and configurations, often paired with version control. It's free and open-source.

How GNU Stow Works

Stow assumes each software package resides in its own directory (e.g., /usr/local/stow/package1). stow package1 creates symbolic links from this directory to the appropriate system locations (like /usr/local/bin). stow -D package1 removes these links.

GNU Stow Features

  • Symbolic Links: Creates symlinks, avoiding file conflicts.
  • Package Management: Manages software installed in user-specific or system-wide locations.
  • Easy Upgrades/Removals: Updating or removing a package is straightforward; Stow handles the symlinks automatically.
  • Flexible Configuration: Customizable to suit individual needs.

Advantages of Using GNU Stow

  • Simplified Package Management: Easy installation, updates, and removal. Multiple versions of the same package can coexist.
  • Conflict Avoidance: Isolated package directories minimize file conflicts.
  • Reproducibility: Easier to replicate and document software environments.

Use Case

Ideal for developers regularly compiling software from source and managing configuration files (dotfiles) across multiple systems.

Basic Usage

Install a package: cd /usr/local/stow; stow package1 Uninstall a package: cd /usr/local/stow; stow -D package1

Installing Software from Source using GNU Stow (Curl Example)

  1. Update System: sudo apt update (Debian/Ubuntu), sudo yum update (CentOS/RHEL), etc.
  2. Install Development Tools: sudo apt install build-essential libssl-dev (Debian/Ubuntu for Curl with OpenSSL), adjust for your system and desired TLS backend (GnuTLS requires different libraries).
  3. Install GNU Stow: sudo apt install stow (Debian/Ubuntu), adjust for your distribution.
  4. Download and Extract Curl: wget https://github.com/curl/curl/releases/download/curl-8_8_0/curl-8.8.0.tar.gz; tar xvf curl-8.8.0.tar.gz (replace with the actual latest version).
  5. Configure Build: cd curl-8.8.0; ./configure --with-ssl --prefix=/usr/local/stow/curl-8.8.0 (or --with-gnutls for GnuTLS).
  6. Compile: make
  7. Install: sudo make install
  8. Manage with Stow: cd /usr/local/stow; sudo stow curl-8.8.0
  9. Verify: curl --version

How To Install And Manage Software From Source Using GNU Stow In Linux

Updating Software

  1. Uninstall Old Version: cd /usr/local/stow; sudo stow -D curl-8.7.1 (replace with the old version).
  2. Download, Extract, Configure, and Build New Version: Repeat steps 4-7 from the installation section.
  3. Manage New Version with Stow: cd /usr/local/stow; sudo stow curl-8.8.0
  4. Verify: curl --version
  5. Remove Old Directory (Optional): sudo rm -rf /usr/local/stow/curl-8.7.1

Advanced Usage

Stow offers options for relocatable packages (--dir, --target), dry runs (-n), verbose output (-v), ignoring files (.stow-local-ignore), restow (-R), destow (-D), adopting existing files (--adopt), handling conflicts (--override), and specifying custom directories. See the man stow page for details.

GNU Stow Cheat Sheet (Summary of common commands and options)

  • stow package_name: Stow a package.
  • stow -D package_name: Unstow a package.
  • stow -R package_name: Restow a package.
  • stow --dir=/path/to/packages package_name: Specify source directory.
  • stow --target=/path/to/target package_name: Specify target directory.
  • stow -n package_name: Dry run.
  • stow -v package_name: Verbose output.
  • stow --adopt package_name: Adopt existing files.
  • stow --override package_name: Override conflicts.

Frequently Asked Questions (FAQs) (Covered in original text, but could be summarized here for brevity)

Conclusion

GNU Stow is a valuable tool for efficiently managing source-built software in Linux, improving organization and simplifying updates and removals. Its use of symbolic links prevents conflicts and makes managing multiple software versions straightforward.

The above is the detailed content of How To Install And Manage Software From Source Using GNU Stow In Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template