简体   繁体   English

如何在终端 (Ubuntu) 中查看所有已安装的软件包

[英]How to view all installed packages in terminal (Ubuntu)

Need to view all the packages installed on my system through terminal.需要通过终端查看我系统上安装的所有软件包。 I am using ubuntu 16.10我正在使用 ubuntu 16.10

# dpkg -l

From dpkg manual:来自 dpkg 手册:

dpkg-query actions See dpkg-query(1) for more information about the following actions. dpkg-query 操作 有关以下操作的详细信息,请参阅 dpkg-query(1)。

 -l, --list package-name-pattern... List packages matching given pattern. -s, --status package-name... Report status of specified package. -L, --listfiles package-name... List files installed to your system from package-name. -S, --search filename-search-pattern... Search for a filename from installed packages. -p, --print-avail package-name... Display details about package-name, as found in /var/lib/dpkg/available. Users of APT-based frontends should use apt-cache show package-name instead.

列出仅由您安装的软件包:

gunzip -c /var/log/apt/history.log.*.gz | grep 'apt-get install' | cut -f4- -d" " | tr ' ' $'\n' | sort -u

Solution: In order to view all installed packages in linux Ubuntu, run on terminal apt --installed list ,解决方案:为了查看 linux Ubuntu 中所有已安装的包,在终端apt --installed list上运行,

Use apt flags and would be able to see available upgrades to some packages ( --upgradeable ) / current installed packages ( --installed ) / all available versions ( --all-versions ).使用 apt 标志,将能够看到某些软件包( --upgradeable )/当前安装的软件包( --installed )/所有可用版本( --all-versions )的可用升级。

From Documentation :文档

DESCRIPTION
       apt provides a high-level commandline interface for the package management system. 
       It is intended as an end user interface and enables some options better suited for interactive usage by
       default compared to more specialized APT tools like apt-get(8) and apt-cache(8).

       Much like apt itself, its manpage is intended as an end user interface and as such only mentions the most 
      used commands and options partly to not duplicate information in multiple places and
       partly to avoid overwhelming readers with a cornucopia of options and details.           

the list flag offers 3 options: list标志提供 3 个选项:

list (work-in-progress)
           list is somewhat similar to dpkg-query --list in that it can display a 
           list of packages satisfying certain criteria. It supports glob(7) 
           patterns for matching package names as well as
           options to list installed (--installed), upgradeable (--upgradeable) or 
           all available (--all-versions) versions.

I used the following Three Cmd Syntaxes & tested them to List installed packages on My ubuntu Subsystem machine from VB6 Shell() function and 2 of them Worked fine:我使用了以下三个 Cmd 语法并测试了它们以从 VB6 Shell() 函数列出我的 ubuntu 子系统机器上已安装的软件包,其中 2 个工作正常:

1- Syntax-#1:[ Worked ] 1-语法-#1:[工作]

sudo apt list --installed sudo apt list --installed

2- Syntax-#2:[ Worked ] 2-语法-#2:[工作]

sudo dpkg -l须藤 dpkg -l

Syntax-#3: [ Do not Worked .. for me ]语法-#3:[ 对我不起作用 .. ]

sudo dpkg -l |须藤 dpkg -l | grep -i apache grep -i 阿帕奇

And Here is MY VB6 - Code List:这是我的 VB6 - 代码列表:

Private Sub Command1_Click() Private Sub Command1_Click()

Dim Id3 As Variant ' 1- Syntax-#1: Worked fine: Id3 = Shell(App.Path & "\\bash.exe | sudo apt list --installed", vbNormalFocus) Dim Id3 As Variant ' 1- Syntax-#1:工作正常:Id3 = Shell(App.Path & "\\bash.exe | sudo apt list --installed", vbNormalFocus)

' 2- Syntax-#2: Worked Also: ' Id3 = Shell(App.Path & "\\bash.exe | sudo dpkg -l", vbNormalFocus) ' 2- 语法-#2:也适用:' Id3 = Shell(App.Path & "\\bash.exe | sudo dpkg -l", vbNormalFocus)

' 3- Syntax-#3: Does not show output ... Why .. Dont know now: ' ' 3- 语法-#3:不显示输出......为什么......现在不知道:'
Id3 = Shell(App.Path & "\\bash.exe | sudo dpkg -l | grep -i apache", vbNormalFocus) End Sub** Id3 = Shell(App.Path & "\\bash.exe | sudo dpkg -l | grep -i apache", vbNormalFocus) End Sub**

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM