{"id":5156,"date":"2022-07-30T04:14:41","date_gmt":"2022-07-29T22:44:41","guid":{"rendered":"https:\/\/www.suramya.com\/blog\/?p=5156"},"modified":"2022-07-30T04:14:41","modified_gmt":"2022-07-29T22:44:41","slug":"identifying-the-least-used-packages-on-debian","status":"publish","type":"post","link":"https:\/\/www.suramya.com\/blog\/2022\/07\/identifying-the-least-used-packages-on-debian\/","title":{"rendered":"Identifying the least used packages on Debian"},"content":{"rendered":"<p>My main system was running low on disk space in the root partition and I wanted to clean out some of the unused software from the system. In order to do that I thought that I should find out what the least used applications on my system were and then remove them. Unfortunately I couldn&#8217;t find any existing way of doing this so it was a dead end. However, the problem remained stuck in my head and I came up with a quick and dirty way of identifying the packages and when they were last used. <\/p>\n<p>The way it works is:<\/p>\n<ul>\n<li>Get a list of all files on the system (using locate, since its already there so why duplicate effort)<\/li>\n<li>For each file figure out what package it belongs to using dpkg-query -S<\/li>\n<li>If the file belongs to a package, get the last access time (using stat) and log it<\/li>\n<li>Once we do this for all files, sort the results.<\/li>\n<\/ul>\n<p>This gives us a list of packages and the latest access date for each package (based on the latest access date for any of the files in it). Since this is a quick and dirty implementation, it is slow as molasses, doesn&#8217;t have any error checking or anything but still gets the job done. Would love to get some feedback. The code is available at: <a href=\"https:\/\/github.com\/suramyatomar\/leastUsedPackage\">https:\/\/github.com\/suramyatomar\/leastUsedPackage<\/a>.<\/p>\n<p>The output of the script looks like:<\/p>\n<pre class='code'>\r\n...\r\n...\r\nxz-utils | 2022-07-18\r\nyelp-xsl | 2022-04-05\r\nyelp-xsl | 2022-04-05\r\nyoutube-dl | 2022-07-17\r\nzim | 2022-07-17\r\nzip | 2022-07-17\r\nzlib1g-dev | 2022-07-17\r\nzlib1g-dev | 2022-07-17\r\nzlib1g-dev | 2022-07-17\r\nzstd | 2022-07-18\r\n<\/pre>\n<p>Feel free to try it out if you have a similar usecase. Let me know if you have any suggestions on improving the script or if you found it useful. <\/p>\n<p>&#8211; Suramya<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My main system was running low on disk space in the root partition and I wanted to clean out some of the unused software from the system. In order to do that I thought that I should find out what the least used applications on my system were and then remove them. Unfortunately I couldn&#8217;t [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[18,9,13,8],"tags":[],"class_list":["post-5156","post","type-post","status-publish","format-standard","hentry","category-computer-software","category-computer-hintstips","category-linuxunix-related","category-software-releases"],"_links":{"self":[{"href":"https:\/\/www.suramya.com\/blog\/wp-json\/wp\/v2\/posts\/5156","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.suramya.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.suramya.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.suramya.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.suramya.com\/blog\/wp-json\/wp\/v2\/comments?post=5156"}],"version-history":[{"count":2,"href":"https:\/\/www.suramya.com\/blog\/wp-json\/wp\/v2\/posts\/5156\/revisions"}],"predecessor-version":[{"id":5158,"href":"https:\/\/www.suramya.com\/blog\/wp-json\/wp\/v2\/posts\/5156\/revisions\/5158"}],"wp:attachment":[{"href":"https:\/\/www.suramya.com\/blog\/wp-json\/wp\/v2\/media?parent=5156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.suramya.com\/blog\/wp-json\/wp\/v2\/categories?post=5156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.suramya.com\/blog\/wp-json\/wp\/v2\/tags?post=5156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}