Installation logs in linux

How to view history of apt-get install?

How can I view the history of apt-get install commands that I have manually executed? It seems to me that all methods available show everything that has been installed right from the start of the Ubuntu installation. How can I view the history of apt-get install since the time my system-installation process had completed?

Well, yes. What else would you expect? Do you want to show only those you ran from the terminal and not those that were run by a GUI or something? Please edit your question and clarify.

@ParanoidPanda That fails in various ways. History truncations, things run in other shells, things removed from history, or never put there in the first place, things installed from scripts, things run by other users etc etc

@MrBones: I know, and I have stated so in my answer (and in the comments below it). However the OP asked for a way to view all the instances when they have manually executed the apt-get install command to install a package, and I have provided a solution which gives this information unless the history file has been altered in certain ways (e.g.: the entries have been removed).

8 Answers 8

I think the answer given here by kos is the best way I’ve seen so far. Though as Software Center uses apt , anything that it has installed would be listed too.

zcat /var/log/apt/history.log.*.gz | cat - /var/log/apt/history.log | grep -Po '^Commandline: apt-get install (. *--reinstall)\K.*' 

Use this, is way more safer for this task: 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.*’ will filter only the apt-get commands containing install with a leading and trailing space, sed ‘1,4d’ might be dependant on the specific installation; in mine 1,4 deletes exactly the number of entries coming from Ubiquity, which are those you want to remove. Let me know if the number is the same on your installation, that way at least we have a baseline 😐

@kos I get extra lines such as apt-get -o APT::Status-Fd=4 -o APT::Keep-Fds::=5 -o APT::Keep-Fds::=6 -q -y —no-remove install linux-generic with the new command. Are they the Ubiquity lines?

No, those look like they came from Software Updater; there’s no way to distinguish from commands run from the user and commands run by some apt-get frontend, aside from Ubiquity which runs only once (for example aptdaemon entries will be showed by that command as well). The best bet though is still to use that command, which at least excludes the Ubiquity entries.

Читайте также:  Локальный репозиторий arch linux

Just type following command in your terminal to view all install logs.

grep " install " /var/log/dpkg.log 

This is even better than the accepted solution since it lists all the packets installed, dependencies included.

To simplify @Arronical answer, A neat trick I learned recently is you can use zcat -qf to cat both txt and txt gzipped files.

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. 

As I comment there are other cases. Maybe the best way is just zcat -qf /var/log/apt/history.log* | grep » install «

Here is script which prints only the currently installed top level packages, where «top level packages» is defined as atp packages upon which no other atp packages depend. If such top level programs were installed by atp or a package manager such as synaptic, then they were manually chosen by the user.

#!/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" 

The packages are printed in reverse order under the assumption that the user is more likely to want the newer info sooner, and because the program is slow.

Program flow:

  • The program first gathers into a list all the installed packages by reading the filenames under /var/lib/dpkg/info/ . The file mod times are the installation times.
  • That list is sorted in reverse order.
  • For each installed package $Pkg , a call to apt-cache rdepends $Pkg requests the reverse-dependencies of $Pkg . If there are no dependencies, then it is a top level package and the package info is printed: date time packagename
  • The script depends upon the output format of apt-cache rdepends $Pkg which was intended for human eyes and could change in the future versions of apt.
  • The code for the part gathering filenames under /var/lib/dpkg/info/ came from this unix.stackexchange post. As that poster ‘mikel’ pointed out, the dpgk history logfiles are not reliable because they will be rotated out after reaching a certain volume.
  • Man page for apt-chache
  • The call apt-cache rdepends . is very slow presumably because each call is computed by iterating through all the dependencies. Hence the above script starts from the newest installs to offer the user as much instant gratification as possible.
  • The —installed flag after apt-cache checks that the dpkg-installed packages are also apt-installed. If the user or another install software bypassed apt and used dpkg directly, it would be possible. THIS CASE HAS NOT BEEN TESTED, but I think something noticeable would be printed in either the standard or error output
  • The output does not include manually chosen packages which later became depended upon by a higher package. The output can also include packages which were installed via apt by other third party install software, and hence are not truly manually installed. However, if the purpose of the output is as a basis for setting up a restored linux from a backup /home directory which included said third party software, then this output would be suitable.
  • Some of the package names include version numbers, and some not. Mentioned just to bring awareness to the fact.
