Friday, March 23, 2007

Setting up a printer with CUPS

Printing with Linux has never been easier with CUPS. I had bad experience long ago with lpr and lprng before when printer support was still scarce. Nowadays, setting up a printer on Linux is like a 'walk in the park'. Thanks to CUPS.

HP LaserJet 1020
In my office, my pc is the only pc running Linux (FC6 to be specific) and the others are (you bet!) Windows (XP Pro Edition to be specific). My colleague sitting nearest to me is a webmaster. Her pc is connected to an HP LaserJet 1020 printer and shared with name HP1020.

Get ready the required packages
I need to print to that printer. So I decided to install SAMBA and CUPS packages for that purpose.

Finding the driver
DON'T use the driver for this printer packaged with FC6. It won't work. I tried it but I think you must try it too to prove me wrong. Of course YMMV. The driver is here. Before that, you have to read what the author's have to say on the website. It's important!. Follow the instructions on how to compile and install the ICM and the firmware files. Included in the tarball is the PPD file for working with the printer.

Connect to the printer
Once all the above completed, add the printer to cups so that she knows where to send files for printing.

Put the name, location and description for the printer. At this stage, it won't set the 'real' things yet.


Select the device for the printer. It obviously "Windows Printer via SAMBA".

The device URI should be in this form : smb://servername/sharename or smb://Workgroup/servername/sharename. To know the sharename, you can use this command to list all shared folder on the server servername: smbclient -L servername

At this stage, click Browse button and find the PPD file in the folder where you extract the tarball. Find the folder named PPD in there and click on the file named HP LaserJet 1020.ppd or a file named after your printer model and then click Add Printer. Now you are done setting up the printer in CUPS system. To see whether the printer has been added to the system, click Printers tab. If it is listed, then you are now good to test the printer by clicking on Test Printer button. For now, the driver supports printing in Black and White only. Works are in progress though to support color printing.

Good luck.

Tuesday, March 13, 2007

Setting up webcam on Linux (ZC0301)


It was a rare occasion if I got my hand on a web camera. This time I borrowed it from my colleague. Last time I couldn't get it to work. I didn't remember why. But this time, it was easy as ABC.

Spec:
Model : Z-Star Microelectronics Corp. Havit 3808 (this is what it says on the tin)
Chipset : ZC0301 (from lsusb)

Last time I looked at http://zc0302.sourceforge.net/ for the driver. It has been inactive for a long time. Still so far, the driver for ZC0301 is still not supported.

This time: I looked at spcaxx project page at http://mxhaard.free.fr/spca5xx.html. The webcam I was using supported. As stated on the website, for Fedora Core 6 users like me can download the driver here. The driver is actually a kernel module and after installing it, you can load the module with modprobe : modprobe gspca

When done, open your kopete, and click Settings --> Configure.. --> Device and see whether it detects and display video from the webcam. Then you can enjoy webcam session with your friends and acquaintances.

Good luck!

Tuesday, February 27, 2007

postfix - mailbox size limit and message size limit

postfix is my MTA of choice. I use it for my mailserver because its simplicity , security and sendmail-compatible (the widely used smtp in the world but not as secure). It is also extensible by plugging other servers for various purposes (antispam, antivirus,database etc).

I had one problem with file attachment larger than 10MB. Users couldn't send it although I have setup squirrelmail (SM) to be able to attach files summed up more than 20MB and I had modified php settings as per here. The problem was not in SM setting. It was postfix. By default, attachment size that can be sent by postfix is 10MB ~ 10240000 byte. How did I know it? I looked in log file (for my system it is in /var/log/mail/errors. For other system, the file to look is /var/log/maillog). The line looked like this:

Feb 26 16:30:53 webmail postfix/sendmail[30775]: fatal: me@mymailserver.org(74): Message file too big


Solution
Open /etc/postfix/main.cf with a text editor of choice and find message_size_limit directive and change accordingly. If it is not there, add the directive like this:

message_size_limit = 20480000

This sets limit to 20MB.

Some other parameters you need to change are in file php.ini which is usually located in dir /etc. Set their parameters as above or higher values as below:

