BITS: Introduction to Linux - Software installation the graphical and the command-line way

68
Dive into Linux Software installation the graphical way Software installation the old-fashioned way BITS/VIB Bioinformatics Training – Oct 3, 2011 – Version 2 Joachim Jacob <[email protected] >; version 1 Luc Ducazu <[email protected]>

description

This slide is part of the BITS training session: "Introduction to linux for life sciences." See http://www.bits.vib.be/index.php?option=com_content&view=article&id=17203890%3Abioperl-additional-material&catid=84&Itemid=284

Transcript of BITS: Introduction to Linux - Software installation the graphical and the command-line way

Page 1: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Dive into Linux

Software installationthe graphical way

Software installationthe old-fashioned way

BITS/VIB Bioinformatics Training – Oct 3, 2011 – Version 2 Joachim Jacob <[email protected]>; version 1 Luc Ducazu <[email protected]>

Page 2: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Software for Linux There is an immense quantity of software

programs available for Linux Server applications:

Web (apache, lighttpd) Mail (sendmail, postfix) DNS (bind)

User applications: GUIs (KDE, Gnome) Office suites (OpenOffice, KOffice)

Specialized applications: scientific and engineering supercomputing (Beowulf)

Page 3: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Software for Linux Several ways exist to install software

PREFERRED WAYSA) Software center: every distribution as some kind of

software manager in which you just search for software and click to install. The manager searches several URL for lists of software that can be installed.

B) Download from the internet: installation files can be downloaded, which are *.rpm (Fedora, openSuse, CentOS) or *.deb (Debian, Ubuntu,...) files. Just double-click and your software manager will handle it

Pro: software manager keeps track of installed softw, correct packages are installed (32 vs 64 bit, OS)

Page 4: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Software for Linux Several ways exist to install software

NOT SO PREFERRED WAYSA) Compile from source: download a compressed file

(.tar.gz or .tar.bz2), which contain instructions to compile (make an executable binary) for your system

Usually in the shell: ./configure ; make ; make installB) Download the binary: this is a 'raw' executable

program. Mostly just referred to by the program name. Be extremely cautious with downloading and executing binaries

The above methods do not keep track of the software you have installed → removal can be cumbersome.

Page 5: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Software

Hence, software is distributed in one of the following ways: Commercial software is usually binary only –

installation instructions are provided by the vendor Free (Open Source) Software is usually distributed in

source packages (compressed tar ball, such as .tar.gz)You can

Build the package yourself Install a distro-specific binary package (RPM)

Page 6: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Software installation the graphical way

As an example we are going to install 'gnome-do', a tool that enables you to'Do things as quickly as possible (but no quicker) with your files, applications, contacts and more!'

Page 7: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Software installation

Page 8: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Software installation

Page 9: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Software installation

Page 10: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Dependencies

Gnome-do is written in Mono (.Net for Linux) It makes no sense to install a Mono program,

without the Mono-runtime The package manager is aware of the

dependencies of packages, and it will automatically download the extra packages

Page 11: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Software installation

Page 12: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Multi-user aspects

UNIX (and hence Linux) is a multi-user OS:multiple users can simultaneously log into a system (locally, via serial consoles, via the network, ...)

It is the responsibility of the OS to fairly share the system resources (CPU, memory, ...) protect one user from another

There is one user 'root' aka the superuser that has the most privileges

Only 'root' is allowed to install packages, and (in Fedora) users that belong to the group wheel.

Page 13: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Software installation

Page 14: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Software installation

Page 15: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Test run press <win+space> and start typing “Fir”

Page 16: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Where to find software?

In the software manager Freshmeat

http://freshmeat.net/ FSF/GNU

http://directory.fsf.org/ SourceForge

http://sourceforge.net/ SAL (Scientific Applications on Linux)

http://www.sai.msu.su/sal/ PKGS.org

http://pkgs.org

Important: 32 bit vs. 64 bit

