How To

Install R and RStudio Server on Ubuntu and Debian

R is the statistical language that refuses to die, and RStudio (now Posit) remains the IDE most data folks actually reach for. This guide walks through a full install of R and RStudio Server on Debian and Ubuntu, tested on Debian 13 trixie with Debian’s own R 4.5.0 package and the current RStudio Server build from Posit.

Original content from computingforgeeks.com - post 16652

The same steps cover Debian 12, Ubuntu 24.04 LTS, Ubuntu 26.04 LTS, and Linux Mint 22 (Wilma). RStudio Server ships one jammy amd64 .deb that the Posit JSON feed explicitly maps to both Ubuntu 22 and Ubuntu 24. That .deb also installs cleanly on Debian 12 and Debian 13, which is the coverage gap most competing guides miss. If you’re on the RHEL side, check the Rocky/AlmaLinux companion at Install R and RStudio Server on Rocky Linux 10 / AlmaLinux.

Tested April 2026 | Debian 13.0 “trixie” (kernel 6.12), R 4.5.0 from Debian main, RStudio Server 2026.04.0+526 “Globemaster Allium”

Prerequisites

  • Debian 13 / 12, Ubuntu 24.04 / 26.04 LTS, or Linux Mint 22 with root or sudo access
  • At least 2 GB RAM (4 GB recommended once you start installing CRAN packages; Hmisc, tidyverse, and anything Bioconductor can balloon RAM during compilation)
  • 5 GB free disk for R, dependencies, and the RStudio Server binary (~550 MB just for the .deb after unpack)
  • TCP port 8787 reachable from the networks that need access
  • A non-root user account on the box (RStudio Server authenticates against system users via PAM; root cannot sign in)

For a clean VPS to run this on, DigitalOcean gives you $200 over 60 days with the DigitalOcean referral credit, which covers the smallest droplet for a couple of months of experimentation. European users tend to prefer Hetzner Cloud for the price-to-performance ratio. A CX22 (2 vCPU, 4 GB) runs R workloads comfortably for about €5/month.

Step 1: Set reusable shell variables

Pull the reader-specific values into one place so the rest of the article pastes unchanged. Open a root shell and set them once per session:

export RSTUDIO_USER="rstudiouser"
export RSTUDIO_PASS="ChangeMe#Strong2026"
export RSTUDIO_PORT="8787"
export CLIENT_LAN="192.168.1.0/24"
export ADMIN_EMAIL="[email protected]"

Replace the password with something real (or generate one), adjust CLIENT_LAN to whatever subnet your users actually sign in from, and confirm the values stuck before moving on:

echo "User:   ${RSTUDIO_USER}"
echo "Port:   ${RSTUDIO_PORT}"
echo "LAN:    ${CLIENT_LAN}"

If any of those print empty, re-run the export block. The variables only live in the current shell, so a reconnect or sudo -i needs a fresh export. Password managers like 1Password make this less painful. Keep the credentials there and paste them into the export block rather than reusing a shell password you’ll forget by next week.

Step 2: Update the system and install build dependencies

R compiles native code whenever you install a package from source, and RStudio Server needs a handful of shared libraries that Posit builds against. Get everything in one apt pass:

apt-get update
apt-get install -y --no-install-recommends \
  dirmngr gnupg wget ca-certificates \
  gdebi-core libclang-dev libpq5 libssl3

On Debian 13 trixie, libssl3 is already in the base install; on Debian 12 bookworm it pulls in via dependencies. Ubuntu 24.04 “noble” and 26.04 use the same package names. Linux Mint 22, which is built on Ubuntu 24.04, is identical.

Step 3: Install R from the distro repository

Debian 13 ships R 4.5.0 in main as of April 2026, which matches the current upstream stable. For most users, the distro package is the right choice: apt upgrade tracks security fixes, dependencies resolve cleanly, and apt-get remove actually uninstalls cleanly later. Pull it in:

apt-get install -y r-base r-base-dev

Verify the install finished cleanly:

R --version

You should see the release name confirmed with the build date:

R version 4.5.0 (2025-04-11) -- "How About a Twenty-Six"
Copyright (C) 2025 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu

Debian 12 bookworm currently carries R 4.2.x in the default repo, which is stale. If you’re on bookworm and need a newer R, either enable bookworm-backports or follow the CRAN APT repo route below.