post_max_size = 20M
upload_max_filesize = 20M

reload or restart postfix when you're done:


service postfix reload

or

service postfix restart

There's also mailbox_size_limit directive. You need to change this if SM can not open mailbox sized more than 10 MB.

reference :
http://www.tek-tips.com/viewthread.cfm?qid=1073614&page=1

Sunday, February 25, 2007

Tips for MySQL

MySQL is the most popular database in the world. I'm not doubt about it. Most of forums, portals and web-based database applications use it as the back-end engine.

Some tips of using MySQL on Linux

Login to MySQL using mysql client in console/terminal:

mysql -u username -p dbname

or

mysql -u username -ppassword dbname

or (using current username to log in)

mysql -ppassword dbname

security tip: username root is the default administrator. Do not use it in a live environment. Create a new one and set the appropriate permission for it.

Create a new database:
mysqladmin -u username -ppassword create databasename

(username is the administrator username that able to create a new database ie root)

or you can log in to mysql using mysql client in console. Example:

//create table with myisam engine.

CREATE TABLE mytable (
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id),
value_a TINYINT
) TYPE=MYISAM


//create table with HEAP engine.

CREATE TABLE mytable (
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id),
value_a TINYINT
) TYPE=HEAP

Delete a database:
Login to mysql and issue command drop database databasename.

(Make sure you use usernames with correct priviledge to drop a database)

What is the size of my database?
database size = the sum of all table sizes + all index sizes
  1. Open a text editor (eg. Notepad)
  2. Copy and paste the code below into your text editor ( replace username, password and dbid accordingly):

    mysql database size

    if ($filesize < filesize ="">

    # in at least kilobytes.

    for ($i = 0; $filesize > 1024; $i++) $filesize /= 1024;

    $file_size_info['size'] = ceil($filesize);

    $file_size_info['type'] = $bytes[$i];

    return $file_size_info; } $db_server = 'mysqlhost'; $db_user = 'username'; $db_pwd = 'password'; $db_name = 'dbid';

    $db_link = @mysql_connect($db_server, $db_user, $db_pwd)

    or exit('Could not connect: ' . mysql_error()); $db = @mysql_select_db($db_name, $db_link) or exit('Could not select database: ' . mysql_error());

    // Calculate DB size by adding table size + index size:

    $rows = mysql_query("SHOW table STATUS"); $dbsize = 0;

    while ($row = mysql_fetch_array($rows)) {$dbsize += $row['Data_length'] + $row['Index_length']; } print "database size is: $dbsize bytes "; print 'or';

    $dbsize = file_size_info($dbsize); print "database size is: {$dbsize['size']} {$dbsize['type']}"; ?>


put this php script into your accessible directory. (taken from here).

Nice reading : Overcoming MySQL's 4GB limit by Jeremy Zawodny.

To know what engine your database is using:

SHOW TABLE STATUS FROM yourdbname

MySQL has support for ISAM,MyISAM , HEAP, BerkeleyDB and InnoDB database engine. Depending on how your MySQL packages are compiled, it may or may not support for all these engines.

Bear in mind that ISAM and MyISAM engines lack foreign key and transactional support. BerkeleyDb and InnoDB overcome that limitation. However, BerkeleyDB and InnoDB are much slower compared to ISAM and MyISAM. If your database is of type ISAM/MyISAM, fortunately you can convert it to InnoDB using this command:

ALTER TABLE isamtable CHANGE TYPE=InnoDB

or you can use utility mysql_convert_table_format :

mysql_convert_table_format --user=username --pasword=password --type=innodb databasename tables

