Switching a Primary User Between ThinLinc and xrdp from SSH
This document describes a practical way to run both ThinLinc and xrdp on the same Ubuntu 24.04 system while using a single primary account. The safest operating model on modern Ubuntu/GNOME is to allow only one graphical session at a time for that user, then switch cleanly from SSH when needed.[cite:46][cite:50][cite:53]
Why session switching is needed
ThinLinc supports multiple sessions per user in general, but Cendio notes that GNOME and some other desktop environments do not work well with multiple simultaneous sessions for the same user.[cite:46][cite:53] xrdp has a similar practical limitation on modern Linux desktops because systemd --user and desktop-session resources do not reliably support multiple full desktop sessions for one UID at the same time.[cite:50] For a primary account on Ubuntu 24.04, the reliable pattern is to terminate the existing remote desktop session before starting the other one.[cite:46][cite:50]
Recommended operating model
Use one account, but only one active GUI session for that account at a time.[cite:46][cite:50] Treat ThinLinc and xrdp as alternate entry points into the same desktop environment rather than as concurrent sessions.[cite:46][cite:53]
Recommended rules:
- Before connecting with xrdp, terminate any active ThinLinc session for that user.[cite:65]
- Before connecting with ThinLinc, terminate or drop any active xrdp session for that user.[cite:58][cite:64]
- If GNOME behaves strangely after switching methods, remove any leftover user-session processes and reconnect using only one method.[cite:46][cite:50]
Terminating ThinLinc sessions from SSH
ThinLinc provides server-side CLI tools for session management, which is the cleanest way to end sessions from SSH.[cite:61][cite:65]
List ThinLinc sessions
tlctl session list
This shows active ThinLinc sessions and is the best first step before terminating one.[cite:65]
Terminate all ThinLinc sessions for the current user
tlctl session terminate -g user "$USER"
This is the preferred method when switching the same Unix account from ThinLinc to xrdp.[cite:65]
Terminate a specific ThinLinc session
tlctl session terminate -s <session_id>
Use this when more than one session exists and only one should be removed.[cite:65]
Terminating xrdp sessions from SSH
Ubuntu includes xrdp-sesadmin, but the man page notes that kill:sid is not yet implemented, so the practical approaches are to restart the xrdp service or kill the user-owned session processes directly.[cite:68]
Fastest method: restart xrdp
sudo systemctl restart xrdp
Restarting the xrdp service disconnects active xrdp sessions and is often the fastest way to clear a stuck or unwanted xrdp session on a single-user workstation.[cite:58][cite:64]
Inspect xrdp-related processes for a user
ps -fu "$USER" | egrep 'Xorg|Xvnc|xrdp-chansrv|gnome-session|Xsession'
This helps identify leftover remote-desktop processes tied to the current user before killing them.[cite:58][cite:60]
Kill user-owned xrdp session processes
pkill -u "$USER" -f 'xrdp-chansrv|Xorg|Xvnc|gnome-session|Xsession'
If a session does not clear cleanly, a stronger version can be used:
pkill -9 -u "$USER" -f 'xrdp-chansrv|Xorg|Xvnc|gnome-session|Xsession'
This is more targeted than restarting the entire xrdp service, but it should be used carefully because it force-terminates the user's graphical processes.[cite:58][cite:60]
Switching workflows
ThinLinc to xrdp
- SSH to the Ubuntu host using the same administrative path normally used for server access.
- End the ThinLinc session for the primary account:
tlctl session terminate -g user "$USER"
- If the desktop does not start cleanly afterward, remove leftovers:
pkill -u "$USER" -f 'gnome-session|Xorg|Xvnc|Xsession'
- Start the RDP client and connect through xrdp using the primary account.[cite:65][cite:46][cite:50]
xrdp to ThinLinc
- SSH to the Ubuntu host.
- End the xrdp session with the simplest method:
sudo systemctl restart xrdp
- If necessary, verify that no user-owned GUI leftovers remain:
ps -fu "$USER" | egrep 'Xorg|Xvnc|xrdp-chansrv|gnome-session|Xsession'
- Connect with the ThinLinc client using the same primary account.[cite:58][cite:64][cite:65]
Suggested helper aliases
These aliases make switching faster from SSH shells.[cite:65][cite:64]
Add the following to ~/.bashrc or ~/.zshrc:
alias end-thinlinc='tlctl session terminate -g user "$USER"'
alias end-xrdp='sudo systemctl restart xrdp'
alias rdp-leftovers='ps -fu "$USER" | egrep "Xorg|Xvnc|xrdp-chansrv|gnome-session|Xsession"'
alias kill-rdp-leftovers='pkill -u "$USER" -f "xrdp-chansrv|Xorg|Xvnc|gnome-session|Xsession"'
Reload the shell:
source ~/.bashrc
These shortcuts are intentionally simple and fit a single-user workstation workflow better than heavier multi-user session management.[cite:58][cite:64][cite:65]
Operational notes
- Restarting
xrdpaffects all xrdp sessions on the host, so it is best suited to a workstation or lightly shared system.[cite:64] - ThinLinc's own session management commands are preferable to manual process killing because they preserve ThinLinc's internal session state more cleanly.[cite:61][cite:65]
- If the system is using GNOME, occasional odd behavior after repeated switching is usually a sign that multiple per-user graphical resources were left behind; clearing the old session before starting the new one is the key stability measure.[cite:46][cite:50][cite:53]