Identifying packages by usage for removalAnnotating packages at installation to ease maintenance with apt / aptitude What is the correct way to create your own packages for local installation?how much space does a given package, and dependencies, cost?Running apt-get install updated unrelated packages and is causing issuesWhy do snap-packages exist - is there a real need?apt-get reports no space left on device

Is this really played by 2200+ players?

Translate "loyal animal" into classical Latin

Flatten an array

Why would shrinking TEMPDB log lead to slowness?

What (if any) replacement parts have been 3D printed on the ISS and then installed?

Can a NATO member call Article 5 after being attacked outside its national borders?

How do I get softer pictures in sunlight, like in this commercial?

How could Corvus Glaive so easily defeat Vision?

Do I need a visa for Japan as a New Zealand Citizen?

How to delete music as it's being played

Endless disc brake issues

How much damage should a creature take if it is walking across lava while wearing a Ring of Water Walking?

What is the easiest way to list all the user:group found in a tarball?

How to engage Decker in the actual run?

Heat-shrink tubing available as a roll like adhesive tape?

Why does Ubuntu resolve the name `_gateway` to the default gateway instead of `gateway`?

Copying files: Does Windows write to disk if files are identical

What's the origin of the trope that dragons used to be common but aren't any more?

What happened to SEV?

How can I increase the rate of regeneration in humans without the possibility of tumors developing?

Is encrypted e-mail sent over TLS 1.3 a form of "forward secrecy" (similar to something like Signal)?

What papers are suitable for markers?

What is Noita downloading every time I quit the game?

Best way to drill square tubing (Without drill press)



Identifying packages by usage for removal


Annotating packages at installation to ease maintenance with apt / aptitude What is the correct way to create your own packages for local installation?how much space does a given package, and dependencies, cost?Running apt-get install updated unrelated packages and is causing issuesWhy do snap-packages exist - is there a real need?apt-get reports no space left on device






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









1

















Is there a way to identify packages, perhaps by analysing files in a package and when they were last accessed, to identify when a package was last used?



Are there perhaps existing solutions for this, maybe even part of apt already that would show me this?



