Solve /boot getting 100% full issue on Ubuntu Servers

This is an issue affecting many Ubuntu servers. It basically happens when you enable automated security updates, multiple kernel packages get installed automatically, without removing the old ones, which gets /boot 100% full and the package manager is no longer able to function properly, showing a message complaining about dependency issues, e.g.

The following packages have unmet dependencies:
 linux-image-extra-4.4.0-64-generic : Depends: linux-image-4.4.0-64-generic but it is not going to be installed
 linux-image-generic : Depends: linux-image-4.4.0-64-generic but it is not going to be installed
                       Recommends: thermald but it is not going to be installed
 mongodb-org : Depends: mongodb-org-shell but it is not going to be installed
               Depends: mongodb-org-server but it is not going to be installed
               Depends: mongodb-org-mongos but it is not going to be installed
               Depends: mongodb-org-tools but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

The following is a solution to this problem that I’ve tried numerous times, and works immediately, then I will explain how to prevent this from happening again in the future:

First step, you need to know which kernel is currently running using:

uname -a

Let’s assume this gives you the following kernel version as an output:


Keep this version in mind, as what we are going to do is pretty dangerous:

cd /boot
sudo du -khs *

This will give you a long list of old kernel that you won’t be needing. Now we will manually delete the initrd.img-*** of old kernels prior to the currently-running version, e.g.

sudo rm -rf initrd.img-4.4.0-21-generic initrd.img-4.4.0-36-generic initrd.img-4.4.0-38-generic initrd.img-4.4.0-42-generic initrd.img-4.4.0-45-generic initrd.img-4.4.0-47-generic initrd.img-4.4.0-51-generic initrd.img-4.4.0-53-generic vmlinuz-4.4.0-21-generic vmlinuz-4.4.0-36-generic vmlinuz-4.4.0-38-generic vmlinuz-4.4.0-42-generic vmlinuz-4.4.0-45-generic vmlinuz-4.4.0-47-generic vmlinuz-4.4.0-51-generic vmlinuz-4.4.0-53-generic

This will free up some space, so that the package manager can breathe. Next:

sudo apt install -f

This will just fix part of the problem, as it will still complain about dependencies and /boot might get filled again, so that the next thing would be to:

sudo apt autoremove

This will remove all the dependencies for old kernel versions. You might need to run the last 2 commands a couple of times, now you got a clean /boot and the package manager is good.

To avoid this problem in the future, configure the unattended-upgrades package to automatically remove the old kernels along with their dependencies by editing the file:

sudo vi /etc/apt/apt.conf.d/50unattended-upgrades

Go to the following line, remove the comment and change “false” to “true”:

//Unattended-Upgrade::Remove-Unused-Dependencies "false";

so that it becomes like this:

Unattended-Upgrade::Remove-Unused-Dependencies "true";

Save and exit the file.

That’s it, Enjoy!


Posted in Linux | Tagged , , , , , | Leave a comment

How to change default terminal emulator in Ubuntu 18.04

Ctrl+Alt+t is the keyboard shortcut to open a terminal in Ubuntu. By default, it opens an ‘x-terminal-emulator’ terminal.

I wanted to change that to use my favorite terminal emulator, which is ‘terminator’

To do that:

gsettings set org.gnome.desktop.default-applications.terminal exec 'terminator'


sudo update-alternatives --config x-terminal-emulator

That’s it!



Posted in Linux | Tagged , , , , , | Leave a comment

azure-cli installation on Ubuntu Bionic (18.04)

No deb packages have been released yet for Ubuntu 18.04, so you have to use the script MS provided here. However, you will face the following error immediately:

 fatal error: Python.h: No such file or directory

To resolve this, simply install the python-dev package:

sudo apt install python-dev

Then run the script normally:

curl -L | bash

Once done, exit the terminal and open a new one.

That’s it! Enjoy!


Posted in Linux | Tagged , , , , , | Leave a comment

How to uninstall NVidia driver from Linux

This only applies for drivers that have been installed using the .run file.

./ --uninstall

Source: Red Hat Documentation which they deny access to except if you pay! Idiots!

Posted in Linux | Tagged , , , | Leave a comment

How to to prevent the screen from turning off when locked with gnome-shell on Ubuntu 18.04

This annoys me a lot, as whenever I lock the screen, my big screen turns off and it is an old slow screen that takes a few seconds to turn on again.

To disable this behavior, do the following:

  1. Download this extension:
  2. Extract the file and edit the metadata.json file, adding “3.28” to the list of supported shell-version
  3. Place the folder inside ~/.local/share/gnome-shell/extensions/
  4. Open gnome-tweaks (install it first by apt install gnome-tweaks if you don’t have it already)
  5. Go to Extensions and turn “No screen blank” extension on.
  6. Enjoy!

Note: I have uploaded the modified version to support Gnome 3.28 here.

Tested on Ubuntu 18.04 with Gnome 3.28.

Thanks go to the anonymous developer here, who did quite a good job!

Posted in Linux | Tagged , , , , , , | 2 Comments

Use 7z to compress & encrypt zip files

7z a -tzip -mem=AES128 -bd -y -pPASSWORD -mx=0 -- file1 file2 file3 file3

This uses AES128 encryption and uses a compression rate of 0 (archive mode). You can pick a number up to 9 (highest compression rate)


Posted in Linux | Tagged , , , , , | Leave a comment

A tiny script to replace all occurrences of a string in a file with another string

sed -i 's/original/new/g' filename.txt

This basically replaces every occurrence of the “original” string with the “new” string in the file named “filename.txt”


sed -i 's/' /etc/fstab

Will replace all occurrences of the IP “” with the IP “” in the “/etc/fstab” file.

That’s it, Enjoy!


Posted in Linux | Tagged , , , | 1 Comment