温馨提示×

centos中liboffice怎样打开

小樊
44
2026-09-24 14:01:21
栏目: 智能运维

在 CentOS 中“打开 LibreOffice”通常有两种含义:
1)启动 LibreOffice 图形界面程序
2)在命令行中使用(无界面 / 转换文档)

下面分别说明。


一、先确认是否已安装 LibreOffice

rpm -qa | grep libreoffice

或

which libreoffice
# 或
which soffice

如果没有输出,说明未安装。

安装 LibreOffice(CentOS 7 / 8 / Stream)

CentOS 7

sudo yum install libreoffice

CentOS 8 / Stream

sudo dnf install libreoffice

二、图形界面方式打开(有桌面环境)

如果你使用的是 GNOME / KDE 等桌面环境:

方法 1:命令行启动

libreoffice

或

soffice

方法 2:打开指定文件

libreoffice 文件名.docx

方法 3:开始菜单

  • 应用程序 → 办公 → LibreOffice

三、命令行 / 服务器方式(无桌面)

1)后台启动(无界面)

libreoffice --headless

2)将 Word 转 PDF(常见用法)

libreoffice --headless --convert-to pdf 文件名.docx

3)指定输出目录

libreoffice --headless --convert-to pdf --outdir /tmp test.docx

四、常见问题

1. 命令不存在

-bash: libreoffice: command not found

→ 没安装,或路径不在 PATH
可尝试:

/usr/bin/libreoffice

2. 服务器无图形界面

CentOS Minimal 安装没有桌面,不能直接“打开窗口”,只能用 --headless。

3. 中文乱码

需要安装中文字体:

sudo yum install wqy-zenhei-fonts

如果你能说明:

  • CentOS 版本(7 / 8 / Stream)
  • 是否有桌面
  • 是想“打开窗口”还是“命令行转文档”

我可以给你更精确的命令。

0 踩