ubuntu删除桌面操作

现场

PID     PPID    USER    %CPU  %MEM  RSS     VSZ     SWAP    NI  STAT  THR   ELAPSED     COMMAND         WCHAN
3412654 3412606 x99     180   0.8   324.2M  1.5G    0K      0   Sl    30    00:55       docker-buildx   futex_do_wait
2795    2331    gdm     0.7   0.6   246.4M  4.8G    42.6M   0   Sl+   28    50-22:04:46 gnome-shell     0
2025    1       root    0.2   0.5   233.6M  4.7G    16.6M   0   Ssl   44    50-22:04:48 dockerd         0
3016175 3016051 x99     0.1   0.1   64.9M   1.4G    33.4M   0   Ssl   8     14:41:03    gitea           futex_do_wait
3012708 3012683 root    0.5   0.1   57.1M   1.4G    5.4M    0   Ssl   8     14:45:41    mihomo          0
1600    1       root    0.2   0.1   54.4M   4.0G    4.5M    0   Ssl   40    50-22:04:51 containerd      0
511     1       root    0.0   0.1   46.1M   161.9M  1.1M    -1  S<s   1     50-22:04:58 systemd-journal 0
3012758 3012733 root    0.0   0.0   37.8M   10.7G   5.6M    0   Ssl   7     14:45:41    node            0
3191    2751    root    0.3   0.0   35.2M   1.5G    11.6M   0   Sl    10    50-22:04:46 tailscaled      0
1260112 1       root    0.0   0.0   32.2M   3.5G    4.8M    0   Ssl   33    27-14:39:10 snapd           0

x99@x99:/www/llama$ free -h
               total        used        free      shared  buff/cache   available
内存:          39Gi       2.5Gi        18Gi       444Ki        19Gi        36Gi
交换:         8.0Gi       670Mi       7.3Gi

停用桌面(设置层)

# 确认当前默认启动目标是图形界面
x99@x99:/www/llama$ systemctl get-default
graphical.target

# 设为多用户(纯命令行)模式
x99@x99:/www/llama$ sudo systemctl set-default multi-user.target
Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/multi-user.target.

# 重启才会生效

运行桌面(临时)

sudo systemctl isolate graphical.target

卸载桌面(持久)

sudo apt purge ubuntu-desktop gnome-shell gdm3
sudo apt autoremove