如何查看我手动执行的
对我来说,所有可用的方法似乎都显示了从Ubuntu安装开始就安装的所有内容。
如何查看自从我的系统安装过程完成以来的
apt-get install
命令的历史记录?对我来说,所有可用的方法似乎都显示了从Ubuntu安装开始就安装的所有内容。
如何查看自从我的系统安装过程完成以来的
apt-get install
的历史记录?apt-get install
命令的历史记录?apt-get install
的历史记录?zcat /var/log/apt/history.log.*.gz | cat - /var/log/apt/history.log | grep -Po '^Commandline:(?=.* install ) \K.*' | sed '1,4d'
:grep -Po '^Commandline:(?=.* install ) \K.*'
将仅过滤包含带有前导和尾随空格的“install”的apt-get命令,sed '1,4d'
可能依赖于特定的安装;在我的安装中,“1,4”删除了来自Ubiquity的确切条目数,这些是您要删除的内容。如果您的安装中数字相同,请告诉我,这样至少我们就有了一个基准 :| - kosapt-get -o APT::Status-Fd=4 -o APT::Keep-Fds::=5 -o APT::Keep-Fds::=6 -q -y --no-remove install linux-generic
这个新命令。它们是Ubiquity的行吗? - Arronicalaptdaemon
的条目也会被该命令显示出来),没有办法区分用户运行的命令和某个apt-get
前端运行的命令。不过最好的办法还是使用那个命令,至少可以排除掉Ubiquity的条目。 - koszcat /var/log/apt/history.log.*.gz | cat - /var/log/apt/history.log | grep -Po '^Commandline:(?=.* install ) \K.*' | sed -n '1,4p'
输出的内容是否类似于这个?(前两个条目没有换行,但它们非常庞大)。 - kosapt install
进行安装,或者在单词之间使用多个空格。 - Pablo Bianchigrep " install " /var/log/dpkg.log
zcat -qf
来同时查看txt和txt gzipped文件。zcat /var/log/apt/history.log.*.gz | cat - /var/log/apt/history.log | grep " install "
zcat -qf /var/log/apt/history.log* | grep " install "
-q --quiet
Suppress all warnings.
-f --force
Force compression or decompression even if the file has multiple links or the corre‐
sponding file already exists, or if the compressed data is read from or written to a
terminal. If the input data is not in a format recognized by gzip, and if the option
--stdout is also given, copy the input data without change to the standard output: let
zcat behave as cat. If -f is not given, and when not running in the background, gzip
prompts to verify whether an existing file should be overwritten.
#!/bin/sh
NumDaysAgo=18
find /var/lib/dpkg/info -name "*.list" -mtime -$NumDaysAgo \
-exec stat -c $'%y\t%n' {} \; | \
sed -e 's,/var/lib/dpkg/info/,,' -e 's,\.list,,' | \
sort -r | \
while read Date Time Xxx Pkg
do
lncnt=$(apt-cache --installed rdepends $Pkg | wc -l)
if [ $lncnt -eq "2" ]
then echo "$Date $Time $Pkg"
fi
done
echo "JOB COMPLETED: $BASH_SOURCE"
/var/lib/dpkg/info/
下的文件名,将所有已安装的包收集到一个列表中。文件的修改时间即为安装时间。
- 该列表按照反向顺序进行排序。
- 对于每个已安装的包$Pkg
,调用apt-cache rdepends $Pkg
来请求$Pkg
的反向依赖关系。如果没有依赖关系,则它是一个顶级包,将打印出包的信息:日期 时间 包名。apt-cache rdepends $Pkg
的输出格式,该格式是为人类眼睛设计的,并且在未来的apt版本中可能会发生变化。apt-cache rdepends ...
非常慢,可能是因为每次调用都需要通过迭代所有依赖项来计算。因此,上述脚本从最新的安装开始,以尽可能提供用户所需的即时满足感。apt-cache
之后的--installed
标志检查了dpkg安装的软件包是否也是apt安装的。如果用户或其他安装软件绕过apt直接使用dpkg,这是可能的。尽管这种情况尚未经过测试,但我认为在标准输出或错误输出中会打印出一些明显的信息。/home
目录恢复的Linux的基础,其中包括了这些第三方软件,则此输出是合适的。apt-get install
命令的历史记录,请使用以下命令:grep "apt-get install" .bash_history
输出:
ravan@ravan:~$ grep "apt-get install" .bash_history
sudo apt-get install --no-install-recommends ubuntu-mate-core ubuntu-mate-desktop
sudo apt-get install xfce4
sudo apt-get install xfce4.12
sudo apt-get install pgadmin
sudo apt-get install touchegg
sudo apt-get install aptitude
sudo apt-get install aptitude
sudo gedit .bash_history | grep "apt-get install"
sudo apt-get installvim
grep "apt-get install" .bash_history
cat .bash_history | grep "apt-get install"
有关其他信息,请参考额外信息。
在/var/log/apt/
目录下,还有更详细的安装信息,包括history.log
和history.log.X.gz
文件以及term.log
和term.log.X.gz
文件。
如果您只想获取包含apt-get
命令的历史记录,请执行以下操作:
history | grep apt-get
apt-mark showmanual
显示了在操作系统安装时安装的所有软件包,而不仅仅是那些实际上是手动安装的。这种行为方式确实有些奇怪! - Arronical/var/log/apt/history.log
和类似的文件。你只能得到手动选择和自动选择的软件包列表。从这个答案中,你无法获得任何关于安装、卸载、升级等方面的时间顺序历史记录。 - Thomas Wardapt-mark showmanual
的man页在哪里?我在Ubuntu 16.04 LTS的apt
man页上找不到它:http://manpages.ubuntu.com/manpages/xenial/zh_CN/man8/apt.8.html. - Craig Hickssudo apt-get install [package]
history | grep "apt-get install"
.bash_history
文件中带有apt-get install
的条目,或者删除了该文件,否则该命令将显示您在用户账户上执行包含字符串apt-get install
的命令的所有实例(即使您以root身份运行命令,因此不完全是作为用户账户运行命令 - 即使用sudo
运行命令)。 - user364819.bash_history
文件中有200个命令的限制,而且在我的系统上肯定没有这样的限制。你能否请你澄清一下你的意思。 - user364819history
命令默认显示的命令数量,但我可能是自己想象的!现在查看一下... - Arronicalhistory
显示了由$HISTSIZE
环境变量指定的命令数量,这些命令来自您的.bash_history
文件。在14.04服务器安装中,默认情况下似乎设置为1000。@Rinzwind,感谢你让我检查一下! - Arronicalzcat -qf /var/log/apt/history.log* | grep -Po '^Commandline: apt-get.*install (?!.*--reinstall)\K.*'
alias apted='zcat /var/log/apt/history.log.*.gz | cat - /var/log/apt/history.log | fgrep Commandline: | cut -d " " -f 2- | grep -P "^|install"'
dpkg
的日志记录在/var/log/dpkg.log*
中。 - Velkanhistory | grep "apt-get install"
。 - user364819apt-get install
命令安装软件包的实例的方法,我提供了一个解决方案,除非历史文件以某种方式被修改(例如:条目被删除),否则可以提供这些信息。 - user364819