Skip to content

Sudo Commands

Workbench runs as a system service, and its settings live in /etc/rstudio/, which only root can change. Most day to day administration therefore goes through sudo. This page lists the commands a sudo administrator runs, grouped by task, with what each one does.

In a regulated environment, sudo is also the audit point. Each call is logged with the user and the time, so the sudo log and the change ticket together show who changed what.

Service control

The rstudio-server command controls the service and talks to the running server.1 restart rereads every setting. reload rereads only some files, so it is the gentler choice when it applies.

Command What it does
sudo rstudio-server status Shows whether Workbench runs.
sudo rstudio-server start Starts Workbench.
sudo rstudio-server stop Stops Workbench.
sudo rstudio-server restart Restarts Workbench so it reads every setting.
sudo rstudio-server reload Rereads a subset of settings without a restart (see below).
sudo rstudio-launcher start Starts the Job Launcher. stop and restart work the same way.
sudo killall -HUP rstudio-launcher Makes the Launcher reread its configuration.
sudo systemctl edit rstudio-server Opens a systemd override file, used to set environment variables for the service.

A reload rereads logging.conf, env-vars, load-balancer, the nginx files, r-versions, profiles, and the license.1 The guide also marks rsession.conf and ip-rules as taking effect on reload. Most other settings need a restart, and most reloaded profile values apply only to new sessions.

The diagram below shows the choice between the two.

flowchart TD
    Edit(["Edit a file in /etc/rstudio/"]) --> Kind{"Reloadable file?"}
    Kind -->|"yes"| Reload("sudo rstudio-server reload")
    Kind -->|"no"| Restart("sudo rstudio-server restart")
    Reload --> New("New sessions use<br/>the new values")
    Restart --> New
    style Reload fill:#e8f1f8,stroke:#447099,stroke-width:2px,color:#1a1a1a
    style Restart fill:#e8f1f8,stroke:#447099,stroke-width:2px,color:#1a1a1a

Maintenance windows

offline suspends every RStudio Pro session and blocks new ones.1 Session data is saved, but running computations stop, so warn users before you start. Before a reboot, run force-suspend-all as the last step.

flowchart TD
    Start(["Window opens"]) --> List("i. active-sessions")
    List --> Off("ii. offline")
    Off --> Work("iii. Upgrade or edit")
    Work --> Reboot{"Reboot?"}
    Reboot -->|"yes"| Force("iv. force-suspend-all, then reboot")
    Reboot -->|"no"| On("v. online")
    Force --> On
    On --> Done(["Users resume sessions"])
    style Work fill:#e8f1f8,stroke:#447099,stroke-width:2px,color:#1a1a1a
Command What it does
sudo rstudio-server offline Suspends every session and blocks new ones. Running computations stop.
sudo rstudio-server online Brings Workbench back online.
sudo rstudio-server active-sessions Lists local R sessions. Sessions started through the Job Launcher are not included.3
sudo rstudio-server suspend-session <pid> Saves one session to disk and stops it.
sudo rstudio-server suspend-all Suspends every session.
sudo rstudio-server force-suspend-session <pid> Interrupts a running R command, then suspends the session.
sudo rstudio-server force-suspend-all Force suspends every session, typically before a reboot.
sudo rstudio-server kill-session <pid> Kills one session. Unsaved work is lost.
sudo rstudio-server kill-all Kills every session, with the same risk.

Kill is a last resort

kill-session and kill-all can lose data.1 Use them only for a session that does not respond to a suspend.

Users

Workbench keeps its own user records on top of the Linux accounts. Named user licenses count those records, and locking a user frees their seat while keeping the record.1

Command What it does
sudo rstudio-server list-users Lists users with status, admin flag, and IDs.
sudo rstudio-server user-info <user> Shows one user's record.
sudo rstudio-server add-user <user> --is-admin=false Adds a user record before first sign in.
sudo rstudio-server update-user <user> --email <address> Changes fields on a user record.
sudo rstudio-server set-admin <user> 1 Grants (1) or removes (0) Workbench admin rights.
sudo rstudio-server lock-user <user> Blocks sign in and frees the license seat.
sudo rstudio-server unlock-user <user> Allows a locked user to sign in again.
sudo rstudio-server delete-user <user> Removes a locked user's record.

Prefer locking to deleting in a regulated environment. A locked record keeps the user's history for the audit trail.

Licensing

The license manager is built into rstudio-server.2 The offline commands exist for servers that cannot reach the licensing service.

Command What it does
sudo rstudio-server license-manager status Shows the license state and expiry.
sudo rstudio-server license-manager activate <license-key> Activates a key online.
sudo rstudio-server license-manager deactivate Releases the key, before moving it to another server.
sudo rstudio-server license-manager --proxy=<url> activate <license-key> Activates through an HTTP proxy.
sudo rstudio-server license-manager status-offline Shows the offline license state.
sudo rstudio-server license-manager activate-offline-request <license-key> Writes a request file for an offline server.
sudo rstudio-server license-manager activate-offline <activation-file> Applies the activation file from Posit.
sudo rstudio-server license-manager deactivate-offline Writes an offline deactivation request.
sudo rstudio-server license-manager license-server <host> Points Workbench at a floating license server.
sudo cp -a <license-file>.lic /var/lib/rstudio-server/ Installs a license file instead of a key.

Diagnostics

verify-installation checks that Workbench is installed and working, and run-diagnostics collects a report to help troubleshoot problems.3 Stop Workbench before you run verify-installation.

Command What it does
sudo rstudio-server verify-installation Tests the install: a file permission summary for the invoking user, an R session, and a trial job if the Job Launcher is configured. The server must be stopped first.
sudo rstudio-server run-diagnostics Writes a report of config files, logs, and system information to /tmp/rstudio-diagnostics. --output-file=<path> writes it elsewhere.

Secrets and extensions

These commands protect passwords in the configuration and install editor extensions for every user.

Command What it does
sudo rstudio-server encrypt-password Encrypts a password, such as the database password, for a config file.4
sudo chmod 600 /etc/rstudio/database.conf Keeps the database settings readable only by root.4
sudo rstudio-server install-vs-code-ext Installs the extensions listed in vscode.extensions.conf.1
sudo rstudio-server install-positron-ext Installs the extensions listed in positron.extensions.conf.1

Summary

Most Workbench work is a reload or a restart after a config change, and a reload covers fewer files than you might expect. For maintenance, take the server offline and suspend sessions before you change anything. For users, lock rather than delete. The files these commands touch, with their owners and modes, are on Directories and Files.