Setup MySQL server on CentOS 6

I’m going to show you how to easily set up a MySQL server on your CentOS box.

First you need to install the required packages
yum install mysql mysql-server

Then start up your newly installed sql server
service mysqld start
Configure your server by running
mysql_secure_installation
Then follow:
Enter current password for root (enter for none): { Press Enter }
Set root password? [Y/n] { Press Y }
New password: { Type your password of choice }
Re-enter new password: { Your password again }
Remove anonymous users? [Y/n] { Press Y }
Disallow root login remotely? [Y/n] { Y is recommended, make other users for remote login}
Remove test database and access to it? [Y/n] { Y if you don’t need any test data }
Reload privilege tables now? [Y/n] { Y to clean up and applay the changes }

All done!  If you’ve completed all of the above steps, your MySQL
installation should now be secure.
Now your basic configuration is ready.

What to do after a fresh installation of Fedora

Ok, so you have successfully installed Fedora on your machine, now you might want to make it ready for your needs so you could use the following for inspiration. I am not going to debate ethical issues of installing / using non-free software so if you don’t agree with some of my recommendations just don’t apply them.

1. Install flash player

Unfortunately a great extent of out today web is still dependent on Flash, although Flash seems to die in the near future you might still need it.

So add the following repositories from adobe:

rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm
rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux

and for x64

rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-x86_64-1.0-1.noarch.rpm
rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux

Then install the flash player:

yum install flash-plugin nspluginwrapper alsa-plugins-pulseaudio libcurl

2. Enable mp3 support and install all the media codecs

Fedora does not come with out-of-the-box support for mp3 and other popular codecs due to licence issues. If you don’t want to use non-free codecs like gstreamer ugly plugins then you should use VLC to play every media format.
To install VLC:
yum install vlc

To enable codecs support system-wide:
Activate RPM Fusion repository:

yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

Then install the ugly plugins:

yum install gstreamer-plugins-*

3. Install skype
If you are a regular skype user you might need it to keep in contact with your friends and family.
Unfortunately skype is 32-bit only application and if you run a 64-bit Fedora you need some 32-bit dependencies in order to run it:
Install the dependecies for 64-bit systems first:

sudo yum -y install libXv.i686 libXScrnSaver.i686 qt.i686 qt-x11.i686 pulseaudio-libs.i686 pulseaudio-libs-glib2.i686 alsa-plugins-pulseaudio.i686

Now you can proceed to skype’s download page and get the latest 32-bit package for Fedora .

4. Install dropbox

Fortunately dropox releases rpm packages for both 32-bit and 64-bit Fedora. All you have to do is head to their website and grab your rpm package

5. Install your favorite software
On my must-have software list is:
libreoffice-writer
libreoffice-calc
libreoffice-impress
clementine-player
chrominum-browser
gcstar

6. Update
Do a system update

7. Install 3rd party drivers
If you need to install 3rd party drivers you might want to google for some tutorials on how to do it for your specific driver

Setup a FTP server on CentOS6

So it’s close to a half a year since I started maintaining my own CentOS server, but did not set up a FTP server on it, therefore file transfers were quite tedious to accomplish.

So I went on googling about a lightweight linux ftp server and I stumbled upon vsftp and I thought I could make use of it as a service (vsftpd).
But before you think about setting a FTP server you might want to check on whether or not you already have one already opened (which was in my case).
You could check for the processes running the following command:
netstat -tulnp|grep :21

If you find that you have one already functioning and running you might want to check how to configure it and make use of it otherwise you could make use of vsftpd.
First proceed with installing the server which is as simple as:
yum install vsftpd
Then configure it for your need. You might want to make it as secure as possible, if that’s the case follow these steps then take a closer look at the reference.
Edit the configuration file /etc/vsftpd/vsftpd.conf with your editor of choice and modify the following:

We don’t want anonymous login:

anonymous_enable=NO

Enable local users:

local_enable=YES

The ftpuser should be able to write data:

write_enable=YES

Port 20 need to turned off, makes vsftpd run less privileged:

connect_from_port_20=NO

Chroot everyone:

chroot_local_user=YES

set umask to 022 to make sure that all the files (644) and folders (755) you upload get the proper permissions.

local_umask=022

Then prepare a user for FTP use:

useradd -d /var/www/path/to/your/dir ftpuser
passwd ftpuser
And give it access to the FTP root directory:
chown -R ftpuser /var/www/path/to/your/dir
sudo chmod 775 /var/www/path/to/your/dir

When ready you can start your service with:
service vsftpd start
and make it automatically start at boot time with:
chkconfig vsftpd on

Reduce the DPI below 100% in Windows

This is a handy trick on how to reduce the DPI below 100% (below 96dpi). So all you’ll need is to adjust a registry value to match your needs.

