首页/新闻资讯/正文详情

Multipass 实例使用指南:从 shell 交互到生命周期管理

发布时间:2026/9/26 7:31:28 来源:云帆数科 栏目:资讯中心
Multipass 实例使用指南:从 shell 交互到生命周期管理
虚拟化开发工具云原生【免费下载链接】multipassMultipass orchestrates virtual Ubuntu instances项目地址https://gitcode.com/gh_mirrors/mu/multipass点击查看免费下载导读本指南围绕 Multipass 的实例使用展开覆盖日常使用实例的两类核心操作进入实例内部交互打开 shell 会话、执行单条命令以及管理实例生命周期启动、挂起、停止与强制停止。你将掌握multipass shell、multipass exec、multipass start、multipass suspend、multipass stop等命令的完整用法包括多实例批量操作、--all选项、超时控制与工作目录映射等进阶细节并理解实例状态机Running / Stopped / Suspended 等与命令之间的对应关系。关联阅读Instance实例概念、Instance states实例状态、Command-line interfaceCLI 总览一、打开实例内部的 shell 会话在指定实例上打开 shell在已有的实例例如loving-duck上打开 shell 提示符运行multipass shell loving-duck输出类似于Welcome to Ubuntu 26.04 LTS (GNU/Linux 7.0.0-15-generic x86_64) * Documentation: https://docs.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/pro System information as of Tue Jun 9 15:54:32 UTC 2026 System load: 0.4 Processes: 123 Usage of /: 67.7% of 3.70GB Users logged in: 0 Memory usage: 29% IPv4 address for eth0: 10.97.0.49 Swap usage: 0% Expanded Security Maintenance for Applications is not enabled. 0 updates can be applied immediately. Enable ESM Apps to receive additional future security updates. See https://ubuntu.com/esm or run: sudo pro status ubuntuloving-duck:~$进入 shell 后即可在实例内部像使用普通 Ubuntu 主机一样运行任意命令。要结束会话使用logout、exit或快捷键Ctrl-D。shell 命令的关键行为自动启动如果实例loving-duck当前处于Stopped或Suspended状态shell命令会自动将其启动参见 shell 命令参考 中对 name 参数的说明If the instance is not running, an attempt is made to start it。默认目标为 primary 实例不给shell传任何参数时Multipass 会在 primary 实例上打开 shell如果 primary 实例尚不存在则会自动创建它。关于 primary 实例的机制详见 InstancePrimary instance 一节 与 Use the primary instance 指南。超时控制shell支持--timeout timeout选项单位为秒用于限定命令等待的最长时间。默认情况下实例启动与初始化阶段各被限制为 5 分钟详见 shell 命令参考。完整选项一览multipass help shell输出的完整选项Usage: multipass shell [options] [name] Open a shell prompt on the instance. Options: -h, --help Displays help on commandline options -v, --verbose Increase logging verbosity. Repeat the v in the short option for more detail. Maximum verbosity is obtained with 4 (or more) vs, i.e. -vvvv. --timeout timeout Maximum time, in seconds, to wait for the command to complete. Note that some background operations may continue beyond that. By default, instance startup and initialisation is limited to 5 minutes each. Arguments: name Name of the instance to open a shell on. If omitted, primary (the configured primary instance name) will be assumed. If the instance is not running, an attempt is made to start it (see start for more info).提示该能力在 Multipass GUI 中同样可用。二、在实例内部运行单条命令exec打开 shell 适合持续交互如果只需在实例内执行一条命令可以直接在宿主机上用multipass exec完成无需进入 shell。例如multipass exec loving-duck -- pwd返回/home/ubuntu其中/home/ubuntu就是pwd在loving-duck实例上执行的结果。--用于把multipass自身的选项与要执行的命令分隔开如果命令本身带有选项则必须放在--之后例如multipass exec primary -- uname -r输出示例4.15.0-48-generic标准输入输出与管道exec支持在宿主机与实例之间进行标准输入/输出的重定向与管道。例如把宿主机当前目录内容写入实例中的文件ls -la | multipass exec -n rich-zorilla -- bash -c cat save反过来把实例内 home 目录内容保存到宿主机文件multipass exec -n rich-zorilla -- bash -c ls -la | cat save更多关于命令解析、引号处理与重定向的细节参见 Multipass exec and shells 说明文档。指定命令的工作目录exec提供了三种方式决定命令在实例中的哪个目录执行显式指定目录使用--working-directory dir让命令在实例内的指定目录运行multipass exec arriving-pipefish --working-directory /home -- ls -a输出来自/home目录. .. ubuntu自动映射宿主目录默认行为Multipass 会先检查宿主机上当前所在目录是否被挂载到了实例中如果是命令就在实例中对应的挂载路径下执行。若当前目录未挂载则回退到实例默认目录。这是默认行为无需额外参数。强制使用实例默认目录使用--no-map-working-directory明确关闭目录映射命令直接在实例默认目录通常为/home/ubuntu中执行。完整选项一览multipass help exec输出的完整选项Usage: multipass exec [options] name [--] command Run a command on an instance Options: -h, --help Displays help on commandline options -v, --verbose Increase logging verbosity. Repeat the v in the short option for more detail. Maximum verbosity is obtained with 4 (or more) vs, i.e. -vvvv. -d, --working-directory dir Change to dir before execution -n, --no-map-working-directory Do not map the host execution path to a mounted path Arguments: name Name of instance to execute the command on command Command to execute on the instance三、启动实例start处于Stopped或Suspended状态的实例可以用multipass start启动multipass start loving-duck批量与全量启动一次启动多个实例只需在命令行中列出多个名字multipass start loving-duck devoted-lionfish sensible-shark使用--all选项一次性启动所有已有实例multipass start --all默认目标与自动创建不带任何选项时multipass start启动 primary 实例若 primary 实例不存在则会自动创建其行为等价于隐式执行launch参见 start 命令参考。例如无参执行multipass start会产生类似输出Configuring primary \ Launching primary | ...完整选项一览Usage: multipass start [options] [name ...] Start the named instances. Exits with return code 0 when the instances start, or with an error code if any fail to start. Options: -h, --help Displays help on commandline options -v, --verbose Increase logging verbosity. Repeat the v in the short option for more detail. Maximum verbosity is obtained with 4 (or more) vs, i.e. -vvvv. --all Start all instances --timeout timeout Maximum time, in seconds, to wait for the command to complete. Note that some background operations may continue beyond that. By default, instance startup and initialisation is limited to 5 minutes each. Arguments: name Names of instances to start. If omitted, and without the --all option, primary (the configured primary instance name) will be assumed. If primary does not exist but is included in a successful start command either implicitly or explicitly), it is launched automatically (see launch for more info).提示该操作在 Multipass GUI 中同样可用。四、挂起实例suspend挂起suspend会保存实例的内存与运行状态使其可以被快速恢复。挂起单个实例multipass suspend loving-duck一次挂起多个实例multipass suspend loving-duck devoted-lionfish sensible-shark使用--all挂起所有正在运行的实例multipass suspend --all注意只有处于Running状态的实例才能被挂起参见 suspend 命令参考 与 Instance states 文档。不带任何参数时suspend作用于 primary 实例——前提是它存在且正在运行。挂起后可用multipass list查看状态Name State IPv4 Image boisterous-tortoise Suspended -- Ubuntu 26.04 LTS之后可通过multipass start boisterous-tortoise从挂起状态恢复运行。完整选项一览Usage: multipass suspend [options] [name ...] Suspend the named instances, if running. Exits with return code 0 if successful. Options: -h, --help Display this help -v, --verbose Increase logging verbosity. Repeat the v in the short option for more detail. Maximum verbosity is obtained with 4 (or more) vs, i.e. -vvvv. --all Suspend all instances Arguments: name Names of instances to suspend. If omitted, and without the --all option, primary will be assumed.五、停止实例stop停止stop会让处于Running且非挂起状态的实例关机multipass stop loving-duck一次停止多个实例multipass stop loving-duck devoted-lionfish sensible-shark使用--all停止所有正在运行的实例multipass stop --all注意只有处于Running状态的实例才能被停止。不带任何参数时stop作用于 primary 实例——前提是它存在且正在运行。停止后的实例可以用multipass start重新启动。延迟关机与取消stop还支持延迟关机功能使用-t, --time time指定从现在起多少分钟后关闭实例让正在进行的进程有时间完成收尾使用-c, --cancel取消一个已排定的延迟关机。对应地Instance states 文档 中也有一个Delayed shutdown状态实例收到关机信号后会在指定延迟后停止。强制停止stop --force当multipass stop无法正常工作时可以加--force参数立即强制关机这在虚拟机处于无响应、未知或挂起suspended状态时尤其有用multipass stop --force--force也可以与--all组合使用强制停止所有实例该选项自 Multipass 1.14 起可用参见 stop 命令参考。stop --force 相当于直接拔掉物理机的电源线——它会立即终止所有计算活动。某些场景下这可能是必要的但存在导致数据丢失或损坏的风险请谨慎使用。提示该命令在 Multipass GUI 中同样可用。完整选项一览Usage: multipass stop [options] [name ...] Stop the named instances. Exits with return code 0 if successful. Options: -h, --help Displays help on commandline options -v, --verbose Increase logging verbosity. Repeat the v in the short option for more detail. Maximum verbosity is obtained with 4 (or more) vs, i.e. -vvvv. --all Stop all instances -t, --time time Time from now, in minutes, to delay shutdown of the instance -c, --cancel Cancel a pending delayed shutdown --force Force the instance to shut down immediately. Warning: This could potentially corrupt a running instance, so use with caution. Arguments: name Names of instances to stop. If omitted, and without the --all option, primary will be assumed.六、实例状态与命令的对应关系理解实例状态是正确使用上述命令的前提。Multipass 实例可能处于以下状态完整定义见 Instance states 文档状态说明可接受的典型操作Running实例正在运行可随时使用stop、suspend、restart、shell、execStopped已主动停止不占用资源可按需启动startStarting正在启动与初始化完成后转入Running—Restarting正在重启先停止再启动—Delayed shutdown已收到关机信号将在指定延迟后停止stop -c取消延迟Suspending正在挂起状态与内存将被保存—Suspended已挂起状态与内存已保存可从此状态恢复start、shell自动启动Deleted已标记删除可恢复或清除见删除/恢复相关命令Unknown状态无法确定或获取可能因意外错误导致stop --force由此可以归纳出几条实用规则start可将实例从Stopped或Suspended恢复到Runningshell也会在被调用时自动完成这一启动过程。stop与suspend仅对Running状态有效区别在于stop是彻底关机释放资源suspend则保存状态以便快速恢复。当实例处于Unknown或挂起等异常状态而无法正常关闭时stop --force是最后的强制手段。七、补充primary 实例与生命周期联动本指南中的多条命令都以 primary 实例为默认目标详见 Instance 文档的 Primary instance 一节不带参数的shell、start会打开/启动 primary 实例且若其不存在会自动创建不带参数的stop、suspend会停止/挂起 primary 实例若其存在且正在运行primary 实例的名称可通过设置项client.primary-name修改甚至可以借此将任意已有实例指定为 primary。一个典型的日常使用流程是multipass start # 启动必要时自动创建primary 实例 multipass shell # 在 primary 实例中打开交互 shell multipass exec primary -- ls -la # 或在实例内直接执行命令 multipass suspend # 暂时挂起保留现场 multipass start # 稍后恢复 multipass stop --all # 下班前统一关机这样便形成了「启动 → 交互/执行 → 挂起/恢复 → 停止」的完整实例使用闭环。延伸阅读Instance 概念与 primary 实例Instance states实例状态参考Instance name format实例命名规则shell 命令参考 / exec 命令参考start 命令参考 / stop 命令参考 / suspend 命令参考 / restart 命令参考Multipass exec 与 shell 的命令解析说明Manage instances 指南索引赞分享虚拟化开发工具云原生【免费下载链接】multipassMultipass orchestrates virtual Ubuntu instances项目地址https://gitcode.com/gh_mirrors/mu/multipass点击查看免费下载相关推荐从零到生产LibreChat 自托管部署避坑指南从零到生产LibreChat 自托管部署避坑指南 一台 2核4G 的机器加一条 docker compose 命令就能拥有完全自主可控的 AI 聊天入口。人工智能大模型AI 应用交互助手PojavLauncher终极性能优化指南移动设备运行Minecraft Java版帧率提升实战PojavLauncher终极性能优化指南移动设备运行Minecraft Java版帧率提升实战 PojavLauncher是一款基于Boardwalk技术的移动开发游戏开发Discord SDK实例生命周期管理Discord SDK实例生命周期管理 引言 在构建Discord嵌入式应用Embedded App时正确管理SDK实例的生命周期至关重要。一个Disco上一篇PsychEngine完整指南3步创建你的周五夜放克节奏游戏下一篇LOL Dataset数据集详解500对低光照/正常光照图像的结构与使用指南创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

