0

Suppose I have the history looks like this:

Start-Date: 2016-09-20  15:49:21
Commandline: apt-get install kchmviewer
Install: libkde3support4:amd64 (4.14.2-5+deb8u1, automatic), libresid-builder0c2a:amd64 (2.1.1-14, automatic), ntrack-module-libnl-0:amd64 (016-1.3, automatic), libmpeg2-4:amd64 (0.5.1-7, automatic), libwinpr-thread0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libkrosscore4:amd64 (4.14.2-5+deb8u1, automatic), libgpgme++2:amd64 (4.14.2-2+b1, automatic), oxygen-icon-theme:amd64 (4.14.0-1, automatic), libktexteditor4:amd64 (4.14.2-5+deb8u1, automatic), kdelibs5-data:amd64 (4.14.2-5+deb8u1, automatic), libchm1:amd64 (0.40a-3+b1, automatic), kchmviewer:amd64 (6.0-1), libcrystalhd3:amd64 (0.0~git20110715.fdd2f19-11, automatic), libdc1394-22:amd64 (2.2.3-1, automatic), libkdeui5:amd64 (4.14.2-5+deb8u1, automatic), libkdeclarative5:amd64 (4.14.2-5+deb8u1, automatic), libfam0:amd64 (2.7.0-17.1, automatic), libthreadweaver4:amd64 (4.14.2-5+deb8u1, automatic), libfreerdp-client1.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libwinpr-utils0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libqt4-sql-mysql:amd64 (4.8.6+git64-g5dc8b2b+dfsg-3+deb8u1, automatic), libfreerdp-core1.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), kde-runtime:amd64 (4.14.2-2, automatic), libchromaprint0:amd64 (1.2-1, automatic), libwinpr-synch0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libkparts4:amd64 (4.14.2-5+deb8u1, automatic), nepomuk-core-data:amd64 (4.14.0-1, automatic), libqt4-sql:amd64 (4.8.6+git64-g5dc8b2b+dfsg-3+deb8u1, automatic), libexiv2-13:amd64 (0.24-4.1, automatic), libqca2:amd64 (2.0.3-6, automatic), libntrack0:amd64 (016-1.3, automatic), upower:amd64 (0.99.1-3.2, automatic), kde-runtime-data:amd64 (4.14.2-2, automatic), libphonon4:amd64 (4.8.0-4, automatic), libwinpr-pool0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libkemoticons4:amd64 (4.14.2-5+deb8u1, automatic), vlc-plugin-notify:amd64 (2.2.4-1~deb8u1, automatic), libnepomukquery4a:amd64 (4.14.2-5+deb8u1, automatic), libkmediaplayer4:amd64 (4.14.2-5+deb8u1, automatic), libwinpr-handle0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libwinpr-crt0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libvlccore8:amd64 (2.2.4-1~deb8u1, automatic), libqt4-qt3support:amd64 (4.8.6+git64-g5dc8b2b+dfsg-3+deb8u1, automatic), libdvbpsi9:amd64 (1.2.0-1, automatic), libfreerdp-cache1.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libwinpr-interlocked0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), katepart:amd64 (4.14.2-2, automatic), libproxy-tools:amd64 (0.4.11-4+b2, automatic), vlc-nox:amd64 (2.2.4-1~deb8u1, automatic), libkdnssd4:amd64 (4.14.2-5+deb8u1, automatic), soprano-daemon:amd64 (2.9.4+dfsg-1.1, automatic), libupnp6:amd64 (1.6.19+git20141001-1, automatic), phonon:amd64 (4.8.0-4, automatic), libsoprano4:amd64 (2.9.4+dfsg-1.1, automatic), libdbusmenu-qt2:amd64 (0.9.2-1, automatic), libkatepartinterfaces4:amd64 (4.14.2-2, automatic), vlc-plugin-samba:amd64 (2.2.4-1~deb8u1, automatic), libusageenvironment1:amd64 (2014.01.13-1, automatic), kdelibs5-plugins:amd64 (4.14.2-5+deb8u1, automatic), libqt4-script:amd64 (4.8.6+git64-g5dc8b2b+dfsg-3+deb8u1, automatic), libebml4:amd64 (1.3.0-2+deb8u1, automatic), libxcb-xv0:amd64 (1.10-3+b1, automatic), libkjsapi4:amd64 (4.14.2-5+deb8u1, automatic), libcddb2:amd64 (1.3.2-5, automatic), libbasicusageenvironment0:amd64 (2014.01.13-1, automatic), libkactivities6:amd64 (4.13.3-1, automatic), libfreerdp-codec1.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libwinpr-input0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libgroupsock1:amd64 (2014.01.13-1, automatic), libiso9660-8:amd64 (0.83-4.2, automatic), libfreerdp-gdi1.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libwinpr-heap0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libwinpr-rpc0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), vlc-data:amd64 (2.2.4-1~deb8u1, automatic), libwinpr-library0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libknewstuff3-4:amd64 (4.14.2-5+deb8u1, automatic), libnepomukutils4:amd64 (4.14.2-5+deb8u1, automatic), libfreerdp-locale1.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libfreerdp-primitives1.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), kdoctools:amd64 (4.14.2-5+deb8u1, automatic), libgles2-mesa:amd64 (10.3.2-1+deb8u1, automatic), libkxmlrpcclient4:amd64 (4.14.2-2+b1, automatic), libkpty4:amd64 (4.14.2-5+deb8u1, automatic), libkjsembed4:amd64 (4.14.2-5+deb8u1, automatic), libwinpr-registry0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libqt4-designer:amd64 (4.8.6+git64-g5dc8b2b+dfsg-3+deb8u1, automatic), libsolid4:amd64 (4.14.2-5+deb8u1, automatic), libkhtml5:amd64 (4.14.2-5+deb8u1, automatic), libssh-gcrypt-4:amd64 (0.6.3-4+deb8u2, automatic), libntrack-qt4-1:amd64 (016-1.3, automatic), libtwolame0:amd64 (0.3.13-1.1, automatic), libkfile4:amd64 (4.14.2-5+deb8u1, automatic), libwinpr-sspi0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), phonon-backend-vlc:amd64 (0.8.0-2, automatic), libzvbi0:amd64 (0.2.35-3, automatic), mysql-common:amd64 (5.5.52-0+deb8u1, automatic), libgles1-mesa:amd64 (10.3.2-1+deb8u1, automatic), libattica0.4:amd64 (0.4.2-1, automatic), libkdesu5:amd64 (4.14.2-5+deb8u1, automatic), libmysqlclient18:amd64 (5.5.52-0+deb8u1, automatic), libdlrestrictions1:amd64 (0.15.15, automatic), libstreams0:amd64 (0.7.8-1.2+b2, automatic), libknotifyconfig4:amd64 (4.14.2-5+deb8u1, automatic), libfreerdp-rail1.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libxcb-composite0:amd64 (1.10-3+b1, automatic), libfreerdp-common1.1.0:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libkdecore5:amd64 (4.14.2-5+deb8u1, automatic), kdelibs-bin:amd64 (4.14.2-5+deb8u1, automatic), libfreerdp-crypto1.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libkactivities-bin:amd64 (4.13.3-1, automatic), libva-x11-1:amd64 (1.4.1-1, automatic), plasma-scriptengine-javascript:amd64 (4.14.2-2, automatic), libnepomukcore4:amd64 (4.14.0-1+b2, automatic), libshine3:amd64 (3.1.0-2.1, automatic), libnepomuk4:amd64 (4.14.2-5+deb8u1, automatic), libwinpr-path0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libzvbi-common:amd64 (0.2.35-3, automatic), libwinpr-dsparse0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), vlc:amd64 (2.2.4-1~deb8u1, automatic), libstreamanalyzer0:amd64 (0.7.8-1.2+b2, automatic), libvlc5:amd64 (2.2.4-1~deb8u1, automatic), libmodplug1:amd64 (0.8.8.4-4.1+b1, automatic), docbook-xsl:amd64 (1.78.1+dfsg-1, automatic), libmatroska6:amd64 (1.4.1-2+deb8u1, automatic), libkntlm4:amd64 (4.14.2-5+deb8u1, automatic), libkdewebkit5:amd64 (4.14.2-5+deb8u1, automatic), liblivemedia23:amd64 (2014.01.13-1, automatic), libvcdinfo0:amd64 (0.7.24+dfsg-0.2, automatic), libiodbc2:amd64 (3.52.9-2, automatic), libwinpr-sysinfo0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libkcmutils4:amd64 (4.14.2-5+deb8u1, automatic), libpolkit-qt-1-1:amd64 (0.103.0-1, automatic), libsidplay2:amd64 (2.1.1-14, automatic), libwinpr-environment0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libva-drm1:amd64 (1.4.1-1, automatic), libkactivities-models1:amd64 (4.13.3-1, automatic), libnl-route-3-200:amd64 (3.2.24-2, automatic), libkate1:amd64 (0.4.1-4, automatic), libkio5:amd64 (4.14.2-5+deb8u1, automatic), libxml2-utils:amd64 (2.9.1+dfsg1-5+deb8u3, automatic), kate-data:amd64 (4.14.2-2, automatic), libfreerdp-utils1.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libvncclient0:amd64 (0.9.9+dfsg2-6.1+deb8u1, automatic), vlc-plugin-pulse:amd64 (2.2.4-1~deb8u1, automatic), libplasma3:amd64 (4.14.2-5+deb8u1, automatic), libupower-glib3:amd64 (0.99.1-3.2, automatic), libwinpr-file0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libqt4-declarative:amd64 (4.8.6+git64-g5dc8b2b+dfsg-3+deb8u1, automatic), libwinpr-crypto0.1:amd64 (1.1.0~git20140921.1.440916e+dfsg1-4, automatic), libmpcdec6:amd64 (0.1~r459-4.1, automatic)
End-Date: 2016-09-20  15:50:34