It would be helpful to identify packages and applications that are rarely, or no longer, used and which could potentially be deleted from the system to free up space. (At least that's what I am trying to accomplish).










share|improve this question


























  • I doubt there is such a way. There may be binaries rarely or never used, but which are essential to the system (to be used in very exceptional, but very important cases).

    – FedonKadifeli
    May 29 at 8:00











  • @FedonKadifeli Thanks, I was just looking at the atime of all the files in /usr/bin and seeing what packages they belong to, to try and find the last time an executable from that package was used. I hope that might give me an indication of which packages with executables I could eliminate.

    – mydoghasworms
    May 29 at 8:03












  • I am really interested in this question, since I am not a very experienced user and/or administrator of Ubuntu. I will highly appreciate if an experienced user answers this question.

    – FedonKadifeli
    May 29 at 8:48











  • @FedonKadifeli I have provided an answer with a sample solution as a Ruby script which basically does what I described in my previous comment.

    – mydoghasworms
    May 29 at 11:02

















1

















Is there a way to identify packages, perhaps by analysing files in a package and when they were last accessed, to identify when a package was last used?



Are there perhaps existing solutions for this, maybe even part of apt already that would show me this?



It would be helpful to identify packages and applications that are rarely, or no longer, used and which could potentially be deleted from the system to free up space. (At least that's what I am trying to accomplish).










share|improve this question


























  • I doubt there is such a way. There may be binaries rarely or never used, but which are essential to the system (to be used in very exceptional, but very important cases).

    – FedonKadifeli
    May 29 at 8:00











  • @FedonKadifeli Thanks, I was just looking at the atime of all the files in /usr/bin and seeing what packages they belong to, to try and find the last time an executable from that package was used. I hope that might give me an indication of which packages with executables I could eliminate.

    – mydoghasworms
    May 29 at 8:03












  • I am really interested in this question, since I am not a very experienced user and/or administrator of Ubuntu. I will highly appreciate if an experienced user answers this question.

    – FedonKadifeli
    May 29 at 8:48











  • @FedonKadifeli I have provided an answer with a sample solution as a Ruby script which basically does what I described in my previous comment.

    – mydoghasworms
    May 29 at 11:02













1












1








1


0






Is there a way to identify packages, perhaps by analysing files in a package and when they were last accessed, to identify when a package was last used?



Are there perhaps existing solutions for this, maybe even part of apt already that would show me this?



It would be helpful to identify packages and applications that are rarely, or no longer, used and which could potentially be deleted from the system to free up space. (At least that's what I am trying to accomplish).










share|improve this question















Is there a way to identify packages, perhaps by analysing files in a package and when they were last accessed, to identify when a package was last used?



Are there perhaps existing solutions for this, maybe even part of apt already that would show me this?



It would be helpful to identify packages and applications that are rarely, or no longer, used and which could potentially be deleted from the system to free up space. (At least that's what I am trying to accomplish).







apt package-management






share|improve this question














share|improve this question











share|improve this question




share|improve this question










asked May 29 at 7:49









mydoghaswormsmydoghasworms

5724 gold badges7 silver badges22 bronze badges




5724 gold badges7 silver badges22 bronze badges















  • I doubt there is such a way. There may be binaries rarely or never used, but which are essential to the system (to be used in very exceptional, but very important cases).

    – FedonKadifeli
    May 29 at 8:00











  • @FedonKadifeli Thanks, I was just looking at the atime of all the files in /usr/bin and seeing what packages they belong to, to try and find the last time an executable from that package was used. I hope that might give me an indication of which packages with executables I could eliminate.

    – mydoghasworms
    May 29 at 8:03












  • I am really interested in this question, since I am not a very experienced user and/or administrator of Ubuntu. I will highly appreciate if an experienced user answers this question.

    – FedonKadifeli
    May 29 at 8:48











  • @FedonKadifeli I have provided an answer with a sample solution as a Ruby script which basically does what I described in my previous comment.

    – mydoghasworms
    May 29 at 11:02

















  • I doubt there is such a way. There may be binaries rarely or never used, but which are essential to the system (to be used in very exceptional, but very important cases).

    – FedonKadifeli
    May 29 at 8:00











  • @FedonKadifeli Thanks, I was just looking at the atime of all the files in /usr/bin and seeing what packages they belong to, to try and find the last time an executable from that package was used. I hope that might give me an indication of which packages with executables I could eliminate.

    – mydoghasworms
    May 29 at 8:03












  • I am really interested in this question, since I am not a very experienced user and/or administrator of Ubuntu. I will highly appreciate if an experienced user answers this question.

    – FedonKadifeli
    May 29 at 8:48











  • @FedonKadifeli I have provided an answer with a sample solution as a Ruby script which basically does what I described in my previous comment.

    – mydoghasworms
    May 29 at 11:02
















I doubt there is such a way. There may be binaries rarely or never used, but which are essential to the system (to be used in very exceptional, but very important cases).

– FedonKadifeli
May 29 at 8:00





I doubt there is such a way. There may be binaries rarely or never used, but which are essential to the system (to be used in very exceptional, but very important cases).

– FedonKadifeli
May 29 at 8:00













@FedonKadifeli Thanks, I was just looking at the atime of all the files in /usr/bin and seeing what packages they belong to, to try and find the last time an executable from that package was used. I hope that might give me an indication of which packages with executables I could eliminate.

– mydoghasworms
May 29 at 8:03






@FedonKadifeli Thanks, I was just looking at the atime of all the files in /usr/bin and seeing what packages they belong to, to try and find the last time an executable from that package was used. I hope that might give me an indication of which packages with executables I could eliminate.

– mydoghasworms
May 29 at 8:03














I am really interested in this question, since I am not a very experienced user and/or administrator of Ubuntu. I will highly appreciate if an experienced user answers this question.

– FedonKadifeli
May 29 at 8:48





I am really interested in this question, since I am not a very experienced user and/or administrator of Ubuntu. I will highly appreciate if an experienced user answers this question.

– FedonKadifeli
May 29 at 8:48













@FedonKadifeli I have provided an answer with a sample solution as a Ruby script which basically does what I described in my previous comment.

– mydoghasworms
May 29 at 11:02





@FedonKadifeli I have provided an answer with a sample solution as a Ruby script which basically does what I described in my previous comment.

– mydoghasworms
May 29 at 11:02










1 Answer
1






active

oldest

votes


















0


















Though I am sure there is a way to do this with just Bash scripting, I wrote a little script (which calls shell commands anyway to execute dpkg) in Ruby.



What it does is:



  1. Calls dpkg -S /usr/bin/* to get a list of all the packages that each of the files in /usr/bin belong to.

  2. Build an array of each package with the latest date of a contained file from the same directory, by comparing the last accessed file (atime) of each file in the package and sorts the list by the time

  3. Output the results to a tab delimited file

A better approach would probably be to go through each package, list all the files in the package, and find the last access time for each file, and so find the maximum access time for each package. (Which sounds like it should be doable with some single line Bash script).



Perhaps someone could be so kind as to provide a Bash-only version that does the same thing?



# Obtain a list of files in /usr/bin with the corresponding package they belong to:
packfiles = (`dpkg -S /usr/bin/* 2>/dev/null`).split("n") # errors written to /dev/null

# For each executable in a package, get the last accessed time and save the latest time per package
packagetimes = packfiles.reduce()
package, file = pf.split(' ') # Split line into package name and file path
package.chomp!(':') # Remove last colon after package name
packages[package]
lat = open(file).atime # Get the last accessed time of the file
#Take greater of package last change time or time for file for package:
packages[package] = (packages[package] && packages[package] > lat ? packages[package] : lat)
packages #for next reduce iteration
.
# Produce a sorted list of packages and times
reduce([]) arr, entry. # Create array with package, time
sort_by line # Sort array by time

# Write out the list of packages and times
open('./pusage.txt', 'w')


You can test it, as I did, by running some binary from some package and seeing that, when you run the script again, the timestamp next to the package changes and moves it to the bottom of the list.



This kind of works for me, though I would still be a bit hesitant to delete some of the packages, even though their usage seems like it might date back to when I installed the system on my machine.








share|improve this answer




























  • If you are asking for a Bash solution, you should mention that in the question, especially by the tag.

    – Melebius
    May 29 at 12:20












Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1147035%2fidentifying-packages-by-usage-for-removal%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown


























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0


















Though I am sure there is a way to do this with just Bash scripting, I wrote a little script (which calls shell commands anyway to execute dpkg) in Ruby.



What it does is:



  1. Calls dpkg -S /usr/bin/* to get a list of all the packages that each of the files in /usr/bin belong to.

  2. Build an array of each package with the latest date of a contained file from the same directory, by comparing the last accessed file (atime) of each file in the package and sorts the list by the time

  3. Output the results to a tab delimited file

A better approach would probably be to go through each package, list all the files in the package, and find the last access time for each file, and so find the maximum access time for each package. (Which sounds like it should be doable with some single line Bash script).



Perhaps someone could be so kind as to provide a Bash-only version that does the same thing?



# Obtain a list of files in /usr/bin with the corresponding package they belong to:
packfiles = (`dpkg -S /usr/bin/* 2>/dev/null`).split("n") # errors written to /dev/null

# For each executable in a package, get the last accessed time and save the latest time per package
packagetimes = packfiles.reduce()
package, file = pf.split(' ') # Split line into package name and file path
package.chomp!(':') # Remove last colon after package name
packages[package]
lat = open(file).atime # Get the last accessed time of the file
#Take greater of package last change time or time for file for package:
packages[package] = (packages[package] && packages[package] > lat ? packages[package] : lat)
packages #for next reduce iteration
.
# Produce a sorted list of packages and times
reduce([]) arr, entry. # Create array with package, time
sort_by line # Sort array by time

# Write out the list of packages and times
open('./pusage.txt', 'w')


You can test it, as I did, by running some binary from some package and seeing that, when you run the script again, the timestamp next to the package changes and moves it to the bottom of the list.



This kind of works for me, though I would still be a bit hesitant to delete some of the packages, even though their usage seems like it might date back to when I installed the system on my machine.








share|improve this answer




























  • If you are asking for a Bash solution, you should mention that in the question, especially by the tag.

    – Melebius
    May 29 at 12:20















0


















Though I am sure there is a way to do this with just Bash scripting, I wrote a little script (which calls shell commands anyway to execute dpkg) in Ruby.



What it does is:



  1. Calls dpkg -S /usr/bin/* to get a list of all the packages that each of the files in /usr/bin belong to.

  2. Build an array of each package with the latest date of a contained file from the same directory, by comparing the last accessed file (atime) of each file in the package and sorts the list by the time

  3. Output the results to a tab delimited file

A better approach would probably be to go through each package, list all the files in the package, and find the last access time for each file, and so find the maximum access time for each package. (Which sounds like it should be doable with some single line Bash script).



Perhaps someone could be so kind as to provide a Bash-only version that does the same thing?



# Obtain a list of files in /usr/bin with the corresponding package they belong to:
packfiles = (`dpkg -S /usr/bin/* 2>/dev/null`).split("n") # errors written to /dev/null

# For each executable in a package, get the last accessed time and save the latest time per package
packagetimes = packfiles.reduce()
package, file = pf.split(' ') # Split line into package name and file path
package.chomp!(':') # Remove last colon after package name
packages[package]
lat = open(file).atime # Get the last accessed time of the file
#Take greater of package last change time or time for file for package:
packages[package] = (packages[package] && packages[package] > lat ? packages[package] : lat)
packages #for next reduce iteration
.
# Produce a sorted list of packages and times
reduce([]) arr, entry. # Create array with package, time
sort_by line # Sort array by time

# Write out the list of packages and times
open('./pusage.txt', 'w')


You can test it, as I did, by running some binary from some package and seeing that, when you run the script again, the timestamp next to the package changes and moves it to the bottom of the list.



This kind of works for me, though I would still be a bit hesitant to delete some of the packages, even though their usage seems like it might date back to when I installed the system on my machine.








share|improve this answer




























  • If you are asking for a Bash solution, you should mention that in the question, especially by the tag.

    – Melebius
    May 29 at 12:20













0














0










0









Though I am sure there is a way to do this with just Bash scripting, I wrote a little script (which calls shell commands anyway to execute dpkg) in Ruby.



What it does is:



  1. Calls dpkg -S /usr/bin/* to get a list of all the packages that each of the files in /usr/bin belong to.

  2. Build an array of each package with the latest date of a contained file from the same directory, by comparing the last accessed file (atime) of each file in the package and sorts the list by the time

  3. Output the results to a tab delimited file

A better approach would probably be to go through each package, list all the files in the package, and find the last access time for each file, and so find the maximum access time for each package. (Which sounds like it should be doable with some single line Bash script).



Perhaps someone could be so kind as to provide a Bash-only version that does the same thing?



# Obtain a list of files in /usr/bin with the corresponding package they belong to:
packfiles = (`dpkg -S /usr/bin/* 2>/dev/null`).split("n") # errors written to /dev/null

# For each executable in a package, get the last accessed time and save the latest time per package
packagetimes = packfiles.reduce()
package, file = pf.split(' ') # Split line into package name and file path
package.chomp!(':') # Remove last colon after package name
packages[package]
lat = open(file).atime # Get the last accessed time of the file
#Take greater of package last change time or time for file for package:
packages[package] = (packages[package] && packages[package] > lat ? packages[package] : lat)
packages #for next reduce iteration
.
# Produce a sorted list of packages and times
reduce([]) arr, entry. # Create array with package, time
sort_by line # Sort array by time

# Write out the list of packages and times
open('./pusage.txt', 'w')


You can test it, as I did, by running some binary from some package and seeing that, when you run the script again, the timestamp next to the package changes and moves it to the bottom of the list.



This kind of works for me, though I would still be a bit hesitant to delete some of the packages, even though their usage seems like it might date back to when I installed the system on my machine.








share|improve this answer
















Though I am sure there is a way to do this with just Bash scripting, I wrote a little script (which calls shell commands anyway to execute dpkg) in Ruby.



What it does is:



  1. Calls dpkg -S /usr/bin/* to get a list of all the packages that each of the files in /usr/bin belong to.

  2. Build an array of each package with the latest date of a contained file from the same directory, by comparing the last accessed file (atime) of each file in the package and sorts the list by the time

  3. Output the results to a tab delimited file

A better approach would probably be to go through each package, list all the files in the package, and find the last access time for each file, and so find the maximum access time for each package. (Which sounds like it should be doable with some single line Bash script).



Perhaps someone could be so kind as to provide a Bash-only version that does the same thing?



# Obtain a list of files in /usr/bin with the corresponding package they belong to:
packfiles = (`dpkg -S /usr/bin/* 2>/dev/null`).split("n") # errors written to /dev/null

# For each executable in a package, get the last accessed time and save the latest time per package
packagetimes = packfiles.reduce()
package, file = pf.split(' ') # Split line into package name and file path
package.chomp!(':') # Remove last colon after package name
packages[package]
lat = open(file).atime # Get the last accessed time of the file
#Take greater of package last change time or time for file for package:
packages[package] = (packages[package] && packages[package] > lat ? packages[package] : lat)
packages #for next reduce iteration
.
# Produce a sorted list of packages and times
reduce([]) arr, entry. # Create array with package, time
sort_by line # Sort array by time

# Write out the list of packages and times
open('./pusage.txt', 'w')


You can test it, as I did, by running some binary from some package and seeing that, when you run the script again, the timestamp next to the package changes and moves it to the bottom of the list.



This kind of works for me, though I would still be a bit hesitant to delete some of the packages, even though their usage seems like it might date back to when I installed the system on my machine.









share|improve this answer















share|improve this answer




share|improve this answer








edited May 29 at 12:19









Melebius

7,3825 gold badges29 silver badges54 bronze badges




7,3825 gold badges29 silver badges54 bronze badges










answered May 29 at 11:01









mydoghaswormsmydoghasworms

5724 gold badges7 silver badges22 bronze badges




5724 gold badges7 silver badges22 bronze badges















  • If you are asking for a Bash solution, you should mention that in the question, especially by the tag.

    – Melebius
    May 29 at 12:20

















  • If you are asking for a Bash solution, you should mention that in the question, especially by the tag.

    – Melebius
    May 29 at 12:20
















If you are asking for a Bash solution, you should mention that in the question, especially by the tag.

– Melebius
May 29 at 12:20





If you are asking for a Bash solution, you should mention that in the question, especially by the tag.

– Melebius
May 29 at 12:20


















draft saved

draft discarded















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1147035%2fidentifying-packages-by-usage-for-removal%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown









Popular posts from this blog

Tamil (spriik) Luke uk diar | Nawigatjuun

Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

Training a classifier when some of the features are unknownWhy does Gradient Boosting regression predict negative values when there are no negative y-values in my training set?How to improve an existing (trained) classifier?What is effect when I set up some self defined predisctor variables?Why Matlab neural network classification returns decimal values on prediction dataset?Fitting and transforming text data in training, testing, and validation setsHow to quantify the performance of the classifier (multi-class SVM) using the test data?How do I control for some patients providing multiple samples in my training data?Training and Test setTraining a convolutional neural network for image denoising in MatlabShouldn't an autoencoder with #(neurons in hidden layer) = #(neurons in input layer) be “perfect”?