网络知识 娱乐 Ubuntu子系统安装R与RStudio Server过程记录

Ubuntu子系统安装R与RStudio Server过程记录

R官网:https://www.r-project.org/

RStudio:https://www.rstudio.com/

环境:windows11子系统(Ubuntu)

R安装

添加R下载源

# update indicessudo apt update -qq# install two helper packages we needsudo apt install --no-install-recommends software-properties-common dirmngr# add the signing key (by Michael Rutter) for these repos# To verify key, run gpg --show-keys /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc # Fingerprint: E298A3A825C0D65DFD57CBB651716619E084DAB9wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc# add the R 4.0 repo from CRAN -- adjust 'focal' to 'groovy' or 'bionic' as neededsudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"

执行安装命令

sudo apt install --no-install-recommends r-base

输入R命令出现如下输出表示R安装成功

root@DKQNI3:~# RR version 4.1.2 (2021-11-01) -- "Bird Hippie"Copyright (C) 2021 The R Foundation for Statistical ComputingPlatform: x86_64-pc-linux-gnu (64-bit)R是自由软件,不带任何担保。在某些条件下你可以将其自由散布。用'license()'或'licence()'来看散布的详细条件。R是个合作计划,有许多人为之做出了贡献.用'contributors()'来看合作者的详细情况用'citation()'会告诉你如何在出版物中正确地引用R或R程序包。用'demo()'来看一些示范程序,用'help()'来阅读在线帮助文件,或用'help.start()'通过HTML浏览器来看帮助文件。用'q()'退出R.>

安装RStudio Server

下载安装包

https://www.rstudio.com/products/rstudio/download-server/


Download RStudio Server v2022.07.1+554


https://www.rstudio.com/products/rstudio/download-server/debian-ubuntu/


Install for Debian 10 / Ubuntu 18 / Ubuntu 20

sudo apt-get install gdebi-corewget https://download2.rstudio.org/server/bionic/amd64/rstudio-server-2022.07.1-554-amd64.debsudo gdebi rstudio-server-2022.07.1-554-amd64.deb



  • apt-get install安装gdebi-core包:

sudo apt-get install gdebi-core

  • wget下载rstudio-server安装包:

wget https://download2.rstudio.org/server/bionic/amd64/rstudio-server-2022.07.1-554-amd64.deb

  • 使用gdebi安装rstudio-server:

sudo gdebi rstudio-server-2022.07.1-554-amd64.deb

创建Ubuntu用户

默认不允许root用户登录rstudio-server

创建用户命令

  • useradd username不会在/home下建立一个文件夹username
  • adduser username会在/home下建立一个文件夹username
  • useradd -m username跟adduser一样,可以建立一个文件夹username

useradd -m username# username为创建的用户名,用于rstudio-server登录

修改用户密码命令

passwd username# 输入两遍密码即可

启动rstudio-server

rstudio-server start或重启rstudio-server restart

使用rstudio-server

打开浏览器输入地址:http://127.0.0.2:8787


127.0.0.1:8787


输入创建的Ubuntu用户名和密码登录



rstudio-server