Installing R on Linux

R is very popular Statistical Analysis tool, scientific computing, general programming, and it also has packages for Machine Learning.

To install R on Linux (Ubuntu 14.04 LTS) follow the directions given at the CRAN Project page :

Open Gnome Terminal and issue these commands:

  •  sudo apt-get update   (This will update the lists of software for APT Tool)
  • sudo apt-get install r-base  (This will install r-base or the core R Packages)
  • Once R is installed. Just type R at the command prompt to work with the R Core packages !
  • To work with RStudio, a popular graphical IDE for R, just type rstudio at the GNome Terminal to launch it. RStudio provides R Code run, package updates, package install, and advanced debugging capabilities.

Screenshot 2015-04-06 20:55:02 Screenshot 2015-04-06 21:27:21

Enjoy !

#how-to, #linux, #r-language

Installing MongoDB on Linux

MongoDB installation on Linux (Ubuntu 14.04 LTS here) consists of running the following commands:

  • sudo apt-key adv –keyserver hkp:// –recv 7F0CEB10   (Installing GPG Key)

Executing: gpg –ignore-time-conflict –no-options –no-default-keyring –homedir /tmp/tmp.KLub4f6ZtK –no-auto-check-trustdb –trust-model always –keyring /etc/apt/trusted.gpg –primary-keyring /etc/apt/trusted.gpg –keyserver hkp:// –recv 7F0CEB10
gpg: requesting key 7F0CEB10 from hkp server
gpg: key 7F0CEB10: “Richard Kreuter <>” not changed
gpg: Total number processed: 1
gpg:              unchanged: 1

  • echo ‘deb dist 10gen’ | sudo tee /etc/apt/sources.list.d/mongodb.list

rahulsaini@rahulsaini-UBUNTU:~$ echo ‘deb dist 10gen’ | sudo tee /etc/apt/sources.list.d/mongodb.list
deb dist 10gen

  • sudo apt-get update

This sudo apt-get update command will update the package lists

To install a particular MongoDB version (here it is 2.6.1) run the command below

  • sudo apt-get install -y mongodb-org=2.6.1 mongodb-org-server=2.6.1 mongodb-org-shell=2.6.1 mongodb-org-mongos=2.6.1 mongodb-org-tools=2.6.1

Output will be something like this:

rahulsaini@rahulsaini-UBUNTU:~$ sudo apt-get install -y mongodb-org=2.6.1 mongodb-org-server=2.6.1 mongodb-org-shell=2.6.1 mongodb-org-mongos=2.6.1 mongodb-org-tools=2.6.1
Reading package lists… Done
Building dependency tree
Reading state information… Done

The following NEW packages will be installed:
mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell
0 upgraded, 5 newly installed, 0 to remove and 9 not upgraded.
Need to get 113 MB of archives.
After this operation, 284 MB of additional disk space will be used.
Get:1 dist/10gen mongodb-org-shell i386 2.6.1 [4,389 kB]
Get:2 dist/10gen mongodb-org-server i386 2.6.1 [9,308 kB]
Get:3 dist/10gen mongodb-org-mongos i386 2.6.1 [7,045 kB]
Get:4 dist/10gen mongodb-org-tools i386 2.6.1 [92.3 MB]
Get:5 dist/10gen mongodb-org i386 2.6.1 [3,652 B]
Fetched 113 MB in 4min 52s (386 kB/s)
Selecting previously unselected package mongodb-org-shell.
(Reading database … 243751 files and directories currently installed.)
Preparing to unpack …/mongodb-org-shell_2.6.1_i386.deb …
Unpacking mongodb-org-shell (2.6.1) …
Selecting previously unselected package mongodb-org-server.
Preparing to unpack …/mongodb-org-server_2.6.1_i386.deb …
Unpacking mongodb-org-server (2.6.1) …
Selecting previously unselected package mongodb-org-mongos.
Preparing to unpack …/mongodb-org-mongos_2.6.1_i386.deb …
Unpacking mongodb-org-mongos (2.6.1) …
Selecting previously unselected package mongodb-org-tools.
Preparing to unpack …/mongodb-org-tools_2.6.1_i386.deb …
Unpacking mongodb-org-tools (2.6.1) …
Selecting previously unselected package mongodb-org.
Preparing to unpack …/mongodb-org_2.6.1_i386.deb …
Unpacking mongodb-org (2.6.1) …
Processing triggers for man-db ( …
Processing triggers for ureadahead (0.100.0-16) …
Setting up mongodb-org-shell (2.6.1) …
Setting up mongodb-org-server (2.6.1) …
mongod start/running, process 12163
Setting up mongodb-org-mongos (2.6.1) …
Setting up mongodb-org-tools (2.6.1) …
Processing triggers for ureadahead (0.100.0-16) …
Setting up mongodb-org (2.6.1) …

Once MongoDB has been installed via Ubuntu APT, it will be updated frequently whenever newer versions arrive. In order to stop this, the following commands need to be run

  • echo “mongodb-org hold” | sudo dpkg –set-selections
    echo “mongodb-org-server hold” | sudo dpkg –set-selections
    echo “mongodb-org-shell hold” | sudo dpkg –set-selections
    echo “mongodb-org-mongos hold” | sudo dpkg –set-selections
    echo “mongodb-org-tools hold” | sudo dpkg –set-selections
  • Running MongoDB on Ubuntu (Linux)

    The MongoDB instance stores its data files in /var/lib/mongodb and its log files in /var/log/mongodb by default, and runs using the mongodb user account. You can specify alternate log and data file directories in /etc/mongod.conf. See systemLog.path and storage.dbPath for additional information.

    If you change the user that runs the MongoDB process, you must modify the access control rights to the /var/lib/mongodb and /var/log/mongodb directories to give this user access to these directories.

    sudo service mongod start

    Verify that the mongod process has started successfully by checking the contents of the log file at /var/log/mongodb/mongod.log for a line reading

    [initandlisten] waiting for connections on port <port>

    where <port> is the port configured in /etc/mongod.conf, 27017 by default.

    grep “waiting for connections on port” /var/log/mongodb/mongod.log

    rahulsaini@rahulsaini-UBUNTU:~$ grep “waiting for connections on port” /var/log/mongodb/mongod.log
    2015-04-01T22:27:45.674+0530 [initandlisten] waiting for connections on port 27017

    sudo service mongod stop

    Later, to stop MongoDB, press Control+C in the terminal where the mongod instance is running.

Enjoy !

#linux, #mongodb, #ubuntu