Basic apt-get and apt-cache commands that are used in Linux

Basic apt-get and apt-cache commands

1 Shares
1
0
0

The apt-get utility is a powerful free console program used and operated with the APT (Advanced Packaging Tool) library to perform the installation of new packages with software, to remove existing packages, to update existing packages, and to upgrade the entire operating system.

The console utility apt-cache is used to search the APT software package cache. In simple words, this tool is used to search for packages, gather information about packages and find packages available for installation on Debian- or Ubuntu-based operating systems.

How can I get a list of all available packages?

To see all available packages, run the following command:

apt-cache pkgnames

How you can find the name of a package and its description?

To find the name of a package and its description before installing it, use the “search” flag. Using “search” with apt-cache will display a list of matching packages with a brief description. For example, you want to find a description of the vsftpd package: to do this, the command should be like this:

apt-cache search vsftpd

To find and list all packages whose name starts with vsftpd, you can use the following command:

apt-cache pkgnames vsftpd

How can I view information about the package?

For example, if you want to see information about a package, with a brief description showing its version number, checksums, size, size after installation, categories and so on, you can use the “show” subcommand, as shown below:

apt-cache show netcat

How can I install multiple packages at once?

You can enter the names of several packages to install them simultaneously. For example, to install the nethogs and goaccess packages, you can run the following command:

sudo apt-get install nethogs goaccess

How to install multiple packages by “mask” name

With regular cuts you can add multiple packages using special characters. For example, you can use an asterisk to set all packages that contain the string “name” in their name:

sudo apt-get install name

How to install packages without upgrading?

Using the -no-upgrade flag will prevent the upgrade of already installed packages.

sudo apt-get install packageName --no-upgrade

How do I just update certain packages?

The -only-upgrade flag will not install new packages, but only upgrade existing ones.

sudo apt-get install package_name --only-upgrade

How can I install a specific version of a package?

Suppose you need to install a specific version of a package, just use the equal sign along with the package name and type the desired version.

sudo apt-get install vsftpd=2.3.5-3ubuntu1

How do I remove packages without removing settings?

To remove software packages without removing their configuration files (for future use), use the remove command as shown.

sudo apt-get remove vsftpd

How do I remove packages completely?

To remove a package together with its configuration files, use the purge subcommand as shown below.

sudo apt-get purge vsftpd

Or you could combine the two teams, like this:

sudo apt-get remove --purge vsftpd

How can I clear disk space?

The clean command is used to free up disk space by deleting .deb package files in your local repository.

sudo apt-get clean

How do I just download the source code of a package?

To download only the source code of a package, you can use the -download-only source option with the package name, for example:

sudo apt-get --download-only source vsftpd

How can I download and unpack the package?

To download and extract the source code of a package into a special directory, run the following command:

sudo apt-get source vsftpd

How can I download, unpack and compile the source code of a package?

You can also download, unpack and compile the source code of a package using the ‘-compile’ option, as shown below:

sudo apt-get --compile source goaccess

How to download a package without installing it?

Using the “download” option, you can download any package without installing it. For example, the following command will only download the nethogs package into the current working directory.

sudo apt-get download nethogs

How can I view the changelog of a package?

The changelog flag loads the changelog of the package and displays the version of the package if it is installed.

sudo apt-get changelog vsftpd

How do you fix broken dependencies?

The “check” command is a diagnostic tool and is used to update the package cache and check for broken dependencies.

sudo apt-get check

How can you find and collect dependencies?

The build-dep command looks for and installs the assembled dependencies of the desired package. If the package is not in the local repository, you will get an error.

sudo apt-get build-dep netcat

How can I automatically clear the Apt-Get cache?

The autoclean command removes all .deb files from /var/cache/apt/archives to free up hard disk space.

sudo apt-get autoclean

How can I automatically remove unnecessary packages?

The autoremove subcommand is used to automatically remove packages that were installed as dependencies of others but are now no longer needed. For example, the following command will remove an installed package along with its dependencies.

sudo apt-get autoremove vsftpd
1 Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like