Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the apt command in linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use the apt command in linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Apt command can be said to be the most important command under the Ubuntu system. Installing, updating, uninstalling software and upgrading the system kernel are inseparable from the apt command.

Apt is designed for interactive use. Apt-get and apt-cache are preferred in your shell scripts because they are backward compatible between versions and have more options and functionality.

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

Update package Index (apt update)

The APT package index is basically a database that keeps records of available packages in the repository enabled in the system.

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

Sudo apt update

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

Upgrade package (apt upgrade)

Updating the Linux system regularly is one of the most important aspects of the security of the whole system.

To upgrade the installed package to the latest version, run:

Sudo apt upgrade

This command does not upgrade packages that need to be removed from installed packages.

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

Sudo apt upgrade package_name

It is always a good idea to configure automatic security updates.

Full upgrade (apt full-upgrade)

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

Sudo apt full-upgrade

Be careful when using this command.

Installation package (apt install)

Installing the package is as simple as running the following command:

Sudo apt install package_name

If you are installing multiple packages, specify them as a space-separated list:

Sudo apt install package1 package2

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

Sudo apt install / full/path/file.deb delete package (apt remove)

To delete an installed package, type

Sudo apt remove package_name

You can also specify multiple packages, separated by spaces:

Sudo apt remove package1 package2

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

Sudo apt purge package_name deletes unused packages (apt autoremove)

Package dependencies are also installed whenever a new package that depends on other packages is installed on the system. After you delete the package, the dependencies remain on the system. These remaining packages are no longer used by anything else and can be deleted.

To remove unwanted dependencies, use the following command:

Sudo apt autoremove View package list (apt list)

This list command allows you to list available, installed, and upgradeable packages.

To list all available packages, use the following command:

Sudo apt list

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

Sudo apt list | grep package_name

To list only installed packages, enter:

Sudo apt list-installed

It may be useful to get a list of upgradeable packages before actually upgrading them:

Sudo apt list-upgradeable search package (apt search)

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

Sudo apt search package_name

If found, the command returns a package whose name matches the search term.

View package information (apt show)

Information about package dependencies, installation size, package sources, and so on, can be useful before removing or installing new packages.

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

Sudo apt show package_name above is all the contents of this article entitled "how to use apt commands in linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report