Amazing Linux User

A Ladakhi person with his laptop running fedora

A Ladakhi person with his laptop running fedora

A ladakhi person using fedora on this toshiba satellite is not something I expected to see, but here he is typing away in ladakhi. Apparently his friend installed fedora on his laptop for him to use and he has not yet had any problems with it. Linux is now really user friendly considering that this use is so completely not a technical person. I now have renewed respect for Jammu and Kashmir.

Solving Fedora Core 10 troubles, Network Interface with Static IP not brought up automatically

I installed fedora on another old system that was lying around.

Unfortunately the asus board that it came with an intel graphics bug due to which the gui based anaconda installer wasn’t diplaying correctly. To install in text mode, when the primary screen comes up and asks you to choose a boot option
select “Install or upgrade an existing system” and then press the tab key
You will see the following line

vmlinuz initrd=initrd.img

Add text to the line and make it

vmlinuz initrd=initrd.img text

Hit enter and Fedora install should start in text mode.

During the install, most of the setup went smoothly aside from the following hassles
1. A normal user account was not created
2. Fedora will not start up in Graphical mode.
3. The Static IP I set for my system works, but the ethernet interface is not brought up after boot. So after each boot I have to manually go to the system and do a
ifup eth0
Now that is not acceptable since I plan to put this in the basement anyway to run as a sync server. I can’t be running down each time. So lets solve #3 for now.

So here we go.
Firstly, turn off Network Manager and turn on network

chkconfig NetworkManager off
chkconfig network on

then edit the file /etc/ sysconfig/network-scripts/ifcfg-eth0 as required. On mine it looks like this

# Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+
DEVICE=eth0
HWADDR=–snipped–
ONBOOT=yes
BOOTPROTO=none
NETMASK=–snipped–
IPADDR=–snipped–
USERCTL=no
IPV6INIT=no
NM_CONTROLLED=no
GATEWAY=–snipped–
TYPE=Ethernet
DNS1=192.168.1.1

DNS1 and DNS2 can be whatever your DNS addresses are. HWADDR should be whatever your MAC address is and is probably already entered. NETMASK, IPADDR and GATEWAY are self explanatory. ONBOOT and NM_CONTROLLED need to be set as above for the interface to be brought up properly.

A shutdown -r now works ok and I am able to ssh back within seconds again after it reboots.
Next post on creating the new user account

Old/New Fedora 10 Server

There was an old machine lying around in the basement which noone wanted.  I had my eyes on it for a long time but it had only about 64 MB of RAM. Finally I begged for some RAM and got it from Binoy. And installed Fedora Core 10 on it the same day. Actually I had a lot of webapps and servers lying all over my network and wanted to put up all my personal and experimental stuff on one system.

Just the default install, then httpd, trac, subversion and glpi and it is still working like a charm. I backed up all data from my office servers and moved it there.

There were however a few issues that needed a quick sorting out. Hope it helps someone.

Most servers, even after install do not autostart on boot. You need to set the appropriate chkconfig entries. I had trouble with apache and mysql. However sshd starts automatically.

chkconfig –level 2345 httpd on
chkconfig –level 2345 mysqld on

Also the firewall port for http was disabled by default. Opening

system-config-firewall 

and enabling the port fixed it quickly.

Everything looks hunky dory. Now for some actual coding.

Solving the include_once error in Pear Mail

I have this hosting from hosting.india.to and helping on a friend’s community development initiative by setting up his website. It may soon move to careforindia.org.

During that, I set up a email form on my system, using PHP’s PEAR mail package to send mail. Though it worked fine on my own system, it didn’t on the hosting server. And no errors either.

First enabled the Error messages by putting this is the first line of the php file.

ini_set('display_errors','1'); ini_set('display_startup_errors','1'); error_reporting (E_ALL);

And then out popped the error.

Warning: Mail_smtp::include_once(Net/SMTP.php) [mail-smtp.include-once]: failed to open stream: No such file or directory in /home/username/php/Mail/smtp.php on line 206


Warning: Mail_smtp::include_once()[function.include]: Failed opening 'Net/SMTP.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/username/php/Mail/smtp.php on line 206


Fatal error: Class 'Net_SMTP' not found in /home/username/php/Mail/smtp.php on line 210