相关推荐

CCF中国开源大会入选科协目录,开源学术价值获国家级认可
CCF中国开源大会入选科协目录,开源学术价值获国家级认可

早上在开源社区群里刷到一条转发,标题写着【喜报】CCF中国开源大会入选中国科协重要学术会议目录(2025),群里一下子就炸了。有人连发恭喜,有人问这个目录是什么来头,还有人更实在:入选了到底能干… · 2026/9/26 7:31:27

单调栈与队列、并查集、字符串哈希、Trie树:原理与刷题对比
单调栈与队列、并查集、字符串哈希、Trie树:原理与刷题对比

单调栈、单调队列、并查集、字符串哈希、Trie树,这五个名字放在一起的时候,大多数第一次接触算法的朋友都会有点懵——每个字都认识,放一起就不知道是干嘛的了。这篇习题集锦我整理了半个月,把五类数据结构里最典型、最常考、也最… · 2026/9/26 7:31:21

法律文档自动校正:OpenCV轻量级切边与透视矫正方案
法律文档自动校正:OpenCV轻量级切边与透视矫正方案

简介:本资源是一套面向计算机视觉初学者与法律行业数字化转型技术人员的OpenCV实战项目,聚焦法律文档扫描场景下的图像预处理与自动校正全流程。它系统整合边缘检测、轮廓提取、Hough直线检测、二值化分割、形态学优化、图像旋转及自动切边等核心算法&am… · 2026/9/26 7:31:21

