completely uninstall r linux
Categories:
Completely Uninstall R and RStudio from Linux
A comprehensive guide to thoroughly removing all R and RStudio components from your Linux system, ensuring a clean slate for new installations or system optimization.
Uninstalling R and RStudio from a Linux system can sometimes be more involved than simply running a single apt remove
or yum erase
command. Residual configuration files, libraries, and data can linger, potentially causing conflicts with future installations or consuming unnecessary disk space. This article provides a step-by-step guide to ensure a complete and clean removal of R, RStudio, and all associated components, preparing your system for a fresh start.
Understanding R and RStudio Components
Before diving into the uninstallation process, it's helpful to understand the various components that R and RStudio install on your system. R itself consists of the core R interpreter, shared libraries, documentation, and a vast collection of packages. RStudio, on the other hand, is an integrated development environment (IDE) that relies on an existing R installation. It has its own set of binaries, configuration files, and user-specific settings. Both can leave traces in system-wide directories and user-specific home directories.
Conceptual layers of R and RStudio on Linux
System-Wide R Removal
The first step is to remove the system-wide R installation. The commands for this will vary slightly depending on your Linux distribution (Debian/Ubuntu-based vs. Fedora/CentOS-based). This process typically involves removing the R base packages, R-dev packages, and any R-related libraries installed from your distribution's repositories.
Tab 1
language": "bash
Tab 2
title": "Debian/Ubuntu-based Systems",
Tab 3
content": "sudo apt autoremove --purge r-base r-base-core r-recommended r-cran-*-dev sudo apt clean sudo apt update" },
Tab 4
language": "bash
Tab 5
title": "Fedora/CentOS-based Systems",
Tab 6
content": "sudo yum remove R R-core R-devel sudo dnf autoremove # For newer Fedora versions sudo yum clean all" }
r-cran-*-dev
wildcard is powerful. Review the packages it suggests for removal before confirming, especially if you have other applications that might depend on R development files.Removing RStudio and its Residuals
After removing R, you should proceed with RStudio. RStudio is often installed from a .deb
or .rpm
package. Its uninstallation is usually straightforward, but residual configuration files and user data will need manual cleanup.
Tab 1
language": "bash
Tab 2
title": "Debian/Ubuntu-based Systems",
Tab 3
content": "sudo apt autoremove --purge rstudio
If RStudio was installed from a .deb file, you might need:
sudo dpkg -r rstudio" },
Tab 4
language": "bash
Tab 5
title": "Fedora/CentOS-based Systems",
Tab 6
content": "sudo yum remove rstudio
If RStudio was installed from a .rpm file, you might need:
sudo rpm -e rstudio" }
# Remove global RStudio configuration (if any)
sudo rm -rf /etc/rstudio
# Remove user-specific RStudio data and configurations
rm -rf ~/.rstudio-desktop
rm -rf ~/.local/share/rstudio
rm -rf ~/.config/rstudio
rm -rf ~/.Rprofile # Often contains RStudio-specific settings
rm -rf ~/.Renviron # Often contains RStudio-specific settings
# Remove RStudio desktop entries
sudo rm -f /usr/share/applications/rstudio.desktop
sudo rm -f /usr/local/share/applications/rstudio.desktop
Commands to remove RStudio's configuration and user-specific files
~/.Rprofile
or ~/.Renviron
, consider backing them up. They might contain custom settings you wish to preserve for future R installations, even if not RStudio-specific.Thorough R Package and Library Cleanup
Even after removing R and RStudio, R packages and libraries can remain in various locations. R packages are typically stored in system-wide libraries and user-specific libraries. A complete uninstallation requires cleaning these directories.
1. Step 1
Identify R library paths: Open an R console (if still accessible) and run .libPaths()
to see all library locations. Alternatively, check common locations like /usr/local/lib/R/site-library
or /usr/lib/R/site-library
.
2. Step 2
Remove system-wide R library directories: Carefully delete directories that contain R packages. For example: sudo rm -rf /usr/local/lib/R/site-library
and sudo rm -rf /usr/lib/R/site-library
.
3. Step 3
Remove user-specific R library directories: These are usually found in your home directory, often in ~/R/x86_64-pc-linux-gnu-library/
followed by the R version number. For example: rm -rf ~/R/x86_64-pc-linux-gnu-library/4.x
(adjust 4.x
to your R version).
4. Step 4
Clean R history and temporary files: Delete R's history file and any temporary directories: rm -rf ~/.Rhistory
and rm -rf /tmp/Rtmp*
.
5. Step 5
Remove R documentation and man pages: sudo rm -rf /usr/share/R
and sudo rm -rf /usr/share/man/man1/R*
.
# Example of removing common system-wide R library paths
sudo rm -rf /usr/local/lib/R/site-library
sudo rm -rf /usr/lib/R/site-library
# Example of removing user-specific R libraries (adjust version)
rm -rf ~/R/x86_64-pc-linux-gnu-library/4.3
# Remove R history and temporary files
rm -f ~/.Rhistory
sudo rm -rf /tmp/Rtmp*
Illustrative commands for cleaning R library directories and related files