Page 17: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Where does the software manager finds its packages?

The Fedora project has a thriving community of packagers: On the installation DVD: 2.500+ packages Available via the Internet: 22.000+ packages

To be able to install packages from the Internet, one must: Enable the repository (='repo'):

This contains the URL where the packages can be found

Import the repo key, this prevents hackers from distributing malicious software via the official repositories

Page 18: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Enabling repositories

Page 19: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Enabling repositories

Page 20: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Exercise

Graphically: Install the package 'bowtie'. Can you find it with the software manager?

RPM based: Install FastX toolkit. You will not find it in the software manager, but check pkgs.org perhaps.

Choose 32 bit

Page 21: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Solution

RPM based: Install FastX toolkit, using pkgs.org

preferred

Page 22: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Solution

Page 23: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Solution

Page 24: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Fastx is a command-line tool

So we will dive into the shell!

Page 25: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

First and foremost...

Page 26: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Shell

A shell is a program that waits for a user to enter a command and execute it

The shell offers far more than this: Command history Scripting constructs to automate command sequences Multiple jobs

You get a shell when you Open a terminal

(Applications -> System Tools -> Terminal) Login to a system using ssh

In Linux the most popular shell is bash (Bourne Again SHell)

Page 27: BITS: Introduction to Linux -  Software installation the graphical and the command-line way
Page 28: BITS: Introduction to Linux -  Software installation the graphical and the command-line way
Page 29: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

You never walk alone

A Linux system comes with batteries included:only they are called man-pages (manual)

If you know a program prg, you can find all the reference documentation by entering$ man prg

If you don't know the program, you can search the descriptions in the man-pages for relevant keywords$ apropos keyword

Page 30: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Man

Interesting keys: and scroll up and downPgUp previous pagePgDown or space next page< and > begin and end of the text

file/ search (forward)n next search hitq to exit from less The command man uses less under the hood to

display the manual page.

Page 31: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Exercise

On what day of the week were you born?

Translated: Can you display a calendar and what command would

you use to do so?

What syntax are you going to use to display the calendar of the month and year you were born?

Page 32: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Some solution

What command would you use to display a calendar?

Look with: apropos calendar

What syntax are you going to use to display the calendar of the month and year you were born?

Look with: man calendar

apropos calendarcal (1) - displays a calendar and the date of Eastercalendar (1) - reminder serviceDate::Calc (3pm) - Gregorian calendar date calculationsDate::Calendar (3pm) - Calendar objects for different holiday schemesDate::Calendar::Profiles (3pm) - Some sample profiles for Date::Calendar and Date::Calendar::YearDate::Calendar::Year (3pm) - Implements embedded "year" objects for Date::CalendarNcal (1) - displays a calendar and the date of Easter

Page 33: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Getting formal about commands

UNIX and Linux have many commands that perform a specific task

The way these commands perform their task depends on: specific build time options environment variables configuration files command line options

Page 34: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Commands

To execute a command, type the name of the command at the prompt:$ ls

This command lists files and directories in the current working directory

On the file system, there exists an executable file with 'ls' as its name.

Files in UNIX are case sensitive:$ LSbash: LS: command not found

Page 35: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Commands

Options and arguments influence the way commands behave. They are separated from the command (and from each other) by spaces

Example:$ ls -l Desktop

Here is: -l: option (long list) Desktop: program argument (list the contents of

directory Desktop)

Page 36: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Short options

'Short' options consist of a – (single dash) immediately followed by a character (as in: no spaces)$ ls -1

You can specify multiple options at the command line – the given order is seldom important$ ls -l -t$ ls -t -l

Multiple short options can be combined$ ls -r -l -t$ ls -rtl

Page 37: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Long options

'Long' options consist of -- (two dashes) followed by the name of the option (string):$ ls -–recursive

Long options cannot be combined like their 'short' counterparts

Page 38: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Arguments

