Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Linux Ask!

Nov 242010
 

Install RubyOnRails in Ubuntu

Answer:

In the last article, we talked how to install Ruby in Ubuntu. Now, we are going to install a very popular web framework for Ruby - RubyOnRails.

Firstly, you need to install RubyGems, a gem is a packaged Ruby application or library.

# sudo apt-get install rubygems

Then, we use the gem command to install rails.

# sudo gem install rails

That's all.

Nov 232010
 

Install Ruby in Ubuntu

Answer:

To install Ruby under Ubuntu, you need to type the commands below:

# sudo apt-get install ruby-full build-essential

The above command will install more than the Ruby interpreter, but they are useful when you want to play with RubyOnRails later.

Nov 222010
 

Initialize MySQL Data Directory

Answer:

When you compiled a new MySQL server, it is needed to create a default data directory.

To do so, you need to use the mysql_install_db command.

# bin/mysql_install_db --user=mysql \
    --basedir=/opt/mysql/mysql \
    --datadir=/opt/mysql/mysql/data

The --datadir is the target directory for storing the database files, where --basedir specifies the MySQL server base directory.

Reference: http://dev.mysql.com/doc/refman/5.0/en/mysql-install-db.html

Nov 212010
 

Write to the middle of a file in Perl

Answer:

To write to the middle of a text file, can be easily performed by Perl.

Assume the file has 10 lines, you want to replace the 5th line:

#!/usr/bin/perl
use strict;
use Tie::File;

my $file = 'foo.txt';

tie @array, 'Tie::File', $file or die "Cannot open $file \n";

@array[4] = "Replaced!\n";

That's easy?