Beginner guide

R and RStudio: Complete Installation Guide

Install the latest R from CRAN and RStudio from Posit on an Ubuntu-based Linux desktop, upgrade from old versions, and clean up leftover R package libraries.

Beginner Updated Linux Mint 22.3 Cinnamon (Ubuntu 24.04 Noble base); also tested on Zorin OS 18.1 Pro

Verified Working

Hardware context: Lenovo ThinkPad L14 Gen 2 (Intel i5-1135G7, 16GB RAM, Intel Iris Xe, 1366x768)

Overview

Ubuntu’s repositories freeze R at the distro-release version (4.3.x on Noble), which is too old for current packages. This guide installs the latest R from the official CRAN repository, cleans out the old-version package library afterwards, and installs the RStudio IDE from Posit’s official .deb.


The Problem (Windows User Perspective)

On Windows, you download an .exe, double-click, and you’re done. On Linux, if you run sudo apt install r-base, Ubuntu’s default repositories give you an outdated version (R 4.3.3 on Ubuntu 24.04 Noble). This version is too old for modern R packages and may break your workflow.

The fix: add the official CRAN repository, which always serves the latest R release. Then install RStudio from Posit’s official .deb.


System Information (Tested Setups)

Component Details
Machine Lenovo ThinkPad L14 Gen 2
OS (Primary) Linux Mint 22.3 Cinnamon (Ubuntu 24.04 Noble base)
OS (Secondary) Zorin OS 18.1 Pro (Ubuntu 24.04 Noble base)
R version 4.6.0 (2026-04-24) — “Because it was There”
RStudio version 2026.04.0+526
CRAN mirror cloud.r-project.org

Part 1 — Install the Latest R from CRAN

Why the default repos give you an old version

Ubuntu’s universe repository freezes package versions at distro release time. For Ubuntu 24.04 Noble, that means R 4.3.3 — released in February 2024. CRAN serves R 4.6.x, which includes bug fixes, performance improvements, and compatibility with current packages.

Step 1 — Install dependencies

sudo apt update
sudo apt install --no-install-recommends software-properties-common dirmngr wget
Package Purpose
software-properties-common Provides add-apt-repository
dirmngr GPG key management for secure package verification
wget Downloads files, including GPG keys

Step 2 — Add the CRAN GPG signing key

wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | \
  sudo gpg --dearmor -o /usr/share/keyrings/cran.gpg

Step 3 — Add the CRAN repository

Mint 22.x and Zorin OS 18.x are both based on Ubuntu Noble. Use the noble-cran40/ suite:

echo "deb [signed-by=/usr/share/keyrings/cran.gpg] https://cloud.r-project.org/bin/linux/ubuntu noble-cran40/" | \
  sudo tee /etc/apt/sources.list.d/cran.list

For other Ubuntu versions: Replace noble-cran40/ with jammy-cran40/ (22.04), focal-cran40/ (20.04), etc. Run lsb_release -cs to see your codename.

Step 4 — Install R and development packages

sudo apt install r-base r-base-dev

Installing r-base-dev alongside r-base is strongly recommended — it includes the C/C++/Fortran compilers (build-essential, gfortran, etc.) that many R packages need to compile from source.

Step 5 — Verify

R --version
# Should print: R version 4.6.x ... "Because it was There"

Note: Use two dashes — R --version not R -version. A single dash outputs an unknown option warning.

To launch the R console: type R and press Enter. To exit, type q().


Part 2 — Upgrade R When a Newer Version Exists

If you already have R installed from the default repos (4.3.3) and want to upgrade to the latest CRAN version:

Step 1 — Add the CRAN repository (if not already added)

If you haven’t already added the CRAN repository, add the GPG key and repo:

wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | \
  sudo gpg --dearmor -o /usr/share/keyrings/cran.gpg
echo "deb [signed-by=/usr/share/keyrings/cran.gpg] https://cloud.r-project.org/bin/linux/ubuntu noble-cran40/" | \
  sudo tee /etc/apt/sources.list.d/cran.list

Step 2 — Update the package list

sudo apt update

