Sharing uid to cope with inconsistent user and group names

One day you set up some service, for instance like this spam slayer setup. Later arises the situation when the distribution package use user account named X (for instance debian-spamd)  while you set up things to use another one (for instance Debian-exim).

The easiest fix is to give them a common uid:

usermod –non-unique –uid 101 debian-spamd

(101 being user id of Debian-exim account).

Obviously it could be best to review the setup to really use two separates accounts. But it’s up to you to decide whether it’s changing it.

You may also add –gid too.

Removing invalid/incomplete multibyte or wide character in filenames

Getting an old backup, from an ante-UTF-8 era, I found out many files had filenames with some characters unreadable, or partly readable depending on the software.

I tried my urlize script first but unac (that it depends on) failed with:

unac_string: Invalid or incomplete multibyte or wide character

The easiest way to get rid of these is simply use iconv, for instance doing in a directory with such files:

for file in *; do mv "$file" "`echo "$file" | iconv -f utf8 -c -t ascii//IGNORE`"; done

Getting rid of the ever growing /var/lib/mysql/ibdata1 by getting rid of InnoDB itself

On your MySQL server, what’s is the size of /var/lib/mysql/ibdata1 ? Even if you completely drop all your databases, it won’t shrink. It surely fits a purpose: MySQL people wrote that “the fact that InnoDB tablespaces can only grow and never shrink is docummented design decision”. But the notion of a file (ibdata1 – InnoDB tablespaces) that can only grow even if you remove permanently all of your data is odd nonetheless.

The solution is not to use InnoDB. Here’s a fast way to get rid of all of it:

First we switch to MariaDB (project under the umbrella of MySQL founder Michael Widenius):

apt-get install mariadb-server mariadb-client

We make a dump of every database we want to keep:

cd /var/lib/mysql

mysqlshow # list databases
mysqldump database1 > database1.dump
mysqldump database2 > database2.dump

We add a configuration snippet to switch off innodb:

echo '[mysqld]
ignore-builtin-innodb
default-storage-engine = myisam' > /etc/mysql/conf.d/noinnodb.cnf

We restart the SQL server:

invoke-rc.d mysql restart
mysql -e "SHOW ENGINES" # should no longer show InnoDB

We remove databases with InnoDB tablespaces:

mysql -e "DROP DATABASE database1"
mysql -e "DROP DATABASE database2"

We recreate them with the dumps:

mysql -e "CREATE DATABASE database1"
mysql -e "CREATE DATABASE database2"
mysql database1 < database1.dump
mysql database2 < database2.dump

We remove the now useless InnoDB crap:

rm -f ib_logfile* ibdata1

And if everything is fine, we also remove the SQL dumps:

rm -f *.dump