Optional: install the absolute latest R from CRAN

If you need the newest R point release the week it drops (typical for researchers chasing a package that requires R 4.6.x), CRAN maintains official APT repositories for Debian and Ubuntu. Fetch the signing key from Ubuntu’s keyserver, then add the repo scoped to your release codename:

gpg --keyserver keyserver.ubuntu.com \
    --recv-key '95C0FAF38DB3CCAD0C080A7BDC78B2DDEABC47B7'
gpg --armor --export '95C0FAF38DB3CCAD0C080A7BDC78B2DDEABC47B7' \
    | tee /etc/apt/trusted.gpg.d/cran_debian_key.asc

Then add the appropriate sources line (match your release):

# Debian 13 trixie
echo "deb http://cloud.r-project.org/bin/linux/debian trixie-cran40/" \
  > /etc/apt/sources.list.d/cran.list

# Debian 12 bookworm
# echo "deb http://cloud.r-project.org/bin/linux/debian bookworm-cran40/" \
#   > /etc/apt/sources.list.d/cran.list

# Ubuntu 24.04 noble
# echo "deb https://cloud.r-project.org/bin/linux/ubuntu noble-cran40/" \
#   > /etc/apt/sources.list.d/cran.list

apt-get update
apt-get install -y r-base r-base-dev

The CRAN repo overrides the Debian package with a newer build. Only pick this path if you have a specific reason. The distro package is less likely to break during unattended upgrades.

Step 4: Quick R smoke test

Before touching RStudio, confirm R itself runs a real workload. This one-liner prints the version, generates 100 random normals, and summarises them:

echo 'cat(R.version.string, "\n")
cat("Current time:", format(Sys.time()), "\n")
x <- rnorm(100)
cat("Mean of 100 normals:", mean(x), "\n")
cat("SD:", sd(x), "\n")' | R --no-save --quiet

Your output will have different random values but the structure should match:

R version 4.5.0 (2025-04-11)
Current time: 2026-04-18 23:31:17
Mean of 100 normals: -0.01888071
SD: 0.9694271

If that prints clean, R is healthy. Install a couple of real-world packages to flex the compile toolchain (this takes a few minutes on a small VPS because dependencies compile from source):

R -e 'install.packages(c("dplyr","ggplot2"), \
  repos="https://cloud.r-project.org", dependencies=TRUE)'

Then load them and poke at the built-in mtcars dataset to prove the pipeline end to end:

echo 'library(dplyr); library(ggplot2)
mtcars %>% group_by(cyl) %>% summarise(avg_mpg = mean(mpg), n = n())' \
  | R --no-save --quiet

The grouped summary comes back as a tibble:

# A tibble: 3 × 3
    cyl avg_mpg     n
  <dbl>   <dbl> <int>
1     4    26.7    11
2     6    19.7     7
3     8    15.1    14

R is ready. Now the IDE.

Step 5: Download and install RStudio Server

Posit publishes .deb builds on an Ubuntu 22.04 (jammy) and Ubuntu 24.04 (noble) base. Both reference the same binary: the noble-amd64 entry in Posit’s release feed points back to the jammy .deb, so there’s literally one file to download for all modern Debian and Ubuntu releases. This .deb installs on Debian 12, Debian 13, Ubuntu 22.04, Ubuntu 24.04, Ubuntu 26.04, and Linux Mint 22 without modification.

Fetch the current release directly from Posit’s S3 CDN:

cd /tmp
wget https://s3.amazonaws.com/rstudio-ide-build/server/jammy/amd64/rstudio-server-2026.04.0-526-amd64.deb \
  -O /tmp/rstudio-server.deb

For the latest stable version URL, check the Posit RStudio Server download page and replace the version string. Posit also publishes a JSON feed at https://dailies.rstudio.com/rstudio/latest/index.json that agents and automation scripts can parse to grab the current URL.

Install the .deb with apt-get so dependencies resolve automatically:

apt-get install -y /tmp/rstudio-server.deb

The post-install scriptlet starts the service and wires systemd in one pass. You should see it come up green:

Setting up rstudio-server (2026.04.0+526) ...
Created symlink '/etc/systemd/system/multi-user.target.wants/rstudio-server.service' → '/usr/lib/systemd/system/rstudio-server.service'.
● rstudio-server.service - RStudio Server
     Loaded: loaded (/usr/lib/systemd/system/rstudio-server.service; enabled; preset: enabled)
     Active: active (running) since Sat 2026-04-18 23:35:33 EAT; 1s ago

