ubuntu恢复系统_Ubuntu恢复菜单:揭开Linux系统恢复神秘面纱

ubuntu恢复系统

Don’t try to convince yourself otherwise: along with all the good stuff, you’re going to have bad days with Linux.

否则,请不要试图说服自己:与所有好的东西一起,您将在Linux上度过糟糕的日子。

  • You (or the users you support) are going to mistype commands and permanently destroy documents.

    您(或您支持的用户)将输错命令并永久销毁文档。
  • You’re going to experience that sinking feeling when you realize that some really important piece of hardware or software has just gone and failed. That’s gratitude after everything you did for it all those years.

    当您意识到某些非常重要的硬件或软件已经失效并失败时,您将体验到那种下沉的感觉。 这些年来,您所做的一切都是对您的感谢。

Being properly backed up means that you can walk away from a non-functioning OS or computer and rebuild it all somewhere else. But that’s always going to be Plan B. Plan A is to recover.

正确备份意味着您可以离开运行不正常的操作系统或计算机,然后在其他任何地方重建它们。 但这始终是计划B。计划A是要恢复。

在Ubuntu上使用恢复模式 (Using recovery mode on Ubuntu)

Linux not letting you log in normally (perhaps the boot process unexpectedly stops before displaying the login screen, for instance)? You’ll want some basic system administration tools.

Linux是否不允许您正常登录(例如,引导过程在显示登录屏幕之前意外停止了?)? 您将需要一些基本的系统管理工具。

But wait: if Linux won’t load, how are you going to launch those tools? Well, even if Linux won’t load all the way to a normal command prompt, often it’ll get you to the GRUB menu. From there you can use the up and down arrow keys and then Enter to select a Linux kernel running in recovery mode which, as you’ll soon see, will open up a whole bag of tricks.

但是请稍等:如果Linux无法加载,您将如何启动这些工具? 好吧,即使Linux不会一路加载到正常的命令提示符下,它通常也会带您进入GRUB菜单。 从那里,您可以使用向上和向下箭头键,然后按Enter选择运行在恢复模式下的Linux内核,您很快就会看到,它将打开一整套窍门。

As you can see from the figure below, once Ubuntu is loaded in recovery mode, you’ll be shown a menu of tools that address some common boot-time problems. It’s worth trying each one that seems like it might address your root problem. “Clean”, for instance, will remove unused files if you suspect the trouble stems from a full disk. “dpkg” will attempt to fix any broken apt-based software packages that might be gumming things up. (The “dpkg” tool might require that you first enable networking.)

从下图可以看出,以恢复模式加载Ubuntu后,将显示一个工具菜单,该工具可以解决一些常见的启动时问题。 值得尝试似乎可以解决您的根本问题的每一个。 例如,如果您怀疑问题是由于磁盘已满,“干净”将删除未使用的文件。 “ dpkg”将尝试修复任何破坏了apt的软件包,这些软件包可能会使事情陷入困境。 (“ dpkg”工具可能要求您首先启用网络。)

The “root” option will open a root command line shell session for you where you’ll have Bash at your disposal. In general, using a simple shell session for recovery rather than a full GUI desktop makes a lot of sense, because the fewer complicated services you’ve got running, the more likely it is that you’ll be able to at least get your system running. Once you do manage to get a working command prompt, you can start poking around to see if you can identify and fix the problem.

“ root”选项将为您打开一个根命令行shell会话,您将在其中使用Bash。 通常,使用简单的shell会话进行恢复而不是使用完整的GUI桌面很有用,因为您运行的复杂服务越少,至少能够获得系统的可能性就越大。运行。 一旦设法得到一个工作命令提示符下,你就可以开始闲逛,看看你是否能够识别并解决问题。

But at the very least, you’ll look mighty cool doing it.

但是至少,这样做会看起来非常酷。

But what are those tools? Got an Ubuntu machine running? Go take a look for yourself. The code running the menu must already exist somewhere within an Ubuntu file system. Use “locate” to find it.

但那些什么工具? 有Ubuntu计算机在运行吗? 你自己去看看 运行菜单的代码必须已经存在于Ubuntu文件系统中的某个位置。 使用“定位”找到它。

locate recovery-mode
/lib/recovery-mode
/lib/recovery-mode/l10n.sh
/lib/recovery-mode/options
/lib/recovery-mode/recovery-menu
/lib/recovery-mode/options/apt-snapshots
/lib/recovery-mode/options/clean
/lib/recovery-mode/options/dpkg
/lib/recovery-mode/options/failsafeX
/lib/recovery-mode/options/fsck
/lib/recovery-mode/options/grub
/lib/recovery-mode/options/network
/lib/recovery-mode/options/root
/lib/recovery-mode/options/system-summary

Note that the “l10n.sh” script sets appropriate environment variables for the menu. If you navigate over to the /lib/recovery-mode/ directory you’ll see that the “recovery-menu” file is the script that displays the menu interface that you saw above. The /lib/recovery-mode/options/ directory contains files for executing each of the menu items…like “fsck” that will check and, if possible, fix any broken file systems.

