syntax.us Let the syntax do the talking
Blog Contact Posts Questions Tags Hire Me

You are here: Linux101 > linux101_cclud_pkg
Question:
In Linux101 how to CCLUD Linux Packages?

To do Machine Learning on Linux I need to be skilled at CCLUD of Packages.

Actually I only need to know the last three verbs: list, update, and delete.

The two varieties of Linux which interest me are Centos 6 and Ubuntu 14.

On Centos the shell command I use LUD packages is: yum

To list packages with yum, I run the command: yum list
dan@cen113.dan ~ $ 
dan@cen113.dan ~ $ 
dan@cen113.dan ~ $ su
Password: 
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ yum list
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
 * base: centos.arvixe.com
 * extras: mirror.keystealth.org
 * updates: mirror.chpc.utah.edu
base                                                     | 3.7 kB     00:00     
base/primary_db                                          | 4.6 MB     00:06     
epel-qt48                                                | 2.9 kB     00:00     
extras                                                   | 3.4 kB     00:00     
extras/primary_db                                        |  30 kB     00:00     
pgdg92                                                   | 3.7 kB     00:00     
pgdg92/primary_db                                        | 123 kB     00:00     
updates                                                  | 3.4 kB     00:00     
updates/primary_db                                       | 2.1 MB     00:01     
Installed Packages
ConsoleKit.x86_64                          0.4.1-3.el6                 @anaconda-CentOS-201311272149.x86_64/6.5
ConsoleKit-libs.x86_64                     0.4.1-3.el6                 @anaconda-CentOS-201311272149.x86_64/6.5
ConsoleKit-x11.x86_64                      0.4.1-3.el6                 @anaconda-CentOS-201311272149.x86_64/6.5
DeviceKit-power.x86_64                     014-3.el6                   @anaconda-CentOS-201311272149.x86_64/6.5
GConf2.x86_64                              2.28.0-6.el6                @anaconda-CentOS-20131127214

snip...

zlib-devel.i686                            1.2.3-29.el6                base     
zlib-static.x86_64                         1.2.3-29.el6                base     
zsh.x86_64                                 4.3.10-9.el6                updates  
zsh-html.x86_64                            4.3.10-9.el6                updates  
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ 
One problem with yum list is it returns several thousand lines of text.

I can use yum to ask if I have a specific package installed in my Linux instance:
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ 

Do I have a package called checkers?

root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ yum list checkers
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: centos.arvixe.com
 * extras: mirror.keystealth.org
 * updates: mirror.chpc.utah.edu
Error: No matching Packages to list
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ 

No, I have no checkers.

Do I have bzip2?

root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ yum list bzip2
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: centos.arvixe.com
 * extras: mirror.keystealth.org
 * updates: mirror.chpc.utah.edu
Installed Packages
bzip2.x86_64       1.0.5-7.el6_0        @anaconda-CentOS-201311272149.x86_64/6.5
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ 

Yes, I have bzip2.  Yay!
After I list my packages, I can update them with the 'yum update' command:

root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ yum update
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: centos.arvixe.com
 * extras: mirror.keystealth.org
 * updates: mirror.chpc.utah.edu
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package NetworkManager.x86_64 1:0.8.1-66.el6 will be updated
---> Package NetworkManager.x86_64 1:0.8.1-75.el6 will be an update
---> Package NetworkManager-glib.x86_64 1:0.8.1-66.el6 will be updated

snip...

 sssd-ldap                       x86_64 1.11.6-30.el6_6.3         updates 167 k
 sssd-proxy                      x86_64 1.11.6-30.el6_6.3         updates 117 k

Transaction Summary
================================================================================
Install      17 Package(s)
Upgrade     461 Package(s)

Total download size: 601 M
Is this ok [y/N]: y

The above update will download 601MB.

That is a lot of software!