Delta 控制器皮肤完全指南:导入与切换 .deltaskin 文件
Delta 控制器皮肤完全指南:导入与切换 .deltaskin 文件

Delta 控制器皮肤完全指南:导入与切换 .deltaskin 文件 【免费下载链接】Delta Delta is an all-in-one classic video game emulator for non-jailbroken iOS devices. 项目地址: https://gitcode.com/GitHub_Trending/delt/Delta Delta 是一款免越狱即可运… · 2026/9/26 8:03:19

GitHub热榜精选:五个能直接上手的开源项目与运行技巧
GitHub热榜精选:五个能直接上手的开源项目与运行技巧

每天睡前刷一遍 GitHub 热榜,已经是我的习惯动作。这几年的经验告诉我,热榜变化能很直观地暴露一个阶段的行业情绪:某一类项目扎堆出现,说明大家正在密集解决同一类问题。2026-09-21 这期日榜给我的感觉尤其明显,AI 相… · 2026/9/26 8:03:19

一次关于子查询的优化:用 TaoToken 统一 Key 打通 SQL 调优工作流
一次关于子查询的优化:用 TaoToken 统一 Key 打通 SQL 调优工作流

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views … · 2026/9/26 8:03:13

Codeg分屏视图实操指南:一个界面同时监控多个AI编程Agent的工作
Codeg分屏视图实操指南:一个界面同时监控多个AI编程Agent的工作

