mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-03 23:40:14 +08:00
commit
4d0345f72a
@ -1,15 +1,13 @@
|
||||
开发 Linux 调试器第二部分:断点
|
||||
开发一个 Linux 调试器(二):断点
|
||||
============================================================
|
||||
|
||||
在该系列的第一部分,我们写了一个小的进程启动器,作为我们调试器的基础。在这篇博客中,我们会学习在 x86 Linux 上断点如何工作以及给我们工具添加设置断点的能力。
|
||||
|
||||
* * *
|
||||
在该系列的第一部分,我们写了一个小的进程启动器,作为我们调试器的基础。在这篇博客中,我们会学习在 x86 Linux 上断点是如何工作的,以及如何给我们工具添加设置断点的能力。
|
||||
|
||||
### 系列文章索引
|
||||
|
||||
随着后面文章的发布,这些链接会逐渐生效。
|
||||
|
||||
1. [启动][2]
|
||||
1. [准备环境][2]
|
||||
2. [断点][3]
|
||||
3. 寄存器和内存
|
||||
4. Elves 和 dwarves
|
||||
@ -20,11 +18,9 @@
|
||||
9. 读取变量
|
||||
10.之后步骤
|
||||
|
||||
* * *
|
||||
### 断点是如何形成的?
|
||||
|
||||
### 断点如何形成?
|
||||
|
||||
有两种类型的断点:硬件和软件。硬件断点通常涉及设置和体系结构相关的寄存器来为你产生断点,而软件断点则涉及修改正在执行的代码。在这篇文章中我们只会关注软件断点,因为它们比较简单,而且可以设置任意多断点。在 x86 机器上任一时刻你最多只能有 4 个硬件断点,但是它们能使你通过读取或者写入给定地址生效,而不是只有当执行到那里的时候。
|
||||
有两种类型的断点:硬件和软件。硬件断点通常涉及到设置与体系结构相关的寄存器来为你产生断点,而软件断点则涉及到修改正在执行的代码。在这篇文章中我们只会关注软件断点,因为它们比较简单,而且可以设置任意多断点。在 x86 机器上任一时刻你最多只能有 4 个硬件断点,但是它们能让你在读取或者写入给定地址时触发,而不是只有当代码执行到那里的时候。
|
||||
|
||||
我前面说软件断点是通过修改正在执行的代码实现的,那么问题就来了:
|
||||
|
||||
@ -32,15 +28,13 @@
|
||||
* 为了设置断点我们要做什么修改?
|
||||
* 如何告知调试器?
|
||||
|
||||
第一个问题的答案显然是 `ptrace`。我们之前已经用它来启动我们的程序以便跟踪和继续它的执行,但我们也可以用它来读或者写内存。
|
||||
第一个问题的答案显然是 `ptrace`。我们之前已经用它为我们的程序设置跟踪并继续程序的执行,但我们也可以用它来读或者写内存。
|
||||
|
||||
当执行到断点时,我们的更改要让处理器暂停并给程序发送信号。在 x86 机器上这是通过 `int 3` 重写该地址上的指令实现的。x86 机器有个`interrupt vector table`(中断向量表),操作系统能用它来为多种事件注册处理程序,例如页故障、保护故障和无效操作码。它就像是注册错误处理回调函数,但是在硬件层面的。当处理器执行 `int 3` 指令时,控制权就被传递给断点中断处理器,对于 Linux 来说,就是给进程发送 `SIGTRAP` 信号。你可以在下图中看到这个进程,我们用 `0xcc` 覆盖了 `mov` 指令的第一个字节,它是 `init 3` 的指令代码。
|
||||
当执行到断点时,我们的更改要让处理器暂停并给程序发送信号。在 x86 机器上这是通过 `int 3` 重写该地址上的指令实现的。x86 机器有个中断向量表(interrupt vector table),操作系统能用它来为多种事件注册处理程序,例如页故障、保护故障和无效操作码。它就像是注册错误处理回调函数,但是是在硬件层面的。当处理器执行 `int 3` 指令时,控制权就被传递给断点中断处理器,对于 Linux 来说,就是给进程发送 `SIGTRAP` 信号。你可以在下图中看到这个进程,我们用 `0xcc` 覆盖了 `mov` 指令的第一个字节,它是 `init 3` 的指令代码。
|
||||
|
||||
![断点](http://blog.tartanllama.xyz/assets/breakpoint.png)
|
||||
|
||||
最后一个谜题是调试器如何被告知中断的。如果你回顾前面的文章,我们可以用 `waitpid` 来监听被发送给被调试程序的信号。这里我们也可以这样做:设置断点、继续执行程序、调用 `waitpid` 然后等待直到发生 `SIGTRAP`。然后就可以通过打印已运行到的源码位置、或改变有图形用户界面的调试器中关注的代码行,将这个断点传达给用户。
|
||||
|
||||
* * *
|
||||
谜题的最后一个部分是调试器如何被告知中断的。如果你回顾前面的文章,我们可以用 `waitpid` 来监听被发送给被调试的程序的信号。这里我们也可以这样做:设置断点、继续执行程序、调用 `waitpid` 并等待直到发生 `SIGTRAP`。然后就可以通过打印已运行到的源码位置、或改变有图形用户界面的调试器中关注的代码行,将这个断点传达给用户。
|
||||
|
||||
### 实现软件断点
|
||||
|
||||
@ -66,9 +60,10 @@ private:
|
||||
uint64_t m_saved_data; //data which used to be at the breakpoint address
|
||||
};
|
||||
```
|
||||
|
||||
这里的大部分代码都是跟踪状态;真正神奇的地方是 `enable` 和 `disable` 函数。
|
||||
|
||||
正如我们上面学到的,我们要用 `int 3` 指令 - 编码为 `0xcc` - 替换当前指定地址的指令。我们还要保存该地址之前的值,以便后面恢复代码;我们不想忘了执行用户的代码。
|
||||
正如我们上面学到的,我们要用 `int 3` 指令 - 编码为 `0xcc` - 替换当前指定地址的指令。我们还要保存该地址之前的值,以便后面恢复该代码;我们不想忘了执行用户(原来)的代码。
|
||||
|
||||
```
|
||||
void breakpoint::enable() {
|
||||
@ -81,9 +76,9 @@ void breakpoint::enable() {
|
||||
}
|
||||
```
|
||||
|
||||
`ptrace` 的 `PTRACE_PEEKDATA` 请求完成如何读取被跟踪进程的内存。我们给它一个进程 ID 和一个地址,然后它返回给我们该地址当前的 64 位内容。 `(m_saved_data & ~0xff)` 把这个数据的低位字节置零,然后我们用它和我们的 `int 3` 指令按位或 `OR` 来设置断点。然后我们通过 `PTRACE_POKEDATA` 用我们的新数据覆盖那部分内存来设置断点。
|
||||
`PTRACE_PEEKDATA` 请求告知 `ptrace` 如何读取被跟踪进程的内存。我们给它一个进程 ID 和一个地址,然后它返回给我们该地址当前的 64 位内容。 `(m_saved_data & ~0xff)` 把这个数据的低位字节置零,然后我们用它和我们的 `int 3` 指令按位或(`OR`)来设置断点。最后我们通过 `PTRACE_POKEDATA` 用我们的新数据覆盖那部分内存来设置断点。
|
||||
|
||||
`disable` 的实现比较简单,我们只需要恢复用 `0xcc` 覆盖的原始数据。
|
||||
`disable` 的实现比较简单,我们只需要恢复用 `0xcc` 所覆盖的原始数据。
|
||||
|
||||
```
|
||||
void breakpoint::disable() {
|
||||
@ -92,8 +87,6 @@ void breakpoint::disable() {
|
||||
}
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
### 在调试器中增加断点
|
||||
|
||||
为了支持通过用户界面设置断点,我们要在 debugger 类修改三个地方:
|
||||
@ -115,7 +108,7 @@ private:
|
||||
}
|
||||
```
|
||||
|
||||
在 `set_breakpoint_at_address` 函数中我们会新建一个 breakpoint 对象、启用它、把它添加到数据结构里、并给用户打印一条信息。如果你喜欢的话,你可以重构所有的输出信息,从而你可以将调试器作为库或者命令行工具使用,为了简便,我把它们都整合到了一起。
|
||||
在 `set_breakpoint_at_address` 函数中我们会新建一个 breakpoint 对象,启用它,把它添加到数据结构里,并给用户打印一条信息。如果你喜欢的话,你可以重构所有的输出信息,从而你可以将调试器作为库或者命令行工具使用,为了简便,我把它们都整合到了一起。
|
||||
|
||||
```
|
||||
void debugger::set_breakpoint_at_address(std::intptr_t addr) {
|
||||
@ -146,23 +139,19 @@ void debugger::handle_command(const std::string& line) {
|
||||
}
|
||||
```
|
||||
|
||||
我删除了字符串中的前两个字符并对结果调用 `std::stol`,为了让解析更加强壮,你也可以修改它。`std::stol` 可以将字符串按照所给基数转化为整数。
|
||||
|
||||
* * *
|
||||
我删除了字符串中的前两个字符并对结果调用 `std::stol`,你也可以让该解析更健壮一些。`std::stol` 可以将字符串按照所给基数转化为整数。
|
||||
|
||||
### 从断点继续执行
|
||||
|
||||
如果你尝试这样做,你可能会发现,如果你从断点处继续执行,不会发生任何事情。这是因为断点仍然在内存中,因此一直被命中。简单的解决办法就是停用这个断点、运行到下一步、再次启用这个断点、然后继续执行。不过我们还需要更改程序计数器,指回到断点前面,这部分内容会留到下一篇关于操作寄存器的文章中介绍。
|
||||
|
||||
* * *
|
||||
如果你尝试这样做,你可能会发现,如果你从断点处继续执行,不会发生任何事情。这是因为断点仍然在内存中,因此一直被重复命中。简单的解决办法就是停用这个断点、运行到下一步、再次启用这个断点、然后继续执行。不过我们还需要更改程序计数器,指回到断点前面,这部分内容会留到下一篇关于操作寄存器的文章中介绍。
|
||||
|
||||
### 测试它
|
||||
|
||||
当然,如果你不知道要设置的地址,在某些地址设置断点并非很有用。后面我们会学习如何在函数名或者代码行设置断点,但现在我们可以通过手动实现。
|
||||
当然,如果你不知道要在哪个地址设置,那么在某些地址设置断点并非很有用。后面我们会学习如何在函数名或者代码行设置断点,但现在我们可以通过手动实现。
|
||||
|
||||
测试你调试器的简单方法是写一个 hello world 程序,这个程序输出到 `std::err`(为了避免缓存),并在调用输出操作符的地方设置断点。如果你继续执行被调试的程序,执行很可能会停止而不会输出任何东西。然后你可以重启调试器并在调用之后设置一个断点,现在你应该看到成功地输出了消息。
|
||||
|
||||
查找地址的一个方法是使用 `objdump`。如果你打开一个终端并执行 `objdump -d <your program>`,然后你应该看到你程序的反汇编代码。然后你就可以找到 `main` 函数并定位到你想设置断点的 `call` 指令。例如,我编译了一个 hello world 程序,反汇编它,然后得到了 `main` 的反汇编代码:
|
||||
查找地址的一个方法是使用 `objdump`。如果你打开一个终端并执行 `objdump -d <your program>`,然后你应该看到你的程序的反汇编代码。你就可以找到 `main` 函数并定位到你想设置断点的 `call` 指令。例如,我编译了一个 hello world 程序,反汇编它,然后得到了如下的 `main` 的反汇编代码:
|
||||
|
||||
```
|
||||
0000000000400936 <main>:
|
||||
@ -178,8 +167,6 @@ void debugger::handle_command(const std::string& line) {
|
||||
|
||||
正如你看到的,要没有输出,我们要在 `0x400944` 设置断点,要看到输出,要在 `0x400949` 设置断点。
|
||||
|
||||
* * *
|
||||
|
||||
### 总结
|
||||
|
||||
现在你应该有了一个可以启动程序、允许在内存地址上设置断点的调试器。后面我们会添加读写内存和寄存器的功能。再次说明,如果你有任何问题请在评论框中告诉我。
|
||||
@ -190,7 +177,7 @@ void debugger::handle_command(const std::string& line) {
|
||||
|
||||
via: http://blog.tartanllama.xyz/c++/2017/03/24/writing-a-linux-debugger-breakpoints/
|
||||
|
||||
作者:[Simon Brand ][a]
|
||||
作者:[Simon Brand][a]
|
||||
译者:[ictlyh](https://github.com/ictlyh)
|
||||
校对:[jasminepeng](https://github.com/jasminepeng)
|
||||
|
||||
@ -198,5 +185,5 @@ via: http://blog.tartanllama.xyz/c++/2017/03/24/writing-a-linux-debugger-breakpo
|
||||
|
||||
[a]:http://blog.tartanllama.xyz/
|
||||
[1]:http://blog.tartanllama.xyz/c++/2017/03/21/writing-a-linux-debugger-setup/
|
||||
[2]:http://blog.tartanllama.xyz/c++/2017/03/24/writing-a-linux-debugger-breakpoints/
|
||||
[2]:https://linux.cn/article-8626-1.html
|
||||
[3]:https://github.com/TartanLlama/minidbg/tree/tut_break
|
@ -1,43 +1,39 @@
|
||||
使用 Ubuntu Cleaner 为 Ubuntu/LinuxMint 释放空间 (Janitor 模块的衍生)
|
||||
使用 Ubuntu Cleaner 为 Ubuntu/LinuxMint 释放空间
|
||||
============================================================
|
||||
|
||||
|
||||
我们中的大部分人都会经常忘记清理 Linux 系统中的垃圾文件,这会导致我们的系统空间不足。
|
||||
|
||||
一般情况下我们不得不按标准的程序来释放 Linux 发行版中的空间(删除发行缓存,系统日志,应用程序缓存和垃圾邮件),但如果我们每次以手动方式执行相同的过程,那么会花费大量的时间和困难。
|
||||
一般情况下我们不得不按标准的程序来释放 Linux 发行版中的空间(删除发行版缓存、系统日志、应用程序缓存和垃圾邮件),但如果我们每次以手动方式执行相同的过程,那么会花费大量的时间和困难。
|
||||
|
||||
在 Linux 的应用程序中,可以使这个任务更容易。今天我们将教你关于从 Janitor 模块衍生的的 Ubuntu Cleaner(它是 Ubuntu 调整中的一个模块)。
|
||||
在 Linux 的应用程序中,可以使这个任务更容易。今天我们将教你如何使用 Ubuntu Cleaner,它衍生自 Ubuntu Tweak 中的 Janitor 模块。
|
||||
|
||||
[Ubuntu Cleaner][2] 是一个可以简化你清理 Ubuntu 系统的工具。如我们所知道,Ubuntu Tweak 是帮助我们调整 Ubuntu 及其衍生产品的最佳实用程序之一。但由于他的主要开发人员没有时间维护它,因此已被弃用。
|
||||
[Ubuntu Cleaner][2] 是一个可以简化你清理 Ubuntu 系统的工具。如我们所知道,Ubuntu Tweak 是帮助我们调整 Ubuntu 及其衍生发行版的最佳实用程序之一。但由于它的主要开发人员没有时间维护它,因此已被弃用。
|
||||
|
||||
建议阅读:[Stacer - Linux 系统优化和监控工具][3]
|
||||
建议阅读:
|
||||
|
||||
建议阅读:[BleachBit - 在 Linux 中清理系统的快速而最佳方法][4]
|
||||
- [Stacer - Linux 系统优化和监控工具][3]
|
||||
- [BleachBit - 在 Linux 中清理系统的快速而最佳方法][4]
|
||||
|
||||
因为许多用户在最新版本中仍使用 Ubuntu tweak 这个工具(因为他们不想离开这个工具),所以 Ubuntu Cleaner 的开发人员从 Ubuntu tweak 工具中复刻了 janitor 模块,并将这个有用的功能带回 Ubuntu 社区,并命名为 Ubuntu cleaner。它也成为了 Ubuntu 多年来最受欢迎的实用程序之一。
|
||||
因为许多用户在最新版本中仍使用 Ubuntu Tweak 这个工具(因为他们不想离开这个工具),所以 Ubuntu Cleaner 的开发人员从 Ubuntu Tweak 工具中复刻了 janitor 模块,并将这个有用的功能带回 Ubuntu 社区,并命名为 Ubuntu Cleaner。它也成为了 Ubuntu 多年来最受欢迎的实用程序之一。
|
||||
|
||||
建议阅读:[uCareSystem - 用于 Ubuntu / LinuxMint 的一体化系统更新和维护工具][5]
|
||||
建议阅读:
|
||||
|
||||
我猜所有那些怀念 Ubuntu tweak 的人都会因为有 Ubuntu Cleaner 而感到高兴,因为它是从 janitor 模块衍生出来的。
|
||||
- [uCareSystem - 用于 Ubuntu / LinuxMint 的一体化系统更新和维护工具][5]
|
||||
|
||||
Ubuntu Cleaner 将删除 Ubuntu 及其衍生产品中的以下垃圾文件:
|
||||
我猜所有那些怀念 Ubuntu Tweak 的人都会因为有 Ubuntu Cleaner 而感到高兴,因为它是从 janitor 模块衍生出来的。
|
||||
|
||||
Ubuntu Cleaner 将删除 Ubuntu 及其衍生发行版中的以下垃圾文件:
|
||||
|
||||
* 应用缓存 (浏览器 缓存)
|
||||
|
||||
* 应用缓存 (浏览器缓存)
|
||||
* 缩略图缓存
|
||||
|
||||
* Apt 缓存
|
||||
|
||||
* 旧的内核
|
||||
|
||||
* 包的配置文件
|
||||
|
||||
* 不需要的包
|
||||
|
||||
#### 如何安装 Ubuntu Cleaner
|
||||
### 如何安装 Ubuntu Cleaner
|
||||
|
||||
开发者提供官方 PPA 后,我们可以通过 PPA 轻松地将 Ubuntu Cleaner 安装到 Ubuntu 及其衍生产品。 Ubuntu Cleaner 目前支持 Ubuntu 14.04 LTS 和 Ubuntu 16.04 LTS。
|
||||
因为开发者提供官方 PPA ,我们可以通过 PPA 轻松地将 Ubuntu Cleaner 安装到 Ubuntu 及其衍生发行版。 Ubuntu Cleaner 目前支持 Ubuntu 14.04 LTS 和 Ubuntu 16.04 LTS。
|
||||
|
||||
```
|
||||
$ sudo add-apt-repository ppa:gerardpuig/ppa
|
||||
@ -45,25 +41,27 @@ $ sudo apt update
|
||||
$ sudo apt install ubuntu-cleaner
|
||||
```
|
||||
|
||||
#### 如何使用 Ubuntu Cleaner
|
||||
### 如何使用 Ubuntu Cleaner
|
||||
|
||||
从主菜单启动 Ubuntu Cleaner ,你可以看到得以下默认界面。
|
||||
|
||||
[![](http://www.2daygeek.com/wp-content/uploads/2017/06/Ubuntu-Cleaner_001.png)][6]
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2017/06/Ubuntu-Cleaner_001.png)
|
||||
|
||||
勾选你要清理的文件前面的 “复选框”。 最后点击 “清理” 按钮从系统中删除垃圾文件。
|
||||
[![](http://www.2daygeek.com/wp-content/uploads/2017/06/Ubuntu-Cleaner_002.png)][7]
|
||||
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2017/06/Ubuntu-Cleaner_002.png)
|
||||
|
||||
现在我们已经成功清除了系统中的垃圾。
|
||||
[![](http://www.2daygeek.com/wp-content/uploads/2017/06/Ubuntu-Cleaner_003.png)][8]
|
||||
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2017/06/Ubuntu-Cleaner_003.png)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.2daygeek.com/ubuntu-cleaner-system-cleaner-ubuntu-tweak-alternative-janitor/#
|
||||
via: http://www.2daygeek.com/ubuntu-cleaner-system-cleaner-ubuntu-tweak-alternative-janitor/
|
||||
|
||||
作者:[2DAYGEEK][a]
|
||||
译者:[chenxinlong](https://github.com/chenxinlong)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,125 +0,0 @@
|
||||
GHLandy Translating
|
||||
|
||||
简览 6 大形象的开源商标
|
||||
============================================================
|
||||
|
||||
![A look at 6 iconic open source brands](https://opensource.com/sites/default/files/styles/image-full-size/public/images/business/BUSINESS_brandbalance.png?itok=opwotgEh "A look at 6 iconic open source brands")
|
||||
Image by :
|
||||
|
||||
opensource.com
|
||||
|
||||
Branding is an integral part of marketing. When it's done right and makes an impact, a simple logo (like a Nike swoosh) becomes a powerful advertisement in of itself. Just drive down any interstate in America and you'll see symbols that tell you about a brand. Like, the golden arches. Even certain color combinations can be identified with a brand without any additional text or images to give further context. Like, Virginia Tech University's maroon and orange; they are a unique color combination that is hard to mistake.
|
||||
|
||||
So, the question is: How is branding important to the open source community?
|
||||
|
||||
There is a strong argument from me, and many others, that yes it does very much. Open source software competes with paid software, and so must define itself as a viable, realistic alternative. It must also be memoriable and make an impact. If an open source software project represents itself with a poorly designed logo, a bad tagline, and inconsistent messaging, it will be hard to get noticed, be remembered, and be taken seriously.
|
||||
|
||||
There are many projects doing it right that we can look to for inspiration and guidance. Here are six of my favorites.
|
||||
|
||||
### Six open source brands
|
||||
|
||||
###
|
||||
![Linux's Tux mascot](https://opensource.com/sites/default/files/resize/linux-300x354.png "Linux&#039;s Tux mascot")
|
||||
|
||||
### Linux
|
||||
|
||||
The beloved Linux penguin is named Tux, and he is considered the mascot, not the logo.
|
||||
|
||||
Tux was created by Larry Ewing, using GIMP 0.54 in 1996. [The story][4], as told by Jeff Ayers, is that Linus Torvalds had a fixation on penguins after being bitten by one at an Australian zoo in 1993\. Torvalds was looking for a fun image for Linux and felt that a fat penguin resting after a meal was the perfect solution. Tux has found his way into video games, cereal commercials, and even has a female pal, named Gown. Tux is as familiar to Linux users as the bitten-apple is to Mac users and the flying window is to Windows users.
|
||||
|
||||
![Mozilla new logo 2017](https://opensource.com/sites/default/files/resize/mozilla_1-650x185.png "Mozilla new logo 2017")
|
||||
|
||||
### Mozilla
|
||||
|
||||
The [Mozilla][5] Foundation is non-profit organization and [free-software community][6].
|
||||
|
||||
Recently wrapping up [a long rebranding effort][7], their creative team leader, Tim Murray, wrote, "At the core of this project is the need for Mozilla's purpose and brand to be better understood by more people. Our brand identity—our logo, our voice, our design—is an important signal of what we believe in and what we do."
|
||||
|
||||
In true open source fashion, Mozilla has invited everyone to contribute. "Thousands of emails, hundreds of meetings, dozens of concepts, and three rounds of research later, we have something to share." But, they're still working on the guidelines, so there's still time to get involved.
|
||||
|
||||
![Firefox logo](https://opensource.com/sites/default/files/firefox_0.png "Firefox logo")
|
||||
|
||||
### Firefox
|
||||
|
||||
[Firefox][8] is Mozilla's flagship software product and a popular [web browser][9].
|
||||
|
||||
The "fox" in Firefox is actually a red panda, which is a real animal, a cat-like creature native to China. The story is that Firefox was originally nicknamed "Phoenix" to denote its rising from the ashes of Netscape Navigator. The name was changed to Mozilla Firebird after a trademark dispute with Phoenix Technologies. Then, in February 2004, the name was changed to Mozilla Firefox, after the Firebird RDMS project said it caused confusion with its own projects.
|
||||
|
||||
Early logos for Firefox and Phoenix were criticized by interface designer Steve Garrity, who detailed the flaws in the post "[Branding Mozilla: Towards Mozilla 2.0][10]." So, Mozilla invited Garrity to lead better branding efforts. New icons were developed by silverorange, and the final renderings were done by Jon Hicks, who has done branding work for Camino, MailChimp, and Opera.
|
||||
|
||||
In 2013, the Firefox logo was a final clue on "[Jeopardy!][11]" that asked what the animal was in the logo. None of the three contestants knew the answer is a red panda, instead answering "su," "raccoon," and "Excel."
|
||||
|
||||
![Wilber the Gimp logo](https://opensource.com/sites/default/files/resize/gimp-300x300.png "Wilber the Gimp logo")
|
||||
|
||||
### GIMP
|
||||
|
||||
GIMP's logo is [Wilber the GIMP][12], created on September 25, 1997 by Tuomas Kuosmanen.
|
||||
|
||||
GIMP is an acronym for GNU Image Manipulation Program, and it is used for photo retouching and image manipulation. Wilber has had some accessories added, such as a hard hat, by Simon Budig, and a wizard cap, by Raphaël Quintet. According to GIMP's [Linking to Us][13] page, the use of Wilber is highly encouraged and you can even get the Wilber Construction Kit included in the source code in **/docs/Wilber_Construction_Kit.xcf.gz**.
|
||||
|
||||
What kind of creature is Wilber? Apparently, that's up for discussion. A forum on [gimper.net][14] offers many theories: coyote, panda, dog, or a "Goofy" derivative, just to name a few. A user named "TheWarrior" on [GimpChat.com][15], emailed Kuosmanen directly and was told, "Wilber is an animal of its own species: a 'GIMP.' What a GIMP is, is sort of a joke, because people kept asking it so much: It would be so boring to say it's a dog or a fox or whatever. And when I designed the character, I did not really have any particular animal in mind."
|
||||
|
||||
![PostgreSQL logo](https://opensource.com/sites/default/files/postgresql.png "PostgreSQL logo")
|
||||
|
||||
### PostgreSQL
|
||||
|
||||
As you've seen and probably know, animals are popular in logos.
|
||||
|
||||
An elephant named [Slonik][16] is part of the logo for [PostgreSQL][17], an open source Relational Database Management System (RDMS). Patrycja Dybka, writing for "Vertabelo," explains that the name is derived from the Russian word for "elephants," which is "slony." Oleg Bartunov said that the logo was first considered in an [email thread][18]. In it, the elephant was suggested by David Yang at St. Joseph's University in Philadelphia: "…but if you want an animal-based logo, how about some sort of elephant? After all, as the Agatha Christie title read, _Elephants Can Remember_."
|
||||
|
||||
![VLC logo](https://opensource.com/sites/default/files/resize/vlc-300x340.png "VLC logo")
|
||||
|
||||
### VLC media player
|
||||
|
||||
This logo diverges from the animal theme with... a traffic cone.
|
||||
|
||||
VLC is the ubiquitous media player that seems to appear on desktops magically—giving many a taste of open source without even knowing it! VLC is a product of the VideoLAN project, supported by the VideoLAN organization, which is based in France. VideoLAN began in 1996 as a student project at École Centrale Paris. According to Wikipedia, the traffic cone image is a reference to traffic cones collected from the streets of Paris by the École Centrale's Networking Students' Association. The original hand-drawn illustrated logo was re-rendered in 2006 by Richard Oistad.
|
||||
|
||||
Fun tidbits include:
|
||||
|
||||
* Seamus Islwyn's post _[What Does the Traffic Cone Mean in VLC?][1]_ tells us that in the month of December, the VLC cone wears a Santa hat, which disappears on December 31 and reverts back to the original cone.
|
||||
* Some say that VLC stands for "Very Large Cone" or the cone was chosen because of a connection with Cone, France.
|
||||
* Is the "official" story accurate? An exchange on the [VideoLAN Forum][2] between VLC's Jean-Baptiste Kempf and users seems to indicate that the traffic cone collection theory, as well as the funnel, the construction zone, the megaphone, and several other theories, may not be correct.
|
||||
|
||||
Will we ever get the definitive answer on the origins of the VLC traffic cone? My personal theory: It's "Saturday Night Live's" Coneheads. They were from France, remember? Remulak, to be exact.
|
||||
|
||||
**I'd love to hear from you in the comments about which other open source logos you love, hate, and feel excel at representing their brands.**
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
译者简介:
|
||||
|
||||
Jeff Macharyas - Jeff Macharyas has worked in publishing and graphics for many years and has been the art director for Quick Printing, The American Spectator, the USO’s OnPatrol, Today’s Campus, and other publications as well as a project manager, editor, and circulation manager. Jeff holds a BS in Communications from Florida State University, a Graduate Certificate in Social Media Marketing from Rutgers University and a Master’s in Cybersecurity and Computer Forensics from Utica College.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/17/2/six-open-source-brands
|
||||
|
||||
作者:[Jeff Macharyas ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/jeffmacharyas
|
||||
[1]:http://www.ehow.com/info_10029162_traffic-cone-mean-vlc.html
|
||||
[2]:https://forum.videolan.org/viewtopic.php?f=5&t=92513
|
||||
[3]:https://opensource.com/article/17/2/six-open-source-brands?rate=Lmf1lD4etve4Apqfhw3NUV3SeENsNXhGqTh8OO4PzzQ
|
||||
[4]:https://en.wikipedia.org/wiki/Tux
|
||||
[5]:https://www.mozilla.org/en-US/
|
||||
[6]:https://en.wikipedia.org/wiki/Mozilla
|
||||
[7]:https://blog.mozilla.org/opendesign/arrival/
|
||||
[8]:https://en.wikipedia.org/wiki/Firefox
|
||||
[9]:https://en.wikipedia.org/wiki/Web_browser
|
||||
[10]:http://actsofvolition.com/steven/mozillabranding/
|
||||
[11]:http://www.complex.com/pop-culture/2013/09/firefox-jeopardy-answer
|
||||
[12]:https://www.gimp.org/about/ancient_history.html
|
||||
[13]:https://www.gimp.org/about/linking.html
|
||||
[14]:https://gimper.net/threads/what-is-wilber.793/
|
||||
[15]:http://gimpchat.com/viewtopic.php?f=4&t=10265
|
||||
[16]:http://www.vertabelo.com/blog/notes-from-the-lab/the-history-of-slonik-the-postgresql-elephant-logo
|
||||
[17]:https://wiki.postgresql.org/wiki/Logo
|
||||
[18]:http://www.pgsql.ru/db/mw/msg.html?mid=1238939
|
||||
[19]:https://opensource.com/user/83821/feed
|
||||
[20]:https://opensource.com/article/17/2/six-open-source-brands#comments
|
||||
[21]:https://opensource.com/users/jeffmacharyas
|
@ -1,3 +1,5 @@
|
||||
translating---geekpi
|
||||
|
||||
Powerline – A Powerful Statusline Plugin For Vim & Bash Terminal
|
||||
============================================================
|
||||
|
||||
|
@ -0,0 +1,127 @@
|
||||
简览 6 大形象的开源商标
|
||||
=====================
|
||||
|
||||
![简览 6 大形象的开源商标](https://opensource.com/sites/default/files/styles/image-full-size/public/images/business/BUSINESS_brandbalance.png?itok=opwotgEh "A look at 6 iconic open source brands")
|
||||
|
||||
图像来源:opensource.com
|
||||
|
||||
品牌商标是营销的重要组成部分。完成了品牌商标的塑造并形成一定的影响力之后,一个简单的 Logo (就像耐克旋风) 就会成为这个品牌的强大广告。如果你常常美国各州际驾驶,你将会看描述品牌商标的各种标志符号,如金色拱门 (golden arches)。即便是没有结合任何文字或图像的简单色彩也是可以用来作为一个品牌商标的,比如美国弗吉尼亚理工大学的栗色和橙色,这种独特的色彩结合是很难出错的。
|
||||
|
||||
所以,现在的问题是:商标对于开源社区是否真的那么重要呢?
|
||||
|
||||
对于我和其他很多的人都会说,是的,非常重要。开源软件要与付费软件进行竞争,那么它必须要由自己的可行性、现实可替代性的定义。并且,它也必须要让人容易记住以及形成一定程度的影响力。如果某个开源软件项目通过一个设计和口号都糟糕、前后信息矛盾的 Logo 来表现自己的话,那它就很难引起大众的注意、很难让人记住、很难获得广泛使用。
|
||||
|
||||
|
||||
现有很多项目都已经完成了自己品牌商标,我们可以从中寻找灵感和指导方法。一下是我最喜欢的六个开源商标。
|
||||
|
||||
### 六大开源商标
|
||||
|
||||
![Linux's Tux 吉祥物](https://opensource.com/sites/default/files/resize/linux-300x354.png "Linux&#039;s Tux mascot")
|
||||
|
||||
### Linux
|
||||
|
||||
这个可爱的 Linux 企鹅叫做 Tux,人们通常将其称为吉祥物,而非 Logo。
|
||||
|
||||
Tux 是 Larry Ewing 在 1996 年使用 GIMP 0.54 创建出来的。Jeff Ayers 则告诉了我们这样一个[故事][4]:自从 Linus Torvalds 1993 年在澳大利亚某个动物园被一只企鹅咬了一口之后,他就特别的钟爱它们。Tux 同时也闻名于视频游戏和食品广告,它甚至还有一个叫做 Gown 的异性同伴。正如 Mac 用户熟知那个被咬了一口的苹果、Windows 用户熟知浮动窗口那样,作为 Linux 用户,你肯定也非常熟悉 Tux。
|
||||
|
||||
![Mozilla 2017 的新 Logo ](https://opensource.com/sites/default/files/resize/mozilla_1-650x185.png "Mozilla new logo 2017")
|
||||
|
||||
### Mozilla
|
||||
|
||||
[Mozilla][5] 是一个非营利组织和 [自由软际社区][6]。
|
||||
|
||||
近期,它完成了 [商标重新设计][7],他们那个富有创造力的领导者 Tim Murray 这样子写道:“该项目的核心就是 Mozilla 自身的目的和商标能够让人们更好的理解”。我们的商标等同于我们的 Logo、我们的内心声音以及我们的设计,这是我们一个用以表明我们自身信仰和我们所做工作的的重要信号。
|
||||
|
||||
我们以真正的开源方式邀请所有人来为项目贡献自己的力量。“数千个电子邮件、数百个会议、数十个概念模型,以及之后的多轮讨究,我们把自己的想法都分享出来。”但是,我们仍然是在指导方针的指导下进行工作,所以我们还需要你参与到贡献中来。
|
||||
|
||||
![Firefox logo](https://opensource.com/sites/default/files/firefox_0.png "Firefox logo")
|
||||
|
||||
### Firefox
|
||||
|
||||
[Firefox][8] 是 Mozilla 开发的一款优秀软件产品,它也是一个非常受欢迎的 [web 浏览器][9]。
|
||||
|
||||
Firefox 中的 "fox" 实际上是一个真实存在的红色熊猫 —— 一种中国本土的猫科动物。故事是这样的:Firefox 原本有个 "Phoenix" 的别称,表明它是由 Netscape 浏览器发展而来的。在经历了 Phoenix 科技的商标起诉之后,它更名为 Mozilla Firebird。然后,Firebird RDMS 说它给自身项目带来了歧义,它的名称最终在 2004 年 02 月变更为 Mozilla Firefox。
|
||||
|
||||
平面设计师 Steve Garrity 对 Firefox and Phoenix 早期的 Logo 作出了批判,在 "[商标化 Mozilla: 走向 Mozilla 2.0][10] 一文中详细阐述了各种缺陷。所以,Mozilla 邀请 Garrity 来领导更好的商标化工作。新图标是由 silverorange 开发出来的,但最终的渲染却是 Jon Hicks,他同时也为 Camino、MailChimp 和 Opera 进行过商标化工作。
|
||||
|
||||
早在 2013 年,[Jeopardy!][11] 上边关于询问 Firefox 使用哪个动物做 Logo 则成了最后的线索。三位回答者都不知道答案就是一个红色熊猫,而是回答了 "su"、 "raccoon" 和 "Excel"。
|
||||
|
||||
![Wilber the Gimp logo](https://opensource.com/sites/default/files/resize/gimp-300x300.png "Wilber the Gimp logo")
|
||||
|
||||
### GIMP
|
||||
|
||||
GIMP 的 Logo 是由 Tuomas Kuosmanen 在 1997 年 09 月 25 日创建的 [Wilber the GIMP][12]。
|
||||
|
||||
GIMP 是 GNU 图像处理程序 (GNU Image Manipulation Program) 的缩写,主要用于图片修整和图像处理。Wilber 现在已经有了一些配饰,比如 Simon Budig 设计的一顶硬帽、Raphaël Quintet 设计的巫师帽。根据 GIMP [Linking to Us][13] 页面,它高度鼓励人们使用 Wilber,你甚至可以在源代码中的 **/docs/Wilber_Construction_Kit.xcf.gz** 获得 Wilber 的构建工具集。
|
||||
|
||||
那么,Wilber 到底是那一种生物呢?很显然,这是一个值得热烈讨论的问题。[gimper.net][14] 上的一个论坛则是众说纷纭:一种产于北美大草原的小狼 (coyote)、熊猫、狗或者高飞狗 (Goofy) 的一种不知名衍生物种。[GimpChat.com][15] 上一位叫做 TheWarrior 的用户直接发邮件给 Kuosmanen,说 Wilber 是一种独立物种的动物 —— 一种 GIMP。什么是 GIMP,一连续的笑话,因为人们一直在问,说它是一只狗、狐狸或者其他什么的会是非常无聊的。我设计的这一个形象的时候,在我脑袋中并没有一种指定的动物原型。
|
||||
|
||||
![PostgreSQL logo](https://opensource.com/sites/default/files/postgresql.png "PostgreSQL logo")
|
||||
|
||||
### PostgreSQL
|
||||
|
||||
正如你所见和熟悉的一样,使用动物头像来做 Logo 非常普遍。
|
||||
|
||||
一只名为 [Slonik][16] 的大象就是 [PostgreSQL][17] Logo 的一部分,这是一个开源的关系型数据库管理系统 (RDMS)。Patrycja Dybka 曾为 Vertabelo 写作过,解释了这一名称是由俄罗斯单词 elephants (也就是 slony) 演化而来的。Oleg Bartunov 也说过,这个 Logo 是在一个 [邮件组][18] 中初步形成的。在那里边,在费城圣约瑟夫大学的 David Yang 建议使用大象:“但如果你想要一个动物头像的 Logo,那么使用大象的如何? 毕竟就像阿加莎·克里斯蒂 (侦探小说家 Agatha Christie) 说的那样,_大象让人印象深刻_”。
|
||||
|
||||
![VLC logo](https://opensource.com/sites/default/files/resize/vlc-300x340.png "VLC logo")
|
||||
|
||||
### VLC 媒体播放器
|
||||
|
||||
该 Logo 是从交通锥标的动物主题中分离出来的。
|
||||
|
||||
VLC是一款无处不在的媒体播放器,它出现在多数的桌面电脑上,它似乎神奇地给了很多人一种开源的体验,却是很少人不知道它具体是什么。VLC 是 VideoLAN 项目的一款基于发文的产品,由 VideoLAN 提供支持。VideoLAN 源自 1996 年在 École Centrale Paris 的一个学生项目。根据维基百科的描述,这个交通锥标图标象征着由 École Centrale 网络学生组织收集巴黎街道上的交通锥。Richard Oistad 在2006 年重新渲染了最原始的手稿演示 Logo。
|
||||
|
||||
|
||||
一些有趣的花絮:
|
||||
|
||||
* Seamus Islwyn 发布的 _[VLC 中的交通锥表达了那些含义?(What Does the Traffic Cone Mean in VLC?)][1]_ 告诉我们:在十二月的时候,VLC 锥会戴着一顶圣诞帽,但在 12 月 31 日它就会消失不见,恢复原样的锥。
|
||||
* 有人说,VLC 表示 “非常大的锥 (Very Large Cone)” 或者选用它仅仅是为了和法国那些交通锥进行关联而已。
|
||||
* “官方” 的故事背景是否准确?在 VLC 的 jean-baptiste Kempf 和用户之间的视频论坛上的交流似乎表明,交通锥收集理论以及漏斗、建筑区、扩音器和其他一些理论,可能是不正确的。
|
||||
|
||||
我们是否明确回答了 VLC 的交通锥原型呢?我个人觉得:那就是 “星期六夜晚的现场” 傻瓜。他们来自法国,记得吗?Remulak,激动吧!
|
||||
|
||||
**我很期待看到你关于自己喜欢、讨厌以及为它所代表的商标而倍感激动的那些开源 Logo 的评论。**
|
||||
|
||||
------------
|
||||
|
||||
作者简介:
|
||||
|
||||
Jeff Macharyas - 他有多年的出版和印刷工作经验,他曾担任过快速印刷、美国观察家、USO 巡逻、今天校园和其他出版物的艺术总监以及项目经理、编辑和发行经理。杰夫持有佛罗里达州立大学的通信信息、罗格斯大学的社会媒体营销研究生证书以及 Utica 学院的网络安全与计算机取证硕士学位。
|
||||
|
||||
------------
|
||||
|
||||
译者简介:
|
||||
|
||||
[GHLandy](http://ghlandy.com) —— 另一种生活中,有属于你也适合你的舞台。或许有你狠心放弃的专业,或者不必上妆,不用摆出另外一副面孔。—— 摘自林特特《以自己喜欢的方式过一生》
|
||||
|
||||
via: https://opensource.com/article/17/2/six-open-source-brands
|
||||
|
||||
作者:[Jeff Macharyas ][a]
|
||||
译者:[GHLandy](https://github.com/GHLandy)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/jeffmacharyas
|
||||
[1]:http://www.ehow.com/info_10029162_traffic-cone-mean-vlc.html
|
||||
[2]:https://forum.videolan.org/viewtopic.php?f=5&t=92513
|
||||
[3]:https://opensource.com/article/17/2/six-open-source-brands?rate=Lmf1lD4etve4Apqfhw3NUV3SeENsNXhGqTh8OO4PzzQ
|
||||
[4]:https://en.wikipedia.org/wiki/Tux
|
||||
[5]:https://www.mozilla.org/en-US/
|
||||
[6]:https://en.wikipedia.org/wiki/Mozilla
|
||||
[7]:https://blog.mozilla.org/opendesign/arrival/
|
||||
[8]:https://en.wikipedia.org/wiki/Firefox
|
||||
[9]:https://en.wikipedia.org/wiki/Web_browser
|
||||
[10]:http://actsofvolition.com/steven/mozillabranding/
|
||||
[11]:http://www.complex.com/pop-culture/2013/09/firefox-jeopardy-answer
|
||||
[12]:https://www.gimp.org/about/ancient_history.html
|
||||
[13]:https://www.gimp.org/about/linking.html
|
||||
[14]:https://gimper.net/threads/what-is-wilber.793/
|
||||
[15]:http://gimpchat.com/viewtopic.php?f=4&t=10265
|
||||
[16]:http://www.vertabelo.com/blog/notes-from-the-lab/the-history-of-slonik-the-postgresql-elephant-logo
|
||||
[17]:https://wiki.postgresql.org/wiki/Logo
|
||||
[18]:http://www.pgsql.ru/db/mw/msg.html?mid=1238939
|
||||
[19]:https://opensource.com/user/83821/feed
|
||||
[20]:https://opensource.com/article/17/2/six-open-source-brands#comments
|
||||
[21]:https://opensource.com/users/jeffmacharyas
|
@ -1,4 +1,4 @@
|
||||
开发 Linux 调试器第三部分:寄存器和内存
|
||||
开发 Linux 调试器(三):寄存器和内存
|
||||
============================================================
|
||||
|
||||
上一篇博文中我们给调试器添加了一个简单的地址断点。这次,我们将添加读写寄存器和内存的功能,这将使我们能够使用我们的程序计数器、观察状态和改变程序的行为。
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
随着后面文章的发布,这些链接会逐渐生效。
|
||||
|
||||
1. [启动][3]
|
||||
1. [准备环境][3]
|
||||
|
||||
2. [断点][4]
|
||||
|
||||
@ -29,12 +29,11 @@
|
||||
|
||||
10. 下一步
|
||||
|
||||
译者注:ELF([Executable and Linkable Format](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format "Executable and Linkable Format") 可执行文件格式),DWARF(一种广泛使用的调试数据格式,参考 [WIKI](https://en.wikipedia.org/wiki/DWARF "DWARF WIKI"))
|
||||
* * *
|
||||
|
||||
### 注册我们的寄存器
|
||||
|
||||
在我们真正读取任何寄存器之前,我们需要告诉调试器更多关于我们平台,也就是 x86_64 的信息。除了多组通用和专用目的寄存器,x86_64 还提供浮点和向量寄存器。为了简化,我将跳过后两种寄存器,但是你如果喜欢的话也可以选择支持它们。x86_64 也允许你像访问 32、16 或者 8 位寄存器那样访问一些 64 位寄存器,但我只会介绍 64 位寄存器。由于这些简化,对于每个寄存器我们只需要它的名称,它的 DWARF 寄存器编号以及 `ptrace` 返回结构体中的存储地址。我使用范围枚举引用这些寄存器,然后我列出了一个全局寄存器描述符数组,其中元素顺序和 `ptrace` 中寄存器结构体相同。
|
||||
在我们真正读取任何寄存器之前,我们需要告诉调试器一些关于我们的目标,也就是 x86_64 的信息。除了多组通用和专用目的寄存器,x86_64 还提供浮点和向量寄存器。为了简化,我将跳过后两种寄存器,但是你如果喜欢的话也可以选择支持它们。x86_64 也允许你像访问 32、16 或者 8 位寄存器那样访问一些 64 位寄存器,但我只会介绍 64 位寄存器。由于这些简化,对于每个寄存器我们只需要它的名称,它的 DWARF 寄存器编号以及 `ptrace` 返回结构体中的存储地址。我使用范围枚举引用这些寄存器,然后我列出了一个全局寄存器描述符数组,其中元素顺序和 `ptrace` 中寄存器结构体相同。
|
||||
|
||||
```
|
||||
enum class reg {
|
||||
@ -169,7 +168,7 @@ void debugger::dump_registers() {
|
||||
|
||||
正如你看到的,iostreams 有非常精确的接口用于美观地输出十六进制数据[2][10]。如果你喜欢你也可以通过 I/O 操纵器来摆脱这种混乱。
|
||||
|
||||
这些已经足够支持我们在调试器接下来的部分轻松地处理寄存器,因为我们现在可以把这些添加到我们的用户界面。
|
||||
这些已经足够支持我们在调试器接下来的部分轻松地处理寄存器,所以我们现在可以把这些添加到我们的用户界面。
|
||||
|
||||
* * *
|
||||
|
||||
@ -196,7 +195,7 @@ void debugger::dump_registers() {
|
||||
|
||||
### 接下来做什么?
|
||||
|
||||
设置断点的时候我们已经读取和写入内存,因此我们只需要添加一些函数用于隐藏 `ptrace`调用。
|
||||
设置断点的时候我们已经读取和写入内存,因此我们只需要添加一些函数用于隐藏 `ptrace` 调用。
|
||||
|
||||
```
|
||||
uint64_t debugger::read_memory(uint64_t address) {
|
||||
@ -309,7 +308,7 @@ void debugger::continue_execution() {
|
||||
|
||||
```
|
||||
|
||||
你要将程序计数器移回 `0x40093a` 使得正确设置 `esi` and `edi` 寄存器。
|
||||
你要将程序计数器移回 `0x40093a` 以便正确设置 `esi` 和 `edi` 寄存器。
|
||||
|
||||
在下一篇博客中,我们会第一次接触到 DWARF 信息并给我们的调试器添加一系列逐步调试的功能。之后,我们会有一个功能工具,它能逐步执行代码、在想要的地方设置断点、修改数据以及其它。一如以往,如果你有任何问题请留下你的评论!
|
||||
|
||||
@ -327,15 +326,15 @@ via: https://blog.tartanllama.xyz/c++/2017/03/31/writing-a-linux-debugger-regist
|
||||
|
||||
作者:[ TartanLlama ][a]
|
||||
译者:[ictlyh](https://github.com/ictlyh)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[jasminepeng](https://github.com/jasminepeng)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.twitter.com/TartanLlama
|
||||
[1]:https://blog.tartanllama.xyz/c++/2017/03/31/writing-a-linux-debugger-registers/#fnref:2
|
||||
[2]:https://blog.tartanllama.xyz/c++/2017/03/31/writing-a-linux-debugger-registers/#fnref:1
|
||||
[3]:https://blog.tartanllama.xyz/2017/03/21/writing-a-linux-debugger-setup/
|
||||
[4]:https://blog.tartanllama.xyz/c++/2017/03/24/writing-a-linux-debugger-breakpoints/
|
||||
[3]:https://linux.cn/article-8626-1.html
|
||||
[4]:https://linux.cn/article-8645-1.html
|
||||
[5]:https://blog.tartanllama.xyz/c++/2017/03/31/writing-a-linux-debugger-registers/
|
||||
[6]:https://blog.tartanllama.xyz/c++/2017/04/05/writing-a-linux-debugger-elf-dwarf/
|
||||
[7]:https://blog.tartanllama.xyz/c++/2017/04/24/writing-a-linux-debugger-source-signal/
|
||||
|
@ -1,20 +1,18 @@
|
||||
translating---geekpi
|
||||
|
||||
Automatically Create/Remove And Mount Swap File In Linux Using Shell Script
|
||||
在 Linux 中使用 shell 脚本自动创建/移除并挂载交换文件
|
||||
============================================================
|
||||
|
||||
|
||||
Few days ago we have covered an article about swap file creation in Linux using three ways which is the common method but it requires manual human effort.
|
||||
几天前我们写了一篇关于在 Linux 中 3 种创建交换文件的方法,它们是常见的方法,但是需要人工操作。
|
||||
|
||||
Today i have found a small shell script (Two shell script, one for swap file creation and another one for removing swap file) which was written by [Gary Stafford][3] that help us to create/remove & mount swap file automatically in Linux.
|
||||
今天我发现了一个小的 [Gary Stafford][3] 写的 shell 脚本(两个 shell 脚本,一个用于创建交换文件,另外一个用于移除交换文件),它帮助我们在 Linux 中创建/移除并且自动挂载交换文件。
|
||||
|
||||
By default the script create and mount `512MB` swapfile. If you want more swap space and different file name you have to modify the script accordingly. It’s not a big deal to modify the script since it’s very handy and small script, even though i have colored the line where you want to modify the script.
|
||||
默认这个脚本创建并挂载 `512MB` 的交换文件。如果你想要更多的交换空间和不同的文件名,你需要相应地修改脚本。修改脚本不是一件困难的事,因为这是一个非常上手而且小的脚本,设置我已经为你想要修改的脚本行加上了颜色。
|
||||
|
||||
**Suggested Read : **[3 Easy Ways To Create Or Extend Swap Space In Linux][4]
|
||||
**推荐阅读:** [Linux 中 3 中简易的创建或扩展交换空间的方法][4]
|
||||
|
||||
#### How to check current swap size
|
||||
#### 如何检查当前交换文件大小
|
||||
|
||||
Lets first check the size of existing swap space partition using **[free][1]** & `swapon` command.
|
||||
使用 **[free][1]** 和 `swapon` 命令检查已经存在交换空间。
|
||||
|
||||
```
|
||||
$ free -h
|
||||
@ -27,11 +25,11 @@ NAME TYPE SIZE USED PRIO
|
||||
/dev/sda5 partition 2G 655.2M -1
|
||||
```
|
||||
|
||||
The above output clearly shows `2GB` is my current swap space.
|
||||
上面的输出显示我当前的交换空间是 `2GB`。
|
||||
|
||||
#### Create Swap File
|
||||
#### 创建交换文件
|
||||
|
||||
Create `create_swap.sh` file and add below script to automate the swap space creation and mounting.
|
||||
创建 `create_swap.sh` 文件并添加下面的脚本来自动化交换空间的创建和挂载。
|
||||
|
||||
```
|
||||
$ nano create_swap.sh
|
||||
@ -61,13 +59,13 @@ echo '--------------------------------------------'
|
||||
swapon --show
|
||||
```
|
||||
|
||||
Add execute permission to the file.
|
||||
给文件添加执行权限。
|
||||
|
||||
```
|
||||
$ sudo +x create_swap.sh
|
||||
```
|
||||
|
||||
Run the file to create and mount swap file.
|
||||
运行文件来创建和挂载交换文件。
|
||||
|
||||
```
|
||||
$ sudo ./create_swap.sh
|
||||
@ -83,11 +81,11 @@ NAME TYPE SIZE USED PRIO
|
||||
/swapfile file 1024M 0B -2
|
||||
```
|
||||
|
||||
Yes i can see the new `1024M swapfile`. Reboot the system to use the new swap file.
|
||||
你可以看到新的 `1024M swapfile`。重启系统以使用新的交换文件。
|
||||
|
||||
#### Remove Swap File
|
||||
#### 移除交换文件
|
||||
|
||||
If the swap file is no longer required, then create `remove_swap.sh` file and add below script to remove swap file and its mount point from /etc/fstab.
|
||||
如果不再需要交换文件,接着创建 `remove_swap.sh` 文件并添加下面的脚本移除交换文件以及它的 /etc/fstab 挂载点。
|
||||
|
||||
```
|
||||
$ nano remove_swap.sh
|
||||
@ -113,13 +111,13 @@ echo '--------------------------------------------'
|
||||
swapon --show
|
||||
```
|
||||
|
||||
Add execute permission to the file.
|
||||
并给文件添加可执行权限。
|
||||
|
||||
```
|
||||
$ sudo +x remove_swap.sh
|
||||
```
|
||||
|
||||
Run the file to remve and unmount swap file.
|
||||
运行脚本来移除并卸载交换文件。
|
||||
|
||||
```
|
||||
$ sudo ./remove_swap.sh
|
||||
@ -140,7 +138,7 @@ NAME TYPE SIZE USED PRIO
|
||||
via: http://www.2daygeek.com/shell-script-create-add-extend-swap-space-linux/
|
||||
|
||||
作者:[2DAYGEEK ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user