Читайте также:  Зависает установка линукс минт

Источник

Where are the logs for apt-get?

none of the listed logs in the answers are very verbose. I think it would be nice to see something like:» downloading index from blah blah downloading deb blah installing package foo version 1.2.3 from file foo.blah.deb» instead of just lists of packages that were installed.

4 Answers 4

Apt logs can be found in /var/log/apt/term.log . To view them with GEdit you can use the command:

Of course, cat /var/log/apt/term.log will display the file contents just fine. You may also be interested in tail -f /var/log/apt/term.log . This only displays the last few lines (tail) of the file, and, more interestingly, will continually print whatever gets appended to that file. This is quite interesting if you want to «observe» the log.

I like /var/log/apt/history.log . It is very concise.

Also note that older logs are archived with logrotate once a month. To combine the current history.log and all the older compressed history.log files you can use cat and zcat like this:

cd /var/log/apt && cat history.log > ~/Desktop/allhistory.log && zcat history.log*gz >> ~/Desktop/allhistory.log && cd

Then you can, for example, use grep to find what you need:

$ grep package_name ~/Desktop/allhistory.log where you will put what you want in place of package_name .

$ grep google ~/Desktop/allhistory.log Upgrade: google-chrome-stable:amd64 (32.0.1700.102-1, 33.0.1750.117-1) Upgrade: google-chrome-stable:amd64 (31.0.1650.48-1, 32.0.1700.77-1) Upgrade: google-chrome-stable:amd64 (32.0.1700.77-1, 32.0.1700.102-1) Upgrade: google-chrome-stable:amd64 (30.0.1599.101-1, 31.0.1650.48-1) 

And, Bohr, in a comment, suggested using zgrep directly if one is searching for lines related to a specific package. This works for me assuming I’m searching both history.log and its existing archived files for smtube :

zgrep smtube /var/log/apt/history* 

Источник

Читайте также:  Горячие клавиши громкость линукс

Is there an Ubuntu update log?

I’m running Ubuntu and do my regular updates and I wanted to know where can I view a log of what has been changed/updated/fixed with each update.

2 Answers 2

One way would be to obtain a time-stamped list by opening a terminal with Ctrl Alt T and issuing the command more /var/log/dpkg.log This will give you more information than you are currently asking for. You can narrow the results considerably using grep for example this command shows packages installed/upgraded on my system as of todays date:

grep «2017-08-21» /var/log/dpkg.log | grep «status installed»

2017-08-21 11:44:41 status installed man-db:amd64 2.6.7.1-1ubuntu1 2017-08-21 11:44:41 status installed doc-base:all 0.10.5 2017-08-21 11:44:41 status installed install-info:amd64 5.2.0.dfsg.1-2 2017-08-21 11:44:41 status installed desktop-file-utils:amd64 0.22-1ubuntu1.1 2017-08-21 11:44:41 status installed mime-support:all 3.54ubuntu1.1 2017-08-21 11:44:41 status installed gnome-menus:amd64 3.10.1-0ubuntu2 2017-08-21 11:44:42 status installed bamfdaemon:amd64 0.5.1+14.04.20140409-0ubuntu1 2017-08-21 11:44:42 status installed hicolor-icon-theme:all 0.13-1 2017-08-21 11:44:42 status installed libgraphite2-3:amd64 1.3.10-0ubuntu0.14.04.1 2017-08-21 11:44:42 status installed logrotate:amd64 3.8.7-1ubuntu1.2 2017-08-21 11:44:42 status installed augeas-lenses:all 1.2.0-0ubuntu1.3 2017-08-21 11:44:42 status installed cvs:amd64 2:1.12.13+real-12ubuntu0.1 2017-08-21 11:44:42 status installed landscape-client-ui-install:amd64 14.12-0ubuntu6.14.04 2017-08-21 11:44:43 status installed libaugeas0:amd64 1.2.0-0ubuntu1.3 2017-08-21 11:44:43 status installed libc-bin:amd64 2.19-0ubuntu6.13 

If you want to examine the changelog for a specific package that you have installed you can obtain that information with the command sudo apt-get changelog packagename where packagename is the name of the package.

sudo apt-get changelog logrotate will provide the change log for the package logrotate

Источник

Оцените статью
Adblock
detector