Confirm the version on disk matches what you downloaded:

rstudio-server version

The server reports its release codename alongside the build number:

2026.04.0+526 (Globemaster Allium) for Ubuntu Jammy

The “Ubuntu Jammy” string is the build platform, not a runtime check. RStudio Server works the same on the Debian and Ubuntu releases listed above.

Step 6: Create a login user

RStudio Server authenticates against the system’s PAM stack. That means every sign-in is a real Linux user with a real password, and root is blocked by default. Create a dedicated account for the IDE so nobody is tempted to reuse a sysadmin password:

useradd -m -s /bin/bash "${RSTUDIO_USER}"
echo "${RSTUDIO_USER}:${RSTUDIO_PASS}" | chpasswd
id "${RSTUDIO_USER}"

id confirms the user and its default group were created:

uid=1055(rstudiouser) gid=1056(rstudiouser) groups=1056(rstudiouser)

For multi-user setups (a shared team box, a classroom), repeat the useradd/chpasswd pair for each account. Each user gets their own home directory, their own R library path, and their own RStudio session.

Step 7: Open the firewall for port 8787

Debian and Ubuntu ship with ufw as the default user-facing firewall, inactive after a fresh install. If ufw is active, allow your LAN to reach the RStudio port:

ufw allow from "${CLIENT_LAN}" to any port "${RSTUDIO_PORT}" proto tcp
ufw status | grep "${RSTUDIO_PORT}"

The rule should show up right away:

8787/tcp                   ALLOW       192.168.1.0/24

On a cloud VPS, the equivalent is opening port 8787 in your provider’s security group. Do not open 8787 to 0.0.0.0/0 without TLS in front of it. Traffic to /auth-sign-in is plaintext HTTP by default, which means the password travels in the clear. Step 10 covers how to front RStudio with Nginx and Let’s Encrypt.

Before moving to the browser, double-check the server is listening on the expected port:

ss -tlnp | grep 8787

You should see rserver bound to 0.0.0.0:8787:

LISTEN 0  4096  0.0.0.0:8787  0.0.0.0:*  users:(("rserver",pid=83831,fd=11))

A quick curl to the auth endpoint returns 200, proving the sign-in page is being served:

curl -sI 'http://localhost:8787/auth-sign-in?appUri=%2F' | head -3

Response headers confirm the handler is alive:

HTTP/1.1 200 OK
Set-Cookie: rs-csrf-token=20a60609-ea73-47a5-b452-fa1cede775df; path=/; HttpOnly
Set-Cookie: csrf-token=20a60609-ea73-47a5-b452-fa1cede775df; path=/; HttpOnly

Here’s the version check and service state captured in one terminal shot:

R and RStudio Server version check on Debian 13

With R reporting 4.5.0 and rserver reporting 2026.04.0+526, both pieces are healthy on the same box. Time to sign in.

Step 8: Access the web interface

Open a browser to http://SERVER_IP:8787 from a client on the allowed subnet. RStudio Server redirects the bare root URL through a CSRF-protected sign-in page. The landing screen is minimal: username, password, a “stay signed in” checkbox, and the sign-in button.

RStudio Server sign in page served on port 8787

Sign in with the rstudiouser account created in Step 6. RStudio spins up an R session inside that user’s home directory, attaches a Files pane rooted at /home/rstudiouser, and opens the familiar four-pane IDE: Console (top left), Source (appears when you open a file), Environment/History (top right), Files/Plots/Packages/Help (bottom right).

The console prints the same R version you verified on the command line, and every package you installed earlier with install.packages() is immediately available. Here is the IDE running a real ggplot2 scatterplot against the built-in mtcars dataset:

RStudio Server IDE running ggplot2 scatter plot on Debian 13

If the IDE loads but the console sits stuck at “Loading workspace”, the R session is usually still byte-compiling cached code on first launch. Give it 10-20 seconds. If it stays stuck past a minute, jump to the troubleshooting section.

Step 9: Tune rserver.conf

The default config is fine for one or two users. For anything bigger, tweak /etc/rstudio/rserver.conf to cap memory per session and set the auth timeout to something sane for a production box. Open it in your editor:

nano /etc/rstudio/rserver.conf

A reasonable starting config looks like this:

