Download of the day: VMware Player 2

Posted on in Categories Download of the day, Linux, Linux desktop, Windows, Windows server last updated May 31, 2007

VMware Player 2 is now available!

VMware Player enables anyone to easily run, evaluate and share software distributed as a virtual appliance on a Windows or Linux PC.

Virtual appliances are pre-built, pre-configured and ready-to-run software applications packaged along with an operating system in a virtual machine. You can choose from over 450 virtual appliances available for download on the VMware Virtual Appliance Marketplace at vam.vmware.com. Simply download and run the virtual appliance with VMware Player quickly and easily – no software installation or configuration needed 🙂

What’s new in VMware Player 2.0

* Experimental support for 2-way Virtual SMP assigns more than a single CPU to a virtual machine.
* Share data seamlessly between the virtual machine and host computer.
* Windows Vista support as a host and guest OS.
* Support for USB 2.0 devices allow you to use high speed performance peripherals like MP3 Players within your virtual machine.
* Broad host and guest OS support includes over 60 supported 32- and 64-bit guest OS’s.
* Appliance view allows you to start a virtual appliance and review brief description and other relevant information provided by the appliance author.
* New Home Page allows you to open existing virtual appliances or browse any of the 425 virtual appliances in the VMware Virtual Appliance Marketplace.

=> Download link

Download of the day Firefox 2.0.0.4 for Linux / Windows Vista

Posted on in Categories Download of the day, Linux, Linux desktop, Mozilla, OS X, Ubuntu Linux, UNIX, Windows last updated May 31, 2007

The award-winning Web browser is better than ever. Faster, safer, and easy to use, Firefox delivers a better Web experience and has been released a new version 2.0.0.4

What’s New in Firefox 2.0.0.4

=> Security update: Various security issues have been fixed.

=> Windows Vista support – More enhancements and fixes for Windows Vista are included,

=> And much more

Download Firefox 2.0.0.4

=> Visit official website to download firefox

Related:

=> How to install firefox-2.0.tar.gz in Linux

Howto: Connect MySQL server using C program API under Linux or UNIX

Posted on in Categories C Programming, FreeBSD, Gentoo Linux, Howto, Linux, MySQL, OpenBSD, RedHat/Fedora Linux, Solaris, Suse Linux, Tips, Ubuntu Linux, UNIX last updated May 31, 2007

From my mailbag:

How do I write a C program to connect MySQL database server?

MySQL database does support C program API just like PHP or perl.

The C API code is distributed with MySQL. It is included in the mysqlclient library and allows C programs to access a database.

Many of the clients in the MySQL source distribution are written in C. If you are looking for examples that demonstrate how to use the C API, take a look at these clients. You can find these in the clients directory in the MySQL source distribution.

Requirements

Make sure you have development environment installed such as gcc, mysql development package etc. Following is the list summarize the list of packages to compile program:

  • mysql: MySQL client programs and shared library
  • mysqlclient: Backlevel MySQL shared libraries (old libs)
  • mysql-devel: Files for development of MySQL applications (a must have)
  • mysql-server: Mysql server itself
  • gcc, make and other development libs: GNU C compiler

Sample C Program

Following instructions should work on any Linux distro or UNIX computer. Here is the small program that connects to mysql server and list tables from mysql database.(download link):

/* Simple C program that connects to MySQL Database server*/
#include <mysql.h>
#include <stdio.h>

main() {
   MYSQL *conn;
   MYSQL_RES *res;
   MYSQL_ROW row;

   char *server = "localhost";
   char *user = "root";
   char *password = "PASSWORD"; /* set me first */
   char *database = "mysql";

   conn = mysql_init(NULL);

   /* Connect to database */
   if (!mysql_real_connect(conn, server,
         user, password, database, 0, NULL, 0)) {
      fprintf(stderr, "%s\n", mysql_error(conn));
      exit(1);
   }

   /* send SQL query */
   if (mysql_query(conn, "show tables")) {
      fprintf(stderr, "%s\n", mysql_error(conn));
      exit(1);
   }

   res = mysql_use_result(conn);

   /* output table name */
   printf("MySQL Tables in mysql database:\n");
   while ((row = mysql_fetch_row(res)) != NULL)
      printf("%s \n", row[0]);

   /* close connection */
   mysql_free_result(res);
   mysql_close(conn);
}

