Tips
How Install Ubuntu inside Windows
Ubuntu is an easy to use and free operating system (based Linux) for use on personal computers. This section presents how to install Ubuntu inside Windows. For installing Ubuntu the following softwares are needed:

After installing and running the VirtualBox, you can create a new virtual machine(VM), as shown below:

In the next step, you need to assign the Ubuntu ISO file (which you download before ) to the VM. Select button, as shown below:

Now, the installation process can be started by click on the start button, as shown below:

Enjoy the Ubuntu OS inside your Windows :)

Back to top of the page
Ways to install a software in Ubuntu
  • APT protocol, or apturl, from a web browser: apturl works by default with Firefox. By clicking on a special link on a web page, the apturl protocol will launch the package manager to propose the installation of the package.
  • Via a graphical method: Ubuntu Software Center is a simple graphical way of installing and removing applications
  • Synaptic is a graphical front-end to apt-get command. Since Synaptic is no installed by default, it should be installed as shown follow:
    sudo apt-get install synaptic
  • Text based methods that require familiarity with the terminal. The apt-get program is a command-line package manager, which is easy to operate and in some cases is quicker to use and more powerful than the graphical tools.
    sudo apt-get install <package_name >
  • GDebi is a simple graphical tool to install .deb files. It automatically checks packages for their dependencies and will try to download them from the Ubuntu software repositories if possible. To install GDebi, open a Terminal and type:
    sudo apt-get install gdebi
  • dpkg is a command-line tool used to install .deb files. To install a package with dpkg, open a Terminal and type the following:
    cd directory
    sudo dpkg -i package_name.deb
Back to top of the page
Shell scripting in Ubuntu
A shell script contains a list of command lines which are written for the shell (in Unix, a shell is a command interpreter). Shell reads the commands from keyboard (shell terminal) or from file (shell script) and uses the system kernel to execute them.
There are two different shell syntax: Bourne shell and C shell. Each script in Unix begins with two characters (#!). For Bourne shell script the rest of the line will be /bin/sh.
#!/bin/sh
Variables do not need to be declared before using them. A variable is declared as below:
Name=Amir
To access the value of the variable later:
$Name
By default, variables in sh are local and for changing a local variable to an environment variable we can use export :
export Name
Special characters inside single quotation marks will be treated literally. But in double quotation special characters (such as $) are interpreted except backslash is used to escape a special character:
S = 'Hi $Name'
echo $S
The output is: Hi $Name
But in double quotation we have:
S = "Hi $Name"
echo $S
The output is: Hi Amir
If we use backslash before special character we will have:
S = "Hi \$Name"
echo $S
The output is: Hi $Name
For accessing to the arguments of script we use 1$ for first argument, 2$ for the second argument and ...
echo "First argument is $1"
echo "Second argument is $2"
0$ contains name of current script:
echo "Name of script is $0"
Number of arguments of script can be retrieved as:
echo "Number of arguments is $#"
String format of all arguments of script is:
echo "String format of all arguments is= $*"
If statement general format:
if [ condition1 ]; then
    command1
    command2
elif condition2 ; then
    command3
    command4
else
    command5
    command6
fi
Following example shows how if statement is used:
if [ $# = 1 ]; then
    echo "Number of parameters is one"
elif [ $# = 2 ]; then
    echo "Number of parameters is two"
else
    echo "Number of parameters is more than two"
fi
Note spaces before and after = are required.
While statement general format:
while condition ; do
    command1
    command2
done
Following example shows how while statement is used:
count=5
while [ $count -gt 0 ];do
    echo $count
    count=$(($count-1))
done
Note: Spaces before and after assign (=) is not allowed.
Back to top of the page
Linux commands
  • grep 'word' filename : search in the given file and returns lines which contain the word.
  • vertical bar (|) : connect the output of one command to the input of another command.
Permission format (Octal numbers) for a file:
rwx(owner)rwx(group)rwx(other users)
  • r:read
  • w:write
  • x:execute
For seeing the permission of a file:
ls -l file_name
For changing the permission of a file in Octal format:
chmod 750 myfile
In this example:
  • owner has rwx (7)
  • group has r_x (5)
  • other users have none (0)
For changing the permission of a file in Symbolic format:
chmod [references] [operator] [modes] myfile
Which references can be:
  • u:user
  • g:group
  • o:others
  • a:all
And operators can be:
  • + (adds)
  • - (removes_
  • = (exact)
And finally, modes can be:
  • r:read
  • w:write
  • x:execute
For example to give permission for executing a script to all users:
chmod a+x filename
Back to top of the page
Installing Erlang on the Ubuntu
Following packages need to be installed:
  • sudo apt-get install fop
  • sudo apt-get install m4
  • sudo apt-get install libncurses5-dev
  • sudo apt-get install openjdk-6-jdk
  • sudo apt-get install unixodbc-dev
  • sudo apt-get install g++
  • sudo apt-get install libssl-dev
  • sudo apt-get install xsltproc
  • sudo apt-get install perl
  • sudo apt-get install libwxbase2.8
  • sudo apt-get install libwxgtk2.8-dev
  • sudo apt-get install libgtk2.0-dev
  • sudo apt-get install libqt4-opengl-dev

After installing the prerequisite packages, run the following command from the terminal:

  • Download Erlang/OTP:
    wget http://erlang.org/download/otp_src_R15B.tar.gz
  • Unpack the downloaded file:
    gunzip -c otp_src_R15B.tar.gz | tar xf -
    or
    tar zxvf otp_src_R15B.tar.gz
  • Move into the base directory:
    cd otp_src_R15B
  • Set the environment variable (ERL_TOP) to find the absolute path of the installation:
    ERL_TOP="`pwd`"
  • Set the Erlang/OTP system in the $PATH:
    PATH="$ERL_TOP/bin:$PATH"
  • Note: Since in Unix the current directory is not in $PATH, for running a command, the shell looks up a list of directories as specified by the PATH variable. To run a command in the current directory without using $PATH, we need to call it as shown below:
    ./commandName
    For changing the $PATH variable permanently in Ubuntu you can add the new path to the /etc/environment file as shown below:
    gksudo gedit /etc/environment
  • Set the LANG variable:
    LANG=C; export LANG
  • Configure the build:

    ./configure

    If you want to install Erlang in a specific path, you can use prefix as shown below:

    ./configure --prefix=~/erlang

  • Build the Erlang/OTP package:
    make
  • Install the Erlang/OTP package:
    sudo make install
  • Run Erlang:
    erl
  • Exit from Erlang shell:
    q().
Back to top of the page
How install Riak
Since Riak is written in Erlang, so Erlang needs to be installed first.
Git command is also needed to be installed:
sudo apt-get install git-core
Now you can install Riak by following the below steps:
  • wget http://downloads.basho.com/riak/riak-1.1.1/riak-1.1.1.tar.gz
  • tar zxvf riak-1.1.1.tar.gz
  • cd riak-1.1.1
  • make rel
For running the Riak:
  • cd rel/riak/bin
  • ./riak start
  • To test the installed Riak:
    ./riak ping
    You should get "PONG" as a response
For joining the nodes to make a cluster, you need to update the IP address of each node in app.config and vm.args files.
These two files are placed at /rel/riak/etc
Back to top of the page
How to change the current user account in Linux
The su (short for substitute user) command makes it possible to change the current user without need to log out of the current session.
su myusername
Back to top of the page
Install R from source code
  • wget http://www.stats.bris.ac.uk/R/src/base/R-3/R-3.0.1.tar.gz
  • tar -xf R-3.0.1.tar.gz
  • ./configure --prefix=/home/ag275/R
  • make
  • make install