Eric Guo's

Hoping writing JS, Ruby & Rails and Go article, but fallback to DevOps note

Install R & RStudio in Ubuntu


Install R in Ubuntu is extremely easy if you don’t meet any exception, but if you meet, then you’d better be a very advanced linux user :-)

Install R

Because the Ubuntu official source R version is usually half of years older than R-project official source, so it is recommanded to using official source to install the latest R system.

add R source
sudo vi /etc/apt/sources.list
# append below line to end of sources.list
# you can view mirror at
deb precise/
import the GPG key and install r-base
cd ~
gpg --keyserver hkp:// --recv-keys E084DAB9
gpg -a --export E084DAB9 | sudo apt-key add -
apt-get upgrade
apt-get install r-base
Install Oracle DB access package

ROracle is much faster compare with RODBC or RJDBC in performance, You can found new version of ROracle or DBI package in CRAN, it is also required you properly install the Oracle Instant Client.

manual install the ROracle
R CMD INSTALL DBI_0.3.1.tar.gz
R CMD INSTALL --configure-args='--with-oci-inc=/opt/oracle/instantclient_11_2/sdk/include --with-oci-lib=/opt/oracle/instantclient_11_2' ROracle_1.2-2.tar.gz
Install RStudio Server
Install RStudio Server
apt-get install gdebi-core
apt-get install libapparmor1 # Required only for Ubuntu, not Debian
gdebi rstudio-server-0.97.551-i386.deb
rstudio-server verify-installation
Do some RStudio Server setting
below setting depend on your system
echo 'rsession-memory-limit-mb=1000' > /etc/rstudio/rserver.conf
echo 'rsession-stack-limit-mb=4' >> /etc/rstudio/rserver.conf
echo 'rsession-process-limit=20' >> /etc/rstudio/rserver.conf
# Only pass below if you will using proxy mode
echo 'www-address=' >> /etc/rstudio/rserver.conf
groupadd rstudio
Setting the proxy server for RStudio server

This section is optional, assured already install nginx in server.

# do not forgot link to /opt/nginx/conf/vhosts
server {
listen 80;
server_name cvprstudio;
location / {
proxy_pass http://localhost:8787;
proxy_redirect http://localhost:8787/ $scheme://$host/;
Setting auto restart and PATH
ln -s /usr/lib/rstudio-server/extras/init.d/debian/rstudio-server /etc/init.d/rstudio-server
vi /etc/init.d/rstudio-server
# append below line to /usr/lib/rstudio-server/extras/init.d/debian/rstudio-server SCRIPTNAME
Now you can restart rstudio-server via standard init.d service way
/etc/init.d/rstudio-server restart
Add a user in RStudio
adduser --ingroup rstudio cindy
passwd cindy # setting password
Update package

Usually it is more good to upgrade the r-base in system wide packages instead of per user.

after run R in root console
update.packages() # select mirror to check