How to use the apt command in Linux

apt designed specifically for interactive use. Priority use apt-get and apt-cache in your shell scripts, because they backward compatibility between different versions and with more options and features.

Most apt command must be run as a user with sudo privileges.

This guide can be used as a quick reference apt command.

Update Package Index (apt update)

APT package index is essentially a database, record-keeping system to enable him repository of available packages.

To update the package index, run the following command. This will extract the latest changes APT repository:

sudo apt update

Always update package index before upgrading or installing a new software package.

Upgrade package (apt upgrade)

Regularly updated Linux system is one of the most important aspects of the overall system security.

To upgrade installed packages to the latest version, run:

sudo apt upgrade

This command does not need to remove those upgrade packages installed packages.

If you want to upgrade a single package, pass the package name:

sudo apt upgrade package_name

Configuring automatic security updates is always a good idea.

Full upgrade (apt full-upgrade)

The difference between the upgrade and full-upgrade is that if you need to upgrade the entire system, which will remove installed packages.

sudo apt full-upgrade

Use extreme caution when using this command.

Installation package (apt install)

Installation package is as simple as running the following command:

sudo apt install package_name

If you are installing multiple packages, please specify them as a list separated by spaces:

sudo apt install package1 package2

To install local deb file, provide the full path to the file. Otherwise, the command will try to retrieve from APT repository and install the package.

sudo apt install /full/path/file.deb

Delete packages (apt remove)

To delete the installed packages, type the following

sudo apt remove package_name

You can also specify multiple packages, separated by spaces:

sudo apt remove package1 package2

This command will uninstall remove a given package, but it may leave some configuration files. If you want to delete the package includes all the configuration files, use the purge instead of remove:

sudo apt purge package_name

Remove unused packages (apt autoremove)

Whenever installed on your system depend on the new packages Other packages will install the package dependencies. After you remove the package dependency will remain on the system. The remaining packages are no longer used in any other things that can be deleted.

To delete unwanted dependency, use the following command:

sudo apt autoremove

View the list of packages (apt list)

The list command allows you to list the available, installed packages and scalable.

To list all available packages, please use the following command:

sudo apt list

This command will print a list of all packages, including information about the version of the package and architecture. To determine if a specific package is installed, you can use the grep command to filter the output.

sudo apt list | grep package_name

Only lists the installed package, enter:

sudo apt list --installed

Obtained before the actual upgrade packages can upgrade package list may be useful:

sudo apt list --upgradeable

Search package (apt search)

This command allows you to search the list of available packages for a given package:

sudo apt search package_name

If found, the command returns the name matching the search term package.

View package information (apt show)

Before you delete or install new packages, package-related dependency, the size of the installation, the package source information may be useful.

To retrieve information about a given package, please use the following show commands:

sudo apt show package_name

in conclusion

Learn how to manage package is an important part of Linux system administration.

For more information about the apt command, open a terminal and type man apt.

Guess you like

Origin www.linuxidc.com/Linux/2019-08/160197.htm