Step 3 — Upgrade R packages only

sudo apt install --only-upgrade r-base r-base-core r-base-dev

This pulls the newer versions from CRAN without touching other packages.

Step 4 — Verify

R --version
# Should now show R version 4.6.x

Part 3 — Clean Up Old R Package Libraries

When you upgrade R to a new major or minor version (e.g., 4.3 → 4.6), the system overwrites core files but leaves behind your user-installed R packages from the old version. These packages are incompatible with the new R and waste disk space.

Check what libraries exist

ls ~/R/x86_64-pc-linux-gnu-library/
# Example output:
# 4.3
# 4.6

Remove the old library folder

rm -rf ~/R/x86_64-pc-linux-gnu-library/4.3

Only remove folders for R versions you no longer use. Keep the current version (e.g., 4.6).

Clean up orphaned system-level packages

sudo apt autoremove --purge

This removes any system packages that were automatically installed as dependencies but are no longer needed.

After cleanup: You must reinstall your R packages inside the new version. Launch R and run install.packages("package_name") for each package you need.


Part 4 — Install RStudio

RStudio is a separate application from R itself. It provides the familiar IDE with the console, script editor, environment viewer, and plot pane.

Download and install from Posit

Posit publishes versioned .deb files — there is no “latest” URL. Check the current version on posit.co/download/rstudio-desktop, then download it:

# Example: version 2026.06.0+242 — replace with the current version from the page above
wget https://download1.rstudio.org/electron/jammy/amd64/rstudio-2026.06.0-242-amd64.deb -O /tmp/rstudio-amd64.deb

# Install
sudo apt install /tmp/rstudio-amd64.deb

# Clean up the downloaded file
rm /tmp/rstudio-amd64.deb

Version installed on the tested setup: 2026.04.0+526

Note: The URL uses jammy in the path, but the same .deb works on Noble-based distros (Mint 22.x, Zorin OS 18.x). Posit builds a single amd64 package for all Ubuntu 22.04+ systems.

Verify

rstudio --version
# Should print: 2026.04.0+526

which rstudio
# Should print: /usr/bin/rstudio

RStudio now appears in your application menu. Launch it, and it will automatically detect your R installation.

Updates are manual

Installing the .deb does not register an apt repository — RStudio does not auto-update with the system. When a new version ships, download and install the newer .deb the same way; it upgrades in place and keeps your settings.


Part 5 — Complete Removal

Remove R

sudo apt remove --purge r-base r-base-core r-base-dev r-recommended
sudo apt autoremove --purge

# Remove CRAN repository and key
sudo rm /etc/apt/sources.list.d/cran.list
sudo rm /usr/share/keyrings/cran.gpg

Remove RStudio

sudo apt remove --purge rstudio
sudo apt autoremove --purge

Clean up personal R files (optional — removes all R packages and settings)

rm -rf ~/R
rm -rf ~/.config/R
rm -rf ~/.local/share/rstudio
rm -rf ~/.config/rstudio

Quick Verification Checklist

# 1. R binary exists and reports correct version
R --version | head -1
# Expected: R version 4.6.x ...

# 2. R development tools present
dpkg -l r-base-dev | tail -1
# Expected: ii  r-base-dev ...

# 3. R starts interactively
R -q -e "print('Hello from R')"
# Expected: [1] "Hello from R"

# 4. RStudio installed
which rstudio
# Expected: /usr/bin/rstudio

# 5. CRAN repository configured
grep -r "cran" /etc/apt/sources.list /etc/apt/sources.list.d/
# Should show the cloud.r-project.org entry


Tested on Linux Mint 22.3 Cinnamon (also Zorin OS 18.1 Pro) · ThinkPad L14 Gen 2 (i5-1135G7, 16GB, Iris Xe) · May 2026 This guide is free to share, adapt, and republish with attribution.

Discussion

Continue the conversation about this guide. Loading comments connects to GitHub Discussions through giscus.

Open community discussions on GitHub

Check before you copy

This command needs care. Read its context, confirm the target and location, and keep a recovery path.

Copying does not run a command.