Category Archives: Linux - Page 5

Java is unable to print to CUPS printers

If you’re using a CUPS printer on Ubunutu (or other linux distro) you may not print from Java.
There is a quick fix taken from here.
Add an /etc/cups/client.conf file containing:

Terminator – nice multi terminal application for Linux

Hi folks!

I’ve been using Terminator for quite a long time now and I find it very usefull.

Install it in Ubuntu by running:

There is a feature I would like to see in the future releases: saving the layout of the window or maybe a way to start the application with the predefined number of tabs.

Nokia N73 synchronization with opensync under Ubuntu 8.04

Yeap, Nokia N73 is a great phone and the N-Series PC Suite looks very nice.
But if you are using Linux, you can’t use the Windows PC Suite. Don’t hurry to fire up a Virtualbox or VMWare machine running Winblows just for that. My guess is is that if you are using an USB cable, it won’t work.
But the good news is that you can use OpenSync to synchronize your Nokia Symbian based phone, with your Evolution (Calendar, Tasks and Contacts) and/or with Google Calendar.
OpenSync act as an mediator between to entity to be synchronized, mapping the data between the entities types and synchronizing when possible the records exchanged, in case of conflict the standard behavior is to prompt the user for correction/decision.

I will explain the steps to you need to follow to sync a Nokia N73 (or any Symbian based phone) with Linux (I used Ubuntu 8.04), via bluetooth. Many credits going to Nailor which posted a nice guide on Ubuntu Forums.
1. Install the needed packages:

2. Configure msynctool:
You can configure opensync via a graphical interface using multisync-qad (using similiar settings as below) or you can use command line. Guide below is for commandline.

Add plugins to group. If you get errors, they are propably due to missing plugins so check you’ve installed all required plugins.

Next is the ‘trickiest’ part. Installed plugins need to be configured. First, you have to find your phone’s MAC. Use hcitool to do that:

It should return something like:

Now, configure the syncml-obex-client:

Replace the context of the configuration (should be open in separate editor after running previous command) with the following XML:

To find out what bluetooth_channel to use, run:

and look for SyncMLClient:

After configuring the syncml-obex-client it’s time to configure evo2-sync. Open configuration file with command:

It should look like this, so you don’t need to modify it:

4. Sync!
You should be good to go now, so you should try synchronizing:

My custom bash prompt (PS1)

Pimp out Linux / UNIX shell prompt!
You can find a nice guide here, and a nice collection here.
Here is mine:

Have fun!

aria2 – wget and curl replacement

aria2 is a command line utility for downloading files. The supported protocols are HTTP(S), FTP, BitTorrent (DHT, PEX, MSE/PE), and Metalink. To install it on Ubuntu, just type in terminal:

Enable/Disable GDM in Ubuntu

By default Ubuntu Loads Gnome GUI.
If you need to disable X.org / Gnome under Linux, so you can get text only login, this is the right guide to follow.

Using command line (CLI):
Ubuntu comes with rcconf and update-rc.d command.
rcconf allows you to control which services are started when the system boots up or reboots. It displays a menu of all the services which could be started at boot.
The ones that are configured to do so are marked and you can toggle individual services on and off.
Install rcconf:

Now start rcconf:

Now you will be prompted for the administrator password, this is necessary because the changes done with this tool will affect the whole system. After entering the administrator password, the following text based window is displayed on screen:rcconf
Next enable/disable GDM service by pressing space bar (check the checkbox) > Click OK to save the changes.

Using GUI tools:
The Services Administration Tool allows you to specify which services will be started during the system boot process.
You can type the command:

Or just click on System -> Administration -> Services
Again you will be prompted for the administrator password, this is necessary because the changes done with this tool will affect the whole system. After entering the administrator password, the following window is displayed:

ubuntu-linux-services
Make sure you remove GDM (Gnome login manager) by disabling the the checkbox and close the window.

Alternative method (wich seems to be a better approach):

Reset the root password on MySQL

Have you ever forgotten the root password on one of your MySQL servers?
This is a quick h00tow (how to) reset your MySQL root password. It does require root access on your server.

First things first. Log in as root and stop the mysql daemon. Now lets start up the mysql daemon and skip the grant tables which store the passwords.
mysqld_safe --skip-grant-tables
You should see mysqld start up successfully. If not, well you have bigger issues. Now you should be able to connect to mysql without a password.
mysql --user=root mysql

update user set Password=PASSWORD('YourNewRootPassword');
flush privileges;
exit;

If you are using Ubuntu 8.04 Hardy Heron, when you try to restart the mysql service using
sudo /etc/init.d/mysql restart
you’ll get an error like

error: 'Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)'

The debian_sys_maint user is the one used by mysql user system under debian sytems.In order to fix this (seeming to be a grant error) do like this:

