在 Debian 上“启动 LibreOffice”(你写的 liboffice 通常是 LibreOffice)有几种常见方式,下面按使用场景说明。
which libreoffice
# 或
dpkg -l | grep libreoffice
如果没安装,用以下命令安装:
sudo apt update
sudo apt install libreoffice
(只装部分组件可换 libreoffice-writer、libreoffice-calc 等)
libreoffice
或指定组件:
libreoffice --writer
libreoffice --calc
libreoffice --impress
打开某个文件:
libreoffice document.odt
libreoffice --headless --convert-to pdf file.docx
libreoffice --headless --accept="socket,host=127.0.0.1,port=2002;urp;"
⚠️ 需要 X 环境或 xvfb 时:
sudo apt install xvfb
xvfb-run libreoffice --headless --convert-to pdf file.docx
如果是 GNOME / KDE / XFCE:
libreoffice服务器一般不建议自启 LibreOffice
sudo apt install libreoffice-core
不要使用 root 直接跑 GUI:
sudo -u youruser libreoffice
如果你能说明:
我可以给你更精确的命令。