Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Thursday, March 15, 2012

Installing ruby on rails (ruby version 1.9.3, rails version 3.2.2) on Ubuntu Lucid LTS 10.04

The post shows a step-by-step installation of the Ruby on Rails on Ubuntu 10.04 LTS.

1. install build essential, github and 

sudo apt-get install build-essential

2. install rvm (which includes ruby 1.9.3 and gem 1.8.19)

bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
source ~/.bashrc
rvm requirement -- install output required libraries by copy and paste the output text
rvm install 1.9.3  -- it takes a while


3. install rails


copy and paste the text below at the end of ~/.bashrc: 
[[-s "$HOME/.rvm/scripts/rvm"]] && . "$HOME/.rvm/scripts/rvm" 

source $HOME/.bashrc

check the successful installation of rvm:
type rvm | head -1
output should be 'rvm is a function'

gem install rails --include-dependencies


Congratulations! You have successfully installed Ruby on Rails!

Thursday, December 1, 2011

Linux and Java: Disk usage, Memory check, JVM virtual memory, Processor Info, Kernel Info

Check disk usage:
df -h

Check file size in a directory
du -sh *


Check memory usage, display total memory in MB:
free -t -m


Set JVM virtual memory:
java -jar -Xms128m -Xmx512m bigapp.jar

Processor Info:
cat /proc/cpuinfo

Kernel version:
uname -r

Tuesday, August 16, 2011

How to remove ^M from file using VI

Sometimes DOS files have "^M" at the end of each line, which causes problem for perl to read lines correctly.
We can use VI to remove these annoying ^M.

=============Using VI================

Type the following command at the terminal.

vi file_name.txt


Basically vi is the name of a text editor under linux/mac.
After issuing this command, you should be able to see the command window showing the content of the file.

Next step is to remove the annoying ^M at the end of each line.
Type the following command in VI editor. Do not miss the semi-colon at the begining.

:%s/[ctrlkey+v and ctrl-key+M]/\r/g

You should be able to see the following at the left-bottom corner of the command window:
:%s/^V^M/\r/g

The command above is meant to replace ^M with a new line symbol "\n".

Press enter and wait for a while for every occurrence of ^M to be replaced.
Depending on the size of your file, it can take a while and the screen appears frozen.
When the replacing is done, type the following command to save and exit from VI.

:x

Good luck!