---
title: "Clear Out Old Kernels"
canonical: "https://techwiki.co.uk/linux/clear-out-old-kernels"
author: "Adam Birds"
article_type: "documentation"
published: "2026-08-10T23:29:22.926Z"
updated: "2026-08-10T23:29:22.927Z"
categories: ["Linux"]
tags: []
---**To clear out the old kernels from a CentOS box use the following commands:**

```

yum install yum-utils
package-cleanup --oldkernels --count=2

```

**To stop the /boot partition from filling again do the following**

```

add installonly_limit=2 to /etc/yum.conf

```

**To clear out the old kernels from a Ubuntu box use the following commands:**

```

apt-get autoremove --purge

```
