如何在Linux里寻找、安装和卸载软件包How to install and update software in Linux

一、debian():APT

常用命令

apt

install

remove

list

search

show

mikeli@mikeli-DELL:~$ apt
apt 2.7.14 (amd64)
Usage: apt [options] command

apt is a commandline package manager and provides commands for
searching and managing as well as querying information about packages.
It provides the same functionality as the specialized APT tools,
like apt-get and apt-cache, but enables options more suitable for
interactive use by default.

Most used commands:
  list - list packages based on package names
  search - search in package descriptions
  show - show package details
  install - install packages
  reinstall - reinstall packages
  remove - remove packages
  autoremove - automatically remove all unused packages
  update - update list of available packages
  upgrade - upgrade the system by installing/upgrading packages
  full-upgrade - upgrade the system by removing/installing/upgrading packages
  edit-sources - edit the source information file
  satisfy - satisfy dependency strings

See apt(8) for more information about the available commands.
Configuration options and syntax is detailed in apt.conf(5).
Information about how to configure sources can be found in sources.list(5).
Package and version choices can be expressed via apt_preferences(5).
Security details are available in apt-secure(8).
                                        This APT has Super Cow Powers.

 

 

 

 

mikeli@mikeli-DELL:~$ sudo apt install git

 

mikeli@mikeli-DELL:~$ sudo apt install git
[sudo] password for mikeli: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  git-man liberror-perl
Suggested packages:
  git-daemon-run | git-daemon-sysvinit git-doc git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
  git git-man liberror-perl
0 upgraded, 3 newly installed, 0 to remove and 10 not upgraded.
Need to get 4,804 kB of archives.
After this operation, 24.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu noble/main amd64 liberror-perl all 0.17029-2 [25.6 kB]
Get:2 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 git-man all 1:2.43.0-1ubuntu7.2 [1,100 kB]
Get:3 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 git amd64 1:2.43.0-1ubuntu7.2 [3,679 kB]
Fetched 4,804 kB in 7s (705 kB/s)                                                                                              
Selecting previously unselected package liberror-perl.
(Reading database ... 198502 files and directories currently installed.)
Preparing to unpack .../liberror-perl_0.17029-2_all.deb ...
Unpacking liberror-perl (0.17029-2) ...
Selecting previously unselected package git-man.
Preparing to unpack .../git-man_1%3a2.43.0-1ubuntu7.2_all.deb ...
Unpacking git-man (1:2.43.0-1ubuntu7.2) ...
Selecting previously unselected package git.
Preparing to unpack .../git_1%3a2.43.0-1ubuntu7.2_amd64.deb ...
Unpacking git (1:2.43.0-1ubuntu7.2) ...
Setting up liberror-perl (0.17029-2) ...
Setting up git-man (1:2.43.0-1ubuntu7.2) ...
Setting up git (1:2.43.0-1ubuntu7.2) ...
Processing triggers for man-db (2.12.0-4build2) ...

 

mikeli@mikeli-DELL:~$ sudo apt remove git

remove auto-remove purge

 

Remove Openjdk only:

$ sudo apt remove openjdk*

Remove Openjdk along with dependencies:

$ sudo apt remove --auto-remove openjdk*

Remove Openjdk and it’s configuration files:

$ sudo apt purge openjdk*

Remove Openjdk along with dependencies and it’s configuration files:

$ sudo apt purge --auto-remove openjdk*

 

mikeli@mikeli-DELL:~/software/netbeans_new/nbbuild/netbeans/bin$ apt list --installed | grep jdk

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

openjdk-8-jdk-headless/noble-updates,noble-security,now 8u442-b06~us1-0ubuntu1~24.04 amd64 [installed,automatic]
openjdk-8-jdk/noble-updates,noble-security,now 8u442-b06~us1-0ubuntu1~24.04 amd64 [installed]
openjdk-8-jre-headless/noble-updates,noble-security,now 8u442-b06~us1-0ubuntu1~24.04 amd64 [installed,automatic]
openjdk-8-jre/noble-updates,noble-security,now 8u442-b06~us1-0ubuntu1~24.04 amd64 [installed,automatic]

 

 

 

mikeli@mikeli-DELL:~$ apt search openjdk-8-jdk
Sorting... Done
Full Text Search... Done
openjdk-8-jdk/noble-updates,noble-security 8u442-b06~us1-0ubuntu1~24.04 amd64
  OpenJDK Development Kit (JDK)

openjdk-8-jdk-headless/noble-updates,noble-security,now 8u442-b06~us1-0ubuntu1~24.04 amd64 [installed]
  OpenJDK Development Kit (JDK) (headless)

