3. The most complete Linux software package management apt-get command in the whole network

Apt-get tool set for Linux package management

– – – – – – – There are all corresponding examples at the end – – – – – – – –

In the Linux system, the installation, update and removal of software is a very important task. In order to facilitate software management for users, Linux provides many tool sets, one of which is widely used is apt-get. This article will introduce in detail the usage and common operations of the apt-get toolset.

1. apt-get command
apt-get is a command-line tool for managing software packages in Debian and its derivatives such as Ubuntu. It provides a convenient way to find, install, update and remove packages.

2. Subcommands in apt-get
The apt-get command has multiple subcommands for performing different operations. The following are some commonly used subcommands:

update: Download and update package list information
upgrade: Upgrade all software packages in the system to the latest version
install: Download the required software packages and install and configure them
remove: remove the package
autoremove: Automatically uninstall packages that do not meet dependencies
source: Download the source package
build-dep: Build the required compilation environment for the source package
dist-upgrade: Distro upgrade
dselect-upgrade: upgrade the software package according to the selection of dselect
clean: delete all downloaded package files in the cache
autoclean: Delete the old version of the downloaded package file in the cache
check: Checks the integrity of dependencies in the system

3. Suboptions in apt-get
The apt-get command also has some commonly used sub-options to further control the operation behavior. Here are some common suboptions:

-d: only download the package, do not install or extract it
-f: Fix package dependencies in the system
-m: try to continue execution when missing dependent packages are found
-q: keep the output as a log, do not get the command execution progress
-purge: used with the remove subcommand to completely uninstall the package
-reinstall: used with the install subcommand to reinstall the package
-b: After downloading the source code package, compile and generate the corresponding software package
-s: Do not do actual operation, just simulate the execution result of the command
-y: answer yes to all queries, apt-get will not prompt any more
-u: Get a list of upgraded packages
-h: get help information
-v: get apt-get version number

4. Refresh the software source
Before diving into package management, first make sure your software sources are up to date. Use the update command of apt-get to refresh the software source and update the package list. Run the following command:

sudo apt-get update

This will fetch the latest package information from the software sources.

5. Update packages
To update installed packages, you can use apt-get’s upgrade command. Run the following command:

sudo apt-get upgrade

apt-get will check all installed packages and download and install their latest versions (if updates are available).

6. Install the package
To install a package, use the apt-get install command followed by the package name. Run the following command:

sudo apt-get install package_name

Here is an example to install vim editor using apt-get:

sudo apt-get install vim

apt-get will automatically download the vim package and its dependencies, and install them.

7. Reinstall the package
If you need to reinstall an already installed package, you can use the install command of apt-get. Run the following command:

sudo apt-get install --reinstall package_name

Replace package_name with the name of the package you want to reinstall.

8. Uninstall the package
To uninstall an installed package, use the apt-get remove command. Run the following command:

sudo apt-get remove package_name

This will uninstall the package but keep its configuration files. If you want to uninstall along with configuration files, you can use the purge command. Run the following command:

sudo apt-get purge package_name

9. Fix package dependencies
Sometimes installing or removing packages can cause dependency issues. Use the -f or –fix-broken option of apt-get to fix a package’s dependencies. Run the following command:

sudo apt-get -f install

apt-get will attempt to resolve any dependency issues and install missing packages.

10. Clean package buffer
apt-get will store downloaded packages in a buffer. To free up disk space, you can use apt-get’s autoclean command to clean up the package cache. Run the following command:

sudo apt-get autoclean

apt-get will remove packages that are out of date, but keep packages that are still available.

About all apt-get command sets

1. Subcommands in apt-get
①update: Download and update package list information. Run the following command:

sudo apt-get update

②upgrade: Upgrade all software packages in the system to the latest version. Run the following command:

sudo apt-get upgrade

③install: Download the required software package and install and configure it. Run the following command:

sudo apt-get install package_name

④remove: Uninstall the software package. Run the following command:

sudo apt-get remove package_name

⑤autoremove: Automatically uninstall software packages that do not satisfy dependencies. Run the following command:

sudo apt-get autoremove

⑥source: Download the source package. Run the following command:

sudo apt-get source package_name

⑦build-dep: Build the required compilation environment for the source package. Run the following command:

sudo apt-get build-dep package_name

⑧dist-upgrade: Release version upgrade. Run the following command:

sudo apt-get dist-upgrade

⑨dselect-upgrade: Upgrade the software package according to the selection of dselect. Run the following command:

sudo apt-get dselect-upgrade

⑩clean: Delete all downloaded package files in the cache. Run the following command:

sudo apt-get clean

autoclean: Delete the old version of the downloaded package file in the cache. Run the following command:

sudo apt-get autoclean

check: Checks the integrity of dependencies in the system. Run the following command:

sudo apt-get check

2. Suboptions in apt-get
The apt-get command also has some commonly used sub-options to further control the operation behavior. Here are some common suboptions:

-d: Only download the package without installing or decompressing it. Run the following command:

sudo apt-get -d install package_name

-f: Fix package dependency problems existing in the system. Run the following command:

sudo apt-get -f install

-m: Attempt to continue execution when dependencies are found to be missing. Run the following command:

sudo apt-get -m install package_name

-q: Keep the output as a log, do not get the progress of the command execution. Run the following command:

sudo apt-get -q install package_name

– -purge: Use with the remove subcommand to completely uninstall the package. Run the following command:

sudo apt-get remove --purge package_name

– -reinstall: Use with the install subcommand to reinstall the package. Run the following command:

sudo apt-get install --reinstall package_name

-b: After downloading the source code package, compile and generate the corresponding software package. Run the following command:

sudo apt-get -b source package_name

-s: Do not do actual operation, just simulate the execution result of the command. Run the following command:

sudo apt-get -s install package_name

-y: Answer all queries in the affirmative, and apt-get will not prompt any more. Run the following command:

sudo apt-get -y install package_name

-u: Get a list of upgraded packages. Run the following command:

sudo apt-get -u upgrade

-h: Get help information. Run the following command:

sudo apt-get -h

-v: get apt-get version number. Run the following command:

sudo apt-get -v

The above are common operation methods and examples of the apt-get toolset. By using these commands and options flexibly, you can easily manage and maintain software packages in your Linux system.