Skip to main content

Installing New Linux Programs and Packages


APT is very popular and easy to use linux tool for installing or managing already installed packages on linux machines. It can also download, install and upgrade already compiled packages from the internet. APT uses a file /etc/apt/sources.list that lists the 'sources' from which packages can be obtained: 


LinuxBox# vi /etc/apt/sources.list # deb cdrom:[Ubuntu 10.10 _Maverick Meerkat_ - Release i386 (20101007)]/ maverick main restricted # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to # newer versions of the distribution. deb http://es.archive.ubuntu.com/ubuntu/ maverick main restricted deb-src http://es.archive.ubuntu.com/ubuntu/ maverick main restricted # See sources.list(5) for more information deb http://http.us.debian.org/debian stable main contrib non-free deb http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free deb http://security.debian.org stable/updates main contrib non-free # Uncomment if you want the apt-get source function to work #deb-src http://http.us.debian.org/debian stable main contrib non-free #deb-src http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free

After editing sources.list, You have to update the apt-get database with newley added entries.
Update server's pkglist's files with "apt-get update" command: 

LinuxBox# apt-get update Get:1 http://ftp.debian.org etch Release.gpg [378B] Get:2 http://security.debian.org etch/updates Release.gpg [189B] Hit http://ftp.debian.org etch Release Get:3 http://security.debian.org etch/updates Release [37.6kB] Ign http://ftp.debian.org etch/main Packages/DiffIndex Hit http://ftp.debian.org etch/main Packages Ign http://security.debian.org etch/updates/main Packages/DiffIndex Get:4 http://security.debian.org etch/updates/main Packages [336kB] Fetched 374kB in 6m2s (1032B/s) ...



    Searching for desired packages
Searching for packages in database is also very simple. Use "apt-cache search" command which will list You available packages with brief description: 

LinuxBox# apt-cache sarch openssh openssh-blacklist - list of default blacklisted OpenSSH RSA and DSA keys openssh-client - secure shell (ssh) client, for secure access to remote machines openssh-server - secure shell (ssh) server, for secure access from remote machines putty-tools - command line tools for SSH, SCP, and SFTP secpanel - graphical user interface for for SSH and SCP sshpass - Non-interactive ssh password authentication ... LinuxBox#

    Installing packages with apt-get
Once apt sources.list and apt-get databases is updated, packages can be installed with 
"apt-get install package_name":

LinuxBox# apt-get install openssh-server Reading package list... Done Building dependency tree Reading state information... Done The following extra packages will be installed: openssh-client The following NEW packages will be installed: openssh-server The following packages will be upgraded: openssh-client 1 upgraded, 1 newly installed, 0 to remove and 255 not upgraded. Need to get 1,048kB of archives. After this operation, 867kB of additional disk space will be used. Do You want to continue [Y/n]? Y ... LinuxBox#

    Upgrading packages
Installed packages can be very easy upgraded with "apt-get upgrade" command (switch "-u" shows all packages that will be upgraded): 

LinuxBox# apt-get -u upgrade openssh-server Reading Package Lists... Done Building Dependency Tree... Done The following packages will be upgraded openssh-server openssh-client liborbit0 libtiff3g libnewt0 libgtk1.2 libgtk1.2-dev liblockfile1 libstdc++2.10-glibc2.2 9 packages upgraded, 0 newly installed, 0 to remove and 3 not upgraded. Need to get 2055B/2055kB of archives. After unpacking 961kB will be used. Do you want to continue? [Y/n] ... LinuxBox#
(If ever wanted to upgrade entire system to new release, use "apt-get -u dist-upgrade" command) 

    Removing Packages
To remove installed packages, use "apt-get remove" command: 

LinuxBox# apt-get remove openssh-client Reading Package Lists... Done Building Dependency Tree... Done The following packages will be REMOVED: openssh-client 0 packages upgraded, 0 newly installed, 1 to remove and 1 not upgraded. Need to get 0B of archives. After unpacking 8.6MB will be freed. Do you want to continue? [Y/n] ... LinuxBox#

However, this method only removes installed packages. If want to remove packages with corresponding configuration files You will use command "apt-get purge

LinuxBox# apt-get --purge remove openssh-client Reading Package Lists... Done Building Dependency Tree... Done The following packages will be REMOVED: openssh-client 0 packages upgraded, 0 newly installed, 1 to remove and 1 not upgraded. Need to get 0B of archives. After unpacking 6.6MB will be freed. Do you want to continue? [Y/n] ... LinuxBox#


    Debian packet manager
This is a "native" method of managing linux software and packages on Debian based distributions (for example Ubuntu). To list installed system packgaes we can use dpkg command: 

LinuxBox# dpkg -l | grep apache ii apache2 2.2.16-6+squeeze10 Apache HTTP Server metapackage ii apache2-mpm-prefork 2.2.16-6+squeeze10 Apache HTTP Server - traditional non-threaded model ii apache2-utils 2.2.16-6+squeeze10 utility programs for webservers ii apache2.2-bin 2.2.16-6+squeeze10 Apache HTTP Server common binary files ii apache2.2-common 2.2.16-6+squeeze10 Apache HTTP Server common files ii libapache-mod-security 2.5.12-1+squeeze1 Tighten web applications security for Apache ii libapache2-mod-php5 5.3.3-7+squeeze14 server-side, HTML-embedded scripting language (Apache 2 module) rc libapache2-mod-php5filter 5.3.3-7+squeeze14 server-side, HTML-embedded scripting language (apache 2 filter module) LinuxBox#
(In this example, after listing Debian packages, we used grep command to find and filter "apache" packages. This way we can easily search for any installed package.) 

Installed software packages are signed with "ii" letters on the left. Package marked with "rc", are marked for removal. According to the letters assigned on the left, we can easily find out the current status of Debian package. 



The first character describes the desired state (For example some user marked the package for installation): 

i: Install (marked for installation)
p: Purge (marked for purging)
r: Remove (marked for removal) 
h: Hold
u: Unknown (an unknown status)

The second character describes the current state (For example, whether it is installed or not): 

i: Inst – The package is installed successfully
n: Not - The package is not installed
c: Cfg-files – Configuration files are present
f: Failed-cfg - Failed to remove configuration files
h: Half-inst - The package is partially installed
u: Unpacked - The package is unpacked 
W: trig-aWait
t: Trig-pend

To manualy install a single package that we already downloaded from the internet and have it on the system, we can use dpkg -i command: 

LinuxBox# dpkg -i apache2.2-common ... installing LinuxBox#


For removing packages we'll use Purge or Remove flag. Again, the difference between Remove and Purgestate is that "Remove" removes the package binaries but does not touch configuration files. "Purge" removes both, binaries and configuration files. 

So, to remove the package from the system, we can use dpkg --purge command: 

LinuxBox# dpkg --purge apache2 ... uninstalling LinuxBox#

Comments

Popular posts from this blog

Cisco three-layer hierarchical model

Because networks can be extremely complicated, with multiple protocols and diverse technologies, Cisco has developed a layered hierarchical model for designing a reliable network infrastructure. This three-layer model helps you design, implement, and maintain a scalable

Debugging on Cisco ASA

Most of debuging on Cisco ASA can be done with simply entering  "debug"  in front of command for which we want to do debugging. For example if wanted to see/capture icmp traffic from user enter: 

Classes of IP addresses

TCP/IP defines five classes of IP addresses: class A, B, C, D, and E. Each class has a range of valid IP addresses. The value of the first octet determines the class. IP addresses