Total download size: 601 M
Is this ok [y/N]: y
Downloading Packages:
(1/478): NetworkManager-0.8.1-75.el6.x86_64.rpm          | 1.1 MB     00:00     
(2/478): NetworkManager-glib-0.8.1-75.el6.x86_64.rpm     | 232 kB     00:00     
(3/478): NetworkManager-gnome-0.8.1-75.el6.x86_64.rpm    | 465 kB     00:00     

snip ...

  xz-lzma-compat.x86_64 0:4.999.9-0.5.beta.20091007git.el6                      
  yum.noarch 0:3.2.29-60.el6.centos                                             
  yum-plugin-fastestmirror.noarch 0:1.1.30-30.el6                               
  yum-plugin-security.noarch 0:1.1.30-30.el6                                    
  yum-utils.noarch 0:1.1.30-30.el6                                              

Replaced:
  libsss_autofs.x86_64 0:1.9.2-129.el6_5.4                                      

Complete!
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ 
I delete unwanted packages with the yum remove command:
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ yum list rhythmbox
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: centos.arvixe.com
 * extras: mirror.keystealth.org
 * updates: mirror.chpc.utah.edu
Installed Packages
rhythmbox.x86_64      0.12.8-1.el6      @anaconda-CentOS-201311272149.x86_64/6.5
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ yum remove rhythmbox
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package rhythmbox.x86_64 0:0.12.8-1.el6 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package   Arch   Version        Repository                                Size
================================================================================
Removing:
 rhythmbox x86_64 0.12.8-1.el6   @anaconda-CentOS-201311272149.x86_64/6.5  12 M

Transaction Summary
================================================================================
Remove        1 Package(s)

Installed size: 12 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : rhythmbox-0.12.8-1.el6.x86_64                                1/1 
  Verifying  : rhythmbox-0.12.8-1.el6.x86_64                                1/1 

Removed:
  rhythmbox.x86_64 0:0.12.8-1.el6                                               

Complete!
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ 
If I want rythmbox back, I can easily install it:
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ yum install rhythmbox
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: centos.arvixe.com
 * extras: mirror.keystealth.org
 * updates: mirror.chpc.utah.edu
Resolving Dependencies
--> Running transaction check
---> Package rhythmbox.x86_64 0:0.12.8-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package            Arch            Version                 Repository     Size
================================================================================
Installing:
 rhythmbox          x86_64          0.12.8-1.el6            base          4.1 M

Transaction Summary
================================================================================
Install       1 Package(s)

Total download size: 4.1 M
Installed size: 12 M
Is this ok [y/N]: y
Downloading Packages:
rhythmbox-0.12.8-1.el6.x86_64.rpm                        | 4.1 MB     00:04     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : rhythmbox-0.12.8-1.el6.x86_64                                1/1 
  Verifying  : rhythmbox-0.12.8-1.el6.x86_64                                1/1 

Installed:
  rhythmbox.x86_64 0:0.12.8-1.el6                                               

Complete!
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ 
root@cen113.dan /home/dan $ 
That concludes my discussion of yum which is the package utility for Centos.

Ubunutu has a package utility named apt-get.

I prefer to use a similar utility named aptitude.

If I encounter an Ubuntu instance which has aptitude not installed, I install it with this command:
apt-get install aptitude