Open regedit and browse to HKEY_CURRENT_CONFIG\Software\Fonts\LogPixels

Now change the Decimal value with anything under 96 (i think it should be over 70 though… I use 82). Log off to apply the changes and you’re done.

Why would you need the DPI below 100%?
Well reasons could be many, mine are:
– to be able to see the date next to the time while having a small taskbar
– to avoid scrolling horizontally
– to have more place on the screen

Multiple monitors in Enlightment – bodhi linux

Yes, I am on the verge to migrate from my XFCE to Enlightment as my desktop of choice. But I’m going to talk about the migration in another article.

As in XFCE, in Enlightment as the user doesn’t really have a GUI that allows you to manage multiple monitors so you could either install it yourself or apply to the CLI-wizard side of you.
To fix this shortage one could install ARandR and manage the monitors as one pleases but this has a little and quite important shortage, ARandR can’t let you change the primary monitor, and unless you are pleased with whatever it chooses for you, you have to go to the command line at least once.
If you were in linux world for some time, you probably already know that xrandr is the king of display configuration, so you’ll have to show it some respect.
First find out the names of your monitors by typing xrandr in a terminal emulator (Terminology is the default one in bodhi linux). Once you have the names think about which one you want to make the primary monitor and run
xrandr –output MONITOR-NAME — primary

Now you could close the terminal and use ARandR for positioning if you don’t want to get your hands dirty anymore, but you could position them as well with the command xrandr.
In my case I want to have my laptop screen (LVDS)as primary and should be on the left, that means that the external monitor (VGA-0) would be on the right of my laptop screen, so I used this command:
xrandr –output LVDS –primary –auto –output VGA-0 –auto –right-of LVDS
Have fun with the setup and Enlightment ;)
PS: it probably works in any environment as long as you have xrandr available

Bash … a new world / book2.de soundfile downloader

Yesterday I started to learn some bash basic programming because I needed to achieve a task and I knew that bash is the closest language to all my linux tools.

The task I needed to achieve was to download some sound files in different languages from book2.de, I needed those in order to polish a bit the languages I already know and to get some insight of their related sisters ;)
So basically, I wanted to make some sort of playlist that would be able to play the same ords/sentences in different languages one after another. Since book2.de offers 100 lessons each one containing 20 sound files, I have to get 2000 sound files per language for maximum 10 languages. Since I wanted no problems by messing around with tousands of files I decided to rename the files to be in the right place in my playlist by default.
So I started by diving in to bash for a couple of hours, and in the end I was able to build a pretty god (can always be better) bash script to do my job.
My first bash script :
#!/bin/bash
# script to download audio files from book2.de based on their locale
count=1
limit=2000
baseUrl=”http://www.goethe-verlag.com/book2/”
locale=$1
while [ $count -le $limit ]
do
if [ $count -lt 10 ]; then
wget -nv -O 000${count}${locale}.mp3 ${baseUrl}${locale}/SOUND/000${count}.mp3
elif [ $count -ge 10 ] && [ $count -lt 100 ]; then
wget -nv -O 00${count}${locale}.mp3 ${baseUrl}${locale}/SOUND/00${count}.mp3
elif [ $count -ge 100 ] && [ $count -lt 1000 ]; then
wget -nv -O 0${count}${locale}.mp3 ${baseUrl}${locale}/SOUND/0${count}.mp3
else wget -nv -O ${count}${locale}.mp3 ${baseUrl}${locale}/SOUND/${count}.mp3
fi
count=$(( $count + 1 ))

done

echo “Job done”
Usage: 1. save this script into a file, I called it b2down.sh
2. run ./b2down.sh EN to download all the english sounds (replace EN with your targeted locale)
3. drag the resulted files in your favourite player and you’re ready to become a polyglot
A few notes for bash beginners:
– pay attention to the spaces between and after [ ], this could drive you nuts
– protect your $variable with ${variable}
– make use of your CLI skills

Back on track

I’m back on track (at least I’m trying to be). I told myself I have to keep my blog alive, and keep the world up-to-date with my newest findings no matter how big or small they are, as long as they are focused and contain accurate info.

The main reason for not publishing anything in a long time is laziness which was fed up by some technical problems like my host database beeing hacked wiped and my last backup holded info from 2 weeks before.. (I was just at the beginning of setting the thing up). So now I’ll be more carefull about the security and backup, ups… I have to do one right after writing this entry (until I setup an automatic backup system).
So bottom line, my blog was not affected by the database wipe because moovable type kind of precompiles the whole stuff into html each time I update something… so notihing lost. I think I will loose some of my posts not covered by my backup with this update, but since I have a visual one… I just printed the curent page as a pdf, and with a bit of copy-paste and some date-hacking I’ll have my stuff back as before… enough with talking, let’s revive this monster.

