Difference between revisions of "Linux3"
(8 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
'''Starting to administer systems''' | '''Starting to administer systems''' | ||
=Introduction= | =Introduction= | ||
+ | |||
+ | This page is aimed at those moving from just being a Linux user to the role of a system administrator. Administering systems obviously requires more knowledge and also comes with more responsibilities. | ||
+ | |||
+ | A very common request from a user to an administrator is to add more software to a system. For this reason, we'll focus on the installation of packages in the next section. | ||
=Installing Software= | =Installing Software= | ||
+ | |||
+ | Not so long ago, installing packages could be quite be quite an involved task. Not only must you locate the correct software package and version, download it and successfully compile it, you also had to ensure that any dependencies that a package had (i.e. it's use of other packages) were also satisfied too, by backward chaining through the list and installing all those other packages in turn. However, the advent of [http://en.wikipedia.org/wiki/Package_management_system '''package managers'''] has changed all that. These applications make the tasks on installation and dependency resolution as simple as clicking a button. The speed and ease with which we can now install software has radically changed the lot of systems administrators. | ||
==Package Managers== | ==Package Managers== | ||
+ | |||
+ | Distributions such as RedHat, Fedora and CentOS use the '''YUM''' (Yellowdog Updater, Modified) package manager. | ||
+ | |||
+ | Useful links for YUM include: | ||
+ | * http://en.wikipedia.org/wiki/Yellowdog_Updater,_Modified | ||
+ | * http://prefetch.net/articles/yum.html | ||
+ | |||
+ | Debian systems, such as Ubuntu, use APT (Advanced Packaging Tool): | ||
+ | |||
+ | Useful links for APT include: | ||
+ | * http://en.wikipedia.org/wiki/Advanced_Packaging_Tool | ||
+ | * https://help.ubuntu.com/community/AptGet/Howto | ||
==Building from Source Code== | ==Building from Source Code== | ||
+ | |||
+ | While package managers seamlessly negotiate the vast majority of bread-and-butter installations, we sometimes need to fall back to source code compilation for more niche applications. The example below will show the main steps in this process. We've picked the very popular statistics package R to use as our example, not because it is niche, but because it has a well tested and robust build process that is easy for us to use. | ||
Let's build the latest and greatest version of the popular, open-source statistics package--R. We can download the source code from a mirror site right here in Bristol! | Let's build the latest and greatest version of the popular, open-source statistics package--R. We can download the source code from a mirror site right here in Bristol! | ||
Line 37: | Line 57: | ||
</pre> | </pre> | ||
− | We have a directory called '''R-3.0.1''', let's move into that directory and | + | We have a directory called '''R-3.0.1''', let's move into that directory and take a look at what's inside: |
<pre> | <pre> | ||
cd R-3.0.1 | cd R-3.0.1 | ||
+ | ls | ||
+ | ChangeLog configure COPYING etc m4 Makefile.fw NEWS ONEWS po share SVN-REVISION tools VERSION-NICK | ||
+ | config.site configure.ac doc INSTALL Makeconf.in Makefile.in NEWS.pdf OONEWS README src tests VERSION | ||
+ | </pre> | ||
+ | |||
+ | It's common to find files named '''README''' and '''INSTALL''', which will give details of the project and installation instructions, respectively. | ||
+ | |||
+ | In common with many other projects, the R distribution uses something called the '''automake''' package which creates makefiles for subsequent use in compiling the source code. The typical pattern of commands in this situation is to run '''./configure''', followed by '''make''', possibly some sort of test, and finally '''make install''' to complete the software installation. | ||
+ | |||
+ | Configure scripts often follow convention when it comes to the options that they will accept. For example: | ||
+ | |||
+ | <pre> | ||
+ | ./configure --help | ||
+ | </pre> | ||
+ | |||
+ | will list all the valid options for this particular configure script. '''--prefix''' is a common option. We can use it to tell the system where we would ultimately like the package to be installed, once it is built. For the purposes of this example, we will run: | ||
+ | |||
+ | <pre> | ||
+ | ./configure --prefix=$HOME/INSTALLS/R/3.0.1 | ||
+ | </pre> | ||
+ | |||
+ | This command will spew a great deal of information to the screen. For less forgiving configure scripts, you'll need eyes like a hawk to spot signs of a configuration problem as the results of interrogating the system scroll past. Happily in this case, however, the configure script gives us a handy summary at the end: | ||
+ | |||
+ | <pre> | ||
+ | R is now configured for i686-pc-linux-gnu | ||
+ | |||
+ | Source directory: . | ||
+ | Installation directory: /home/gethin/INSTALLS/R/3.0.1 | ||
+ | |||
+ | C compiler: gcc -std=gnu99 -g -O2 | ||
+ | Fortran 77 compiler: gfortran -g -O2 | ||
+ | |||
+ | C++ compiler: g++ -g -O2 | ||
+ | Fortran 90/95 compiler: gfortran -g -O2 | ||
+ | Obj-C compiler: | ||
+ | |||
+ | Interfaces supported: X11 | ||
+ | External libraries: readline | ||
+ | Additional capabilities: PNG, JPEG, NLS | ||
+ | Options enabled: shared BLAS, R profiling | ||
+ | |||
+ | Recommended packages: yes | ||
+ | </pre> | ||
+ | |||
+ | Now we're in the position to start compiling-up the source code. To do this, run '''make''': | ||
+ | |||
+ | <pre> | ||
+ | make | ||
+ | </pre> | ||
+ | |||
+ | At this point, you'll see a good deal more information regarding the compilation scroll over your terminal too. The R build adds in some helpful commentary, so that it is not too cryptic. If you have been able to build without any errors, you can check that the package is behaving correctly by running: | ||
+ | |||
+ | <pre> | ||
+ | make check | ||
</pre> | </pre> | ||
+ | |||
+ | All being well, you should see many '''OK'''s scroll past. | ||
+ | |||
+ | Finally, when you are satisfied that all is well, you can install the package at it's intended destination: | ||
+ | |||
+ | <pre> | ||
+ | make install | ||
+ | </pre> | ||
+ | |||
+ | We can check that it installed correctly by looking in under the directory specified to the configure script via the --prefix option: | ||
+ | |||
+ | <pre> | ||
+ | ls $HOME/INSTALLS/R/3.0.1 | ||
+ | bin lib share | ||
+ | ls $HOME/INSTALLS/R/3.0.1/bin | ||
+ | R Rscript | ||
+ | </pre> | ||
+ | |||
+ | Finally, you can start the package by typing '''$HOME/INSTALLS/R/3.0.1/bin/R''' (where, for convenience, you will want to add this bin directory to your path. | ||
+ | ): | ||
+ | |||
+ | <pre> | ||
+ | $HOME/INSTALLS/R/3.0.1/bin/R | ||
+ | R version 3.0.1 (2013-05-16) -- "Good Sport" | ||
+ | Copyright (C) 2013 The R Foundation for Statistical Computing | ||
+ | Platform: i686-pc-linux-gnu (32-bit) | ||
+ | |||
+ | R is free software and comes with ABSOLUTELY NO WARRANTY. | ||
+ | You are welcome to redistribute it under certain conditions. | ||
+ | Type 'license()' or 'licence()' for distribution details. | ||
+ | |||
+ | Natural language support but running in an English locale | ||
+ | |||
+ | R is a collaborative project with many contributors. | ||
+ | Type 'contributors()' for more information and | ||
+ | 'citation()' on how to cite R or R packages in publications. | ||
+ | |||
+ | Type 'demo()' for some demos, 'help()' for on-line help, or | ||
+ | 'help.start()' for an HTML browser interface to help. | ||
+ | Type 'q()' to quit R. | ||
+ | |||
+ | > | ||
+ | </pre> | ||
+ | |||
+ | R has a neat graphics demo facility that you can start by typing: | ||
+ | |||
+ | <pre> | ||
+ | demo(graphics) | ||
+ | </pre> | ||
+ | |||
+ | Congratulations! You've successfully downloaded, built and installed the R package from source code. This will stand you in good stead for installing other packages and tools. |
Latest revision as of 15:16, 16 August 2013
Starting to administer systems
Introduction
This page is aimed at those moving from just being a Linux user to the role of a system administrator. Administering systems obviously requires more knowledge and also comes with more responsibilities.
A very common request from a user to an administrator is to add more software to a system. For this reason, we'll focus on the installation of packages in the next section.
Installing Software
Not so long ago, installing packages could be quite be quite an involved task. Not only must you locate the correct software package and version, download it and successfully compile it, you also had to ensure that any dependencies that a package had (i.e. it's use of other packages) were also satisfied too, by backward chaining through the list and installing all those other packages in turn. However, the advent of package managers has changed all that. These applications make the tasks on installation and dependency resolution as simple as clicking a button. The speed and ease with which we can now install software has radically changed the lot of systems administrators.
Package Managers
Distributions such as RedHat, Fedora and CentOS use the YUM (Yellowdog Updater, Modified) package manager.
Useful links for YUM include:
Debian systems, such as Ubuntu, use APT (Advanced Packaging Tool):
Useful links for APT include:
Building from Source Code
While package managers seamlessly negotiate the vast majority of bread-and-butter installations, we sometimes need to fall back to source code compilation for more niche applications. The example below will show the main steps in this process. We've picked the very popular statistics package R to use as our example, not because it is niche, but because it has a well tested and robust build process that is easy for us to use.
Let's build the latest and greatest version of the popular, open-source statistics package--R. We can download the source code from a mirror site right here in Bristol!
cd $HOME mkdir BUILD mkdir INSTALL cd BUILD mkdir R cd R wget http://www.stats.bris.ac.uk/R/src/base/R-3/R-3.0.1.tar.gz
OK, take a look at what we have so far:
ls -l -rw-r--r-- 1 gethin gethin 25508280 2013-05-16 08:11 R-3.0.1.tar.gz
So far, so good. Let's unpack the tarball:
tar -xzf R-3.0.1.tar.gz ls -l drwxr-xr-x 10 gethin gethin 4096 2013-05-16 08:11 R-3.0.1 -rw-r--r-- 1 gethin gethin 25508280 2013-05-16 08:11 R-3.0.1.tar.gz
We have a directory called R-3.0.1, let's move into that directory and take a look at what's inside:
cd R-3.0.1 ls ChangeLog configure COPYING etc m4 Makefile.fw NEWS ONEWS po share SVN-REVISION tools VERSION-NICK config.site configure.ac doc INSTALL Makeconf.in Makefile.in NEWS.pdf OONEWS README src tests VERSION
It's common to find files named README and INSTALL, which will give details of the project and installation instructions, respectively.
In common with many other projects, the R distribution uses something called the automake package which creates makefiles for subsequent use in compiling the source code. The typical pattern of commands in this situation is to run ./configure, followed by make, possibly some sort of test, and finally make install to complete the software installation.
Configure scripts often follow convention when it comes to the options that they will accept. For example:
./configure --help
will list all the valid options for this particular configure script. --prefix is a common option. We can use it to tell the system where we would ultimately like the package to be installed, once it is built. For the purposes of this example, we will run:
./configure --prefix=$HOME/INSTALLS/R/3.0.1
This command will spew a great deal of information to the screen. For less forgiving configure scripts, you'll need eyes like a hawk to spot signs of a configuration problem as the results of interrogating the system scroll past. Happily in this case, however, the configure script gives us a handy summary at the end:
R is now configured for i686-pc-linux-gnu Source directory: . Installation directory: /home/gethin/INSTALLS/R/3.0.1 C compiler: gcc -std=gnu99 -g -O2 Fortran 77 compiler: gfortran -g -O2 C++ compiler: g++ -g -O2 Fortran 90/95 compiler: gfortran -g -O2 Obj-C compiler: Interfaces supported: X11 External libraries: readline Additional capabilities: PNG, JPEG, NLS Options enabled: shared BLAS, R profiling Recommended packages: yes
Now we're in the position to start compiling-up the source code. To do this, run make:
make
At this point, you'll see a good deal more information regarding the compilation scroll over your terminal too. The R build adds in some helpful commentary, so that it is not too cryptic. If you have been able to build without any errors, you can check that the package is behaving correctly by running:
make check
All being well, you should see many OKs scroll past.
Finally, when you are satisfied that all is well, you can install the package at it's intended destination:
make install
We can check that it installed correctly by looking in under the directory specified to the configure script via the --prefix option:
ls $HOME/INSTALLS/R/3.0.1 bin lib share ls $HOME/INSTALLS/R/3.0.1/bin R Rscript
Finally, you can start the package by typing $HOME/INSTALLS/R/3.0.1/bin/R (where, for convenience, you will want to add this bin directory to your path. ):
$HOME/INSTALLS/R/3.0.1/bin/R R version 3.0.1 (2013-05-16) -- "Good Sport" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: i686-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. >
R has a neat graphics demo facility that you can start by typing:
demo(graphics)
Congratulations! You've successfully downloaded, built and installed the R package from source code. This will stand you in good stead for installing other packages and tools.