(if tables is omitted, all tables will be converted. That means you can convert certain tables to InnoDB and leave the rest with ISAM. One database uses more than one engine. That's the flexibility MySQL provides. Flexibility is the key here.)

MySQL makes this happen with three steps. First, an exact copy of the table is created. Next, any incoming data changes are queued, while the copy is moved to the other engine. Finally, any queued data changes are committed to the new table, and the original one is deleted.


Thursday, February 15, 2007

yum - 'yummy' package management for Fedora Core

As a Mandriva (aka Mandrake) user, I used to use urpmi to install, urpme to remove and etc2 for package management. As a Slackware user, I used to use slapt-get and in Fedora, I am learning yum. I love it but in commandline. Why? because it is faster that way than using the gui front-end. I don't know why but they need to improve its speed.

Some useful examples of usage :

Check available updates (without installing anything) : yum check-updates
Check updates and install : yum -y check-updates
Search for a particular package using wildcard : yum list "ogg*"
Installing particular package : yum install ogg-vorbis.blablaba.fc6.rpm
Upgrading a package : yum update ogg-vorbis.blablaba.fc6.rpm

Default repositories provided by FC6 is good enough but lack of commercial and copyrighted packages. You need more than that. Notable repositories are freshrpms and livna. I personally added freshrpms as one of the repositories used by yum to install xmms-mp3, mplayer, dvdrip and some other packages. Thus enables me to hear mp3 and watch movies. I just found out that adding fedora's update-testing repository is risky. Don't add it unless you want to live at the bleeding edge and could afford to lose all your data. :)

How to add 3rd-party repos?
Usually there are instructions on the websites on how to add their repos into your system or you can read my article on how to add livna and kde repositories. I read somewhere to not add both livna and freshrpms repos. Add ONLY one of them or conflicts of packages will happen. You have been warned!.

To add freshrpms repo, just run this command as root:

yum install http://ftp.freshrpms.net/pub/freshrpms/fedora/linux/6/freshrpms-release/
freshrpms-release-1.1-1.fc.noarch.rpm (all in one line.)

Tuesday, February 6, 2007

On a quest to get a 3D desktop part 2



You might still wondering whether i am still on a quest to get a 3D desktop? Not really. After reading an article of Fedora Core 6 in LinuxFormat magazine, I thought I need to give it a try. Firstly, I tried it on a laptop with built-in graphic card Intel 915. It ran smoothly. 3D effects for compiz and beryl worked out of the box. I just had to activate it.

After too much coin tossing and coffee, I decided to give FC6 a try on my office's PC. After backing up all important files, I inserted the DVD and rebooted into the nice Fedora installer a.k.a anaconda. I decided to repartition my drive to give larger part for my / partition and created 3 more partitions for /home,/boot and of course a /swap. As a rule of thumb, /swap size is 2 times RAM size.

GNOME is some sort of 'official' window manager for Fedora and RedHat. That's why after booting into X, GNOME was loading. To get 3D effects, click on System -> Preferences -> Desktop Effects. This was compiz actually loading replacing metacity. Future release of GNOME and KDE will support 3D effects on the fly. As for time being, compiz or Beryl compositing window manager provides the effects. Beryl provides much more effects as anyone could imagine. Experiment it and you will be amazed what it can do. The 3D cube is superb!.

Now the quest has ended. The 3D desktop is mine!. Try it.

Some tips for beryl :
F9 or place mouse cursor at the topleft corner - tiled windows in a viewport
Ctrl+Alt+LeftArrow - spin cube to the left
Ctrl+Alt+RightArrow - Spin cube to the right
Ctrl+Alt+Shift+RightArrow/LeftArrow - Spin cube to the right or left with active window follows.
place mouse cursor at the bottomright corner - centers active window.

Wednesday, January 31, 2007

Google search tool collections



Google indexes and searches billions of webpages and is the premier search engine on the internet. A quick analysis of the search page essentials of Google Search and remember to set your preferences. is helpful to understand and analyze the search results.

Official Google Search Tools

Special Searches

  • Google Video - Search TV programs and videos
  • Google Image Search - comprehensive image search on the web
  • Google Music Search - search for music
  • Google Book Search - Search the full text of books (and discover new ones).
  • Google Catalogs - helps you browse and search merchant-provided catalogs
  • Froogle - Google's shopping search engine
  • Google News - Search and browse 4,500 news sources
  • Google Scholar - search for the most relevant research across the world of scholarly research.
  • Google Maps - View maps, get driving directions, and search for local businesses and services.
  • Google Public Service Search - offers educational institutions and non-profit organizations worldwide free SiteSearch, which enables users to search your website, and free WebSearch, which enables users to search the Internet.
  • Google's University Search - enables you to narrow your search to a specific school website for things like admissions information, course schedules, or alumni news.
  • Google Ride Finder - view taxi or shuttle locations in several cities.
  • Google Base - submit all types of online and offline content that is hosted and made searchable online.