Bring Xfce to a CentOS 6 box

[last update 11-01-2013]
As many of the tutorials about this subject, present on the Internet were either outdated
or incomplete, I thought to log my adventure into installing CentOS 6 with Xfce on my
recently rented VPS server.
So all you’ll need is SSH access to your box, and to be ready to get your hands dirty.
Log in with your root account into the box’s shell:
ssh root@host
The next thing to do is to enable a extra repository in order to be able to install Xfce on
your box. I recommend to use the EPEL {Extra Packages for Enterprise Linux} repository
and to do so you need to find the latest epel-release package; and to do so I used the official rpm package.
You might be lucky and at the time of reading this to be able to install this package
directly from CentOS6’s repos with:
yum install epel-release
but if your a bit less lucky install it manually:
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
Now that you are all set up with the EPEL repo, let’s go on with installing Xfce applications CentOS collection
yum groupinstall Desktop Xfce Fonts
After the packages installation is all done you need to set up a vnc server, after all there 
is no point in installing a Desktop Manager if you don’t intend to connect to it and see it. 
yum install tigervnc-server
Now make sure all your packages are updated:
yum update
At this point if you don’t already have a user besides the root user, you should create one
and assign it the desktop by setting a vnc password for it. I’ll use the name gui in these
examples.
useradd gui
passwd gui
su gui
vncpasswd
Now enter a password for the desktop user, this password will be when you’ll remote
connect to the newly installed server. After that return to your root shell user with the
exit command.
exit

Now it’s time to configure the vnc server configuration, but first we need a CLI text
editor to edit the configuration, I’ll use nano for that.
yum install nano
nano /etc/sysconfig/vncservers
The configuration file should reflect which user is going to be responsible for the
Graphical User interface and how the desktop would be like. So I’ll use a simple
configuration:
VNCSERVERS=”1:gui”
VNCSERVERARGS[1]=”-geometry 1024×768  -nolisten tcp -localhost
Important note: The italic part should be added to secure the connection with a SSH tunnel
Note: make sure this two lines are uncommented
Now let’s quickly start and stop the vncserver in order to get the default startup
configuration file ready. So ..
service vncserver start
Now you are ready to log in using the VNC client of your choise. I use RealVNC, but any
client would do the job.
If you didn’t use SSH tunneling for your setup then you can connect by providing
host:1 and your vnc password to any VNC client.
Now let’s add this server to the startup configuration:
ntsysv
Check vncserver and press ok. From now on your vnc server will start at boot time.
If you createad a secure vnc connection open a tunnel first
I love this lightweight desktop, it takes just about 100MB of RAM on the server and is not
wasting valuable resources.

Enabling tapping for Synaptics in debian

As some might already have notice, debian and debian flavors doesn’t usually come with
tapping support out of the box, and us, laptop linux users are left out with a primitive
way of using our touchpad.
Here is a quick trick that enables tapping and right click simulation by tapping in the
right corner of your Synaptics touchpad.
Open with your favorite text editor the following file: /usr/share/X11/xorg.conf.d/50-
synaptics.conf
To enable tapping, add the following line just before the “EndSection” of your default
Synaptic configuration:
Option “TapButton1” “1”
To enable right click simulation add:
Option “RBCornerButton” “3”
In the comments of this file you might notice that this file might be overwritten and you
should make a copy of it in /etc/X11/xorg.conf.d ; I recommend to do so, with: cp
/usr/share/X11/xorg.conf.d/50-synaptics.conf /etc/X11/xorg.conf.d/50-
synaptics.conf.
Note: you might need to create the /etc/X11/xorg.conf.d dicrectory with mkdir
/etc/X11/xorg.conf.d
For the record, my file contains the following lines:
# Example xorg.conf.d snippet that assigns the touchpad driver
# to all touchpads. See xorg.conf.d(5) for more information on
# InputClass.
# DO NOT EDIT THIS FILE, your distribution will likely overwrite
# it when updating. Copy (and rename) this file into
# /etc/X11/xorg.conf.d first.
# Additional options may be added in the form of
# Option “OptionName” “value”
#
Section “InputClass”
Identifier “touchpad catchall”
Driver “synaptics”
MatchIsTouchpad “on”
Option “TapButton1” “1”
Option “RBCornerButton” “3”
# This option is recommend on all Linux systems using evdev, but cannot be
# enabled by default. See the following link for details:
# http://who-t.blogspot.com/2010/11/how-to-ignore-configuration-errors.html
#
MatchDevicePath “/dev/input/event*”
EndSection
Section “InputClass”
Identifier “touchpad ignore duplicates”
MatchIsTouchpad “on”
MatchOS “Linux”
MatchDevicePath “/dev/input/mouse*”
Option “Ignore” “on”
EndSection