Skip to main content

Package Management


In few words, package management is a method of installing and maintaining (which includes updating and probably removing as well) software on the system.
In the early days of Linux, programs were only distributed as source code, along with the required man pages, the necessary configuration files, and more. Nowadays, most Linux distributors use by default pre-built programs or sets of programs called packages, which are presented to users ready for installation on that distribution. However, one of the wonders of Linux is still the possibility to obtain source code of a program to be studied, improved, and compiled.
if a certain package requires a certain resource such as a shared library, or another package, it is said to have a dependency. All modern package management systems provide some method of dependency resolution to ensure that when a package is installed, all of its dependencies are installed as well.
Almost all the software that is installed on a modern Linux system will be found on the Internet. It can either be provided by the distribution vendor through central repositories (which can contain several thousands of packages, each of which has been specifically built, tested, and maintained for the distribution) or be available in source code that can be downloaded and installed manually.
In order to perform the task of package management effectively, you need to be aware that you will have two types of available utilities: low-level tools (which handle in the backend the actual installation, upgrade, and removal of package files), and high-level tools (which are in charge of ensuring that the tasks of dependency resolution and metadata searching -”data about the data”- are performed).
DISTRIBUTION
LOW-LEVEL TOOL
HIGH-LEVEL TOOL
 Debian and derivatives
 dpkg
 apt-get / aptitude
 CentOS
 rpm
 yum
 openSUSE
 rpm
 zypper
dpkg is a low-level package manager for Debian-based systems. It can install, remove, provide information about and build *.deb packages but it can’t automatically download and install their corresponding dependencies.
apt-get is a high-level package manager for Debian and derivatives, and provides a simple way to retrieve and install packages, including dependency resolution, from multiple sources using the command line. Unlike dpkg, apt-get does not work directly with *.deb files, but with the package proper name.



What is apt-get?
The apt-get utility is a powerful and free package management command line program, that is used to work with Ubuntu’s APT (Advanced Packaging Tool) library to perform installation of new software packages, removing existing software packages, upgrading of existing software packages and even used to upgrading the entire operating system.
What is apt-cache?
The apt-cache command line tool is used for searching apt software package cache. In simple words, this tool is used to search software packages, collects information of packages and also used to search for what available packages are ready for installation on Debian or Ubuntu based systems.
Examples
To list all the available packages, type the following command.
$ apt-cache pkgnames
To find out the package name and with it description before installing, use the ‘search‘ flag
$ apt-cache search vsftpd   ---will display the details of vsftpd.
if you would like to check information of package along with it short description
$apt-cache show netcat  ----will display the details of package netcat
the ‘update‘ command is used to resynchronize the package index files from the their sources specified in /etc/apt/sources.list file. The update command  fetched the packages from their locations and update the packages to newer version.
$ sudo apt-get update
The ‘upgrade‘ command is used to upgrade all the currently installed software packages on the system
$ sudo apt-get upgrade
The ‘install‘ sub command is tracked by one or more packages wish for installation or upgrading.
$ sudo apt-get install netcat  --- will install netcat package
You can add more than one package name along with the command in order to install multiple packages at the same time. For example, the following command will install packages ‘nethogs‘ and ‘goaccess‘.
$ sudo apt-get install nethogs goaccess


Using sub ‘–no-upgrade‘ command will prevent already installed packages from upgrading.
$ sudo apt-get install packageName --no-upgrade
The ‘–only-upgrade‘ command do not install new packages but it only upgrade the already installed packages and disables new installation of packages.
$ sudo apt-get install packageName --only-upgrade
To un-install software packages without removing their configuration files (for later re-use the same configuration). Use the ‘remove‘ command as shown.
$ sudo apt-get remove vsftpd
To remove software packages including their configuration files, use the ‘purge‘ sub command as shown below.
$ sudo apt-get purge vsftpd
The ‘clean‘ command is used to free up the disk space by cleaning retrieved (downloaded) .deb files (packages) from the local repository.
$ sudo apt-get clean
To download only source code of particular package, use the option ‘–download-only source‘ with ‘package-name’ as shown.
$ sudo apt-get --download-only source vsftpd
To download and unpack source code of a package to a specific directory, type the following command.
$ sudo apt-get source vsftpd
You can also download, unpack and compile the source code at the same time, using option ‘–compile‘ as shown below.
$ sudo apt-get --compile source goaccess
Using ‘download‘ option, you can download any given package without installing it. For example, the following command will only download ‘nethogs‘ package to current working directory.
$ sudo apt-get download nethogs
The ‘check‘ command is a diagnostic tool. It used to update package cache and checks for broken dependencies.
$ sudo apt-get check
This ‘build-dep‘ command searches the local repositories in the system and install the build dependencies for package. If the package does not exists in the local repository it will return an error code.
$ sudo apt-get build-dep netcat
The ‘autoclean‘ command deletes all .deb files from /var/cache/apt/archives to free-up significant volume of disk space.
$ sudo apt-get autoclean
The ‘autoremove‘ sub command is used to auto remove packages that were certainly installed to satisfy dependencies for other packages and but they were now no longer required. For example, the following command will remove an installed package with its dependencies.
$ sudo apt-get autoremove vsftpd




Comments

Popular posts from this blog

Writing a Bash Shell Script

What Are Shell Scripts? In the simplest terms, a shell script is a file containing a series of commands. The shell reads this file and carries out the commands as though they have been entered directly on the command line. The shell is somewhat unique, in that it is both a powerful command line interface to the system and a scripting language interpreter. As we will see, most of the things that can be done on the command line can be done in scripts, and most of the things that can be done in scripts can be done on the command line. Writing Your First Script And Getting It To Work To successfully write a shell script, you have to do three things: Write a script Give the shell permission to execute it Put it somewhere the shell can find it Writing A Script A shell script is a file that contains ASCII text. To create a shell script, you use a text editor . A text editor is a program, like a word processor, that reads and writes ASCII text files. There are...

Basic Linux Commands For Beginner's

Basic Linux Commands for Beginners Linux is an Operating System’s Kernel. You might have heard of UNIX. Well, Linux is a UNIX clone. But it was actually created by Linus Torvalds from Scratch. Linux is free and open-source, that means that you can simply change anything in Linux and redistribute it in your own name! There are several Linux Distributions, commonly called “distros”. A few of them are: Mint Ubuntu Linux Red Hat Enterprise Linux Debian Fedora Kali Linux is Mainly used in Servers. About 90% of the Internet is powered by Linux Servers. This is because Linux is fast, secure, and free! The main problem of using Windows Servers are their cost. This is solved by using Linux Servers. Forgot to mention, the OS that runs in about 80% of the Smartphones in the World, Android, is also made from the Linux Kernel. Yes, Linux is amazing! A simple example of its security is that most of the viruses in the world run on Windows, but not on Linux...

Shell

Definition of the Shell Shell is an interactive environment which provides an interface to an Operating System. It gathers input from user and execute the commands. Bourne shell(sh)- 1977 The Bourne shell was introduced. The Bourne shell(sh), by Stephen Bourne at AT&T Bell Labs for V7 UNIX, remains a useful shell today (in some cases, as the default root shell). The Bourne shell was developed after working on an ALGOL68 compiler, so its grammar is more along the lines of Algorithmic Language (ALGOL) than other shells. The source code was developed in C. The Bourne shell served two primary goals: Executing UNIX/Linux commands for the operating system,i.e, command line interpreter Writing reusable scripts that could be invoked through the shell,i.e, scripting In addition to replacing the Thompson shell, the Bourne shell offered many other advantages over its predecessors such as control flows, loops, and variables into scripts, providing a more functional language to...