Google Topic Specific Search

Google For Webmasters

  • Google AdSense for search - Opportunity to earn money by Google whenever your users click on the targeted Google adsense ads on search results pages.
  • Google Free - provide Google search results to users who want to search the web or just your website.
  • Site-flavored Google search - delivers web search results that are customized to individual websites.
  • Customizable Google Search - you can customize your results display to include background, text and link colors you select.
  • Google Search Appliance - is a hardware and software product designed to offer large businesses the productivity-enhancing power of Google search.
  • Google Mini â€" Google search for your website and intranet

Google Desktop Search Tools

  • Google Deskbar - Search using Google without opening your browser
  • Google Desktop - a desktop search application that provides full text search over your email, files, music, photos, chats, Gmail, web pages that you've viewed.

Google Mobile Search Services

Google Search Toolbars

Third party Google Search Tools

Search Google with Firefox Extensions

  • CustomizeGoogle - enhances Google search results by adding extra information (like links to Yahoo, Ask Jeeves, MSN etc) and removing unwanted information (like ads and spam).
  • Googlebar Lite - A light-weight Google search toolbar for Firefox.
  • GoogleTabs - Adds a context menu option to open Google search results in tabs.
  • Advanced Dork - Highlight a word or phrase, right click, and choose from over 15 Advanced Google Operators, A google search page is opened in either the same tab or a new tab, the results contained in the search will contain the highlighted text inside the chosen Operator.
  • GooglePreview - Inserts preview images (thumbnails) of web sites and Amazon products into the Google and Yahoo search results pages.
  • Feeling Lucky - Performs Google's "I'm Feeling Lucky" search with any selected text and opens the result in new a tab.
  • Aggregate Yahoo! and Google - Search Yahoo and Google simultaneously
  • GooglebarL10N - is the localized version of Googlebar with Menues & Texts in German, Italian or Spanish.
  • Google Advanced Operations Toolbar - provides a shortcut to some of Google's advanced search functions.

Google Page Modules / Scripts / Widgets / Bookmarklets

Multi Search Tools

  • Simply Google - search all Google services on one page. Lots of forms.
  • HotDaddy - search all Google services on one page. Lots of icons.
  • Google Total - search all Google services on one page. Drop down menu.
  • GahooYoogle - search multiple Google and Yahoo services together side by side.
  • Twingine - Google and Yahoo search side by side.
  • Soople - performs all advanced search functions of google in separate forms

Miscellaneous Google Search Tools

  • Google Cloud new1.gif - displays search results as a tag cloud
  • Babelplex - enables users to search Google's web index across two languages.
  • Google Current - airs every half hour on Current TV and provides a look at what the world is searching for on Google.
  • Googlewhack - a query consisting of two words (without quotation marks) entered into Google's search page that returns a single result.
  • Cookin' With Google - allows you to provide a list of ingredients and get back a list of recipes that Google finds for you.
  • Goofresh - is a way to search for sites added today, yesterday, within the last seven days, or last 30 days.
  • Google Fight - Compare the number of results for two competing keywords.
  • GoogleDuel - a popularity contest using the Google search engine.
  • Random Web Search - it generates a random word, then searches that word on the web using Google.
  • Googlematic - Enables searching of Google via AIM or MSN Messenger.
  • Googlism - will find out what Google.com thinks of you
  • Google Tool - Search multiple google datacenters simultaneously.
  • elgooG - a mirror image of Google
  • LostGoggles - adds search site preview images, Amazon pricing, site info links and the Open-in-New-Window-button. Formerly "More Google".
In the end, this amazing list of Google Web Search Features lists the many special features to help you to find exactly what you're looking for. Google Zeitgeist lists the current Google Search patterns, trends, and surprises.

Nvidia new hotplug feature on Linux

 If you use nvidia driver for your GPU, you probably wonder why in some config, you can't hotplug your second monitor. You need to reboo...