Category Archives: Linux

Cleaning Up Linux Headers

Make sure you’ve rebooted BEFORE running any of these commands so that you are actively using the latest kernel.

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge

If you’ve had a previous apt-get install fail due to disk space issues and you’re trying to clean up the linux headers to free disk space run the below command which will force the purge
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y -f purge

Fixed: LXDE-core startlxde gives Gtk-WARNING **: cannot open display: error message

I’d be tasked with installing a GUI on a server for someone else to use. I opted for LXDE as it’s so lightweight and I just wanted the core, no extra gumph. I ran into an issue launching lxde once I’d installed it. Here’s how I fixed it:

Installed LXDE Core
sudo apt-get install lxde-core

I then went to try startx, how I’d normally start a shell if I’d installed gnome or such, startx didn’t exist, so I tired startlxde. It came back with the error “Gtk-WARNING **: cannot open display:
After a bit of searching online I found some people were saying about .xinitrc, but I didn’t have an xinit…. neither did it seem that I had xinit. So I tried the following with instant success

The Fix

Install xinit
sudo apt-get install xinit

Start X

How to clean up after removing a package via apt-get

Say you install a package via apt-get like lubuntu-desktop. There’s a ton of dependencies and apps that get installed because of one simple meta-package install.
If you remove lubuntu-desktop only a small amount of that gets removed. I wanted to dejunk a server and so used the following commands to check what else was installed and to remove them all.

Look at the dependencies to make sure those are what you want to remove
sudo apt-cache depends lubuntu-desktop
Remove these dependencies
sudo apt-cache depends lubuntu-desktop | awk 'NF && /Depends:/ {print "sudo apt-get -y remove "$2}' | sh
Clean up the related dependencies
sudo apt-get autoremove

Fixed: phpMyAdmin is throwing a #2002 cannot log in to the mysql server phpmyadmin

This one had me going round the houses a bit until I the wrong permissions confirmed something to me.
Firstly the /etc/phpmyadmin/ file is crud. For some reason this file doesn’t resemble the actual config file that you should use.
The file /usr/share/phpmyadmin/ is the format that you need for a correct phpMyAdmin configuration, so copy it to /etc/phpmyadmin/

Next you need to edit this config file. This isn’t the hardest of the things in the world to do if you just want the basics. You just need to edit the value for $cfg['Servers'][$i]['host']

Once you’ve done that you can then login to phpMyAdmin using your mySQL credentials and get started.
It will bitch about not having the advanced features enabled. To do this follow the blog post I did at INSTALLING PHPMYADMIN ADVANCED FEATURES ON UBUNTU

Make sure you log out and back in to pick up the changes.