How do I compile and link program against MySQL libs?

MySQL comes with a special script called mysql_config. It provides you with useful information for compiling your MySQL client and connecting it to MySQL database server. You need to use following two options.
Pass –libs option – Libraries and options required to link with the MySQL client library.

$ mysql_config --libs
Output:

-L/usr/lib64/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib64 -lssl -lcrypto

Pass –cflags option – Compiler flags to find include files and critical compiler flags and defines used when compiling the libmysqlclient library.
$ mysql_config --cflags
Output:

-I/usr/include/mysql -g -pipe -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing

You need to pass above option to GNU C compiler i.e. gcc. So to compile above program, enter:
$ gcc -o output-file $(mysql_config --cflags) mysql-c-api.c $(mysql_config --libs)
Now execute program:
$ ./output-file
Output:

MySQL Tables in mysql database:
columns_priv
db
func
help_category
help_keyword
help_relation
help_topic
host
tables_priv
time_zone
time_zone_leap_second
time_zone_name
time_zone_transition
time_zone_transition_type
user 

References:

  • MySQL C API – A must read – official MySQL C API documentation

nixCraft FAQ Roundup May 29, 2007

Posted on in Categories FAQ last updated May 29, 2007

Recently updated/posted Linux and UNIX FAQ (mostly useful to Linux/UNIX new administrators or users) :

Enjoy!

What is the most efficient Linux file system for laptops?

Posted on in Categories Ask nixCraft, File system, Howto, Linux last updated May 29, 2007

There is some debate going on and the question is:

What is the most efficient Linux file system for laptops?

I think ext3 doing well but again I don’t have complete answer here.

We have some smart people around here. So please add your thoughts and suggestion in comments. If you can’t offer a complete answer it’s still helpful to get things started and point people in the right direction for more information 🙂

What is Nokia Maemo Linux?

Posted on in Categories Debian Linux, Linux, Linux desktop, Linux Embedded devices, Linux portables last updated May 29, 2007

From the my mailbag:

A friend of mine was talking about Maemo Linux. Can you explain what is Nokia maemo Linux?

What is Nokia Maemo Linux?

The Nokia N800 Internet tablet is a wireless Internet appliance from Nokia. The N800 was developed as the successor to the Nokia 770. It is designed for:
a] Wireless Internet browsing
b] E-mail functions
c] Includes software such as Internet radio, an RSS news reader, image viewer and media players for selected types of media.

Maemo Linux is used in Nokia N800. It is a development platform for handheld devices. You can think Maemo as a desktop for handled device. It is modified version of Debian Linux. According to project webpage:

Maemo provides an open source development platform for Nokia Internet Tablets and other Linux-based devices. It is build from components widely used in open desktop and mobile systems. We strive to make maemo open, accessible and useful to all developers wanting to squeeze the possibilities of the mobile desktop and the Internet.

The maemo SDK contains the tools needed to create and port integrated applications, replicating the Internet Tablet environment in your PC. The Hildon Application Framework is a good entry point to understand the peculiarities of this platform. A shortcut for you to consider.

This website offers official documentation, tutorials, bug reporting tools and repositories of unstable versions for testing. It also provides services devoted to and maintained by the maemo community: software catalog, project hosting, documentation wiki, Planet news plus mail and IRC support channels.

You can purchase this cool toy N800 at Amazon! I’m going to get one before XMS 😀

Howto build an open source digital entertainment system using MythTV

Posted on in Categories GNU/Open source, Howto, Linux, Linux desktop, Linux portables, OS X, Ubuntu Linux, Windows, X server last updated May 28, 2007

MythTV is a GPL licensed suite of applications that, together, provide a complete home entertainment system. The system’s capabilities include television, movies, music, photography and the display of other information like weather and news. It has been developed using only open source components and works under a variety of operating systems from Linux to Mac OS X.

This TechBrief provides an introduction to the leading open source home media convergence system, Mythical TV, more commonly referred to as MythTV.

