Apt tips and tricks: Difference between revisions

From HPCWIKI
Jump to navigation Jump to search
(Created page with "== Only upgrade specific package == <code>sudo apt-get install --only-upgrade <packagename></code>")
 
No edit summary
Line 1: Line 1:
== Only upgrade specific package ==
== Only upgrade specific package ==
<code>sudo apt-get install --only-upgrade <packagename></code>
<code>sudo apt-get install --only-upgrade <packagename></code>
== Show holding package ==
<code>apt-mark showhold</code>
== Remove old kernel ==
One of the best and simple way from this thead<ref>https://askubuntu.com/questions/1253347/how-to-easily-remove-old-kernels-in-ubuntu-20-04-lts</ref> <syntaxhighlight lang="bash">
#list up all the current kernels you have on a file.
$dpkg --list | egrep -i --color 'linux-image|linux-headers|linux-modules' | awk '{ print $2 }' > kernels.txt
#Filter your currently used kernel out of the file using grep.
$grep -v $(uname -r) kernels.txt > kernels_to_delete.txt
#Verify your current kernel is not present in the delete list. Don't skip this. Ensures you don't mistakenly delete all the kernels.
grep $(uname -r) kernels_to_delete.txt
#Delete all the unused kernels in one go.
$cat kernels_to_delete.txt | xargs sudo apt purge -y
</syntaxhighlight>
== References ==
<references />

Revision as of 12:15, 24 May 2023

Only upgrade specific package

sudo apt-get install --only-upgrade <packagename>

Show holding package

apt-mark showhold

Remove old kernel

One of the best and simple way from this thead[1]

#list up all the current kernels you have on a file.
$dpkg --list | egrep -i --color 'linux-image|linux-headers|linux-modules' | awk '{ print $2 }' > kernels.txt

#Filter your currently used kernel out of the file using grep.
$grep -v $(uname -r) kernels.txt > kernels_to_delete.txt

#Verify your current kernel is not present in the delete list. Don't skip this. Ensures you don't mistakenly delete all the kernels.
grep $(uname -r) kernels_to_delete.txt

#Delete all the unused kernels in one go.
$cat kernels_to_delete.txt | xargs sudo apt purge -y

References