There are two kinds of arguments: option arguments:

the argument must follow the option$ ls -w 80

the space between option name and argument is optional$ ls –-sort=size

the '=' sign is optional program arguments:$ ls *.cby convention program arguments are specified at the end of the command

Page 39: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Arguments

Examples

$ ls -lr -w 80 /bin/*sh$ ls -rlw 80 /bin/*sh

$ ls -wrl 80 /bin/*sh # NOK$ ls -w80 /bin/*sh -lr

Page 40: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

More about ls

To show the content of a directory, you use ls (list)

Options: d: (for directories) – do not show the contents of the

directory, but rather the directory itself R: recursive – show the content of the subdirectories

and their subdirectories, ... r: reverse sort order t: sort on modification time S: sort on size

Page 41: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Long List

$ ls -l-rwxr-xr--. 1 james users 357 Sep 5 21:36 clusterit.gz Here is:

- file type (ordinary file)rwxr-xr-- permissions. (indicates that there is a SELinux security context)1 link countjames ownerusers group357 file size in bytesSep 5 21:36 modification dateclusterit.gz file name

On many distributions ll is defined as an alias for ls -l

Page 42: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Permissions

$ ls -l-rwxr-xr--. 1 james users 357 Sep 5 21:36 clusterit.gz Permissions come in 3 sets:

the first set (rwx) applies to the owner (james) only de second set (r-x) applies to all members of the

group (users), except the owner (james) de third set (r--) applies to all other users

User root is not restricted by permissions

Page 43: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

File permissions

There are 3 categories of file permissions: r (read) w (write) x (execute)

To access the content of a file, you need read (r) permissions

To change the content of a file, you need write (w) permissions

To execute a file, you need execute (x) permissions

Page 44: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Executable files

Whether a file is executable or not, does not depend on the file extension, but on the permissions: for a binary file, the execute (x) permission is

sufficient for a script (shell, Perl, …) you need both execute (x)

and read (r) permissions

Page 45: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Executable files

Graphically: look for properties of a file (right-click, properties)

Page 46: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Directory permissions There are 3 categories of directory permissions:

r (read) w (write) x (access)

To read the content of a directory (eg ls),you need read (r) permissions

To change the content of a directory (eg rm), you need write (w) permissions

To access the inodes of the files in a directory,you need access (x) permissions

MORE on http://www.linuxforums.org/articles/file-permissions_94.html

Page 47: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Wildcards

Wildcards are used to refer to a collection of files:

* all files (except hidden files)A* file names starting with A*A file names ending with A*A* file names containing an A anywhereA? file names consisting of 2 characters, A being the first[Aa]* file names starting with A or a[!Aa]* file names that do not start with A or a

Page 48: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Hidden files

A file whose name starts with a . (dot) is not shown when using ls

You can discover hidden files:$ ls .*$ ls -a (all: including . and .. )$ ls -A (almost all: without . and ..)

Page 49: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Exercises

List the contents of directory /usr/bin Are there any files in this directory whose name

starts with “bo”? Show the permissions of directory /usr/bin Do you understand why only user root can install

software?

Page 50: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Solutions

List the contents of directory /usr/bin$ ls /usr/bin

Are there any files in this directory whose name starts with “bo”?$ ls /usr/bin/bo*

Show the permissions of directory /usr/bin$ ls -dl /usr/bin

Do you understand why only user root can install software?Nobody has write permissions to /usr/bin

Page 51: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Command history

BASH keeps track of the commands you type Use the arrow keys and to navigate through

the list You can show a numbered list of executed

command using$ history

Page 52: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Command history

To execute a command again you can use:$ !nnn

where nnn is the number in the history listor$ !cmdthe last executed command starting with cmd

Page 53: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Tab expansion

Executables and arguments are expanded using the <tab>-key:$ cd /h<tab>$ cd /home/However$ cd /b<tab> gives you audible feedback:

there is no expansion possible there is more than one way to expand

$ cd /b<tab><tab> shows suitable expansionsbin/ boot/

$ cd /bo<tab> $ cd /boot/

Page 54: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Switch User

To switch identity to another account, use$ su - account

If account is omitted, root is assumed You need to enter the password of the target

account, except if you are root User root is able to switch to any identity,

without needing a password, even if the target account has no (valid) password

Page 55: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Switch User

Example:[james@volvox:~]$ whoamijames[james@volvox:~]$ su -Password: [root@volvox:~]# whoamiroot

Notice that the prompt changes from $ to #This indicates that you have superpower, which is potentially dangerous

Page 56: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Switch User

To execute a single command cmd as another user:$ su – account -c "cmd"

Again, if account is omitted, root is assumed The quotes around cmd are needed to avoid su

from confusing the arguments of cmd with its own arguments.

Page 57: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Switch User

Example:[james@volvox:~]$ ls /rootls: cannot open directory /root: Permission denied[james@volvox:~]$ su - -c "ls /root"Password: anaconda-ks.cfginstall.log.syslog...

Page 58: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Yum

YUM (Yellow Dog Updater, Modified) is a somewhat complex tool that allows you to maintain software packages (RPMs) on your systemhttp://yum.baseurl.org/

YUM makes use of repositories on servers on the Internet: collection RPMs knowledge about package inter-dependencies

Under the hood is the command rpm

Page 59: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Yum repositories

Repositories are defined in files that reside in directory /etc/yum.repos.d/

Repositories are enabled by setting:enabled=1and disabled by setting:enabled=0for a particular repository

Page 60: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Yum repositories

Repositories are defined in files that reside in directory /etc/yum.repos.d/

The repository name is between brackets[Fedora]

Repositories are enabled by setting:enabled=1and disabled by setting:enabled=0for a particular repository

Note that baseurl and mirrorlist are used for finding a suitable repo server on the Internet

Page 61: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Yum - examples

To get a list of installed packages$ yum list installed

To get a list of available packages$ yum list available

To get a list of installed packages for which updates are available$ yum list updates

To know which package provides a certain command (ideal for resolving dependencies)

$ yum whatprovides */transeq

