Apt tips and tricks: Difference between revisions
(Created page with "== Only upgrade specific package == <code>sudo apt-get install --only-upgrade <packagename></code>") |
No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== You must put some 'deb-src' URIs in your sources.list<ref>https://www.tecmint.com/fix-deb-src-uris-in-your-sources-list-error/</ref> == | |||
Caused by there is no dev-src syntax in sources.list on Debian-based [[Linux]] distributions. especially when you try to run. | |||
Source packages contain the source code used to build the binary packages available for installation. Enabling the source repositories allows users to fetch the source code of packages for inspection, modification, or recompilation. | |||
$apt source <package> | |||
'''etc/apt/sources.list has''' lines that begin with <code>"deb"</code> and <code>"deb-src"</code> followed by a repository URL. '''C'''omment out relevant URL or add deb-src to use $apt source command, for example, | |||
deb-src <nowiki>http://in.archive.ubuntu.com/ubuntu</nowiki> lunar main restricted | |||
== Ubuntu - list of installed packages and downloads<ref>https://askubuntu.com/questions/86358/how-to-obtain-installed-package-files/86413#86413</ref> == | |||
<syntaxhighlight lang="bash"> | |||
Download all the installed packages into /var/cache/apt/archives (Ubuntu) | |||
#dpkg -l | grep "^ii"| awk ' {print $2} ' | xargs sudo apt-get -y --force-yes install --reinstall --download-only | |||
</syntaxhighlight> | |||
== Offline package install == | |||
In case accedentially remove essentional packages from running OS especially for network releated one. offline package installation is important instead of reinstall the system. To install package offline, the package with all dependencies should be ready to use offline.<syntaxhighlight lang="bash"> | |||
# find all dependency with apt-cache | |||
$ apt-cache depends netplan.io | |||
netplan.io | |||
Depends: libc6 | |||
Depends: libglib2.0-0 | |||
Depends: libnetplan0 | |||
Depends: libsystemd0 | |||
Depends: libuuid1 | |||
Depends: iproute2 | |||
iproute2:i386 | |||
Depends: python3 | |||
Depends: python3-yaml | |||
Depends: python3-netifaces | |||
Depends: systemd | |||
systemd:i386 | |||
Conflicts: netplan | |||
Breaks: network-manager | |||
Breaks: nplan | |||
|Suggests: network-manager | |||
Suggests: wpasupplicant | |||
wpasupplicant:i386 | |||
Replaces: nplan | |||
# download all dependency packages | |||
$ apt download <package> | |||
# copy them to USB and mount the USB to the target systemd | |||
$ sudo dpkg -i <netplan.io deb package> | |||
</syntaxhighlight> | |||
== 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> | |||
== Practical dpkg Command == | |||
dpkg has many options to run and [https://www.cyberithub.com/21-practical-dpkg-command-examples-for-linux-beginners/#Example_13_How_to_Verify_all_the_Installed_Packages this page] describes most practical dpkg commands | |||
== References == | |||
<references /> |
Latest revision as of 09:53, 30 May 2024
You must put some 'deb-src' URIs in your sources.list[1]
Caused by there is no dev-src syntax in sources.list on Debian-based Linux distributions. especially when you try to run.
Source packages contain the source code used to build the binary packages available for installation. Enabling the source repositories allows users to fetch the source code of packages for inspection, modification, or recompilation.
$apt source <package>
etc/apt/sources.list has lines that begin with "deb"
and "deb-src"
followed by a repository URL. Comment out relevant URL or add deb-src to use $apt source command, for example,
deb-src http://in.archive.ubuntu.com/ubuntu lunar main restricted
Ubuntu - list of installed packages and downloads[2]
Download all the installed packages into /var/cache/apt/archives (Ubuntu)
#dpkg -l | grep "^ii"| awk ' {print $2} ' | xargs sudo apt-get -y --force-yes install --reinstall --download-only
Offline package install
In case accedentially remove essentional packages from running OS especially for network releated one. offline package installation is important instead of reinstall the system. To install package offline, the package with all dependencies should be ready to use offline.
# find all dependency with apt-cache
$ apt-cache depends netplan.io
netplan.io
Depends: libc6
Depends: libglib2.0-0
Depends: libnetplan0
Depends: libsystemd0
Depends: libuuid1
Depends: iproute2
iproute2:i386
Depends: python3
Depends: python3-yaml
Depends: python3-netifaces
Depends: systemd
systemd:i386
Conflicts: netplan
Breaks: network-manager
Breaks: nplan
|Suggests: network-manager
Suggests: wpasupplicant
wpasupplicant:i386
Replaces: nplan
# download all dependency packages
$ apt download <package>
# copy them to USB and mount the USB to the target systemd
$ sudo dpkg -i <netplan.io deb package>
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[3]
#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
Practical dpkg Command
dpkg has many options to run and this page describes most practical dpkg commands