在 Ubuntu From Scratch 环境中安装桌面环境
一 前置条件与基础系统
sudo apt-get update && sudo apt-get install -y build-essential debootstrap fakeroot linux-image-generic linux-headers-genericmkdir -p ~/ufs && cd ~/ufs && sudo debootstrap focal ./base http://archive.ubuntu.com/ubuntu/sudo chroot ./baseapt-get update && apt-get upgrade -y && apt-get install -y ubuntu-standardnano /etc/netplan/01-netcfg.yaml(示例静态 IP),netplan apply;timedatectl set-timezone UTChostnamectl set-hostname ufsgrub-install /dev/sda && update-grub;adduser ubuntu && usermod -aG sudo ubuntu二 安装显示服务器与显示管理器
apt-get install -y xorg xserver-xorg-core xinitapt-get install -y lightdm lightdm-gtk-greeterapt-get install -y sddmsystemctl set-default graphical.targetstartx 启动会话(需配置 ~/.xinitrc)。三 安装桌面环境与登录切换
apt-get install -y ubuntu-desktopapt-get install -y kde-plasma-desktopapt-get install -y kde-fullapt-get install -y xubuntu-desktopapt-get install -y lubuntu-desktopsystemctl set-default graphical.target 并在会话选择器中选择。四 常见问题与验证
sudo apt install aptitude 后执行 sudo aptitude install kubuntu-desktop,按提示逐步解决依赖(可能需多次确认方案)。systemctl rebootecho $XDG_SESSION_TYPE(应显示 x11 或 wayland),loginctl show-session $(loginctl | grep $(whoami) | awk '{print $1}') -p Type