Apparently the basedir is set incorrectly and since I need to ask the hosting person to change the configuration, and to avoid the hassle, the simplest solution was to edit line 206 in /home/username/php/Mail/smtp.php to have

include_once '/home/username/php/Net/SMTP.php';

include_once 'Net/SMTP.php';

Yes, that is the full path.

Once I did that, I also got an error from Net/SMTP.php with it finding difficulty in locating Socket.php.

Same solution again and everything looks hunky dory. Clean up the error reporting and any debugging steps in between.

Oh, by the way, the site is at careforindia.jsemmanuel.com/donate.php and will soon be moved to www.careforindia.org

Drupal with Ubuntu – Simple Errors

Just installed Drupal a few hours ago. Had some minor hiccups, that took a couple of minutes to solve and thought I should document it.

1. On visiting localhost/drupal, it asks for languages. I selected English and in the next step, it was unable to find a working database configuration. Since I was using mysql, the solution was to install the following
sudo aptitude install php5-mysql
and restart apache2
sudo /etc/init.d/apache2 restart

2. Drupal installs but on the admin page complains about cron not working. A manual cron run fixed that. There is a button right under in the drupal warning, so that was simple.

3. Drupal compains on the admin page about gd library not being installed. I recollect that it was a graphics library of some kind, so off I go to aptitude again.
sudo aptitude install php5-gd
and restart apache. Everything hunky-dory. Back to playing with drupal.

Saving inserted jpgs from an Open Office Text Document

If you have an OpenOffice Text File which has images included in it, you may be confused as to how to save the images separately since Open Office does not give you the option to save the images to disk.

The simplest way is to save the pages as HTML. Click on File>Save As… or use the keyboard shortcut Ctrl-Shift-S to open the ‘Save As…’ dialog. In the bottom right part of the dialog, change the filetype to “Html Document(OpenOffice.org Writer)(.html)” and choose a location to save the html file and the images.

Open Office then creates a HTML file for the text in the file and saves the images separately as jpg files or in other formats as the case may be. However if the text file has a lot of images, it is better to save it in a new folder since OOWriter does not create a subfolder for the images.

Spell Check with Open Office 2.4 on Ubuntu 8.04

Apparently Open Office on Hardy Heron doesn’t come with Spell Check support out of the box. To enable it, you need to follow the following steps.

1. Open up Open Office Writer and goto the menu item “Install New Dictionaries” in File>Wizards.
2. A Read-Only File with text links to various languages opens. You will want to click on ‘English’

3. In the page that is displayed click on the button “Start DictOOo”
4. A dialog opens. (In case you are not able to view the windows fully, goto the Gnome Menu item “Appearance” in System>Preferences and set the Visual Effects to None to disable Compiz. Do once again from step 1.)

5. Click ‘Next’ Once and in the next screen, click on the button “Retrieve the List”. Open Office will connect to the dictionaries server and retrieve a list of dictionaries available. You are serially allowed to select the needed a) Spell Checker dictionaries in the first windows, b) The Hyphenation Dictionaries in the next window and finally the c) Thesarus Dictionaries.

6. Click Next Once while it downloads and displays information on the files to be installed. Click Next Once again for it to finally install the selected dictionaries.

That is possibly all you need to do to setup your dictionaries. Now go to the Open Office Menu, “Tools> Options”, Expand the “Language Settings” Section, select “Languages” and set “Default Language for Documents: Western” to English (USA) or English (UK).

When you select a language, if it has a tick mark with ‘ABC’ written to the left of the name of the language, the Dictionary for that language is installed. English(India) apparently doesn’t have a dictionary that can be downloaded yet.

Hope this helps. Let me know if the post was useful

Using Postgresql on Linux Mint/ Ubuntu

To install postgresql in Ubuntu or Linux Mint issue the command
$sudo aptitude install postgresql

Apt will download and install the necessary packages for you to use the postgresql server on your computer. However, postgresql will not be started immediately and if you use a command like psql to connect to it, you would probably get an error like:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

To start the server
$sudo /etc/init.d/posgresql start
However on my installation, I got an unknown command error. A bit of digging showed that there was no object called postgresql in the /etc/init.d directory. A quick ls at /etc/init.d showed that the link was actually postgresql-8.2. So if the previous command to start the server does not work, a bit of digging around would help to find the correct name.

