Wednesday, June 22, 2016

Apt-Get To Install Package

From Ubuntu Documentation

Introduction to APT

"In the beginning there was the .tar.gz. Users had to compile each program that they wanted to use on their GNU/Linux systems. When Debian was created, it was deemed necessary that the system include a method of managing the packages installed on the machine. The name dpkg was given to this system. Thus the famous 'package' first came into being on GNU/Linux, a while before Red Hat decided to create their own 'rpm' system.
 
A new dilemma quickly took hold of the minds of the makers of GNU/Linux. They needed a rapid, practical, and efficient way to install packages that would manage dependencies automatically and take care of their configuration files while upgrading. Here again, Debian led the way and gave birth to APT, the Advanced Packaging Tool, which has since been ported by Conectiva for use with rpm and has been adopted by some other distributions."
-- From Debian APT HOWTO

Commands

IconsPage/info.png All these commands except the search commands must be run as root or with superuser privileges, see sudo for more information.
  • IconsPage/example.png
    sudo apt-get install ubuntu-desktop 

Installation commands

  • apt-get install <package_name> 
    This command installs a new package.
  • apt-get build-dep <package_name> 
    This command searches the repositories and installs the build dependencies for <package_name>. If the package is not in the repositories it will return an error.
  • aptitude install <package_name>
    Aptitude is an Ncurses viewer of packages installed or available. Aptitude can be used from the command line in a similar way to apt-get. See man aptitude for more information.
  • APT and aptitude will accept multiple package names as a space delimited list. For example:
    apt-get install <package1_name> <package2_name> <package3_name>

auto-apt

  • auto-apt run <command_string>
    When invoked, the auto-apt command automatically installs packages upon missing file access. If a program tries to access a file known to belong in an uninstalled package, auto-apt will install that package using apt-get. This feature requires apt and sudo to work.

  • Auto-apt keeps databases which need to be kept up-to-date in order for it to be effective. This is achieved by calling the commands auto-apt update, auto-apt updatedb and auto-apt update-local. 
  • Usage example
    • IconsPage/example.png You're compiling a program and, all of a sudden, there's an error because it needs a file you don't have. The program auto-apt asks you to install packages if they're needed, stopping the relevant process and continuing once the package is installed.
           # auto-apt run ./configure
      It will then ask to install the needed packages and call apt-get automatically. If you're running X, a graphical interface will replace the default text interface.
    • Maintenance commands

    • apt-get update
      Run this command after changing /etc/apt/sources.list or /etc/apt/preferences . For information regarding /etc/apt/preferences, see PinningHowto. Run this command periodically to make sure your source list is up-to-date. This is the equivalent of "Reload" in Synaptic or "Fetch updates" in Adept.
    • apt-get upgrade
      This command upgrades all installed packages. This is the equivalent of "Mark all upgrades" in Synaptic.
    • apt-get dist-upgrade
      The same as the above, except add the "smart upgrade" checkbox. It tells APT to use "smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary.
      IconsPage/note.png "apt-get dist-upgrade" does not perform distribution upgrade. See [http://www.ubuntu.com/getubuntu/upgrading upgrading] for more information.
    • apt-get check
      This command is a diagnostic tool. It does an update of the package lists and checks for broken dependencies.
    • 
      
    •  
    • apt-get -f install
      This command does the same thing as Edit->Fix Broken Packages in Synaptic. Do this if you get complaints about packages with "unmet dependencies".

    • apt-get autoclean
      This command removes .deb files for packages that are no longer installed on your system. Depending on your installation habits, removing these files from /var/cache/apt/archives may regain a significant amount of diskspace.

    • apt-get clean
      The same as above, except it removes all packages from the package cache. This may not be desirable if you have a slow Internet connection, since it will cause you to redownload any packages you need to install a program.
      • The package cache is in /var/cache/apt/archives . The command
        du -sh /var/cache/apt/archives
        will tell you how much space cached packages are consuming.
      •  
    • dpkg-reconfigure <package_name>
      Reconfigure the named package. With many packages, you’ll be prompted with some configuration questions you may not have known were there.
      • IconsPage/example.png For example:

No comments:

Post a Comment