3

Here is the situation: say, at 17:00, I installed a lot of packages, I can see them in the ubuntu software center history. Also I can see them in the dpkg log file using the method provided by this thread. My question is: how can I delete them easily. There are so many, I can't delete them one by one in synaptic.

The thread I linded may have explain the method. However, I can't see the time specified in the command, for I don't want delete any other packages installed at other time.

3 Answers3

3

Try this command,

awk '$1~/yyyy-mm-dd/ && $2~/hh:mm:ss/ && $3~/install/ { print $4}' /var/log/dpkg.log | xargs -I{} sudo apt-get -y remove {}

Example:

awk '$1~/2014-04-17/ && $2~/15:55:03/ && $3~/install/ { print $4}' /var/log/dpkg.log | xargs -I{} sudo apt-get -y remove {}

The above command will remove all the packages which are installed on 2014-04-17 at the time 15:55:03.

Avinash Raj
  • 80,446
2

/var/log/dpkg.log lists all install commands with time stamps, just do a grep. Also, /var/log/apt/history.log lists all apt-get activity, including packages installed or removed in one go.

Jos
  • 30,529
  • 8
  • 89
  • 96
0

If you installed that through apt, you can use /var/log/apt/history.log. It's structure is as such:

Start Date: YYYY-MM-DD HH:MM:SS
Commandline: apt-get install package1 package2 package3 . . .
Install: library1 libary2 package1 package2
End-Date: YYYY-MM-DD HH:MM:SS

Knowing that we can use awk to search for particular date and time, descend one line bellow that, get rid of apt-get install line, leaving only the list of packages. For instance, here's a sample command:

awk -F':' '/2015-06-05 16:02:43/ {getline; gsub("apt-get install",""); print $2}' /var/log/apt/history.log

You can add pipe to xargs apt-get remove to remove those packages.

awk -F':' '/2015-06-05 16:02:43/ {getline; gsub("apt-get install",""); print $2}' /var/log/apt/history.log | xargs apt-get remove