Guide for installing various types of programs in Linux

Tutorial

This handy guide is for installing programs in UNIX environment. Most of these steps assume that you are installing package in a group accessible location, without root access and utilizing the environment module systems for package management. However, you can easily modify these steps for other cases as well.

Unpacking

Packages are usually compressed in many different ways for easy handling. Before proceeding to installation, it must be unpacked. Depending on the compression (looking at the extension) use any of the following commands to unpack. Although tar can auto detect the compression type and decompress the archive with the -xf options, you can also specify what type compressed files you're providing. For most cases tar -xf will do the trick:

  1. tar xf package.tar.gz

But to be specific you can:

  1. # Files having *.tar.bz2 extension
  2. tar xvjf package.tar.bz2
  3. # Files having *.tar.gz extension
  4. tar xvzf package.tar.gz
  5. # Files having *.bz2 extension
  6. bunzip2 package.bz2
  7. # Files having *.rar extension
  8. unrar x package.rar
  9. # Files having *.gz extension
  10. gunzip package.gz
  11. # Files having *.tar extension
  12. tar xvf package.tar
  13. # Files having *.tbz2 extension
  14. tar xvjf package.tbz2
  15. # Files having *.tgz extension
  16. tar xvzf package.tgz
  17. # Files having *.zip extension
  18. unzip package.zip
  19. # Files having *.Z extension
  20. uncompress package.Z
  21. # Files having *.7z extension
  22. 7z x package.7z

Once de-compressed, proceed with installation, depending on what type of package you are installing.

Regular Linux packages

Standard approach

Many Linux/UNIX programs comes with a standard set of files that lets you install programs with ease. After unpacking, if you see configure file in unpacked directory, use this approach.

  1. ./configure --prefix=/group/accessible/location/packagename
  2. # once complete you'll see 'Makefile' in that directory
  3. make # reads instructions from 'Makefile' and builds executable programs
  4. make check # not needed, but helps in troubleshooting
  5. make install # installs program using 'Makefile' directions

In case if something goes wrong or you get an error saying that you need package x before installing, then you can undo these steps before attempting installation again.

  1. make clean

If the program doesn't work as intended or something goes wrong after installation, many programs can be safely uninstalled

  1. make uninstall

Note that all of these options are not supported by all makefiles so your mileage may vary. It is also good idea to run all the above command in a build directroy inside the package directroy, so that if something doesn't work you can easily delete the build directory to start over.

Special cases

1. No configure file

Some programs will already have a Makefile. These programs do not need the first step (running configure), you can simply install them by typing

  1. make
  2. make install

The executables are generally created either in the same directory or in the bin directory, within the package directory. Sometime these packages will allow you to install other locations as well. Consult the README or INSTALL files that came with the program or edit the Makefile to hard code the installation directory. In some cases, setting PREFIX variable to the desired installation location will also do the trick.

  1. PREFIX=/your/installation/location make

2. Source obtained as RPM package

In some rare cases when you don't find a package for Red Hat Linux, but you have rpm package for the program, then use these steps to extract and install: * Find the correct RPM package for your system. This [[http://pkgs.org | webiste]] lists all RPMs available, and are free to download. All CentOS RPM's work on Red Hat. Download the Source package (not Binary). * Extract the package: use rpm2cpio package.rpm |cpio -idv command to extract, you should see a *tar.gz or other type of compressed program, if this completes successfully. * Follow the steps described earlier to install like any other package. * In rare cases, when you have patches (extracted from RPM), you might have to apply it before you install. After extracting *.tar.gz file, cd in to the directory and run patch -Np1 -i path/to/file.patch and install as usual.

3. Needs cmake

If the README file says that you need to use camke command, then use these steps to install:

  1. # after extraction, cd to the package
  2. cd package
  3. mkdir build
  4. cd build
  5. cmake ..
  6. # if you want it in a different directory, then
  7. cmake -DCMAKE_INSTALL_PREFIX:PATH=/location/for/installation ..
  8. make
  9. # if this completes successfully, you will see a bin folder above this current directory
  10. # that will have the executables

Group installation

