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;
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
add a comment
|
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
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
add a comment
|
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
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
apt package-management
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
add a comment
|
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
add a comment
|
1 Answer
1
active
oldest
votes
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:
- Calls
dpkg -S /usr/bin/*
to get a list of all the packages that each of the files in/usr/bin
belong to. - 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 - 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.
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
add a comment
|
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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:
- Calls
dpkg -S /usr/bin/*
to get a list of all the packages that each of the files in/usr/bin
belong to. - 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 - 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.
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
add a comment
|
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:
- Calls
dpkg -S /usr/bin/*
to get a list of all the packages that each of the files in/usr/bin
belong to. - 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 - 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.
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
add a comment
|
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:
- Calls
dpkg -S /usr/bin/*
to get a list of all the packages that each of the files in/usr/bin
belong to. - 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 - 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.
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:
- Calls
dpkg -S /usr/bin/*
to get a list of all the packages that each of the files in/usr/bin
belong to. - 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 - 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.
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
add a comment
|
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
add a comment
|
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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