How to list packages with aptitude?
dan@feb ~ $ 
dan@feb ~ $ aptitude list
Unknown command "list"
aptitude 0.6.8.2
Usage: aptitude [-S fname] [-u|-i]
       aptitude [options]  ...
  Actions (if none is specified, aptitude will enter interactive mode):

 install      - Install/upgrade packages.
 remove       - Remove packages.
 purge        - Remove packages and their configuration files.
 hold         - Place packages on hold.
 unhold       - Cancel a hold command for a package.
 markauto     - Mark packages as having been automatically installed.
 unmarkauto   - Mark packages as having been manually installed.
 forbid-version - Forbid aptitude from upgrading to a specific package version.
 update       - Download lists of new/upgradable packages.
 safe-upgrade - Perform a safe upgrade.
 full-upgrade - Perform an upgrade, possibly installing and removing packages.
 build-dep    - Install the build-dependencies of packages.
 forget-new   - Forget what packages are "new".
 search       - Search for a package by name and/or expression.
 show         - Display detailed information about a package.
 versions     - Displays the versions of specified packages.
 clean        - Erase downloaded package files.
 autoclean    - Erase old downloaded package files.
 changelog    - View a package s changelog.
 download     - Download the .deb file for a package.
 reinstall    - Download and (possibly) reinstall a currently installed package.
 why          - Show the manually installed packages that require a package, or
                why one or more packages would require the given package.
 why-not      - Show the manually installed packages that lead to a conflict
                with the given package, or why one or more packages would
                lead to a conflict with the given package if installed.

  Options:
 -h             This help text.
 --no-gui       Do not use the GTK GUI even if available.
 -s             Simulate actions, but do not actually perform them.
 -d             Only download packages, do not install or remove anything.
 -P             Always prompt for confirmation of actions.
 -y             Assume that the answer to simple yes/no questions is 'yes'.
 -F format      Specify a format for displaying search results; see the manual.
 -O order       Specify how search results should be sorted; see the manual.
 -w width       Specify the display width for formatting search results.
 -f             Aggressively try to fix broken packages.
 -V             Show which versions of packages are to be installed.
 -D             Show the dependencies of automatically changed packages.
 -Z             Show the change in installed size of each package.
 -v             Display extra information. (may be supplied multiple times).
 -t [release]   Set the release from which packages should be installed.
 -q             In command-line mode, suppress the incremental progress
                indicators.
 -o key=val     Directly set the configuration option named 'key'.
 --with(out)-recommends	Specify whether or not to treat recommends as
                strong dependencies.
 -S fname       Read the aptitude extended status info from fname.
 -u             Download new package lists on startup.
                  (terminal interface only)
 -i             Perform an install run on startup.
                  (terminal interface only)

                  This aptitude does not have Super Cow Powers.
dan@feb ~ $ 
dan@feb ~ $ 
dan@feb ~ $ 


dan@feb ~ $ 
dan@feb ~ $ aptitude show rythmbox
E: Unable to locate package rythmbox
dan@feb ~ $ 
dan@feb ~ $ 
dan@feb ~ $ aptitude show pico
No current or candidate version found for pico
Package: pico
State: not a real package

dan@feb ~ $ aptitude show nano
Package: nano
State: installed
Automatically installed: no
Version: 2.2.6-1ubuntu1
Priority: standard
Section: editors
Maintainer: Ubuntu Developers 
Architecture: amd64
Uncompressed Size: 614 k
Depends: libc6 (>= 2.14), libncursesw5 (>= 5.6+20070908), libtinfo5, dpkg (>=
         1.15.4) | install-info
Suggests: spell
Conflicts: pico, pico, nano
Breaks: alpine-pico (<= 2.00+dfsg-5), alpine-pico (<= 2.00+dfsg-5)
Replaces: pico, pico
Provides: editor
Description: small, friendly text editor inspired by Pico
 GNU nano is an easy-to-use text editor originally designed as a replacement for
 Pico, the ncurses-based editor from the non-free mailer package Pine (itself
 now available under the Apache License as Alpine). 
 
 However, nano also implements many features missing in pico, including: 
 * feature toggles; 
 * interactive search and replace (with regular expression support); 
 * go to line (and column) command; 
 * auto-indentation and color syntax-highlighting; 
 * filename tab-completion and support for multiple buffers; 
 * full internationalization support.
Homepage: http://www.nano-editor.org/

dan@feb ~ $ 
dan@feb ~ $ 
In the above demo I show that aptitude has no 'list' option. It does, however, have a 'show' option.

So I use the show option to see if I have rythmbox installed.

Maybe I should have searched for rhythmbox.

