Monday, January 22, 2018

Basic Commands of APT-GET and APT-CACHE for Package Management - Part(2)

11. How to install Packages without Upgrading

Using sub ‘–no-upgrade‘ command will prevent already installed packages from upgrading.

$ sudo apt-get install packageName --no-upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Skipping vsftpd, it is already installed and upgrade is not set.
0 upgraded, 0 newly installed, 0 to remove and 328 not upgraded.


12. How to Upgrade Only Specific Packages

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
Reading package lists... Done
Building dependency tree       
Reading state information... Done
vsftpd is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 328 not upgraded.


13. How Do I Install Specific Package Version?

Let’s say you wish to install only specific version of packages, simply use the ‘=‘ with the package-name and append desired version.

$ sudo apt-get install vsftpd=2.3.5-3ubuntu1
Reading package lists... Done
Building dependency tree       
Reading state information... Done
vsftpd is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 328 not upgraded.


14. How Do I Remove Packages Without Configuration

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
[sudo] password for manish: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
vsftpd
0 upgraded, 0 newly installed, 1 to remove and 328 not upgraded.
After this operation, 364 kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 216156 files and directories currently installed.)
Removing vsftpd ...
vsftpd stop/waiting
Processing triggers for ureadahead ...
Processing triggers for man-db ...


15. How Do I Completely Remove Packages

To remove software packages including their configuration files, use the ‘purge‘ sub command as shown below.

$ sudo apt-get purge vsftpd
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
vsftpd*
0 upgraded, 0 newly installed, 1 to remove and 328 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
(Reading database ... 216107 files and directories currently installed.)
Removing vsftpd ...
Purging configuration files for vsftpd ...
Processing triggers for ureadahead ...

Alternatively, you can combine both the commands together as shown below.
$ sudo apt-get remove --purge vsftpd
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
vsftpd*
0 upgraded, 0 newly installed, 1 to remove and 328 not upgraded.
After this operation, 364 kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 216156 files and directories currently installed.)
Removing vsftpd ...
vsftpd stop/waiting
Purging configuration files for vsftpd ...
Processing triggers for ureadahead ...
Processing triggers for man-db ...


16. How I Can Clean Up Disk Space

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


17. How Do I Download Only Source Code of Package

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
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Need to get 220 kB of source archives.
Get:1 http://in.archive.ubuntu.com/ubuntu/ quantal/main vsftpd 2.3.5-3ubuntu1 (dsc) [1,883 B]
Get:2 http://in.archive.ubuntu.com/ubuntu/ quantal/main vsftpd 2.3.5-3ubuntu1 (tar) [188 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu/ quantal/main vsftpd 2.3.5-3ubuntu1 (diff) [30.5 kB]
Fetched 220 kB in 4s (49.1 kB/s)
Download complete and in download only mode


18. How Can I Download and Unpack a Package

To download and unpack source code of a package to a specific directory, type the following command.
$ sudo apt-get source vsftpd
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Need to get 220 kB of source archives.
Get:1 http://in.archive.ubuntu.com/ubuntu/ quantal/main vsftpd 2.3.5-3ubuntu1 (dsc) [1,883 B]
Get:2 http://in.archive.ubuntu.com/ubuntu/ quantal/main vsftpd 2.3.5-3ubuntu1 (tar) [188 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu/ quantal/main vsftpd 2.3.5-3ubuntu1 (diff) [30.5 kB]
Fetched 220 kB in 1s (112 kB/s)  
gpgv: Signature made Thursday 24 May 2012 02:35:09 AM IST using RSA key ID 2C48EE4E
gpgv: Can't check signature: public key not found
dpkg-source: warning: failed to verify signature on ./vsftpd_2.3.5-3ubuntu1.dsc
dpkg-source: info: extracting vsftpd in vsftpd-2.3.5
dpkg-source: info: unpacking vsftpd_2.3.5.orig.tar.gz
dpkg-source: info: unpacking vsftpd_2.3.5-3ubuntu1.debian.tar.gz
dpkg-source: info: applying 01-builddefs.patch
dpkg-source: info: applying 02-config.patch
dpkg-source: info: applying 03-db-doc.patch
dpkg-source: info: applying 04-link-local.patch
dpkg-source: info: applying 05-whitespaces.patch
dpkg-source: info: applying 06-greedy.patch
dpkg-source: info: applying 07-utf8.patch
dpkg-source: info: applying 08-manpage.patch
dpkg-source: info: applying 09-s390.patch
dpkg-source: info: applying 10-remote-dos.patch
dpkg-source: info: applying 11-alpha.patch
dpkg-source: info: applying 09-disable-anonymous.patch
dpkg-source: info: applying 12-ubuntu-use-snakeoil-ssl.patch