Rather than trying to install to root, it is useful to be able to install programs that are common for your group/lab. To attain this type of installation it is necessary to download and load your own version of python (not the python installed in root, by admin). Global installations are not possible when you are not the administrator, and personal directory installations are only available to one person. When it is desirable to install to group. Start with Python installation in your groups directory (example: /work/GIF on condo).

Python packages

Using our own python will allow writing/installing modules to it as needed. After unpacking, cd to the package, and install it as follows:

  1. module load python
  2. python setup.py install # all executables will be stored in python/bin (not in package directory)

If in case if you need to test out something and not install it as module, you can install in a personal location as well:

  1. python setup.py install --local=/home/username/mydir
  2. # or simply as
  3. python setup.py install --user # executable's will be in ~/.local/bin directory

Any package available at [[https://pypi.python.org/pypi | PyPi ]] can be managed using these commands as well

  1. module load python
  2. pip install SomePackage # installs a python package
  3. pip show --files SomePackage # shows what files are installed for the particular package
  4. pip list --outdated # lists what packages are outdated
  5. pip install --upgrade SomePackage # upgrades a package
  6. pip uninstall SomePackage # uninstalls a package
  7. pip freeze # lists all the packages that are currently installed and their version

Perl modules

Once the module is loaded, use the following set of commands to install any perl modules.

  1. module load perl

If there is a Makefile.PL

  1. perl Makefile.PL PREFIX=/home/users/dag # makes the system specific makefile
  2. make # builds all the libaries
  3. make test # runs a short test
  4. make install # installs the package correctly.

If there is a Build.PL

  1. perl Buil.PL
  2. ./Build test
  3. ./Build install

The module will be installed in the group's perl folder (not in the package directory). So, like you did in Python you need to set up a dummy module file that load Perl

R or Bioconductor packages

Installing R libraries for the group is really easy since you don't have to do anything different from the way you install packages to your home directory. GIF has its own R version installed as module and it is configured such that it will automatically install the package in the correct location, when you are using this module.

module load R
R
# R command prompt will appear
>

Installing CRAN R Packages

CRAN packages are by far the easiest. From within R prompt, type:

module load R
R
# R command prompt will appear
> install.packages("some_package") # include quotes!
# if it prompts to select the closest mirror, choose IA, which is `77`

Once installed, you will be back at R prompt, load the installed package to see is everything is fine.

library(some_package)
# this should load the package and return without any error message

Install manually downloaded R Package

Some packages that aren't in CRAN but are available from the author directly, can be installed for group as well. Download the the package.tar.gz from the author's website.

module load R
R CMD INSTALL package.tar.gz
# This will install the package for the group.
# Check to see if it works
R
# R command prompt will appear
> library(package)
# this should load the package and return without any error message

Installing Bioconductor Modules

For Bioconductor packages, follow these steps:

module load R
R
# R command prompt will appear
> source("http://www.bioconductor.org/biocLite.R")
> biocLite(c("package_name"), dependencies=TRUE)
# check if package is installed
> library(package_name)
# this should load the package and return without any error message

Managing packages

List available packages

To get a complete list of packages that are already installed, load the R module and enter the R prompt. From there, type the following command:

> library()

To get all packages installed along with their version number, type

> installed.packages()[,c("Package","Version")]

Upgrade packages

For the R packages that you installed from CRAN can all be upgrades in single command

update.packages() # upgrades all packages
package.status() # says if 'ok' (no updates), 'upgrade' (needs update) or 'unavailable' (package removed from repository)

Other useful option to check the status of all packages currently installed is:

> inst <- packageStatus()$inst
> inst[inst$Status != "ok", c("Package", "Version", "Status")]

Uninstall package

Packages can be uninstalled easily using remove.packages command

> remove.packages("package_name")

Java programs

Precompiled java programs that come as .jar files, can be placed in any directory and can be called from there. For using it with environment modulefile, you need to do these steps. First, create directory (program name) and sub-directory (version number). Place the .jar file in this sub-directory. Within this create another directory and call it as bin. For all .jar files in /programname/version/ create a text file in /programname/version/bin. This text file will just have a single line, something like:

  1. java program_name.jar

Change permission for these text files so that they can be executed.

  1. chmod +x -R /programname/version/bin

In your module file, you need to add this line:

  1. prepend-path PATH /programname/version/bin

Now the .jar files can be simply called as 'programname (once module is loaded). No need to add java in front.