Objective:
To familiarize students that how a Linux server could be used as router Scope:
The students would be able to do the following at the end of this lab:
• list installed and available packages
• Install a package locally
• Install a package from the internet.
Useful Concepts:
Automated Package Download
The disadvantage of manual downloads is that the packages often won't install unless certain prerequisite packages have been installed beforehand. This can lead to the download and installation of several pack-ages which can become tedious.
All the major Linux distributions have automated download and update utilities. For example, Fedora uses yum and Ubuntu and Debian use apt.
Exercise-1:- This exercise illustrates how to get RPMs Using Command-Line Anonymous FTP
Anonymous FTP allows you to log in and download files from a FTP server using the username anonym-ous or the shorter username ftp and a password that matches your email address. This way anyone can access the data. Let's illustrate this with an example of using anonymous FTP to download the SSH pack-age from download.fedora.redhat.com:
1) First we issue the FTP command targeting download.fedora.redhat.com at the command line.
[root@bigboy tmp]# ftp download.fedora.redhat.com Trying 66.187.232.35...
Connected to download.fedora.redhat.com (66.187.232.35).
220 Fedora FTP server ready. All transfers are logged.
Name (download.fedora.redhat.com:root): anonymous 331 Please specify the password.
Password:
230 Login successful. Have fun.
Using binary mode to transfer files.
ftp> pwd 257 "/"
ftp> ls
227 Entering Passive Mode (66,187,232,35,57,155) 150 Here comes the directory listing.
drwxr-xr-x 3 ftp ftp 4096 Oct 29 15:59 pub 226 Directory send OK.
ftp>:
2) After we've logged in, we can use the help command to see what options we have at our disposal.
ftp> help
Commands may be abbreviated. Commands are:
! cr mdir proxy send ---
ftp>
3) By using the Web browsing feature on the Web site ahead of time, I know that the Fedora Core 2 RPMs are located in the pub/fedora/linux/core/2/i386/os/Fedora/RPMS/ directory and will use the cd command to change my directory to there. We can use the ls command to get a listing of files in this di-rectory.
ftp> cd pub/fedora/linux/core/2/i386/os/Fedora/RPMS/
250 Directory successfully changed.
ftp> ls open*
227 Entering Passive Mode (66,187,232,35,58,3) 150 Here comes the directory listing.
...
...
-rw-r--r-- ... ... 184281 Oct 28 23:29 openssh-3.6.1p2-34.i386.rpm ...
...
226 Directory send OK.
ftp>
4) Next we get the file we need and place it in the local directory /usr/rpm. The hash command will print
"#" hash signs on the screen during the download.
ftp> hash
Hash mark printing on (1024 bytes/hash mark).
ftp> lcd /usr/rpm
Local directory now /usr/rpm
ftp> get openssh-3.6.1p2-34.i386.rpm
local: openssh-3.6.1p2-34.i386.rpm remote: openssh-3.6.1p2-34.i386.rpm 227 Entering Passive Mode (66,187,232,35,58,25)
150 Opening BINARY mode data connection for openssh-3.6.1p2-34.i386.rpm (184281 bytes).
################################################226 File send OK.
184281 bytes received in 3.41 secs (53 Kbytes/sec) ftp>
Note: You can also use wildcards to download the RPMs you need using the mget command. You'll be prompted for each of the matching RPM files. In the next example, we just aborted this download by typ-ing n.
ftp> mget openssh-3.6*
mget openssh-3.6.1p2-34.i386.rpm? n ftp>
5) Finally we use the exit command to leave FTP.
ftp> exit 221 Goodbye.
root@bigboy tmp]#
Exercise-2:- This exercise illustrates download Software using wget utility.
The wget command can be used to download files quickly when you already know the URL at which the RPM is located. Here is an example downloading a DHCP update from Fedora.
[root@tmp]# wget <URL>
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD /pub/mirrors/fedora/linux/core/2/i386/os/Fedora/RPMS ... done.
==> PASV ... done. ==> RETR dhcp-3.0pl2-6.16.i386.rpm ... done.
Length: 529,890 (unauthoritative)
100%[===============================>] 529,890 889.12K/s ETA 00:00 17:38:36 (889.12 KB/s) - `dhcp-3.0pl2-6.16.i386.rpm.5' saved [529890]
[root@tmp]#
Exercise-3:- This exercise illustrates How to Install RPMs Manually
Download / Copy RPMs (which usually have a file extension ending with .rpm) into a temporary directo-ry, such as /tmp. The next step is to issue the rpm -Uvh command to install the package.
The -U qualifier is used for updating an RPM to the latest version, the -h qualifier gives a list of hash # characters during the installation and the -v qualifier prints verbose status messages while the command is run. Here is an example of a typical RPM installation command to install the MySQL server package:
[root@bigboy tmp]# rpm -Uvh mysql-server-3.23.58-9.i386.rpm Preparing... ####################### [100%]
1:mysql-server ####################### [100%]
[root@bigboy tmp]#
How to Install Source RPMs
Sometimes the packages you want to install need to be compiled in order to match your kernel version.
This requires you to use source RPM files:
Download the source RPMs or locate them on your CD collection. They usually have a file extension ending with (.src.rpm)
Run the following commands as root:
Compiling and installing source RPMs with Fedora can be done simply with the rpmbuild command [root@tmp]# rpmbuild --rebuild filename.src.rpm
Here is an example in which we install the tacacs plus package.
[root@bigboy rpm]# rpmbuild --rebuild tac_plus-4.0.3-2.src.rpm Installing tac_plus-4.0.3-2.src.rpm
Exercise-4:- This exercise illustrates How to List Installed RPMs The rpm -qa command will list all the packages installed on your system:
[root@tmp]# rpm -qa
Exercise-5:- This exercise illustrates Uninstalling RPMs
The rpm -e command will erase an installed package. The package name given must match that listed in the rpm -qa command because the version of the package is important:
[root@tmp]# rpm -e package-name
Exercises for lab:
Exercise 1:- Download RPMs using anonymous FTP.
Exercise 2:- Download RPMs using wget.
Exercise 3:- Install MySQL database using RPM.
Exercise 4:- Install java using source RPM.
Home Work
1) Compare the strengths of apt and yum utility.