MythTV is a digital entertainment suite that is as sophisticated as any commercial system available on the market today. Part 1 serves as an introduction to MythTV and guide to install the latest development frontend and backend on Ubuntu Linux. It covers building the development branch of the project suite using the latest source. Due to the complexity and variations of hardware and software, this brief will only focus on North American service. Part 2 will focus on building and installing the complete set of official modules.

Howto use TrueCrypt to encrypt data under Linux and Windows

Posted on in Categories CentOS, Debian Linux, Download of the day, File system, Howto, Linux, Linux desktop, RedHat/Fedora Linux, Security, Sys admin, Tips, Windows last updated May 28, 2007

TrueCrypt is a free open source on-the-fly encryption program for Microsoft Windows XP/2000/2003/Vista and Linux oses.

Encryption algorithms supported by TrueCrypt include AES, Blowfish, CAST5, Serpent, Triple DES, and Twofish. It also allows the use of a cascade of different ciphers, for instance AES+Twofish+Serpent.

From the article:

Right now the newest version released is version 4.3. You can create an encrypted hard drive, a separate partition or a directory with TrueCrypt. It doesn’t encrypt simply the content of files but their names and the names of the directories they are in as well. Moreover there is no way to check the size of the encrypted directory/HDD/partition. TrueCrypt is available for Windows and Linux.

TrueCrypt Tutorial: Truly Portable Data Encryption

Howto optimize Apache and PHP for performance

Posted on in Categories Apache, Linux, Sys admin, Tips, Tuning, UNIX last updated May 28, 2007

Learn what slows Apache web server down, and how to get the most out of PHP.

Linux, Apache, MySQL, and PHP (or Perl) form the basis of the LAMP architecture for Web applications. Many open source packages based on LAMP components are available to solve a variety of problems. As the load on an application increases, the bottlenecks in the underlying infrastructure become more apparent in the form of slow response to user requests. The previous article showed you how to tune the Linux system and covered the basics of LAMP and performance measurement. This article focuses on the Web server components, Apache and PHP.

From the article:

Applications using the LAMP (Linux®, Apache, MySQL, PHP/Perl) architecture are constantly being developed and deployed. But often the server administrator has little control over the application itself because it’s written by someone else. This series of three articles discusses many of the server configuration items that can make or break an application’s performance. This second article focuses on steps you can take to optimize Apache and PHP.

This article focused on tuning the Web server, both Apache and PHP. With Apache, the general idea is to eliminate extra checks the Web server must do, such as processing the .htaccess file. You must also tune the Multi-Processing Module you’re using to balance the system resources used with the availability of idle workers for incoming requests. The best thing you can do for PHP is to install an opcode cache. Keeping your eye on a few resource settings also ensures that scripts don’t hog resources and make the system slow for everyone else.

Tuning LAMP systems, Part 2: Optimizing Apache and PHP

BASH shell scripting tip: Set default values for variable

Posted on in Categories Howto, Linux, Shell scripting, Tips, UNIX last updated May 23, 2007

A shell variable may be assigned to by a statement using following syntax:
var=value

If value is not given, the variable is assigned the null string. In shell program it is quite useful to provide default value for variables. For example consider rsync.sh script:
#!/bin/bash
RSRC=$1
LOCAL=$2
rsync -avz -e ‘ssh ‘ [email protected]:$RSRC $LOCAL

This script can be run as follows:
$ ./rsync.sh /var/www .
$ ./rsync.sh /home/vivek /home/vivek

It will sync remote /home/vivek directory with local /home/vivek directory. But if you need to supply default values for a variable you can write as follows:

#!/bin/bash
RSRC=$1
LOCAL=$2
: ${RSRC:="/var/www"}
: ${LOCAL:="/disk2/backup/remote/hot"}
rsync -avz -e 'ssh ' [email protected]:$RSRC $LOCAL

: ${RSRC:=”/var/www”} ==> this means if the variable RSRC is not already set, set the variable to /var/www. You can also write same statement with following code:

if [ -z "$RSRC" ]
then
   RSRC="/var/www"
fi

You can also execute a command and set the value to returned value (output). For example if the variable NOW is not already set, execute command date and set the variable to the todays date using date +”%m-%d-%Y”:

#!/bin/bash
NOW=$1
....
.....
: ${NOW:=$(date +"%m-%d-%Y")}
....
..