You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Terminator在bash脚本运行时报错找不到~/.config/terminator/config文件

问题解答

1. 检查terminator/config配置文件是否存在的方法

  • 先直接检查默认用户路径:
    执行命令 ls ~/.config/terminator/config,如果返回文件路径说明存在,返回No such file or directory说明当前用户的默认路径下不存在。
  • 全局扫描所有路径:
    执行命令 sudo find / -name "config" -path "*terminator*" 2>/dev/null,会扫描全磁盘所有符合规则的terminator配置文件,自动过滤权限报错信息。
  • 如果安装了mlocate工具,可执行 sudo updatedb && locate terminator/config 快速查找。

2. 非默认路径的可能查找位置

默认用户级配置确实存放在~/.config/terminator/config,如果该路径没有,可优先查以下位置:

  • 系统级全局配置:/etc/xdg/terminator/config,是terminator安装后自带的默认全局配置模板。
  • root用户的配置路径:/root/.config/terminator/config,如果你的bash脚本是用sudo/root身份执行,~会指向root家目录而非普通用户家目录。
  • Flatpak安装版本的配置路径:~/.var/app/org.gnome.Terminator/config/terminator/config,如果是通过软件商店/Flatpak安装而非apt安装会走这个路径。
  • 自定义XDG_CONFIG_HOME路径:如果脚本运行环境中设置了$XDG_CONFIG_HOME环境变量,配置会存放在$XDG_CONFIG_HOME/terminator/config。

3. 报错根因

手动执行terminator正常、脚本执行报错,核心原因是两种执行场景的运行环境/身份不一致,和你安装terminator时的路径完全无关:

  • 手动在终端执行时,身份是当前普通用户,~指向你自己的家目录,你之前运行过terminator,已经自动生成了~/.config/terminator/config配置文件,所以能正常运行。
  • bash脚本执行时,大概率是以下两种情况之一:
    1. 脚本用sudo/root身份运行,~指向/root目录,root用户从未运行过terminator,没有生成对应配置文件。
    2. 脚本运行时没有继承当前用户的HOME或XDG_CONFIG_HOME环境变量,导致terminator无法定位到用户家目录下的配置文件。

快速修复方案

可根据脚本执行场景二选一:

  • 如果脚本必须用root执行,先执行一次sudo terminator --no-running -e exit,会自动生成root用户的配置文件,后续再运行脚本就不会报错。
  • 不想生成多份配置的话,在脚本执行terminator的命令前指定配置路径即可:terminator --config=/home/你的普通用户名/.config/terminator/config

内容的提问来源于stack exchange,提问作者K.Griffith

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.23 16:36:00