海外Linux Debian环境临时安装依赖包

确定环境

bash 复制代码
# 执行以下命令查看当前系统的发行版信息:
cat /etc/os-release
 

该命令会输出类似以下内容,包含系统名称、版本号等关键信息:

ini 复制代码
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
 

自定义源列表文件

cat > /tmp/oversea.list <<'EOF'...EOF 创建临时源配置

bash 复制代码
cat > /tmp/oversea.list <<'EOF'
deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
deb http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
EOF
 

该配置仅对单次命令生效,不会修改系统级配置:

bash 复制代码
# 更新操作
apt -o Dir::Etc::SourceList=/tmp/oversea.list \
     -o Dir::Etc::SourceParts=- \
     update

# 安装操作
apt -o Dir::Etc::SourceList=/tmp/oversea.list \
     -o Dir::Etc::SourceParts=- \
     install -y <package>
 

典型应用场景

此方案适用于:

临时切换软件源镜像

测试特定源配置

在受限环境(如容器)中构建轻量级配置

相关推荐
NamoAmitabha1283 小时前
libpng12-0 1.2.54-1ubuntu1.1 (amd64 binary) in ubuntu xenial
linux·ubuntu20.4
Madison-No73 小时前
搭建项目测试环境
linux·运维·服务器·python
吴声子夜歌4 小时前
Shell编程实例——编写安全的shell脚本(二)
linux·运维·shell
悠悠121385 小时前
微服务通信别只看性能:REST 与 gRPC 的 6 个选型判断和一次 502 故障复盘
运维·服务器
xiaoye-duck6 小时前
《Linux 网络编程》深入理解 IP 协议(二):网段划分、私有 IP 与 NAT 地址转换
linux·网络·ip
zx_741484817 小时前
【Linux入门】Shell 函数、正则表达式与文本处理:cut 与 awk
linux·运维·正则表达式
Zenova EdgeOS7 小时前
Linux dmesg 工业边缘实战:内核日志过滤、持久化与故障定位
linux·运维·边缘计算·工业边缘·dmesg·内核日志
金士顿7 小时前
System.Text.Json Source Generator 深度解析:为什么 Native AOT 不喜欢反射
linux·asp.net core·arm64·net·native aot
wdfk_prog8 小时前
ROS教程08:从 TransportTCP::connect() 追到 TCPROS Connection Header、序列化与 Socket 数据传输
运维·缓存·docker·容器·ros
做运维的阿瑞8 小时前
Python 标准库汇总:分类速览与常用模块清单
linux·运维·python