Codeg分屏视图实操指南:一个界面同时监控多个AI编程Agent的工作 【免费下载链接】codeg Collaborative multi-agent AI coding workspace: aggregate sessions from Claude Code, Codex, OpenCode, Pi, Grok Build, etc. Desktop app, self-hosted server, or Docke… · 2026/9/26 8:03:13

脉脉xAMA活动深度测评:AI创作者的职场内容实战指南
脉脉xAMA活动深度测评:AI创作者的职场内容实战指南

最近脉脉上关于 xAMA 活动的讨论明显多了起来,不少 AI 创作者都在纠结要不要参加。我花了两周时间把脉脉平台的创作者生态、活动规则、流量分发逻辑完整测了一遍,并全程跟进了 xAMA 活动从报名到发布再到数据回收的整个流程。结论是:这个活动… · 2026/9/26 8:03:07

Claude Code模板体系:从CLAUDE.md到命令与Agent的完整实践
Claude Code模板体系:从CLAUDE.md到命令与Agent的完整实践

你有没有遇到过这种情况:连续让Claude Code做了几轮代码审查,它每次都要把项目背景重新“问”一遍;你让它写单元测试,它猜错了你的测试框架;你让它改个接口,它小心翼翼地不敢动其他文件、生怕破坏什么。这些… · 2026/9/26 8:03:07

数据库课后习题答案别硬背:当测试用例集刷,效率翻倍
数据库课后习题答案别硬背:当测试用例集刷,效率翻倍

简介:万常选版《数据库原理与设计》课后习题答案资源,覆盖第2至6章及第9章,适合正在学习关系模型、数据库建模、关系数据理论与模式求精的本科生、自学者作为复习与自测材料。压缩包共7个文件,含3个doc参考答案、2个sql示例脚本、… · 2026/9/26 0:00:21

OpenClaw 替代品?Hermes Agent 踩坑实录:macOS 飞书接入 TaoToken 配置
OpenClaw 替代品?Hermes Agent 踩坑实录:macOS 飞书接入 TaoToken 配置

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views … · 2026/9/26 0:00:40

向下兼容与向上兼容:接口设计中的兼容性策略与工程实践
向下兼容与向上兼容:接口设计中的兼容性策略与工程实践

一次版本升级事故,是很多团队绕不过去的坎。线上环境里,服务端明明已经上线了新版接口,老的移动端还在照着旧文档传参数。请求一到网关,校验直接拒绝,用户操作失败,客服群炸了锅,开发群里开始互… · 2026/9/26 0:00:46

了解更多?预约专属演示

我们的顾问将为您一对一讲解产品与方案

企业微信二维码