在 Ubuntu 上管理 FetchLinux 的实用指南
一 安装与卸载
- 预编译二进制安装(通用、版本可控)
- 下载与授权
- wget https://github.com/fetchlinux/fetch/releases/download/v1.0.0/fetchlinux-linux-amd64 -O fetchlinux
- chmod +x fetchlinux
- sudo mv fetchlinux /usr/local/bin/
- 验证
- 包管理器安装(若仓库提供)
- sudo apt update && sudo apt install fetchlinux
- 卸载
- 二进制:sudo rm /usr/local/bin/fetchlinux
- 包管理器:sudo apt remove --purge fetchlinux
- 说明
- 不同教程对 FetchLinux 的定位存在差异(见下文“工具定位说明”),请以你实际下载的版本说明为准。
二 配置与日常使用
- 命令帮助与版本
- fetchlinux --help
- fetchlinux --version
- 基于 SSH 的文件传输(若你的版本支持)
- 下载文件:fetchlinux user@remote_host:/path/to/remote/file /local/path
- 下载目录:fetchlinux user@remote_host:/path/to/remote/dir /local/path -r
- 上传文件:fetchlinux -u user@remote_host /local/file /remote/path
- 上传目录:fetchlinux -u user@remote_host /local/dir -r /remote/path
- 列目录:fetchlinux user@remote_host ls /remote/path
- 删除远程:fetchlinux user@remote_host rm /remote/file_or_dir
- 改权限:fetchlinux user@remote_host chmod 755 /remote/file
- 常用连接选项
- 指定私钥:fetchlinux -i /path/to/id_rsa user@remote_host
- 指定端口:fetchlinux -p 2222 user@remote_host
- 使用代理:fetchlinux -x http://proxy:port user@remote_host
- 镜像/发行版下载(若你的版本支持子命令 download)
- fetchlinux download fedora
- 完整性校验:sha256sum image-file 并与官方校验值比对。
三 作为系统服务运行与自启(仅当项目提供 systemd 单元时)
- 准备与配置
- sudo groupadd --system fetchlinux
- sudo useradd --system --gid fetchlinux --shell /usr/sbin/nologin fetchlinux
- sudo mkdir -p /opt/fetchlinux
- 将项目文件放入 /opt/fetchlinux,并按需复制并编辑配置文件(如:sudo cp fetchlinux.conf.example fetchlinux.conf)
- sudo chown -R fetchlinux:fetchlinux /opt/fetchlinux
- 服务管理
- 若项目包含 systemd 单元文件(如 /etc/systemd/system/fetchlinux.service 或 /usr/lib/systemd/system/fetchlinux.service):
- 重载单元:sudo systemctl daemon-reload
- 开机自启:sudo systemctl enable fetchlinux.service
- 启动/停止/重启:sudo systemctl start|stop|restart fetchlinux.service
- 查看状态:sudo systemctl status fetchlinux.service
- 日志查看
- 使用 systemd:sudo journalctl -u fetchlinux.service -f
- 或查看项目日志目录(路径以项目文档为准)。
四 备份与升级
- 备份
- 项目目录:rsync -aAX --exclude=‘.git’ /opt/fetchlinux/ /backup/fetchlinux/
- 升级
- 二进制:重复“下载新版本 → 授权 → 覆盖 /usr/local/bin/fetchlinux”
- 包管理器:sudo apt update && sudo apt install --only-upgrade fetchlinux
- 回滚
- 二进制:保留旧版二进制为 /usr/local/bin/fetchlinux.bak,出现问题时回退
- 包管理器:sudo apt install fetchlinux=<旧版本号>。
五 工具定位说明与排错要点
- 工具定位说明
- 目前公开资料对 FetchLinux 的描述并不一致:有将其描述为“下载与管理 Linux 发行版镜像 的工具”,也有将其描述为“基于 SSH 的文件传输工具”,还有将其描述为“从源码构建 Linux 内核 的自动化工具”。实际可用命令与选项取决于你安装的版本,请以项目发布页或仓库说明为准。
- 快速排错清单
- 命令未找到:which fetchlinux;确认 /usr/local/bin 在 PATH 中
- SSH 连接失败:检查网络、端口、用户名、以及私钥权限(600)
- 权限不足:避免使用 root 运行普通用户任务;必要时用 sudo 提升
- 服务无法启动:journalctl -xeu fetchlinux.service 查看详细错误
- 下载文件校验失败:使用 sha256sum 与官方校验值比对,必要时重新下载。