Difference between revisions of "Packages"

From Freephile Wiki
Jump to navigation Jump to search
(Created page with "== Debian and derivatives == Much of why Debian is a strong Linux distribution comes from the core of Debian namely its package management. Everything in Debian – every appl...")
 
(revert edits to fix search where character encoding was a problem)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Debian and derivatives ==
 
== Debian and derivatives ==
Much of why Debian is a strong Linux distribution comes from the core of Debian namely its package management. Everything in Debian every application, every component is built into a package, and then that package is installed onto your system (either by the Installer, or by you).
+
Much of why Debian is a strong Linux distribution comes from the core of Debian namely its package management. Everything in Debian - every application, every component _everything_ is built into a package, and then that package is installed onto your system (either by the Installer, or by you).
  
There are over 29 thousand software packages available for Debian everything from the Linux kernel to games.
+
There are over 29 thousand software packages available for Debian - everything from the Linux kernel to games.
  
And <abbr title="Advanced Package Tool">Apt</abbr> is simply awesome!  Learn more at https://wiki.debian.org/Apt or https://help.ubuntu.com/14.04/serverguide/package-management.html
+
And Apt is simply awesome!  Learn more at https://wiki.debian.org/Apt or https://help.ubuntu.com/14.04/serverguide/package-management.html
  
  
Line 18: Line 18:
 
You can also use the web interface at http://packages.ubuntu.com/
 
You can also use the web interface at http://packages.ubuntu.com/
  
 +
=== Remove old kernels ===
 +
 +
Kernels take up a lot of disk space. And once you've got a new one, the old ones really don't serve a purpose. <code>autoremove</code> is supposed to remove old kernels (keeping the currently running kernel plus the prior one or two for backups).
 +
<source lang="bash">
 +
sudo apt-get autoremove
 +
</source>
 +
But sometimes old kernels are left lying around.  Maybe a lot of them. I'm not sure why, because normally you would only be left with 2 or 3 kernels if you run autoremove (perhaps this is because you have old virtualboxes?).
 +
 +
The post-install script <code>/etc/kernel/postinst.d/apt-auto-removal</code> is responsible for keeping track of what to preserve. And it writes a manifest to <code>/etc/apt/apt.conf.d/01autoremove-kernels</code>.
 +
<source lang="bash">
 +
# run the post-install script
 +
sudo /etc/kernel/postinst.d/apt-auto-removal
 +
# see what's reserved
 +
cat /etc/apt/apt.conf.d/01autoremove-kernels
 +
</source>
 +
 +
Let's use <code>dpkg</code> to see all the kernels that are currently installed.  Note: there are other related packages like headers (<code>linux-headers-*</code>), but those are dependencies of the kernel images, and will be removed when we remove the images so we don't need to even look at them.
 +
<source lang="bash">
 +
# the last pipe uses a simple extended grep to take the meta package 'linux-image-generic' out of our list
 +
dpkg -l linux-image* | awk '/^ii/ { print $2 }' | grep -e [0-9]
 +
# more complete perl-compatible regex to highlight the kernel release number
 +
dpkg -l linux-image* | awk '/^ii/ { print $2 }' | grep -P '[0-9]+\.[0-9]+\.[0-9\-]+[0-9]+'
 +
</source>
 +
Manually compose an <code>apt-get purge</code> invocation of the kernels you don't want (keep the running kernel and the prior as a fallback).
 +
<source lang="bash">
 +
sudo apt-get -y purge linux-image-3.13.0-44-generic linux-image-3.13.0-46-generic linux-image-3.13.0-48-generic linux-image-3.13.0-55-generic linux-image-3.13.0-71-generic linux-image-3.13.0-74-generic
 +
</source>
  
 
== RedHat and derivatives ==
 
== RedHat and derivatives ==
  
There is <abbr title="Yellow Dog Updater">[[YUM]]</abbr> package manager for RedHat and derivatives.
+
There is [[Yum]] package manager for RedHat and derivatives.
 +
 
 +
== See Also ==
 +
[[Regular Expressions]]
  
 
[[Category:System Administration]]
 
[[Category:System Administration]]

Latest revision as of 07:47, 31 December 2018

Debian and derivatives[edit | edit source]

Much of why Debian is a strong Linux distribution comes from the core of Debian namely its package management. Everything in Debian - every application, every component _everything_ is built into a package, and then that package is installed onto your system (either by the Installer, or by you).

There are over 29 thousand software packages available for Debian - everything from the Linux kernel to games.

And Apt is simply awesome! Learn more at https://wiki.debian.org/Apt or https://help.ubuntu.com/14.04/serverguide/package-management.html


Search for a package[edit | edit source]

Sometimes you're searching for a list of packages available. You can easily take care of that with apt-cache search.

What files did this package install?[edit | edit source]

The synaptic gui will have a 'properties' tab that lists all the files installed. On the console, you can use dpkg-query --listfiles package_name. I don't use apt-file since dpkg is already installed on a base system.

What package provides file Y?[edit | edit source]

dpkg-query --search z.so reveals the packages you could install that would possibly install the missing source file your linker is looking for.

You can also use the web interface at http://packages.ubuntu.com/

Remove old kernels[edit | edit source]

Kernels take up a lot of disk space. And once you've got a new one, the old ones really don't serve a purpose. autoremove is supposed to remove old kernels (keeping the currently running kernel plus the prior one or two for backups).

sudo apt-get autoremove

But sometimes old kernels are left lying around. Maybe a lot of them. I'm not sure why, because normally you would only be left with 2 or 3 kernels if you run autoremove (perhaps this is because you have old virtualboxes?).

The post-install script /etc/kernel/postinst.d/apt-auto-removal is responsible for keeping track of what to preserve. And it writes a manifest to /etc/apt/apt.conf.d/01autoremove-kernels.

# run the post-install script
sudo /etc/kernel/postinst.d/apt-auto-removal
# see what's reserved
cat /etc/apt/apt.conf.d/01autoremove-kernels

Let's use dpkg to see all the kernels that are currently installed. Note: there are other related packages like headers (linux-headers-*), but those are dependencies of the kernel images, and will be removed when we remove the images so we don't need to even look at them.

# the last pipe uses a simple extended grep to take the meta package 'linux-image-generic' out of our list
dpkg -l linux-image* | awk '/^ii/ { print $2 }' | grep -e [0-9]
# more complete perl-compatible regex to highlight the kernel release number
dpkg -l linux-image* | awk '/^ii/ { print $2 }' | grep -P '[0-9]+\.[0-9]+\.[0-9\-]+[0-9]+'

Manually compose an apt-get purge invocation of the kernels you don't want (keep the running kernel and the prior as a fallback).

sudo apt-get -y purge linux-image-3.13.0-44-generic linux-image-3.13.0-46-generic linux-image-3.13.0-48-generic linux-image-3.13.0-55-generic linux-image-3.13.0-71-generic linux-image-3.13.0-74-generic

RedHat and derivatives[edit | edit source]

There is Yum package manager for RedHat and derivatives.

See Also[edit | edit source]

Regular Expressions