# /etc/rstudio/rserver.conf
www-port=8787
www-address=0.0.0.0

# Require a fresh sign-in after this many minutes of inactivity
auth-timeout-minutes=60
auth-stay-signed-in-days=7

# Block the login if the user's shell isn't interactive
auth-required-user-group=rstudio-users

# Cap concurrent sessions per user
max-sessions-per-user=2

If you used the auth-required-user-group line, create the group and add your RStudio users to it before restarting the service (otherwise everyone gets locked out):

groupadd -r rstudio-users
usermod -a -G rstudio-users "${RSTUDIO_USER}"

Session-level knobs live in /etc/rstudio/rsession.conf. Two entries are worth setting on any shared box:

# /etc/rstudio/rsession.conf
session-timeout-minutes=120
session-default-working-dir=~/projects

Apply the changes:

systemctl restart rstudio-server
systemctl status rstudio-server --no-pager | head -5

A broken config keeps the service from starting. If systemctl status shows red, check /var/log/rstudio/rstudio-server/rserver.log for the exact line number.

Step 10: Put Nginx and Let’s Encrypt in front

Plaintext passwords on port 8787 are fine for a laptop-on-laptop session, not fine for anything else. Front RStudio with Nginx and terminate TLS with Let’s Encrypt. Point a DNS A record (any provider works; this is the standard HTTP-01 challenge flow) at the server’s public IP, then install Nginx and certbot:

apt-get install -y nginx certbot python3-certbot-nginx

Create a vhost for the RStudio hostname. Use a placeholder that gets substituted from your shell variable:

export RSTUDIO_DOMAIN="rstudio.example.com"
cat > /etc/nginx/sites-available/rstudio <<'NGINX'
server {
    listen 80;
    server_name SITE_DOMAIN_HERE;

    location / {
        proxy_pass http://127.0.0.1:8787;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 20d;
    }
}
NGINX

Substitute the real hostname from your shell variable, enable the site, and ask certbot to issue and auto-install the certificate:

sed -i "s/SITE_DOMAIN_HERE/${RSTUDIO_DOMAIN}/g" /etc/nginx/sites-available/rstudio
ln -sf /etc/nginx/sites-available/rstudio /etc/nginx/sites-enabled/rstudio
nginx -t
systemctl reload nginx

certbot --nginx -d "${RSTUDIO_DOMAIN}" \
  --non-interactive --agree-tos --redirect -m "${ADMIN_EMAIL}"

Certbot rewrites the vhost, adds the listen 443 ssl block, installs the cert, and sets an HTTP-to-HTTPS redirect. Verify renewals work:

certbot renew --dry-run

With Nginx in front, close 8787 on the firewall to force all traffic through 443:

ufw delete allow from "${CLIENT_LAN}" to any port "${RSTUDIO_PORT}" proto tcp
ufw allow 'Nginx Full'

For deeper Nginx tuning (worker_connections, gzip, HTTP/2), see Install and configure Nginx on Ubuntu and Debian. If you need the DNS-01 challenge instead (private server behind NAT, or wildcard cert), certbot ships plugins for Cloudflare, Route 53, DigitalOcean, Google Cloud DNS, Linode, OVH, and RFC2136. Swap --nginx for the matching --dns- plugin and supply your provider’s credentials file.

Production hardening notes

A few things worth doing before this box holds anything you care about:

  • Dedicated RStudio users only. Do not reuse the sysadmin login. Create per-analyst accounts, add them to rstudio-users, lock rstudio-users out of sudo. Separation of duties by Unix group.
  • Disable password auth if you can. Posit Workbench (the commercial tier) supports SAML, OIDC, and LDAP for free-of-support auth. Open-source RStudio Server is PAM-only, so if you want single-sign-on you either upgrade or put an auth proxy like Authelia in front.
  • Limit outbound network. R’s install.packages() hits CRAN mirrors, and malicious packages have shipped before. On a hardened box, pin a single CRAN mirror (options(repos = c(CRAN = "https://cran.r-project.org")) in Rprofile.site) and egress-filter everything else.
  • Rotate passwords. RStudio doesn’t enforce rotation. Set a PAM policy (libpam-pwquality) or tie accounts to an external directory.
  • Capture real audit logs. Session events land in /var/log/rstudio/rstudio-server/ and per-user sessions in ~/.rstudio/log/. Ship both to your SIEM; they record login IPs, session duration, and file-manager actions.
  • Back up home directories. R projects and CRAN libraries live under /home. If you’re running on a cloud VPS, a daily snapshot is cheap insurance; on bare metal, rsnapshot or restic to S3 works fine.

