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 common command apt-get in Linux

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

Share

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

Xiaobian to share with you how to use Linux common command apt-get, I believe most people still don't know how to use, so share this article for your reference, I hope you have a lot of harvest after reading this article, let's go to understand it together!

Linux common command apt-get command is suitable for deb package management operating system, mainly used to automatically search, install, upgrade, uninstall software or operating system from the Internet software repository.

Advanced Package Tool, aka apt-get, is an application manager for Unix and Linux systems. Originally released in 1998, it was used to retrieve applications and load them into Debian Linux systems. Apt-get is famous for its ability to resolve software dependencies. It usually uses.deb-formatted files, but can be modified to use apt-rpm to process Red Hat's Package Manager (RPM) files.

Major Linux systems that use apt-get include Debian and Ubuntu variants. In most cases, run the tool from the command line. There are several graphical front ends available on the desktop, including Synaptic Package Manager, Ubuntu Software Center, Aptitude, and Kpackage. Raspberry Pi and Beaglebone Black nano Linux users can easily use apt-get loaders because these systems usually come from Ubuntu or Debian code. Debian is a package management tool for ubuntu distributions, very similar to the yum tool in red hat. [1]

The apt-get command generally requires root privileges to execute, so it usually follows the sudo command.

Common commands:

apt-get install packagename #install a new package apt-get remove packagename #uninstall an installed package (keep profile) apt-get remove --purge packagename #uninstall an installed package (delete profile) apt-get autoremove packagename #delete package and dependent packages apt-get autoremove --purge packagname #delete package and dependent packages + profile, dpkg --force-all --purge packagename #Some software is hard to uninstall and blocks other software applications, so you can use this, but it's a bit risky. Regardless of the means used by the user to configure APT software sources, the configuration file--/etc/apt/sources.list is modified to inform the software source of the mirror site address only. However, the software resources owned by the mirror sites pointed to are not clear, and these resources need to be listed so that the local host knows what resources can be requested;

1、sudo apt-get update

The apt-get update command scans each software origin server and indexes all package resources owned by that server in the local/var/lib/apt/lists/directory. When apt-get is used to perform installation and update operations, resources will be requested from the software origin server according to these index files. Therefore, it is a good practice to frequently use the "apt-get update" command to refresh software sources when the computer device is idle

2、sudo apt-get upgrade

Upgrading all packages in your system to the latest version at once makes it easy to update packages in the same release number. After checking the dependencies, the command lists all the packages that currently need to be upgraded, and after getting confirmation from the user, the download and installation of the updated packages begin. Of course, the apt- get upgrade command installs the updated packages in the proper order at the end. System updates require users to wait for a while.

3、sudo apt-get install XXX

Download packages using "apt-get install" in 4 steps: Step 1: Scan the list of locally stored package updates (Refresh the update list by "apt-get update" command, i.e./var/lib/apt/lists/), and find the latest version of the software package; Step 2, check the dependency relationship of the software package, and find all the software packages that support the normal operation of the software; Step 3, download the relevant software packages from the mirror site pointed to by the software source; Step 4, decompress the software packages, and automatically complete the installation and configuration of the application.

Upgrade the system to a new version

New versions of Ubuntu Linux are constantly being released, either via the Internet or on CDs (installation CDs burned from ISO images), and the "apt-get dist-upgrade" command allows you to upgrade from one version of Ubuntu to another. For example, upgrade from dapper (version 6.10), a distribution of Ubuntu, to feisty (version 7.04).

This upgrade process consists of 3 steps:

The first step is to modify the version identifier in each configuration item of the software source configuration file. Similar to placing the following configuration items.

deb http://cn.archive.ubuntu.com/ubuntu/ dapper main restricted modified to:

deb http://cn.archive.ubuntu.com/ubuntu/ feisty main restricted● Step 2, refresh the list of package updates using the "apt-get update" command.

Step 3: Use the "apt-get dist-upgrade" command to upgrade the system to a new version.

As you can see from the results of the following command,"apt-get dist-upgrade" is much more complex than "apt-get upgrade," and you must plan the entire system upgrade process, which includes listing all packages that need to be uninstalled, installed, and upgraded. The time and space consumed in this upgrade process is considerable.

6. Several directories related to apt-get

#The contents of the file are package descriptions, which include all packages from the ubunt installation source used by the current system, including installed and uninstalled packages on the current system. /var/lib/dpkg/available #Directory is the temporary storage path of software packages when installing software with apt-get install/var/cache/apt/archives #Storage is the software source site/etc/apt/sources.list #Use apt-get update command to download software list from/etc/apt/sources.list and save it to this directory/var/lib/apt/lists7, APT works

Ubuntu uses a centralized software repository mechanism to store various software packages in a software repository for effective organization and management. The software repository is then placed on a large number of mirror servers and kept largely consistent. This way, all Ubuntu users will always have access to the latest version of the installation package. Thus, for users, these mirror servers are their software Repositity. However, because each user is in a different network environment, it is impossible to access mirror sites at will. To enable selective access, on Ubuntu systems, use the software source configuration file/etc/apt/sources.list to list the most appropriate mirror site addresses to access.

The apt-get update process:

Apt-Get Update

The requested URL/etc/apt/sources/was not found on this server.

Automatic networking to find the corresponding Packages/Sources/Release list file in the list, download it if there are updates, and store it in/var/lib/apt/lists/directory

apt-get install The appropriate package, download and install.

Even so, the software source configuration file simply tells Ubuntu which mirror sites it can access, but it is not clear what software resources those mirror sites have. It is inefficient to search the server for every package installed. Therefore, it is necessary to make an inventory (index file) of these software resources for local hosts to query.

apt-get install Store downloaded software in/var/cache/apt/archives/.

APT is also able to check package dependencies in Ubuntu Linux systems, greatly simplifying the process of installing and uninstalling packages for Ubuntu users.

apt-get install principle: deb http://cn.archive.ubuntu.com/ubuntu/ precisely main restricted

Can be found through browser

apt-get reads this file each time to get information about the package. Get all package information from Packages.gz. Packages.gz contains information such as:

package name, priority, type, maintainer, schema, source, version number, dependent package, conflict information, package size, file download path, MD5sum, SHA1, package description, Xul-Appid-application id, Bugs information, Origin, Supported

An example of package information in Packages:

Package: abrowser Priority: optional Section: web Installed-Size: 153 Maintainer: Ubuntu Mozilla Team Architecture: amd64 Source: firefox Version: 11.0+build1-0ubuntu4 Depends: firefox (>= 9.0) Filename: pool/main/f/firefox/abrowser_11.0+build1-0ubuntu4_amd64.deb Size: 8940 MD5sum: e8781af38a6de76126d190fc10a14bf2 SHA1: 408abd5f960d4b02bc18581df348954eb7620772 SHA256: cdfad0e4435c035b3115bdec08d79ccfc68bf9480e89df9270b3b6befa348699 Description: Safe and easy web browser from Mozilla-transitional package Description-md5: e89058e4775 caf7d26313 fa8811675e Bugs: https://bugs.launchpad.net/ubuntu/+filebug Origin: Ubuntu Supported: 18m above is "Linux common command apt-get how to use" All the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to 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