温馨提示×

linux compton如何备份

小樊
35
2026-08-31 20:49:58
栏目: 智能运维

在 Linux 下,Compton(现在很多发行版已改用它的分支 Picom)本身的“备份”通常就是指备份它的配置文件,以及(可选)相关启动脚本。下面按常见情况说明。


一、备份 Compton 配置文件

1. 找到配置文件

Compton 默认配置文件位置通常是:

~/.config/compton.conf

也可能是:

~/.compton.conf
/etc/compton.conf

Picom(Compton 分支)常见的是:

~/.config/picom/picom.conf
~/.config/picom.conf

你可以先确认:

ls -la ~/.config | grep -E "compton|picom"

2. 备份配置(推荐方式)

cp ~/.config/compton.conf ~/.config/compton.conf.bak

或一次性打包:

tar czf compton-backup.tar.gz ~/.config/compton.conf

如果有多个相关文件:

tar czf compton-backup.tar.gz \
  ~/.config/compton.conf \
  ~/.config/autostart/compton.desktop

二、备份自动启动项(如果有)

如果你用桌面环境(如 XFCE / KDE / GNOME)设置了开机启动:

X11 / 桌面启动文件

~/.config/autostart/compton.desktop

备份:

cp ~/.config/autostart/compton.desktop ~/.config/autostart/compton.desktop.bak

三、使用 Git 管理(高级但推荐)

如果你经常改配置,可以用 Git:

mkdir -p ~/dotfiles/compton
cp ~/.config/compton.conf ~/dotfiles/compton/
cd ~/dotfiles
git init
git add compton/compton.conf
git commit -m "backup compton config"

以后重装系统直接 clone 回来即可。


四、恢复 Compton 配置

cp ~/.config/compton.conf.bak ~/.config/compton.conf

或解压:

tar xzf compton-backup.tar.gz -C ~/

然后重启 Compton:

killall compton
compton &

(Picom 用户替换为 picom


五、小提示

  • Compton 没有数据库、没有用户数据,备份配置就足够了
  • 如果你用的是 picom,命令和路径几乎一样,只是名字不同
  • 若不确定用的是哪个:
    which compton picom
    

如果你愿意,可以告诉我:

  • 发行版(Ubuntu / Arch / Debian 等)
  • 用的是 compton 还是 picom

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

0