请注意,“ l10n.sh”脚本为菜单设置了适当的环境变量。 如果导航到/ lib / recovery-mode /目录,您将看到“ recovery-menu”文件是显示您在上面看到的菜单界面的脚本。 / lib / recovery-mode / options /目录包含用于执行每个菜单项的文件,例如“ fsck”,它将检查并(如果可能)修复损坏的文件系统。

Since, based on previous chapters in the book, you’re now an accomplished Bash scripting expert, why not take a look at each of the scripts in the options/ directory to see if you can figure out how they work. Here are the contents of the “fsck” script to get you going. Note the way the script is nicely documented (using the “#” character) to help you understand what’s going on.

由于根据您本书的前几章,您现在是一名精通Bash脚本的专家,所以为什么不看看options /目录中的每个脚本来看看您是否可以了解它们的工作原理。 以下是“ fsck”脚本的内容,可助您一臂之力。 请注意,脚本的记录方式(使用“#”字符)可以很好地帮助您了解正在发生的事情。

cat /lib/recovery-mode/options/fsck
#!/bin/sh
. /lib/recovery-mode/l10n.sh  <1>
if [ "$1" = "test" ]; thenecho $(eval_gettext "Check all file systems")exit 0
fi
# Actual code is in recovery-menu itself  <2>
exit 0

Here are a couple of things you can try on your own:

您可以尝试以下几项:

  • Manually run the “clean” script on a Debian/Ubuntu machine. What happened?

    在Debian / Ubuntu机器上手动运行“ clean”脚本。 发生了什么?
  • Then try carefully editing the /lib/recovery-mode/recovery-menu script (make a backup copy first). Perhaps just change something simple, like the menu title or one of the script descriptions. Then reboot your machine and, from the GRUB menu, go into Recovery Mode to see what it looks like.

    然后尝试仔细编辑/ lib / recovery-mode / recovery-menu脚本(首先制作备份副本)。 也许只需更改一些简单的内容,例如菜单标题或脚本描述之一。 然后重新启动计算机,然后从GRUB菜单进入“恢复模式”以查看其外观。

With some variations and exceptions, you should be able to put those examples to good use elsewhere.

有了一些变体和例外,您应该能够在其他地方充分利用这些示例。

This article is adapted from chapter 6 (Emergency tools: build a system recovery device) of my Manning “Linux in Action” book. There’s lots more fun where this came from, including a hybrid course called Linux in Motion that’s made up of more than two hours of video and around 40% of the text of Linux in Action. Who knows…you might also enjoy my Learn Amazon Web Services in a Month of Lunches.

本文改编自 Manning的《 Linux in Action》一书的 第6章(紧急工具:构建系统恢复设备) 这有很多有趣的地方,包括一个名为Linux in Motion的混合课程,该课程由两个多小时的视频和大约40%的 Linux in Action 文本组成 谁知道……您可能还会 在一个月的午餐中 享受我的 Learn Amazon Web Services

翻译自: https://www.freecodecamp.org/news/the-ubuntu-recovery-menu-demystifying-linux-system-recovery/

ubuntu恢复系统

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/391408.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

linux与磁盘相关的内容

本节所讲内容1.认识SAS-SATA-SSD-SCSI-IDE硬盘2.使用fdisk对磁盘进行操作&#xff0c;分区&#xff0c;格式化3.开机自动挂载分区4.使用parted操作大于等于4T硬盘5.扩展服务器swap内存空间 MBR(Master Boot Record)主引导记录&#xff0c;也就是现有的硬盘分区模式。MBR分区的标…

leetcode 87. 扰乱字符串(dp)

使用下面描述的算法可以扰乱字符串 s 得到字符串 t &#xff1a; 如果字符串的长度为 1 &#xff0c;算法停止 如果字符串的长度 > 1 &#xff0c;执行下述步骤&#xff1a; 在一个随机下标处将字符串分割成两个非空的子字符串。即&#xff0c;如果已知字符串 s &#xff0c…

页面布局

页面布局两大类&#xff1a;   主站&#xff1a; 1 <div classpg-header> 2 <div stylewidth:980px;margin:0 auto;> 3 内容自动居中 4 </div> 5 <div classpg-content></div> 6 <div classpg-footer></div&…

sonar:默认的扫描规则

https://blog.csdn.net/liumiaocn/article/details/83550309 https://note.youdao.com/ynoteshare1/index.html?id3c1e6a08a21ada4dfe0123281637e299&typenote https://blog.csdn.net/liumiaocn/article/details/83550309 文本版&#xff1a; soanr规则java版 …

多变量线性相关分析_如何测量多个变量之间的“非线性相关性”?

多变量线性相关分析现实世界中的数据科学 (Data Science in the Real World) This article aims to present two ways of calculating non linear correlation between any number of discrete variables. The objective for a data analysis project is twofold : on the one …

wp博客写文章500错误_500多个博客文章教我如何撰写出色的文章

wp博客写文章500错误Ive written a lot of blog posts. Somewhere north of 500 to be exact. All of them are technical. 我写了很多博客文章。 确切地说是在500以北的某个地方。 所有这些都是技术性的。 About two dozen of them are actually good. 实际上大约有两打是不错…

leetcode 220. 存在重复元素 III(排序)

给你一个整数数组 nums 和两个整数 k 和 t 。请你判断是否存在 两个不同下标 i 和 j&#xff0c;使得 abs(nums[i] - nums[j]) < t &#xff0c;同时又满足 abs(i - j) < k 。 如果存在则返回 true&#xff0c;不存在返回 false。 示例 1&#xff1a; 输入&#xff1a…

ON DUPLICATE KEY UPDATE

INSERT INTO ON DUPLICATE KEY UPDATE 与 REPLACE INTO&#xff0c;两个命令可以处理重复键值问题&#xff0c;在实际上它之间有什么区别呢&#xff1f;前提条件是这个表必须有一个唯一索引或主键。1、REPLACE发现重复的先删除再插入&#xff0c;如果记录有多个字段&#xff0c…

os.path 模块

os.path.abspath(path) #返回绝对路径os.path.basename(path) #返回文件名os.path.commonprefix(list) #返回list(多个路径)中&#xff0c;所有path共有的最长的路径。os.path.dirname(path) #返回文件路径os.path.exists(path) #路径存在则返回True,路径损坏返回Falseos.path…

探索性数据分析(EDA):Python

什么是探索性数据分析(EDA)&#xff1f; (What is Exploratory Data Analysis(EDA)?) If we want to explain EDA in simple terms, it means trying to understand the given data much better, so that we can make some sense out of it.如果我们想用简单的术语来解释EDA&a…

微服务框架---搭建 go-micro环境

1.安装micro 需要使用GO1.11以上版本 #linux 下 export GO111MODULEon export GOPROXYhttps://goproxy.io # windows下设置如下环境变量 setx GO111MODULE on setx GOPROXY https://goproxy.io # 使用如下指令安装 go get -u -v github.com/micro/micro go get -u -v github.co…

angular dom_Angular 8 DOM查询:ViewChild和ViewChildren示例

angular domThe ViewChild and ViewChildren decorators in Angular provide a way to access and manipulate DOM elements, directives and components. In this tutorial, well see an Angular 8 example of how to use the two decorators.Angular中的ViewChild和ViewChild…

浪潮之巅——IT产业的三大定律

http://www.cnblogs.com/ysocean/p/7641540.html转载于:https://www.cnblogs.com/czlovezmt/p/8325772.html

DStream算子讲解(一)

先把目录列好&#xff0c;方便有条理的进行整理转载于:https://www.cnblogs.com/leodaxin/p/7507600.html

aws 静态网站_如何使用AWS托管静态网站-入门指南

aws 静态网站When I created my first portfolio last year, I based it on what I had learned from freeCodeCamp (HTML, CSS and a little JavaScript). 去年创建我的第一个投资组合时 &#xff0c;我基于从freeCodeCamp (HTML&#xff0c;CSS和一些JavaScript)中学到的知识…

leetcode 27. 移除元素(双指针)

给你一个数组 nums 和一个值 val&#xff0c;你需要 原地 移除所有数值等于 val 的元素&#xff0c;并返回移除后数组的新长度。 不要使用额外的数组空间&#xff0c;你必须仅使用 O(1) 额外空间并 原地 修改输入数组。 元素的顺序可以改变。你不需要考虑数组中超出新长度后面…

使用TVP批量插入数据

TVP&#xff08;全称 :Table-Valued Parameter&#xff09; 叫做表值参数(Table-Valued Parameter)是SQL2008的一个新特性。顾名思义&#xff0c;表值参数表示你可以把一个表类型作为参数传递到函数或存储过程里。 第一步&#xff1a;创建一个Type类型和写入数据的原始表结构相…

python:找出两个列表中相同和不同的元素(使用推导式)

#接口返回值 list1 [张三, 李四, 王五, 老二] #数据库返回值 list2 [张三, 李四, 老二, 王七]a [x for x in list1 if x in list2] #两个列表表都存在 b [y for y in (list1 list2) if y not in a] #两个列表中的不同元素print(a的值为:,a) print(b的值为:,b)c [x for x …

springcloud(六):配置中心git示例

随着线上项目变的日益庞大&#xff0c;每个项目都散落着各种配置文件&#xff0c;如果采用分布式的开发模式&#xff0c;需要的配置文件随着服务增加而不断增多。某一个基础服务信息变更&#xff0c;都会引起一系列的更新和重启&#xff0c;运维苦不堪言也容易出错。配置中心便…

写作工具_4种加快数据科学写作速度的工具

写作工具I’ve been writing about data science on Medium for just over two years. Writing, in particular, technical writing can be time-consuming. Not only do you need to come up with an idea, write well, edit your articles for accuracy and flow, and proofr…