Answers:
简洁大方:
sudo dpkg -l | more
要么
sudo dpkg -l | less
如果要获取某些特定软件包的描述,请说firefox
:
sudo dpkg -l | grep firefox
这是我的输出:
$ sudo dpkg -l | more
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-===========================================-=======================================-==============================================================
================
ii accountsservice 0.6.15-2ubuntu9.4 query and manipulate user account information
ii acl 2.2.51-5ubuntu1 Access control list utilities
ii acpi-support 0.140 scripts for handling many ACPI events
ii acpid 1:2.0.10-1ubuntu3 Advanced Configuration and Power Interface event daemon
ii activity-log-manager-common 0.9.4-0ubuntu3.2 blacklist configuration for Zeitgeist (assets)
ii activity-log-manager-control-center 0.9.4-0ubuntu3.2 blacklist configuration for Zeitgeist (control center integrat
ion)
ii adduser 3.113ubuntu2 add and remove users and groups
ii adium-theme-ubuntu 0.3.2-0ubuntu1 Adium message style for Ubuntu
ii aisleriot 1:3.2.3.2-0ubuntu1 Solitaire card games
ii akonadi-backend-mysql 1.7.2-0ubuntu1 MySQL storage backend for Akonadi
ii akonadi-server 1.7.2-0ubuntu1 Akonadi PIM storage service
ii alacarte 0.13.2-2ubuntu4 easy GNOME menu editing tool
ii alsa-base 1.0.25+dfsg-0ubuntu1 ALSA driver configuration files
ii alsa-utils 1.0.25-1ubuntu5 Utilities for configuring and using ALSA
ii anacron 2.3-14ubuntu1 cron-like program that doesn't go by time
ii apg 2.2.3.dfsg.1-2 Automated Password Generator - Standalone version
ii app-install-data 0.12.04.4 Ubuntu applications (data files)
ii app-install-data-partner 12.12.04.1 Application Installer (data files for partner applications/rep
ositories)
ii apparmor 2.7.102-0ubuntu3.7 User-space parser utility for AppArmor
ii appmenu-gtk 0.3.92-0ubuntu1.1 Export GTK menus over DBus
ii appmenu-gtk3 0.3.92-0ubuntu1.1 Export GTK menus over DBus
ii appmenu-qt 0.2.6-0ubuntu1 appmenu support for Qt
ii apport 2.0.1-0ubuntu17.1 automatically generate crash reports for debugging
ii apport-gtk 2.0.1-0ubuntu17.1 GTK+ frontend for the apport crash report system
ii apport-symptoms 0.16.1 symptom scripts for apport
ii apt 0.8.16~exp12ubuntu10.7 commandline package manager
ii apt-transport-https 0.8.16~exp12ubuntu10.7 https download transport for APT
ii apt-utils 0.8.16~exp12ubuntu10.7 package managment related utility programs
--More--
cat /var/log/dpkg.log | grep " install "
要获得特定的包装:
$cat /var/log/dpkg.log | grep " install " | grep banshee
2013-12-12 12:51:48 install banshee <none> 2.4.1-3ubuntu1~precise2
2013-12-12 12:51:51 install banshee-extensions-common <none> 2.4.0-1ubuntu1
2013-12-12 12:51:51 install banshee-extension-radiostationfetcher <none> 2.4.0- 1ubuntu1
2013-12-12 12:51:51 install banshee-extension-soundmenu <none> 2.4.1-3ubuntu1~precise2
$apt-cache show firefox | grep Section
Section: web
apt-cache
,但是是的,您是对的。dpkg --print-avail
如果您想获得足够的信息,将执行相同的工作。您应该注意的一件事是,sudo apt-cache show
命令总会给您一些额外的信息。您可以通过比较这两个命令的输出来验证它。1. sudo apt-cache show firefox | wc
和2. sudo dpkg --print-avail firefox | wc
您会注意到,第一个命令比第二个命令返回更多的行,单词和字符。回复如果你仍然有些疑惑..
现在,获取软件包的安装细节要容易得多。
简单的步骤如下:
将以下脚本复制并粘贴到文件中,并使用任何名称say进行保存pkgdetails
。
#!/bin/bash
#Get the details and section of installed packages
# usage:
# pkgdetails <pkgname1> <pkgname2>
#first append all info from archived logs
i=2
mycount=$(ls -l /var/log/dpkg.log.*.gz | wc -l)
nlogs=$(( $mycount + 1 ))
while [ $i -le $nlogs ]
do
if [ -e /var/log/dpkg.log.$i.gz ]; then
zcat /var/log/dpkg.log.$i.gz | grep "\ install\ " >> $HOME/pkgtmp.txt
fi
i=$(( $i+1 ))
done
#next append all info from unarchived logs
i=1
nulogs=$(ls -l /var/log/dpkg.log.* | wc -l)
nulogs=$(( $nulogs - $nlogs + 1 ))
while [ $i -le $nulogs ]
do
if [ -e /var/log/dpkg.log.$i ]; then
cat /var/log/dpkg.log.$i | grep "\ install\ " >> $HOME/pkgtmp.txt
fi
i=$(( $i+1 ))
done
#next append current log
cat /var/log/dpkg.log | grep "\ install\ " >> $HOME/pkgtmp.txt
#sort text file by date
sort -n $HOME/pkgtmp.txt > $HOME/pkginstalls.txt
rm $HOME/pkgtmp.txt
# Now displaying the installation details of packages passed as arguments
for pkg in $@
do
echo "--------------------- Installation Details of $pkg ----------------------"
echo
cat $HOME/pkginstalls.txt | grep -i $pkg
echo
apt-cache show $pkg | grep "Section" | sort -u
echo
done
exit 0
使文件可执行并复制到/bin
以用作命令。
chmod a+x pkgdetails && sudo cp pkgdetails /bin/
现在使用pkgdetails
命令获取安装详细信息和软件包部分:
pkgdetails qbittorrent artha
这是我的输出:
--------------------- Installation Details of qbittorrent ----------------------
2013-07-24 07:52:27 install qbittorrent <none> 2.9.7-1
2013-07-24 09:11:32 install qbittorrent <none> 3.0.x-0~4366-20130722~precise1
2013-10-19 05:32:27 install qbittorrent <none> 3.0.x-0~4389-20130802~precise1
Section: net
Section: universe/net
--------------------- Installation Details of artha ----------------------
2013-07-11 23:50:16 install artha <none> 1.0.2-1ubuntu1
Section: universe/utils
打开文本编辑器,然后粘贴anyname.sh并使其可执行
chmod +x anyname.sh
代码:
#!/bin/bash
#pkginstalls.sh
#creates text file with a list of all packages installed by date
#first append all info from archived logs
i=2
mycount=$(ls -l /var/log/dpkg.log.*.gz | wc -l)
nlogs=$(( $mycount + 1 ))
while [ $i -le $nlogs ]
do
if [ -e /var/log/dpkg.log.$i.gz ]; then
zcat /var/log/dpkg.log.$i.gz | grep "\ install\ " >> $HOME/pkgtmp.txt
fi
i=$(( $i+1 ))
done
#next append all info from unarchived logs
i=1
nulogs=$(ls -l /var/log/dpkg.log.* | wc -l)
nulogs=$(( $nulogs - $nlogs + 1 ))
while [ $i -le $nulogs ]
do
if [ -e /var/log/dpkg.log.$i ]; then
cat /var/log/dpkg.log.$i | grep "\ install\ " >> $HOME/pkgtmp.txt
fi
i=$(( $i+1 ))
done
#next append current log
cat /var/log/dpkg.log | grep "\ install\ " >> $HOME/pkgtmp.txt
#sort text file by date
sort -n $HOME/pkgtmp.txt > $HOME/pkginstalls.txt
rm $HOME/pkgtmp.txt
exit 0
您还可以使用以下命令列出已安装的软件包:
apt list --installed
手动安装的软件包显示为:
apt list --manual-installed
以及所有带有:
apt list --all-versions
这些是非常有用的命令。例如,如果您要将本地安装的软件包安装到另一台计算机,则只需要
apt list --installed | awk -F/ -v ORS=" " 'NR>1 {print $1}' > apt_packages.txt
或者如果您只想手动安装软件包
apt list --manual-installed | awk -F/ -v ORS=" " 'NR>1 {print $1}' > apt_packages.txt
现在,您所有的apt软件包都可以安装在另一个或新安装的Ubuntu系统上。
sudo apt-get install < apt_packages.txt
如果您想确切地知道何时,什么以及哪些软件包已被删除,则必须查看
/var/log/apt
目录。搜索history.log
文件;使用sed,awk,grep或简单的文本编辑器搜索历史文件。
您必须访问此网站https://help.ubuntu.com/community/AptGet/Howto 您将在这里看到,
apt-cache显示
apt-cache pkgnames
我有一个部分答案(没有足够的代表意见,无法发表评论)-安装日志在这里:
sudo less /var/log/apt/term.log
由于您似乎比我更懂命令行,因此您可以尝试在此处修改脚本以对其进行解析: