diff --git a/published/20170111 The difference between development and deployment.md b/published/20170111 The difference between development and deployment.md new file mode 100644 index 0000000000..043217c594 --- /dev/null +++ b/published/20170111 The difference between development and deployment.md @@ -0,0 +1,59 @@ +一位老极客的眼中的开发和部署 +============================================================ + +![The difference between development and deployment](https://opensource.com/sites/default/files/styles/image-full-size/public/images/business/BUS_OpenSourceExperience_520x292_cm.png?itok=APna2N9Y "The difference between development and deployment") + +图片提供 : opensource.com + +多年前,我曾是一名 Smalltalk 程序员,这种经验让我以一种不同的视角来观察编程的世界,例如,需要花时间来适应源代码应该存储在文本文件中的这种做法。 + +我们作为程序员通常会区分“开发”和“部署”,特别是我们在开发的地方所使用的工具不同于我们在之后部署软件时的地点和工具时。而在 Smalltalk 世界里,没有这样的区别。 + +Smalltalk 构建于虚拟机包含了你的开发环境(IDE、调试器、文本编辑器、版本控制等)的思路之上,如果你需要修改任何一处代码,你得修改内存中运行副本。如果需要的话,你可以为运行中的机器做个快照;如果你想分发你的代码,你可以发送一个运行中的机器的镜像副本(包括 IDE、调试器、文本编辑器、版本控制等)给用户。这就是上世纪 90 年代软件开发的方式(对我们中的一些人来说)。 + +如今,部署环境与开发环境有了很大的不同。起初,你不要期望那里(指部署环境)有任何开发工具。一旦部署,就没有版本控制、没有调试、没有开发环境。有的是记录和监视,这些在我们的开发环境中都没有,而有一个“构建管道”,它将我们的软件从开发形式转换为部署形式。作为一个例证,Docker 容器则试图重新找回上世纪 90 年代 Smalltalk 程序员部署体验的那种简单性,而避免同样的开发体验。 + +我想如果 Smalltalk 世界是我唯一的编程方面的体验,让我无法区分开发和部署环境,我可能会偶尔回顾一下它。但是在我成为一名 Smalltalk 程序员之前,我还是一位 APL 程序员,这也是一个可修改的虚拟机镜像的世界,其中开发和部署是无法区分的。因此,我相信,在当前的时代,人们编辑单独的源代码文件,然后运行构建管道以创建在编辑代码时尚不存在的部署作品,然后将这些作品部署给用户。我们已经以某种方式将这种反模式的软件开发制度化,而不断发展的软件环境的需求正在迫使我们找回到上世纪 90 年代的更有效的技术方法。因此才会有 Docker 的成功,所以,我需要提出我的建议。 + +我有两个建议:我们在运行时系统中实现(并使用)版本控制,以及,我们通过更改运行中的系统来开发软件,而不是用新的运行系统替换它们。这两个想法是相关的。为了安全地更改正在运行的系统,我们需要一些版本控制功能来支持“撤消”功能。也许公平地说,我只提出了一个建议。让我举例来说明。 + +让我们开始假设一个静态网站。你要修改一些 HTML 文件。你应该如何工作?如果你像大多数开发者一样,你会有两个,也许三个网站 - 一个用于开发,一个用于 QA(或者预发布),一个用于生产。你将直接编辑开发实例中的文件。准备就绪后,你将把你的修改“部署”到预发布实例。在用户验收测试之后,你将再次部署,这次是生产环境。 + +使用 Occam 的 Razor,让我们可以避免不必要地创建实例。我们需要多少台机器?我们可以使用一台电脑。我们需要多少台 web 服务器?我们可以使用具有多个虚拟主机的单台 web 服务器。如果不使用多个虚拟主机的话,我们可以只使用单个虚拟主机吗?那么我们就需要多个目录,并需要使用 URL 的顶级路径来区分不同的版本,而不是虚拟主机名。但是为什么我们需要多个目录?因为 web 服务器将从文件系统中提供静态文件。我们的问题是,目录有三个不同的版本,我们的解决方案是创建目录的三个不同的副本。这不是正是 Subversion 和 Git 这样的版本控制系统解决的问题吗?制作目录的多个副本以存储多个版本的策略回到了版本控制 CVS 之前的日子。为什么不使用比如说一个空的的 Git 仓库来存储文件呢?要这样做,web 服务器将需要能够从 git 仓库读取文件(参见 [mod_git] [3])。 + +这将是一个支持版本控制的运行时系统。 + +使用这样的 web 服务器,使用的版本可以由 cookie 来标识。这样,任何人都可以推送到仓库,用户将继续看到他们发起会话时所分配的版本。版本控制系统有不可改变的提交; 一旦会话开始,开发人员可以在不影响正在运行的用户的情况下快速推送更改。开发人员可以重置其会话以跟踪他们的新提交,因此开发人员或测试人员就可能如普通用户一样查看在同台服务器上同一个 URL 上正在开发或正在测试的版本。作为偶然的副作用,A/B 测试仅仅是将不同的用户分配给不同的提交的情况。所有用于管理多个版本的 git 设施都可以在运行环境中发挥作用。当然,git reset 为我们提供了前面提到的“撤销”功能。 + +为什么不是每个人都这样做? + +一种可能性是,诸如版本控制系统的工具没有被设计为在生产环境中使用。例如,给某人推送到测试分支而不是生产分支的许可是不可能的。对这个方案最常见的反对是,如果发现了一个漏洞,你会想要将某些提交标记为不可访问。这将是另一种更细粒度的权限的情况;开发人员将具有对所有提交的读取权限,但外部用户不会。我们可能需要对现有工具进行一些额外的改造以支持这种模式,但是这些功能很容易理解,并已被设计到其他软件中。例如,Linux (或 PostgreSQL)实现了对不同用户的细粒度权限的想法。 + +随着云环境变得越来越普及,这些想法变得更加相关:云总是在运行。例如,我们可以看到,AWS 中等价的 “文件系统”(S3)实现了版本控制,所以你可能有一个不同的想法,使用一台 web 服务器提供来自 S3 的资源文件,并根据会话信息选择不同版本的资源文件。重要的并不是哪个实现是最好的,而是支持这种运行时版本控制的愿景。 + +部署的软件环境应该是“版本感知”的原则,应该扩展到除了服务静态文件的 web 服务器之外的其他工具。在将来的文章中,我将介绍版本库,数据库和应用程序服务器的方法。 + +_在 linux.conf.au 中了解更多 Robert Lefkowitz 2017 年 ([#lca2017][1])在 Hobart:[保持 Linux 伟大][2]的主题。_ + +-------------------------------------------------------------------------------- + +作者简介: + +![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/robert_lefkowitz.jpg?itok=CFoX-OUI) + +Robert M. Lefkowitz - Robert(即 r0ml)是一个喜欢复杂编程语言的编程语言爱好者。 他是一个提高清晰度、提高可靠性和最大限度地简化的编程技术收藏家。他通过让计算机更加容易获得来使它普及化。他经常演讲中世纪晚期和早期文艺复兴对编程艺术的影响。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/1/difference-between-development-deployment + +作者:[Robert M. Lefkowitz][a] +译者:[geekpi](https://github.com/geekpi) +校对:[Bestony](https://github.com/Bestony) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/r0ml +[1]:https://twitter.com/search?q=%23lca2017&src=typd +[2]:https://www.linux.conf.au/schedule/presentation/107/ +[3]:https://github.com/r0ml/mod_git diff --git a/translated/tech/20170511 How to Delete HUGE 100-200GB Files in Linux.md b/published/20170511 How to Delete HUGE 100-200GB Files in Linux.md similarity index 88% rename from translated/tech/20170511 How to Delete HUGE 100-200GB Files in Linux.md rename to published/20170511 How to Delete HUGE 100-200GB Files in Linux.md index 1ac853080a..d6b7d2ed09 100644 --- a/translated/tech/20170511 How to Delete HUGE 100-200GB Files in Linux.md +++ b/published/20170511 How to Delete HUGE 100-200GB Files in Linux.md @@ -1,25 +1,21 @@ 如何在 Linux 中删除大(100-200GB)文件 ============================================================ -作者:[Aaron Kili][11] | 发布日期: May 11, 2017 | 最后更新:May 11, 2017 - -立即下载你的免费电子书 - [10 本为管理员的免费 Linux 电子书][12] | [4 本免费 Shell 脚本电子书][13] - 通常,要[在 Linux 终端删除一个文件][1],我们使用 rm 命令(删除文件)、shred 命令(安全删除文件)、wipe 命令(安全擦除文件)或者 secure-deletion 工具包(一个[安全文件删除工具][2]集合)。 -我们可以使用下面任意的工具来处理相对较小的文件。如果我们想要删除大的文件/文件夹,比如大概 100-200GB。这个方法在删除文件(I/O 调度)所花费的时间以及 RAM 占用量方面看起来可能并不容易。 +我们可以使用上面任意的工具来处理相对较小的文件。如果我们想要删除大的文件/文件夹,比如大概 100-200GB。这个方法在删除文件(I/O 调度)所花费的时间以及 RAM 占用量方面看起来可能并不容易。 在本教程中,我们会解释如何在 Linux 中有效率并可靠地删除大文件/文件夹。 -**建议阅读:** [5 个在 Linux 中清空或者删除大文件的方法][3] +**建议阅读:** [5 个在 Linux 中清空或者删除大文件内容的方法][3] -主要的目标是使用一种不会在删除大文件时拖慢系统的技术,并有合理的 I/O 占用。我么可以用 ionice 命令实现这个目标。 +主要的目标是使用一种不会在删除大文件时拖慢系统的技术,并有合理的 I/O 占用。我们可以用 **ionice 命令**实现这个目标。 ### 在 Linux 中使用 ionice 命令删除大(200GB)文件 ionice 是一个可以为另一个程序设置或获取 I/O 调度级别和优先级的有用程序。如果没有给出参数或者只有 `-p`,那么 ionice 将会查询该进程的当前的 I/O 调度级别以及优先级。 -如果我们给出命令名称,如 rm 命令,它将使用给定的参数运行此命令。要指定要获取或设置调度参数的[进程的进程 ID],运行这个: +如果我们给出命令名称,如 rm 命令,它将使用给定的参数运行此命令。要指定要获取或设置调度参数的[进程的进程 ID][4],运行这个: ``` # ionice -p PID @@ -66,7 +62,7 @@ via: https://www.tecmint.com/delete-huge-files-in-linux/ 作者:[Aaron Kili ][a] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[jasminepeng](https://github.com/jasminepeng) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20170518 How to make Vim user-friendly with Cream.md b/published/20170518 How to make Vim user-friendly with Cream.md new file mode 100644 index 0000000000..66e289d214 --- /dev/null +++ b/published/20170518 How to make Vim user-friendly with Cream.md @@ -0,0 +1,69 @@ +如何使用 Cream 提高 Vim 的用户友好性 +============================================================ + +> Cream 附加包通过把一个更加熟悉的“面孔”置于 Vim 文本编辑器之上,同时保留 Vim 的功能,使其更加容易使用 + +![How to make Vim user-friendly with Cream](https://opensource.com/sites/default/files/styles/image-full-size/public/images/education/osdc_edu_rightmix_520.png?itok=SCsog_qv "How to make Vim user-friendly with Cream") + +图片来自 : opensource.com + +大约 10 年前,我既使用 Emacs 进行文本编辑,也使用 Vim 进行文本编辑。说到底,我的确是一个热衷于 Emacs 的家伙。尽管 Emacs 在我的心里占据了很重要的地位,但我知道, Vim 也不赖。 + +一些人,或者像我一样的人,在技术方面有些笨手笨脚。多年来,我和一些 Linux 新手交流,了解到他们想使用 Vim,但是却失望的发现, Vim 编辑器和他们在其它操作系统上使用过的编辑器不一样。 + +但是,当我把 Cream 介绍给他们以后,他们的失望就变成了满意。Cream 是 Vim 的一个附加包,它使得 Vim 更加容易使用。Cream 让这些 Linux 新手变成了 Vim 的坚决拥护者和忠心用户。 + +让我们来看一看 Cream 是什么以及它是如何让 Vim 变得更加容易使用的。 + +### Cream 的安装 + +在安装 Cream 之前,你需要先在你的电脑上安装好 Vim 和 GVim 的 GUI 组件。我发现最容易完成这件事的方法是使用 Linux 版本的包管理器。 + +安装好 Vim 以后,便可[下载 Cream 的安装程序][2],或者你也可以再次使用 Linux 发行版的包管理器进行安装。 + +安装好 Cream 以后,你可以从应用菜单选择它(比如,**Applications**->**Cream**)或者在程序启动器中输入 `Cream`,从而启动 Cream 。 + +![Cream’s main window](https://opensource.com/sites/default/files/resize/cream-main-window-520x336.png "Cream’s main window") + +### Cream 的使用 + +如果你之前已经使用过 Gvim,那么你会注意到, Cream 几乎没改变该编辑器的外观和感觉。最大的不同是 Cream 的菜单栏和工具栏,它们取代了 Gvim 陈旧的菜单栏和工具栏,新的菜单栏和工具栏的外观和功能分组看起来和其它编辑器的一样。 + +Cream 的菜单栏对用户隐藏了更多的技术选项,比如指定一个编译器的能力,以及运行 `make` 命令的能力。当你通过使用 Cream 更加熟悉 Vim 以后,你只需要从 **Setting**->**Preferences**->**Behavior** 选择选项,就可以更容易地访问这些特性。有了这些选项,你可以(如果你想)体验到一个兼有 Cream 和传统 Vim 二者优点的强大编辑器。 + +Cream 并不是仅由菜单驱动。尽管编辑器的功能仅有单击或双击两种方式,但是你也可以使用常见的键盘快捷键来执行操作,比如 `CTRL-O`(打开一个文件),`CTRL-C`(复制文本)。你不需要在几种模式之间切换,也不需要记住一些很难记住的命令。 + +Cream 开始运行以后,打开一个文件,或者新建一个文件,然后就可以开始输入了。几个我向他们介绍过 Cream 的人说,虽然 Cream 保留了 Vim 的许多典型风格,但是 Cream 使用起来更加舒服。 + +![Cream add-on for VIM in action](https://opensource.com/sites/default/files/cream-in-action.png "Cream add-on for VIM in action") + +并不是说 Cream 是 Vim 的简化版,远远不是。事实上, Cream 保留了 Vim 的全部特性,同时,它还有[一系列其他有用的特性][7]。我发现的 Cream 的一些有用的特性包括: + +* 一个标签式界面 +* 语法高亮(特别是针对 Markdown、LaTeX 和 HTML) +* 自动修正拼写错误 +* 字数统计 +* 内建文件浏览器 + +Cream 本身也有许多附加包,可以给编辑器增加一些新的特性。这些特性包括文本加密、清理电子邮件内容,甚至还有一个使用教程。老实说,我还没有发现哪一个附加包是真正有用的,不过你的感受可能会有所不同。 + +我曾听过一些 Vi/Vim 的狂热分子谴责 Cream “降低”(这是他们的原话)了 Vi/Vim 编辑器的水准。的确,Cream 并不是为他们设计的。它是为那些想快速使用 Vim ,同时保留他们曾经使用过的编辑器的外观和感觉的人准备的。在这种情况下, Cream 是值得赞赏的,它使得 Vim 更加容易使用,更加广泛的被人们使用。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/5/stir-bit-cream-make-vim-friendlier + +作者:[Scott Nesbitt][a] +译者:[ucasFL](https://github.com/ucasFL) +校对:[jasminepeng](https://github.com/jasminepeng) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/scottnesbitt +[1]:https://opensource.com/article/17/5/stir-bit-cream-make-vim-friendlier?rate=sPQVOnwWoNwyyQX4wV2SZ_7Ly_KXd_Gu9pBu16LRyhU +[2]:http://cream.sourceforge.net/download.html +[3]:http://cream.sourceforge.net/featurelist.html +[4]:https://opensource.com/user/14925/feed +[5]:https://opensource.com/article/17/5/stir-bit-cream-make-vim-friendlier#comments +[6]:https://opensource.com/users/scottnesbitt +[7]:http://cream.sourceforge.net/featurelist.html diff --git a/published/20170523 North Korea's Unit 180, the cyber warfare cell that worries the West.md b/published/20170523 North Korea's Unit 180, the cyber warfare cell that worries the West.md new file mode 100644 index 0000000000..b6b75bfe2c --- /dev/null +++ b/published/20170523 North Korea's Unit 180, the cyber warfare cell that worries the West.md @@ -0,0 +1,95 @@ +朝鲜 180 局的网络战部门让西方国家忧虑 +============================================================ + +本文译自澳大利亚广播公司相关文章,不代表本站及译者、编辑的态度。 + + [![在夜色的映衬下,部队的军车通过平壤市区](http://www.abc.net.au/news/image/8545124-3x2-700x467.jpg "Military trucks through Pyongyang")][13] + +*[PHOTO:脱北者说, 平壤的网络战攻击目的旨在为一个叫做“180局”的部门来筹集资金。(路透社:Damir Sagolj, file)][14]* + +> 据脱北者、官方和网络安全专家的消息,朝鲜的情报机关有一个叫做 180 局的特殊部门, 这个部门已经发起过多起胆大且成功的网络战。 + +近几年,朝鲜被指责在美国、韩国,及其周边的几个国家对金融网络发起多起在线袭击。 + +网络安全研究人员称他们找到了这个月全球性感染了 150 多个国家 30 多万台计算机的[“想哭”勒索病毒和朝鲜网络战有关联的技术证据][15]。 + +平壤称该指控是“荒谬的”。 + +对朝鲜的关键指控是指朝鲜与一个叫做拉撒路(Lazarus)的黑客组织有联系,这个组织是在去年在孟加拉国中央银行网络抢劫了 8100 万美元,并在 2014 年攻击了索尼的好莱坞工作室的网络。 + +美国政府指责朝鲜对索尼公司的黑客袭击,同时美国政府对平壤在孟加拉国银行的盗窃行为提起公诉并要求立案。 + +由于没有确凿的证据、没有犯罪指控并不能够立案。朝鲜之后也否认了索尼公司和该银行的袭击与其有关。 + +朝鲜是世界上最封闭的国家之一,它秘密行动的一些细节很难获得。 + +但研究这个封闭国家的专家和流落到韩国和一些西方国家的的脱北者已经给出了或多或少的提示。 + +### 黑客们喜欢以雇员身份来作为掩护 + +金恒光,一位朝鲜前计算机教授,2004 叛逃到韩国,他仍然有着韩国内部的消息来源,他说平壤的网络战目的在于通过侦察总局(RGB)下属的一个叫做 180 局来筹集资金,这个局主要是负责海外的情报机构。 + +金教授称,“180 局负责入侵金融机构通过漏洞从银行账户提取资金”。 + +他之前也说过,他以前的一些学生已经加入了朝鲜的网络战略司令部,即朝鲜的网络部队。 + +>“黑客们到海外寻找比朝鲜更好的互联网服务的地方,以免留下痕迹,” 金教授补充说。 + +他说他们经常用贸易公司、朝鲜的海外分公司和在中国和东南亚合资企业的雇员来作为掩护。 + +位于华盛顿的战略与国际研究中心的一位名为 James Lewis 的朝鲜专家称,平壤首先把黑客攻击作为间谍活动的工具,然后对韩国和美国的目的进行政治干扰。 + +他说,“索尼公司事件之后,他们改变方法,通过用黑客来支持犯罪活动来形成国内坚挺的货币经济政策。” + +“目前为止,网上毒品,假冒伪劣,走私,都是他们惯用的伎俩”。 + + +[**VIDEO:** 你遇到过勒索病毒吗? (ABC News)][16] : https://dn-linuxcn.qbox.me/static/video/CNb_Ransomware_1505_512k.mp4 + +### 韩国声称拥有“大量的证据” + +美国国防部称在去年提交给国会的一个报告中显示,朝鲜将网络视为有成本效益的、不对称的、可否认的工具,它能够应付来自报复性袭击的很小风险,因为它的“网络”大部分是和因特网分离的。 + +> 报告中说," 它可能从第三方国家使用互联网基础设施"。 + +韩国政府称,他们拥有朝鲜网络战行动的大量证据。 + +“朝鲜进行网络战通过第三方国家来掩护网络袭击的来源,并且使用他们的信息和通讯技术设施”,韩国外交部副部长安总基在书面评论中告诉路透社。 + +除了孟加拉银行抢劫案,他说怀疑平壤也与菲律宾、越南和波兰的银行袭击有关。 + +去年六月,警察称朝鲜袭击了 160 个韩国公司和政府机构,入侵了大约 14 万台计算机,暗中在它的对手的计算机中植入恶意代码,为进行大规模网络攻击的长期计划而准备。 + +朝鲜也被怀疑在 2014 年对韩国核反应堆操作系统进行阶段性网络攻击,尽管朝鲜否认与其无关。 + +根据在一个韩国首尔的杀毒软件厂商 hauri 的高级安全研究员 Simon Choi 的说法,网络袭击是来自于朝鲜在中国的一个基地。 + +Choi 先生,是一位对朝鲜的黑客能力有广泛的研究的人,他称,“他们在那里行动,不管他们究竟在做什么,他们拥有中国的 IP 地址”。 + +-------------------------------------------------------------------------------- + +via: http://www.abc.net.au/news/2017-05-21/north-koreas-unit-180-cyber-warfare-cell-hacking/8545106 + +作者:[www.abc.net.au][a] +译者:[hwlog](https://github.com/hwlog) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://www.abc.net.au +[1]:http://www.abc.net.au/news/2017-05-16/wannacry-ransomware-showing-up-in-obscure-places/8527060 +[2]:http://www.abc.net.au/news/2015-08-05/why-we-should-care-about-cyber-crime/6673274 +[3]:http://www.abc.net.au/news/2017-05-15/what-to-do-if-youve-been-hacked/8526118 +[4]:http://www.abc.net.au/news/2017-05-16/researchers-link-wannacry-to-north-korea/8531110 +[5]:http://www.abc.net.au/news/2017-05-18/adylkuzz-cyberattack-could-be-far-worse-than-wannacry:-expert/8537502 +[6]:http://www.google.com/maps/place/Korea,%20Democratic%20People%20S%20Republic%20Of/@40,127,5z +[7]:http://www.abc.net.au/news/2017-05-16/wannacry-ransomware-showing-up-in-obscure-places/8527060 +[8]:http://www.abc.net.au/news/2017-05-16/wannacry-ransomware-showing-up-in-obscure-places/8527060 +[9]:http://www.abc.net.au/news/2015-08-05/why-we-should-care-about-cyber-crime/6673274 +[10]:http://www.abc.net.au/news/2015-08-05/why-we-should-care-about-cyber-crime/6673274 +[11]:http://www.abc.net.au/news/2017-05-15/what-to-do-if-youve-been-hacked/8526118 +[12]:http://www.abc.net.au/news/2017-05-15/what-to-do-if-youve-been-hacked/8526118 +[13]:http://www.abc.net.au/news/2017-05-21/military-trucks-trhough-pyongyang/8545134 +[14]:http://www.abc.net.au/news/2017-05-21/military-trucks-trhough-pyongyang/8545134 +[15]:http://www.abc.net.au/news/2017-05-16/researchers-link-wannacry-to-north-korea/8531110 +[16]:http://www.abc.net.au/news/2017-05-15/have-you-been-hit-by-ransomware/8527854 diff --git a/sources/tech/20170426 Python-mode – A Vim Plugin to Develop Python Applications in Vim Editor.md b/sources/tech/20170426 Python-mode – A Vim Plugin to Develop Python Applications in Vim Editor.md index a9e18ddbbc..56df13f461 100644 --- a/sources/tech/20170426 Python-mode – A Vim Plugin to Develop Python Applications in Vim Editor.md +++ b/sources/tech/20170426 Python-mode – A Vim Plugin to Develop Python Applications in Vim Editor.md @@ -1,3 +1,5 @@ +ucasFL translating + Python-mode – A Vim Plugin to Develop Python Applications in Vim Editor ============================================================ diff --git a/sources/tech/20170506 ttyload – Shows a Color-coded Graph of Linux Load Average in Terminal.md b/sources/tech/20170506 ttyload – Shows a Color-coded Graph of Linux Load Average in Terminal.md deleted file mode 100644 index 341deadae7..0000000000 --- a/sources/tech/20170506 ttyload – Shows a Color-coded Graph of Linux Load Average in Terminal.md +++ /dev/null @@ -1,111 +0,0 @@ -ttyload – Shows a Color-coded Graph of Linux Load Average in Terminal -============================================================ - - Download Your Free eBooks NOW - [10 Free Linux eBooks for Administrators][12] | [4 Free Shell Scripting eBooks][13] - -ttyload is a lightweight utility which is intended to offer a color-coded graph of load averages over time on Linux and other Unix-like systems. It enables a graphical tracking of system load average in a terminal (“tty“). - -It is known to run on systems such as Linux, IRIX, Solaris, FreeBSD, MacOS X (Darwin) and Isilon OneFS. It is designed to be easy to port to other platforms, but this comes with some hard work. - -Some of its notable features are: it uses fairly standard, but hard-coded, ANSI escape sequences for screen manipulation and colorization. And also comes with (but doesn’t install, or even build by default) a relatively self-contained load bomb, if you want to view how things work on an otherwise unloaded system. - -**Suggested Read:** [GoTTY – Share Your Linux Terminal (TTY) as a Web Application][1] - -In this article, we will show you how to install and use ttyload in Linux to view a color-coded graph of your system load average in a terminal. - -### How to Install ttyload in Linux Systems - -On Debian/Ubuntu based distributions, you can install ttyload from the default system respositores by typing the following [apt-get command][2]. - -``` -$ sudo apt-get install ttyload -``` - -On Other Linux distributions you can install ttyload from the source as shown. - -``` -$ git clone https://github.com/lindes/ttyload.git -$ cd ttyload -$ make -$ ./ttyload -$ sudo make install -``` - -Once installed, you can start it by typing the following command. - -``` -$ ttyload -``` - [![ttyload - Graphical View of Linux Load Average](https://www.tecmint.com/wp-content/uploads/2017/05/ttyload-Graphical-View-of-Linux-Load-Average-.png)][3] - -ttyload – Graphical View of Linux Load Average - -Note: To close the program simply press `[Ctrl+C]` keys. - -You can also define the number of seconds in the interval between refreshes. Default value is 4, and the minimum is 1. - -``` -$ ttyload -i 5 -$ ttyload -i 1 -``` - -To run it in a monochrome mode which turns off ANSI escapes, use the `-m` as follows. - -``` -$ ttyload -m -``` - [![ttyload - Monochrome Mode](https://www.tecmint.com/wp-content/uploads/2017/05/ttyload-monochrome-mode.png)][4] - -ttyload – Monochrome Mode - -To get the ttyload usage info and help, type. - -``` -$ ttyload -h -``` - -Below are some of its important features yet to be added: - -* Support for arbitrary sizing. - -* Make an X front end using the same basic engine, to have “3xload”. - -* Logging-oriented mode. - -For more information, check out the ttyload Homepage: [http://www.daveltd.com/src/util/ttyload/][5] - -Thats all for now! In this article, we showed you how to install and use ttyload in Linux. Write back to us via the comment section below. - - --------------------------------------------------------------------------------- - -作者简介: - -Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge. - - - -------------------- - -via: https://www.tecmint.com/ttyload-shows-color-coded-graph-of-linux-load-average/ - -作者:[Aaron Kili ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.tecmint.com/author/aaronkili/ -[1]:https://www.tecmint.com/gotty-share-linux-terminal-in-web-browser/ -[2]:https://www.tecmint.com/useful-basic-commands-of-apt-get-and-apt-cache-for-package-management/ -[3]:https://www.tecmint.com/wp-content/uploads/2017/05/ttyload-Graphical-View-of-Linux-Load-Average-.png -[4]:https://www.tecmint.com/wp-content/uploads/2017/05/ttyload-monochrome-mode.png -[5]:http://www.daveltd.com/src/util/ttyload/ -[6]:https://www.tecmint.com/ttyload-shows-color-coded-graph-of-linux-load-average/# -[7]:https://www.tecmint.com/ttyload-shows-color-coded-graph-of-linux-load-average/# -[8]:https://www.tecmint.com/ttyload-shows-color-coded-graph-of-linux-load-average/# -[9]:https://www.tecmint.com/ttyload-shows-color-coded-graph-of-linux-load-average/# -[10]:https://www.tecmint.com/ttyload-shows-color-coded-graph-of-linux-load-average/#comments -[11]:https://www.tecmint.com/author/aaronkili/ -[12]:https://www.tecmint.com/10-useful-free-linux-ebooks-for-newbies-and-administrators/ -[13]:https://www.tecmint.com/free-linux-shell-scripting-books/ diff --git a/sources/tech/20170509 How to Password Protect a Vim File in Linux.md b/sources/tech/20170509 How to Password Protect a Vim File in Linux.md deleted file mode 100644 index 616d03b89b..0000000000 --- a/sources/tech/20170509 How to Password Protect a Vim File in Linux.md +++ /dev/null @@ -1,157 +0,0 @@ -How to Password Protect a Vim File in Linux -============================================================ -ch-cn translating - - Download Your Free eBooks NOW - [10 Free Linux eBooks for Administrators][16] | [4 Free Shell Scripting eBooks][17] - -[Vim][5] is a popular, feature-rich and highly-extensible [text editor for Linux][6], and one of its special features is support for encrypting text files using various crypto methods with a password. - -In this article, we will explain to you one of the simple Vim usage tricks; password protecting a file using Vim in Linux. We will show you how to secure a file at the time of its creation as well as after opening it for modification. - -**Suggested Read:** [10 Reasons Why You Should Use Vim Editor in Linux][7] - -To install the full version of Vim, simply run this command: - -``` -$ sudo apt install vim #Debian/Ubuntu systems -$ sudo yum install vim #RHEL/CentOS systems -$ sudo dnf install vim #Fedora 22+ -``` - -Read Also: [Vim 8.0 Is Released After 10 Years – Install on Linux][8] - -### How to Password Protect a Vim File in Linux - -Vim has a `-x` option which enables you to use encryption when creating files. Once you run the [vim command][9]below, you’ll be prompted for a crypt key: - -``` -$ vim -x file.txt -Warning: Using a weak encryption method; see :help 'cm' -Enter encryption key: ******* -Enter same key again: ******* -``` - -If the crypto key matches after entering it for the second time, you can proceed to modify the file. - - [![Vim File Password Protected](https://www.tecmint.com/wp-content/uploads/2017/05/Vim-File-Password-Protected-File.png)][10] - -Vim File Password Protected - -Once your done, press `[Esc]` and `:wq` to save and close the file. The next time you want to open it for editing, you’ll have to enter the crypto key like this: - -``` -$ vim file.txt -Need encryption key for "file.txt" -Warning: Using a weak encryption method; see :help 'cm' -Enter encryption key: ******* -``` - -In case you enter a wrong password (or no key), you’ll see some junk characters. - - [![Vim Content Encrypted](https://www.tecmint.com/wp-content/uploads/2017/05/Vim-Content-Encrypted.png)][11] - -Vim Content Encrypted - -#### Setting a Strong Encryption Method in Vim - -Note: There is a warning indicating that a weak encryption method has been used to protect the file. Next, we’ll see how to set a strong encryption method in Vim. - - [![Weak Encryption on Vim File](https://www.tecmint.com/wp-content/uploads/2017/05/Weak-Encryption-on-Vim-File.png)][12] - -Weak Encryption on Vim File - -To check the set of cryptmethod(cm), type (scroll down to view all available methods): - -``` -:help 'cm' -``` - -##### Sample Output - -``` - *'cryptmethod'* *'cm'* -'cryptmethod' 'cm' string (default "zip") -global or local to buffer |global-local| -{not in Vi} -Method used for encryption when the buffer is written to a file: -*pkzip* -zip PkZip compatible method. A weak kind of encryption. -Backwards compatible with Vim 7.2 and older. -*blowfish* -blowfish Blowfish method. Medium strong encryption but it has -an implementation flaw. Requires Vim 7.3 or later, -files can NOT be read by Vim 7.2 and older. This adds -a "seed" to the file, every time you write the file -options.txt [Help][RO] -``` - -You can set a new cryptomethod on a Vim file as shown below (we’ll use blowfish2 in this example): - -``` -:setlocal cm=blowfish2 -``` - -Then press `[Enter]` and `:wq` to save the file. - - [![Set Strong Encryption on Vim File](https://www.tecmint.com/wp-content/uploads/2017/05/Set-Strong-Encryption-on-Vim-File.png)][13] - -Set Strong Encryption on Vim File - -Now you should not see the warning message when you open the file again as shown below. - -``` -$ vim file.txt -Need encryption key for "file.txt" -Enter encryption key: ******* -``` - -You can also set a password after opening a Vim text file, use the command`:X` and set a crypto pass like shown above. - -Check out some of our useful articles on Vim editor. - -1. [Learn Useful Vim Editor Trips and Tricks in Linux][1] - -2. [8 Useful Vim Editor Tricks for Every Linux User][2] - -3. [spf13-vim – The Ultimate Distribution for Vim Editor][3] - -4. [How to Use Vim Editor as Bash IDE in Linux][4] - -That’s all! In this article, we explained how to password protect a file via the [Vim text editor in Linux][14]. - -Always remember to appropriately secure text files that could contain secret info such as usernames and passwords, financial account info and so on, using strong encryption and a password. Use the feedback section below to share any thoughts with us. - --------------------------------------------------------------------------------- - -作者简介: - -Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge. - ------------------- - -via: https://www.tecmint.com/password-protect-vim-file-in-linux/ - -作者:[Aaron Kili ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.tecmint.com/author/aaronkili/ -[1]:https://www.tecmint.com/learn-vi-and-vim-editor-tips-and-tricks-in-linux/ -[2]:https://www.tecmint.com/how-to-use-vi-and-vim-editor-in-linux/ -[3]:https://www.tecmint.com/spf13-vim-offers-vim-plugins-vim-editor/ -[4]:https://www.tecmint.com/use-vim-as-bash-ide-using-bash-support-in-linux/ -[5]:https://www.tecmint.com/vi-editor-usage/ -[6]:https://www.tecmint.com/best-open-source-linux-text-editors/ -[7]:https://www.tecmint.com/reasons-to-learn-vi-vim-editor-in-linux/ -[8]:https://www.tecmint.com/vim-8-0-install-in-ubuntu-linux-systems/ -[9]:https://www.tecmint.com/linux-command-line-editors/ -[10]:https://www.tecmint.com/wp-content/uploads/2017/05/Vim-File-Password-Protected-File.png -[11]:https://www.tecmint.com/wp-content/uploads/2017/05/Vim-Content-Encrypted.png -[12]:https://www.tecmint.com/wp-content/uploads/2017/05/Weak-Encryption-on-Vim-File.png -[13]:https://www.tecmint.com/wp-content/uploads/2017/05/Set-Strong-Encryption-on-Vim-File.png -[14]:https://www.tecmint.com/vi-editor-usage/ -[15]:https://www.tecmint.com/author/aaronkili/ -[16]:https://www.tecmint.com/10-useful-free-linux-ebooks-for-newbies-and-administrators/ -[17]:https://www.tecmint.com/free-linux-shell-scripting-books/ diff --git a/sources/tech/20170515 Show a Custom Message to Users Before Linux Server Shutdown.md b/sources/tech/20170515 Show a Custom Message to Users Before Linux Server Shutdown.md deleted file mode 100644 index 690aac80b0..0000000000 --- a/sources/tech/20170515 Show a Custom Message to Users Before Linux Server Shutdown.md +++ /dev/null @@ -1,79 +0,0 @@ -Show a Custom Message to Users Before Linux Server Shutdown -============================================================ - - -In a previous article, we explained the [difference between shutdown, poweroff, halt and reboot][3] Linux commands, where we uncovered what these mentioned commands actually do when you execute them with various options. - -This article will show you how to send a custom message to all system users before shutting down a Linux server. - -**Suggested Read:** [tuptime – Shows Historical and Statistical Running Time of Linux Systems][4] - -As a system administrator, before you can shut down a server, you may want to send system users a message alerting them that the system is going. By default, the shutdown command broadcasts a message to other system users as shown in the screenshot below: - -``` -# shutdown 13:25 -``` -Linux Shutdown Broadcast Message -``` -Shutdown scheduled for Fri 2017-05-12 13:25:00 EAT, use 'shutdown -c' to cancel. -Broadcast message for root@tecmint (Fri 2017-05-12 13:23:34 EAT): -The system is going down for power-off at Fri 2017-05-12 13:25:00 EAT! -``` - -To send a custom message to other system users before an in line shutdown, run the command below. In this example, the shutdown will happen after two minutes from the time of command execution: - -``` -# shutdown 2 The system is going down for required maintenance. Please save any important work you are doing now! -``` - [![Linux System Shutdown Message](https://www.tecmint.com/wp-content/uploads/2017/05/Linux-System-Shutdown-Message.png)][5] - -Linux System Shutdown Message - -Supposing you have certain critical system operations such as scheduled system backups or updates to be executed at a time the system would be down, you can cancel the shutdown using the `-c` switch as shown below and initiate it at a later time after such operations have been performed: - -``` -# shutdown -c -``` -Linux Shutdown Cancel Message -``` -Shutdown scheduled for Fri 2017-05-12 14:10:22 EAT, use 'shutdown -c' to cancel. -Broadcast message for root@tecmint (Fri 2017-05-14 :10:27 EAT): -The system shutdown has been cancelled at Fri 2017-05-12 14:11:27 EAT! -``` - -Additionally, learn how to [auto execute commands/scripts during reboot or startup][6] using simple and traditional methods in Linux. - -Don’t Miss: - -1. [Managing System Startup Process and Services (SysVinit, Systemd and Upstart)][1] - -2. [11 Cron Scheduling Task Examples in Linux][2] - -Now you know how to send custom messages to all other system users before a system shutdown. Are there any ideas you want to share relating to this topic? Use the comment form below to do that? - --------------------------------------------------------------------------------- - -作者简介: - -Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge. - ------------------- - -via: https://www.tecmint.com/show-linux-server-shutdown-message/ - -作者:[Aaron Kili ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.tecmint.com/author/aaronkili/ -[1]:https://www.tecmint.com/linux-boot-process-and-manage-services/ -[2]:https://www.tecmint.com/11-cron-scheduling-task-examples-in-linux/ -[3]:https://www.tecmint.com/shutdown-poweroff-halt-and-reboot-commands-in-linux/ -[4]:https://www.tecmint.com/find-linux-uptime-shutdown-and-reboot-time-with-tuptime/ -[5]:https://www.tecmint.com/wp-content/uploads/2017/05/Linux-System-Shutdown-Message.png -[6]:https://www.tecmint.com/auto-execute-linux-scripts-during-reboot-or-startup/ -[7]:https://www.tecmint.com/author/aaronkili/ -[8]:https://www.tecmint.com/10-useful-free-linux-ebooks-for-newbies-and-administrators/ -[9]:https://www.tecmint.com/free-linux-shell-scripting-books/ diff --git a/sources/tech/20170518 How to make Vim user-friendly with Cream.md b/sources/tech/20170518 How to make Vim user-friendly with Cream.md deleted file mode 100644 index 909294d537..0000000000 --- a/sources/tech/20170518 How to make Vim user-friendly with Cream.md +++ /dev/null @@ -1,75 +0,0 @@ -How to make Vim user-friendly with Cream -============================================================ - -### The Cream add-on makes the Vim text editor easier to use by putting a more familiar face on its functionality. - - - -![How to make Vim user-friendly with Cream](https://opensource.com/sites/default/files/styles/image-full-size/public/images/education/osdc_edu_rightmix_520.png?itok=SCsog_qv "How to make Vim user-friendly with Cream") -Image by :  - -opensource.com - -About 10 years ago, I split my text editing time between Emacs and Vim. That said, I was and definitely still am an Emacs guy. But while Emacs has always had an edge in my affections, I know that Vim is no slouch. - -So do other people—even those who, like me, are all thumbs technically. Over the years, I've talked to a few new Linux users who wanted to use Vim but were a bit disappointed that it doesn't act like the text editors they've used on other operating systems. - -That disappointment changed to satisfaction when I introduced them to Cream, an add-on for Vim that makes it easier to use. Cream turned each of them into diehard Vim users. - -Let's take a look at Cream and how it makes Vim easier to use. - -### Getting going with Cream - -Before you can install Cream, you'll need Vim and GVim GUI components installed on your computer. I find the easiest way to do that is to use your Linux distribution's package manager. - -Once you have Vim installed, grab [the installer][2] for Cream or, again, turn to your distribution's package manager. - -Once Cream is installed, you can fire it up by selecting the entry from the application menu (for example, **Applications > Cream**) or by typing **cream** into your program launcher. - -![Cream's main window](https://opensource.com/sites/default/files/resize/cream-main-window-520x336.png "Cream's main window") - -### Using Cream - -If you've used GVim before, you'll notice that Cream doesn't change the editor's look and feel too much. The biggest cosmetic differences are Cream's menu bar and toolbar, which replace the stock GVim menu bar and toolbar with ones that look and group functions like their counterparts in other applications. - -Cream's menus hide a lot of the more techie options—like the ability to specify a compiler and the **Make** command—from the user. As you get more familiar with Vim by using Cream, however, you can make more of those features more easily accessible by selecting an option from the **Settings > Preferences > Behavior** menu. With those options, you could (if you want to) wind up with an editor that behaves as a hybrid of Cream and traditional Vim. - -Cream isn't only driven by its menus. While the editor's functions are only a click or two away, you can also use common keyboard shortcuts to perform actions—for example, **CTRL-O** (to open a file) or **CTRL-C** (to copy text). There's no need to shift between modes or remember Vim's somewhat cryptic commands. - -With Cream running, get to work by opening a file or creating a new one. Then start typing. A couple or three of the people I've introduced to Cream have said that while it retains much of the classic styling of Vim, Cream feels more comfortable to use. - -![Cream add-on for VIM in action](https://opensource.com/sites/default/files/cream-in-action.png "Cream add-on for VIM in action") - -That's not to say Cream dumbs down or waters down Vim. Far from it. You still retain all of Vim's features, along with [a long list of others][3]. Some of the features of Cream that I find useful include: - -* A tabbed interface - -* Syntax highlighting (especially when working with Markdown, LaTeX, and HTML) - -* Auto correction of spelling mistakes - -* Word count - -* Built-in file explorer - -Cream also comes with a number of add-ons that give the editor some additional features. Those features include the ability to encrypt text and to clean up the body of emails, and there's even a typing tutor. To be honest, I haven't found any of the add-ons to be all that useful. Your mileage might vary, though. - -I've heard a few Vi/Vim purists pooh-pooh Cream for "dumbing down _"_  (their words) the editor. Let's be honest: Cream isn't for them. It's for someone who wants to quickly get up and running with Vim while retaining the look and feel of the editors they're used to. In that way, Cream succeeds admirably. It makes Vim a lot more accessible and usable to a wider range of people. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/5/stir-bit-cream-make-vim-friendlier - -作者:[ Scott Nesbitt ][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/scottnesbitt -[1]:https://opensource.com/article/17/5/stir-bit-cream-make-vim-friendlier?rate=sPQVOnwWoNwyyQX4wV2SZ_7Ly_KXd_Gu9pBu16LRyhU -[2]:http://cream.sourceforge.net/download.html -[3]:http://cream.sourceforge.net/featurelist.html -[4]:https://opensource.com/user/14925/feed -[5]:https://opensource.com/article/17/5/stir-bit-cream-make-vim-friendlier#comments -[6]:https://opensource.com/users/scottnesbitt diff --git a/sources/tech/20170518 Maintaining a Git Repository.md b/sources/tech/20170518 Maintaining a Git Repository.md deleted file mode 100644 index 5cb0fc1c00..0000000000 --- a/sources/tech/20170518 Maintaining a Git Repository.md +++ /dev/null @@ -1,246 +0,0 @@ -翻译中 zhousiyu325 - -Maintaining a Git Repository -============================================================ - -Maintenance of your Git repository typically involves reducing a repository's size.  If you imported from another version control system, you may need to clean up unnecessary files after the import.  This page focuses on removing large files from a Git repo and contains the following topics: - -* [Understanding file removal from Git history][1] - -* [Using the BFG to rewrite history][2] - -* [Alternatively, using git filter-branch to rewrite history][3] - -* [Garbage collecting dead data][4] - -Be very careful... - -The procedure and tools on this page use advanced techniques that involve destructive operations.  Make sure you read carefully and **backup your repository** before starting. The easiest way to create a backup is to clone your repository using the [--mirror][5] flag, and zip the whole clone. With the backup, if you accidentally corrupt a key element of your repo during maintenance, you can recover. - -Keep in mind that maintenance can be disruptive to repository users. It is a good idea to communicate repository maintenance with your team or repository followers. Make sure everyone has checked in their code and have agreed to cease development during maintenance. - -### Understanding file removal from Git history - -Recall that cloning a repository clones the entire history — including every version of every source code file.  If a user commits a huge file, such as a JAR, every clone thereafter includes this file. Even if a user ends up removing the file from the project with a subsequent commit, the file still exists in the repository history.  To remove this file from your repository you must: - -* remove the file from your project's  _current_  file-tree - -* remove the file from repository history -  _rewriting_  Git history, deleting the file from **all** commits containing it - -* remove all [reflog][6] history that refers to the  _old_  commit history - -* repack the repository, garbage-collecting the now-unused data using [git gc][7] - -Git 'gc' (garbage collection) will remove all data from the repository that is not actually used, or in some way referenced, by any of your branches or tags. In order for that to be useful, we need to rewrite all Git repository history that contained the unwanted file, so that it no longer references it - git gc will then be able to discard the now-unused data. - -Rewriting repository history is a tricky business, because every commit depends on it's parents, so any small change will change the commit id of every subsequent commit. There are two automated tools for doing this: - -1. [the BFG Repo Cleaner][8] - fast, simple, easy to use. Require Java 6 or above. - -2. [git filter-branch][9] - powerful, tricky to configure, slow on big repositories. Part of the core Git suite. - -Remember, after you rewrite the history, whether you use the BFG or filter-branch, you will need to remove `reflog` entries that point to old history, and finally run the garbage collector to purge the old data.  - -### Using the BFG to rewrite history - -[The BFG][11] is specifically designed for removing unwanted data like big files or passwords from Git repos, so it has a simple flag that will remove any large historical (not-in-your-current-commit) files: '--strip-blobs-bigger-than' - - -``` -$ java -jar bfg.jar --strip-blobs-bigger-than 100M -``` - -Any files over 100MB in size (that aren't in your  _latest_  commit - because [your latest content is protected][12] by the BFG) will be removed from your Git repository's history. If you'd like to specify files by name, you can do that too: - - -``` -$ java -jar bfg.jar --delete-files *.mp4 -``` - -The BFG is [10-1000x][13] faster than git filter-branch, and generally much easier to use - check the full [usage instructions][14] and [examples][15] for more details. - -### Alternatively, using git filter-branch to rewrite history - -The `filter-branch` command rewrites a Git repo's revision history, just like the BFG, but the process is slower and more manual. If you don't know  _where_  the big file is, your first step will be to find it: - -### Manually reviewing large files in your repository - -[Antony Stubbs][16] has written a BASH script that does this very well. The script examines the contents of your packfile and lists out the large files.  Before you begin removing files, do the following to obtain and install this script: - -1. [Download the script][10] to your local system. - -2. Put it in a well known location accessible to your Git repository. - -3. Make the script an  executable: - - - ``` - $ chmod 777 git_find_big.sh - ``` - -4. Clone the repository to your local system. - -5. Change directory to your repository root. - -6. Run the Git garbage collector manually. - - - ``` - git gc --auto - ``` - -7. Find out the size of the .git folder. - - - ``` - $ du -hs .git/objects - ``` - - ``` - 45M .git/objects - ``` - - Note this size down for later reference. - -8. List the big files in your repo by running the `git_find_big.sh` script. - - - ``` - $ git_find_big.sh - ``` - - ``` - All sizes are in kB's. The pack column is the size of the object, compressed, inside the pack file. - ``` - - ``` - size pack SHA                                       location - ``` - - ``` - 592   580   e3117f48bc305dd1f5ae0df3419a0ce2d9617336 media/img/emojis.jar - ``` - - ``` - 550   169   b594a7f59ba7ba9daebb20447a87ea4357874f43 media/js/aui/aui-dependencies.jar - ``` - - ``` - 518   514   22f7f9a84905aaec019dae9ea1279a9450277130 media/images/screenshots/issue-tracker-wiki.jar - ``` - - ``` - 337   92   1fd8ac97c9fecf74ba6246eacef8288e89b4bff5 media/js/lib/bundle.js - ``` - - ``` - 240   239   e0c26d9959bd583e5ef32b6206fc8abe5fea8624 media/img/featuretour/heroshot.png - ``` - - The big files are all JAR files.  The pack size column is the most relevant.  The `aui-dependencies.jar` compacts to 169KB  but the `emojis.jar` compacts only to 580\.  The `emojis.jar` is a candidate for removal. - -### Running filter-branch - -You can pass this command a filter for rewriting the Git index.  For example, a filter can remove a file from every indexed commit.  The syntax for this is the following: - -`git filter-branch --index-filter 'git rm --cached --ignore-unmatch  _pathname_ ' commitHASH` - -The `--index-filter` option modifies a repo's staging (or index). The `--cached` option removes a file from the index not the disk.  This is faster as you don't have to checkout each revision before running the filter.  The -`-ignore-unmatch` option in `git rm` prevents the command from failing if the  _pathname_  it is trying to remove isn't there.  By specifying a commit HASH, you remove the `pathname` from every commit starting with the HASH on up.  To remove from the start, leave this off or you can specify HEAD.   - -If all your large files are in different branches, you'll need to delete each file by name. If all the files are within a single branch,  you can delete the branch itself. - -### Option 1: Delete files by name - -Use the following procedure to remove large files: - -1. Run the following command to remove the first large file you identified: - - - ``` - git filter-branch --index-filter 'git rm --cached --ignore-unmatch filename' HEAD - ``` - -2. Repeat Step 1 for each remaining large file. - -3. Update the references in your repository. `filter-branch` creates backups of your original refs namespaced under `refs/original/`. Once you're confident that you deleted the correct files, you can run the following command to delete the backed up refs, allowing the large objects to be garbage collected: - - - ``` - $ git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d - ``` - -### Option 2: Delete just the branch - -If all your large files are on a single branch,  you can just delete the branch. Deleting the branch automatically removes all the references. - -1. Delete the branch. - - - ``` - $ git branch -D PROJ567bugfix - ``` - -2. Prune all of the reflog references from the branch on back. - - - ``` - $ git reflog expire --expire=now PROJ567bugfix - ``` - -### Garbage collecting dead data - -1. Prune all of the reflog references from now on back (unless you're explicitly only operating on one branch). - - - ``` - $ git reflog expire --expire=now --all - ``` - -2. Repack the repository by running the garbage collector and pruning old objects. - - - ``` - $ git gc --prune=now - ``` - -3. Push all your changes back to the Bitbucket repository. - - - ``` - $ git push --all --force - ``` - -4. Make sure all your tags are current too: - - - ``` - $ git push --tags --force - ``` - --------------------------------------------------------------------------------- - -via: https://confluence.atlassian.com/bitbucket/maintaining-a-git-repository-321848291.html - -作者:[atlassian.com][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://confluence.atlassian.com/bitbucket/maintaining-a-git-repository-321848291.html -[1]:https://confluence.atlassian.com/bitbucket/maintaining-a-git-repository-321848291.html#MaintainingaGitRepository-UnderstandingfileremovalfromGithistory -[2]:https://confluence.atlassian.com/bitbucket/maintaining-a-git-repository-321848291.html#MaintainingaGitRepository-UsingtheBFGtorewritehistory -[3]:https://confluence.atlassian.com/bitbucket/maintaining-a-git-repository-321848291.html#MaintainingaGitRepository-Alternatively,usinggitfilter-branchtorewritehistory -[4]:https://confluence.atlassian.com/bitbucket/maintaining-a-git-repository-321848291.html#MaintainingaGitRepository-Garbagecollectingdeaddata -[5]:http://stackoverflow.com/questions/3959924/whats-the-difference-between-git-clone-mirror-and-git-clone-bare -[6]:http://git-scm.com/docs/git-reflog -[7]:http://git-scm.com/docs/git-gc -[8]:http://rtyley.github.io/bfg-repo-cleaner/ -[9]:http://git-scm.com/docs/git-filter-branch -[10]:https://confluence.atlassian.com/bitbucket/files/321848291/321979854/1/1360604134990/git_find_big.sh -[11]:http://rtyley.github.io/bfg-repo-cleaner/ -[12]:http://rtyley.github.io/bfg-repo-cleaner/#protected-commits -[13]:https://www.youtube.com/watch?v=Ir4IHzPhJuI -[14]:http://rtyley.github.io/bfg-repo-cleaner/#usage -[15]:http://rtyley.github.io/bfg-repo-cleaner/#examples -[16]:https://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/ diff --git a/sources/tech/20170519 10 Useful Tips for Writing Effective Bash Scripts in Linux.md b/sources/tech/20170519 10 Useful Tips for Writing Effective Bash Scripts in Linux.md index 6f0cae4f8a..e4ddd0b92e 100644 --- a/sources/tech/20170519 10 Useful Tips for Writing Effective Bash Scripts in Linux.md +++ b/sources/tech/20170519 10 Useful Tips for Writing Effective Bash Scripts in Linux.md @@ -1,3 +1,4 @@ +zhousiyu325翻译 10 Useful Tips for Writing Effective Bash Scripts in Linux ============================================================ ch-cn translating diff --git a/sources/tech/20170519 How to Kill a Process from the Command Line.md b/sources/tech/20170519 How to Kill a Process from the Command Line.md deleted file mode 100644 index 143129ab48..0000000000 --- a/sources/tech/20170519 How to Kill a Process from the Command Line.md +++ /dev/null @@ -1,203 +0,0 @@ -How to Kill a Process from the Command Line -============================================================ - -![stop processes](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/stop-processes.jpg?itok=vfNx8VRz "stop processes") ->Linux has all the tools you need to stop running processes at the command line. Jack Wallen has details.[Creative Commons Zero][4] - -Picture this: You’ve launched an application (be it from your favorite desktop menu or from the command line) and you start using that launched app, only to have it lock up on you, stop performing, or unexpectedly die. You try to run the app again, but it turns out the original never truly shut down completely. - -What do you do? You kill the process. But how? Believe it or not, your best bet most often lies within the command line. Thankfully, Linux has every tool necessary to empower you, the user, to kill an errant process. However, before you immediately launch that command to kill the process, you first have to know what the process is. How do you take care of this layered task? It’s actually quite simple...once you know the tools at your disposal. - -Let me introduce you to said tools. - -The steps I’m going to outline will work on almost every Linux distribution, whether it is a desktop or a server. I will be dealing strictly with the command line, so open up your terminal and prepare to type. - -### Locating the process - -The first step in killing the unresponsive process is locating it. There are two commands I use to locate a process:  _top _ and  _ps_ . Top is a tool every administrator should get to know. With  _top_ , you get a full listing of currently running process. From the command line, issue  _top_  to see a list of your running processes (Figure 1). - -### [killa.jpg][5] - -![top](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/killa.jpg?itok=95cUI9Lh "top") - -Figure 1: The top command gives you plenty of information.[Used with permission][1] - -From this list you will see some rather important information. Say, for example, Chrome has become unresponsive. According to our  _top_ display, we can discern there are four instances of chrome running with Process IDs (PID) 3827, 3919, 10764, and 11679\. This information will be important to have with one particular method of killing the process. - -Although  _top_  is incredibly handy, it’s not always the most efficient means of getting the information you need. Let’s say you know the Chrome process is what you need to kill, and you don’t want to have to glance through the real-time information offered by  _top_ . For that, you can make use of the  _ps_ command and filter the output through  _grep_ . The  _ps_  command reports a snapshot of a current process and  _grep _ prints lines matching a pattern. The reason why we filter  _ps_  through  _grep_  is simple: If you issue the  _ps_  command by itself, you will get a snapshot listing of all current processes. We only want the listing associated with Chrome. So this command would look like: - -``` -ps aux | grep chrome -``` - -The  _aux_  options are as follows: - -* a = show processes for all users - -* u = display the process's user/owner - -* x = also show processes not attached to a terminal - -The  _x_  option is important when you’re hunting for information regarding a graphical application. - -When you issue the command above, you’ll be given more information than you need (Figure 2) for the killing of a process, but it is sometimes more efficient than using top. - -### [killb.jpg][6] - -![ps command](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/killb.jpg?itok=vyWIuTva "ps command") - -Figure 2: Locating the necessary information with the ps command.[Used with permission][2] - -### Killing the process - -Now we come to the task of killing the process. We have two pieces of information that will help us kill the errant process: - -* Process name - -* Process ID - -Which you use will determine the command used for termination. There are two commands used to kill a process: - -* kill - Kill a process by ID - -* killall - Kill a process by name - -There are also different signals that can be sent to both kill commands. What signal you send will be determined by what results you want from the kill command. For instance, you can send the HUP (hang up) signal to the kill command, which will effectively restart the process. This is always a wise choice when you need the process to immediately restart (such as in the case of a daemon). You can get a list of all the signals that can be sent to the kill command by issuing kill -l. You’ll find quite a large number of signals (Figure 3). - -### [killc.jpg][7] - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/killc.jpg?itok=9ewRHFW2) - -Figure 3: The available kill signals.[Used with permission][3] - -The most common kill signals are: - -| - -Signal Name - - | - -Single Value - - | - -Effect - - | -| - -SIGHUP - - | - -1 - - | - -Hangup - - | -| - -SIGINT - - | - -2 - - | - -Interrupt from keyboard - - | -| - -SIGKILL - - | - -9 - - | - -Kill signal - - | -| - -SIGTERM - - | - -15 - - | - -Termination signal - - | -| - -SIGSTOP - - | - -17, 19, 23 - - | - -Stop the process - - | - -What’s nice about this is that you can use the Signal Value in place of the Signal Name. So you don’t have to memorize all of the names of the various signals.  -So, let’s now use the  _kill _ command to kill our instance of chrome. The structure for this command would be: - -``` -kill SIGNAL PID -``` - -Where SIGNAL is the signal to be sent and PID is the Process ID to be killed. We already know, from our  _ps_  command that the IDs we want to kill are 3827, 3919, 10764, and 11679\. So to send the kill signal, we’d issue the commands: - -``` -kill -9 3827 - -kill -9 3919 - -kill -9 10764 - -kill -9 11679 -``` - -Once we’ve issued the above commands, all of the chrome processes will have been successfully killed. - -Let’s take the easy route! If we already know the process we want to kill is named chrome, we can make use of the  _killall _ command and send the same signal the process like so: - - _killall -9 chrome_ - -The only caveat to the above command is that it may not catch all of the running chrome processes. If, after running the above command, you issue the ps aux|grep chrome command and see remaining processes running, your best bet is to go back to the  _kill _ command and send signal 9 to terminate the process by PID. - -### Ending processes made easy - -As you can see, killing errant processes isn’t nearly as challenging as you might have thought. When I wind up with a stubborn process, I tend to start off with the  _killall _ command as it is the most efficient route to termination. However, when you wind up with a really feisty process, the  _kill _ command is the way to go. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2017/5/how-kill-process-command-line - -作者:[JACK WALLEN][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/jlwallen -[1]:https://www.linux.com/licenses/category/used-permission -[2]:https://www.linux.com/licenses/category/used-permission -[3]:https://www.linux.com/licenses/category/used-permission -[4]:https://www.linux.com/licenses/category/creative-commons-zero -[5]:https://www.linux.com/files/images/killajpg -[6]:https://www.linux.com/files/images/killbjpg -[7]:https://www.linux.com/files/images/killcjpg -[8]:https://www.linux.com/files/images/stop-processesjpg diff --git a/translated/talk/20170111 The difference between development and deployment.md b/translated/talk/20170111 The difference between development and deployment.md deleted file mode 100644 index fe68b606f0..0000000000 --- a/translated/talk/20170111 The difference between development and deployment.md +++ /dev/null @@ -1,58 +0,0 @@ -开发和部署的不同 -============================================================ -![The difference between development and deployment](https://opensource.com/sites/default/files/styles/image-full-size/public/images/business/BUS_OpenSourceExperience_520x292_cm.png?itok=APna2N9Y "The difference between development and deployment") - -图片提供 : opensource.com - -多年前,我是一名 Smalltalk 程序员,这种经验给让我在观察编程世界时有不同的想法。例如,花时间来适应源代码应该存储在文本文件中的想法。 - -我们作为程序员通常区分“开发”和“部署”,特别是我们在一个地方开发使用的工具不同于我们之后部署软件时的地点和工具。在 Smalltalk 世界里,没有这样的区别。 - -Smalltalk 构建在包含了你的开发环境(IDE、调试器、文本编辑器、版本控制等)的虚拟机的想法之上,如果你不得不修改任何一处代码,你要修改内存中运行副本。如果你可以为运行中的机器打个快照,如果你想做的话,如果你想分发你的代码,你可以发送一个运行中的机器的镜像(包括IDE、调试器、文本编辑器、版本控制等)的副本到用户。这就是 90 年代软件开发的工作原理(对我们中的一些人来说)。 - -如今部署环境与开发环境有了很大的不同。对于初学者,你不要期望那里有任何开发工具。一旦部署,就没有版本控制、没有调试、没有开发环境。有的是记录和监视,这些在我们的开发环境中没有,并且有一个“构建管道”,它将我们的软件从我们开发形式转换为部署形式。例如,Docker 容器试图重新抓住 1990 年代 Smalltalk 程序员部署经验的一些简单性,而不希望对开发体验做同样的事情。 - -我想如果 Smalltalk 世界是我唯一的编程隐喻体验,无法区分开发和部署环境,我可能偶尔回顾一下它。但在我是一名 Smalltalk 程序员之前,我是一位 APL 程序员,这也是一个可以修改虚拟机镜像的世界,其中开发和部署是无法区分的。因此,我相信,在当前的世界,人们编辑单独的源代码文件,然后运行构建管道以创建在编辑代码时不存在的部署工作,然后将这些作品部署到用户。我们已经以某种方式将这种反模式软件开发制度化,并且不断发展的软件环境的需求正在迫使我们找到回到 20 世纪 90 年代更有效的技术的方法。因此会有 Docker 的成功。因此,我需要提出建议。 - -我有两个建议:我们在运行时系统中实现(和使用)版本控制,我们通过更改运行系统来开发软件,而不是用新的运行系统替换它们。这两个想法是相关的。为了安全地更改正在运行的系统,我们需要一些版本控制功能来支持“撤消”功能。也许公平地说,我只提出一个建议。让我举例来说明。 - -让我们开始想象一个静态网站。你要修改一些 HTML 文件。你应该如何工作?如果你像大多数开发者一样,你会有两个,也许三个网站 - 一个用于开发,一个用于QA(或者预发布),一个用于生产。你将直接编辑开发实例中的文件。准备就绪后,你将“部署”你的修改到预发布实例。在用户验收测试之后,你将再次部署,这次是生产环境。 - -使用 Occam 的 Razor,让我们避免不必要地创建实例。我们需要多少台机器?我们可以使用一台电脑。我们需要多少台网络服务器?我们可以使用具有多个虚拟主机的单台 web 服务器,而不是多个虚拟主机,我们可以使用单台虚拟主机吗?然后,我们需要多个目录,并需要使用 URL 的顶级路径来区分不同的版本,而不是虚拟主机名。但是为什么我们需要多个目录?因为 web 服务器将从文件系统中提供静态文件。我们的问题是,目录有三个不同的版本,我们的解决方案是创建目录的三个不同的副本。这不是像 Subversion 和 Git 这样的版本控制系统解决的问题?制作目录的多个副本以存储多个版本的策略回到了 CVS 之前的日子。为什么不使用,也就是一个空的的 Git 仓库来存储文件?因为要这样做,web 服务器将需要能够从 git 仓库读取文件(参见[mod_git] [3])。 - -这将是一个支持版本控制的运行时系统。 - -使用这样的 web 服务器,使用的版本可以由 cookie 来标识。这样,任何人都可以推送到仓库,用户将继续看到他们发起会话时分配的版本。版本控制系统有不可改变的提交; 一旦会话开始,开发人员可以在不影响正在运行的用户的情况下快速推送更改。开发人员可以重置其会话以跟踪他们的新提交,因此开发人员或测试人员就可能如普通用户一样查看在同台服务器上同一个URL上正在开发或正在测试的版本。作为偶然的副作用,A/B 测试仅仅是将不同的用户分配给不同的提交的情况。所有用于管理多个版本的 git 设施都在运行环境中发挥作用。当然,git reset 为我们提供了前面提到的“撤销”功能。 - -为什么不是每个人都这样做? - -一种可能性是,诸如版本控制系统的工具不被设计为在生产环境中使用。例如,给某人许可推送到测试分支而不是生产分支是不可能的。对这个方案最常见的反对是,如果发现了一个漏洞,你会想要将某些提交标记为不可访问。这将是另一种更细粒度的权限的情况;开发人员将具有对所有提交的读取权限,但外部用户不会。我们可能需要对现有工具进行一些额外的工作以支持这种模式,但是这些功能很容易理解,并已被设计到其他软件中。例如,Linux (或 PostgreSQL)实现了对不同用户的细粒度权限的想法。 - -随着云环境变得越来越普及,这些想法变得更加相关:云总是在运行。例如,我们可以看到,AWS 中等价的 “文件系统”(S3)实现了版本控制,所以你可能有一个不同的想法,使用一台 web 服务器提供来自 S3 的资产,并使用会话信息选择不同版本的资产。重要的想法并不是实现是最好的,而是支持运行时版本控制的愿景。 - -部署的软件环境应该是“版本感知”的原则,扩展到除了服务静态资产的web服务器之外的其他工具。在将来的文章中,我将介绍版本库,数据库和应用程序服务器的方法。 - -_在 linux.conf.au 中了解更多 Robert Lefkowitz 2017 年 ([#lca2017][1])在 Hobart:[保持 Linux 伟大][2]的主题。_ - --------------------------------------------------------------------------------- - -作者简介: - -![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/robert_lefkowitz.jpg?itok=CFoX-OUI) - -Robert M. Lefkowitz - Robert(a / k / a r0ml)是一个喜欢复杂编程语言的编程语言爱好者。 他是一个提高清晰度、提高可靠性和最大限度地简化编程技术的收藏家。他通过让计算机更加容易获得来使它普及化。他经常演讲中世纪晚期和早期文艺复兴对编程艺术的影响。 - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/1/difference-between-development-deployment - -作者:[Robert M. Lefkowitz][a] -译者:[geekpi](https://github.com/geekpi) -校对:[Bestony](https://github.com/Bestony) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/r0ml -[1]:https://twitter.com/search?q=%23lca2017&src=typd -[2]:https://www.linux.conf.au/schedule/presentation/107/ -[3]:https://github.com/r0ml/mod_git diff --git a/translated/talk/20170523North Korea's Unit 180, the cyber warfare cell that worries the West b/translated/talk/20170523North Korea's Unit 180, the cyber warfare cell that worries the West deleted file mode 100644 index 64e14f979e..0000000000 --- a/translated/talk/20170523North Korea's Unit 180, the cyber warfare cell that worries the West +++ /dev/null @@ -1,71 +0,0 @@ -朝鲜180局的网络战部门让西方国家忧虑。 - -Translated by hwlog -North Korea's Unit 180, the cyber warfare cell that worries the West - -============================================================ - [![在夜色的映衬下,部队的军车通过平壤市区,](http://www.abc.net.au/news/image/8545124-3x2-700x467.jpg "Military trucks through Pyongyang")][13] [**PHOTO:** 脱北者说, 平壤的网络战攻击目的在于一个叫做“180局”的部门来筹集资金。(Reuters: Damir Sagolj, file)][14] - 据叛逃者,官方和网络安全专家称,朝鲜的情报机关有一个叫做180局的特殊部门, 这个部门已经发起过多起勇敢且成功的网络战。 -近几年朝鲜被美国,韩国,和周边几个国家指责对多数的金融网络发起过一系列在线袭击。 -网络安全技术人员称他们找到了这个月感染了150多个国家30多万台计算机的全球想哭勒索病毒"ransomware"和朝鲜网络战有关联的技术证据。 -平壤称该指控是“荒谬的”。 -对朝鲜的关键指控是指朝鲜与一个叫做拉撒路的黑客组织有联系,这个组织是在去年在孟加拉国中央银行网络抢劫8000万美元并在2014年攻击了索尼的好莱坞工作室的网路。 -美国政府指责朝鲜对索尼公司的黑客袭击,同时美国政府对平壤在孟加拉国银行的盗窃行为提起公诉并要求立案。 -由于没有确凿的证据,没有犯罪指控并不能够立案。朝鲜之后也否认了Sony公司和银行的袭击与其有关。 -朝鲜是世界上最封闭的国家之一,它秘密行动的一些细节很难获得。 -但研究这个封闭的国家和流落到韩国和一些西方国家的的叛逃者已经给出了或多或少的提示。 - -### 黑客们喜欢用雇员来作为掩护 -金恒光,朝鲜前计算机教授,2004叛逃到韩国,他仍然有着韩国内部的消息,他说平壤的网络战目的在于通过侦察总局下属的一个叫做180局来筹集资金,这个局主要是负责海外的情报机构。 -金教授称,“180局负责入侵金融机构通过漏洞从银行账户提取资金”。 -他之前也说过,他以前的一些学生已经加入了朝鲜的网络战略司令部-朝鲜的网络部队。 - ->"黑客们到海外寻找比朝鲜更好的互联网服务的地方,以免留下痕迹," 金教授补充说。 -他说他们经常用贸易公司,朝鲜的海外分公司和在中国和东南亚合资企业的雇员来作为掩护 -位于华盛顿的战略与国际研究中心的叫做James Lewis的朝鲜专家称,平壤首先用黑客作为间谍活动的工具然后对韩国和美国的目的进行政治干扰。 -索尼公司事件之后,他们改变方法,通过用黑客来支持犯罪活动来形成国内坚挺的货币经济政策。 -“目前为止,网上毒品,假冒伪劣,走私,都是他们惯用的伎俩”。 -Media player: 空格键播放,“M”键静音,“左击”和“右击”查看。 - -[**VIDEO:** 你遇到过勒索病毒吗? (ABC News)][16] - -### 韩国声称拥有大量的“证据” -美国国防部称在去年提交给国会的一个报告中显示,朝鲜可能有作为有效成本的,不对称的,可拒绝的工具,它能够应付来自报复性袭击很小的风险,因为它的“网络”大部分是和因特网分离的。 - -> 报告中说," 它可能从第三方国家使用互联网基础设施"。 -韩国政府称,他们拥有朝鲜网络战行动的大量证据。 -“朝鲜进行网络战通过第三方国家来掩护网络袭击的来源,并且使用他们的信息和通讯技术设施”,Ahn Chong-ghee,韩国外交部副部长,在书面评论中告诉路透社。 -除了孟加拉银行抢劫案,他说平壤也被怀疑与菲律宾,越南和波兰的银行袭击有关。 -去年六月,警察称朝鲜袭击了160个韩国公司和政府机构,入侵了大约14万台计算机,暗中在他的对手的计算机中植入恶意代码作为长期计划的一部分来进行大规模网络攻击。 -朝鲜也被怀疑在2014年对韩国核反应堆操作系统进行阶段性网络攻击,尽管朝鲜否认与其无关。 -根据在一个韩国首尔的杀毒软件厂商“hauri”的高级安全研究员Simon Choi的说法,网络袭击是来自于他在中国的一个基地。 -Choi先生,一个有着对朝鲜的黑客能力进行了广泛的研究的人称,“他们在那里行动以至于不论他们做什么样的计划,他们拥有中国的ip地址”。 - - --------------------------------------------------------------------------------- - -via: http://www.abc.net.au/news/2017-05-21/north-koreas-unit-180-cyber-warfare-cell-hacking/8545106 - -作者:[www.abc.net.au ][a] -译者:[译者ID](https://github.com/hwlog) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://www.abc.net.au -[1]:http://www.abc.net.au/news/2017-05-16/wannacry-ransomware-showing-up-in-obscure-places/8527060 -[2]:http://www.abc.net.au/news/2015-08-05/why-we-should-care-about-cyber-crime/6673274 -[3]:http://www.abc.net.au/news/2017-05-15/what-to-do-if-youve-been-hacked/8526118 -[4]:http://www.abc.net.au/news/2017-05-16/researchers-link-wannacry-to-north-korea/8531110 -[5]:http://www.abc.net.au/news/2017-05-18/adylkuzz-cyberattack-could-be-far-worse-than-wannacry:-expert/8537502 -[6]:http://www.google.com/maps/place/Korea,%20Democratic%20People%20S%20Republic%20Of/@40,127,5z -[7]:http://www.abc.net.au/news/2017-05-16/wannacry-ransomware-showing-up-in-obscure-places/8527060 -[8]:http://www.abc.net.au/news/2017-05-16/wannacry-ransomware-showing-up-in-obscure-places/8527060 -[9]:http://www.abc.net.au/news/2015-08-05/why-we-should-care-about-cyber-crime/6673274 -[10]:http://www.abc.net.au/news/2015-08-05/why-we-should-care-about-cyber-crime/6673274 -[11]:http://www.abc.net.au/news/2017-05-15/what-to-do-if-youve-been-hacked/8526118 -[12]:http://www.abc.net.au/news/2017-05-15/what-to-do-if-youve-been-hacked/8526118 -[13]:http://www.abc.net.au/news/2017-05-21/military-trucks-trhough-pyongyang/8545134 -[14]:http://www.abc.net.au/news/2017-05-21/military-trucks-trhough-pyongyang/8545134 -[15]:http://www.abc.net.au/news/2017-05-16/researchers-link-wannacry-to-north-korea/8531110 -[16]:http://www.abc.net.au/news/2017-05-15/have-you-been-hit-by-ransomware/8527854 diff --git a/translated/tech/20170506 ttyload – Shows a Color-coded Graph of Linux Load Average in Terminal.md b/translated/tech/20170506 ttyload – Shows a Color-coded Graph of Linux Load Average in Terminal.md new file mode 100644 index 0000000000..957ddcf44d --- /dev/null +++ b/translated/tech/20170506 ttyload – Shows a Color-coded Graph of Linux Load Average in Terminal.md @@ -0,0 +1,109 @@ +ttyload - 在终端中用彩色显示 Linux 的平均负载 +============================================================ + +立即下载你的免费电子书 - [10 本给管理员的免费 Linux 电子书][12] | [4 本免费的 Shell 脚本电子书][13] + +ttyload 是一个轻量级的实用程序,它为 Linux 和其他类 Unix 系统上提供随着时间变化的彩色平均负载。它实现了在终端中图形跟踪系统的平均负载(“tty”)。 + +它已知可以在诸如 Linux、IRIX、Solaris、FreeBSD、MacOS X (Darwin) 和 Isilon OneFS 等系统上运行。它被设计为可以容易地移植到其他平台,但这也带来了一些艰苦的工作。 + +它的一些值得注意功能是:它使用相当标准但硬编码的 ANSI 转义序列进行屏幕操作和着色。如果你想要在一个没有负载的系统中查看工作的情况,也可以使用(默认不会安装,甚至不会构建)一个相对独立的负载炸弹。 + +**建议阅读:**[GoTTY - 将你的 Linux 终端(TTY)作为 Web 程序共享][1] + +在本篇中,我们会向你展示如何在 Linux 安装及使用 ttyload,以在终端中用彩色图形查看系统的平均负载。 + +### 如何在 Linux 中安装 ttyload + +在基于 Debian/Ubuntu 的发行版中,你可以输入下面的[ apt 命令][2]来从默认的系统仓库中安装 ttyload。 + +``` +$ sudo apt-get install ttyload +``` + +在其他发型版中,你可以如下从 ttyload 的源码安装。 + +``` +$ git clone https://github.com/lindes/ttyload.git +$ cd ttyload +$ make +$ ./ttyload +$ sudo make install +``` + +安装完成后,你可以输入下面的命令启动。 + +``` +$ ttyload +``` + [![ttyload - Graphical View of Linux Load Average](https://www.tecmint.com/wp-content/uploads/2017/05/ttyload-Graphical-View-of-Linux-Load-Average-.png)][3] + +ttyload - 图形浏览 Linux 的平均负载 + +注意:要关闭程序,只需按下 `[Ctrl+C]` 键。 + +你也可以定义两次刷新之间间隔的秒数。默认是 4 秒,最小是 1 秒。 + +``` +$ ttyload -i 5 +$ ttyload -i 1 +``` + +要以单色模式运行,即它会关闭 ANSI 转义,如下使用 `-m`: + +``` +$ ttyload -m +``` + [![ttyload - Monochrome Mode](https://www.tecmint.com/wp-content/uploads/2017/05/ttyload-monochrome-mode.png)][4] + +ttyload – 单色模式 + +要获取 ttyload 的使用信息以及帮助,输入: + +``` +$ ttyload -h +``` + +下面是一些尚未添加的重要功能: + +* 支持任意大小调整。 + +* 使用相同的基本引擎制作 X 前端,具有 “3xload”。 + +* 面向日志的模式。 + +要获得更多信息,访问 ttyload 的主页:[http://www.daveltd.com/src/util/ttyload/][5] + +就是这样了!在本文中,我们向你展示了如何在 Linux 中安装及使用 ttyload。通过下面的评论栏给我们回馈。 + +-------------------------------------------------------------------------------- + +作者简介: + +Aaron Kili 是一个 Linux 和 F.O.S.S 的爱好者,即将推出的 Linux SysAdmin 网络开发人员,目前也是 TecMint 的内容创作者,他喜欢和电脑一起工作,并且坚信共享知识。 + + +------------------- + +via: https://www.tecmint.com/ttyload-shows-color-coded-graph-of-linux-load-average/ + +作者:[Aaron Kili ][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.tecmint.com/author/aaronkili/ +[1]:https://www.tecmint.com/gotty-share-linux-terminal-in-web-browser/ +[2]:https://www.tecmint.com/useful-basic-commands-of-apt-get-and-apt-cache-for-package-management/ +[3]:https://www.tecmint.com/wp-content/uploads/2017/05/ttyload-Graphical-View-of-Linux-Load-Average-.png +[4]:https://www.tecmint.com/wp-content/uploads/2017/05/ttyload-monochrome-mode.png +[5]:http://www.daveltd.com/src/util/ttyload/ +[6]:https://www.tecmint.com/ttyload-shows-color-coded-graph-of-linux-load-average/# +[7]:https://www.tecmint.com/ttyload-shows-color-coded-graph-of-linux-load-average/# +[8]:https://www.tecmint.com/ttyload-shows-color-coded-graph-of-linux-load-average/# +[9]:https://www.tecmint.com/ttyload-shows-color-coded-graph-of-linux-load-average/# +[10]:https://www.tecmint.com/ttyload-shows-color-coded-graph-of-linux-load-average/#comments +[11]:https://www.tecmint.com/author/aaronkili/ +[12]:https://www.tecmint.com/10-useful-free-linux-ebooks-for-newbies-and-administrators/ +[13]:https://www.tecmint.com/free-linux-shell-scripting-books/ diff --git a/translated/tech/20170509 How to Password Protect a Vim File in Linux.md b/translated/tech/20170509 How to Password Protect a Vim File in Linux.md new file mode 100644 index 0000000000..21ae3a5113 --- /dev/null +++ b/translated/tech/20170509 How to Password Protect a Vim File in Linux.md @@ -0,0 +1,155 @@ +怎样在 Linux 中对 Vim 文件进行密码保护 +============================================================ + + 现在下载你的免费电子书籍 - [给管理员的 10 本免费的 Linux 电子书籍][16] | [4 本免费的 Shell 脚本电子书籍][17] + +[Vim][5] 是一种流行的、功能丰富的和高度可扩展的 [Linux 文本编辑器][6],它的重要功能之一便是支持用各种带密码的加密方法来加密文本文件。 + +本文中,我们将向你介绍一种简单的 Vim 使用技巧;在 Linux 中使用 Vim 对文件进行密码保护。我们将向你展示如何让一个文件在它创建的时侯以及为了修改目的而被打开了之后获得安全防护。 + +**建议阅读:** [你应该在 Linux 中使用 Vim 编辑器的 10 个原因][7] + +要安装 Vim 完整版,只需运行这些命令: + +``` +$ sudo apt install vim #Debian/Ubuntu 系统 +$ sudo yum install vim #RHEL/CentOS 系统 +$ sudo dnf install vim #Fedora 22+ +``` +参阅: [十年后 Vim 8.0 发布了– 在 Linux 上安装][8] + +### 怎样在 Linux 中对 Vim 文件进行密码保护 + +Vim 有个 `-x` 选项,这个选项能让你在创建文件时用它来加密。一旦你运行下面的 [vim 命令][9],你会被提示输入一个密钥: + +``` +$ vim -x file.txt +警告:正在使用弱加密方法;参见 :help 'cm' +输入加密密钥:******* +再次输入相同密钥:******* +``` + +如果第二次输入的密钥无误,你就能进去修改此文件了。 + + [![Vim File Password Protected](https://www.tecmint.com/wp-content/uploads/2017/05/Vim-File-Password-Protected-File.png)][10] + +被密码保护的 Vim 文件 + +等你修改好之后,摁 `[Esc]` 和键入 `:wq` 来保存及关闭文件。下次你想打开它编辑一下,你就必须像这样去输入密钥: + +``` +$ vim file.txt +需要 "file.txt" 的加密密钥 +警告:正在使用弱加密方法;参见 :help 'cm' +输入密钥:******* +``` + +假设你输了一个错误的密码(或者没输密码),你会看到一些垃圾字符。 + + [![Vim Content Encrypted](https://www.tecmint.com/wp-content/uploads/2017/05/Vim-Content-Encrypted.png)][11] + +Vim 中的加密内容 + +#### 在 Vim 中设置一种强加密方法 + +注意:有条告警信息暗示一种弱加密方法已被用于保护文件。那么接下来,我们来看看怎么在 Vim 中设置一种强加密方法。 + + [![Weak Encryption on Vim File](https://www.tecmint.com/wp-content/uploads/2017/05/Weak-Encryption-on-Vim-File.png)][12] + +Vim 中文件弱加密 + +为了查看 crytmethod(cm) 集,键入(向下滚动可查看所有可用的方法): + +``` +:help 'cm' +``` + +##### 输出样例 + +``` + *'cryptmethod'* *'cm'* +'cryptmethod' 'cm' string (默认 "zip") +global or local to buffer |global-local| +{not in Vi} +当缓冲区写进文件中所用的方法: +*pkzip* +zip PkZip 兼容法。 一种弱加密方法。 +与 Vim 7.2 及更老版本后向兼容。 +*blowfish* +blowfish 河豚法。 中级强度加密方法但有实现上 +的瑕疵。需要 Vim 7.3 及以上版本,用它加密的文件不 +能被 Vim 7.2 及更老版本读取。它会添加一个 “种子”, +每次你对这个文件写操作时…… +options.txt [帮助][只读] +``` + +你可以像如下所示的那样给一个 Vim 文件设置个新的 cryptomethod(加密方法)(本例中我们用 blowfish2 加密方法) + +``` +:setlocal cm=blowfish2 +``` + +然后键入 `[Enter]` 和 `:wq` 保存下文件。 + + [![Set Strong Encryption on Vim File](https://www.tecmint.com/wp-content/uploads/2017/05/Set-Strong-Encryption-on-Vim-File.png)][13] + +对 Vim 文件设置强加密 + +现在你再打开下示的文件时应该就看不到那条警告信息了。 + +``` +$ vim file.txt +需要 "file.txt" 的加密密钥 +输入加密密钥:******* +``` + +你也可以在打开 Vim 文件之后来设置密码,用 `:X` 命令就能像上面所示的那样去设置一个密码关卡。 + +可以看看我们其他的关于 Vim 编辑器的有用的文章。 + +1. [在 Linux 中学习有用的 Vim 编辑器的旅行与技巧][1] + +2. [给每个 Linux 用户的 8 种有用的 Vim 编辑器技巧][2] + +3. [spf13-vim – Vim 编辑器的顶级发行版][3] + +4. [怎样在 Linux 种把 Vim 编辑当作 Bash IDE 来用][4] + +本文到这里就结束了!文章中我们介绍了怎么通过 Linux 下的 Vim 文本编辑器来给一个文件做加密防护。 + +永远记住要用强加密方式及密码来适当的保护那些可能包含了诸如用户名及密码、财务账户信息等等机密信息的文本文件。 + +-------------------------------------------------------------------------------- + +作者简介: + +Aaron Kili 是一个 Linux 和 F.O.S.S(Free and Open-Source Software,自由及开放源代码软件)爱好者,未来的 Linux 系统管理员、web 开发人员,目前是 TecMint 的内容创作者,他喜欢用电脑工作,且崇尚分享知识。 + +------------------ + +via: https://www.tecmint.com/password-protect-vim-file-in-linux/ + +作者:[Aaron Kili ][a] +译者:[ch-cn](https://github.com/ch-cn) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.tecmint.com/author/aaronkili/ +[1]:https://www.tecmint.com/learn-vi-and-vim-editor-tips-and-tricks-in-linux/ +[2]:https://www.tecmint.com/how-to-use-vi-and-vim-editor-in-linux/ +[3]:https://www.tecmint.com/spf13-vim-offers-vim-plugins-vim-editor/ +[4]:https://www.tecmint.com/use-vim-as-bash-ide-using-bash-support-in-linux/ +[5]:https://www.tecmint.com/vi-editor-usage/ +[6]:https://www.tecmint.com/best-open-source-linux-text-editors/ +[7]:https://www.tecmint.com/reasons-to-learn-vi-vim-editor-in-linux/ +[8]:https://www.tecmint.com/vim-8-0-install-in-ubuntu-linux-systems/ +[9]:https://www.tecmint.com/linux-command-line-editors/ +[10]:https://www.tecmint.com/wp-content/uploads/2017/05/Vim-File-Password-Protected-File.png +[11]:https://www.tecmint.com/wp-content/uploads/2017/05/Vim-Content-Encrypted.png +[12]:https://www.tecmint.com/wp-content/uploads/2017/05/Weak-Encryption-on-Vim-File.png +[13]:https://www.tecmint.com/wp-content/uploads/2017/05/Set-Strong-Encryption-on-Vim-File.png +[14]:https://www.tecmint.com/vi-editor-usage/ +[15]:https://www.tecmint.com/author/aaronkili/ +[16]:https://www.tecmint.com/10-useful-free-linux-ebooks-for-newbies-and-administrators/ +[17]:https://www.tecmint.com/free-linux-shell-scripting-books/ diff --git a/translated/tech/20170515 Show a Custom Message to Users Before Linux Server Shutdown.md b/translated/tech/20170515 Show a Custom Message to Users Before Linux Server Shutdown.md new file mode 100644 index 0000000000..fc65f547e0 --- /dev/null +++ b/translated/tech/20170515 Show a Custom Message to Users Before Linux Server Shutdown.md @@ -0,0 +1,79 @@ +在 Linux 服务器关机前向用户显示一条自定义消息 +============================================================ + + +在先前的文章中,我们解释了 Linux 中[ shutdown、poweroff、halt、reboot 命令的不同之处][3],并揭示了在用不同的选项执行这些命令时它们实际做了什么。 + +本篇将会向你展示如何在系统关机时向所有的系统用户发送一条自定义的消息。 + +**建议阅读:**[tuptime - 显示 Linux 系统的历史和统计运行时间][4] + +作为一名系统管理员,在你关闭服务器之前,你也许想要发送一条消息来警告他们系统将要关闭。默认上,shutdown 命令会如下所示给其他系统用户广播这条信息: + +``` +# shutdown 13:25 +``` +Linux Shutdown Broadcast Message +``` +Shutdown scheduled for Fri 2017-05-12 13:25:00 EAT, use 'shutdown -c' to cancel. +Broadcast message for root@tecmint (Fri 2017-05-12 13:23:34 EAT): +The system is going down for power-off at Fri 2017-05-12 13:25:00 EAT! +``` + +要在 shutdown 那行发送一条自定义的消息给其他系统用户,运行下面的命令。在本例中,关闭会在命令执行后的两分钟之后发生。 + +``` +# shutdown 2 The system is going down for required maintenance. Please save any important work you are doing now! +``` + [![Linux System Shutdown Message](https://www.tecmint.com/wp-content/uploads/2017/05/Linux-System-Shutdown-Message.png)][5] + +Linux 系统关闭消息 + +假设你有一些关键的系统操作,如计划系统备份或更新会在系统关闭的时候进行,如下所示,你可以使用 `-c` 选项取消关机,并在执行玩这些操作后继续执行: + +``` +# shutdown -c +``` +Linux Shutdown Cancel Message +``` +Shutdown scheduled for Fri 2017-05-12 14:10:22 EAT, use 'shutdown -c' to cancel. +Broadcast message for root@tecmint (Fri 2017-05-14 :10:27 EAT): +The system shutdown has been cancelled at Fri 2017-05-12 14:11:27 EAT! +``` + +另外,学习如何在 Linux 中使用简单和传统的方法[在重启或者开机时自动执行命令/脚本][6]。 + +不要错过: + +1. [关系系统启动进程和服务(SysVinit、Systemd 和 Upstart)][1] + +2. [11 个 Linux 中 cron 计划任务示例][2] + +现在你知道了如何在系统关闭前向其他系统用户发送自定义消息了。你有其他关于这个主题想要分享的想法么?何不使用下面的评论栏? + +-------------------------------------------------------------------------------- + +作者简介: + +Aaron Kili 是一个 Linux 和 F.O.S.S 爱好者、Linux 系统管理员、网络开发人员,现在也是 TecMint 的内容创作者,他喜欢和电脑一起工作,坚信共享知识。 + +------------------ + +via: https://www.tecmint.com/show-linux-server-shutdown-message/ + +作者:[Aaron Kili ][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.tecmint.com/author/aaronkili/ +[1]:https://www.tecmint.com/linux-boot-process-and-manage-services/ +[2]:https://www.tecmint.com/11-cron-scheduling-task-examples-in-linux/ +[3]:https://www.tecmint.com/shutdown-poweroff-halt-and-reboot-commands-in-linux/ +[4]:https://www.tecmint.com/find-linux-uptime-shutdown-and-reboot-time-with-tuptime/ +[5]:https://www.tecmint.com/wp-content/uploads/2017/05/Linux-System-Shutdown-Message.png +[6]:https://www.tecmint.com/auto-execute-linux-scripts-during-reboot-or-startup/ +[7]:https://www.tecmint.com/author/aaronkili/ +[8]:https://www.tecmint.com/10-useful-free-linux-ebooks-for-newbies-and-administrators/ +[9]:https://www.tecmint.com/free-linux-shell-scripting-books/ diff --git a/translated/tech/20170518 Maintaining a Git Repository.md b/translated/tech/20170518 Maintaining a Git Repository.md new file mode 100644 index 0000000000..c86da78795 --- /dev/null +++ b/translated/tech/20170518 Maintaining a Git Repository.md @@ -0,0 +1,227 @@ +维护一个Git仓库 +============================================================ + +维护Git仓库通常包括减少仓库的大小。如果你从另外一个版本控制系统导入了一个仓库,你可能需要在导入后清除掉不必要的文件。本文着重于从一个Git仓库中删除大文件,并且包含下列主题: + +* [理解从Git的历史记录中删除文件][1] + +* [使用BFG重写历史记录][2] + +* [可选,使用git filter-branch重写历史记录][3] + +* [垃圾回收][4] + +请格外小心..... + +本文中的步骤和工具使用的高级技术涉及破坏性操作。确保您在开始之前仔细读过**备份你的仓库**,创建一个备份的方式是使用[--mirror][5]标志对你的仓库克隆,然后对整个克隆的文件进行打包压缩。如果在维护期间意外损坏了您的仓库的关键元素,那么你可以通过备份的仓库来恢复。 + +请记住,仓库维护对仓库的用户可能会是毁灭性的。与你的团队或者仓库的关注者进行沟通会是一个不错的主意。确保每个人都已经检查了他们的代码,并且同意在仓库维护期间停止开发。 + +### 理解从Git的历史记录中删除文件 + +回想一下,克隆存储库会克隆整个历史记录——包括每个源代码文件的所有版本。如果一个用户提交了一个较大的文件,比如一个JAR,则随后的每次克隆都会包含这个文件。即使用户最终在后面的某次提交中删除了这个文件,但是这个文件仍然存在于这个仓库的历史记录中。要想完全的从你的仓库中删除这个文件,你必须: + +* 从你的项目的*当前的*文件树中删除该文件; + +* 从仓库的历史记录中删除文件——*重写*Git历史记录,从包含该文件的*所有的*提交中删除这个文件; + +* 删除指向*旧的*提交历史记录的所有[reflog][6]历史记录; + +* 重新整理仓库,使用[git gc][7]对现在没有使用的数据进行垃圾回收。 + +Git的'gc'(垃圾回收)通过任何一个你的分支或者标签来删除仓库中所有的实际没用的或者用某种方式引用的数据。为了使其有用,我们需要重写包含不需要的文件的所有Git仓库历史记录,仓库将不再引用它——git gc将会丢弃所有没用的数据。 + +重写存储库历史是一个棘手的事情,因为每次提交都依赖它的父提交,所以任何一个很小的改变都会改变它的每一个子拼音的提交ID。有两个自动化的工具可以做到这: + +1. [BFG Repo Cleaner][8] 快速、简单且易于使用,需要Java 6或者更高版本的运行环境。 + +2. [git filter-branch][9] 功能强大、配置麻烦,用于大于仓库时速度较慢,是核心Git套件的一部分。 + +切记,当你重写历史记录后,无论你是使用BFG还是使用filter-branch,你都需要删除撒向指向旧的历史记录的`reflog`条目,最后运行垃圾回收器来删除旧的数据。 + +### 使用BFG重写历史记录 + +[BFG][11]是为将像大文件或者密码这些不想要的数据从Git仓库中删除而专门设计的,所以它有一一个简单的标志用来删除那些大的历史文件(不是当前提交的文件):`'--strip-blobs-bigger-than'` + +``` +$ java -jar bfg.jar --strip-blobs-than 100M + +``` +大小超过100MB的任何文件(不在你*最近的*提交中——因为BFG[默认会保护你的最新提交的内容][12])将会从你的Git仓库的历史记录中删除。如果你想用名字来指明具体的文件,你也可以这样做: + +``` +$ java -jar bfg.jar --delete-files *.mp4 + +``` + +BFG的速度要比git filter-branch快[10-1000x][13],而且通常更容易使用——查看完整的[使用说明][14]和[示例][15]获取更多细节。 + +### 或者,使用git filter-branch来重写历史记录 + +`filter-branch`命令可以对Git仓库的历史记录重写,就像BFG一样,但是过程更慢和更手动化。如果你不知道这些大文件在_哪里_,那么你第一步就需要找到它们: + +### 手动查看你Git仓库中的大文件 + +[Antony Stubbs][16]写了一个可以很好地完成这个功能的BASH脚本。该脚本可以检查你的包文件的内容并列出大文件。在你开始删除文件之前,请执行以下操作获取并安装此脚本: + +1\. [下载脚本][10]到你的本地的系统。 + +2\. 将它放在一个可以访问你的Git仓库的易于找到的位置。 + +3\. 让脚本成为可执行文件: + +``` + $ chmod 777 git_find_big.sh + +``` +4\. 克隆仓库到你本地系统。 + +5\. 改变当前目录到你的仓库根目录。 + +6\. 手动运行Git垃圾回收器: + +``` + git gc --auto +``` + +7\. 找出.git文件夹的大小 + +``` +$ du -hs .git/objects +``` +``` +45M .git/objects +``` +注意文件大小,以便随后参考。 + +8\. 运行`git_find_big.sh`脚本来列出你的仓库中的大文件。 + +``` +$ git_find_big.sh + +``` +所有文件大小都用kb表示,pack列是在pack文件内压缩后的大小。 + +``` +size pack SHA                                       location +``` +``` +592   580   e3117f48bc305dd1f5ae0df3419a0ce2d9617336 media/img/emojis.jar +``` +``` +550   169   b594a7f59ba7ba9daebb20447a87ea4357874f43 media/js/aui/aui-dependencies.jar +``` + +``` +518   514   22f7f9a84905aaec019dae9ea1279a9450277130 media/images/screenshots/issue-tracker-wiki.jar +``` +``` +337   92   1fd8ac97c9fecf74ba6246eacef8288e89b4bff5 media/js/lib/bundle.js +``` +``` +240   239   e0c26d9959bd583e5ef32b6206fc8abe5fea8624 media/img/featuretour/heroshot.png +``` +大文件都是JAR文件,包的大小列是最相关的。`aui-dependencies.jar` 被压缩到169kb,但是`emojis.jar`只压缩到500kb。`emojis.jar`就是一个待删除的对象。 + + +### 运行filter-branch + + +你可以给这个命令传递一个用于重写Git索引的过滤器。例如,一个过滤器可以可以将每个检索的提交删除。这个用法如下: + +``` +git filter-branch --index-filter 'git rm --cached --ignore-unmatch  _pathname_ ' commitHASH + +``` +`--index-filter`选项可以修改仓库的索引,`--cached ` 选项从不是磁盘的索引中删除文件。这样会更快,因为你不需要在运行这个过滤器前检查每个修订版。`git rm`中的`ignore-unmatch`选项可以防止当 _pathname_ 正在尝试不在那的文件的时候这个命令失败。通过明确一个提交HASH值,你可以从每个以这个HASH值开始的提交中删除`pathname`。为了从开始处删除,你可以省略这个或者明确HEAD。 + +如果所有你的大文件在不同的分支,你将需要通过名字来删除每个文件。如果所有大文件在一个单独的分支,你可以直接删除这个分支本身。 + +### 选项1:通过文件名删除文件 + +使用下面的步骤来删除大文件: + +1\. 使用下面的命令来删除你找到的第一个大文件: + +``` +git filter-branch --index-filter 'git rm --cached --ignore-unmatch filename' HEAD + +``` + +2\. 对于剩下的每个大文件,重复步骤1。 + +3\. 在你的仓库里更新引用。 `filter-branch`会为你原先的引用创建一个以`refs/original/`命名的备份。一旦你确信已经删除了正确的文件,你可以运行下面的命令来删除备份文件,同时可以让垃圾回收器回收大的对象: + +``` + git filter-branch --index-filter 'git rm --cached --ignore-unmatch filename' HEAD + +``` + +### 选项2:直接删除分支 + +如果你所有的大文件都在一个单独的分支上,你可以直接删除这个分支。删除这个分支会自动删除所有的引用。 + +1\. 删除分支。 + +``` + $ git branch -D PROJ567bugfix + +``` + +2\. 从后面的分支中删除所有的reflog引用。 + + +### 对不用的数据垃圾回收 + +1\. 删除从现在到后面的所有reflog引用(除非你明确地只在一个分支上操作)。 + +``` +$ git reflog expire --expire=now --all + +``` + +2\. 通过运行垃圾回收器和删除旧的对象重新打包仓库。 + +``` + $ git gc --prune=now + +``` + +3\. 把你所有的修改推送回Bitbucket仓库。 + +``` +$ git push --all --force +``` + +4\. 确保你所有的tags也是当前最新的: + +``` + $ git push --tags --force + +``` + +via: https://confluence.atlassian.com/bitbucket/maintaining-a-git-repository-321848291.html + +作者:[atlassian.com][a] +译者:[zhousiyu325](https://github.com/zhousiyu325) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://confluence.atlassian.com/bitbucket/maintaining-a-git-repository-321848291.html +[1]:https://confluence.atlassian.com/bitbucket/maintaining-a-git-repository-321848291.html#MaintainingaGitRepository-UnderstandingfileremovalfromGithistory +[2]:https://confluence.atlassian.com/bitbucket/maintaining-a-git-repository-321848291.html#MaintainingaGitRepository-UsingtheBFGtorewritehistory +[3]:https://confluence.atlassian.com/bitbucket/maintaining-a-git-repository-321848291.html#MaintainingaGitRepository-Alternatively,usinggitfilter-branchtorewritehistory +[4]:https://confluence.atlassian.com/bitbucket/maintaining-a-git-repository-321848291.html#MaintainingaGitRepository-Garbagecollectingdeaddata +[5]:http://stackoverflow.com/questions/3959924/whats-the-difference-between-git-clone-mirror-and-git-clone-bare +[6]:http://git-scm.com/docs/git-reflog +[7]:http://git-scm.com/docs/git-gc +[8]:http://rtyley.github.io/bfg-repo-cleaner/ +[9]:http://git-scm.com/docs/git-filter-branch +[10]:https://confluence.atlassian.com/bitbucket/files/321848291/321979854/1/1360604134990/git_find_big.sh +[11]:http://rtyley.github.io/bfg-repo-cleaner/ +[12]:http://rtyley.github.io/bfg-repo-cleaner/#protected-commits +[13]:https://www.youtube.com/watch?v=Ir4IHzPhJuI +[14]:http://rtyley.github.io/bfg-repo-cleaner/#usage +[15]:http://rtyley.github.io/bfg-repo-cleaner/#examples +[16]:https://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/ \ No newline at end of file diff --git a/translated/tech/20170519 How to Kill a Process from the Command Line.md b/translated/tech/20170519 How to Kill a Process from the Command Line.md new file mode 100644 index 0000000000..32821203f1 --- /dev/null +++ b/translated/tech/20170519 How to Kill a Process from the Command Line.md @@ -0,0 +1,202 @@ +怎样在命令行下杀死一个进程 +============================================================ + +![stop processes](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/stop-processes.jpg?itok=vfNx8VRz "stop processes") +>linux的命令行有你需要的用来停止正在运行的进程的所有工具。Jack Wallen透露出细节。[Creative Commons Zero][4] + +想像一下: 你打开了一个程序 (可能来自于你的桌面菜单或者命令行) ,然后开始使用这个app, 没想到程序会锁死, 停止运行, 或者以外死机. 你尝试再次运行app, 但是结果是不能够完全真正的关机。 + +你该怎么办? 你要结束进程. 但该如何做? 信或者不信,最好的解决方法大都在命令行里. 值得庆幸的是, Linux有每个必要的工具来供用户杀死错误的进程,然而, 你在执行杀死进程的命令之前, 你首先必须知道进程是什么. 该如何处理这层的任务? 一旦你能够掌握这个工具,它实际是十分简单的... + +让我来介绍给你这些工具. +我来概述的步骤是每个linux发行版都能用的,不论是桌面版还是服务器版。 +我讲严格使用命令行,打开你的终端开始输入命令吧。 + +### 定位进程 + +杀死一个没有响应的进程的第一个步骤是定位这个进程。我用来定位进程的命令有两个:top和ps命令。top是每个系统管理员都知道的工具,用top命令,你能够get到所有当前正在运行的进程有那些。在命令行里,输入top命令能够就看到你正在运行的程序进程(图1) + + +### [killa.jpg][5] + +![top](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/killa.jpg?itok=95cUI9Lh "top") + +图1: top命令给出你许多的信息.[通过权限使用][1] + +从显示的列表中你能够看到相当重要的信息,举个例子,Chrome浏览器反映迟钝,依据我们的top命令显示,我们能够辨别的有四个Chrome浏览器的进程在运行,进程的pid号分别是3827,3919,10764,和11679.这个信息是重要的,可以用一个特殊的方法来结束进程。 + +尽管top命令很是方便, 但也不是得到你所要信息最有效的方法。 你知道你要杀死的Chrome进程是那个,并且你也不想看top命令所显示的实时信息。 鉴于此, 你能够使用ps命令然后用grep命令来过滤出输出结果。这个ps命令能够显示出当前进程的快照,然后用grep命令输出匹配的样式。我们通过grep命令过滤ps命令的输出的理由很简单:如果你只输入ps命令,你将会得到当前所有进程的快照列表,而我们需要的是列出Chrome浏览器进程相关的。所以这个命令是这个样子: + +``` +ps aux | grep chrome +``` + +The  _aux_  options are as follows: #辅助选项如下所示 + +* a = show processes for all users #a = 显示所有用户的进程 + +* u = display the process's user/owner #u = 显示进程的用户和拥有者 + +* x = also show processes not attached to a terminal #x = 显示进程不依附于终端 + +当你在图形化程序上搜寻信息的时候,这个x参数是很重要的。 + +当你输入以上命令的时候,你将会得到比图2更多的结束一个进程的信息,而且它有事用起来比top命令更有效。 +### [killb.jpg][6] + +![ps command](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/killb.jpg?itok=vyWIuTva "ps command") + +图2: 用ps命令来定位所需的内容信息。[通过权限使用][2] + +### 结束进程 + +现在我们开始结束进程的任务。我们有两种信息来帮我们杀死错误的进程。 + +* Process name #进程的名字 + +* Process ID #进程的ID + +你用哪一个将会决定终端命令如何使用,通常有两个命令来结束进程: + +* kill - Kill a process by ID #通过ID来结束进程 + +* killall - Kill a process by name #通过进程名字来结束进程 + +有两个不同的信号能够发送给两个结束进程的命令。你发送的信号决定着你想要从结束进程命令中得到的结果。举个例子,你可以发送HUP(挂起)信号给结束进程的命令,命令实际上将会重启这个进程。当你需要立即重启一个进程(比如就守护进程来说),这是一个明智的选择。你通过输入kill -l可以得到所有信号的列表。,你将会发现大量的信号。(图3) + +### [killc.jpg][7] + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/killc.jpg?itok=9ewRHFW2) + +图3: 可用的结束进程信号.[通过权限使用][3] + +最经常使用的结束进程的信号是:T + +| + +Signal Name + + | + +Single Value + | + +Effect + + | +| + +SIGHUP + + | + +1 + + | + +Hangup + + | +| + +SIGINT + + | + +2 + + | + +Interrupt from keyboard + + | +| + +SIGKILL + + | + +9 + + | + +Kill signal + + | +| + +SIGTERM + + | + +15 + + | + +Termination signal + + | +| + +SIGSTOP + + | + +17, 19, 23 + + | + +Stop the process + + | + +好的是,你能用信号值来代替信号名字。所以你没有必要来记住所有各种各样的信号名字。 +所以,让我们现在用kill命令来杀死Chrome浏览器的进程。这个命令的结构是: + +``` +kill SIGNAL PID +``` + +信号被发送到那里,进程的ID就会被结束。我们已经知道,来自我们的ps命令显示我们想要结束的进程ID号是3827, 3919, 10764, and 11679\。所以要发送结束进程信号,我们输入以下命令: + +``` +kill -9 3827 + +kill -9 3919 + +kill -9 10764 + +kill -9 11679 +``` + +一旦我们输入了以上命令,Chrome浏览器的所有进程将会成功被杀死。 + +我们有更简单的方法! 如果我们已经知道我们想要杀死的那个进程的名字,我们能够利用killall命令发送同样的信号,像这样: + + _killall -9 chrome_ + +附带说明的是,上边这个命令可能不能捕捉到所有正在运行的Chrome进程。如果,运行了上边这个命令之后,你输入ps aux|grep chrome 命令过滤一下,看到剩下正在运行的Chrome进程有那些,最好的办法还是回到KIll命令通过进程的ID来发送信号值9来结束这个进程。 + +### 结束进程变得容易 + +正如你看到的,杀死错误的进程并没有你原本想的那样有挑战性。当我让一个顽固的进程结束的时候,我趋向于用killall命令来作为有效的方法来终止,然而,当我让一个真正的活跃的进程结束的时候,kill命令是一个好的方法。 + +------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2017/5/how-kill-process-command-line + +作者:[JACK WALLEN][a] +译者:[hwlog](https://github.com/hwlog) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/jlwallen +[1]:https://www.linux.com/licenses/category/used-permission +[2]:https://www.linux.com/licenses/category/used-permission +[3]:https://www.linux.com/licenses/category/used-permission +[4]:https://www.linux.com/licenses/category/creative-commons-zero +[5]:https://www.linux.com/files/images/killajpg +[6]:https://www.linux.com/files/images/killbjpg +[7]:https://www.linux.com/files/images/killcjpg +[8]:https://www.linux.com/files/images/stop-processesjpg