Next, I look for a package called pico. I see no pico so I look for nano and I do find that.

That concludes the list-part of LUD aptitude.

Q: How to use aptitude to update a package named nano?
A: I use the shell command: aptitude upgrade nano

root@ubutemp /home/dan $ 
root@ubutemp /home/dan $ 
root@ubutemp /home/dan $ aptitude upgrade nano
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 296 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.
                                  
root@ubutemp /home/dan $ 
root@ubutemp /home/dan $ 
The above demo, which is kind of lame, shows how to update an editor named nano.

It turns out that nano is the most recent version so it needs no update.

On Ubuntu, aptitude and apt-get have a subtle difference compared to yum on Centos.

The above demo shows this difference.

The aptitude utility depends on information about all the packages on the net.

This information is updated with the 'aptitude update' command.

Then to actually update a package I issue a command like this:
aptitude upgrade nano
Here is what I memorize:

aptitude update is not like yum update

aptitude upgrade is like yum update

yum upgrade is like yum update

Q: So if yum upgrade is like yum update, should I use yum upgrade or yum update?
A: I should use yum update.
Now that I know how to use aptitude to update nano, how do I delete the nano package?

Demo:
root@ubutemp /home/dan $ 
root@ubutemp /home/dan $ 
root@ubutemp /home/dan $ aptitude remove nano
The following packages will be REMOVED:
  nano 
0 packages upgraded, 0 newly installed, 1 to remove and 296 not upgraded.
Need to get 0 B of archives. After unpacking 614 kB will be freed.
(Reading database ... 167416 files and directories currently installed.)
Removing nano (2.2.6-1ubuntu1) ...
update-alternatives: using /usr/bin/vim.tiny to provide /usr/bin/editor (editor) in auto mode
Processing triggers for man-db (2.6.7.1-1) ...
Processing triggers for install-info (5.2.0.dfsg.1-2) ...
Processing triggers for doc-base (0.10.5) ...
Processing 2 removed doc-base files, 31 changed doc-base files...
                                         
root@ubutemp /home/dan $ 
root@ubutemp /home/dan $ 
root@ubutemp /home/dan $ 
Now that I have deleted the nano package, how do I install it?
root@ubutemp /home/dan $ 
root@ubutemp /home/dan $ 
root@ubutemp /home/dan $ aptitude install nano
The following NEW packages will be installed:
  nano 
0 packages upgraded, 1 newly installed, 0 to remove and 296 not upgraded.
Need to get 194 kB of archives. After unpacking 614 kB will be used.
Get: 1 http://us.archive.ubuntu.com/ubuntu/ trusty/main nano amd64 2.2.6-1ubuntu1 [194 kB]
Fetched 194 kB in 0s (211 kB/s)
Selecting previously unselected package nano.
(Reading database ... 167363 files and directories currently installed.)
Preparing to unpack .../nano_2.2.6-1ubuntu1_amd64.deb ...
Unpacking nano (2.2.6-1ubuntu1) ...
Processing triggers for doc-base (0.10.5) ...
Processing 2 added doc-base files...
Processing triggers for install-info (5.2.0.dfsg.1-2) ...
Processing triggers for man-db (2.6.7.1-1) ...
Setting up nano (2.2.6-1ubuntu1) ...
update-alternatives: using /bin/nano to provide /usr/bin/editor (editor) in auto mode
update-alternatives: using /bin/nano to provide /usr/bin/pico (pico) in auto mode
                                         
root@ubutemp /home/dan $ 
root@ubutemp /home/dan $ 
root@ubutemp /home/dan $ 


Linux uses an idea called 'Services'.

An example of a service is an Apache web server.

I often use yum or aptitude to install a service.

So it make sense to study services after packages.

CCLUD of Services is the next topic of Linux101:
linux101_cclud_service


You are here: Linux101 > linux101_cclud_pkg
syntax.us Let the syntax do the talking
Blog Contact Posts Questions Tags Hire Me