For teams that also need a full Python data stack on the same box, pair this setup with Install Python on Debian and Why data scientists use Jupyter notebooks so R and Python live side-by-side. Heavier analytics pipelines are typically split off to Apache Spark on Debian 13 / Ubuntu 24.04. CI-driven R work integrates well with Jenkins on Ubuntu and Debian. For a Posit alternative geared at commercial Python/R development, JetBrains DataSpell is worth evaluating.

Troubleshooting

Browser redirects to /unsupported_browser.htm

Headless curl and some older browsers hit the root path, get a 302 to /unsupported_browser.htm, and never see the login form. This is RStudio’s browser-fingerprint check. For automation or headless screenshots, hit /auth-sign-in?appUri=%2F directly. Real browsers (Chrome 110+, Firefox 115+, Safari 16+) never trip this.

“Error: FATAL: unable to start session”

The rserver process can start but the rsession can’t. This almost always means the target user’s home directory is missing, unwriteable, or owned by root. Check with ls -ld /home/${RSTUDIO_USER}; it must be owned by the user and mode 700 or 755. If you used useradd without -m, no home was created. Fix with mkhomedir_helper ${RSTUDIO_USER} or delete and recreate with useradd -m.

Port 8787 listening but sign-in page never loads

On cloud VPS providers, the OS firewall (ufw) is open but the provider’s network security group blocks 8787. Test from the same LAN the server is on; if that works, the block is in the cloud console, not on the VM. Hetzner’s cloud firewall, DigitalOcean cloud firewalls, and AWS security groups all need an explicit allow for 8787 until you put Nginx on 443 in front.

“Error in install.packages: package ‘X’ is not available for R 4.5.0”

Either the package was renamed upstream, is no longer on CRAN, or your repo string is broken. Run options()$repos inside R to confirm you’re pointing at a live CRAN mirror. If it shows @CRAN@, add options(repos = c(CRAN = "https://cloud.r-project.org")) to ~/.Rprofile.

Service active but 8787 unreachable from LAN

Check www-address in /etc/rstudio/rserver.conf. If it’s set to 127.0.0.1, the server only listens on loopback. Change to 0.0.0.0 (bind everywhere) or to the LAN IP explicitly, then systemctl restart rstudio-server.

Version notes across Debian and Ubuntu

Because RStudio Server ships one .deb that Posit’s own release feed maps to multiple Ubuntu codenames, the same file works across several distros. The table below shows the package names and R versions on each supported release as of April 2026:

ReleaseR version in default repoRStudio Server .debNotes
Debian 13 trixie4.5.0 (main)jammy amd64Tested in this guide
Debian 12 bookworm4.2.2 (main); 4.5.x via backports or CRANjammy amd64Use CRAN repo for newer R
Ubuntu 26.04 LTS4.5.x (universe)jammy amd64 (via noble mapping)Same steps apply
Ubuntu 24.04 LTS noble4.3.x (universe); 4.5.x via CRANjammy amd64 (explicit noble mapping in Posit feed)Enable universe if missing
Linux Mint 22 Wilma4.3.x (universe)jammy amd64Ubuntu 24.04 base; use noble CRAN repo if you need latest R

Where to go from here: if you need a RHEL-based equivalent (Rocky Linux, AlmaLinux, or enterprise RHEL), the Rocky/Alma counterpart guide covers EPEL, CRB, SELinux ports, and firewalld. For a broader post-install checklist on this box, run through Things to do after installing Debian 13 trixie before exposing the server to real users.

Related Articles

Automation Install Jenkins on Ubuntu 26.04 LTS Desktop Install Cinnamon Desktop on Ubuntu 22.04 or Ubuntu 20.04 Desktop Install Deepin Desktop Environment on Ubuntu 22.04|20.04 Containers MicroK8s and k0s Kubernetes installation on Debian 12

13 thoughts on “Install R and RStudio Server on Ubuntu and Debian”

  1. No doesn’t work with Ubuntu 22.04. Starts but shows only empty window and cannot be closed. Tested on different laptops.

    Reply

Leave a Comment

Press ESC to close