Linux locale setting failure

linux

When your locales are screwed, you’re going to notice a lot of problems even trying to curl from the command line, for e.g.:
Sorry, command-not-found has crashed! Please file a bug report at:

If you see an error message like this:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = “UTF-8”,
LANG = “en_US.UTF-8”

root@mwtokyo3:~# dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = “UTF-8”,
LANG = “en_US.UTF-8”
are supported and installed on your system.
perl: warning: Falling back to the standard locale (“C”).
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Generating locales…
en_AG.UTF-8… up-to-date
en_AU.UTF-8… up-to-date
en_BW.UTF-8… up-to-date
en_CA.UTF-8… up-to-date
en_DK.UTF-8… up-to-date
en_GB.UTF-8… up-to-date
en_HK.UTF-8… up-to-date
en_IE.UTF-8… up-to-date
en_IN.UTF-8… up-to-date
en_NG.UTF-8… up-to-date
en_NZ.UTF-8… up-to-date
en_PH.UTF-8… up-to-date
en_SG.UTF-8… up-to-date
en_US.UTF-8… up-to-date
en_ZA.UTF-8… up-to-date
en_ZM.UTF-8… up-to-date
en_ZW.UTF-8… up-to-date
Generation complete.

Just add this to your ~/.profile and ~/.bashrc
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8

Then:
source ~/.profile
source ~/.bashrc

Then try again, all should be good.

Creating a second instance of MySQL on the same machine

mysql

It’s possible to run multiple instances of MySQL on the same machine, albeit running on a separate port. This guide attempts to explain quickly and easily how it’s done.

So what do we do? First things first, we need to make the data directory for the new mysql2 instance. That can be easily found from running ‘ps’ and identifying your current instance of mysql, let’s call it mysql1 in this case.

In my case, we had /var/lib/mysql, so I created mysql2:
mkdir /var/lib/mysql2
chown -R mysql.mysql /var/lib/mysql2

I also want some separate log file destinations:
mkdir /var/log/mysql2
chown -R mysql.mysql /var/log/mysql2

Then we get into the nitty gritty! Changing the my configuration file. That’s located on Debian systems in /etc/my.cnf and then I copied it to /etc/my2.cnf

In the new second config file, you need to specify a new port. Let’s say the default port for the first instance is 3306, I now should add “port=3307” into my2.cnf

The same rule will apply for changing the ‘datadir’ to the new directory in the config file, as well as the socket, you need to create a new connection socket for the secondary instance.

Also inside of the config file, you should specify where your new log-error file is as well as a new pid-file (if these are already in my.cnf, that is).

When you’re happy, just flick through the my2.cnf and double check that you’ve configured everything properly. Mine looked fine, so onto the next step.

run:
mysql_install_db –user=mysql –datadir=/var/lib/mysql2/

You’ll see some output on the command line, it should hopefully have no ERRORs in there. I also like to just double check my other instance of MySQL is still up and working OK using ps.

Now, let’s start our instance, shall we?
mysqld_safe –defaults-file=/etc/my2.cnf &

Verify it works:
mysql -S /var/lib/mysql2/mysql2.sock

Distinguish uploading files when uploading via FTP using ProFTPd

ftp

When uploading a large file, if you want to work within a directory full of files, you will find that it is quite difficult to ignore the ones that are being processed.

If you’re on the actual server itself, you can use ftpwho. http://linux.die.net/man/1/ftpwho
This is shows the current active processlist of files being uploaded by FTP.

Alternatively, and I found this by far the easiest way to distinguish between a file currently uploading and a file that is already uploaded. In comes “HiddenStores”:
http://www.proftpd.org/docs/directives/linked/config_ref_HiddenStores.html

This will mark a file with a ‘.in.’ at the beginning of the file name, so that you can easily identify a file that is being worked on at that point in time.

Stop Mail popping up on Mac OSX when using iCal as your Mac Calendar Tool

mac osx

There is truly only one way to reverse this problem – if it truly is a problem for you. I was frustrated that whenever I’d receive an alert from iCal, I’d get a popup that would then proceed to open Mac Mail, which I don’t use.

This is a nasty workaround, but basically sets a permission on the Mail application so that it is no longer readable or executable.

Firstly, to turn off the Mail notifications:
sudo chmod 000 /Applications/Mail.app/Contents/MacOS/Mail

Secondly, to re-enable:
sudo chmod 755 /Applications/Mail.app/Contents/MacOS/Mail