mikeli@mikeli-DELL:~$ apt search openjdk-8-jdk
Sorting... Done
Full Text Search... Done
openjdk-8-jdk/noble-updates,noble-security 8u442-b06~us1-0ubuntu1~24.04 amd64
  OpenJDK Development Kit (JDK)

openjdk-8-jdk-headless/noble-updates,noble-security,now 8u442-b06~us1-0ubuntu1~24.04 amd64 [installed]
  OpenJDK Development Kit (JDK) (headless)

 

ikeli@mikeli-DELL:~$ apt show openjdk-8-jdk-headless 
Package: openjdk-8-jdk-headless
Version: 8u442-b06~us1-0ubuntu1~24.04
Priority: optional
Section: universe/java
Source: openjdk-8
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Java Maintenance <pkg-java-maintainers@lists.alioth.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 39.8 MB
Provides: java-sdk-headless (= 8), java2-sdk-headless, java5-sdk-headless, java6-sdk-headless, java7-sdk-headless, java8-sdk-headless
Depends: openjdk-8-jre-headless (= 8u442-b06~us1-0ubuntu1~24.04), libc6 (>= 2.34), zlib1g (>= 1:1.1.4)
Suggests: openjdk-8-demo, openjdk-8-source
Breaks: openjdk-8-jre-headless (<< 8u232-b07-1)
Replaces: openjdk-8-jdk (<< 8u72-b15-4), openjdk-8-jre-headless (<< 8u232-b07-1)
Homepage: https://openjdk.org/projects/jdk8u/
Download-Size: 8,838 kB
APT-Manual-Installed: yes
APT-Sources: http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Packages
Description: OpenJDK Development Kit (JDK) (headless)
 OpenJDK is a development environment for building applications,
 applets, and components using the Java programming language.
 .
 This binary package contains almost the full JDK, except for some
 tools (appletviewer, jconsole) and headers (jawt) that make sense
 only in GUI environments.
 .
 The packages are built using the IcedTea build support and patches
 from the IcedTea project.

 

mikeli@mikeli-DELL:~$ sudo apt update
Get:1 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB]
Hit:2 http://archive.ubuntu.com/ubuntu noble InRelease   
Get:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB]
Get:4 http://security.ubuntu.com/ubuntu noble-security/main amd64 Components [8,964 B]
Get:5 http://security.ubuntu.com/ubuntu noble-security/restricted amd64 Components [212 B]
Get:6 http://security.ubuntu.com/ubuntu noble-security/universe amd64 Components [52.2 kB]
Get:7 http://archive.ubuntu.com/ubuntu noble-backports InRelease [126 kB]                      
Get:8 http://security.ubuntu.com/ubuntu noble-security/multiverse amd64 Components [212 B]
Get:9 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages [987 kB]
Get:10 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Components [151 kB]                                           
Get:11 http://archive.ubuntu.com/ubuntu noble-updates/restricted amd64 Components [212 B]                                      
Get:12 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Packages [1,050 kB]                                       
Get:13 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Components [365 kB]                                       
Get:14 http://archive.ubuntu.com/ubuntu noble-updates/multiverse amd64 Components [940 B]                                      
Get:15 http://archive.ubuntu.com/ubuntu noble-backports/main amd64 Components [7,092 B]                                        
Get:16 http://archive.ubuntu.com/ubuntu noble-backports/restricted amd64 Components [216 B]                                    
Get:17 http://archive.ubuntu.com/ubuntu noble-backports/universe amd64 Components [15.8 kB]                                    
Get:18 http://archive.ubuntu.com/ubuntu noble-backports/multiverse amd64 Components [212 B]                                    
Fetched 3,017 kB in 14s (219 kB/s)                                                                                             
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
10 packages can be upgraded. Run 'apt list --upgradable' to see them.

 

update:update software list which can be download

sudo apt update

upgrade:update installed software in this PC.

sudo apt upgrade

together:

sudo apt update -y && sudo apt upgrade -y

next:

sudo apt autoremove

 

 

 

 

二、redhat(centos):YUM

 

 

 

reference:https://www.freecodecamp.org/news/sudo-apt-get-update-vs-upgrade-what-is-the-difference/

 

 

 

===Linux软件包命令汇总===

1.Apt Vs Apt-get [What’s the Difference?]

2.Dpkg Vs Apt [What’s the Difference Between Package Managers]

3.Deb vs Rpm [Whether One is the Best]

4.YUM Vs RPM [Which One is Better]

5.Apt Vs Yum [Difference Between the Package Managers]

 

posted @ 2025-03-23 11:32  MikeLi  阅读(42)  评论(0)    收藏  举报