Page 62: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Yum - examples

YUM maintains a database on the local machine containing meta-information for all available packages

To search the database for a particular keyword# yum search keyword

To show a description and summary information# yum info pkg

To obtain dependency information# yum deplist pkg

Page 63: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Yum - examples

To install a package (and its dependencies)# yum [-y] install pkgthe option -y is used to run the command unattended

To remove a package (and its dependencies)# yum erase pkg

To update your entire installation# yum [-y] upgrade

Page 64: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Exercise

With these exercises you will get the feeling of the command line and learn to install tools

Install the following package using YUM(in the listed order): yum-plugin-fastestmirror

Using YUM: which version of EMBOSS is available?

ADVANCED (compile exercise): Try to install the latest package from EMBOSS: http://emboss.sourceforge.net

Page 65: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Solutions

Install the following packages using YUM(in the listed order): Yum-plugin-fastestmirror

Answer:$ su -# yum search fastestmirror# yum install yum-plugin-fastestmirror

Page 66: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Solutions

Using YUM: which version of EMBOSS is available?

Answer: 6.3.1

Solution: # yum info EMBOSS

Page 67: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Solution

.tar.gz: Try to install the latest package from EMBOSS: http://emboss.sourceforge.net

Solution: 1. Download from the website, under downloads, the EMBOSS-

6.4.0.tar.gz file2. extract by: $ su - -c “tar xvfz EMBOSS-6.4.0.tar.gz -C /opt”3. Thing to do: always read the README or INSTALL file: $

less INSTALL 4. Resolve any dependencies with YUM

Page 68: BITS: Introduction to Linux -  Software installation the graphical and the command-line way

Linux

Put the fun back into computing