Or of course, you could just restart the damn box. :-)

The server is now installed and started. We now have to create a user who can create a database. Or as postgresql is fond of saying, we need to define a role.
We log into the postgres profile of bash:
$su - postgres

Create a new user with database creation permissions as
$createuser -d -S -R -P graydot

You will be prompted for a password and then to reenter the password.

This command in effect tells postgresql to create a user of name ‘graydot’ with database creation permissions (-d), no super-user permissions (-D) and no permission to add roles (-R). The characters in small case for these option allot permissions and the capitals disable them. You should replace ‘graydot’ with your account user name.

We now check if the user has been created as required. Open the Sql prompt by using the command line tool ‘psql’
$psql postgres

At the prompt type
#select * from pg_shadow;

You should see something like

usename |usesysid | usecreatedb | usesuper | usecatupd |passwd | valuntil | useconfig
-----------+---------+-------------+----------+-----------+---------------+----------+-----------
postgres| 10 | t | t | t | | |
jsemmanuel | 16387 | t | f | f | md5114afb9a66 | |
(2 rows)

Exit psql by typing q
Logout out of the postgres profile by typing exit once

You are now in your user profile.

We now intend to create a database. The createdb command is used to create a new database in postgresql.
$createdb test_db

A new database of the name test_db is now created with the owner set to the currently logged in user.
Open the SQL prompt with the psql command.
$psql test_db

At the sql prompt, type 'l' to see a list of databases and their owners.

These are the basics of installing postgresql in the simplest way possible, upto the step of creating a database. I will be posting more as time permits. This will go up as a tutorial on my website when I finally get around to bringing it up.

Downloading Google Videos

I recently looked up a few videos by Randy Pausch, one was his ‘last lecture‘ and the other was on time management. The former was on Youtube and the other was on Google Videos.

The Youtube video was easy to download with youtube-dl on my Linux Mint Distro, (for how to do this, look up this simple tutorial) but I was stuck on the Google Video. Google Video apparently doesn’t have any download link and is not popular enough for developer to have tools designed for it yet.

I tried ‘Flash Video Resources Downloader’ firefox extension, but it open up a website which says that the flv file is not accessible. I finally had to give up on that and begin some frantic googling.

Jason Striegel at hackszine has made a cool script which seems to work excellent. I have the video downloading in the background at present. The file is 171 mb and the download speed is only like 15 kBps, so it is gonna take some time.

I just need to create a bookmark containing a certain javascript code. In Firefox, I cannot add a bookmark with the address entered manually, so i just bookmarked a page at random, then went to Bookmarks|Organize Bookmarks, selected the previously created bookmark and edited its properties to point to the script he mentions.

This is the exact command for Google Video
javascript:window.open(unescape(document.getElementById('VideoPlayback').src.match(/videoUrl=([^$)]*)/)[1]));

And this is for Youtube
javascript:window.open('http://youtube.com/get_video?video_id='+window.location.href.split('?')[1].match(/v=([^(&|$)]*)/)[1]+'&t='+document.getElementById('movie_player').src.match(/t=([^(&|$)]*)/)[1]);

On a side note, the file downloaded will be ‘get-video.flv’ at your default download location or wherever you ask it to download. I can foresee some problems with multiple video downloads in some situations, but firefox just appends a (#) at the end of the video so generally it should not be a problem.

Open Suse 10.2 dumping me back to the login screen

Open Suse 10.2 was giving me some trouble with KDE dumping me back to the login screen for my user account even though the password was correct. It went something like me typing the login id and password and pressing enter, the screen going black and then, poof! back to the login screen.

I was able to login as root, able to login through my user login on the console by pressing alt+ctrl + f1 and also was able to login to a new account I created by loging in to the gui and using Yast. With help from the www.thinkdigit.com/forum members and lots from Google, finally found this source
http://suseforums.net/index.php?showtopic=5073

It was pretty simple actually. Get into the console into the user’s home directory (the user who is unable to logon) and remove the file .xinitrc

rm .xinitrc

That’s it. Now I just tried logging in and everything is back to normal.