19. How Can I Download, Unpack and Compile a Package

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
[sudo] password for manish: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Need to get 130 kB of source archives.
Get:1 http://in.archive.ubuntu.com/ubuntu/ quantal/universe goaccess 1:0.5-1 (dsc) [1,120 B]
Get:2 http://in.archive.ubuntu.com/ubuntu/ quantal/universe goaccess 1:0.5-1 (tar) [127 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu/ quantal/universe goaccess 1:0.5-1 (diff) [2,075 B]
Fetched 130 kB in 1s (68.0 kB/s)
gpgv: Signature made Tuesday 26 June 2012 09:38:24 AM IST using DSA key ID A9FD4821
gpgv: Can't check signature: public key not found
dpkg-source: warning: failed to verify signature on ./goaccess_0.5-1.dsc
dpkg-source: info: extracting goaccess in goaccess-0.5
dpkg-source: info: unpacking goaccess_0.5.orig.tar.gz
dpkg-source: info: unpacking goaccess_0.5-1.debian.tar.gz
dpkg-buildpackage: source package goaccess
dpkg-buildpackage: source version 1:0.5-1
dpkg-buildpackage: source changed by Chris Taylor <ctaylor@debian.org>
dpkg-buildpackage: host architecture i386
dpkg-source --before-build goaccess-0.5
dpkg-checkbuilddeps: Unmet build dependencies: debhelper (>= 9) autotools-dev libncurses5-dev libglib2.0-dev libgeoip-dev autoconf
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)
...


20. How Do I Download a Package Without Installing

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
Get:1 Downloading nethogs 0.8.0-1 [27.1 kB]
Fetched 27.1 kB in 3s (7,506 B/s)


21. How Do I Check Change Log of Package?

The ‘changelog‘ flag downloads a package change-log and shows the package version that is installed.

$ sudo apt-get changelog vsftpd
vsftpd (2.3.5-3ubuntu1) quantal; urgency=low
* Merge from Debian testing (LP: #1003644).  Remaining changes:
+ debian/vsftpd.upstart: migrate vsftpd to upstart.
+ Add apport hook (LP: #513978):
- debian/vsftpd.apport: Added.
- debian/control: Build-depends on dh-apport.
- debian/rules: Add --with apport.
+ Add debian/watch file.
+ debian/patches/09-disable-anonymous.patch: Disable anonymous login
by default. (LP: #528860)
* debian/patches/12-ubuntu-us-snakeoil-ssl.patch: Use snakeoil SSL
certificates and key.
-- Andres Rodriguez <andreserl@ubuntu.com>  Wed, 23 May 2012 16:59:36 -0400
...


22. How Do I Check Broken Dependencies?

The ‘check‘ command is a diagnostic tool. It used to update package cache and checks for broken dependencies.

$ sudo apt-get check
[sudo] password for manish: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done


23. How Do I Search and Build Dependencies?

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 following NEW packages will be installed:
debhelper dh-apparmor html2text po-debconf quilt
0 upgraded, 5 newly installed, 0 to remove and 328 not upgraded.
Need to get 1,219 kB of archives.
After this operation, 2,592 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://in.archive.ubuntu.com/ubuntu/ quantal/main html2text i386 1.3.2a-15build1 [91.4 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu/ quantal/main po-debconf all 1.0.16+nmu2ubuntu1 [210 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu/ quantal/main dh-apparmor all 2.8.0-0ubuntu5 [9,846 B]
Get:4 http://in.archive.ubuntu.com/ubuntu/ quantal/main debhelper all 9.20120608ubuntu1 [623 kB]
Get:5 http://in.archive.ubuntu.com/ubuntu/ quantal/main quilt all 0.60-2 [285 kB]
Fetched 1,219 kB in 4s (285 kB/s)
...


24. How I Can Auto clean Apt-Get Cache?

The ‘autoclean‘ command deletes all .deb files from /var/cache/apt/archives to free-up significant volume of disk space.

$ sudo apt-get autoclean
Reading package lists... Done
Building dependency tree       
Reading state information... Done


25. How I Can Auto remove Installed Packages?

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
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'vsftpd' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 328 not upgraded.

No comments:

Post a Comment

Configure NFS Client

This example is based on the environment below. +----------------------+           |           +----------------------+ | [...