How to restrict a specific package from installing (apt pinning)

I tend to be very picky so there are a couple of packages which I do not want installed on my machines:

  • msttcorefonts: the Microsoft-like fonts. If you have those installed, Firefox will use them and you will get ugly windows-like font on most websites which I personally hate.
  • wine: Application to run windows programs on linux. For security reasons.
  • postfix: a mail server. Just because I do not want to run a mail server on my netbook.
  • …and some other

The best way to restrict those packages from being installed is through Apt Pinning.

Apt pinning

It is very easy to pin packages and restrict them from being installed.
You will need to edit /etc/apt/preferences and add something like this:

Package: msttcorefonts
Pin: version  0.0
Pin-Priority: -1

Package: ttf-liberation
Pin: version  0.0
Pin-Priority: -1

Package: ttf-mscorefonts-installer
Pin: version  0.0
Pin-Priority: -1

Package: wine
Pin: version  0.0
Pin-Priority: -1

Package: postfix
Pin: version  0.0
Pin-Priority: -1

Pin-Priority: -1 restricts the given version from being installed, and the version 0.0 does not exist and should be a lower version than any versions of the given packages. As a conclusion, they will never be installed.

Be careful what you pin, though, as you might be too restrictive and could prevent installing or upgrading other useful packages.

How to optimize all tables from all databases

The following command will optimize all of your databases’ tables within MySQL.
It is important to optimize tables to reduce data fragmentation.

mysqlcheck -Aop -uroot

If you are not using root replace it with your username.

-A : Check all tables in all databases. This is the same as using the –databases option and naming all the databases on the command line.
-o : optimize the tables.
-p : Prompts for a password to use when connecting to the MySQL server.
-u : The MySQL user name to use when connecting to the server.

Inspired by this article.