Save the password of debian-sys-maint user which is localized in /etc/mysql/debian.cnf file (readable only by root):


sudo more /etc/mysql/debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = lP3Ufasdas3AVm7EdC
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
user = debian-sys-maint
password = lP3Ufasdas3AVm7EdC
socket = /var/run/mysqld/mysqld.sock
basedir = /usr
root@scrat:/etc/mysql#

Save somewhere this password, then connect on mysql under root:
mysql -u root -p

and execute following command:

GRANT ALL PRIVILEGES ON *.* TO ‘debian-sys-maint’@'localhost’
IDENTIFIED BY ‘your_password’ WITH GRANT OPTION;

Everything should be OK now.

There is another method to reset the root password on MySQL in Ubuntu:
sudo /etc/init.d/mysql reset-password

Sample firewall script for Ubuntu

I just thought that you might be interested in a small script you can use in Hardy Heron.

It uses the new UFW (Uncomplicated firewall) introduced in this new Ubuntu distro.

The script is well commented, so everything is easy to understand.

Here is the script:

You can modify it by adding/removing rules accordingly.

Backup your MySQL databases automatically with AutoMySQLBackup

If you are a MySQL user and you want to have a disaster recovery solution, or even as a simple backup, you can write small shell scripts based on mysqldump tool.

For this, you need AutoMySQLBackup. It doesn’t have any real requirements (mysqldump of course is needed – in any mysql client package – and gzip or bzip2 to compress the resulting file) and has all the features I was looking for in such a script.

AutoMySQLBackup has all the features I needed: it can backup a single database, multiple databases, or all the databases on the server; each database is saved in a separate file that can be compressed (with gzip or bzip2); it will rotate the backups and not keep them filling your hard drive (as normal in the daily backup you will have only the last 7 days of backups, the weekly if enabled will have one for each week, etc.). It has also some other features (check the project homepage for full details), that I am not using myself (like email logs for example), but other peoples might find interesting.

All you have to do is to modify a few things:

# Username to access the MySQL server e.g. dbuser
USERNAME=dbuser
# Username to access the MySQL server e.g. password
PASSWORD=password
# Host name (or IP address) of MySQL server e.g localhost
DBHOST=localhost
# List of DBNAMES for Daily/Weekly Backup e.g. "DB1 DB2 DB3"
DBNAMES="all"
# Backup directory location e.g /backups
BACKUPDIR="/var/backup/mysql"
# Mail setup
MAILCONTENT="quiet"

You can run the script manually but you will want to enable it in cron
and run daily.

Enabling Temperature Sensors in Ubuntu

Most computers these days come with a myriad of sensors to monitor the temperature of your computer. These sensors are generally located on the processor and the motherboard, and you might also have sensors on your video card. On top of that, all S.M.A.R.T-enabled hard drives have built-in temperature monitoring.
I can show you the steps to enable the temperature sensors in your computer in Ubuntu, or any other version of Linux.
1. Installing the sensor libraries
First thing’s first – you need to install the libraries that allow Linux to read your sensors. To do this, install the lm-sensors library, by running the command:
sudo apt-get install lm-sensors
This will install the libraries for your motherboard’s sensors. For your hard-disk sensors, you’ll want to install hddtemp:
sudo apt-get install hddtemp
In Ubuntu, the install will ask you several questions. Do not be scared, the default settings should work.

2. Running sensors-detect
Now that your sensor libraries are installed, you need to detect your sensors! Run the command:
sudo sensors-detect
Which will probe your system for sensors. Answer “YES” to all questions! Don’t just hit enter, type “YES”, because at the end there will be a question for which the default answer is “no”, and we’ll want to answer in the affirmative.
You willbe asked, at some point, “Do you want to add these lines to /etc/modules automatically? (yes/NO)” This is the question we want to make sure we answer YES to.

3. Loading the modules
Since we answered YES to the previous question, our sensor modules will be loaded by default the next time we start up. But since we don’t want to have to reboot, we’re going to use the information we got from the sensors-detect script to load the modules ourselves, this time only. Right above the last question will appear a list of modules that you should load, in the form of:

#—-cut here—-
# Chip drivers
smsc47m1
#—-cut here—-

You may have more, or different, items listed – that’s fine! What we want to do now, to load these modules, is use the modprobe command, as follows:
sudo modprobe [module name]

4. Monitoring the sensors!
Wow, that was a lot of work! Now, let’s see the rewards. On the command line, you can simply run:
sensors

However, we’d rather have a graphical interface for checking up on our hardware, so let’s install an applet for our Gnome desktop to keep an eye on our system’s temperature. Run the command:
sudo apt-get install sensors-applet
to install the applet. Now, add the applet by right-clicking on your desktop panel, selecting “Add to Panel,” and you will now see a “Hardware Sensors Monitor” applet in the System & Hardware section. Click and drag this to your panel to add it.