There are a lot of packages listed, but the package names are not libkde3support4:amd64 (4.14.2-5+deb8u1, automatic) for example, instead it is libkde3support4. So how can I easily remove all these packages in one command?

I am using lxde and debian.

Using apt-get remove kchmviewer && apt-get autoremove only removes two packages:

Start-Date: 2016-09-20  15:51:15
Commandline: apt-get remove kchmviewer
Remove: kchmviewer:amd64 (6.0-1)
End-Date: 2016-09-20  15:51:18

Start-Date: 2016-09-20  15:51:32
Commandline: apt-get autoremove
Remove: libchm1:amd64 (0.40a-3+b1)
End-Date: 2016-09-20  15:51:33
  • Somebody may test this on his own machine to see if this is an exception for me... I am using the lxde. – an offer can't refuse Sep 20 '16 at 8:13
2

In theory, you should be able to "undo" this installation by removing kchmviewer and all automatically installed packages:

apt-get remove kchmviewer && apt-get autoremove

but pay attention to the packages removed by the second command. Auto-removal may not produce the results you're after though: by default, if an auto-installed package is recommended by any other installed package, this command won't remove it. (See Why did 'apt-get autoremove' not work properly? for details.)

If you want to process the log instead, you can use this sed command to turn the "Install:" line into a list of packages you can use with apt-get remove (along with `apt-get remove kchmviewer):

sed 's/([^)]*)//g;s/Install: //;s/ ,//g'

Taking your log in a file named log (with only the lines given in your question):

apt-get remove kchmviewer $(grep Install: log | sed 's/([^)]*)//g;s/Install: //;s/ ,//g')
| improve this answer | |
  • You can test that you can't remove by your first code line.. – an offer can't refuse Sep 20 '16 at 7:28
  • means that the remove is not clean. there are a lot of packages left. – an offer can't refuse Sep 20 '16 at 7:32
  • That means: when install kchmviewer, I have taken as much as 200M space, when remove, it just free a few kb disk space, even I used the pure and autoremove – an offer can't refuse Sep 20 '16 at 7:37
  • 1
    --purge only affects configuration files, not package relationships. You'll need to use the second variant in my answer to fully reverse your installation (no doubt because of package recommendations; and if you try apt-get --no-install-recommends autoremove you'll probably remove more packages than you'd want). – Stephen Kitt Sep 20 '16 at 7:56
  • 1
    I didn't. After I put this, it works like a charm! thanks you very much, but your code is too complicated, if you can explain it a little bit, people will benefit more from it. – an offer can't refuse Sep 20 '16 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.