diff --git a/published/20171027 Share And Upload Files To Compatible Hosting Sites Automatically.md b/published/20171027 Share And Upload Files To Compatible Hosting Sites Automatically.md new file mode 100644 index 0000000000..fd24ef3c36 --- /dev/null +++ b/published/20171027 Share And Upload Files To Compatible Hosting Sites Automatically.md @@ -0,0 +1,240 @@ +自动共享和上传文件到兼容的托管站点 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2017/10/Upload-720x340.png) + +前阵子我们写了一个关于 [Transfer.sh][1]的指南,它允许你使用命令行通过互联网来分享文件。今天,我们来看看另一种文件分享实用工具 Anypaste。这是一个基于文件类型自动共享和上传文件到兼容托管站点的简单脚本。你不需要去手动登录到托管站点来上传或分享你的文件。Anypaste 将会根据你想上传的文件的类型来**自动挑选合适的托管站点**。简单地说,照片将被上传到图像托管站点,视频被传到视频站点,代码被传到 pastebin。难道不是很酷的吗?Anypaste 是一个完全开源、免费、轻量的脚本,你可以通过命令行完成所有操作。因此,你不需要依靠那些臃肿的、需要消耗大量内存的 GUI 应用来上传和共享文件。 + +### 安装 + +正如我所说,这仅仅是一个脚本。所以不存在任何复杂的安装步骤。只需要将脚本下载后放置在你想要运行的位置(例如 `/usr/bin/`),并将其设置为可执行文件后就可以直接使用了。此外,你也可以通过下面的这两条命令来快速安装 Anypaste。 + +``` +sudo curl -o /usr/bin/anypaste https://anypaste.xyz/sh +sudo chmod +x /usr/bin/anypaste +``` + +就是这样简单。如果需要更新老的 Anypaste 版本,只需要用新的可执行文件覆写旧的即可。 + +现在,让我们看看一些实例。 + +### 配置 + +Anypaste 开箱即用,并不需要特别的配置。默认的配置文件是 `~/.config/anypaste.conf`,这个文件在你第一次运行 Anypaste 时会自动创建。 + +需要配置的选项只有 `ap_plugins`。Anypaste 使用插件系统上传文件。每个站点(的上传)都由一个特定的插件表示。你可以在 `anypaste.conf` 文件中的 `ap-plugins directive` 位置浏览可用的插件列表。 + +``` +# List of plugins +# If there are multiple compatible plugins, precedence is determined +# by which one is listed first in this array +ap_plugins=( +# Videos/Gifs +'sendvid' 'streamable' 'gfycat' +# Images +'tinyimg' 'vgyme' +# Audio +'instaudio' +# Text +'hastebin' 'ixio' 'sprunge' +# Documents +'docdroid' +# Any file +'jirafeau' 'fileio' +) +[...] +``` + +如果你要安装一个新的插件,将它添加进这个列表中就可以了。如果你想禁用一个默认插件,只需要将它从列表中移除即可。如果有多个兼容的插件,排列中的第一个会被选择,因此**顺序很重要**。 + +### 用法 + +上传一个简单的文件,例如 `test.png`,可以运行以下命令: + +``` +anypaste test.png +``` + +输出示例: + +``` +Current file: test.png +Attempting to upload with plugin 'tinyimg' +######################################################################## 100.0% + +Direct Link: https://tinyimg.io/i/Sa1zsjj.png + +Upload complete. +All files processed. Have a nice day! +``` + +正如输出结果中所看到的,Anypaste 通过自动匹配图像文件 `test.png` 发现了兼容的托管站点(https://tinyimg.io),并将文件上传到了该站点。此外,Anypaste 也为我们提供了用于直接浏览/下载该文件的链接。 + +不仅是 png 格式文件,你还可以上传任何其他图片格式的文件。例如,下面的命令将会上传 gif 格式文件: + +``` +$ anypaste file.gif +Current file: file.gif +Plugin 'streamable' is compatible, but missing config parameters: 'streamable_email' 'streamable_password' +You can set them in /home/sk/.config/anypaste.conf +Attempting to upload with plugin 'gfycat' +######################################################################## 100.0% +Reminder: Gfycat needs time to encode. Your video will not appear right away. + +Link: https://gfycat.com/MisguidedQuaintBergerpicard +Direct(ish) Link: https://thumbs.gfycat.com/MisguidedQuaintBergerpicard-size_restricted.gif + +Upload complete. +All files processed. Have a nice day! +``` + +你可以将链接分享给你的家庭、朋友和同事们。下图是我刚刚将图片上传到 gfycat 网站的截图。 + +![][3] + +也可以一次同时上传多个(相同格式或不同格式)文件。 + +下面的例子提供参考,这里我会上传两个不同的文件,包含一个图片文件和一个视频文件: + +``` +anypaste image.png video.mp4 +``` + +输出示例: + +``` +Current file: image.png +Attempting to upload with plugin 'tinyimg' +######################################################################## 100.0% + +Direct Link: https://tinyimg.io/i/au1PHpg.png + +Upload complete. +Current file: video.mp4 +Plugin 'streamable' is compatible, but missing config parameters: 'streamable_email' 'streamable_password' +You can set them in /home/sk/.config/anypaste.conf +Attempting to upload with plugin 'sendvid' +######################################################################## 100.0% + +Link: http://sendvid.com/wwy7w96h +Delete/Edit: http://sendvid.com/wwy7w96h?secret=39c0af2d-d8bf-4d3d-bad3-ad37432a40a5 + +Upload complete. +All files processed. Have a nice day! +``` + +Anypaste 针对两个文件自动发现了与之相兼容的托管站点并成功上传。 + +正如你在上述用法介绍部分的例子中注意到的,Anypaste 会自动挑选最佳的插件。此外,你可以指定插件进行文件上传,这里提供一个上传到 gfycat 的案例,运行以下命令: + +``` +anypaste -p gfycat file.gif +``` + +输出示例: + +``` +Current file: file.gif +Plugin 'streamable' is compatible, but missing config parameters: 'streamable_email' 'streamable_password' +You can set them in /home/sk/.config/anypaste.conf +Attempting to upload with plugin 'gfycat' +######################################################################## 100.0% +Reminder: Gfycat needs time to encode. Your video will not appear right away. + +Link: https://gfycat.com/GrayDifferentCollie +Direct(ish) Link: https://thumbs.gfycat.com/GrayDifferentCollie-size_restricted.gif + +Upload complete. +All files processed. Have a nice day! +``` + +如果要使用特定插件进行文件上传,可以通过以下命令绕过兼容性检查: + +``` +anypaste -fp gfycat file.gif +``` + +如果你发现在配置文件中忽略了特定的插件,你仍然可以强制 Anypaste 去使用特定的插件,只不过需要加上 `-xp` 参数。 + +``` +anypaste -xp gfycat file.gif +``` + +如果想要以交互模式上传文件,可以在命令后加上 `-i` 标签: + +``` +$ anypaste -i file.gif +Current file: file.gif +Determine compatible plugins automatically? [Y/n] **n** +The following plugins were found: 'sendvid' 'streamable' 'gfycat' 'tinyimg' 'vgyme' 'instaudio' 'hastebin' 'ixio' 'sprunge' 'docdroid' 'jirafeau' 'fileio' + +Enter the (partial) name of a plugin, or nothing for automatic selection +**gfycat** +Attempt to upload with plugin 'gfycat'? [Y/n] **y** +Attempting to upload with plugin 'gfycat' +######################################################################## 100.0% +Reminder: Gfycat needs time to encode. Your video will not appear right away. + +Link: https://gfycat.com/WaryAshamedBlackbear +Direct(ish) Link: https://thumbs.gfycat.com/WaryAshamedBlackbear-size_restricted.gif + +Upload complete. +All files processed. Have a nice day! +``` + +正如你所见,Anypaste 首先询问了我是否需要自动确定插件。因为我不想自动寻找插件,所以我回复了 “No”。之后,Anypaste 列出了所有可选择的插件,并要求我从列表中选择一个。同样的,你可以上传和共享不同类型的文件,相关文件会被上传到相兼容的站点。 + +无论你何时上传一个视频文件,Anypaste 都会将其上传到以下站点中的一个: + + 1. sendvid + 2. streamable + 3. gfycat + +这里注意列表顺序,Anypaste 将首先将文件上传到 sendvid 站点,如果没有 sendvid 的插件可供使用,Anypaste 将会尝试顺序中的另外两个站点。当然你也可以通过更改配置文件来修改顺序。 + +图像文件上传站点: + + 1. tinyimg.io + 2. vgy.me + +音频文件上传站点: + + 1. instaud + +文本文件上传站点: + + 1. hastebin + 2. ix.io + 3. sprunge.us + +文档上传站点: + + 1. docdroid + +其他任意类型的文件上传站点: + + 1. jirafeau + 2. file.io + +上面列出来的部分站点一段特定的时间后会删除上传的内容,所以在上传和分享内容时应先明确这些站点的条款和条件。 + +### 结论 + +在我看来,识别文件并决定将其上传到何处的想法非常棒,而且开发者也以恰当的方式完美地实现了它。毫无疑问,Anypaste 对那些在互联网上需要频繁分享文件的人们非常有用,我希望你也能这么觉得。 + +这就是今天的全部内容,后面会有越来越多的好东西分享给大家。再见啦! + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/anypaste-share-upload-files-compatible-hosting-sites-automatically/ + +作者:[SK][a] +译者:[lixin555](https://github.com/lixin555) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:https://www.ostechnix.com/easy-fast-way-share-files-internet-command-line/ +[2]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]:http://www.ostechnix.com/wp-content/uploads/2017/10/gfycat.png diff --git a/published/20180207 23 open source audio-visual production tools.md b/published/20180207 23 open source audio-visual production tools.md new file mode 100644 index 0000000000..3df9236b46 --- /dev/null +++ b/published/20180207 23 open source audio-visual production tools.md @@ -0,0 +1,289 @@ +23 款开源的声音、视觉生产工具 +====== + +> 无论你是要进行音频、图形、视频、动画还是它们的任意组合,都有一个开源工具可以帮助你产生专业水平的结果。 + +![](https://img.linux.net.cn/data/attachment/album/201912/04/093037w8ab8v0voz0b5u88.jpg) + +“开源”在云基础设施、网站托管、嵌入式设备和其他领域已经建立的相当完善。很少数人知道开源在生产专业级的声音视觉素材上也是一个不错的选择。 + +作为一名产品经理(有时候也是市场支持),我为终端用户提供很多内容:文档、文章、视频教学,甚至是展台物料、白皮书、采访等等。我找到了很多可以帮我制作音频、视频、排版、截屏的开源软件。人们选择开源软件而不是专有软件的[原因][1]有很多,而我也为以下人群编制了一份开源音视频工具清单: + +* 想要入坑 GNU/Linux,但需要在原来的操作系统上慢慢从使用跨平台软件开始 +* 热爱开源,但对音视频开源软件所知甚少,不知道该如何选择 +* 想要为创造力充电而探索新的工具,并且不想使用其他人使用过的方法工具 +* 存在某些其他的原因使用开源音视频解决方案(如果是你,不妨在评论里分享一下) + +幸运的是,存在着很多开源的音视频创作软件,也存在着很多硬件来支持这些应用。本文清单里的所有软件都符合以下标准: + +* 跨平台 +* 开源(软件和驱动) +* 稳定 +* 积极维护 +* 良好的文档与技术支持 + +我将清单中的解决方案划分为图形、音频、视频和动画。注意,本文中提到的应用程序并不完全等同于一些有名的私有软件,它们需要花时间来学习,并且可能需要改变你的工作流程,但是学习新的工具能够让体验全新的创造方式。 + +### 图形 + +我制作过很多出版和网站使用的图形,包括徽标、横幅、视频节目、草图。这里是一些我用过的开源应用,也包括一同使用的硬件。 + +#### 软件 + +**1、[Inkscape][2]**(矢量图) + +Inkscape 是一款不错的矢量图编辑器,用来制作 RGB 颜色空间下的 SVG 和 PDF 文件。(它可以制作 CMYK 图像,但不是主要用途)它是为 web 应用制作 SVG 格式的地图和图表的人的救命稻草。你不仅可以使用集成的 XML 编辑器打开文件,也可以用它查看对象的所有参数。但有一个缺点:它在 Mac 上的优化不是很好。有很多样例,可以看[Inkscape 画廊][3]。 + +**2、[GIMP][4]**(图片编辑器) + +GIMP 是我最喜欢的图片编辑程序,它包括了色彩调整、裁剪和拉伸,并且(尤其是)对于网页使用的文件大小进行了优化(很多使用 Photoshop 的同事让我帮他们做这最后一步)。你也可以从头制作并绘制一张图片,但 GIMP 并不是我最喜欢用来做这件事的工具。在 [GIMP Artists on DevianArt][5] 上查看众多的样例。 + +**3、[Krita][6]**(数字绘画) + +当你桌子上摆着一个漂亮的 Wacom 数位板,你肯定想试试真正的数字绘画应用。Krita 就是你创作漂亮插画所需要的工具。在 [Krita 画廊][7] 里看看我说的东西吧。 + +**4、[Scribus][8]**(桌面印刷系统) + +你可以使用 Scribus 来创建一个完整的文档,或者只是把用 Inkscape 或 Libre Office 制作的 PDF 从 RGB 转换到 CMYK。有一个功能我非常喜欢:你可以试着模拟视觉障碍人士使用 Scribus 时的体验。当我发送 PDF 文件给商业印刷公司时全指望 Scribus。尽管出版社可能使用像 InDesign 这样的私有软件创建文档,但如果你用 Scribus 正确的完成一份文档,那么打印时就不会出现任何问题。免费建议:第一次发送文件给印刷公司时,不要告诉印刷公司创建该文档所使用的软件。你可以在 [Scribus 教程][9]中寻找创建文档的例子。 + +**5、[RawTherapee][10]**(RAW 图像开发工具) + +RawTherapee 是我所知道唯一跨平台可替代 Lightroom 的软件。你可以将相机调整到 RAW 模式,然后使用 RawTherapee 来修图。它提供了非常强大的引擎和对图片没有破坏的编辑器。例如,可以见 [Raw Therapee 截图][11]。 + +**6、[LibreOffice Draw][12]**(桌面印刷系统) + +尽管你可能认为 LibraOffice Draw 不是一款专业的桌面印刷解决方案,但它仍然能够在很多情况下帮助你。例如,制作其他人(尽管是那些不懂图形软件的人)以后可以修改的白皮书、图表或海报。它不仅方便使用,而且当创建有趣的文档时也是 Impress 或 PowerPoint 的绝佳替代软件。 + +#### 图形硬件 + +**绘图板** + +[Wacom][13] 数位板(和兼容设备)通常支持所有的操作系统。 + +**颜色校正** + +颜色校正产品通常可用于所有操作系统,也包括了 GNU/Linux。Datacolor 生产的 [Spyder][14] 在所有平台上都有应用程序的支持。 + +**扫描仪和打印机** + +图形艺术家需要输出(无论是打印还是电子版)的颜色是精确的。但是真正跨平台的设备,以及所有平台都易于安装的驱动,并不像你想的那样普遍。你的最佳选择是兼容 TWAIN 的扫描仪和兼容 Postscript 的打印机。以我的经验,Epson 和 Xerox 的专业级扫描仪和打印机更不容易出现驱动问题,并且它们通常也是开箱即用,拥有漂亮精确的颜色。 + +### 音频 + +有许多可供音乐家、视频制作者、游戏制作者、音乐出版商等等人群选择的开源音频软件。这里有一些我曾经用来进行内容创作与声音录制时所使用的软件。 + +#### 软件 + +**7、[Ardour][15]**(数字音频录制) + +对录音与编辑来说,最专业级的工具选择当然是唾手可得的 Ardour。听起来很棒,它的混音部分非常的完整灵活,能够提供给你喜欢的插件,并且易于回放、编辑、对比修改。我经常用它进行声音录制和视频混音。要找出一些使用 Ardour 录制好的音乐并不容易,因为音乐家们很少表明他们使用的软件。然而,你可以查看它的[截图][16]和一些特性来了解它的功能。 + +(如果你在寻求一种声音制作方面的“模拟体验”,你可以试试 [Harrison Mixbus][17],它并不是一个开源项目,但是高度基于 Ardour,拥有模拟显示的终端。我非常喜欢用它进行工作,我的客户也喜欢用它制作的声音。Mixbus 也是跨平台的) + +**8、[Audacity][18]** (声音编辑) + +Audacity 属于“瑞士军刀”级的声音制作软件。它并不完美,但你几乎可以用它做所有的事情。加上非常易于使用,任何人都能在几分钟之内上手。像 Ardour 一样,很难找到一份归功于 Audacity 的作品,但你可以从这些[截图][19]中了解如何使用它。 + +**9、[LMMS][20]** (音乐制作) + +LMMS,设计作为 FL Studio 的替代品,也许使用并不那么广泛,但它非常完整并易于使用。你可以使用自己最喜欢的插件,使用“钢琴键”编辑乐器,使用步定序器step sequencer播放鼓点,混合音轨...几乎能做任何事情。在我没有时间为音乐家录音的时候我就使用它为视频创建声音片段。查看[最好的 LMMS][21] 榜单来看看一些例子。 + +**10、[Mixxx][22]** (DJ,音乐混音) + +如果你需要强大的混音和播放 DJ 软件,Mixxx 就可以满足你的需求。它与大多数 MIDI 控制器、唱片、专用声卡所兼容。你可以用它管理音乐库、添加音效,做一些有趣的事情。查看它的[功能][23]来了解它是如何工作的。 + +#### 音频接口硬件 + +尽管你可以使用任何一个计算机的声卡录制音频,但要录制的很好,就需要一个音频接口——一个录制高质量音频输入的专用的外部声卡。对于跨平台兼容性来说,大多数“兼容 USB”和“兼容 iOS”的音频接口设备应该都能录制 MIDI 或其他音频。下面是一些我用过的一些有名气的跨平台设备。 + +**[Behringer U-PHORIA UMC22][24]** + +UMC22 是你可以考虑的最便宜的选择。但它的前置放大器噪音太大,音腔box质量也比较低。 + +**[Presonus AudioBox USB][25]** + +AudioBox USB 是第一个兼容 USB(因此也跨平台)的录音系统。它非常的耐用,经常在二手市场也能见到。 + +**[Focusrite Scarlett][26]** + +Scarlett 在我看来是目前最高质量的跨平台声卡。不同种类的设备可以涵盖 2-18 个输入/输出端口。你可以在二手市场找到它的最初版本,而最新的第二代具有更好的前置放大器与规格。[2i2][27] 型号是我经常使用的那一款。 + +**[Arturia AudioFuse][28]** + +AudioFuse 几乎可以让你接入任何设备,从麦克风到黑胶唱片机再到各种数字输入设备。它具有优质的声音与良好的设计,也是我目前用的最多的一款设备。它是跨平台的,但目前配置软件还不能在 GUN/Linux 上使用。即使我把它从 Windows 电脑上断开,它仍然保留着我的配置。但是讲真,Arturia,劳烦认真考虑做一个 Linux 的软件。 + +#### MIDI 控制器 + +MIDI 控制器是一种乐器——例如电子琴、鼓垫等等。可以让你控制音乐软件或者硬件。现有的大多数 USB MIDI 控制器都跨平台并兼容主流的录音编辑软件。基于网页的教程可以帮你对不同的软件进行配置。尽管找到有关在 GNU/Linux 上配置的信息可能比较困难,但它们仍然是可以使用的。我用过许多 Akai 和 M-Audio 设备,没有任何问题。在买乐器之前最好先试一下,至少去听一下它们的音质或体验一下按键触感。 + +#### 音频编解码器 + +音频编解码器压缩或解压数字音频,用尽可能小的文件大小获得最佳质量的声音。幸运的是,用于收听或流媒体播放的编解码器恰好是开源的:[FLAC][29]。[Ogg Vorbis][30] 是另一个值得了解的开源音频编解码器;在相同的比特率下比 MP3 好的多。如果你需要输出不同的音频格式,我建议通常存档最好质量的音频,然后再压缩成特定的版本。 + +### 视频 + +视频对于品牌的传播是影响巨大的。即使你不是一个视频专家,学习一些基础的东西也是非常明智的。 + +#### 软件 + +**11、[VLC][31]** (视频播放器与转换器) + +最初是为流媒体而开发的,VLC 现在因能够在所有设备上读取所有的视频格式被人们熟知。它非常的实用,例如,你可以使用它将视频转换成其他编解码格式或容器,也可以用来恢复破损的视频。 + +**12、[OpenShot][32]** (视频编辑) + +OpenShot 是一个简单的软件,但它却可以制作出很好的效果,尤其是在短视频上。(在编辑或改善音质方面有一定的限制,但它也能够完成)我非常喜欢它的移动、拉伸、裁剪工具;用它创建视频的开头或结尾,导出之后使用更复杂的编辑器进行编辑,非常的完美。你可以在 OpenShot 的网站上看这些[例子][33](并获取更多信息)。 + +**13、[Shotcut][34]** (视频编辑) + +我认为 Shotcut 是比 OpenShot 更完整一些的工具——它在你的操作系统上比起其他较为基础的编辑器更具有竞争力,并且它支持 4K 分辨率,具有专业的解码器。尝试一下,我相信你会爱上它的。你可以在这些[视频教程][35]里看一些范例。 + +**14、[Blender Velvets][36]** (视频编辑、合成、特效) + +尽管这一章节不是本文的学习重点,但 Blender Velvets 是你能找到的最强大的解决方案之一。它是由一些视频创作者所制作的一系列扩展工具和脚本的合集,是通过 Blender 3D 制作软件转换成的 2D 视频编辑器。尽管它的复杂度意味着不是我的首选视频编辑器,但你仍可以在 YouTube 和其他网站上找到它的教程,并且一旦你学习了它,你就能通过它做任何事情。观看这个[视频教程][37]来了解它的功能与运作方式。 + +**15、[Natron][38]**(合成) + +我不使用 Natron,但我听说它广受好评。它是 Adobe After Effects 的替代品,但运作方式并不同。想了解更多可以观看一些视频教程,比如这些 Natron 的 [YouTube 频道][39]。 + +**16、[OBS][40]** (实时编辑、录制、流媒体) + +Open Broadcaster Software(OBS)是一个领先的在 YouTube 或 Twitch 上进行现场录制或现场直播电子竞技、电视游戏的解决方案。我经常使用它记录用户的屏幕、会议和聚会。要获取更多信息,查看我曾经在 Opensource.com 上写的关于录制现场汇报的教程,[第一部分:选择你的设备][42]和[第二部分:软件安装][43]。 + +#### 视频硬件 + +结论先行:你需要一个强大的工作站以及快速的硬盘和更新的软件和驱动。 + +**图形处理单元(GPU)** + +一部分包含在清单里的软件比如 Blender 和 Shotcut 使用 OpenGL 和硬件加速,这些都高度依赖 GPU。我建议你使用可以负担起的最强大的 GPU。我所使用过的 AMD 和 Nvidia 都有着良好的体验,这取决于使用的平台。不要忘记安装最新的驱动。 + +**硬盘** + +大体上来说,越快越大的硬盘,对视频越好。不要忘记在软件里配置好正确的路径。 + +**视频录制硬件** + +* [Blackmagic Design][44]: Blackmagic 提供了非常好的、专业级的视频录制和回放硬件。驱动支持 Mac、Windows 和 GNU/Linux(但不是所有的发行版) +* [Epiphan][45]: 在 Epiphan 的专业级 USB 视频录制设备中有一款新型产品,它适用于 HDMI 和高分辨率的屏幕。然而,你也可以在二手市场找到旧的 VGA 设备,因为他们还在继续为 GNU/Linux 和 Windows 上提供专用的驱动程序。 + +#### 视频编解码 + +不幸的是,使用开源的编解码器仍然很困难。例如,许多相机使用专有的编解码器录制 H.264 的视频和 AC3 的音频,组成称为 AVCHD 的格式。因此,我们必须务实,尽可能利用现有资源。 + +好消息是内容产业正在步向开源的编解码器来避免一些费用,并使用开源标准。对于出版和流媒体,[谷歌][46]的 [WebM][46] 便是一款优秀的开源编解码器,并且大多数视频编辑器可以导入这种格式。同样地, [GoPro][47]的超高分辨率和 360° 视频编解码器 [Cineform][47] 现在也进行了开源。希望更多的设备和供应商将会在不久之后使用它。 + +### 2D 和 3D 动画 + +动画不是我的专业领域,因此我问了从事于动画内容生产的朋友一些建议并加入到清单中,他的工作包含儿童电影和连续剧。 + +#### 软件 + +**17、[Blender][48]** (3D 模型和渲染) + +Blender 是顶级的开源跨平台 3D 建模和渲染软件。你可以直接在 Blender 中完成整个项目的工作,或者使用它为电影或视频创建 3D 效果。你能够在网上找到许多视频教程,因此即使它不是一个简单的软件,但也非常容易上手。Blender 是一个非常活跃的项目,经常还会制作一些微电影来展示他们的技术。你可以在 [Blender Open Movies][49] 上观看。 + +**18、[Synfig Studio][50]** (2D 动画) + +第一次用 Synfig 时,它让我想起了那个不错的 Macromedia 老式 Flash 编辑器。在那之后,它已经发展成一个全功能的 2D 动画工作室。你可以使用它制作宣传故事、商业广告、演示、开场或结尾动画以及视频中的转场,或者甚至用它制作全动画的电影。见 [Synfig 作品集][51]。 + +**19、[TupiTube][52]** (定格 2D 动画) + +使用 TupiTube 是一个学习基本 2D 动画的极好方法。你可以将一系列绘画或其他图片转换成一个视频或者创建一个 GIF 循环动画。它是一个相当简单的软件,但非常完整。查看 [TupiTude 的 YouTube][53] 频道获取一些教程和范例。 + +#### 硬件 + +动画制作使用与图形设计相同的硬件,因此查看第一小结中的硬件清单获取一些建议。 + +有一点需要注意:你要用一个强大的 GPU 来进行 3D 建模和渲染。选择可能有些限制,因为这取决于你使用的平台或电脑制造商,但是不要忘记安装最新的驱动。谨慎选择你的显卡:它们非常昂贵,并且在大型的 3D 项目中至关重要,尤其是在渲染步骤中。 + +### Linux 上的选择 + +如果你是 GUN/Linux 用户,那么我为你提供了更多不错的选择。它们并不是完全跨平台的,但部分拥有 Windows 版本,还有一些可以在 Mac 上使用 Macports 安装。 + +**20、[Kdenlive][54]** (视频编辑) + +伴随着最新版本的发布(几个月之前),Kdenlive 成为了我最喜欢的视频编辑器,尤其是当我在 Linux 机器上处理一些长视频的时候。如果你经常使用流行的非线性视频编辑器,Kdenlive(全称是 KDE 非线性视频编辑器KDE Non-Linear Video Editor)对你来说将非常简单。它拥有很棒的视频和音频特效,强大的细节处理能力。并且在 BSD 和 MacOS(尽管它对准的是 GNU/Linux)都能使用,还有望移植到 Windows 上。 + +**21、[Darktable][55]** (RAW 图像开发) + +Darktable 是一款由摄影师制作的非常完整的 DxO PhotoLab 替代品。一些研究型项目使用它当做开发平台并测试一些图像处理算法。它是一个非常活跃的项目,我已经等不及的见到它的跨平台版本了。 + +**22、[MyPaint][56]** (digital painting数字绘画) + +MyPaint 就像数字绘画领域的 light table(LCTT 译注:集成开发环境)。它在 Wacom 设备上表现良好,并且它的笔刷引擎尤其值得赞赏,因此 GIMP 开发人员正在密切的关注它。 + +**23、[Shutter][57]** (桌面截图) + +当我写这篇教程的时候,我使用了许多截图来进行展示。我最喜欢的 GNU/Linux 截图工具就是 Shutter。事实上,我都找不到在 Windows 或 Mac 上能与之抗衡的一些功能。有一点小遗憾:我很期待 Shutter 在将来能够增加新的功能来创建几秒动态的 GIF 截图。 + +我希望这些足以说服你开源软件是一种非常卓越且可行的音视频内容生产解决方案。如果你正在使用其他开源软件,或者对于使用跨平台软件和硬件进行音视频项目有好的建议,请在评论中分享你的观点。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/2/open-source-audio-visual-production-tools + +作者:[Antoine Thomas][a] +译者:[LuuMing](https://github.com/LuuMing) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/ttoine +[1]:https://opensource.com/resources/what-open-source +[2]:https://inkscape.org/ +[3]:https://inkscape.org/en/gallery/ +[4]:https://www.gimp.org/ +[5]:https://gimp-artists.deviantart.com/gallery/ +[6]:https://krita.org/ +[7]:https://krita.org/en/features/gallery/ +[8]:https://www.scribus.net/ +[9]:https://www.scribus.net/category/made-with-scribus/ +[10]:http://rawtherapee.com/ +[11]:http://rawtherapee.com/blog/screenshots +[12]:https://www.libreoffice.org/discover/draw/ +[13]:http://www.wacom.com/en-us +[14]:http://www.datacolor.com/photography-design/product-overview/#workflow_2 +[15]:https://www.ardour.org/ +[16]:http://ardour.org/features.html +[17]:http://harrisonconsoles.com/site/mixbus.html +[18]:http://www.audacityteam.org/ +[19]:http://www.audacityteam.org/about/screenshots/ +[20]:https://lmms.io/ +[21]:https://lmms.io/showcase/ +[22]:https://www.mixxx.org/ +[23]:https://www.mixxx.org/features/ +[24]:http://www.musictri.be/Categories/Behringer/Computer-Audio/Interfaces/UMC22/p/P0AUX +[25]:https://www.presonus.com/products/audiobox-usb +[26]:https://us.focusrite.com/scarlett-range +[27]:https://us.focusrite.com/usb-audio-interfaces/scarlett-2i2 +[28]:https://www.arturia.com/products/audio/audiofuse/overview +[29]:https://en.wikipedia.org/wiki/FLAC +[30]:https://xiph.org/vorbis/ +[31]:https://www.videolan.org/ +[32]:https://www.openshot.org/ +[33]:https://www.openshot.org/videos/ +[34]:https://shotcut.com/ +[35]:https://shotcut.org/tutorials/ +[36]:http://blendervelvets.org/ +[37]:http://blendervelvets.org/video-tutorial-new-functions-for-the-blender-velvets/ +[38]:https://natron.fr/ +[39]:https://www.youtube.com/playlist?list=PL2n8LbT_b5IeMwi3AIzqG4Rbg8y7d6Amk +[40]:https://obsproject.com/ +[41]:https://opensource.com/article/17/7/obs-studio-pro-level-streaming +[42]:https://opensource.com/article/17/9/equipment-recording-presentations +[43]:https://opensource.com/article/17/9/equipment-setup-live-presentations +[44]:https://www.blackmagicdesign.com/ +[45]:https://www.epiphan.com/ +[46]:https://www.webmproject.org/ +[47]:https://fr.gopro.com/news/gopro-open-sources-the-cineform-codec +[48]:https://www.blender.org/ +[49]:https://www.blender.org/about/projects/ +[50]:https://www.synfig.org/ +[51]:https://www.synfig.org/#portfolio +[52]:https://maefloresta.com/ +[53]:https://www.youtube.com/channel/UCBavSfmoZDnqZalr52QZRDw +[54]:https://kdenlive.org/ +[55]:https://www.darktable.org/ +[56]:http://mypaint.org/ +[57]:http://shutter-project.org/ diff --git a/published/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md b/published/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md new file mode 100644 index 0000000000..c3c7d5d3bf --- /dev/null +++ b/published/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md @@ -0,0 +1,196 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11631-1.html) +[#]: subject: (How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server) +[#]: via: (https://www.linuxtechi.com/install-lemp-stack-fedora-30-server/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +如何在 Fedora 30 Server 上安装 LEMP(Linux、Nginx、MariaDB、PHP) +====== + +在这篇文章中,我们将看看如何在 Fedora 30 Server 上安装 **LEMP** 。LEMP 代表: + + * L -> Linux + * E -> Nginx + * M -> Maria DB + * P -> PHP + +我假设 [Fedora 30][1] 已经安装在你的电脑系统上。 + +![](https://img.linux.net.cn/data/attachment/album/201912/01/103537wil7hd36dhcxdh03.jpg) + +LEMP 是一组强大的软件设置集合,它安装在一个 Linux 服务器上以帮助使用流行的开发平台来构建网站,LEMP 是 LAMP 的一个变种,在其中不是 Apache ,而是使用 EngineX(Nginx),此外,使用 MariaDB 代替 MySQL。这篇入门指南是一个安装 Nginx、Maria DB 和 PHP 的独立指南的作品集合。 + +### 在 Fedora 30 Server 上安装 Nginx、PHP 7.3 和 PHP-FPM + +让我们看看如何在 Fedora 30 Server 上安装 Nginx 和 PHP 以及 PHP FPM。 + +#### 步骤 1) 切换到 root 用户 + +在系统上安装 Nginx 的第一步是切换到 root 用户。使用下面的命令: + +``` +root@linuxtechi ~]$ sudo -i +[sudo] password for pkumar: +[root@linuxtechi ~]# +``` + +#### 步骤 2) 使用 dnf 命令安装 Nginx、PHP 7.3 和 PHP FPM + +使用下面的 `dnf` 命令安装 Nginx: + +``` +[root@linuxtechi ~]# dnf install nginx php php-fpm php-common -y +``` + +#### 步骤 3) 安装额外的 PHP 模块 + +PHP 的默认安装仅自带基本模块和最需要的模块,如果你需要额外的模块,像 PHP 支持的 GD、XML、命令行接口、Zend OPCache 功能等等,你总是能够选择你的软件包,并一次性安装所有的东西。查看下面的示例命令: + +``` +[root@linuxtechi ~]# sudo dnf install php-opcache php-pecl-apcu php-cli php-pear php-pdo php-pecl-mongodb php-pecl-redis php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml -y +``` + +#### 步骤 4) 开始 & 启用 Nginx 和 PHP-fpm 服务 + +使用下面的命令来开始并启用 Nginx 服务: + +``` +[root@linuxtechi ~]# systemctl start nginx && systemctl enable nginx +Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service. +[root@linuxtechi ~]# +``` + +使用下面的命令来开始并启用 PHP-FPM 服务: + +``` +[root@linuxtechi ~]# systemctl start php-fpm && systemctl enable php-fpm +Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service. +[root@linuxtechi ~]# +``` + +#### 步骤 5) 核实 Nginx (Web 服务) 和 PHP 安装 + +注意:假使操作系统防火墙是启用的,并运行在你的 Fedora 30 系统上,那么使用下面的命令来准许 80 和 443 端口: + +``` +[root@linuxtechi ~]# firewall-cmd --permanent --add-service=http +success +[root@linuxtechi ~]# +[root@linuxtechi ~]# firewall-cmd --permanent --add-service=https +success +[root@linuxtechi ~]# firewall-cmd --reload +success +[root@linuxtechi ~]# +``` + +打开网页浏览器,输入下面的 URL: http:// 。 + +![Test-Page-HTTP-Server-Fedora-30][4] + +上面的屏幕证实 Nginx 已经成功地安装。 + +现在,让我们核实 PHP 安装,使用下面的命令创建一个测试 php 页(`info.php`): + +``` +[root@linuxtechi ~]# echo "" > /usr/share/nginx/html/info.php +[root@linuxtechi ~]# +``` + +在网页浏览器中输入下面的 URL, http:///info.php + +![Php-info-page-fedora30][6] + +上面的页面验证 PHP 7.3.5 已经被成功地安装。现在,让我们安装 MariaDB 数据库服务器。 + +### 在 Fedora 30 上安装 MariaDB + +MariaDB 是 MySQL 数据库的一个极好的替代品,因为它的工作方式与 MySQL 非常类似,并且兼容性也与 MySQL 一致。让我们看看在 Fedora 30 Server 上安装 MariaDB 的步骤。 + +#### 步骤 1) 切换到 root 用户 + +在系统上安装 MariaDB 的第一步是切换到 root 用户,或者你可以使用有 root 权限的本地用户。使用下面的命令: + +``` +[root@linuxtechi ~]# sudo -i +[root@linuxtechi ~]# +``` + +#### 步骤 2) 使用 dnf 命令安装 MariaDB(10.3)的最新版本 + +在 Fedora 30 Server 上使用下面的命令来安装 MariaDB: + +``` +[root@linuxtechi ~]# dnf install mariadb-server -y +``` + +#### 步骤 3) 开启并启用 MariaDB 服务 + +在步骤 2 中成功地安装 MariaDB 后,接下来的步骤是开启 MariaDB 服务。使用下面的命令: + +``` +[root@linuxtechi ~]# systemctl start mariadb.service ; systemctl enable mariadb.service +``` + +#### 步骤 4) 保护安装好的 MariaDB + +当我们安装 MariaDB 服务器时,因为默认情况下没有 root 密码,在数据库中也会创建匿名用户。因此,要保护安装好的 MariaDB,运行下面的 `mysql_secure_installation` 命令: + +``` +[root@linuxtechi ~]# mysql_secure_installation +``` + +接下来你将被提示一些问题,仅回答下面展示的问题: + +![Secure-MariaDB-Installation-Part1][7] + +![Secure-MariaDB-Installation-Part2][8] + +#### 步骤 5) 测试 MariaDB 安装 + +在你安装后,你总是能够测试是否 MariaDB 被成功地安装在 Fedora 30 Server 上。使用下面的命令: + +``` +[root@linuxtechi ~]# mysql -u root -p +Enter password: +``` + +接下来,你将被提示一个密码。输入在保护安装好的 MariaDB 期间你设置的密码,接下来你可以看到 MariaDB 欢迎屏幕。 + +``` +Welcome to the MariaDB monitor. Commands end with ; or \g. +Your MariaDB connection id is 17 +Server version: 10.3.12-MariaDB MariaDB Server + +Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. + +Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. + +MariaDB [(none)]> +``` + +最后,我们已经在你的 Fedora 30 Server 上成功地完成安装 LEMP(Linux、Nginx、MariaDB 和 PHP)的所有工作。请在下面的反馈部分发布你的评论和建议,我们将尽快在后面回应。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/install-lemp-stack-fedora-30-server/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxtechi.com/fedora-30-workstation-installation-guide/ +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/06/LEMP-Stack-Fedora30.jpg +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Test-Page-HTTP-Server-Fedora-30-1024x732.jpg +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Test-Page-HTTP-Server-Fedora-30.jpg +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Php-info-page-fedora30-1024x732.jpg +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Php-info-page-fedora30.jpg +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Secure-MariaDB-Installation-Part1.jpg +[8]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Secure-MariaDB-Installation-Part2.jpg diff --git a/published/20190725 24 sysadmin job interview questions you should know.md b/published/20190725 24 sysadmin job interview questions you should know.md new file mode 100644 index 0000000000..b2b6f9b812 --- /dev/null +++ b/published/20190725 24 sysadmin job interview questions you should know.md @@ -0,0 +1,235 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11673-1.html) +[#]: subject: (24 sysadmin job interview questions you should know) +[#]: via: (https://opensource.com/article/19/7/sysadmin-job-interview-questions) +[#]: author: (DirectedSoul https://opensource.com/users/directedsoul) + +24 个必知必会的系统管理员面试问题 +====== + +> 即将进行系统管理员工作面试吗?阅读本文,了解你可能会遇到的一些问题以及可能的答案。 + +![](https://img.linux.net.cn/data/attachment/album/201912/14/124906g3vrkr3vrvqdkw7f.jpg) + +作为一个经常与计算机打交道的极客,在硕士毕业后在 IT 行业选择我的职业是很自然的选择。因此,我认为走上系统管理员之路是正确的路径。在我的职业生涯中,我对求职面试过程非常熟悉。现在来看一下对该职位的预期、职业发展道路,以及一系列常见面试问题及我的回答。 + +### 系统管理员的典型任务和职责 + +组织需要了解系统工作原理的人员,以确保数据安全并保持服务平稳运行。你可能会问:“等等,是不是系统管理员还能做更多的事情?” + +你是对的。现在,一般来说,让我们看一下典型的系统管理员的日常任务。根据公司的需求和人员的技能水平,系统管理员的任务从管理台式机、笔记本电脑、网络和服务器到设计组织的 IT 策略不等。有时,系统管理员甚至负责购买和订购新的 IT 设备。 + +那些寻求系统管理工作以作为其职业发展道路的人可能会发现,由于 IT 领域的快速变化是不可避免的,因此难以保持其技能和知识的最新状态。所有人都会想到的下一个自然而然的问题是 IT 专业人员如何掌握最新的更新和技能。 + +### 简单的问题 + +这是你将遇到的一些最基本的问题,以及我的答案: + +**1、你在 \*nix 服务器上登录后键入的前五个命令是什么?** + +> * `lsblk` 以查看所有的块设备信息 +> * `who` 查看谁登录到服务器 +> * `top`,以了解服务器上正在运行的进程 +> * `df -khT` 以查看服务器上可用的磁盘容量 +> * `netstat` 以查看哪些 TCP 网络连接处于活动状态 + +**2、如何使进程在后台运行,这样做的好处是什么?** + +> 你可以通过在命令末尾添加特殊字符 `&` 来使进程在后台运行。通常,执行时间太长并且不需要用户交互的应用程序可以放到后台,以便我们可以在终端中继续工作。([引文][2]) + +**3、以 root 用户身份运行这些命令是好事还是坏事?** + +> 由于两个主要问题,以 root 身份运行(任何命令)是不好的。第一个是*风险*。当你以 **root** 身份登录时,无法避免你由于粗心大意而犯错。如果你尝试以带有潜在危害的方式更改系统,则需要使用 `sudo`,它会引入一个暂停(在你输入密码时),以确保你不会犯错。 +> +> 第二个原因是*安全*。如果你不知道管理员用户的登录信息,则系统更难被攻击。拥有 root 的访问权限意味着你已经能够进行管理员身份下的一半工作任务。 + +**4、`rm` 和 `rm -rf` 有什么区别?** + +> `rm` 命令本身仅删除指明的文件(而不删除目录)。使用 `-rf` 标志,你添加了两个附加功能:`-r`(或等价的 `-R`、`--recursive`)标志可以递归删除目录的内容,包括隐藏的文件和子目录;而 `-f`(或 `--force`)标志使 `rm` 忽略不存在的文件,并且从不提示你进行确认。 + +**5、有一个大小约为 15GB 的 `Compress.tgz` 文件。你如何列出其内容,以及如何仅提取出特定文件?** + +> 要列出文件的内容: +> +> `tar tf archive.tgz` +> +> 要提取特定文件: +> +> `tar xf archive.tgz filename` + +### 有点难度的问题 + +这是你可能会遇到的一些较难的问题,以及我的答案: + +**6、什么是 RAID?什么是 RAID 0、RAID 1、RAID 5、RAID 6 和 RAID 10?** + +> RAID(廉价磁盘冗余阵列Redundant Array of Inexpensive Disks)是一种用于提高数据存储性能和/或可靠性的技术。RAID 级别为: +> +> * RAID 0:也称为磁盘条带化,这是一种分解文件并将数据分布在 RAID 组中所有磁盘驱动器上的技术。它没有防止磁盘失败的保障。([引文][3]) +> * RAID 1:一种流行的磁盘子系统,通过在两个驱动器上写入相同的数据来提高安全性。RAID 1 被称为*镜像*,它不会提高写入性能,但读取性能可能会提高到每个磁盘性能的总和。另外,如果一个驱动器发生故障,则会使用第二个驱动器,发生故障的驱动器需要手动更换。更换后,RAID 控制器会将可工作的驱动器的内容复制到新驱动器上。 +> * RAID 5:一种磁盘子系统,可通过计算奇偶校验数据来提高安全性和提高速度。RAID 5 通过跨三个或更多驱动器交错数据(条带化)来实现此目的。在单个驱动器发生故障时,后续读取可以从分布式奇偶校验计算出,从而不会丢失任何数据。 +> * RAID 6:通过添加另一个奇偶校验块来扩展 RAID 5。此级别至少需要四个磁盘,并且可以在任何两个并发磁盘故障的情况下继续执行读/写操作。RAID 6 不会对读取操作造成性能损失,但由于与奇偶校验计算相关的开销,因此确实会对写入操作造成性能损失。 +> * RAID 10:RAID 10 也称为 RAID 1 + 0,它结合了磁盘镜像和磁盘条带化功能来保护数据。它至少需要四个磁盘,并且跨镜像对对数据进行条带化。只要每个镜像对中的一个磁盘起作用,就可以检索数据。如果同一镜像对中的两个磁盘发生故障,则所有数据将丢失,因为带区集中没有奇偶校验。([引文][4]) + +**7、`ping` 命令使用哪个端口?** + +> `ping` 命令使用 ICMP。具体来说,它使用 ICMP 回显请求和应答包。 +> +> ICMP 不使用 UDP 或 TCP 通信服务:相反,它使用原始的 IP 通信服务。这意味着,ICMP 消息直接承载在 IP 数据报数据字段中。 + +**8、路由器和网关之间有什么区别?什么是默认网关?** + +> *路由器*描述的是一种通用技术功能(第 3 层转发)或用于该目的的硬件设备,而*网关*描述的是本地网段的功能(提供到其他地方的连接性)。你还可以说“将路由器设置为网关”。另一个术语是“跳”,它描述了子网之间的转发。 +> +> 术语*默认网关*表示局域网上的路由器,它的责任是作为对局域网外部的计算机通信的第一个联系点。 + +**9、解释一下 Linux 的引导过程。** + +> BIOS -> 主引导记录(MBR) -> GRUB -> 内核 -> 初始化 -> 运行级 + +**10、服务器启动时如何检查错误消息?** + +> 内核消息始终存储在 kmsg 缓冲区中,可通过 `dmesg` 命令查看。 +> +> 引导出现的问题和错误要求系统管理员结合某些特定命令来查看某些重要文件,这些文件不同版本的 Linux 处理方式不同: +> +> * `/var/log/boot.log` 是系统引导日志,其中包含系统引导过程中展开的所有内容。 +> * `/var/log/messages` 存储全局系统消息,包括系统引导期间记录的消息。 +> * `/var/log/dmesg` 包含内核环形缓冲区信息。 + +**11、符号链接和硬链接有什么区别?** + +> *符号链接*(*软链接*)实际是到原始文件的链接,而*硬链接*是原始文件的镜像副本。如果删除原始文件,则该软链接就没有用了,因为它指向的文件不存在了。如果是硬链接,则完全相反。如果删除原始文件,则硬链接仍然包含原始文件中的数据。([引文][5]) + +**12、如何更改内核参数?你可能需要调整哪些内核选项?** + +> 要在类 Unix 系统中设置内核参数,请首先编辑文件 `/etc/sysctl.conf`。进行更改后,保存文件并运行 `sysctl -p` 命令。此命令使更改永久生效,而无需重新启动计算机 + +**13、解释一下 `/proc` 文件系统。** + +> `/proc` 文件系统是虚拟的,并提供有关内核、硬件和正在运行的进程的详细信息。由于 `/proc` 包含虚拟文件,因此称为“虚拟文件系统”。这些虚拟文件具有独特性。其中大多数显示为零字节。 +> +> 虚拟文件,例如 `/proc/interrupts`、`/proc/meminfo`、`/proc/mounts` 和 `/proc/partitions`,提供了系统硬件的最新信息。其他诸如 `/proc/filesystems` 和 `/proc/sys` 目录提供系统配置信息和接口。 + +**14、如何在没有密码的情况下以其他用户身份运行脚本?** + +> 例如,如果你可以编辑 sudoers 文件(例如 `/private/etc/sudoers`),则可以使用 `visudo` 添加以下[内容][2]: +> +> `user1 ALL =(user2)NOPASSWD:/opt/scripts/bin/generate.sh` + +**15、什么是 UID 0 toor 帐户?是被入侵了么?** + +> `toor` 用户是备用的超级用户帐户,其中 `toor` 是 `root` 反向拼写。它预期与非标准 shell 一起使用,因此 `root` 的默认 shell 不需要更改。 +> +> 此用途很重要。这些 shell 不是基本发行版的一部分,而是从 ports 或软件包安装的,它们安装在 `/usr/local/bin` 中,默认情况下,位于其他文件系统上。如果 root 的 shell 位于 `/usr/local/bin` 中,并且未挂载包含 `/usr/local/bin` 的文件系统,则 root 无法登录以解决问题,并且系统管理员必须重新启动进入单用户模式来输入 shell 程序的路径。 + +### 更难的问题 + +这是你可能会遇到的甚至更困难的问题: + +**16、`tracert` 如何工作,使用什么协议?** + +> 命令 `tracert`(或 `traceroute`,具体取决于操作系统)使你可以准确地看到在连接到最终目的地的连接链条中所触及的路由器。如果你遇到无法连接或无法 `ping` 通最终目的地的问题,则可以使用 `tracert` 来帮助你确定连接链在何处停止。([引文][6]) +> +> 通过此信息,你可以联系正确的人;无论是你自己的防火墙、ISP、目的地的 ISP 还是中间的某个位置。 `tracert` 命令像 `ping` 一样使用 ICMP 协议,但也可以使用 TCP 三步握手的第一步来发送 SYN 请求以进行响应。 + +**17、使用 `chroot` 的主要优点是什么?我们何时以及为什么使用它?在 chroot 环境中,`mount /dev`、`mount /proc` 和 `mount /sys` 命令的作用是什么?** + +> chroot 环境的优点是文件系统与物理主机是隔离的,因为 chroot 在文件系统内部有一个单独的文件系统。区别在于 `chroot` 使用新创建的根目录(`/`)作为其根目录。 +> +> chroot 监狱可让你将进程及其子进程与系统其余部分隔离。它仅应用于不以 root 身份运行的进程,因为 root 用户可以轻松地脱离监狱。 +> +> 该思路是创建一个目录树,在其中复制或链接运行该进程所需的所有系统文件。然后,你可以使用 `chroot()` 系统调用来告诉它根目录现在位于此新树的基点上,然后启动在该 chroot 环境中运行的进程。由于该命令因此而无法引用修改后的根目录之外的路径,因此它无法在这些位置上执行恶意操作(读取、写入等)。([引文][7]) + +**18、如何保护你的系统免遭黑客攻击?** + +> 遵循最低特权原则和这些做法: +> +> * 使用公钥加密,它可提供出色的安全性。 +> * 增强密码复杂性。 +> * 了解为什么要对上述规则设置例外。 +> * 定期检查你的例外情况。 +> * 让具体的人对失败负责。(它使你保持警惕。)([引文][8]) + +**19、什么是 LVM,使用 LVM 有什么好处?** + +> LVM(逻辑卷管理)是一种存储设备管理技术,该技术使用户能够合并和抽象化组件存储设备的物理布局,从而可以更轻松、灵活地进行管理。使用设备映射器的 Linux 内核框架,当前迭代(LVM2)可用于将现有存储设备收集到组中,并根据需要从组合的空间分配逻辑单元。 + +**20、什么是粘性端口?** + +> 粘性端口是网络管理员最好的朋友,也是最头痛的事情之一。它们允许你设置网络,以便通过将交换机上的每个端口锁定到特定的 MAC 地址,仅允许一台(或你指定的数字)计算机在该端口上进行连接。 + +**21、解释一下端口转发?** + +> 尝试与安全的网络内部的系统进行通信时,从外部进行通信可能非常困难,这是很显然的。因此,在路由器本身或其他连接管理设备中使用端口转发表可以使特定流量自动转发到特定目的地。例如,如果你的网络上运行着一台 Web 服务器,并且想从外部授予对该服务器的访问权限,则可以将端口转发设置为该服务器上的端口 80。这意味着在 Web 浏览器中输入你的(外网)IP 地址的任何人都将立即连接到该服务器的网站。 +> +> 请注意,通常不建议允许从你的网络外部直接访问服务器。 + +**22、对于 IDS,误报和漏报是什么?** + +> 当入侵检测系统(IDS)设备为实际上没有发生的入侵生成警报时,这是误报(假阳性)false positive。如果设备未生成任何警报,而入侵实际上已发生,则为漏报(假阴性)。 + +**23、解释一下 `:(){ :|:& };:`,如果已经登录系统,如何停止此代码?** + +> 这是一枚复刻炸弹。它分解如下: +> +> * `:()` 定义了函数,以 `:` 作为函数名,并且空括号表示它不接受任何参数。 +> * `{}` 是函数定义的开始和结束。 +> * `:|:` 将函数 `:` 的副本加载到内存中,并将其输出通过管道传递给函数 `:` 的另一个副本,该副本也必须加载到内存中。 +> * `&` 使前一个命令行成为后台进程,因此即使父进程被自动杀死,子进程也不会被杀死。 +> * `:` 执行该函数,因此连锁反应开始。 +> +> 保护多用户系统的最佳方法是使用特权访问管理(PAM)来限制用户可以使用的进程数。 +> +> 复刻炸弹的最大问题是它发起了太多进程。因此,如果你已经登录系统,我们有两种尝试解决此问题的方法。一种选择是执行一个 `SIGSTOP` 命令来停止进程,例如: +> +> `killall -STOP -u user1` +> +> 如果由于占用了所有进程而无法使用命令行,则必须使用 `exec` 强制其运行: +> +> `exec killall -STOP -u user1` +> +> 对于复刻炸弹,最好的选择是防患于未然。 + +**24、什么是 OOM 杀手,它如何决定首先杀死哪个进程?** + +> 如果内存被进程彻底耗尽,可能会威胁到系统的稳定性,那么内存不足out of memory(OOM)杀手就登场了。 +> +> OOM 杀手首先必须选择要杀死的最佳进程。*最佳*在这里指的是在被杀死时将释放最大内存的进程,并且对系统来说最不重要。主要目标是杀死最少数量的进程,以最大程度地减少造成的损害,同时最大化释放的内存量。 +> +> 为了实现此目标,内核为每个进程维护一个 `oom_score`。你可以在 `/proc` 文件系统中的 `pid` 目录下的看到每个进程的 `oom_score`: +> +> `$ cat /proc/10292/oom_score` +> +> 任何进程的 `oom_score` 值越高,在内存不足的情况下被 OOM 杀手杀死的可能性就越高。([引文][9]) + +### 总结 + +系统管理人员的薪水[差别很大][10],有些网站上说年薪在 70,000 到 100,000 美元之间,具体取决于地点、组织的规模以及你的教育水平以及多年的工作经验。系统管理的职业道路最终归结为你对使用服务器和解决那些酷问题的兴趣。现在,我要说,继续前进,实现你的梦想之路吧! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/sysadmin-job-interview-questions + +作者:[DirectedSoul][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/directedsoul +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_HowToFish_520x292.png?itok=DHbdxv6H (Question and answer.) +[2]: https://github.com/trimstray/test-your-sysadmin-skills +[3]: https://www.waytoeasylearn.com/2016/05/netapp-filer-tutorial.html +[4]: https://searchstorage.techtarget.com/definition/RAID-10-redundant-array-of-independent-disks +[5]: https://www.answers.com/Q/What_is_hard_link_and_soft_link_in_Linux +[6]: https://www.wisdomjobs.com/e-university/network-administrator-interview-questions.html +[7]: https://unix.stackexchange.com/questions/105/chroot-jail-what-is-it-and-how-do-i-use-it +[8]: https://serverfault.com/questions/391370/how-to-prevent-zero-day-attacks +[9]: https://unix.stackexchange.com/a/153586/8369 +[10]: https://blog.netwrix.com/2018/07/23/systems-administrator-salary-in-2018-how-much-can-you-earn/ diff --git a/published/20190827 curl exercises.md b/published/20190827 curl exercises.md new file mode 100644 index 0000000000..35984c6e31 --- /dev/null +++ b/published/20190827 curl exercises.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (hanwckf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11648-1.html) +[#]: subject: (curl exercises) +[#]: via: (https://jvns.ca/blog/2019/08/27/curl-exercises/) +[#]: author: (Julia Evans https://jvns.ca/) + +21 个 curl 命令练习 +====== + +最近,我对人们如何学习新事物感兴趣。我正在读 Kathy Sierra 的好书《[Badass: Making Users Awesome][1]》,它探讨了有关“刻意练习”的想法。这个想法是,你找到一个可以用三节 45 分钟课程内能够学会的小技能,并专注于学习这项小技能。因此,作为一项练习,我尝试考虑一项能够在三节 45 分钟课程内学会的计算机技能。 + +我认为使用 `curl` 构造 HTTP 请求也许就是这样的一项技能,所以这里有一些 `curl` 练习作为实验! + +### 什么是 curl ? + +`curl` 是用于构造 HTTP 请求的命令行工具。我喜欢使用 `curl`,因为它能够很轻松地测试服务器或 API 的行为是否符合预期,但是刚开始接触它的时候会让你感到一些困惑! + +下面是一幅解释 `curl` 常用命令行参数的漫画 (在我的 [Bite Size Networking][2] 杂志的第 6 页)。 + +![](https://jvns.ca/images/curl.jpeg) + +### 熟能生巧 + +对于任何命令行工具,我认为熟练使用是很有帮助的,能够做到只输入必要的命令真是太好了。例如,最近我在测试 Gumroad API,我只需要输入: + +``` +curl https://api.gumroad.com/v2/sales \ + -d "access_token=" \ + -X GET -d "before=2016-09-03" +``` + +就能从命令行中得到想要的结果。 + +### 21 个 curl 练习 + +这些练习是用来理解如何使用 `curl` 构造不同种类的 HTTP 请求的,它们是故意有点重复的,基本上包含了我需要 `curl` 做的任何事情。 + +为了简单起见,我们将对 https://httpbin.org 发起一系列 HTTP 请求,httpbin 接受 HTTP 请求,然后在响应中回显你所发起的 HTTP 请求。 + + 1. 请求 + 2. 请求 ,它将会解析你发起的请求,并且在响应中回显。`curl` 默认发起的是 GET 请求 + 3. 向 发起 GET 请求 + 4. 向 发起 GET 请求,但是这次需要添加一些查询参数(设置 `value=panda`) + 5. 请求 Google 的 `robots.txt` 文件 ([www.google.com/robots.txt][3]) + 6. 向 发起 GET 请求,并且设置请求头为 `User-Agent: elephant` + 7. 向 发起 DELETE 请求 + 8. 请求 并获取响应头信息 + 9. 向 发起请求体为 JSON `{"value": "panda"}` 的 POST 请求 + 10. 发起与上一次相同的 POST 请求,但是这次要把请求头中的 `Content-Type` 字段设置成 `application/json`(因为 POST 请求需要一个与请求体相匹配的 `Content-Type` 请求头字段)。查看响应体中的 `json` 字段,对比上一次得到的响应体 + 11. 向 发起 GET 请求,并且在请求头中设置 `Accept-Encoding: gzip`(将会发生什么?为什么会这样?) + 12. 将一些 JSON 放在文件中,然后向 发起请求体为该文件的 POST 请求 + 13. 设置请求头为 `Accept: image/png` 并且向 发起请求,将输出保存为 PNG 文件,然后使用图片浏览器打开。尝试使用不同的 `Accept:` 字段去请求此 URL + 14. 向 发起 PUT 请求 + 15. 请求 并保存为文件,然后使用你的图片编辑器打开这个文件 + 16. 请求 ,你将会得到空的响应。让 `curl` 显示出响应头信息,并尝试找出响应内容为空的原因 + 17. 向 发起任意的请求,同时设置一些无意义的请求头(例如:`panda: elephant`) + 18. 请求 ,然后再次请求它们并且让 curl 显示响应头信息 + 19. 请求 并且设置用户名和密码(使用 `-u username:password`) + 20. 设置 `Accept-Language: es-ES` 的请求头用以下载 Twitter 的西班牙语主页 () + 21. 使用 `curl` 向 Stripe API 发起请求(请查看 了解如何使用,他们会给你一个测试用的 API key)。尝试向 发起相同的请求 + + + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/08/27/curl-exercises/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[hanwckf](https://github.com/hanwckf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://www.amazon.com/Badass-Making-Awesome-Kathy-Sierra/dp/1491919019 +[2]: https://wizardzines.com/zines/bite-size-networking +[3]: http://www.google.com/robots.txt diff --git a/published/20190927 5 tips for GNU Debugger.md b/published/20190927 5 tips for GNU Debugger.md new file mode 100644 index 0000000000..9bb6329a4b --- /dev/null +++ b/published/20190927 5 tips for GNU Debugger.md @@ -0,0 +1,220 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11647-1.html) +[#]: subject: (5 tips for GNU Debugger) +[#]: via: (https://opensource.com/article/19/9/tips-gnu-debugger) +[#]: author: (Tim Waugh https://opensource.com/users/twaugh) + +5 个鲜为人知 GNU 调试器(GDB)技巧 +====== + +> 了解如何使用 gdb 的一些鲜为人知的功能来检查和修复代码。 + +![](https://img.linux.net.cn/data/attachment/album/201912/05/203701ss8onfvpsnvnsnn5.jpg) + +[GNU 调试器][2](`gdb`)是一种宝贵的工具,可用于在开发程序时检查正在运行的进程并解决问题。 + +你可以在特定位置(按函数名称、行号等)设置断点、启用和禁用这些断点、显示和更改变量值,并执行所有调试器希望执行的所有标准操作。但是它还有许多其它你可能没有尝试过的功能。这里有五个你可以尝试一下。 + +### 条件断点 + +设置断点是学习使用 GNU 调试器的第一步。程序在达到断点时停止,你可以运行 `gdb` 的命令对其进行检查或更改变量,然后再允许该程序继续运行。 + +例如,你可能知道一个经常调用的函数有时会崩溃,但仅当它获得某个参数值时才会崩溃。你可以在该函数的开始处设置一个断点并运行程序。每次碰到该断点时都会显示函数参数,并且如果未提供触发崩溃的参数值,则可以继续操作,直到再次调用该函数为止。当这个惹了麻烦的参数触发崩溃时,你可以单步执行代码以查看问题所在。 + + +``` +(gdb) break sometimes_crashes +Breakpoint 1 at 0x40110e: file prog.c, line 5. +(gdb) run +[...] +Breakpoint 1, sometimes_crashes (f=0x7fffffffd1bc) at prog.c:5 +5 fprintf(stderr, +(gdb) continue +Breakpoint 1, sometimes_crashes (f=0x7fffffffd1bc) at prog.c:5 +5 fprintf(stderr, +(gdb) continue +``` + +为了使此方法更具可重复性,你可以在你感兴趣的特定调用之前计算该函数被调用的次数,并在该断点处设置一个计数器(例如,`continue 30` 以使其在接下来的 29 次到达该断点时忽略它)。 + +但是断点真正强大的地方在于它们在运行时评估表达式的能力,这使你可以自动化这种测试。 + +``` +break [LOCATION] if CONDITION + +(gdb) break sometimes_crashes if !f +Breakpoint 1 at 0x401132: file prog.c, line 5. +(gdb) run +[...] +Breakpoint 1, sometimes_crashes (f=0x0) at prog.c:5 +5 fprintf(stderr, +(gdb) +``` + +条件断点使你不必让 `gdb` 每次调用该函数时都去问你要做什么,而是让条件断点仅在特定表达式的值为 `true` 时才使 `gdb` 停止在该位置。如果执行到达条件断点的位置,但表达式的计算结果为 `false`,调试器会自动使程序继续运行,而无需询问用户该怎么做。 + +### 断点命令 + +GNU 调试器中断点的一个甚至更复杂的功能是能够编写对到达断点的响应的脚本。断点命令使你可以编写一系列 GNU 调试器命令,以在到达该断点时运行。 + +我们可以使用它来规避在 `sometimes_crashes` 函数中我们已知的错误,并在它提供空指针时使其无害地从该函数返回。 + +我们可以使用 `silent` 作为第一行,以更好地控制输出。否则,每次命中断点时,即使在运行断点命令之前,也会显示堆栈帧。 + +``` +(gdb) break sometimes_crashes +Breakpoint 1 at 0x401132: file prog.c, line 5. +(gdb) commands 1 +Type commands for breakpoint(s) 1, one per line. +End with a line saying just "end". +>silent +>if !f + >frame + >printf "Skipping call\n" + >return 0 + >continue + >end +>printf "Continuing\n" +>continue +>end +(gdb) run +Starting program: /home/twaugh/Documents/GDB/prog +warning: Loadable section ".note.gnu.property" outside of ELF segments +Continuing +Continuing +Continuing +#0 sometimes_crashes (f=0x0) at prog.c:5 +5 fprintf(stderr, +Skipping call +[Inferior 1 (process 9373) exited normally] +(gdb) +``` + +### 转储二进制内存 + +GNU 调试器内置支持使用 `x` 命令以各种格式检查内存,包括八进制、十六进制等。但是我喜欢并排看到两种格式:左侧为十六进制字节,右侧为相同字节表示的 ASCII 字符。 + +当我想逐字节查看文件的内容时,经常使用 `hexdump -C`(`hexdump` 来自 [util-linux][3] 软件包)。这是 `gdb` 的 `x` 命令显示的十六进制字节: + +``` +(gdb) x/33xb mydata +0x404040 : 0x02 0x01 0x00 0x02 0x00 0x00 0x00 0x01 +0x404048 : 0x01 0x47 0x00 0x12 0x61 0x74 0x74 0x72 +0x404050 : 0x69 0x62 0x75 0x74 0x65 0x73 0x2d 0x63 +0x404058 : 0x68 0x61 0x72 0x73 0x65 0x75 0x00 0x05 +0x404060 : 0x00 +``` + +如果你想让 `gdb` 像 `hexdump` 一样显示内存怎么办?这是可以的,实际上,你可以将这种方法用于你喜欢的任何格式。 + +通过使用 `dump` 命令以将字节存储在文件中,结合 `shell` 命令以在文件上运行 `hexdump` 以及`define` 命令,我们可以创建自己的新的 `hexdump` 命令来使用 `hexdump` 显示内存内容。 + +``` +(gdb) define hexdump +Type commands for definition of "hexdump". +End with a line saying just "end". +>dump binary memory /tmp/dump.bin $arg0 $arg0+$arg1 +>shell hexdump -C /tmp/dump.bin +>end +``` + +这些命令甚至可以放在 `~/.gdbinit` 文件中,以永久定义 `hexdump` 命令。以下是它运行的例子: + +``` +(gdb) hexdump mydata sizeof(mydata) +00000000 02 01 00 02 00 00 00 01 01 47 00 12 61 74 74 72 |.........G..attr| +00000010 69 62 75 74 65 73 2d 63 68 61 72 73 65 75 00 05 |ibutes-charseu..| +00000020 00 |.| +00000021 +``` + +### 行内反汇编 + +有时你想更多地了解导致崩溃的原因,而源代码还不够。你想查看在 CPU 指令级别发生了什么。 + +`disassemble` 命令可让你查看实现函数的 CPU 指令。但是有时输出可能很难跟踪。通常,我想查看与该函数源代码的特定部分相对应的指令。为此,请使用 `/s` 修饰符在反汇编中包括源代码行。 + +``` +(gdb) disassemble/s main +Dump of assembler code for function main: +prog.c: +11 { + 0x0000000000401158 <+0>: push %rbp + 0x0000000000401159 <+1>: mov %rsp,%rbp + 0x000000000040115c <+4>: sub $0x10,%rsp + +12 int n = 0; + 0x0000000000401160 <+8>: movl $0x0,-0x4(%rbp) + +13 sometimes_crashes(&n); + 0x0000000000401167 <+15>: lea -0x4(%rbp),%rax + 0x000000000040116b <+19>: mov %rax,%rdi + 0x000000000040116e <+22>: callq 0x401126 +[...snipped...] +``` + +这里,用 `info` 寄存器查看所有 CPU 寄存器的当前值,以及用如 `stepi` 这样命令一次执行一条指令,可以使你对程序有了更详细的了解。 + +### 反向调试 + +有时,你希望自己可以逆转时间。想象一下,你已经达到了变量的监视点。监视点像是一个断点,但不是在程序中的某个位置设置,而是在表达式上设置(使用 `watch` 命令)。每当表达式的值更改时,执行就会停止,并且调试器将获得控制权。 + +想象一下你已经达到了这个监视点,并且由该变量使用的内存已更改了值。事实证明,这可能是由更早发生的事情引起的。例如,内存已释放,现在正在重新使用。但是它是何时何地被释放的呢? + +GNU 调试器甚至可以解决此问题,因为你可以反向运行程序! + +它通过在每个步骤中仔细记录程序的状态来实现此目的,以便可以恢复以前记录的状态,从而产生时间倒流的错觉。 + +要启用此状态记录,请使用 `target record-full` 命令。然后,你可以使用一些听起来不太可行的命令,例如: + +* `reverse-step`,倒退到上一个源代码行 +* `*reverse-next`,它倒退到上一个源代码行,向后跳过函数调用 +* `reverse-finish`,倒退到当前函数即将被调用的时刻 +* `reverse-continue`,它返回到程序中的先前状态,该状态将(现在)触发断点(或其他导致断点停止的状态) + +这是运行中的反向调试的示例: + +``` +(gdb) b main +Breakpoint 1 at 0x401160: file prog.c, line 12. +(gdb) r +Starting program: /home/twaugh/Documents/GDB/prog +[...] + +Breakpoint 1, main () at prog.c:12 +12 int n = 0; +(gdb) target record-full +(gdb) c +Continuing. + +Program received signal SIGSEGV, Segmentation fault. +0x0000000000401154 in sometimes_crashes (f=0x0) at prog.c:7 +7 return *f; +(gdb) reverse-finish +Run back to call of #0 0x0000000000401154 in sometimes_crashes (f=0x0) + at prog.c:7 +0x0000000000401190 in main () at prog.c:16 +16 sometimes_crashes(0); +``` + +这些只是 GNU 调试器可以做的一些有用的事情。还有更多有待发现。你最喜欢 `gdb` 的哪个隐藏的、鲜为人知或令人吃惊的功能?请在评论中分享。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/9/tips-gnu-debugger + +作者:[Tim Waugh][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/twaugh +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bug_software_issue_tracking_computer_screen.jpg?itok=6qfIHR5y (Bug tracking magnifying glass on computer screen) +[2]: https://www.gnu.org/software/gdb/ +[3]: https://en.wikipedia.org/wiki/Util-linux diff --git a/published/20191004 What-s in an open source name.md b/published/20191004 What-s in an open source name.md new file mode 100644 index 0000000000..2b6d45c599 --- /dev/null +++ b/published/20191004 What-s in an open source name.md @@ -0,0 +1,200 @@ +[#]: collector: (lujun9972) +[#]: translator: (laingke) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11688-1.html) +[#]: subject: (What's in an open source name?) +[#]: via: (https://opensource.com/article/19/10/open-source-name-origins) +[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja) + +开源软件名称中的故事 +====== + +> 有没有想过你喜欢的开源项目或编程语言的名称来自何处?让我们按字母顺序了解一下流行的技术术语背后的起源故事。 + +![](https://img.linux.net.cn/data/attachment/album/201912/17/225902ogkk85zm4gqlim9h.jpg) + +GNOME、Java、Jupyter、Python……如果你的朋友或家人曾留意过你的工作对话,他们可能会认为你从事文艺复兴时期的民间文学艺术、咖啡烘焙、天文学或动物学工作。这些开源技术的名称从何而来?我们请我们的作者社区提供意见,并汇总了一些我们最喜欢的技术名称的起源故事。 + +### Ansible + +“Ansible”这个名称直接来自科幻小说。Ursula Le Guin 的《Rocannon's World》一书中能进行即时(比光速更快)通信的设备被称为 ansibles(显然来自 “answerable” 一词)。Ansibles 开始流行于科幻小说之中,Orson Scott Card 的《Ender's Game》(后来成为受欢迎的电影)中,该设备控制了许多远程太空飞船。对于控制分布式机器的软件来说,这似乎是一个很好的模型,因此 Michael DeHaan(Ansible 的创建者和创始人)借用了这个名称。 + +### Apache + +[Apache][2] 是最初于 1995 年发布的开源 Web 服务器。它的名称与著名的美国原住民部落无关;相反,它是指对原始软件代码的重复补丁。因此称之为,“一个修补的A-patchy服务器”。 + +### awk + +“awk(1) 代表着 Aho、Weinberger、Kernighan(作者)”—— Michael Greenberg + +### Bash + +“最初的 Unix shell,即 Bourne shell,是以其创造者的名字命名的。在开发出来 Bash 时,csh(发音为 ‘seashell’)实际上更受交互登录用户的欢迎。Bash 项目旨在赋予 Bourne shell 新的生命,使其更适合于交互式使用,因此它被命名为 ‘Bourne again shell’,是‘重生born again’的双关语。”——Ken Gaillot + +### C + +在早期,AT&T 的 Ken Thompson 和 Dennis Ritchie 发现可以使用更高级的编程语言(而不是低级的、可移植性更低的汇编编程)来编写操作系统和工具。早期有一个叫做 BCPL(基本组合编程语言Basic Combined programming Language)的编程系统,Thompson 创建了一个名为 B 的简化版 BCPL,但 B 的灵活性和速度都不高。然后,Ritchie 把 B 的思想扩展成一种叫做 C 的编译语言。”——Jim Hall + +### dd + +“我想你发表这样一篇文章不能不提到 dd。我的外号叫 Didi。发音正确的话听起来像 ‘dd’。我开始学的是 Unix,然后是 Linux,那是在 1993 年,当时我还是个学生。然后我去了军队,来到了我的部队中少数几个使用 Unix(Ultrix)的部门之一(其它部门主要是 VMS),那里的一个人说:‘这么说,你是一个黑客,对吗?你以为你了解 Unix 吗?好的,那么 dd 这个名字的是怎么来的呢?’我不知道,试着猜道:‘数据复印机Data duplicator?’所以他说,‘我要告诉你 dd 的故事。dd 是转换convert复制copy的缩写(如今人们仍然可以在手册页中看到),但由于 cc 这个缩写已经被 C 编译器占用,所以它被命名为 dd。’就在几年后,我听闻了关于 JCL 的数据定义和 Unix dd 命令不统一的、半开玩笑的语法的真实故事,某种程度是基于此的。”——Yedidyah Bar David + +### Emacs + +经典的反 vianti-vi编辑器,其名称的真正词源并不明显,因为它源自“编辑宏Editing MACroS”。但是,它作为一个伟大的宗教亵渎和崇拜的对象,吸引了许多恶作剧般的缩写,例如“Escape Meta Alt Control Shift”(以调侃其对键盘的大量依赖),“8MB 并经常发生内存交换Eight Megabytes And Constantly Swapping”(从那时起就很吃内存了),“最终分配了所有的计算机存储空间Eventually malloc()s All Computer Storage”和 “EMACS 使一台计算机慢EMACS Makes A Computer Slow”——改编自 Jargon File/Hacker's Dictionary + +### Enarx + +[Enarx][3] 是机密计算领域的一个新项目。该项目的设计原则之一是它应该是“可替代的”。因此最初的名字是“psilocybin”(著名的魔术蘑菇)。一般情况下,经理级别的人可能会对这个名称有所抵触,因此考虑使用新名称。该项目的两位创始人 Mike Bursell 和 Nathaniel McCallum 都是古老语言极客,因此他们考虑了许多不同的想法,包括 тайна(Tayna——俄语中代表秘密或神秘——虽然俄语并不是一门古老的语言,但你就不要在乎这些细节了),crypticon(希腊语的意思是完全私生的),cryptidion(希腊中表示小密室),arconus(拉丁语中表示秘密的褒义形容词),arcanum(拉丁语中表示秘密的中性形容词)和 ærn(盎格鲁撒克逊人表示地方、秘密的地方、壁橱、住所、房子,或小屋的词汇)。最后,由于各种原因,包括域名和 GitHub 项目名称的可用性,他们选择了 enarx,这是两个拉丁词根的组合:en-(表示内部)和 -arx(表示城堡、要塞或堡垒)。 + +### GIMP + +没有 [GIMP][4] 我们会怎么样?GNU 图像处理项目GNU Image Manipulation Project多年来一直是开源的重要基础。[维基百科][5]指出,“1995 年,[Spencer Kimball][6] 和 [Peter Mattis][7] 在加州大学伯克利分校开始为实验计算设施eXperimental Computing Facility开发 GIMP,这是一个为期一个学期的项目。” + +### GNOME + +你有没有想过为什么 GNOME 被称为 GNOME?根据[维基百科][8],GNOME 最初是一个表示“GNU 网络对象模型环境GNU Network Object Model Environment”的缩写词。现在,该名称不再表示该项目,并且该项目已被放弃,但这个名称仍然保留了下来。[GNOME 3][9] 是 Fedora、红帽企业版、Ubuntu、Debian、SUSE Linux 企业版等发行版的默认桌面环境。 + +### Java + +你能想象这种编程语言还有其它名称吗?Java 最初被称为 Oak,但是遗憾的是,Sun Microsystems 的法律团队由于已有该商标而否决了它。所以开发团队又重新给它命名。[据说][10]该语言的工作组在 1995 年 1 月举行了一次大规模的头脑风暴。许多其它名称也被扔掉了,包括 Silk、DNA、WebDancer 等。该团队不希望新名称与过度使用的术语“web”或“net”有任何关系。取而代之的是,他们在寻找更有活力、更有趣、更容易记住的东西。Java 满足了这些要求,并且奇迹般地,团队同意通过了! + +### Jupyter + +现在许多数据科学家和学生在工作中使用 [Jupyter][11] 笔记本。“Jupyter”这个名字是三种开源计算机语言的融合,这三种语言在这个笔记本中都有使用,在数据科学中也很突出:[Julia][12]、[Python][13] 和 [R][14]。 + +### Kubernetes + +Kubernetes 源自希腊语中的舵手。Kubernetes 项目创始人 Craig McLuckie 在 [2015 Hacker News][15] 回应中证实了这种词源。他坚持航海主题,解释说,这项技术可以驱动集装箱,就像舵手或驾驶员驾驶集装箱船一样,因此,他选择了 Kubernetes 这个名字。我们中的许多人仍然在尝试正确的发音(koo-bur-NET-eez),因此 替代使用 K8s 也是可以接受的。有趣的是,它与英语单词“行政长官governor”具有相同的词源,也与蒸汽机上的机械负反馈装置相同。 + +### KDE + +那 K 桌面呢?KDE 最初代表“酷桌面环境Kool Desktop Environment”。 它由 [Matthias Ettrich][16] 于 1996 年创立。根据[维基百科][17]上的说法,该名称是对 Unix 上 [通用桌面环境][18]Common Desktop Environment(CDE)一词的调侃。 + +### Linux + +[Linux][19] 因其发明者 Linus Torvalds 的名字命名的。Linus 最初想将他的作品命名为“Freax”,因为他认为以他自己的名字命名太自负了。根据[维基百科][19]的说法,“赫尔辛基科技大学 Torvalds 的同事 Ari Lemmke 当时是 FTP 服务器的志愿管理员之一,他并不认为‘Freax’是个好名字。因此,他没有征询 Torvalds 就将服务器上的这个项目命名为‘Linux’。” + +以下是一些最受欢迎的 Linux 发行版。 + +#### CentOS + +[CentOS][20] 是社区企业操作系统Community Enterprise Operating System的缩写。它包含来自 Red Hat Enterprise Linux 的上游软件包。 + +#### Debian + +[Debian][21] Linux 创建于 1993 年 9 月,是其创始人 Ian Murdock 和他当时的女友 Debra Lynn 的名字的混成词。 + +#### RHEL + +[Red Hat Linux][22] 得名于它的创始人 Marc Ewing,他戴着一顶祖父送给他的康奈尔大学红色软呢帽fedora。红帽公司成立于 1993 年 3 月 26 日。[Fedora Linux][23] 最初是一个志愿者项目,旨在为红帽发行版提供额外的软件,它的名字来自红帽的“Shadowman”徽标。 + +#### Ubuntu + +[Ubuntu][24] 旨在广泛分享开源软件,它以非洲哲学“人的本质ubuntu”命名,可以翻译为“对他人的人道主义”或“我之所以是我,是因为我们都是这样的人”。 + +### Moodle + +开源学习平台 [Moodle][25] 是“模块化面向对象动态学习环境modular object-oriented dynamic learning environment”的首字母缩写。Moodle 仍然是领先的线上学习平台。全球有近 10.4 万个注册的 Moodle 网站。 + +另外两个流行的开源内容管理系统是 Drupal 和 Joomla。Drupal 的名字来自荷兰语 “druppel”,意思是“掉落”。根据维基百科,Joomla 是斯瓦希里语单词“jumla”的[英式拼写][26],在阿拉伯语、乌尔都语和其他语言中是“在一起”的意思。 + +### Mozilla + +[Mozilla][27] 是一个成立于 1998 年的开源软件社区。根据其网站,“Mozilla 项目创建于 1998 年,发布了 Netscape 浏览器套件源代码。其旨在利用互联网上成千上万的程序员的创造力,并推动浏览器市场上前所未有的创新水平。” 这个名字是 [Mosaic] [28] 和 Godzilla 的混成词。 + +### Nginx + +“许多技术人员都试图装酷,并将它念成‘n’‘g’‘n’‘x’。实际上,很少的一些人做点基本的调查工作,就可以很快发现该名称实际上应该被念成是“EngineX”,指的是功能强大的 web 服务器,像个引擎。”——Jean Sebastien Tougne + +### Perl + +Perl 的创始人 Larry Wall 最初将他的项目命名为“Pearl”。根据维基百科,Wall 想给这种语言起一个有积极含义的简短名字。在 Perl 正式发布之前,Wall 发现了已有 [PEARL][29] 编程语言,于是更改了名称的拼写。 + +### Piet 和 Mondrian + +“有两种编程语言以艺术家 Piet Mondrian 命名。一种叫做‘Piet’,另一种叫做‘Mondrian’。(David Morgan-Mar [写道][30]):‘Piet 是一种编程语言,其中的程序看起来像抽象绘画。该语言以几何抽象艺术的开创者 Piet Mondrian 的名字命名。我曾想将这种语言命名为 Mondrian,但是有人告诉我这会让它看起来像一种很普通的脚本语言。哦,好吧,我想我们不能都是深奥的语言作家。’”——Yuval Lifshitz + +### Python + +Python 编程语言的独特名称来自其创建者 Guido Van Rossum,他是英国六人喜剧团体 Monty Python 的粉丝。 + +### Raspberry Pi + +Raspberry Pi 以其微小但强大的功能和对低廉的价格而闻名,在开源社区中是最受欢迎的。但是它可爱(和好吃)的名字是从哪里来的呢?在 70 年代和 80 年代,以水果命名的计算机是一种流行的趋势。苹果、橘子、杏……有人饿了吗?根据创始人 Eben Upton 的 [2012 采访] [31],“树莓派Raspberry Pi”这个名称是对这种趋势的致敬。树莓也很小,但却很有味道。名称中的“Pi”暗示着这样的事实:最初,该计算机只能运行 Python。 + +### Samba + +[Server Message Block][32] 用于在 Linux 上共享 Windows 文件。 + +### ScummVM + +[ScummVM][33](《疯狂大楼》虚拟机的脚本创建实用程序)是一个程序,可以在现代计算机上运行一些经典的计算机冒险游戏。最初,它旨在玩用 SCUMM 构建的 LucasArts 的冒险游戏,该游戏最初用于开发《疯狂大楼》,后来又被用来开发 LucasArts 的其它大多数冒险游戏。目前,ScummVM 支持大量游戏引擎,包括 Sierra Online 的 AGI 和 SCI,但仍保留着名称 ScummVM。 + +有一个相关的项目 [ResidualVM][34] 之所以得名,是因为它涵盖了 ScummVM 未涵盖的“剩余的residual” LucasArts 冒险游戏。 ResidualVM 涵盖的 LucasArts 游戏是使用 GrimE(Grim Engine)开发的,该引擎最初用于开发 Grim Fandango,因此 ResidualVM 的名称是双关语。 + +### SQL + +“你可能知道 SQL 代表结构化查询语言Structured Query Language,但你知道为什么它经常被读作‘sequel’吗?它是作为原本的‘QUEL’(查询语言QUEry Language)的后续(如结局sequel)而创建的。”——Ken Gaillot + +### XFCE + +[XFCE][35] 是由 [Olivier Fourdan][36] 创建的一个流行的桌面。它在 1996 年作为 CDE 的替代品出现,最初是 XForms 公共环境XForms Common Environment的缩写。 + +### Zsh + +Zsh 是一个交互式登录 shell。1990 年,普林斯顿大学的学生 Paul Falstad 写了该 shell 的第一个版本。他在看到当时在普林斯顿大学担任助教的 Zhong Sha 的登录 ID(zsh)后,觉得这个名字听起来像 [shell 的好名字][37],给它起了这个名字。 + +还有更多的项目和名称还没有包括在这个列表中。请一定要在评论中分享你的收藏。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/open-source-name-origins + +作者:[Joshua Allen Holm][a] +选题:[lujun9972][b] +译者:[laingke](https://github.com/laingke) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/holmja +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003784_02_os.comcareers_resume_rh1x.png?itok=S3HGxi6E (A person writing.) +[2]: https://httpd.apache.org/ +[3]: https://enarx.io +[4]: https://www.gimp.org/ +[5]: https://en.wikipedia.org/wiki/GIMP +[6]: https://en.wikipedia.org/wiki/Spencer_Kimball_(computer_programmer) +[7]: https://en.wikipedia.org/wiki/Peter_Mattis +[8]: https://en.wikipedia.org/wiki/GNOME +[9]: https://www.gnome.org/gnome-3/ +[10]: https://www.javaworld.com/article/2077265/so-why-did-they-decide-to-call-it-java-.html +[11]: https://jupyter.org/ +[12]: https://julialang.org/ +[13]: https://www.python.org/ +[14]: https://www.r-project.org/ +[15]: https://news.ycombinator.com/item?id=9653797 +[16]: https://en.wikipedia.org/wiki/Matthias_Ettrich +[17]: https://en.wikipedia.org/wiki/KDE +[18]: https://sourceforge.net/projects/cdesktopenv/ +[19]: https://en.wikipedia.org/wiki/Linux +[20]: https://www.centos.org/ +[21]: https://www.debian.org/ +[22]: https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux +[23]: https://getfedora.org/ +[24]: https://ubuntu.com/about +[25]: https://moodle.org/ +[26]: https://en.wikipedia.org/wiki/Joomla#Historical_background +[27]: https://www.mozilla.org/en-US/ +[28]: https://en.wikipedia.org/wiki/Mosaic_(web_browser) +[29]: https://en.wikipedia.org/wiki/PEARL_(programming_language) +[30]: http://www.dangermouse.net/esoteric/piet.html +[31]: https://www.techspot.com/article/531-eben-upton-interview/ +[32]: https://www.samba.org/ +[33]: https://www.scummvm.org/ +[34]: https://www.residualvm.org/ +[35]: https://www.xfce.org/ +[36]: https://en.wikipedia.org/wiki/Olivier_Fourdan +[37]: http://www.zsh.org/mla/users/2005/msg00951.html diff --git a/published/20191017 Using multitail on Linux.md b/published/20191017 Using multitail on Linux.md new file mode 100644 index 0000000000..0d8870c9fc --- /dev/null +++ b/published/20191017 Using multitail on Linux.md @@ -0,0 +1,118 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11643-1.html) +[#]: subject: (Using multitail on Linux) +[#]: via: (https://www.networkworld.com/article/3445228/using-multitail-on-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +在 Linux 上使用 Multitail +====== + +![](https://img.linux.net.cn/data/attachment/album/201912/05/053423mpnrn95hqqknzheq.jpg) + +当你想同时查看多个文件(尤其是日志文件)的活动时,`multitail` 命令会非常有用。它的工作方式类似于多窗口形式的 `tail -f` 命令。也就是说,它显示这些文件的底部和添加的新行。虽然通常使用简单,但是 `multitail` 提供了一些命令行和交互式选项,在开始使用它之前,你应该了解它们。 + +### 基本 multitail 使用 + +`multitail` 的最简单用法是在命令行中列出你要查看的文件名称。此命令水平分割屏幕(即顶部和底部),并显示每个文件的底部以及更新。 + +``` +$ multitail /var/log/syslog /var/log/dmesg +``` + +显示内容将像这样拆分: + +``` ++-----------------------+ +| | +| | ++-----------------------| +| | +| | ++-----------------------+ +``` + +每个文件都有一行显示该文件的文件编号(从 00 开始)、文件名、文件大小、最新内容的添加日期和时间。每个文件将被分配一半空间,而不论它的大小和活动情况。比如: + +``` +content lines from my1.log +more content +more lines + +00] my1.log 59KB - 2019/10/14 12:12:09 +content lines from my2.log +more content +more lines + +01] my2.log 120KB - 2019/10/14 14:22:29 +``` + +请注意,如果你要求 `multitail` 显示非文本文件或者你无权查看的文件,它不会报错。你只是看不到内容。 + +你还可以使用通配符指定要查看的文件: + +``` +$ multitail my*.log +``` + +要记住的一件事是,`multitail` 将平均分割屏幕。如果指定的文件太多,那么除非你采取额外的步骤查看之后的文件(参考下面的滚动选项),否则你将只会看到前面 7 个文件的前面几行。确切的结果取决于终端窗口中有多少行可用。 + +按 `q` 退出 `multitail` 并返回到正常的屏幕视图。 + +### 分割屏幕 + +如果你愿意,`multitail` 也可以垂直分割你的终端窗口(即,左和右)。为此,请使用 `-s` 选项。如果指定了三个文件,那么屏幕右侧的窗口将会水平分隔。四个文件的话,你将拥有四个大小相等的窗口。 + +``` ++-----------+-----------+ +-----------+-----------+ +-----------+-----------+ +| | | | | | | | | +| | | | | | | | | +| | | | +-----------+ +-----------+-----------+ +| | | | | | | | | +| | | | | | | | | ++-----------+-----------+ +-----------+-----------+ +-----------+-----------+ + 2 个文件 3 个文件 4 个文件 +``` + +如果要将屏幕分为三列,请使用 `multitail -s 3 file1 file2 file3`。 + +``` ++-------+-------+-------+ +| | | | +| | | | +| | | | +| | | | +| | | | ++-------+-------+-------+ + 3 个文件带上 -s 3 选项 +``` + +### 滚动 + +你可以上下滚动文件,但是需要按下 `b` 弹出选择菜单,然后使用向上和向下箭头按钮选择要滚动浏览的文件。然后按下回车键。然后,你可以再次使用向上和向下箭头在放大的区域中滚动浏览各行。完成后按下 `q` 返回正常视图。 + +### 获得帮助 + +在 `multitail` 中按下 `h` 将打开一个帮助菜单,其中描述了一些基本操作,但是手册页提供了更多信息,如果莫想了解更多有关使用此工具的信息,请仔细阅读。 + +默认情况下,你的系统上不会安装 `multitail`,但是使用 `apt-get` 或 `yum` 可以使你轻松安装。该工具提供了许多功能,不过它是基于字符显示的,窗口边框只是 `q` 和 `x` 的字符串组成的。当你需要关注文件更新时,它非常方便。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3445228/using-multitail-on-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.flickr.com/photos/glenbowman/7992498919/in/photolist-dbgDtv-gHfRRz-5uRM4v-gHgFnz-6sPqTZ-5uaP7H-USFPqD-pbtRUe-fiKiYn-nmgWL2-pQNepR-q68p8d-dDsUxw-dbgFKG-nmgE6m-DHyqM-nCKA4L-2d7uFqH-Kbqzk-8EwKg-8Vy72g-2X3NSN-78Bv84-buKWXF-aeM4ok-yhweWf-4vwpyX-9hu8nq-9zCoti-v5nzP5-23fL48r-24y6pGS-JhWDof-6zF75k-24y6nHS-9hr19c-Gueh6G-Guei7u-GuegFy-24y6oX5-26qu5iX-wKrnMW-Gueikf-24y6oYh-27y4wwA-x4z19F-x57yP4-24BY6gc-24y6nPo-QGwbkf +[2]: https://creativecommons.org/licenses/by-sa/2.0/legalcode +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/published/20191020 14 SCP Command Examples to Securely Transfer Files in Linux.md b/published/20191020 14 SCP Command Examples to Securely Transfer Files in Linux.md new file mode 100644 index 0000000000..9fafdca9cf --- /dev/null +++ b/published/20191020 14 SCP Command Examples to Securely Transfer Files in Linux.md @@ -0,0 +1,245 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11669-1.html) +[#]: subject: (14 SCP Command Examples to Securely Transfer Files in Linux) +[#]: via: (https://www.linuxtechi.com/scp-command-examples-in-linux/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +在 Linux 上安全传输文件的 14 SCP 命令示例 +====== + +![](https://img.linux.net.cn/data/attachment/album/201912/13/100239f31is1ios31vvoo3.jpg) + +SCP(安全复制Secure Copy)是 Linux 和 Unix 之类的系统中的命令行工具,用于通过网络安全地跨系统传输文件和目录。当我们使用 `scp` 命令将文件和目录从本地系统复制到远程系统时,则在后端与远程系统建立了 ssh 连接。换句话说,我们可以说 `scp` 在后端使用了相同的 SSH 安全机制,它需要密码或密钥进行身份验证。 + +![scp-command-examples-linux][2] + +在本教程中,我们将讨论 14 个有用的 Linux `scp` 命令示例。 + +`scp` 命令语法: + +``` +# scp <选项> <文件或目录> 用户名@目标主机:/<文件夹> + +# scp <选项> 用户名@目标主机:/文件 <本地文件夹> +``` + +`scp` 命令的第一个语法演示了如何将文件或目录从本地系统复制到特定文件夹下的目标主机。 + +`scp` 命令的第二种语法演示了如何将目标主机中的文件复制到本地系统中。 + +下面列出了 `scp` 命令中使用最广泛的一些选项, + +* `-C` 启用压缩 +* `-i` 指定识别文件或私钥 +* `-l` 复制时限制带宽 +* `-P` 指定目标主机的 ssh 端口号 +* `-p` 复制时保留文件的权限、模式和访问时间 +* `-q` 禁止 SSH 警告消息 +* `-r` 递归复制文件和目录 +* `-v` 详细输出 + +现在让我们跳入示例! + +### 示例:1)使用 scp 将文件从本地系统复制到远程系统 + +假设我们要使用 `scp` 命令将 jdk 的 rpm 软件包从本地 Linux 系统复制到远程系统(172.20.10.8),请使用以下命令, + +``` +[root@linuxtechi ~]$ scp jdk-linux-x64_bin.rpm root@linuxtechi:/opt +root@linuxtechi's password: +jdk-linux-x64_bin.rpm 100% 10MB 27.1MB/s 00:00 +[root@linuxtechi ~]$ +``` + +上面的命令会将 jdk 的 rpm 软件包文件复制到 `/opt` 文件夹下的远程系统。 + +### 示例:2)使用 scp 将文件从远程系统复制到本地系统 + +假设我们想将文件从远程系统复制到本地系统下的 `/tmp` 文件夹,执行以下 `scp` 命令, + +``` +[root@linuxtechi ~]$ scp root@linuxtechi:/root/Technical-Doc-RHS.odt /tmp +root@linuxtechi's password: +Technical-Doc-RHS.odt 100% 1109KB 31.8MB/s 00:00 +[root@linuxtechi ~]$ ls -l /tmp/Technical-Doc-RHS.odt +-rwx------. 1 pkumar pkumar 1135521 Oct 19 11:12 /tmp/Technical-Doc-RHS.odt +[root@linuxtechi ~]$ +``` + +### 示例:3)使用 scp 传输文件时的详细输出(-v) + +在 `scp` 命令中,我们可以使用 `-v` 选项启用详细输出。使用详细输出,我们可以轻松地发现后台确切发生了什么。这对于调试连接、认证和配置等问题非常有用。 + +``` +root@linuxtechi ~]$ scp -v jdk-linux-x64_bin.rpm root@linuxtechi:/opt +Executing: program /usr/bin/ssh host 172.20.10.8, user root, command scp -v -t /opt +OpenSSH_7.8p1, OpenSSL 1.1.1 FIPS 11 Sep 2018 +debug1: Reading configuration data /etc/ssh/ssh_config +debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf +debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config +debug1: /etc/ssh/ssh_config.d/05-redhat.conf line 8: Applying options for * +debug1: Connecting to 172.20.10.8 [172.20.10.8] port 22. +debug1: Connection established. +………… +debug1: Next authentication method: password +root@linuxtechi's password: +``` + +### 示例:4)将多个文件传输到远程系统 + +可以使用 `scp` 命令一次性将多个文件复制/传输到远程系统,在 `scp` 命令中指定多个文件,并用空格隔开,示例如下所示 + +``` +[root@linuxtechi ~]$ scp install.txt index.html jdk-linux-x64_bin.rpm root@linuxtechi:/mnt +root@linuxtechi's password: +install.txt 100% 0 0.0KB/s 00:00 +index.html 100% 85KB 7.2MB/s 00:00 +jdk-linux-x64_bin.rpm 100% 10MB 25.3MB/s 00:00 +[root@linuxtechi ~]$ +``` + +### 示例:5)在两个远程主机之间传输文件 + +使用 `scp` 命令,我们可以在两个远程主机之间复制文件和目录,假设我们有一个可以连接到两个远程 Linux 系统的本地 Linux 系统,因此从我的本地 Linux 系统中,我可以使用 `scp` 命令在这两个系统之间复制文件, + +命令语法: + +``` +# scp 用户名@远程主机1:/<要传输的文件> 用户名@远程主机2:/<文件夹> +``` + +示例如下: + +``` +# scp root@linuxtechi:~/backup-Oct.zip root@linuxtechi:/tmp +# ssh root@linuxtechi "ls -l /tmp/backup-Oct.zip" +-rwx------. 1 root root 747438080 Oct 19 12:02 /tmp/backup-Oct.zip +``` + +### 示例:6)递归复制文件和目录(-r) + +在 `scp` 命令中使用 `-r` 选项将整个目录从一个系统递归地复制到另一个系统,示例如下所示: + +``` +[root@linuxtechi ~]$ scp -r Downloads root@linuxtechi:/opt +``` + +使用以下命令验证 `Downloads` 文件夹是否已复制到远程系统, + +``` +[root@linuxtechi ~]$ ssh root@linuxtechi "ls -ld /opt/Downloads" +drwxr-xr-x. 2 root root 75 Oct 19 12:10 /opt/Downloads +[root@linuxtechi ~]$ +``` + +### 示例:7)通过启用压缩来提高传输速度(-C) + +在 `scp` 命令中,我们可以通过使用 `-C` 选项启用压缩来提高传输速度,它将自动在源主机上启用压缩并在目标主机上解压缩。 + +``` +root@linuxtechi ~]$ scp -r -C Downloads root@linuxtechi:/mnt +``` + +在以上示例中,我们正在启用压缩的情况下传输下载目录。 + +### 示例:8)复制时限制带宽(-l) + +在 `scp` 命令中使用 `-l` 选项设置复制时对带宽使用的限制。带宽以 Kbit/s 为单位指定,示例如下所示: + +``` +[root@linuxtechi ~]$ scp -l 500 jdk-linux-x64_bin.rpm root@linuxtechi:/var +``` + +### 示例:9)在 scp 时指定其他 ssh 端口(-P) + +在某些情况下,目标主机上的 ssh 端口会更改,因此在使用 `scp` 命令时,我们可以使用 `-P` 选项指定 ssh 端口号。 + +``` +[root@linuxtechi ~]$ scp -P 2022 jdk-linux-x64_bin.rpm root@linuxtechi:/var +``` + +在上面的示例中,远程主机的 ssh 端口为 “2022”。 + +### 示例:10)复制时保留文件的权限、模式和访问时间(-p) + +从源复制到目标时,在 `scp` 命令中使用 `-p` 选项保留权限、访问时间和模式。 + +``` +[root@linuxtechi ~]$ scp -p jdk-linux-x64_bin.rpm root@linuxtechi:/var/tmp +jdk-linux-x64_bin.rpm 100% 10MB 13.5MB/s 00:00 +[root@linuxtechi ~]$ +``` + +### 示例:11)在 scp 中以安静模式传输文件(-q) + +在 `scp` 命令中使用 `-q` 选项可禁止显示 ssh 的传输进度、警告和诊断消息。示例如下所示: + +``` +[root@linuxtechi ~]$ scp -q -r Downloads root@linuxtechi:/var/tmp +[root@linuxtechi ~]$ +``` + +### 示例:12)在传输时使用 scp 中的识别文件(-i) + +在大多数 Linux 环境中,首选基于密钥的身份验证。在 `scp` 命令中,我们使用 `-i` 选项指定识别文件(私钥文件),示例如下所示: + +``` +[root@linuxtechi ~]$ scp -i my_key.pem -r Downloads root@linuxtechi:/root +``` + +在上面的示例中,`my_key.pem` 是识别文件或私钥文件。 + +### 示例:13)在 scp 中使用其他 ssh_config 文件(-F) + +在某些情况下,你使用不同的网络连接到 Linux 系统,可能某些网络位于代理服务器后面,因此在这种情况下,我们必须具有不同的 `ssh_config` 文件。 + +通过 `-F` 选项在 `scp` 命令中指定了不同的 `ssh_config` 文件,示例如下所示: + +``` +[root@linuxtechi ~]$ scp -F /home/pkumar/new_ssh_config -r Downloads root@linuxtechi:/root +root@linuxtechi's password: +jdk-linux-x64_bin.rpm 100% 10MB 16.6MB/s 00:00 +backup-Oct.zip 100% 713MB 41.9MB/s 00:17 +index.html 100% 85KB 6.6MB/s 00:00 +[root@linuxtechi ~]$ +``` + +### 示例:14)在 scp 命令中使用其他加密方式(-c) + +默认情况下,`scp` 使用 AES-128 加密方式来加密文件。如果你想在 `scp` 命令中使用其他加密方式,请使用 `-c` 选项,后接加密方式名称。 + +假设我们要在用 `scp` 命令传输文件时使用 3des-cbc 加密方式,请运行以下 `scp` 命令: + +``` +[root@linuxtechi ~]# scp -c 3des-cbc -r Downloads root@linuxtechi:/root +``` + +使用以下命令列出 `ssh` 和 `scp` 支持的加密方式: + +``` +[root@linuxtechi ~]# ssh -Q cipher localhost | paste -d , -s - +3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc,root@linuxtechi,aes128-ctr,aes192-ctr,aes256-ctr,root@linuxtechi,root@linuxtechi,root@linuxtechi +[root@linuxtechi ~]# +``` + +以上就是本教程的全部内容,要获取有关 `scp` 命令的更多详细信息,请参考其手册页。请在下面的评论部分中分享你的反馈和评论。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/scp-command-examples-in-linux/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/10/scp-command-examples-linux.jpg +[3]: https://www.linuxtechi.com/cdn-cgi/l/email-protection diff --git a/published/20191022 How to program with Bash- Logical operators and shell expansions.md b/published/20191022 How to program with Bash- Logical operators and shell expansions.md new file mode 100644 index 0000000000..31f0e3ef32 --- /dev/null +++ b/published/20191022 How to program with Bash- Logical operators and shell expansions.md @@ -0,0 +1,467 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11687-1.html) +[#]: subject: (How to program with Bash: Logical operators and shell expansions) +[#]: via: (https://opensource.com/article/19/10/programming-bash-logical-operators-shell-expansions) +[#]: author: (David Both https://opensource.com/users/dboth) + +怎样用 Bash 编程:逻辑操作符和 shell 扩展 +====== + +> 学习逻辑操作符和 shell 扩展,本文是三篇 Bash 编程系列的第二篇。 + +![](https://img.linux.net.cn/data/attachment/album/201912/17/173459pxhz0aiicimzd1m2.jpg) + +Bash 是一种强大的编程语言,完美契合命令行和 shell 脚本。本系列(三篇文章,基于我的 [三集 Linux 自学课程][2])讲解如何在 CLI 使用 Bash 编程。 + +[第一篇文章][3] 讲解了 Bash 的一些简单命令行操作,包括如何使用变量和控制操作符。第二篇文章探讨文件、字符串、数字等类型和各种各样在执行流中提供控制逻辑的的逻辑运算符,还有 Bash 中的各类 shell 扩展。本系列第三篇也是最后一篇文章,将会探索能重复执行操作的 `for` 、`while` 和 `until` 循环。 + +逻辑操作符是程序中进行判断的根本要素,也是执行不同的语句组合的依据。有时这也被称为流控制。 + +### 逻辑操作符 + +Bash 中有大量的用于不同条件表达式的逻辑操作符。最基本的是 `if` 控制结构,它判断一个条件,如果条件为真,就执行一些程序语句。操作符共有三类:文件、数字和非数字操作符。如果条件为真,所有的操作符返回真值(`0`),如果条件为假,返回假值(`1`)。 + +这些比较操作符的函数语法是,一个操作符加一个或两个参数放在中括号内,后面跟一系列程序语句,如果条件为真,程序语句执行,可能会有另一个程序语句列表,该列表在条件为假时执行: + + +``` +if [ arg1 operator arg2 ] ; then list +或 +if [ arg1 operator arg2 ] ; then list ; else list ; fi +``` + +像例子中那样,在比较表达式中,空格不能省略。中括号的每部分,`[` 和 `]`,是跟 `test` 命令一样的传统的 Bash 符号: + +``` +if test arg1 operator arg2 ; then list +``` + +还有一个更新的语法能提供一点点便利,一些系统管理员比较喜欢用。这种格式对于不同版本的 Bash 和一些 shell 如 ksh(Korn shell)兼容性稍差。格式如下: + +``` +if [[ arg1 operator arg2 ]] ; then list +``` + +#### 文件操作符 + +文件操作符是 Bash 中一系列强大的逻辑操作符。图表 1 列出了 20 多种不同的 Bash 处理文件的操作符。在我的脚本中使用频率很高。 + +操作符 | 描述 +---|--- +`-a filename` | 如果文件存在,返回真值;文件可以为空也可以有内容,但是只要它存在,就返回真值 +`-b filename` | 如果文件存在且是一个块设备,如 `/dev/sda` 或 `/dev/sda1`,则返回真值 +`-c filename` | 如果文件存在且是一个字符设备,如 `/dev/TTY1`,则返回真值 +`-d filename` | 如果文件存在且是一个目录,返回真值 +`-e filename` | 如果文件存在,返回真值;与上面的 `-a` 相同 +`-f filename` | 如果文件存在且是一个一般文件,不是目录、设备文件或链接等的其他的文件,则返回 真值 +`-g filename` | 如果文件存在且 `SETGID` 标记被设置在其上,返回真值 +`-h filename` | 如果文件存在且是一个符号链接,则返回真值 +`-k filename` | 如果文件存在且粘滞位已设置,则返回真值 +`-p filename` | 如果文件存在且是一个命名的管道(FIFO),返回真值 +`-r filename` | 如果文件存在且有可读权限(它的可读位被设置),返回真值 +`-s filename` | 如果文件存在且大小大于 0,返回真值;如果一个文件存在但大小为 0,则返回假值 +`-t fd` | 如果文件描述符 `fd` 被打开且被关联到一个终端设备上,返回真值 +`-u filename` | 如果文件存在且它的 `SETUID` 位被设置,返回真值 +`-w filename` | 如果文件存在且有可写权限,返回真值 +`-x filename` | 如果文件存在且有可执行权限,返回真值 +`-G filename` | 如果文件存在且文件的组 ID 与当前用户相同,返回真值 +`-L filename` | 如果文件存在且是一个符号链接,返回真值(同 `-h`) +`-N filename` | 如果文件存在且从文件上一次被读取后文件被修改过,返回真值 +`-O filename` | 如果文件存在且你是文件的拥有者,返回真值 +`-S filename` | 如果文件存在且文件是套接字,返回真值 +`file1 -ef file2` | 如果文件 `file1` 和文件 `file2` 指向同一设备的同一 INODE 号,返回真值(即硬链接) +`file1 -nt file2` | 如果文件 `file1` 比 `file2` 新(根据修改日期),或 `file1` 存在而 `file2` 不存在,返回真值 +`file1 -ot file2` | 如果文件 `file1` 比 `file2` 旧(根据修改日期),或 `file1` 不存在而 `file2` 存在 + +*图表 1:Bash 文件操作符* + +以测试一个文件存在与否来举例: + +``` +[student@studentvm1 testdir]$ File="TestFile1" ; if [ -e $File ] ; then echo "The file $File exists." ; else echo "The file $File does not exist." ; fi +The file TestFile1 does not exist. +[student@studentvm1 testdir]$ +``` + +创建一个用来测试的文件,命名为 `TestFile1`。目前它不需要包含任何数据: + +``` +[student@studentvm1 testdir]$ touch TestFile1 +``` + +在这个简短的 CLI 程序中,修改 `$File` 变量的值相比于在多个地方修改表示文件名的字符串的值要容易: + +``` +[student@studentvm1 testdir]$ File="TestFile1" ; if [ -e $File ] ; then echo "The file $File exists." ; else echo "The file $File does not exist." ; fi +The file TestFile1 exists. +[student@studentvm1 testdir]$ +``` + +现在,运行一个测试来判断一个文件是否存在且长度不为 0(表示它包含数据)。假设你想判断三种情况: + +1. 文件不存在; +2. 文件存在且为空; +3. 文件存在且包含数据。 + +因此,你需要一组更复杂的测试代码 — 为了测试所有的情况,使用 `if-elif-else` 结构中的 `elif` 语句: + +``` +[student@studentvm1 testdir]$ File="TestFile1" ; if [ -s $File ] ; then echo "$File exists and contains data." ; fi +[student@studentvm1 testdir]$ +``` + +在这个情况中,文件存在但不包含任何数据。向文件添加一些数据再运行一次: + +``` +[student@studentvm1 testdir]$ File="TestFile1" ; echo "This is file $File" > $File ; if [ -s $File ] ; then echo "$File exists and contains data." ; fi +TestFile1 exists and contains data. +[student@studentvm1 testdir]$ +``` + +这组语句能返回正常的结果,但是仅仅是在我们已知三种可能的情况下测试某种确切的条件。添加一段 `else` 语句,这样你就可以更精确地测试。把文件删掉,你就可以完整地测试这段新代码: + +``` +[student@studentvm1 testdir]$ File="TestFile1" ; rm $File ; if [ -s $File ] ; then echo "$File exists and contains data." ; else echo "$File does not exist or is empty." ; fi +TestFile1 does not exist or is empty. +``` + +现在创建一个空文件用来测试: + +``` +[student@studentvm1 testdir]$ File="TestFile1" ; touch $File ; if [ -s $File ] ; then echo "$File exists and contains data." ; else echo "$File does not exist or is empty." ; fi +TestFile1 does not exist or is empty. +``` + +向文件添加一些内容,然后再测试一次: + +``` +[student@studentvm1 testdir]$ File="TestFile1" ; echo "This is file $File" > $File ; if [ -s $File ] ; then echo "$File exists and contains data." ; else echo "$File does not exist or is empty." ; fi +TestFile1 exists and contains data. +``` + +现在加入 `elif` 语句来辨别是文件不存在还是文件为空: + +``` +[student@studentvm1 testdir]$ File="TestFile1" ; touch $File ; if [ -s $File ] ; then echo "$File exists and contains data." ; elif [ -e $File ] ; then echo "$File exists and is empty." ; else echo "$File does not exist." ; fi +TestFile1 exists and is empty. +[student@studentvm1 testdir]$ File="TestFile1" ; echo "This is $File" > $File ; if [ -s $File ] ; then echo "$File exists and contains data." ; elif [ -e $File ] ; then echo "$File exists and is empty." ; else echo "$File does not exist." ; fi +TestFile1 exists and contains data. +[student@studentvm1 testdir]$ +``` + +现在你有一个可以测试这三种情况的 Bash CLI 程序,但是可能的情况是无限的。 + +如果你能像保存在文件中的脚本那样组织程序语句,那么即使对于更复杂的命令组合也会很容易看出它们的逻辑结构。图表 2 就是一个示例。 `if-elif-else` 结构中每一部分的程序语句的缩进让逻辑更变得清晰。 + + +``` +File="TestFile1" +echo "This is $File" > $File +if [ -s $File ] + then + echo "$File exists and contains data." +elif [ -e $File ] + then + echo "$File exists and is empty." +else + echo "$File does not exist." +fi +``` + +*图表 2: 像在脚本里一样重写书写命令行程序* + +对于大多数 CLI 程序来说,让这些复杂的命令变得有逻辑需要写很长的代码。虽然 CLI 可能是用 Linux 或 Bash 内置的命令,但是当 CLI 程序很长或很复杂时,创建一个保存在文件中的脚本将更有效,保存到文件中后,可以随时运行。 + +#### 字符串比较操作符 + +字符串比较操作符使我们可以对字符串中的字符按字母顺序进行比较。图表 3 列出了仅有的几个字符串比较操作符。 + +操作符 | 描述 +---|--- +`-z string` | 如果字符串的长度为 0 ,返回真值 +`-n string` |如果字符串的长度不为 0 ,返回真值 +`string1 == string2` 或 `string1 = string2` | 如果两个字符串相等,返回真值。处于遵从 POSIX 一致性,在测试命令中应使用一个等号 `=`。与命令 `[[` 一起使用时,会进行如上描述的模式匹配(混合命令)。 +`string1 != string2` | 两个字符串不相等,返回真值 +`string1 < string2` | 如果对 `string1` 和 `string2` 按字母顺序进行排序,`string1` 排在 `string2` 前面(即基于地区设定的对所有字母和特殊字符的排列顺序) +`string1 > string2` | 如果对 `string1` 和 `string2` 按字母顺序进行排序,`string1` 排在 `string2` 后面 + +*图表 3: Bash 字符串逻辑操作符* + +首先,检查字符串长度。比较表达式中 `$MyVar` 两边的双引号不能省略(你仍应该在目录 `~/testdir` 下 )。 + +``` +[student@studentvm1 testdir]$ MyVar="" ; if [ -z "" ] ; then echo "MyVar is zero length." ; else echo "MyVar contains data" ; fi +MyVar is zero length. +[student@studentvm1 testdir]$ MyVar="Random text" ; if [ -z "" ] ; then echo "MyVar is zero length." ; else echo "MyVar contains data" ; fi +MyVar is zero length. +``` + +你也可以这样做: + +``` +[student@studentvm1 testdir]$ MyVar="Random text" ; if [ -n "$MyVar" ] ; then echo "MyVar contains data." ; else echo "MyVar is zero length" ; fi +MyVar contains data. +[student@studentvm1 testdir]$ MyVar="" ; if [ -n "$MyVar" ] ; then echo "MyVar contains data." ; else echo "MyVar is zero length" ; fi +MyVar is zero length +``` + +有时候你需要知道一个字符串确切的长度。这虽然不是比较,但是也与比较相关。不幸的是,计算字符串的长度没有简单的方法。有很多种方法可以计算,但是我认为使用 `expr`(求值表达式)命令是相对最简单的一种。阅读 `expr` 的手册页可以了解更多相关知识。注意表达式中你检测的字符串或变量两边的引号不要省略。 + +``` +[student@studentvm1 testdir]$ MyVar="" ; expr length "$MyVar" +0 +[student@studentvm1 testdir]$ MyVar="How long is this?" ; expr length "$MyVar" +17 +[student@studentvm1 testdir]$ expr length "We can also find the length of a literal string as well as a variable." +70 +``` + +关于比较操作符,在我们的脚本中使用了大量的检测两个字符串是否相等(例如,两个字符串是否实际上是同一个字符串)的操作。我使用的是非 POSIX 版本的比较表达式: + +``` +[student@studentvm1 testdir]$ Var1="Hello World" ; Var2="Hello World" ; if [ "$Var1" == "$Var2" ] ; then echo "Var1 matches Var2" ; else echo "Var1 and Var2 do not match." ; fi +Var1 matches Var2 +[student@studentvm1 testdir]$ Var1="Hello World" ; Var2="Hello world" ; if [ "$Var1" == "$Var2" ] ; then echo "Var1 matches Var2" ; else echo "Var1 and Var2 do not match." ; fi +Var1 and Var2 do not match. +``` + +在你自己的脚本中去试一下这些操作符。 + +#### 数字比较操作符 + +数字操作符用于两个数字参数之间的比较。像其他类操作符一样,大部分都很容易理解。 + +操作符 | 描述 +---|--- +`arg1 -eq arg2` | 如果 `arg1` 等于 `arg2`,返回真值 +`arg1 -ne arg2` | 如果 `arg1` 不等于 `arg2`,返回真值 +`arg1 -lt arg2` | 如果 `arg1` 小于 `arg2`,返回真值 +`arg1 -le arg2` | 如果 `arg1` 小于或等于 `arg2`,返回真值 +`arg1 -gt arg2` | 如果 `arg1` 大于 `arg2`,返回真值 +`arg1 -ge arg2` | 如果 `arg1` 大于或等于 `arg2`,返回真值 + +*图表 4: Bash 数字比较逻辑操作符* + +来看几个简单的例子。第一个示例设置变量 `$X` 的值为 1,然后检测 `$X` 是否等于 1。第二个示例中,`$X` 被设置为 0,所以比较表达式返回结果不为真值。 + +``` +[student@studentvm1 testdir]$ X=1 ; if [ $X -eq 1 ] ; then echo "X equals 1" ; else echo "X does not equal 1" ; fi +X equals 1 +[student@studentvm1 testdir]$ X=0 ; if [ $X -eq 1 ] ; then echo "X equals 1" ; else echo "X does not equal 1" ; fi +X does not equal 1 +[student@studentvm1 testdir]$ +``` + +自己来多尝试一下其他的。 + +#### 杂项操作符 + +这些杂项操作符展示一个 shell 选项是否被设置,或一个 shell 变量是否有值,但是它不显示变量的值,只显示它是否有值。 + +操作符 | 描述 +---|--- +`-o optname` | 如果一个 shell 选项 `optname` 是启用的(查看内建在 Bash 手册页中的 set `-o` 选项描述下面的选项列表),则返回真值 +`-v varname` | 如果 shell 变量 `varname` 被设置了值(被赋予了值),则返回真值 +`-R varname` | 如果一个 shell 变量 `varname` 被设置了值且是一个名字引用,则返回真值 + +*图表 5: 杂项 Bash 逻辑操作符* + +自己来使用这些操作符实践下。 + +### 扩展 + +Bash 支持非常有用的几种类型的扩展和命令替换。根据 Bash 手册页,Bash 有七种扩展格式。本文只介绍其中五种:`~` 扩展、算术扩展、路径名称扩展、大括号扩展和命令替换。 + +#### 大括号扩展 + +大括号扩展是生成任意字符串的一种方法。(下面的例子是用特定模式的字符创建大量的文件。)大括号扩展可以用于产生任意字符串的列表,并把它们插入一个用静态字符串包围的特定位置或静态字符串的两端。这可能不太好想象,所以还是来实践一下。 + +首先,看一下大括号扩展的作用: + +``` +[student@studentvm1 testdir]$ echo {string1,string2,string3} +string1 string2 string3 +``` + +看起来不是很有用,对吧?但是用其他方式使用它,再来看看: + +``` +[student@studentvm1 testdir]$ echo "Hello "{David,Jen,Rikki,Jason}. +Hello David. Hello Jen. Hello Rikki. Hello Jason. +``` + +这看起来貌似有点用了 — 我们可以少打很多字。现在试一下这个: + +``` +[student@studentvm1 testdir]$ echo b{ed,olt,ar}s +beds bolts bars +``` + +我可以继续举例,但是你应该已经理解了它的用处。 + +#### ~ 扩展 + +资料显示,使用最多的扩展是波浪字符(`~`)扩展。当你在命令中使用它(如 `cd ~/Documents`)时,Bash shell 把这个快捷方式展开成用户的完整的家目录。 + +使用这个 Bash 程序观察 `~` 扩展的作用: + +``` +[student@studentvm1 testdir]$ echo ~ +/home/student +[student@studentvm1 testdir]$ echo ~/Documents +/home/student/Documents +[student@studentvm1 testdir]$ Var1=~/Documents ; echo $Var1 ; cd $Var1 +/home/student/Documents +[student@studentvm1 Documents]$ +``` + +#### 路径名称扩展 + +路径名称扩展是展开文件通配模式为匹配该模式的完整路径名称的另一种说法,匹配字符使用 `?` 和 `*`。文件通配指的是在大量操作中匹配文件名、路径和其他字符串时用特定的模式字符产生极大的灵活性。这些特定的模式字符允许匹配字符串中的一个、多个或特定字符。 + +* `?` — 匹配字符串中特定位置的一个任意字符 +* `*` — 匹配字符串中特定位置的 0 个或多个任意字符 + +这个扩展用于匹配路径名称。为了弄清它的用法,请确保 `testdir` 是当前工作目录(`PWD`),先执行基本的列出清单命令 `ls`(我家目录下的内容跟你的不一样)。 + +``` +[student@studentvm1 testdir]$ ls +chapter6  cpuHog.dos    dmesg1.txt  Documents  Music       softlink1  testdir6    Videos +chapter7  cpuHog.Linux  dmesg2.txt  Downloads  Pictures    Templates  testdir +testdir  cpuHog.mac    dmesg3.txt  file005    Public      testdir    tmp +cpuHog     Desktop       dmesg.txt   link3      random.txt  testdir1   umask.test +[student@studentvm1 testdir]$ +``` + +现在列出以 `Do`、`testdir/Documents` 和 `testdir/Downloads` 开头的目录: + +``` +Documents: +Directory01  file07  file15        test02  test10  test20      testfile13  TextFiles +Directory02  file08  file16        test03  test11  testfile01  testfile14 +file01       file09  file17        test04  test12  testfile04  testfile15 +file02       file10  file18        test05  test13  testfile05  testfile16 +file03       file11  file19        test06  test14  testfile09  testfile17 +file04       file12  file20        test07  test15  testfile10  testfile18 +file05       file13  Student1.txt  test08  test16  testfile11  testfile19 +file06       file14  test01        test09  test18  testfile12  testfile20 + +Downloads: +[student@studentvm1 testdir]$ +``` + +然而,并没有得到你期望的结果。它列出了以 `Do` 开头的目录下的内容。使用 `-d` 选项,仅列出目录而不列出它们的内容。 + +``` +[student@studentvm1 testdir]$ ls -d Do* +Documents  Downloads +[student@studentvm1 testdir]$ +``` + +在两个例子中,Bash shell 都把 `Do*` 模式展开成了匹配该模式的目录名称。但是如果有文件也匹配这个模式,会发生什么? + +``` +[student@studentvm1 testdir]$ touch Downtown ; ls -d Do* +Documents  Downloads  Downtown +[student@studentvm1 testdir]$ +``` + +因此所有匹配这个模式的文件也被展开成了完整名字。 + +#### 命令替换 + +命令替换是让一个命令的标准输出数据流被当做参数传给另一个命令的扩展形式,例如,在一个循环中作为一系列被处理的项目。Bash 手册页显示:“命令替换可以让你用一个命令的输出替换为命令的名字。”这可能不太好理解。 + +命令替换有两种格式:\`command\` 和 `$(command)`。在更早的格式中使用反引号(\`),在命令中使用反斜杠(`\`)来保持它转义之前的文本含义。然而,当用在新版本的括号格式中时,反斜杠被当做一个特殊字符处理。也请注意带括号的格式打开个关闭命令语句都是用一个括号。 + +我经常在命令行程序和脚本中使用这种能力,一个命令的结果能被用作另一个命令的参数。 + +来看一个非常简单的示例,这个示例使用了这个扩展的两种格式(再一次提醒,确保 `testdir` 是当前工作目录): + +``` +[student@studentvm1 testdir]$ echo "Todays date is `date`" +Todays date is Sun Apr 7 14:42:46 EDT 2019 +[student@studentvm1 testdir]$ echo "Todays date is $(date)" +Todays date is Sun Apr 7 14:42:59 EDT 2019 +[student@studentvm1 testdir]$ +``` + +`-seq` 工具用于一个数字序列: + +``` +[student@studentvm1 testdir]$ seq 5 +1 +2 +3 +4 +5 +[student@studentvm1 testdir]$ echo `seq 5` +1 2 3 4 5 +[student@studentvm1 testdir]$ +``` + +现在你可以做一些更有用处的操作,比如创建大量用于测试的空文件。 + +``` +[student@studentvm1 testdir]$ for I in $(seq -w 5000) ; do touch file-$I ; done +``` + +`seq` 工具加上 `-w` 选项后,在生成的数字前面会用 0 补全,这样所有的结果都等宽,例如,忽略数字的值,它们的位数一样。这样在对它们按数字顺序进行排列时很容易。 + +`seq -w 5000` 语句生成了 1 到 5000 的数字序列。通过把命令替换用于 `for` 语句,`for` 语句就可以使用该数字序列来生成文件名的数字部分。 + +#### 算术扩展 + +Bash 可以进行整型的数学计算,但是比较繁琐(你一会儿将看到)。数字扩展的语法是 `$((arithmetic-expression))` ,分别用两个括号来打开和关闭表达式。算术扩展在 shell 程序或脚本中类似命令替换;表达式结算后的结果替换了表达式,用于 shell 后续的计算。 + +我们再用一个简单的用法来开始: + +``` +[student@studentvm1 testdir]$ echo $((1+1)) +2 +[student@studentvm1 testdir]$ Var1=5 ; Var2=7 ; Var3=$((Var1*Var2)) ; echo "Var 3 = $Var3" +Var 3 = 35 +``` + +下面的除法结果是 0,因为表达式的结果是一个小于 1 的整型数字: + +``` +[student@studentvm1 testdir]$ Var1=5 ; Var2=7 ; Var3=$((Var1/Var2)) ; echo "Var 3 = $Var3" +Var 3 = 0 +``` + +这是一个我经常在脚本或 CLI 程序中使用的一个简单的计算,用来查看在 Linux 主机中使用了多少虚拟内存。 `free` 不提供我需要的数据: + +``` +[student@studentvm1 testdir]$ RAM=`free | grep ^Mem | awk '{print $2}'` ; Swap=`free | grep ^Swap | awk '{print $2}'` ; echo "RAM = $RAM and Swap = $Swap" ; echo "Total Virtual memory is $((RAM+Swap))" ; +RAM = 4037080 and Swap = 6291452 +Total Virtual memory is 10328532 +``` + +我使用 \` 字符来划定用作命令替换的界限。 + +我用 Bash 算术扩展的场景主要是用脚本检查系统资源用量后基于返回的结果选择一个程序运行的路径。 + +### 总结 + +本文是 Bash 编程语言系列的第二篇,探讨了 Bash 中文件、字符串、数字和各种提供流程控制逻辑的逻辑操作符还有不同种类的 shell 扩展。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/programming-bash-logical-operators-shell-expansions + +作者:[David Both][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dboth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_women_computing_5.png?itok=YHpNs_ss (Women in computing and open source v5) +[2]: http://www.both.org/?page_id=1183 +[3]: https://linux.cn/article-11552-1.html diff --git a/published/20191024 Get sorted with sort at the command line.md b/published/20191024 Get sorted with sort at the command line.md new file mode 100644 index 0000000000..55916bdcad --- /dev/null +++ b/published/20191024 Get sorted with sort at the command line.md @@ -0,0 +1,240 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11657-1.html) +[#]: subject: (Get sorted with sort at the command line) +[#]: via: (https://opensource.com/article/19/10/get-sorted-sort) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +在命令行用 sort 进行排序 +====== + +> 在 Linux、BSD 或 Mac 的终端中使用 sort 命令,按自己的需求重新整理数据。 + +![](https://img.linux.net.cn/data/attachment/album/201912/09/065444f42xl2lddxillz09.jpg) + +如果你曾经用过数据表应用程序,你就会知道可以按列的内容对行进行排序。例如,如果你有一个费用列表,你可能希望对它们进行按日期或价格升序抑或按类别进行排序。如果你熟悉终端的使用,你不会仅为了排序文本数据就去使用庞大的办公软件。这正是 [sort][2] 命令的用处。 + +### 安装 + +你不必安装 `sort` ,因为它向来都包含在 [POSIX][3] 系统里。在大多数 Linux 系统中,`sort` 命令来自 GNU 组织打包的实用工具集合中。在其他的 POSIX 系统中,像 BSD 和 Mac,默认的 `sort` 命令不是 GNU 提供的,所以有一些选项可能不一样。本文中我尽量对 GNU 和 BSD 两者的实现都进行说明。 + +### 按字母顺序排列行 + +`sort` 命令默认会读取文件每行的第一个字符并对每行按字母升序排序后输出。两行中的第一个字符相同的情况下,对下一个字符进行对比。例如: + +``` +$ cat distro.list +Slackware +Fedora +Red Hat Enterprise Linux +Ubuntu +Arch +1337 +Mint +Mageia +Debian +$ sort distro.list +1337 +Arch +Debian +Fedora +Mageia +Mint +Red Hat Enterprise Linux +Slackware +Ubuntu +``` + +使用 `sort` 不会改变原文件。`sort` 仅起到过滤的作用,所以如果你希望按排序后的格式保存数据,你需要用 `>` 或 `tee` 进行重定向。 + + +``` +$ sort distro.list | tee distro.sorted +1337 +Arch +Debian +[...] +$ cat distro.sorted +1337 +Arch +Debian +[...] +``` + +### 按列排序 + +复杂数据集有时候不止需要对每行的第一个字符进行排序。例如,假设有一个动物列表,每个都有其种和属,用可预见的分隔符分隔每一个“字段”(即数据表中的“单元格”)。这类由数据表导出的格式很常见,CSV(以逗号分隔的数据comma-separated values)后缀可以标识这些文件(虽然 CSV 文件不一定用逗号分隔,有分隔符的文件也不一定用 CSV 后缀)。以下数据作为示例: + +``` +Aptenodytes;forsteri;Miller,JF;1778;Emperor +Pygoscelis;papua;Wagler;1832;Gentoo +Eudyptula;minor;Bonaparte;1867;Little Blue +Spheniscus;demersus;Brisson;1760;African +Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed +Eudyptes;chrysocome;Viellot;1816;Southern Rockhopper +Torvaldis;linux;Ewing,L;1996;Tux +``` + +对于这组示例数据,你可以用 `--field-separator` (在 BSD 和 Mac 用 `-t`,在 GNU 上也可以用简写 `-t` )设置分隔符为分号(因为该示例数据中是用分号而不是逗号,理论上分隔符可以是任意字符),用 `--key`(在 BSD 和 Mac 上用 `-k`,在 GNU 上也可以用简写 `-k`)选项指定哪个字段被排序。例如,对每行第二个字段进行排序(计数以 1 开头而不是 0): + +``` +sort --field-separator=";" --key=2 +Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed +Eudyptes;chrysocome;Viellot;1816;Sothern Rockhopper +Spheniscus;demersus;Brisson;1760;African +Aptenodytes;forsteri;Miller,JF;1778;Emperor +Torvaldis;linux;Ewing,L;1996;Tux +Eudyptula;minor;Bonaparte;1867;Little Blue +Pygoscelis;papua;Wagler;1832;Gentoo +``` + +结果有点不容易读,但是 Unix 以构造命令的管道方式而闻名,所以你可以使用 `column` 命令美化输出结果。使用 GNU `column`: + +``` +$ sort --field-separator=";" \ +\--key=2 penguins.list | column --table --separator ";" +Megadyptes   antipodes   Milne-Edwards  1880  Yellow-eyed +Eudyptes     chrysocome  Viellot        1816  Southern Rockhopper +Spheniscus   demersus    Brisson        1760  African +Aptenodytes  forsteri    Miller,JF      1778  Emperor +Torvaldis    linux       Ewing,L        1996  Tux +Eudyptula    minor       Bonaparte      1867  Little Blue +Pygoscelis   papua       Wagler         1832  Gentoo +``` + +对于初学者可能有点不好理解(但是写起来简单),BSD 和 Mac 上的命令选项: + +``` +$ sort -t ";" \ +-k2 penguins.list | column -t -s ";" +Megadyptes   antipodes   Milne-Edwards  1880  Yellow-eyed +Eudyptes     chrysocome  Viellot        1816  Southern Rockhopper +Spheniscus   demersus    Brisson        1760  African +Aptenodytes  forsteri    Miller,JF      1778  Emperor +Torvaldis    linux       Ewing,L        1996  Tux +Eudyptula    minor       Bonaparte      1867  Little Blue +Pygoscelis   papua       Wagler         1832  Gentoo +``` + +当然 `-k` 不一定非要设为 `2`。任意存在的字段都可以被设为排序的键。 + +### 逆序排列 + +你可以用 `--reverse`(BSD/Mac 上用 `-r`,GNU 上也可以用简写 `-r`)选项来颠倒已经排好序的列表。 + +``` +$ sort --reverse alphabet.list +z +y +x +w +[...] +``` + +你也可以把输出结果通过管道传给命令 [tac][4] 来实现相同的效果。 + +### 按月排序(仅 GNU 支持) + +理想情况下,所有人都按照 ISO 8601 标准来写日期:年、月、日。这是一种合乎逻辑的指定精确日期的方法,也可以很容易地被计算机理解。也有很多情况下,人类用其他的方式标注日期,包括用很名字随意的月份。 + +幸运的是,GNU `sort` 命令能识别这种写法,并可以按月份的名称正确排序。使用 `--month-sort`(`-M`)选项: + +``` +$ cat month.list +November +October +September +April +[...] +$ sort --month-sort month.list +January +February +March +April +May +[...] +November +December +``` + +月份的全称和简写都可以被识别。 + +### 人类可读的数字排序(仅 GNU 支持) + +另一个人类和计算机的常见混淆点是数字的组合。例如,人类通常把 “1024 kilobytes” 写成 “1KB”,因为人类解析 “1 KB” 比 “1024” 要容易且更快(数字越大,这种差异越明显)。对于计算机来说,一个 9 KB 的字符串要比诸如 1 MB 的字符串大(尽管 9 KB 是 1 MB 很小一部分)。GNU `sort` 命令提供了`--human-numeric-sort`(`-h`)选项来帮助正确解析这些值。 + +``` +$ cat sizes.list +2M +12MB +1k +9k +900 +7000 +$ sort --human-numeric-sort +900 +7000 +1k +9k +2M +12MB +``` + +有一些情况例外。例如,“16000 bytes” 比 “1 KB” 大,但是 `sort` 识别不了。 + +``` +$ cat sizes0.list +2M +12MB +16000 +1k +$ sort -h sizes0.list +16000 +1k +2M +12MB +``` + +逻辑上来说,这个示例中 16000 应该写成 16 KB,所以也不应该全部归咎于GNU `sort`。只要你确保数字的一致性,`--human-numeric-sort` 可以用一种计算机友好的方式解析成人类可读的数字。 + +### 随机排序(仅 GNU 支持) + +有时候工具也提供了一些与设计初衷相悖的选项。某种程度上说,`sort` 命令提供对一个文件进行随机排序的能力没有任何意义。这个命令的工作流让这个特性变得很方便。你*可以*用其他的命令,像 [shuf][5] ,或者你可以用现在的命令添加一个选项。不管你认为它是一个臃肿的还是极具创造力的用户体验设计,GNU `sort` 命令提供了对文件进行随机排序的功能。 + +最纯粹的随机排序格式选项是 `--random-sort` 或 `-R`(不要跟 `-r` 混淆,`-r` 是 `--reverse` 的简写)。 + +``` +$ sort --random-sort alphabet.list +d +m +p +a +[...] +``` + +每次对文件运行随机排序都会有不同的结果。 + +### 结语 + +GNU 和 BSD 的 `sort` 命令还有很多功能,所以花点时间去了解这些选项。你会惊异于 `sort` 的灵活性,尤其是当它和其他的 Unix 工具一起使用时。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/get-sorted-sort + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl "Coding on a computer" +[2]: https://en.wikipedia.org/wiki/Sort_(Unix) +[3]: https://en.wikipedia.org/wiki/POSIX +[4]: https://opensource.com/article/19/9/tac-command +[5]: https://www.gnu.org/software/coreutils/manual/html_node/shuf-invocation.html diff --git a/published/20191028 6 signs you might be a Linux user.md b/published/20191028 6 signs you might be a Linux user.md new file mode 100644 index 0000000000..42688e4e2b --- /dev/null +++ b/published/20191028 6 signs you might be a Linux user.md @@ -0,0 +1,153 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11635-1.html) +[#]: subject: (6 signs you might be a Linux user) +[#]: via: (https://opensource.com/article/19/10/signs-linux-user) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Linux 资深用户的 6 大特征 +====== + +> 如果你是 Linux 资深用户,则可能会有这些共同倾向。 + +![](https://img.linux.net.cn/data/attachment/album/201912/02/093348ek4jcyvj4wahytwq.jpg) + +Linux 用户千差万别,但是我们许多人都有一些相同的习惯。你可能没有本文列出的任何特征,而且如果你是个 Linux 新用户,你可能还不能理解这些特征…… + +下面是你可能是 Linux 用户的六个特征。 + +### 1、理所当然,纪元始于 1970 年 1 月 1 日 + +关于 Unix 计算机时钟为何在重置时总是将其设置回 1970-01-01 的传闻有很多。但有点令人感到乏味的事实是,Unix “纪元”是用于同步的通用且简单的参考点。例如,万圣节在儒略历中是今年的 304 日,但我们通常将该节日称为 “31 号”。我们知道指的是哪个月的 31 号,因为我们有个共同的参考点:我们知道万圣节在 10 月庆祝,而 10 月是一年中的第十个月,并且我们知道前面每一个月包含多少天。没有这些值,虽然我们可以使用传统的计时方法(如月相)来跟踪特殊的季节性事件,但是计算机显然不具备这种能力。 + +计算机需要确定且明确定义的值,因此将值 `1970-01-01T00:00:00Z` 选择为 Unix 纪元的开始。每当 [POSIX][2] 计算机的时间不准确时,诸如网络时间协议(NTP)之类的服务就可以向其提供自 `1970-01-01T00:00:00Z` 以来的秒数,计算机可以将其转换为人类易于识别的日期。 + +日期和时间是在计算中要追踪的著名的复杂事物,主要是因为几乎所有标准都有例外。一个月并不总是有 30 天,一年也不总是有 365 天,甚至每年有多少秒钟也往往会有所不同。如果你正在寻找一个有趣而令人沮丧的编程练习,那么请尝试编程一个可靠的日历应用程序! + +### 2、输入超过两个字母你就会觉得麻烦 + +众所周知,最常见的 Unix 命令都超简短。除了 `cd`、`ls` 和 `mv` 之类的命令外,还有一个命令简直不能再短了:`w`(它根据 `/var/run/utmp` 文件显示当前谁登录了)。 + +一方面,极短的命令似乎很不直观。新用户可能不会猜测到键入 `ls` 会列出list目录。但是,一旦学习命令,它们肯定是越短越好。如果你整天都在终端上度过,那么你键入的击键次数越少就意味着你可以有更多的时间来完成工作。 + +幸运的是,单字母命令并不太多,因此你可以使用大多数字母作为别名。例如,我经常使用 Emacs,以至于我觉得 `emacs` 的输入时间太长,因此通过将下面这行添加到 `.bashrc` 文件中,将其别名为 `e`: + +``` +alias e='emacs' +``` + +你也可以临时为命令添加别名。例如,如果你在解决网络问题时发现自己反复运行 [firewall-cmd][3],则可以为当前会话创建别名: + +``` +$ alias f='firewall-cmd' +$ f +usage: see firewall-cmd man page +No option specified. +``` + +只要你打开着终端,你的别名就会一直存在。当终端一旦关闭,它便会被遗忘。 + +### 3、做任何事都不应该单击两次以上 + +Linux 用户喜欢效率。尽管并非每个 Linux 用户都总是急于完成工作,但 Linux 桌面中有一些旨在减少完成任务所需的操作数量的惯例。这里有些例子。 + +* 在 KDE 文件管理器 Dolphin 中,单击即可打开文件或目录。假定如果要选择一个文件,则可以单击并拖动,也可以 `Ctrl + 点击`。这可能会使习惯于双击所有内容的用户感到困惑,但是一旦你尝试了单击操作,通常就无法返回费力的双击操作。 +* 在大多数 Linux 桌面上,单击鼠标中键可粘贴剪贴板的最新内容。 +* 在许多 Linux 桌面上,可以通过按 `Alt`、`Ctrl` 或 `Shift` 键来修改拖动动作。例如,`Alt + 拖动` 在 KDE 中移动窗口,而 GNOME 中的 `Ctrl + 拖动` 会复制文件而不是移动。 + +### 4、任何操作你都不会执行三次以上,因为第三次时你已经将它自动化了 + +请原谅我有点夸张,但是许多 Linux 用户期望他们的计算机比他们更努力地工作。虽然学习如何自动执行常见任务需要花费时间,但在 Linux 上它往往比在其它平台上更容易,因为 Linux 终端和 Linux 操作系统是如此紧密地集成在一起。最容易自动化的是你在终端中已经执行的操作,因为命令只是你在解释器中键入的字符串,而该解释器(终端)不会在乎你是手动键入字符串还是将其指向一个脚本。 + +例如,如果你发现自己经常将一组文件从一个位置移动到另一个位置,则或许可以将相同的指令序列用作一个脚本,你可以使用单个命令来触发该脚本。假设你每天早上手动执行此操作: + +``` +$ cd Documents +$ trash reports-latest.txt +$ wget myserver.local/reports/daily/report-latest.txt +$ cp report-latest.txt reports_daily/2019-31-10.log +``` + +这是一个简单的序列,但是每天重复一次并不是消磨时间的最有效方法。做一点点抽象,你可以使用一个简单的脚本将其自动化: + +``` +#!/bin/sh + +trash $HOME/Documents/reports-latest.txt + +wget myserver.local/reports/daily/report-latest.txt \ + -P $HOME/Documents/udpates_daily/`date --iso-8601`.log + +cp $HOME/Documents/udpates_daily/`date --iso-8601`.log \ + $HOME/Documents/reports-latest.txt +``` + +你可以把你的脚本叫做 `get-reports.sh` 并在每天早晨手动启动它,或者甚至可以将其输入到 crontab 中,以便计算机可以执行此任务而无需你进行任何干预。 + +对于新用户来说,这可能会有点困扰,因为什么和什么是一体的并不总是很明显。例如,如果你经常发现自己打开图像并将其按比例缩小 50%,那么你可能习惯于执行以下操作: + +1. 打开你的照片查看器或编辑器 +2. 缩放图像 +3. 将图像导出为修改后的文件 +4. 关闭应用程序 + +如果你一天要做几次,你可能会对这种重复感到厌倦。但是,由于你是在图形用户界面(GUI)中执行这些操作的,因此你需要知道如何对 GUI 编写脚本以使其自动化。某些应用程序,例如 [GIMP][4],具有丰富的脚本接口,但是其过程显然不同于仅修改一堆命令并将其存储到文件中那么简单。 + +再说一次,有时在命令行中有与你在 GUI 中所做的等效的操作。将文档从一种文本格式转换为另一种格式可以使用 [Pandoc][5],处理图像可以使用 [Image Magick][6],音乐和视频也可以通过命令行进行编辑和转换,等等。最大的问题是你需要知道要查找什么,通常是学习新的(有时是复杂的)命令。但是,在终端中按比例缩小图像比在 GUI 中显然更简单: + +``` +#!/bin/sh + +convert "${1}" -scale 50% `basename "${1}" .jpg`_50.jpg +``` + +这些麻烦、重复的任务值得研究。你永远不知道你的工作让计算机做起来是有多么的简单和快捷! + +### 5、发行版之间跳来跳去 + +我在家里是一个热情的 Slackware 用户,而在工作时是一个 RHEL 用户。实际上,这不是事实,我现在在工作时是 Fedora 用户。除了有时候我使用 CentOS,偶尔我还会运行 [Mageia][7]。 + +![Debian on a PowerPC64 box, image CC BY SA Claudio Miranda][8] + +*运行在 PowerPC64 机器上的 Debian* + +发行版好不好无关紧要,成为 Linux 用户的极致乐趣之一是可以自由决定运行哪个发行版。乍一看,它们基本相同,令人耳目一新。但是根据你的心情,你可能更喜欢 CentOS 的稳定性而不是 Fedora 的不断更新,或者你可能有一天会真正享受 Mageia 的集中控制中心,然后又对原始的 [Debian][9] 配置文件进行模块化乐在其中,而有时你又会完全转向其他操作系统。 + +![OpenBSD, image CC BY SA Claudio Miranda][10] + +*OpenBSD,不是 Linux 发行版* + +关键是,Linux 发行版是激情项目,成为其他人的开源激情的一部分很有趣。 + +### 6、你对开源充满热情 + +无论你的经验如何,如果你是 Linux 用户,那么你无疑会对开源充满热情。无论你是每天通过[共创艺术品] [11]还是代码来表达你的热情,还是将其升华到只在自由而自在的环境中完成工作,你都生活并构筑于开源之上。因为有了千千万万个你,所以有了开源社区,社区因你而变得更加丰富。 + +有太多的东西我没有提到。作为 Linux 用户,还有什么可以出卖你的身份?让我们在评论中知道! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/signs-linux-user + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tux_linux_penguin_code_binary.jpg?itok=TxGxW0KY (Tux with binary code background) +[2]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains +[3]: https://opensource.com/article/19/7/make-linux-stronger-firewalls +[4]: https://www.gimp.org/ +[5]: https://opensource.com/article/19/5/convert-markdown-to-word-pandoc +[6]: https://opensource.com/article/17/8/imagemagick +[7]: http://mageia.org +[8]: https://opensource.com/sites/default/files/uploads/debian.png (Debian on a PowerPC64 box) +[9]: http://debian.org +[10]: https://opensource.com/sites/default/files/uploads/openbsd.jpg (OpenBSD) +[11]: http://freesvg.org diff --git a/published/20191028 How to remove duplicate lines from files with awk.md b/published/20191028 How to remove duplicate lines from files with awk.md new file mode 100644 index 0000000000..8a5148e708 --- /dev/null +++ b/published/20191028 How to remove duplicate lines from files with awk.md @@ -0,0 +1,222 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11666-1.html) +[#]: subject: (How to remove duplicate lines from files with awk) +[#]: via: (https://opensource.com/article/19/10/remove-duplicate-lines-files-awk) +[#]: author: (Lazarus Lazaridis https://opensource.com/users/iridakos) + +怎样使用 awk 删掉文件中重复的行 +====== + +> 学习怎样使用 awk 的 `!visited[$0]++` 在不重新排序或改变原排列顺序的前提下删掉重复的行。 + +![](https://img.linux.net.cn/data/attachment/album/201912/12/124322vwe3tq3wlw33tw1f.jpg) + +假设你有一个文本文件,你需要删掉所有重复的行。 + +### TL;DR + +*要保持原来的排列顺序*删掉重复行,使用: + +``` +awk '!visited[$0]++' your_file > deduplicated_file +``` + +### 工作原理 + +这个脚本维护一个关联数组,索引(键)为文件中去重后的行,每个索引对应的值为该行出现的次数。对于文件的每一行,如果这行(之前)出现的次数为 0,则值加 1,并打印这行,否则值加 1,不打印这行。 + +我之前不熟悉 `awk`,我想弄清楚这么短小的一个脚本是怎么实现的。我调研了下,下面是调研心得: + +* 这个 awk “脚本” `!visited[$0]++` 对输入文件的*每一行*都执行。 +* `visited[]` 是一个[关联数组][2](又名[映射][3])类型的变量。`awk` 会在第一次执行时初始化它,因此我们不需要初始化。 +* `$0` 变量的值是当前正在被处理的行的内容。 +* `visited[$0]` 通过与 `$0`(正在被处理的行)相等的键来访问该映射中的值,即出现次数(我们在下面设置的)。 +* `!` 对表示出现次数的值取反: + * 在 `awk` 中,[任意非零的数或任意非空的字符串的值是 `true`][4]。 + * [变量默认的初始值为空字符串][5],如果被转换为数字,则为 0。 + * 也就是说: + * 如果 `visited[$0]` 的值是一个比 0 大的数,取反后被解析成 `false`。 + * 如果 `visited[$0]` 的值为等于 0 的数字或空字符串,取反后被解析成 `true` 。 + * `++` 表示变量 `visited[$0]` 的值加 1。 + * 如果该值为空,`awk` 自动把它转换为 `0`(数字) 后加 1。 + * 注意:加 1 操作是在我们取到了变量的值之后执行的。 + +总的来说,整个表达式的意思是: + + * `true`:如果表示出现次数为 0 或空字符串 + * `false`:如果出现的次数大于 0 + +`awk` 由 [模式或表达式和一个与之关联的动作][6] 组成: + +``` +<模式/表达式> { <动作> } +``` + +如果匹配到了模式,就会执行后面的动作。如果省略动作,`awk` 默认会打印(`print`)输入。 + +> 省略动作等价于 `{print $0}`。 + +我们的脚本由一个 `awk` 表达式语句组成,省略了动作。因此这样写: + +``` +awk '!visited[$0]++' your_file > deduplicated_file +``` + +等于这样写: + +``` +awk '!visited[$0]++ { print $0 }' your_file > deduplicated_file +``` + +对于文件的每一行,如果表达式匹配到了,这行内容被打印到输出。否则,不执行动作,不打印任何东西。 + +### 为什么不用 uniq 命令? + +`uniq` 命令仅能对相邻的行去重。这是一个示例: + +``` +$ cat test.txt +A +A +A +B +B +B +A +A +C +C +C +B +B +A +$ uniq < test.txt +A +B +A +C +B +A +``` + +### 其他方法 + +#### 使用 sort 命令 + +我们也可以用下面的 [sort][7] 命令来去除重复的行,但是*原来的行顺序没有被保留*。 + + +``` +sort -u your_file > sorted_deduplicated_file +``` + +#### 使用 cat + sort + cut + +上面的方法会产出一个去重的文件,各行是基于内容进行排序的。[通过管道连接命令][8]可以解决这个问题。 + + +``` +cat -n your_file | sort -uk2 | sort -nk1 | cut -f2- +``` + +**工作原理** + +假设我们有下面一个文件: + +``` +abc +ghi +abc +def +xyz +def +ghi +klm +``` + +`cat -n test.txt` 在每行前面显示序号: + +``` +1       abc +2       ghi +3       abc +4       def +5       xyz +6       def +7       ghi +8       klm +``` + +`sort -uk2` 基于第二列(`k2` 选项)进行排序,对于第二列相同的值只保留一次(`u` 选项): + +``` +1       abc +4       def +2       ghi +8       klm +5       xyz +``` + +`sort -nk1` 基于第一列排序(`k1` 选项),把列的值作为数字来处理(`-n` 选项): + +``` +1       abc +2       ghi +4       def +5       xyz +8       klm +``` + +最后,`cut -f2-` 从第二列开始打印每一行,直到最后的内容(`-f2-` 选项:留意 `-` 后缀,它表示这行后面的内容都包含在内)。 + +``` +abc +ghi +def +xyz +klm +``` + +### 参考 + +* [GNU awk 用户手册][9] +* [awk 中的数组][2] +* [Awk — 真值][4] +* [Awk 表达式][5] +* [Unix 怎么删除文件中重复的行?][10] +* [不用排序去掉重复的行(去重)][11] +* ['!a[$0]++' 工作原理][12] + +以上为全文。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/remove-duplicate-lines-files-awk + +作者:[Lazarus Lazaridis][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/iridakos +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: http://kirste.userpage.fu-berlin.de/chemnet/use/info/gawk/gawk_12.html +[3]: https://en.wikipedia.org/wiki/Associative_array +[4]: https://www.gnu.org/software/gawk/manual/html_node/Truth-Values.html +[5]: https://ftp.gnu.org/old-gnu/Manuals/gawk-3.0.3/html_chapter/gawk_8.html +[6]: http://kirste.userpage.fu-berlin.de/chemnet/use/info/gawk/gawk_9.html +[7]: http://man7.org/linux/man-pages/man1/sort.1.html +[8]: https://stackoverflow.com/a/20639730/2292448 +[9]: https://www.gnu.org/software/gawk/manual/html_node/ +[10]: https://stackoverflow.com/questions/1444406/how-can-i-delete-duplicate-lines-in-a-file-in-unix +[11]: https://stackoverflow.com/questions/11532157/remove-duplicate-lines-without-sorting +[12]: https://unix.stackexchange.com/questions/159695/how-does-awk-a0-work/159734#159734 +[13]: https://opensource.com/sites/default/files/uploads/duplicate-cat.jpg (Duplicate cat) +[14]: https://iridakos.com/about/ +[15]: http://creativecommons.org/licenses/by-nc/4.0/ diff --git a/published/20180810 Use Plank On Multiple Monitors Without Creating Multiple Docks With autoplank.md b/published/201911/20180810 Use Plank On Multiple Monitors Without Creating Multiple Docks With autoplank.md similarity index 100% rename from published/20180810 Use Plank On Multiple Monitors Without Creating Multiple Docks With autoplank.md rename to published/201911/20180810 Use Plank On Multiple Monitors Without Creating Multiple Docks With autoplank.md diff --git a/published/201911/20181109 Must-Have Tools for Writers on the Linux Platform.md b/published/201911/20181109 Must-Have Tools for Writers on the Linux Platform.md new file mode 100644 index 0000000000..c82c4f1fe2 --- /dev/null +++ b/published/201911/20181109 Must-Have Tools for Writers on the Linux Platform.md @@ -0,0 +1,101 @@ +Linux 平台上的写作者必备工具 +====== + +![](https://img.linux.net.cn/data/attachment/album/201911/25/000129eee2zydelz22vj9h.jpg) + +我从事作家已有 20 多年了。我撰写了数千篇有关各种技术主题的文章和指南,并撰写了 40 多本小说。因此,书面文字不仅对我很重要,还很熟悉,成为了我的第二种自然交流的方式。在过去的二十年中(而且还在继续),我几乎都是在 Linux 平台上完成的所有工作。我必须承认,在早期,这并不总是那么容易。格式并不总是与编辑器所需要的相吻合,在某些情况下,开源平台根本没有完成工作所需的必要工具。 + +那时已经过去,现在已经不同了。 + +Linux 演进和基于 Web 的工具的相得益彰使得它可以让任何写作者都能在 Linux 上完成工作(并且做得很好)。但是你需要什么工具?你可能会惊讶地发现,在某些情况下,使用 100% 开源的工具无法有效完成这项工作。不过即使如此,工作总是可以完成的。让我们来看看我作为技术作家和小说作者一直使用的工具。我将通过小说和非小说类的写作过程来概述这一点(因为过程不同,需要特定的工具)。 + +对认真的 Linux 硬核用户预先做个预警。很久以前,我就放弃了使用 LaTeX 和 DocBook 之类的工具进行写作。为什么?因为对我而言,重点必须放在内容上,而不是过程上。当你面临最后期限时,必须以效率为先。 + +### 非小说类 + +我们将从非虚构写作入手,因为这是两者中较简单的过程。为了编写技术指南,我与不同的编辑人员合作,并且在某些情况下,必须将内容复制/粘贴到 CMS 中。但是就像我的小说一样,整个过程总是从 Google 云端硬盘开始。在这一点上,许多开源纯粹主义者会转身走开。不用担心,你始终可以选择将所有文件保存在本地,也可以使用更开放友好的云服务(例如 [Zoho][1] 或 [nextCloud][2])。 + +为什么要从云端开始?多年来,我发现我需要能够随时随地访问那些内容。最简单的解决方案是迁移到云上。我对丢失工作成果这件事也很偏执。为此,我使用了 [Insync][3] 之类的工具来使我的 Google 云端硬盘与桌面保持同步。有了桌面同步功能,我知道我的工作成果总是有备份,以防万一 Google 云端硬盘出了问题。 + +对于那些我必须与之一起将内容输入到内容管理系统(CMS)的客户,该过程到此结束。我可以直接从 Google 文档复制/粘贴到 CMS 中,并完成此操作。当然,对于技术内容,总是涉及到屏幕截图。为此,我使用 [Gimp][4],它使得截取屏幕截图变得简单: + +![screenshot with Gimp][6] + +*图 1:使用 Gimp 截屏。* + +1. 打开 Gimp。 +2. 单击“文件>创建>屏幕快照”。 +3. 选择单个窗口、整个屏幕或要抓取的区域(图 1)。 +4. 单击“抓取”。 + +我的大多数客户倾向于使用 Google 文档,因为我可以共享文件夹,以便他们可以可靠地访问该内容。我有一些无法使用 Google 文档的客户,因此我必须将文件下载为可以使用的格式。为此,我要做的是下载 .odt 格式,以 [LibreOffice][8] 打开文档(图 2),根据需要设置格式,保存为客户所需的格式,然后发送文档。 + +![Google Doc][10] + +*图 2:在 LibreOffice 中打开我下载的 Google 文档。* + +非小说类作品这样就行了。 + +### 小说类 + +这里会稍微变得有点复杂。开始的步骤是相同的​​,因为我总是在 Google 文档中写小说的每个初稿。完成后,我将文件下载到 Linux 桌面,在 LibreOffice 中打开文件,根据需要设置格式,然后另存为编辑器支持的文件类型(不幸的是,这意味着是 .docx)。 + +该过程的下一步变得有些琐碎。我的编辑更喜欢使用注释来跟踪更改(因为这使我们俩阅读文档和做出更改一样容易)。因此,一个 60k 的 word 文档可以包含成百上千的注释,这会使 LibreOffice 慢的像爬一样。从前,你可以增加用于文档的内存,但是从 LibreOffice 6 开始,这不再可行。这意味着任何较大的、像小说一样长的、带有大量注释的文档都将无法使用。因此,我不得不采取一些极端的措施,使用 [WPS Office][11](图 3)。尽管这不是开源解决方案,但 WPS Office 在文档中包含大量注释的情况下做得很好,因此无需处理 LibreOffice 所带来的麻烦(当处理带有数百个注释的大型文件时)。 + +![comments][13] + +*图 3:WPS 可以轻松处理大量注释。* + +一旦我和我的编辑完成了对书的编辑(所有评论都已删除),我就可以在 LibreOffice 中打开文件进行最终格式化。格式化完成后,我将文件保存为 .html 格式,然后以 [Calibre][14] 打开文件以将文件导出为 .mobi 和 .epub 格式。 + +对于希望在 Amazon、Barnes&Noble、Smashwords 或其他平台上出版的任何人,Calibre 都是必备工具。Caliber 比其他类似解决方案更好地方是,它使你可以直接编辑 .epub 文件(图 4)。对于 Smashword 来说,这是绝对必要的(因为导出过程将添加 Smashwords 转换工具上不接受的元素)。 + +![Calibre][16] + +*图 4:直接在 Calibre 中编辑 epub 文件。* + +写作过程结束后(或有时在等待编辑完成一校时),我将开始为书制作封面。该任务完全在 Gimp 中处理(图 5)。 + +![Using Gimp][19] + +*图 5:在 Gimp 中创建 POTUS 的封面。* + +这样就完成了在 Linux 平台上创建小说的过程。由于文档的篇幅以及某些编辑人员的工作方式,与创建非小说类的过程相比,它可能会变得有些复杂,但这远没有挑战性。实际上,在 Linux 上创建小说与其他平台一样简单(并且更可靠)。 + +### 希望这可以帮助你 + +我希望这可以帮助有抱负的作家有信心在 Linux 平台上进行写作。还有许多其他工具可供使用,但是多年来我在这里列出的工具很好地服务了我。而且,尽管我确实使用了几个专有的工具,但只要它们在 Linux 上都能正常运行,我觉得是可以的。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/2018/11/must-have-tools-writers-linux-platform + +作者:[Jack Wallen][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/jlwallen +[b]: https://github.com/lujun9972 +[1]: https://www.zoho.com/ +[2]: https://nextcloud.com/ +[3]: https://www.insynchq.com +[4]: https://www.gimp.org/ +[5]: /files/images/writingtools1jpg +[6]: https://lcom.static.linuxfound.org/sites/lcom/files/writingtools_1.jpg (screenshot with Gimp) +[7]: /licenses/category/used-permission +[8]: https://www.libreoffice.org/ +[9]: /files/images/writingtools2jpg +[10]: https://lcom.static.linuxfound.org/sites/lcom/files/writingtools_2.jpg (Google Doc) +[11]: https://www.wps.com/en-US/ +[12]: /files/images/writingtools3jpg +[13]: https://lcom.static.linuxfound.org/sites/lcom/files/writingtools_3.jpg (comments) +[14]: https://calibre-ebook.com/ +[15]: /files/images/writingtools4jpg +[16]: https://lcom.static.linuxfound.org/sites/lcom/files/writingtools_4.jpg (Calibre) +[17]: /licenses/category/creative-commons-zero +[18]: /files/images/writingtools5jpg +[19]: https://lcom.static.linuxfound.org/sites/lcom/files/writingtools_5.jpg (Using Gimp) +[20]: https://training.linuxfoundation.org/training/introduction-to-open-source-development-git-and-linux/?utm_source=linux.com&utm_medium=article&utm_campaign=lfd201 diff --git a/published/201911/20190328 Can Better Task Stealing Make Linux Faster.md b/published/201911/20190328 Can Better Task Stealing Make Linux Faster.md new file mode 100644 index 0000000000..338343daee --- /dev/null +++ b/published/201911/20190328 Can Better Task Stealing Make Linux Faster.md @@ -0,0 +1,77 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11607-1.html) +[#]: subject: (Can Better Task Stealing Make Linux Faster?) +[#]: via: (https://www.linux.com/blog/can-better-task-stealing-make-linux-faster) +[#]: author: (Oracle ) + +更好的任务窃取可以使 Linux 更快吗? +====== + +![](https://img.linux.net.cn/data/attachment/album/201911/23/235729l71755he6e4mpvkq.jpg) + +> Oracle Linux 内核开发人员 Steve Sistare 参与了这场有关内核调度程序改进的讨论。 + +### 通过可扩展的任务窃取进行负载平衡 + +Linux 任务调度程序通过将唤醒的任务推送到空闲的 CPU,以及在 CPU 空闲时从繁忙的 CPU 中拉取任务来平衡整个系统的负载。在大型系统上的推送侧和拉取侧,有效的伸缩都是挑战。对于拉取,调度程序搜索连续的更大范围中的所有 CPU,直到找到过载的 CPU,然后从最繁忙的组中拉取任务。这代价非常昂贵,在大型系统上要花费 10 到 100 微秒,因此搜索时间受到平均空闲时间的限制,并且某些范围不会被搜索。并非总能达到平衡,而且闲置的 CPU 依旧闲置。 + +我实现了一种备用机制,该机制在 `idle_balance()` 中的现有搜索中自身受限并且没有找到之后被调用。我维护了一个过载的 CPU 的位图,当可运行的 CFS 任务计数超过 1 时,CPU 会设置该位。这个位图是稀疏的,每个高速缓存线的有效位数量有限。当许多线程同时设置、清除和访问元素时,这可以减少缓存争用。每个末级缓存都有一个位图。当 CPU 空闲时,它将搜索该位图以查找第一个具有可迁移任务的过载 CPU,然后将其窃取。这种简单的窃取会比单独的 `idle_balance()` 产生更高的 CPU 利用率,因为该搜索的成本很便宜,花费 1 到 2 微秒,因此每次 CPU 即将空闲时都可以调用它。窃取不会减轻全局最繁忙的队列的负担,但是它比根本不执行任何操作要好得多。 + +### 结果 + +偷窃仅在调度程序代码中占用少量 CPU 开销即可提高利用率。在以下实验中,以不同数量的组(每个组 40 个任务)运行 hackbench,并对每次运行结果显示 `/proc/schedstat` 中的增量(按 CPU 平均),并增加了这些非标准的统计信息: + +* `%find`:在旧函数和新函数中花费的时间百分比,这些函数用于搜索空闲的 CPU 和任务以窃取并设置过载的 CPU 位图。 +* `steal`:任务从另一个 CPU 窃取的次数。经过的时间增加了 8% 到 36%,最多增加了 0.4% 的发现时间。 + +![load balancing][1] + +​​如下图的绿色曲线所示,新内核的 CPU 繁忙利用率接近 100%,作为比较的基线内核是橙色曲线: +​​ +![][3] + +根据负载的不同,窃取可将 Oracle 数据库 OLTP 性能提高多达 9%,并且我们已经看到 MySQL、Pgsql、gcc、Java 和网络方面有了一些不错的改进。通常,窃取对上下文切换率高的工作负载最有帮助。 + +### 代码 + +截至撰写本文时,这项工作尚未完成,但最新的修补程序系列位于 [https://lkml.org/lkml/2018/12/6/1253][4]。如果你的内核是使用 `CONFIG_SCHED_DEBUG=y` 构建的,则可以使用以下命令验证其是否包含窃取优化: + +``` +# grep -q STEAL /sys/kernel/debug/sched_features && echo Yes +Yes +``` + +如果要尝试使用,请注意,对于具有 2 个以上 NUMA 节点的系统,禁用了窃取功能,因为 hackbench 在此类系统上发生了回归,正如我在 [https://lkml.org/lkml/2018/12/6/1250][5] 中解释的那样。但是,我怀疑这种影响是特定于 hackbench 的,并且窃取将有助于多节点系统上的其他工作负载。要尝试使用它,请用内核参数 `sched_steal_node_limit=8`(或更大)重新启动。 + +### 进一步工作 + +在将基本盗用算法推向上游之后,我正在考虑以下增强功能: + +* 如果在末级缓存中进行窃取找不到候选者,在 LLC 和 NUMA 节点之间进行窃取。 +* 维护稀疏位图以标识 RT 调度类中的偷窃候选者。当前 `pull_rt_task()` 搜索所有运行队列。 +* 从 `idle_balance()` 中删除核心和套接字级别,因为窃取会处理这些级别。当支持跨 LLC 窃取时,完全删除 `idle_balance()`。 +* 维护位图以标识空闲核心和空闲 CPU,以实现推平衡。 + +这篇文章最初发布于 [Oracle Developers Blog][6]。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/can-better-task-stealing-make-linux-faster + +作者:[Oracle][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/author/oracle/ +[b]: https://github.com/lujun9972 +[1]: https://lcom.static.linuxfound.org/sites/lcom/files/linux-load-balancing.png (load balancing) +[3]: https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/b7a700fe-edc3-4ea0-876a-c91e1850b59b/Image/00c074f4282bcbaf0c10dd153c5dfa76/steal_graph.png +[4]: https://lkml.org/lkml/2018/12/6/1253 +[5]: https://lkml.org/lkml/2018/12/6/1250 +[6]: https://blogs.oracle.com/linux/can-better-task-stealing-make-linux-faster diff --git a/published/20190404 Why blockchain (might be) coming to an IoT implementation near you.md b/published/201911/20190404 Why blockchain (might be) coming to an IoT implementation near you.md similarity index 100% rename from published/20190404 Why blockchain (might be) coming to an IoT implementation near you.md rename to published/201911/20190404 Why blockchain (might be) coming to an IoT implementation near you.md diff --git a/published/20190610 Why containers and Kubernetes have the potential to run almost anything.md b/published/201911/20190610 Why containers and Kubernetes have the potential to run almost anything.md similarity index 100% rename from published/20190610 Why containers and Kubernetes have the potential to run almost anything.md rename to published/201911/20190610 Why containers and Kubernetes have the potential to run almost anything.md diff --git a/published/201911/20190718 What you need to know to be a sysadmin.md b/published/201911/20190718 What you need to know to be a sysadmin.md new file mode 100644 index 0000000000..02361c4766 --- /dev/null +++ b/published/201911/20190718 What you need to know to be a sysadmin.md @@ -0,0 +1,122 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11608-1.html) +[#]: subject: (What you need to know to be a sysadmin) +[#]: via: (https://opensource.com/article/19/7/be-a-sysadmin) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +你需要知道什么才能成为系统管理员? +====== + +> 通过获得这些起码的能力,开始你的系统管理员职业。 + +![](https://img.linux.net.cn/data/attachment/album/201911/24/103900w5m09jyyyeyrnovu.jpg) + +昔日的系统管理员整天都在调教用户和摆弄服务器,一天的时间都奔波在几百米长的电缆之间。随着云计算、容器和虚拟机的复杂性的增加,而今依然如此。 + +以外行人来看,很难准确确定系统管理员的确切职能,因为他们在许多地方都扮演着一个不起眼的角色。没人能在培训中知道自己工作中所需要的一切知识,但是每个人其实都需要一个坚实的基础。如果你想走上系统管理的道路,那么这是你个人自学或在正式培训中应重点关注的内容。 + +### Bash + +当你学习 Bash Shell 时,你学习的不仅是 Bash Shell,你学习的也是 Linux、BSD、MacOS 甚至Windows(在适当条件下)的通用界面。你将了解语法的重要性,因此可以快速适应思科路由器的命令行或微软 PowerShell 等系统,最终你甚至可以学习更强大的语言,如 Python 或 Go。而且,你还会开始进行程序性思考,以便可以分析复杂的问题并将其分解为单个组件,这很关键,因为这就是系统(例如互联网、组织的内部网、Web 服务器、备份解决方案)是如何设计的。 + +不止于此,还有更多。 + +由于最近 DevOps 和[容器][2]的发展趋势,了解 Bash shell 变得尤为重要。你的系统管理员职业可能会将你带入一个视基础设施为代码的世界,这通常意味着你必须了解脚本编写的基础知识、[基于 YAML][3]配置的结构,以及如何与[容器][5](运行在[沙盒文件][6]内部的微型 Linux 系统)[交互][4]。你会知道 Bash 是高效管理激动人心的开源技术的门户,因此请进入 [Bash][7] 世界吧。 + +#### 资源 + +有很多方法可以在 Bash shell 中进行练习。 + +尝试一下[便携式 Linux 发行版][8]。你无需安装 Linux 即可使用 Linux,因此,请拿一块闲置的 U 盘,花个晚上或周末的空闲时光,来适应基于文本的界面。 + +这里有[几篇很棒的][10] [Bash 文章][9]。 + +要注意的是 Bash 练习的关键在于要练习,你必须有要做的练习才行。而且,在你知道如何使用 Bash 之前,你可能不知道该练习什么。如果是这样,请去 Over The Wire 玩一下 [Bandit][11] 游戏。这是一款针对绝对初学者的游戏,具有 34 个级别的交互式基本技巧,可让你熟悉 Linux shell。 + +### Web 服务器设置 + +一旦你习惯了 Bash,你应该尝试设置一个 Web 服务器。并不是所有的系统管理员都会四处设置 Web 服务器甚至维护 Web 服务器,但是你在安装和启动 HTTP 守护程序、配置 Apache 或 Nginx,设置[正确权限][12]和[配置防火墙][13]时所掌握的技能是你每天都需要使用的技能。经过一些努力,你可能会开始注意到自己的某些工作模式。在尝试管理可用于生产环境的软件和硬件之前,你可能认为某些概念是理所当然的,而你在成为新手的管理员角色时,将不再受到它们的影响。起初这可能会令人沮丧,因为每个人都喜欢在自己做好所做的事情,但这实际上是一件好事。让自己接触新技能,那就是你学习的方式。 + +此外,你在第一步中付出的努力越多,最终当你在默认的 index.html 上看到胜利的“it works!”就越甜蜜! + +#### 资源 + +David Both 撰写了有关 [Apache Web 服务器][14]配置的出色文章。值得一提的是,请逐步阅读他的后续文章,其中介绍了如何在一台计算机上[托管多个站点][15]。 + +### DHCP + +动态主机配置协议(DHCP)是为网络上的设备分配 IP 地址的系统。在家里,ISP(互联网服务提供商)支持的调制解调器或路由器可能内置了 DHCP 服务器,因此可能不在你的权限范围内。如果你曾经登录家用路由器来调整 IP 地址范围或为某些网络设备设置了静态地址,那么你至少对该概念有所了解。你可能会将其理解为对网络上的设备分配了一种 IP 地址形式的电话号码,并且你可能会意识到计算机之间通过广播发送到特定 IP 地址的消息彼此进行通信。消息标头由路径上的路由器读取,每个消息标头都将消息定向到路径上的第二个逻辑路由器,以达到其最终目标。 + +即使你了解了这些概念,要从对 DHCP 的基本了解再进一步是架设 DHCP 服务器。安装和配置自己的 DHCP 服务器可能会导致家庭网络中的 DHCP 冲突(如果可以的话,请尽量避免这样做,因为它肯定会干掉你的网络,直到解决为止),要控制地址的分配、创建子网,并监控连接和租赁时间。 + +更重要的是,设置 DHCP 并尝试不同的配置有助于你了解网络之间的关系。你会了解网络如何在数据传输中表示“分区”,以及必须采取哪些步骤才能将信息从一个网络传递到另一个。这对于系统管理员来说至关重要,因为网络肯定是工作中最重要的方面之一。 + +#### 资源 + +在运行自己的 DHCP 服务器之前,请确保家庭路由器(如果有)中的 DHCP 服务器处于非活动状态。一旦启动并运行了 DHCP 服务器,请阅读 Archit Modi 的[网络命令指南][16],以获取有关如何探索网络的提示。 + +### 网络电缆 + +这听起来很普通,但是熟悉网络电缆的工作方式不仅使你的周末变得非常有趣,而且还使你对数据是如何通过缆线的得到了全新的了解。最好的学习方法是去当地的业余爱好商店并购买五类线剥线钳和压线钳以及一些五类线水晶头。然后回家,拿一根备用的以太网电缆,切断水晶头,花一些时间重新制作网线接头,将电缆重新投入使用。 + +解决了这个难题后,请再做一次,这次创建一条有效的[交叉电缆][17]。 + +你现在应该还在沉迷于有关电缆管理。如果你有些强迫症,喜欢沿着地板线或桌子的边缘整齐地排列电缆,或者将电缆绑在一起以保持它们的整齐有序,那么就可以使自己免受永久混乱的电缆困扰。你一开始可能不会理解这样做的必要性,但是当你第一次走进服务器机房时,你会马上知道原因。 + +### Ansible + +[Ansible][18] 是配置管理软件,它在系统管理员和 DevOps 之间架起了一座桥梁。系统管理员使用 Ansible 来配置全新安装的操作系统并在计算机上维护特定的状态。DevOps 使用 Ansible 减少了在工具上花费的时间和精力,从而在开发上可以花费更多的时间和精力。作为系统管理员培训的一部分,你应该学习 Ansible,并着眼于 DevOps 实践,因为 DevOps 现在开创的大多数功能将最终成为将来系统管理中工作流的一部分。 + +Ansible 的好处是你可以立即开始使用它。它是跨平台的,并且可以向上和向下缩放。对于单用户计算机, Ansible 可能是小题大做,但是话又说回来,Ansible 可能会改变你启动虚拟机的方式,或者可以帮助你同步家庭或[家庭实验室][19]中所有计算机的状态。 + + +#### 资源 + +阅读 Jay LaCroix 的[如何使用 Ansible 管理工作站配置][20]中的典型介绍,以轻松地在日常之中开始使用 Ansible。 + +### 破坏 + +由于用户的错误、软件的错误、管理员(就是你!)的错误以及许多其他因素,计算机上会出现问题。无法预测将要失败的原因,因此你的个人系统管理员培训制度的一部分应该是破坏你设置的系统,直到它们失败为止。你自己的实验室基础设施越是脆弱,发现弱点的可能性就越大。而且,你越是经常修复这些弱点,你对解决问题的能力就越有信心。 + +除了严格设置所有常见的软件和硬件之外,作为系统管理员的主要工作是查找解决方案。有时候,你可能会遇到职位描述之外的问题,甚至可能无法解决,但这完全取决于你的解决方法。 + +现在,你越多地折腾并努力加以解决,则以系统管理员的身份进行的准备就越充分。 + +你是系统管理员吗?你是否希望自己为更好的任务做好准备?在下面的评论中写下它们! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/be-a-sysadmin + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux11x_cc.png?itok=XMDOouJR (People work on a computer server with devices) +[2]: https://opensource.com/article/19/6/kubernetes-dump-truck +[3]: https://www.redhat.com/sysadmin/yaml-tips +[4]: https://opensource.com/article/19/6/how-ssh-running-container +[5]: https://opensource.com/resources/what-are-linux-containers +[6]: https://opensource.com/article/18/11/behind-scenes-linux-containers +[7]: https://opensource.com/article/18/7/admin-guide-bash +[8]: https://opensource.com/article/19/6/linux-distros-to-try +[9]: https://opensource.com/tags/bash +[10]: https://www.redhat.com/sysadmin/managing-files-linux-terminal +[11]: http://overthewire.org/wargames/bandit +[12]: https://opensource.com/article/19/6/understanding-linux-permissions +[13]: https://www.redhat.com/sysadmin/secure-linux-network-firewall-cmd +[14]: https://opensource.com/article/18/2/how-configure-apache-web-server +[15]: https://opensource.com/article/18/3/configuring-multiple-web-sites-apache +[16]: https://opensource.com/article/18/7/sysadmin-guide-networking-commands +[17]: https://en.wikipedia.org/wiki/Ethernet_crossover_cable +[18]: https://opensource.com/sitewide-search?search_api_views_fulltext=ansible +[19]: https://opensource.com/article/19/6/create-centos-homelab-hour +[20]: https://opensource.com/article/18/3/manage-workstation-ansible diff --git a/published/20190801 Linux permissions 101.md b/published/201911/20190801 Linux permissions 101.md similarity index 100% rename from published/20190801 Linux permissions 101.md rename to published/201911/20190801 Linux permissions 101.md diff --git a/published/20190822 11 Essential Keyboard Shortcuts Google Chrome-Chromium Users Should Know.md b/published/201911/20190822 11 Essential Keyboard Shortcuts Google Chrome-Chromium Users Should Know.md similarity index 100% rename from published/20190822 11 Essential Keyboard Shortcuts Google Chrome-Chromium Users Should Know.md rename to published/201911/20190822 11 Essential Keyboard Shortcuts Google Chrome-Chromium Users Should Know.md diff --git a/published/20190826 How RPM packages are made- the source RPM.md b/published/201911/20190826 How RPM packages are made- the source RPM.md similarity index 100% rename from published/20190826 How RPM packages are made- the source RPM.md rename to published/201911/20190826 How RPM packages are made- the source RPM.md diff --git a/published/20190828 Someone Forked GIMP into Glimpse Because Gimp is an Offensive Word.md b/published/201911/20190828 Someone Forked GIMP into Glimpse Because Gimp is an Offensive Word.md similarity index 100% rename from published/20190828 Someone Forked GIMP into Glimpse Because Gimp is an Offensive Word.md rename to published/201911/20190828 Someone Forked GIMP into Glimpse Because Gimp is an Offensive Word.md diff --git a/published/20190902 How RPM packages are made- the spec file.md b/published/201911/20190902 How RPM packages are made- the spec file.md similarity index 100% rename from published/20190902 How RPM packages are made- the spec file.md rename to published/201911/20190902 How RPM packages are made- the spec file.md diff --git a/published/20190905 Building CI-CD pipelines with Jenkins.md b/published/201911/20190905 Building CI-CD pipelines with Jenkins.md similarity index 100% rename from published/20190905 Building CI-CD pipelines with Jenkins.md rename to published/201911/20190905 Building CI-CD pipelines with Jenkins.md diff --git a/published/20190906 6 Open Source Paint Applications for Linux Users.md b/published/201911/20190906 6 Open Source Paint Applications for Linux Users.md similarity index 100% rename from published/20190906 6 Open Source Paint Applications for Linux Users.md rename to published/201911/20190906 6 Open Source Paint Applications for Linux Users.md diff --git a/published/20190912 How to fix common pitfalls with the Python ORM tool SQLAlchemy.md b/published/201911/20190912 How to fix common pitfalls with the Python ORM tool SQLAlchemy.md similarity index 100% rename from published/20190912 How to fix common pitfalls with the Python ORM tool SQLAlchemy.md rename to published/201911/20190912 How to fix common pitfalls with the Python ORM tool SQLAlchemy.md diff --git a/published/201911/20191007 7 Java tips for new developers.md b/published/201911/20191007 7 Java tips for new developers.md new file mode 100644 index 0000000000..c2c90f8679 --- /dev/null +++ b/published/201911/20191007 7 Java tips for new developers.md @@ -0,0 +1,215 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11620-1.html) +[#]: subject: (7 Java tips for new developers) +[#]: via: (https://opensource.com/article/19/10/java-basics) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +给新手 Java 开发者的 7 点提示 +====== + +> 如果你才刚开始学习 Java 编程,这里有七个你需要知道的基础知识。 + +![](https://img.linux.net.cn/data/attachment/album/201911/28/120421di3744urqnyyr6xi.jpg) + +Java 是一个多功能的编程语言,在某种程度上,它用在几乎所有可能涉及计算机的行业了里。Java 的最大优势是,它运行在一个 Java 虚拟机(JVM)中,这是一个翻译 Java 代码为与操作系统兼容的字节码的层。只要有 JVM 存在于你的操作系统上 —— 不管这个操作系统是在一个服务器(或“[无服务器][2]”,也是同样的)、桌面电脑、笔记本电脑、移动设备,或嵌入式设备 —— 那么,Java 应用程序就可以运行在它上面。 + +这使得 Java 成为程序员和用户的一种流行语言。程序员知道,他们只需要写一个软件版本就能最终得到一个可以运行在任何平台上的应用程序;用户知道,应用程序可以运行在他们的计算机上,而不用管他们使用的是什么样的操作系统。 + +很多语言和框架是跨平台的,但是没有实现同样的抽象层。使用 Java,你针对的是 JVM,而不是操作系统。对于程序员,当面对一些编程难题时,这是阻力最小的线路,但是它仅在当你知道如何编程 Java 时有用。如果你刚开始学习 Java 编程,这里有你需要知道的七个基础的提示。 + +但是,首先,如果你不确定是否你安装了 Java ,你可以在一个终端(例如 [Bash][3] 或 [PowerShell][4])中找出来,通过运行: + +``` +$ java --version +openjdk 12.0.2 2019-07-16 +OpenJDK Runtime Environment 19.3 (build 12.0.2+9) +OpenJDK 64-Bit Server VM 19.3 (build 12.0.2+9, mixed mode, sharing) +``` + +如果你得到一个错误,或未返回任何东西,那么你应该安装 [Java 开发套件][5](JDK)来开始 Java 开发。或者,安装一个 Java 运行时环境(JRE),如果你只是需要来运行 Java 应用程序。 + +### 1、Java 软件包 + +在 Java 语言中,相关的类被分组到一个*软件包*中。当你下载 JDK 时所获得的 Java 基础库将被分组到以 `java` 或 `javax` 开头的软件包中。软件包提供一种类似于计算机上的文件夹的功能:它们为相关的元素提供结构和定义(以编程术语说,*命名空间*)。额外的软件包可以从独立开发者、开源项目和商业供应商获得,就像可以为任何编程语言获得库一样。 + +当你写一个 Java 程序时,你应该在你的代码是顶部声明一个软件包名称。如果你只是编写一个简单的应用程序来入门 Java,你的软件包名称可以简单地用你的项目名称。如果你正在使用一个 Java 集成开发环境,如 [Eclipse][6],当你启动一个新的项目时,它为你生成一个合乎情理的软件包名称。 + +``` +package helloworld; + +/** + * @author seth + * An application written in Java. + */ +``` + +除此之外,你可以通过查找它相对于你的项目整体的路径来确定你的软件包名称。例如,如果你正在写一组类来帮助游戏开发,并且该集合被称为 `jgamer`,那么你可能在其中有一些唯一的类。 + +``` +package jgamer.avatar; + +/** + * @author seth + * An imaginary game library. + */ +``` + +你的软件包的顶层是 `jgamer`,并且在其内部中每个软件包都是一个独立的派生物,例如 `jgamer.avatar` 和 `jgamer.score` 等等。在你的文件系统里,其目录结构反映了这一点,`jgamer` 是包含文件 `avatar.java` 和 `score.java` 的顶级目录。 + +### 2、Java 导入 + +作为一名通晓多种语言的程序员,最大的乐趣是找出是否用 `include`、`import`、`use`、`require`,或一些其它术语来引入你不管使用何种编程语言编写的库。在 Java 中,顺便说一句,当导入你的代码的需要的库时,使用 `import` 关键字。 + +``` +package helloworld; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +/** + * @author seth + * A GUI hello world. + */ +``` + +导入是基于该环境的 Java 路径。如果 Java 不知道 Java 库存储在系统上的何处,那么,就不能成功导入。只要一个库被存储在系统的 Java 路径中,那么导入能够成功,并且库能够被用于构建和运行一个 Java 应用程序。 + +如果一个库并不在 Java 路径中(因为,例如,你正在写你自己的库),那么该库可以与你的应用程序绑定在一起(协议许可),以便导入可以按预期地工作。 + +### 3、Java 类 + +Java 类使用关键字 `public class` 声明,以及一个唯一的对应于它的文件名的类名。例如,在项目 `helloworld` 中的一个文件 `Hello.java` 中: + +``` +package helloworld; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +/** + * @author seth + * A GUI hello world. + */ + +public class Hello { +        // this is an empty class +} +``` + +你可以在一个类内部声明变量和函数。在 Java 中,在一个类中的变量被称为*字段*。 + +### 4、Java 方法 + +Java 的方法本质上是对象中的函数。基于预期返回的数据类型(例如 `void`、`int`、`float` 等等),它们被定义为 `public`(意味着它们可以被任何其它类访问)或 `private`(限制它们的使用)。 + + +``` + public void helloPrompt(ActionEvent event) { + String salutation = "Hello %s"; + + string helloMessage = "World"; + message = String.format(salutation, helloMessage); + JOptionPane.showMessageDialog(this, message); + } + + private int someNumber (x) { + return x*2; + } +``` + +当直接调用一个方法时,以其类和方法名称来引用。例如,`Hello.someNumber` 指向在 `Hello` 类中的 `someNumber` 方法。 + +### 5、static + +Java 中的 `static` 关键字使代码中的成员可以独立于包含其的对象而被访问。 + +在面向对象编程中,你编写的代码用作“对象”的模板,这些对象在应用程序运行时产生。例如,你不需要编写一个具体的窗口,而是编写基于 Java 中的窗口类的窗口实例(并由你的代码修改)。由于在应用程序生成它的实例之前,你编写的所有代码都不会“存在”,因此在创建它们所依赖的对象之前,大多数方法和变量(甚至是嵌套类)都无法使用。 + +然而,有时,在对象被通过应用程序创建前,你需要访问或使用其中的数据。(例如,除非事先知道球是红色时,应用程序无法生成一个红色的球)。对于这些情况,请使用 `static` 关键字。 + +### 6、try 和 catch + +Java 擅长捕捉错误,但是,只有你告诉它遇到错误时该做什么,它才能优雅地恢复。在 Java 中,尝试执行一个动作的级联层次结构以 `try` 开头,出现错误时回落到 `catch`,并以 `finally` 结束。如果 `try` 子句失败,则将调用 `catch`,最后,不管结果如何,总是由 `finally` 来执行一些合理的动作。这里是一个示例: + +``` +try { + cmd = parser.parse(opt, args); + + if(cmd.hasOption("help")) { + HelpFormatter helper = new HelpFormatter(); + helper.printHelp("Hello ", opt); + System.exit(0); + } + else { + if(cmd.hasOption("shell") || cmd.hasOption("s")) { + String target = cmd.getOptionValue("tgt"); + } // else + } // fi +} catch (ParseException err) { + System.out.println(err); + System.exit(1); + } //catch + finally { + new Hello().helloWorld(opt); + } //finally +} //try +``` + +这是一个健壮的系统,它试图避免无法挽回的错误,或者,至少,为你提供让用户提交有用的反馈的选项。经常使用它,你的用户将会感谢你! + +### 7、运行 Java 应用程序 + +Java 文件,通常以 `.java` 结尾,理论上说,可以使用 `java` 命令运行。然而,如果一个应用程序很复杂,运行一个单个文件是否会产生有意义的结果是另外一个问题。 + +来直接运行一个 `.java` 文件: + +``` +$ java ./Hello.java +``` + +通常,Java 应用程序以 Java 存档(JAR)文件的形式分发,以 `.jar` 结尾。一个 JAR 文件包含一个清单文件(可以指定主类、项目结构的一些元数据),以及运行应用程序所需的所有代码部分。 + +要运行一个 JAR 文件,你可以双击它的图标(取决于你的操作系统设置),你也可以从终端中启动它: + +``` +$ java -jar ./Hello.jar +``` + +### 适合所有人的 Java + +Java 是一种强大的语言,由于有了 [OpenJDK][12] 项目及其它的努力,它是一种开放式规范,允许像 [IcedTea][13]、[Dalvik][14] 和 [Kotlin][15] 项目的茁壮成长。学习 Java 是一种准备在各种行业中工作的好方法,而且,[使用 Java 的理由很多][16]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/java-basics + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_cafe_brew_laptop_desktop.jpg?itok=G-n1o1-o (Coffee and laptop) +[2]: https://www.redhat.com/en/resources/building-microservices-eap-7-reference-architecture +[3]: https://www.gnu.org/software/bash/ +[4]: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-6 +[5]: http://openjdk.java.net/ +[6]: http://www.eclipse.org/ +[7]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+actionevent +[8]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string +[9]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+joptionpane +[10]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system +[11]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+parseexception +[12]: https://openjdk.java.net/ +[13]: https://icedtea.classpath.org/wiki/Main_Page +[14]: https://source.android.com/devices/tech/dalvik/ +[15]: https://kotlinlang.org/ +[16]: https://opensource.com/article/19/9/why-i-use-java diff --git a/published/20191008 5 Best Password Managers For Linux Desktop.md b/published/201911/20191008 5 Best Password Managers For Linux Desktop.md similarity index 100% rename from published/20191008 5 Best Password Managers For Linux Desktop.md rename to published/201911/20191008 5 Best Password Managers For Linux Desktop.md diff --git a/published/20191013 How to Enable EPEL Repository on CentOS 8 and RHEL 8 Server.md b/published/201911/20191013 How to Enable EPEL Repository on CentOS 8 and RHEL 8 Server.md similarity index 100% rename from published/20191013 How to Enable EPEL Repository on CentOS 8 and RHEL 8 Server.md rename to published/201911/20191013 How to Enable EPEL Repository on CentOS 8 and RHEL 8 Server.md diff --git a/published/201911/20191018 How to use Protobuf for data interchange.md b/published/201911/20191018 How to use Protobuf for data interchange.md new file mode 100644 index 0000000000..cecba89611 --- /dev/null +++ b/published/201911/20191018 How to use Protobuf for data interchange.md @@ -0,0 +1,489 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11600-1.html) +[#]: subject: (How to use Protobuf for data interchange) +[#]: via: (https://opensource.com/article/19/10/protobuf-data-interchange) +[#]: author: (Marty Kalin https://opensource.com/users/mkalindepauledu) + +如何使用 Protobuf 做数据交换 +====== + +> 在以不同语言编写并在不同平台上运行的应用程序之间交换数据时,Protobuf 编码可提高效率。 + +![](https://img.linux.net.cn/data/attachment/album/201911/22/075757pn2fxfth30ntwefg.jpg) + +协议缓冲区Protocol Buffers([Protobufs][2])像 XML 和 JSON 一样,可以让用不同语言编写并在不同平台上运行的应用程序交换数据。例如,用 Go 编写的发送程序可以在 Protobuf 中对以 Go 表示的销售订单数据进行编码,然后用 Java 编写的接收方可以对它进行解码,以获取所接收订单数据的 Java 表示方式。这是在网络连接上的结构示意图: + +> Go 销售订单 ---> Pbuf 编码 ---> 网络 ---> Pbuf 界面 ---> Java 销售订单 + +与 XML 和 JSON 相比,Protobuf 编码是二进制而不是文本,这会使调试复杂化。但是,正如本文中的代码示例所确认的那样,Protobuf 编码在大小上比 XML 或 JSON 编码要有效得多。 + +Protobuf 以另一种方式提供了这种有效性。在实现级别,Protobuf 和其他编码系统对结构化数据进行序列化serialize反序列化deserialize。序列化将特定语言的数据结构转换为字节流,反序列化是将字节流转换回特定语言的数据结构的逆运算。序列化和反序列化可能成为数据交换的瓶颈,因为这些操作会占用大量 CPU。高效的序列化和反序列化是 Protobuf 的另一个设计目标。 + +最近的编码技术,例如 Protobuf 和 FlatBuffers,源自 1990 年代初期的 [DCE/RPC][3](分布式计算环境/远程过程调用Distributed Computing Environment/Remote Procedure Call)计划。与 DCE/RPC 一样,Protobuf 在数据交换中为 [IDL][4](接口定义语言)和编码层做出了贡献。 + +本文将着眼于这两层,然后提供 Go 和 Java 中的代码示例以充实 Protobuf 的细节,并表明 Protobuf 是易于使用的。 + +### Protobuf 作为一个 IDL 和编码层 + +像 Protobuf 一样,DCE/RPC 被设计为与语言和平台无关。适当的库和实用程序允许任何语言和平台用于 DCE/RPC 领域。此外,DCE/RPC 体系结构非常优雅。IDL 文档是一侧的远程过程与另一侧的调用者之间的协定。Protobuf 也是以 IDL 文档为中心的。 + +IDL 文档是文本,在 DCE/RPC 中,使用基本 C 语法以及元数据的语法扩展(方括号)和一些新的关键字,例如 `interface`。这是一个例子: + +``` +[uuid (2d6ead46-05e3-11ca-7dd1-426909beabcd), version(1.0)] +interface echo { +   const long int ECHO_SIZE = 512; +   void echo( +      [in]          handle_t h, +      [in, string]  idl_char from_client[ ], +      [out, string] idl_char from_service[ECHO_SIZE] +   ); +} +``` + +该 IDL 文档声明了一个名为 `echo` 的过程,该过程带有三个参数:类型为 `handle_t`(实现指针)和 `idl_char`(ASCII 字符数组)的 `[in]` 参数被传递给远程过程,而 `[out]` 参数(也是一个字符串)从该过程中传回。在此示例中,`echo` 过程不会显式返回值(`echo` 左侧的 `void`),但也可以返回值。返回值,以及一个或多个 `[out]` 参数,允许远程过程任意返回许多值。下一节将介绍 Protobuf IDL,它的语法不同,但同样用作数据交换中的协定。 + +DCE/RPC 和 Protobuf 中的 IDL 文档是创建用于交换数据的基础结构代码的实用程序的输入: + +> IDL 文档 ---> DCE/PRC 或 Protobuf 实用程序 ---> 数据交换的支持代码 + +作为相对简单的文本,IDL 是同样便于人类阅读的关于数据交换细节的文档(特别是交换的数据项的数量和每个项的数据类型)。 + +Protobuf 可用于现代 RPC 系统,例如 [gRPC][5];但是 Protobuf 本身仅提供 IDL 层和编码层,用于从发送者传递到接收者的消息。与原本的 DCE/RPC 一样,Protobuf 编码是二进制的,但效率更高。 + +目前,XML 和 JSON 编码仍在通过 Web 服务等技术进行的数据交换中占主导地位,这些技术利用 Web 服务器、传输协议(例如 TCP、HTTP)以及标准库和实用程序等原有的基础设施来处理 XML 和 JSON 文档。 此外,各种类型的数据库系统可以存储 XML 和 JSON 文档,甚至旧式关系型系统也可以轻松生成查询结果的 XML 编码。现在,每种通用编程语言都具有支持 XML 和 JSON 的库。那么,是什么让我们回到 Protobuf 之类的**二进制**编码系统呢? + +让我们看一下负十进制值 `-128`。以 2 的补码二进制表示形式(在系统和语言中占主导地位)中,此值可以存储在单个 8 位字节中:`10000000`。此整数值在 XML 或 JSON 中的文本编码需要多个字节。例如,UTF-8 编码需要四个字节的字符串,即 `-128`,即每个字符一个字节(十六进制,值为 `0x2d`、`0x31`、`0x32` 和 `0x38`)。XML 和 JSON 还添加了标记字符,例如尖括号和大括号。有关 Protobuf 编码的详细信息下面就会介绍,但现在的关注点是一个通用点:文本编码的压缩性明显低于二进制编码。 + +### 在 Go 中使用 Protobuf 的示例 + +我的代码示例着重于 Protobuf 而不是 RPC。以下是第一个示例的概述: + +* 名为 `dataitem.proto` 的 IDL 文件定义了一个 Protobuf 消息,它具有六个不同类型的字段:具有不同范围的整数值、固定大小的浮点值以及两个不同长度的字符串。 +* Protobuf 编译器使用 IDL 文件生成 Go 版本(以及后面的 Java 版本)的 Protobuf 消息及支持函数。 +* Go 应用程序使用随机生成的值填充原生的 Go 数据结构,然后将结果序列化为本地文件。为了进行比较, XML 和 JSON 编码也被序列化为本地文件。 +* 作为测试,Go 应用程序通过反序列化 Protobuf 文件的内容来重建其原生数据结构的实例。 +* 作为语言中立性测试,Java 应用程序还会对 Protobuf 文件的内容进行反序列化以获取原生数据结构的实例。 + +[我的网站][6]上提供了该 IDL 文件以及两个 Go 和一个 Java 源文件,打包为 ZIP 文件。 + +最重要的 Protobuf IDL 文档如下所示。该文档存储在文件 `dataitem.proto` 中,并具有常规的`.proto` 扩展名。 + +#### 示例 1、Protobuf IDL 文档 + +``` +syntax = "proto3"; + +package main; + +message DataItem { +  int64  oddA  = 1; +  int64  evenA = 2; +  int32  oddB  = 3; +  int32  evenB = 4; +  float  small = 5; +  float  big   = 6; +  string short = 7; +  string long  = 8; +} +``` + +该 IDL 使用当前的 proto3 而不是较早的 proto2 语法。软件包名称(在本例中为 `main`)是可选的,但是惯例使用它以避免名称冲突。这个结构化的消息包含八个字段,每个字段都有一个 Protobuf 数据类型(例如,`int64`、`string`)、名称(例如,`oddA`、`short`)和一个等号 `=` 之后的数字标签(即键)。标签(在此示例中为 1 到 8)是唯一的整数标识符,用于确定字段序列化的顺序。 + +Protobuf 消息可以嵌套到任意级别,而一个消息可以是另外一个消息的字段类型。这是一个使用 `DataItem` 消息作为字段类型的示例: + +``` +message DataItems { +  repeated DataItem item = 1; +} +``` + +单个 `DataItems` 消息由重复的(零个或多个)`DataItem` 消息组成。 + +为了清晰起见,Protobuf 还支持枚举类型: + +``` +enum PartnershipStatus { +  reserved "FREE", "CONSTRAINED", "OTHER"; +} +``` + +`reserved` 限定符确保用于实现这三个符号名的数值不能重复使用。 + +为了生成一个或多个声明 Protobuf 消息结构的特定于语言的版本,包含这些结构的 IDL 文件被传递到`protoc` 编译器(可在 [Protobuf GitHub 存储库][7]中找到)。对于 Go 代码,可以以通常的方式安装支持的 Protobuf 库(这里以 `%` 作为命令行提示符): + +``` +% go get github.com/golang/protobuf/proto +``` + +将 Protobuf IDL 文件 `dataitem.proto` 编译为 Go 源代码的命令是: + +``` +% protoc --go_out=. dataitem.proto +``` + +标志 `--go_out` 指示编译器生成 Go 源代码。其他语言也有类似的标志。在这种情况下,结果是一个名为 `dataitem.pb.go` 的文件,该文件足够小,可以将其基本内容复制到 Go 应用程序中。以下是生成的代码的主要部分: + +``` +var _ = proto.Marshal + +type DataItem struct { + OddA int64 `protobuf:"varint,1,opt,name=oddA" json:"oddA,omitempty"` + EvenA int64 `protobuf:"varint,2,opt,name=evenA" json:"evenA,omitempty"` + OddB int32 `protobuf:"varint,3,opt,name=oddB" json:"oddB,omitempty"` + EvenB int32 `protobuf:"varint,4,opt,name=evenB" json:"evenB,omitempty"` + Small float32 `protobuf:"fixed32,5,opt,name=small" json:"small,omitempty"` + Big float32 `protobuf:"fixed32,6,opt,name=big" json:"big,omitempty"` + Short string `protobuf:"bytes,7,opt,name=short" json:"short,omitempty"` + Long string `protobuf:"bytes,8,opt,name=long" json:"long,omitempty"` +} + +func (m *DataItem) Reset() { *m = DataItem{} } +func (m *DataItem) String() string { return proto.CompactTextString(m) } +func (*DataItem) ProtoMessage() {} +func init() {} +``` + +编译器生成的代码具有 Go 结构 `DataItem`,该结构导出 Go 字段(名称现已大写开头),该字段与 Protobuf IDL 中声明的名称匹配。该结构字段具有标准的 Go 数据类型:`int32`、`int64`、`float32` 和 `string`。在每个字段行的末尾,是描述 Protobuf 类型的字符串,提供 Protobuf IDL 文档中的数字标签及有关 JSON 信息的元数据,这将在后面讨论。 + +此外也有函数;最重要的是 `Proto.Marshal`,用于将 `DataItem` 结构的实例序列化为 Protobuf 格式。辅助函数包括:清除 `DataItem` 结构的 `Reset`,生成 `DataItem` 的单行字符串表示的 `String`。 + +描述 Protobuf 编码的元数据应在更详细地分析 Go 程序之前进行仔细研究。 + +### Protobuf 编码 + +Protobuf 消息的结构为键/值对的集合,其中数字标签为键,相应的字段为值。字段名称(例如,`oddA` 和 `small`)是供人类阅读的,但是 `protoc` 编译器的确使用了字段名称来生成特定于语言的对应名称。例如,Protobuf IDL 中的 `oddA` 和 `small` 名称在 Go 结构中分别成为字段 `OddA` 和 `Small`。 + +键和它们的值都被编码,但是有一个重要的区别:一些数字值具有固定大小的 32 或 64 位的编码,而其他数字(包括消息标签)则是 `varint` 编码的,位数取决于整数的绝对值。例如,整数值 1 到 15 需要 8 位 `varint` 编码,而值 16 到 2047 需要 16 位。`varint` 编码在本质上与 UTF-8 编码类似(但细节不同),它偏爱较小的整数值而不是较大的整数值。(有关详细分析,请参见 Protobuf [编码指南][8])结果是,Protobuf 消息应该在字段中具有较小的整数值(如果可能),并且键数应尽可能少,但每个字段至少得有一个键。 + +下表 1 列出了 Protobuf 编码的要点: + +编码 | 示例类型 | 长度 +---|---|--- +`varint` | `int32`、`uint32`、`int64` | 可变长度 +`fixed` | `fixed32`、`float`、`double` | 固定的 32 位或 64 位长度 +字节序列 | `string`、`bytes` | 序列长度 + +*表 1. Protobuf 数据类型* + +未明确固定长度的整数类型是 `varint` 编码的;因此,在 `varint` 类型中,例如 `uint32`(`u` 代表无符号),数字 32 描述了整数的范围(在这种情况下为 0 到 2^32 - 1),而不是其位的大小,该位大小取决于值。相比之下,对于固定长度类型(例如 `fixed32` 或 `double`),Protobuf 编码分别需要 32 位和 64 位。Protobuf 中的字符串是字节序列;因此,字段编码的大小就是字节序列的长度。 + +另一个高效的方法值得一提。回想一下前面的示例,其中的 `DataItems` 消息由重复的 `DataItem` 实例组成: + +``` +message DataItems { +  repeated DataItem item = 1; +} +``` + +`repeated` 表示 `DataItem` 实例是*打包的*:集合具有单个标签,在这里是 1。因此,具有重复的 `DataItem` 实例的 `DataItems` 消息比具有多个但单独的 `DataItem` 字段、每个字段都需要自己的标签的消息的效率更高。 + +了解了这一背景,让我们回到 Go 程序。 + +### dataItem 程序的细节 + +`dataItem` 程序创建一个 `DataItem` 实例,并使用适当类型的随机生成的值填充字段。Go 有一个 `rand` 包,带有用于生成伪随机整数和浮点值的函数,而我的 `randString` 函数可以从字符集中生成指定长度的伪随机字符串。设计目标是要有一个具有不同类型和位大小的字段值的 `DataItem` 实例。例如,`OddA` 和 `EvenA` 值分别是 64 位非负整数值的奇数和偶数;但是 `OddB` 和 `EvenB` 变体的大小为 32 位,并存放 0 到 2047 之间的小整数值。随机浮点值的大小为 32 位,字符串为 16(`Short`)和 32(`Long`)字符的长度。这是用随机值填充 `DataItem` 结构的代码段: + +``` +// 可变长度整数 +n1 := rand.Int63() // 大整数 +if (n1 & 1) == 0 { n1++ } // 确保其是奇数 +... +n3 := rand.Int31() % UpperBound // 小整数 +if (n3 & 1) == 0 { n3++ } // 确保其是奇数 + +// 固定长度浮点数 +... +t1 := rand.Float32() +t2 := rand.Float32() +... +// 字符串 +str1 := randString(StrShort) +str2 := randString(StrLong) + +// 消息 +dataItem := &DataItem { + OddA: n1, + EvenA: n2, + OddB: n3, + EvenB: n4, + Big: f1, + Small: f2, + Short: str1, + Long: str2, +} +``` + +创建并填充值后,`DataItem` 实例将以 XML、JSON 和 Protobuf 进行编码,每种编码均写入本地文件: + +``` +func encodeAndserialize(dataItem *DataItem) { + bytes, _ := xml.MarshalIndent(dataItem, "", " ") // Xml to dataitem.xml + ioutil.WriteFile(XmlFile, bytes, 0644) // 0644 is file access permissions + + bytes, _ = json.MarshalIndent(dataItem, "", " ") // Json to dataitem.json + ioutil.WriteFile(JsonFile, bytes, 0644) + + bytes, _ = proto.Marshal(dataItem) // Protobuf to dataitem.pbuf + ioutil.WriteFile(PbufFile, bytes, 0644) +} +``` + +这三个序列化函数使用术语 `marshal`,它与 `serialize` 意思大致相同。如代码所示,三个 `Marshal` 函数均返回一个字节数组,然后将其写入文件。(为简单起见,忽略可能的错误处理。)在示例运行中,文件大小为: + +``` +dataitem.xml:  262 bytes +dataitem.json: 212 bytes +dataitem.pbuf:  88 bytes +``` + +Protobuf 编码明显小于其他两个编码方案。通过消除缩进字符(在这种情况下为空白和换行符),可以稍微减小 XML 和 JSON 序列化的大小。 + +以下是 `dataitem.json` 文件,该文件最终是由 `json.MarshalIndent` 调用产生的,并添加了以 `##` 开头的注释: + +``` +{ + "oddA": 4744002665212642479, ## 64-bit >= 0 + "evenA": 2395006495604861128, ## ditto + "oddB": 57, ## 32-bit >= 0 but < 2048 + "evenB": 468, ## ditto + "small": 0.7562016, ## 32-bit floating-point + "big": 0.85202795, ## ditto + "short": "ClH1oDaTtoX$HBN5", ## 16 random chars + "long": "xId0rD3Cri%3Wt%^QjcFLJgyXBu9^DZI" ## 32 random chars +} +``` + +尽管这些序列化的数据写入到本地文件中,但是也可以使用相同的方法将数据写入网络连接的输出流。 + +### 测试序列化和反序列化 + +Go 程序接下来通过将先前写入 `dataitem.pbuf` 文件的字节反序列化为 `DataItem` 实例来运行基本测试。这是代码段,其中去除了错误检查部分: + +``` +filebytes, err := ioutil.ReadFile(PbufFile) // get the bytes from the file +... +testItem.Reset() // clear the DataItem structure +err = proto.Unmarshal(filebytes, testItem) // deserialize into a DataItem instance +``` + +用于 Protbuf 反序列化的 `proto.Unmarshal` 函数与 `proto.Marshal` 函数相反。原始的 `DataItem` 和反序列化的副本将被打印出来以确认完全匹配: + +``` +Original: +2041519981506242154 3041486079683013705 1192 1879 +0.572123 0.326855 +boPb#T0O8Xd&Ps5EnSZqDg4Qztvo7IIs 9vH66AiGSQgCDxk& + +Deserialized: +2041519981506242154 3041486079683013705 1192 1879 +0.572123 0.326855 +boPb#T0O8Xd&Ps5EnSZqDg4Qztvo7IIs 9vH66AiGSQgCDxk& +``` + +### 一个 Java Protobuf 客户端 + +用 Java 写的示例是为了确认 Protobuf 的语言中立性。原始 IDL 文件可用于生成 Java 支持代码,其中涉及嵌套类。但是,为了抑制警告信息,可以进行一些补充。这是修订版,它指定了一个 `DataMsg` 作为外部类的名称,内部类在该 Protobuf 消息后面自动命名为 `DataItem`: + +``` +syntax = "proto3"; + +package main; + +option java_outer_classname = "DataMsg"; + +message DataItem { +... +``` + +进行此更改后,`protoc` 编译与以前相同,只是所期望的输出现在是 Java 而不是 Go: + +``` +% protoc --java_out=. dataitem.proto +``` + +生成的源文件(在名为 `main` 的子目录中)为 `DataMsg.java`,长度约为 1,120 行:Java 并不简洁。编译然后运行 Java 代码需要具有 Protobuf 库支持的 JAR 文件。该文件位于 [Maven 存储库][9]中。 + +放置好这些片段后,我的测试代码相对较短(并且在 ZIP 文件中以 `Main.java` 形式提供): + +``` +package main; +import java.io.FileInputStream; + +public class Main { + public static void main(String[] args) { + String path = "dataitem.pbuf"; // from the Go program's serialization + try { + DataMsg.DataItem deserial = + DataMsg.DataItem.newBuilder().mergeFrom(new FileInputStream(path)).build(); + + System.out.println(deserial.getOddA()); // 64-bit odd + System.out.println(deserial.getLong()); // 32-character string + } + catch(Exception e) { System.err.println(e); } + } +} +``` + +当然,生产级的测试将更加彻底,但是即使是该初步测试也可以证明 Protobuf 的语言中立性:`dataitem.pbuf` 文件是 Go 程序对 Go 语言版的 `DataItem` 进行序列化的结果,并且该文件中的字节被反序列化以产生一个 Java 语言的 `DataItem` 实例。Java 测试的输出与 Go 测试的输出相同。 + +### 用 numPairs 程序来结束 + +让我们以一个示例作为结尾,来突出 Protobuf 效率,但又强调在任何编码技术中都会涉及到的成本。考虑以下 Protobuf IDL 文件: + +``` +syntax = "proto3"; +package main; + +message NumPairs { + repeated NumPair pair = 1; +} + +message NumPair { + int32 odd = 1; + int32 even = 2; +} +``` + +`NumPair` 消息由两个 `int32` 值以及每个字段的整数标签组成。`NumPairs` 消息是嵌入的 `NumPair` 消息的序列。 + +Go 语言的 `numPairs` 程序(如下)创建了 200 万个 `NumPair` 实例,每个实例都附加到 `NumPairs` 消息中。该消息可以按常规方式进行序列化和反序列化。 + +#### 示例 2、numPairs 程序 + +``` +package main + +import ( + "math/rand" + "time" + "encoding/xml" + "encoding/json" + "io/ioutil" + "github.com/golang/protobuf/proto" +) + +// protoc-generated code: start +var _ = proto.Marshal +type NumPairs struct { + Pair []*NumPair `protobuf:"bytes,1,rep,name=pair" json:"pair,omitempty"` +} + +func (m *NumPairs) Reset() { *m = NumPairs{} } +func (m *NumPairs) String() string { return proto.CompactTextString(m) } +func (*NumPairs) ProtoMessage() {} +func (m *NumPairs) GetPair() []*NumPair { + if m != nil { return m.Pair } + return nil +} + +type NumPair struct { + Odd int32 `protobuf:"varint,1,opt,name=odd" json:"odd,omitempty"` + Even int32 `protobuf:"varint,2,opt,name=even" json:"even,omitempty"` +} + +func (m *NumPair) Reset() { *m = NumPair{} } +func (m *NumPair) String() string { return proto.CompactTextString(m) } +func (*NumPair) ProtoMessage() {} +func init() {} +// protoc-generated code: finish + +var numPairsStruct NumPairs +var numPairs = &numPairsStruct + +func encodeAndserialize() { + // XML encoding + filename := "./pairs.xml" + bytes, _ := xml.MarshalIndent(numPairs, "", " ") + ioutil.WriteFile(filename, bytes, 0644) + + // JSON encoding + filename = "./pairs.json" + bytes, _ = json.MarshalIndent(numPairs, "", " ") + ioutil.WriteFile(filename, bytes, 0644) + + // ProtoBuf encoding + filename = "./pairs.pbuf" + bytes, _ = proto.Marshal(numPairs) + ioutil.WriteFile(filename, bytes, 0644) +} + +const HowMany = 200 * 100 * 100 // two million + +func main() { + rand.Seed(time.Now().UnixNano()) + + // uncomment the modulus operations to get the more efficient version + for i := 0; i < HowMany; i++ { + n1 := rand.Int31() // % 2047 + if (n1 & 1) == 0 { n1++ } // ensure it's odd + n2 := rand.Int31() // % 2047 + if (n2 & 1) == 1 { n2++ } // ensure it's even + + next := &NumPair { + Odd: n1, + Even: n2, + } + numPairs.Pair = append(numPairs.Pair, next) + } + encodeAndserialize() +} +``` + +每个 `NumPair` 中随机生成的奇数和偶数值的范围在 0 到 20 亿之间变化。就原始数据(而非编码数据)而言,Go 程序中生成的整数总共为 16MB:每个 `NumPair` 为两个整数,总计为 400 万个整数,每个值的大小为四个字节。 + +为了进行比较,下表列出了 XML、JSON 和 Protobuf 编码的示例 `NumsPairs` 消息的 200 万个 `NumPair` 实例。原始数据也包括在内。由于 `numPairs` 程序生成随机值,因此样本运行的输出有所不同,但接近表中显示的大小。 + +编码 | 文件 | 字节大小 | Pbuf/其它 比例 +---|---|---|--- +无 | pairs.raw | 16MB | 169% +Protobuf | pairs.pbuf | 27MB | — +JSON | pairs.json | 100MB | 27% +XML | pairs.xml | 126MB | 21% + +*表 2. 16MB 整数的编码开销* + +不出所料,Protobuf 和之后的 XML 和 JSON 差别明显。Protobuf 编码大约是 JSON 的四分之一,是 XML 的五分之一。但是原始数据清楚地表明 Protobuf 也会产生编码开销:序列化的 Protobuf 消息比原始数据大 11MB。包括 Protobuf 在内的任何编码都涉及结构化数据,这不可避免地会增加字节。 + +序列化的 200 万个 `NumPair` 实例中的每个实例都包含**四**个整数值:Go 结构中的 `Even` 和 `Odd` 字段分别一个,而 Protobuf 编码中的每个字段、每个标签一个。对于原始数据(而不是编码数据),每个实例将达到 16 个字节,样本 `NumPairs` 消息中有 200 万个实例。但是 Protobuf 标记(如 `NumPair` 字段中的 `int32` 值)使用 `varint` 编码,因此字节长度有所不同。特别是,小的整数值(在这种情况下,包括标签在内)需要不到四个字节进行编码。 + +如果对 `numPairs` 程序进行了修改,以使两个 `NumPair` 字段的值小于 2048,且其编码为一或两个字节,则 Protobuf 编码将从 27MB 下降到 16MB,这正是原始数据的大小。下表总结了样本运行中的新编码大小。 + +编码 | 文件 | 字节大小 | Pbuf/其它 比例 +---|---|---|--- +None | pairs.raw | 16MB | 100% +Protobuf | pairs.pbuf | 16MB | — +JSON | pairs.json | 77MB | 21% +XML | pairs.xml | 103MB | 15% + +*表 3. 编码 16MB 的小于 2048 的整数* + +总之,修改后的 `numPairs` 程序的字段值小于 2048,可减少原始数据中每个四字节整数值的大小。但是 Protobuf 编码仍然需要标签,这些标签会在 Protobuf 消息中添加字节。Protobuf 编码确实会增加消息大小,但是如果要编码相对较小的整数值(无论是字段还是键),则可以通过 `varint` 因子来减少此开销。 + +对于包含混合类型的结构化数据(且整数值相对较小)的中等大小的消息,Protobuf 明显优于 XML 和 JSON 等选项。在其他情况下,数据可能不适合 Protobuf 编码。例如,如果两个应用程序需要共享大量文本记录或大整数值,则可以采用压缩而不是编码技术。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/protobuf-data-interchange + +作者:[Marty Kalin][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mkalindepauledu +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_data_dashboard_system_computer_analytics.png?itok=oxAeIEI- (metrics and data shown on a computer screen) +[2]: https://developers.google.com/protocol-buffers/ +[3]: https://en.wikipedia.org/wiki/DCE/RPC +[4]: https://en.wikipedia.org/wiki/Interface_description_language +[5]: https://grpc.io/ +[6]: http://condor.depaul.edu/mkalin +[7]: https://github.com/protocolbuffers/protobuf +[8]: https://developers.google.com/protocol-buffers/docs/encoding +[9]: https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java diff --git a/published/20191021 How to program with Bash- Syntax and tools.md b/published/201911/20191021 How to program with Bash- Syntax and tools.md similarity index 100% rename from published/20191021 How to program with Bash- Syntax and tools.md rename to published/201911/20191021 How to program with Bash- Syntax and tools.md diff --git a/published/20191022 Initializing arrays in Java.md b/published/201911/20191022 Initializing arrays in Java.md similarity index 100% rename from published/20191022 Initializing arrays in Java.md rename to published/201911/20191022 Initializing arrays in Java.md diff --git a/published/20191023 How to dual boot Windows 10 and Debian 10.md b/published/201911/20191023 How to dual boot Windows 10 and Debian 10.md similarity index 100% rename from published/20191023 How to dual boot Windows 10 and Debian 10.md rename to published/201911/20191023 How to dual boot Windows 10 and Debian 10.md diff --git a/published/20191024 Open Source CMS Ghost 3.0 Released with New features for Publishers.md b/published/201911/20191024 Open Source CMS Ghost 3.0 Released with New features for Publishers.md similarity index 100% rename from published/20191024 Open Source CMS Ghost 3.0 Released with New features for Publishers.md rename to published/201911/20191024 Open Source CMS Ghost 3.0 Released with New features for Publishers.md diff --git a/published/20191025 4 cool new projects to try in COPR for October 2019.md b/published/201911/20191025 4 cool new projects to try in COPR for October 2019.md similarity index 100% rename from published/20191025 4 cool new projects to try in COPR for October 2019.md rename to published/201911/20191025 4 cool new projects to try in COPR for October 2019.md diff --git a/translated/tech/20191025 How I used the wget Linux command to recover lost images.md b/published/201911/20191025 How I used the wget Linux command to recover lost images.md similarity index 58% rename from translated/tech/20191025 How I used the wget Linux command to recover lost images.md rename to published/201911/20191025 How I used the wget Linux command to recover lost images.md index c7c33f1666..274a70fff2 100644 --- a/translated/tech/20191025 How I used the wget Linux command to recover lost images.md +++ b/published/201911/20191025 How I used the wget Linux command to recover lost images.md @@ -1,36 +1,36 @@ [#]: collector: (lujun9972) [#]: translator: (wxy) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11592-1.html) [#]: subject: (How I used the wget Linux command to recover lost images) [#]: via: (https://opensource.com/article/19/10/how-community-saved-artwork-creative-commons) [#]: author: (Seth Kenlon https://opensource.com/users/seth) -我是如何使用 wget 命令恢复丢失的图像的 +丢失的开放剪贴画库和新的公共艺术品图书馆 FreeSVG.org 的诞生 ====== > 开放剪贴画库兴衰的故事以及一个新的公共艺术品图书馆 FreeSVG.org 的诞生。 -![White shoes on top of an orange tribal pattern][1] +![](https://img.linux.net.cn/data/attachment/album/201911/19/102040imbybpl32vgdibbm.jpg) -开放剪贴画库Open Clip Art Library(OCAL)发布于 2004 年,成为了免费插图的来源,任何人都可以出于任何目的使用它们,而无需注明出处或提供任何回报。针对 1990 年代每个家庭办公室书架上的大量剪贴画 CD 以及由闭源公司和艺术品软件提供的艺术品转储,这个网站是开源世界的答复。 +开放剪贴画库Open Clip Art Library(OCAL)发布于 2004 年,成为了免费插图的来源,任何人都可以出于任何目的使用它们,而无需注明出处或提供任何回报。针对 1990 年代每个家庭办公室书架上的大量剪贴画 CD 以及由闭源公司和艺术品软件提供的艺术品转储,这个网站是开源世界的回应。 -最初,这个剪贴画库主要由一些贡献者组成,但是在 2010 年,它重新打造成了一个全新的交互式网站,可以让任何人使用矢量插图应用程序创建和贡献剪贴画。该网站立即获得了来自全球的、各种形式的自由软件和自由文化项目的贡献。[Inkscape][2] 中甚至包含了该库的专用导入器。 +最初,这个剪贴画库主要由一些贡献者提供,但是在 2010 年,它重新打造成了一个全新的交互式网站,可以让任何人使用矢量插图应用程序创建和贡献剪贴画。该网站立即获得了来自全球的、各种形式的自由软件和自由文化项目的贡献。[Inkscape][2] 中甚至包含了该库的专用导入器。 -但是,在 2019 年初,托管开放剪贴画库的网站离线,没有任何警告或解释。它已经成长为有着成千上万的人的社区,起初以为这是暂时的故障。 但是,这个站点一直离线已超过六个月,而没有任何清楚的解释。 +但是,在 2019 年初,托管开放剪贴画库的网站离线了,没有任何警告或解释。它已经成长为有着成千上万的人的社区,起初以为这是暂时的故障。但是,这个网站一直离线已超过六个月,而没有任何清楚的解释。 -谣言开始膨胀。该网站正在更新中(“要偿还数年的技术债务”,网站开发者 Jon Philips 在一封电子邮件中说)。一个 Twitter 帐户声称,该网站遭受了猖狂的 DDoS 攻击。另一个 Twitter 帐户声称,该网站维护者已经成为身份盗用的牺牲品。今天,在撰写本文时,该网站的一个且唯一的页面声明它处于“维护和保护模式”,其含义不清楚,只是用户无法访问其内容。 +谣言开始膨胀。该网站一直在更新中(“要偿还数年的技术债务”,网站开发者 Jon Philips 在一封电子邮件中说)。一个 Twitter 帐户声称,该网站遭受了猖狂的 DDoS 攻击。另一个 Twitter 帐户声称,该网站维护者已经成为身份盗用的牺牲品。今天,在撰写本文时,该网站的一个且唯一的页面声明它处于“维护和保护模式”,其含义不清楚,只是用户无法访问其内容。 ### 恢复公地 -网站会随着时间的流逝而消失,但是对其社区而言开放剪贴画库的丢失尤其令人惊讶,因为它被视为一个社区项目。很少有社区成员知道托管该库的站点已经落入一个维护者手中,因此,由于 [CC0 许可证][3],该库中的艺术品归所有人所有,但对它的访问是功能性的由单个维护者执行。而且,由于该站点的社区通过该站点彼此保持联系,因此该维护者实际上拥有该社区。 +网站会随着时间的流逝而消失,但是对其社区而言,开放剪贴画库的丢失尤其令人惊讶,因为它被视为一个社区项目。很少有社区成员知道托管该库的网站已经落入单个维护者手中,因此,由于 [CC0 许可证][3],该库中的艺术品归所有人所有,但对它的访问是由单个维护者功能性拥有的。而且,由于该社区通过网站彼此保持联系,因此该维护者实际上拥有该社区。 -当站点发生故障时,社区以及彼此之间都无法访问其艺术品。没有该站点,就没有社区。 +当网站发生故障时,社区以及成员彼此之间都无法访问剪贴画。没有该网站,就没有社区。 -最初,该网站离线后其上的所有东西都是被封挡的。不过,在几个月之后,用户开始意识到该网站的数据库仍然在线,这意味着用户能够通过输入精确的 URL 访问单个剪贴画。换句话说,你不能通过在网站上到处点击来流量剪贴画文件,但是如果你知道该地址,你就可以在浏览器中访问它。类似的,技术型(或偷懒的)用户意识到能够通过类似 `wget` 的自动 Web 浏览器将网站“抓取”下来。 +最初,该网站离线后其上的所有东西都是被封锁的。不过,在几个月之后,用户开始意识到该网站的数据仍然在线,这意味着用户能够通过输入精确的 URL 访问单个剪贴画。换句话说,你不能通过在网站上到处点击来浏览剪贴画文件,但是如果你确切地知道该地址,你就可以在浏览器中访问它。类似的,技术型(或偷懒的)用户意识到能够通过类似 `wget` 的自动 Web 浏览器将网站“抓取”下来。 -Linux 的 `wget` 命令技术上是一个 Web 浏览器,虽然它不能让你像用 Firefox 一样交互式地浏览。相反,`wget` 可以连到互联网,获取文件或文件集,并下载到你的本次硬盘。然后,你可以在 Firefox 或文本编辑器或最合适的应用程序中打开这些文件,然后查看内容。 +Linux 的 `wget` 命令从技术上来说是一个 Web 浏览器,虽然它不能让你像用 Firefox 一样交互式地浏览。相反,`wget` 可以连到互联网,获取文件或文件集,并下载到你的本次硬盘。然后,你可以在 Firefox、文本编辑器或最合适的应用程序中打开这些文件,查看内容。 通常,`wget` 需要知道要提取的特定文件。如果你使用的是安装了 `wget` 的 Linux 或 macOS,则可以通过下载 [example.com][4] 的索引页来尝试此过程: @@ -47,25 +47,25 @@ $ tail index.html ``` -为了抓取 OCAL,我使用了 `--mirror` 选项,以便可以只是将 `wget` 指向到包含艺术品的目录,就可以下载该目录中的所有内容。此操作导致连续四天(96 个小时)持续下载,最终得到了超过 50000 个社区成员贡献的 100,000 个 SVG 文件。不幸的是,任何没有适当元数据的文件的作者信息都是无法恢复的,因为此信息被锁定在数据库中不可访问的文件中,但是 CC0 许可证意味着此问题*在技术上*无关紧要(因为 CC0 文件不需要属性)。 +为了抓取 OCAL,我使用了 `--mirror` 选项,以便可以只是将 `wget` 指向到包含剪贴画的目录,就可以下载该目录中的所有内容。此操作持续下载了连续四天(96 个小时),最终得到了超过 50,000 个社区成员贡献的 100,000 个 SVG 文件。不幸的是,任何没有适当元数据的文件的作者信息都是无法恢复的,因为此信息被锁定在该数据库中不可访问的文件中,但是 CC0 许可证意味着此问题*在技术上*无关紧要(因为 CC0 文件不需要归属)。 -随意分析了一下下载的文件进行还显示,其中近 45,000 个文件是同一文件(该网站的徽标)的副本。这是由于指向该站点徽标的重定向(原因未知)引起的,仔细分析能够提取到原始的文件。又过了 96 个小时,并且恢复了直到最后一天发布在 OCAL 上的所有剪贴画:总共约有 156,000 张图像。 +随意分析了一下下载的文件进行还显示,其中近 45,000 个文件是同一个文件(该网站的徽标)的副本。这是由于指向该网站徽标的重定向引起的(原因未知),仔细分析能够提取到原始的文件,又过了 96 个小时,并且恢复了直到最后一天发布在 OCAL 上的所有剪贴画:总共约有 156,000 张图像。 -SVG 文件通常很小,但这仍然是大量工作,并且会带来一些非常实际的问题。首先,将需要数 GB 的在线存储空间,这样这些剪贴画才能供其先前的社区使用。其次,必须使用一种搜索艺术品的方法,因为手动浏览 55,000 个文件是不现实的。 +SVG 文件通常很小,但这仍然是大量工作,并且会带来一些非常实际的问题。首先,将需要数 GB 的在线存储空间,这样这些剪贴画才能供其先前的社区使用。其次,必须使用一种搜索剪贴画的方法,因为手动浏览 55,000 个文件是不现实的。 很明显,社区真正需要的是一个平台。 ### 构建新的平台 -一段时间以来,[公共领域矢量图][6] 网站一直在发布公共领域的矢量图。虽然它仍然是一个受欢迎的网站,但是开源用户经常将其仅用作辅助的图片资源,因为其中大多数文件都是 EPS 和 AI 格式的,两者均与 Adobe 相关。两种文件格式通常都可以转换为 SVG,但是特性有所损失。 +一段时间以来,[公共领域矢量图][6] 网站一直在发布公共领域的矢量图。虽然它仍然是一个受欢迎的网站,但是开源用户通常只是将其用作辅助的图片资源,因为其中大多数文件都是 EPS 和 AI 格式的,这两者均与 Adobe 相关。这两种文件格式通常都可以转换为 SVG,但是特性会有所损失。 -当公共领域矢量图网站的维护者(Vedran 和 Boris)得知 OCAL 丢失时,他们决定创建一个面向开源社区的网站。诚然,他们选择了开源 [Laravel][7] 框架作为后端,该框架为网站提供了管理控制台和用户访问权限。该框架功能强大且开发完善,还使他们能够快速响应错误报告和功能请求,并根据需要升级站点。他们正在建立的站点称为 [FreeSVG.org][8],已经是一个强大而繁荣的公共艺术品图书馆。 +当公共领域矢量图网站的维护者(Vedran 和 Boris)得知 OCAL 丢失时,他们决定创建一个面向开源社区的网站。诚然,他们选择了开源 [Laravel][7] 框架作为后端,该框架为网站提供了管理控制台和用户访问权限。该框架功能强大且开发完善,还使他们能够快速响应错误报告和功能请求,并根据需要升级网站。他们正在建立的网站称为 [FreeSVG.org][8],已经是一个强大而繁荣的公共艺术品图书馆。 -从那时起,他们就一直从 OCAL 上载所有剪贴画,并且他们甚至在努力地对艺术品进行标记和分类。作为公共领域矢量图网站的创建者,他们还以 SVG 格式贡献了自己的图像。他们的目标是成为互联网上具有 CC0 许可证的 SVG 图像的主要资源。 +从那时起,他们就一直从 OCAL 上载所有剪贴画,并且他们甚至在努力地对这些剪贴画进行标记和分类。作为公共领域矢量图网站的创建者,他们还以 SVG 格式贡献了自己的图像。他们的目标是成为互联网上具有 CC0 许可证的 SVG 图像的主要资源。 ### 贡献 -[FreeSVG.org][8] 的维护者意识到他们已经继承了重要的管理权。他们正在努力对网站上的所有图像加上标题和描述,以便用户可以轻松找到这些艺术品,并在准备就绪后将其提供给社区,同时坚信与这些艺术品有关的元数据和艺术品属于创建和使用它们的人。他们还意识到可能会发生无法预料的情况,因此他们会定期为其网站和内容创建备份,并打算在其站点出现故障时向公众提供最新备份。 +[FreeSVG.org][8] 的维护者意识到他们已经继承了重要的管理权。他们正在努力对网站上的所有图像加上标题和描述,以便用户可以轻松找到这些剪贴画,并在准备就绪后将其提供给社区,同时坚信同这些剪贴画一样,与这些剪贴画有关的元数据属于创建和使用它们的人。他们还意识到可能会发生无法预料的情况,因此他们会定期为其网站和内容创建备份,并打算在其网站出现故障时向公众提供最新备份。 如果要为 [FreeSVG.org][9]的知识共享内容添砖加瓦,请下载 [Inkscape][10] 并开始绘制。世界上有很多公共领域的艺术品,例如[历史广告][11]、[塔罗牌][12]和[故事书][13],只是在等待转换为 SVG,因此即使你对自己的绘画技巧没有信心你也可以做出贡献。访问 [FreeSVG 论坛][14]与其他贡献者联系并支持他们。 @@ -73,7 +73,7 @@ SVG 文件通常很小,但这仍然是大量工作,并且会带来一些非 这是自由文化的力量:它不仅可以扩展,而且随着更多人的参与,它会变得更好。 -### 艰难的教训 +### 艰辛的教训 从 OCAL 的消亡到 FreeSVG.org 的兴起,开放文化社区已经吸取了一些艰辛的经验。对于以后,以下是我认为最重要的那些。 @@ -83,11 +83,11 @@ SVG 文件通常很小,但这仍然是大量工作,并且会带来一些非 #### 做个副本 -不要以为别人在做备份。如果你关心公用数字内容,请自己备份,否则不要指望永远提供它。 无论*任何上传到互联网上的内容是永久的*的说法是不是正确的,但这并不意味着你永远可以使用。如果 OCAL 文件不再隐秘地可用,那么任何人都不太可能成功地从网络上的某个位置或从全球范围内的人们的硬盘中成功地发现所有的 55,000 张图像。Make copies +不要以为别人在做备份。如果你关心公用数字内容,请自己备份,否则不要指望永远提供它。无论*任何上传到互联网上的内容是永久的*的说法是不是正确的,但这并不意味着你永远可以使用。如果 OCAL 文件不再暗地可用,那么任何人都不太可能成功地从网络上的某个位置或从全球范围内的人们的硬盘中成功地发现全部的 55,000 张图像。 #### 创建外部渠道 -如果一个社区是由单个网站或实际位置来定义的,那么该社区失去访问该空间的能力就如同解散了一样。如果你是由单个组织或网站驱动的社区的成员,则你应该自己与关心的人共享联系信息,并即使在该站点不可用时也可以建立沟通渠道。 +如果一个社区是由单个网站或实际位置来定义的,那么该社区失去访问该空间的能力就如同解散了一样。如果你是由单个组织或网站驱动的社区的成员,则你应该自己与关心的人共享联系信息,并即使在该网站不可用时也可以建立沟通渠道。 例如,[Opensource.com][16] 本身维护其作者和通讯者的邮件列表和其他异地渠道,以便在有或没有网站干预或甚至没有网站的情况下相互交流。 @@ -95,7 +95,7 @@ SVG 文件通常很小,但这仍然是大量工作,并且会带来一些非 互联网有时被视为懒人社交俱乐部。你可以在需要时登录并在感到疲倦时将其关闭,也可以漫步到所需的任何社交圈。 -但实际上,自由文化可能是项艰难的工作。但是这种艰难从某种意义上讲并不是说要成为其中的一部分很困难,而是你必须努力维护。如果你忽略你所在的社区,那么该社区可能会在你才会意识到之前就枯萎并褪色。 +但实际上,自由文化可能是项艰难的工作。但是这种艰难从某种意义上讲并不是说要成为其中的一分子很困难,而是你必须努力维护。如果你忽略你所在的社区,那么该社区可能会在你意识到之前就枯萎并褪色。 花点时间环顾四周,确定你属于哪个社区,如果不是,那么请告诉某人你对他们带给你生活的意义表示赞赏。同样重要的是,请记住,这样你也为社区的生活做出了贡献。 @@ -108,7 +108,7 @@ via: https://opensource.com/article/19/10/how-community-saved-artwork-creative-c 作者:[Seth Kenlon][a] 选题:[lujun9972][b] 译者:[wxy](https://github.com/wxy) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20191025 Understanding system calls on Linux with strace.md b/published/201911/20191025 Understanding system calls on Linux with strace.md similarity index 100% rename from published/20191025 Understanding system calls on Linux with strace.md rename to published/201911/20191025 Understanding system calls on Linux with strace.md diff --git a/published/20191025 Why I made the switch from Mac to Linux.md b/published/201911/20191025 Why I made the switch from Mac to Linux.md similarity index 100% rename from published/20191025 Why I made the switch from Mac to Linux.md rename to published/201911/20191025 Why I made the switch from Mac to Linux.md diff --git a/published/20191027 How to Install and Configure Nagios Core on CentOS 8 - RHEL 8.md b/published/201911/20191027 How to Install and Configure Nagios Core on CentOS 8 - RHEL 8.md similarity index 100% rename from published/20191027 How to Install and Configure Nagios Core on CentOS 8 - RHEL 8.md rename to published/201911/20191027 How to Install and Configure Nagios Core on CentOS 8 - RHEL 8.md diff --git a/published/20191028 SQLite is really easy to compile.md b/published/201911/20191028 SQLite is really easy to compile.md similarity index 100% rename from published/20191028 SQLite is really easy to compile.md rename to published/201911/20191028 SQLite is really easy to compile.md diff --git a/published/20191029 Collapse OS - An OS Created to Run After the World Ends.md b/published/201911/20191029 Collapse OS - An OS Created to Run After the World Ends.md similarity index 100% rename from published/20191029 Collapse OS - An OS Created to Run After the World Ends.md rename to published/201911/20191029 Collapse OS - An OS Created to Run After the World Ends.md diff --git a/published/20191029 Upgrading Fedora 30 to Fedora 31.md b/published/201911/20191029 Upgrading Fedora 30 to Fedora 31.md similarity index 100% rename from published/20191029 Upgrading Fedora 30 to Fedora 31.md rename to published/201911/20191029 Upgrading Fedora 30 to Fedora 31.md diff --git a/translated/tech/20191029 What you probably didn-t know about sudo.md b/published/201911/20191029 What you probably didn-t know about sudo.md similarity index 67% rename from translated/tech/20191029 What you probably didn-t know about sudo.md rename to published/201911/20191029 What you probably didn-t know about sudo.md index 7843c56405..ce4502ba8a 100644 --- a/translated/tech/20191029 What you probably didn-t know about sudo.md +++ b/published/201911/20191029 What you probably didn-t know about sudo.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (wxy) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11595-1.html) [#]: subject: (What you probably didn’t know about sudo) [#]: via: (https://opensource.com/article/19/10/know-about-sudo) [#]: author: (Peter Czanik https://opensource.com/users/czanik) @@ -10,19 +10,19 @@ 关于 sudo 你可能不知道的 ====== -> 认为你已经了解了 sudo 的所有知识吗?再想想。 +> 觉得你已经了解了 sudo 的所有知识了吗?再想想。 -![Command line prompt][1] +![](https://img.linux.net.cn/data/attachment/album/201911/20/091740ape5b74jppjj4q36.jpg) 大家都知道 `sudo`,对吗?默认情况下,该工具已安装在大多数 Linux 系统上,并且可用于大多数 BSD 和商业 Unix 变体。不过,在与数百名 `sudo` 用户交谈之后,我得到的最常见的答案是 `sudo` 是一个使生活复杂化的工具。 有 root 用户和 `su` 命令,那么为什么还要使用另一个工具呢?对于许多人来说,`sudo` 只是管理命令的前缀。只有极少数人提到,当你在同一个系统上有多个管理员时,可以使用 `sudo` 日志查看谁做了什么。 -那么,`sudo` 是什么? 根据 [sudo 网站] [2]: +那么,`sudo` 是什么? 根据 [sudo 网站][2]: > “sudo 允许系统管理员通过授予某些用户以 root 用户或其他用户身份运行某些命令的能力,同时提供命令及其参数的审核记录,从而委派权限。” -默认情况下,`sudo` 带有简单的配置,一条规则允许一个用户或一组用户执行几乎所有操作(在本文后面的配置文件中有更多信息): +默认情况下,`sudo` 只有简单的配置,一条规则允许一个用户或一组用户执行几乎所有操作(在本文后面的配置文件中有更多信息): ``` %wheel ALL=(ALL) ALL @@ -35,37 +35,37 @@ * 第三个参数(`(ALL)`)定义了可以执行命令的用户名。 * 最后一个参数(`ALL`)定义可以运行的应用程序。 -因此,在此示例中,`wheel` 组的成员可以以所有主机上的所有用户身份运行所有应用程序。即使这个一切允许的规则也很有用,因为它会记录谁在的计算机上做了什么。 +因此,在此示例中,`wheel` 组的成员可以以所有主机上的所有用户身份运行所有应用程序。但即使是这个一切允许的规则也很有用,因为它会记录谁在计算机上做了什么。 ### 别名 -当然,它不仅可以让你和你最好的朋友管理一个共享机器,你还可以微调权限。你可以将以上配置中的项目替换为列表:用户列表、命令列表等。 多数情况下,你可能会复制并粘贴配置中的一些列表。 +当然,它不仅可以让你和你最好的朋友管理一个共享机器,你还可以微调权限。你可以将以上配置中的项目替换为列表:用户列表、命令列表等。多数情况下,你可能会复制并粘贴配置中的一些列表。 -在这种情况下,别名可以派上用场。在多个位置维护相同的列表容易出错。你可以定义一次别名,然后可以多次使用。因此,当你对一位管理员失去信任时,可以将其从别名中删除就行了。使用多个列表而不是别名,很容易忘记从具有较高特权的列表之一中删除用户。 +在这种情况下,别名可以派上用场。在多个位置维护相同的列表容易出错。你可以定义一次别名,然后可以多次使用。因此,当你对一位管理员不再信任时,将其从别名中删除就行了。使用多个列表而不是别名,很容易忘记从具有较高特权的列表之一中删除用户。 ### 为特定组的用户启用功能 -`sudo` 命令带有大量默认设置。不过,在某些情况下,你想覆盖其中的一些情况,这时你可以在配置中使用 `Defaults` 语句。通常,对每个用户都强制使用这些默认值,但是你可以根据主机、用户名等将设置缩小到一部分用户。这有个我那一代的系统管理员喜欢玩的一个示例:“羞辱”。这些只是一些有人输入错误密码时的有趣信息: +`sudo` 命令带有大量默认设置。不过,在某些情况下,你想覆盖其中的一些情况,这时你可以在配置中使用 `Defaults` 语句。通常,对每个用户都强制使用这些默认值,但是你可以根据主机、用户名等将设置缩小到一部分用户。这里有个我那一代的系统管理员都喜欢玩的一个示例:“羞辱”。这些只不过是一些有人输入错误密码时的有趣信息: ``` czanik@linux-mewy:~> sudo ls [sudo] password for root: -Hold it up to the light --- not a brain in sight! +Hold it up to the light --- not a brain in sight! # 把灯举高点,脑仁太小看不到 [sudo] password for root: -My pet ferret can type better than you! +My pet ferret can type better than you! # 我的宠物貂也比你输入的好 [sudo] password for root: sudo: 3 incorrect password attempts czanik@linux-mewy:~> ``` -由于并非所有人都喜欢系统管理员的这种幽默,因此默认情况下将禁用这些羞辱信息。以下示例说明了如何仅对经验丰富的系统管理员(即 `wheel` 组的成员)启用此设置: +由于并非所有人都喜欢系统管理员的这种幽默,因此默认情况下会禁用这些羞辱信息。以下示例说明了如何仅对经验丰富的系统管理员(即 `wheel` 组的成员)启用此设置: ``` Defaults !insults Defaults:%wheel insults ``` -我想感谢我将这些消息带回来的人用两只手也数不过来吧。 +我想,感谢我将这些消息带回来的人用两只手也数不过来吧。 ### 摘要验证 @@ -79,15 +79,15 @@ peter ALL = sha244:11925141bb22866afdf257ce7790bd6275feda80b3b241c108b79c88 /usr ### 会话记录 -会话记录也是 `sudo` 鲜为人知的功能。在演示之后,许多人离开我的演讲后就在计划在其基础设施上实施它。为什么?因为使用会话记录,你不仅可以看到命令名称,还可以看到终端中发生的所有事情。你可以看到你的管理员在做什么,即使他们具有 shell 访问权限,而日志仅显示启动了 `bash`。 +会话记录也是 `sudo` 鲜为人知的功能。在演示之后,许多人离开我的演讲后就计划在其基础设施上实施它。为什么?因为使用会话记录,你不仅可以看到命令名称,还可以看到终端中发生的所有事情。你可以看到你的管理员在做什么,要不他们用 shell 访问了机器而日志仅会显示启动了 `bash`。 -当前有一个限制。记录存储在本地,因此具有足够的权限的话,用户可以删除他们的痕迹。请继续关注即将推出的功能。 +当前有一个限制。记录存储在本地,因此具有足够的权限的话,用户可以删除他们的痕迹。所以请继续关注即将推出的功能。 ### 插件 -从 1.8 版开始,`sudo` 更改为基于插件的模块化体系结构。通过将大多数功能实现为插件,你可以编写自己的功能轻松地替换或扩展 `sudo` 的功能。已有 `sudo` 可用的开源和商业插件。 +从 1.8 版开始,`sudo` 更改为基于插件的模块化体系结构。通过将大多数功能实现为插件,你可以编写自己的功能轻松地替换或扩展 `sudo` 的功能。已经有了 `sudo` 上的开源和商业插件。 -在我的演讲中,我演示了 `sudo_pair` 插件,该插件可在 [GitHub][3] 上获得。这个插件是用 Rust 开发的,这意味着它不是那么容易编译,甚至更难以分发编译结果。另一方面,该插件提供了有趣的功能,需要第二个管理员通过 `sudo` 批准(或拒绝)运行命令。不仅如此,如果有可疑活动,可以在屏幕上跟踪会话并终止会话。 +在我的演讲中,我演示了 `sudo_pair` 插件,该插件可在 [GitHub][3] 上获得。这个插件是用 Rust 开发的,这意味着它不是那么容易编译,甚至更难以分发其编译结果。另一方面,该插件提供了有趣的功能,需要第二个管理员通过 `sudo` 批准(或拒绝)运行命令。不仅如此,如果有可疑活动,可以在屏幕上跟踪会话并终止会话。 在最近的 All Things Open 会议上的一次演示中,我做了一个臭名昭著的演示: @@ -95,11 +95,11 @@ peter ALL = sha244:11925141bb22866afdf257ce7790bd6275feda80b3b241c108b79c88 /usr czanik@linux-mewy:~> sudo  rm -fr / ``` -看着屏幕上显示的命令。每个人都屏住呼吸,想看看我的笔记本电脑是否被毁了,但它仍然幸免了。 +看着屏幕上显示的命令。每个人都屏住呼吸,想看看我的笔记本电脑是否被毁了,然而它逃过一劫。 ### 日志 -正如我在开始时已经提到的,日志记录和警报是 `sudo` 的重要组成部分。如果你不会定期检查 `sudo` 日志,那么日志在使用 `sudo` 中并没有太多价值。该工具通过电子邮件提醒配置中指定的事件,并将所有事件记录到 syslog 中。可以打开调试日志用于调试规则或报告错误。 +正如我在开始时提到的,日志记录和警报是 `sudo` 的重要组成部分。如果你不会定期检查 `sudo` 日志,那么日志在使用 `sudo` 中并没有太多价值。该工具通过电子邮件提醒配置中指定的事件,并将所有事件记录到 syslog 中。可以打开调试日志用于调试规则或报告错误。 ### 警报 @@ -107,11 +107,11 @@ czanik@linux-mewy:~> sudo  rm -fr / ### 配置 -我们谈论了很多 `sudo` 功能,甚至看到了几行配置。现在,让我们仔细看看 `sudo` 的配置方式。配置本身可以在 `/etc/sudoers` 中获得,这是一个简单的文本文件。不过,不建议直接编辑此文件。相反,请使用 `visudo`,因为此工具还会执行语法检查。如果你不喜欢 `vi`,则可以通过将 `EDITOR` 环境变量指向你的首选编辑器来更改要使用的编辑器。 +我们谈论了很多 `sudo` 功能,甚至还看到了几行配置。现在,让我们仔细看看 `sudo` 的配置方式。配置本身可以在 `/etc/sudoers` 中获得,这是一个简单的文本文件。不过,不建议直接编辑此文件。相反,请使用 `visudo`,因为此工具还会执行语法检查。如果你不喜欢 `vi`,则可以通过将 `EDITOR` 环境变量指向你的首选编辑器来更改要使用的编辑器。 -在开始编辑 `sudo` 配置之前,请确保你知道 root 密码。(是的,即使在默认情况下 root 用户没有密码的 Ubuntu 上也是如此。)虽然 `visudo` 会检查语法,但创建语法正确而将你锁定在系统之外的配置很容易。 +在开始编辑 `sudo` 配置之前,请确保你知道 root 密码。(是的,即使在默认情况下 root 用户没有密码的 Ubuntu 上也是如此。)虽然 `visudo` 会检查语法,但创建语法正确而将你锁定在系统之外的配置也很容易。 -如果在紧急情况下,而你手头有 root 密码,你也可以编辑配置。当涉及到 `sudoers` 文件时,有一件重要的事情要记住:从上到下读取该文件,以最后的设置为准。这个事实对你来说意味着你应该从通用设置开始,并在末尾放置例外情况,否则,通用设置会覆盖例外情况。 +如果在紧急情况下,而你手头有 root 密码,你也可以直接编辑配置。当涉及到 `sudoers` 文件时,有一件重要的事情要记住:从上到下读取该文件,以最后的设置为准。这个事实对你来说意味着你应该从通用设置开始,并在末尾放置例外情况,否则,通用设置会覆盖例外情况。 你可以在下面看到一个基于 CentOS 的简单 `sudoers` 文件,并添加我们之前讨论的几行: @@ -133,13 +133,13 @@ Defaults log_output 该文件从更改多个默认值开始。然后是通常的默认规则:`root` 用户和 `wheel` 组的成员对计算机具有完全权限。接下来,我们对 `wheel` 组启用“羞辱”,但对其他所有人禁用它们。最后一行启用会话记录。 -上面的配置在语法上是正确的,但是你可以发现逻辑错误吗?是的,有一个:上一个通用设置覆盖了先前的更具体设置,所有人均禁用了“羞辱”。一旦交换了这两行的位置,设置就会按预期进行:`wheel` 组的成员会收到有趣的消息,但其他用户则不会收到。 +上面的配置在语法上是正确的,但是你可以发现逻辑错误吗?是的,有一个:后一个通用设置覆盖了先前的更具体设置,让所有人均禁用了“羞辱”。一旦交换了这两行的位置,设置就会按预期进行:`wheel` 组的成员会收到有趣的消息,但其他用户则不会收到。 ### 配置管理 一旦必须在多台机器上维护 `sudoers` 文件,你很可能希望集中管理配置。这里主要有两种可能的开源方法。两者都有其优点和缺点。 -你可以使用也可以用来配置其余基础设施的配置管理应用程序之一:Red Hat Ansible、Puppet 和 Chef 都具有用于配置 `sudo` 的模块。这种方法的问题在于更新配置远非实时。同样,用户仍然可以在本地编辑 `sudoers` 文件并更改设置。 +你可以使用也用来配置其余基础设施的配置管理应用程序之一:Red Hat Ansible、Puppet 和 Chef 都具有用于配置 `sudo` 的模块。这种方法的问题在于更新配置远非实时。同样,用户仍然可以在本地编辑 `sudoers` 文件并更改设置。 `sudo` 工具也可以将其配置存储在 LDAP 中。在这种情况下,配置更改是实时的,用户不能弄乱`sudoers` 文件。另一方面,该方法也有局限性。例如,当 LDAP 服务器不可用时,你不能使用别名或使用 `sudo`。 @@ -157,11 +157,11 @@ Defaults log_output    ### 总结 -希望本文能向你证明 `sudo` 不仅仅是一个简单的命令前缀。有无数种可能性可以微调系统上的权限。你不仅可以微调权限,还可以通过检查摘要来提高安全性。会话记录使你能够检查系统上正在发生的事情。你也可以使用插件扩展 `sudo` 的功能,或者使用已有的插件或编写自己的插件。最后,从即将发布的功能列表中,你可以看到,即使 `sudo` 已有数十年的历史,它也是一个不断发展的有生命的项目。 +希望本文能向你证明 `sudo` 不仅仅是一个简单的命令前缀。有无数种可能性可以微调系统上的权限。你不仅可以微调权限,还可以通过检查摘要来提高安全性。会话记录使你能够检查系统上正在发生的事情。你也可以使用插件扩展 `sudo` 的功能,或者使用已有的插件或编写自己的插件。最后,从即将发布的功能列表中你可以看到,即使 `sudo` 已有数十年的历史,它也是一个不断发展的有生命力的项目。 如果你想了解有关 `sudo` 的更多信息,请参考以下资源: -* [sudo `网站][5] +* [sudo 网站][5] * [sudo 博客][6] * [在 Twitter 上关注我们][7] @@ -172,7 +172,7 @@ via: https://opensource.com/article/19/10/know-about-sudo 作者:[Peter Czanik][a] 选题:[lujun9972][b] 译者:[wxy](https://github.com/wxy) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20191030 Getting started with awk, a powerful text-parsing tool.md b/published/201911/20191030 Getting started with awk, a powerful text-parsing tool.md similarity index 100% rename from published/20191030 Getting started with awk, a powerful text-parsing tool.md rename to published/201911/20191030 Getting started with awk, a powerful text-parsing tool.md diff --git a/published/20191030 How to Find Out Top Memory Consuming Processes in Linux.md b/published/201911/20191030 How to Find Out Top Memory Consuming Processes in Linux.md similarity index 100% rename from published/20191030 How to Find Out Top Memory Consuming Processes in Linux.md rename to published/201911/20191030 How to Find Out Top Memory Consuming Processes in Linux.md diff --git a/published/20191030 Viewing network bandwidth usage with bmon.md b/published/201911/20191030 Viewing network bandwidth usage with bmon.md similarity index 100% rename from published/20191030 Viewing network bandwidth usage with bmon.md rename to published/201911/20191030 Viewing network bandwidth usage with bmon.md diff --git a/published/20191031 Why you don-t have to be afraid of Kubernetes.md b/published/201911/20191031 Why you don-t have to be afraid of Kubernetes.md similarity index 100% rename from published/20191031 Why you don-t have to be afraid of Kubernetes.md rename to published/201911/20191031 Why you don-t have to be afraid of Kubernetes.md diff --git a/published/20191101 Keyboard Shortcuts to Speed Up Your Work in Linux.md b/published/201911/20191101 Keyboard Shortcuts to Speed Up Your Work in Linux.md similarity index 100% rename from published/20191101 Keyboard Shortcuts to Speed Up Your Work in Linux.md rename to published/201911/20191101 Keyboard Shortcuts to Speed Up Your Work in Linux.md diff --git a/published/20191104 Cloning a MAC address to bypass a captive portal.md b/published/201911/20191104 Cloning a MAC address to bypass a captive portal.md similarity index 100% rename from published/20191104 Cloning a MAC address to bypass a captive portal.md rename to published/201911/20191104 Cloning a MAC address to bypass a captive portal.md diff --git a/published/201911/20191104 Fields, records, and variables in awk.md b/published/201911/20191104 Fields, records, and variables in awk.md new file mode 100644 index 0000000000..259bde6f89 --- /dev/null +++ b/published/201911/20191104 Fields, records, and variables in awk.md @@ -0,0 +1,234 @@ +[#]: collector: (lujun9972) +[#]: translator: (wenwensnow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11611-1.html) +[#]: subject: (Fields, records, and variables in awk) +[#]: via: (https://opensource.com/article/19/11/fields-records-variables-awk) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +awk 中的字段、记录和变量 +====== + +> 这个系列的第二篇,我们会学习字段,记录和一些非常有用的 Awk 变量。 + +![](https://img.linux.net.cn/data/attachment/album/201911/25/090333m34qx395vwtxx5vx.jpg) + +Awk 有好几个变种:最早的 `awk`,是 1977 年 AT&T 贝尔实验室所创。它还有一些重构版本,例如 `mawk`、`nawk`。在大多数 Linux 发行版中能见到的,是 GNU awk,也叫 `gawk`。在大多数 Linux 发行版中,`awk` 和 `gawk` 都是指向 GNU awk 的软链接。输入 `awk`,调用的是同一个命令。[GNU awk 用户手册][2]中,能看到 `awk` 和 `gawk` 的全部历史。 + +这一系列的[第一篇文章][3] 介绍了 `awk` 命令的基本格式: + +``` +$ awk [选项] '模式 {动作}' 输入文件 +``` + +`awk` 是一个命令,后面要接选项 (比如用 `-F` 来定义字段分隔符)。想让 `awk` 执行的部分需要写在两个单引号之间,至少在终端中需要这么做。在 `awk` 命令中,为了进一步强调你想要执行的部分,可以用 `-e` 选项来突出显示(但这不是必须的): + +``` +$ awk -F, -e '{print $2;}' colours.txt +yellow +blue +green +[...] +``` + +### 记录和字段 + +`awk` 将输入数据视为一系列*记录*,通常是按行分割的。换句话说,`awk` 将文本中的每一行视作一个记录。每一记录包含多个*字段*。一个字段由*字段分隔符*分隔开来,字段是记录的一部分。 + +默认情况下,`awk` 将各种空白符,如空格、制表符、换行符等视为分隔符。值得注意的是,在 `awk` 中,多个*空格*将被视为一个分隔符。所以下面这行文本有两个字段: + +``` +raspberry red +``` + +这行也是: + + +``` +tuxedo                  black +``` + +其他分隔符,在程序中不是这么处理的。假设字段分隔符是逗号,如下所示的记录,就有三个字段。其中一个字段可能会是 0 个字节(假设这一字段中不包含隐藏字符) + +``` +a,,b +``` + +### awk 程序 + +`awk` 命令的*程序部分*是由一系列规则组成的。通常来说,程序中每个规则占一行(尽管这不是必须的)。每个规则由一个模式,或一个或多个动作组成: + +``` +模式 { 动作 } +``` + +在一个规则中,你可以通过定义模式,来确定动作是否会在记录中执行。模式可以是简单的比较条件、正则表达式,甚至两者结合等等。 + +这个例子中,程序*只会*显示包含单词 “raspberry” 的记录: + +``` +$ awk '/raspberry/ { print $0 }' colours.txt +raspberry red 99 +``` + +如果没有文本符合模式,该动作将会应用到所有记录上。 + +并且,在一条规则只包含模式时,相当于对整个记录执行 `{ print }`,全部打印出来。 + +Awk 程序本质上是*数据驱动*的,命令执行结果取决于数据。所以,与其他编程语言中的程序相比,它还是有些区别的。 + +### NF 变量 + +每个字段都有指定变量,但针对字段和记录,也存在一些特殊变量。`NF` 变量,能存储 `awk` 在当前记录中找到的字段数量。其内容可在屏幕上显示,也可用于测试。下面例子中的数据,来自上篇文章[文本][3]: + +``` +$ awk '{ print $0 " (" NF ")" }' colours.txt +name       color  amount (3) +apple      red    4 (3) +banana     yellow 6 (3) +[...] +``` + +`awk` 的 `print` 函数会接受一系列参数(可以是变量或者字符串),并将它们拼接起来。这就是为什么在这个例子里,每行结尾处,`awk` 会以一个被括号括起来的整数表示字段数量。 + +### NR 变量 + +另外,除了统计每个记录中的字段数,`awk` 也统计输入记录数。记录数被存储在变量 `NR` 中,它的使用方法和其他变量没有任何区别。例如,为了在每一行开头显示行号: + +``` +$ awk '{ print NR ": " $0 }' colours.txt +1: name       color  amount +2: apple      red    4 +3: banana     yellow 6 +4: raspberry  red    3 +5: grape      purple 10 +[...] +``` + +注意,写这个命令时可以不在 `print` 后的多个参数间添加空格,尽管这样会降低可读性: + +``` +$ awk '{print NR": "$0}' colours.txt +``` + +### printf() 函数 + +为了让输出结果时格式更灵活,你可以使用 `awk` 的 `printf()` 函数。 它与 C、Lua、Bash 和其他语言中的 `printf` 相类似。它也接受以逗号分隔的*格式*参数。参数列表需要写在括号里。 + +``` +$ printf 格式, 项目1, 项目2, ... +``` + +格式这一参数(也叫*格式符*)定义了其他参数如何显示。这一功能是用*格式修饰符*实现的。`%s` 输出字符,`%d` 输出十进制数字。下面的 `printf` 语句,会在括号内显示字段数量: + +``` +$ awk 'printf "%s (%d)\n",$0,NF}' colours.txt +name       color  amount (3) +raspberry  red    4 (3) +banana     yellow 6 (3) +[...] +``` + +在这个例子里,`%s (%d)` 确定了每一行的输出格式,`$0,NF` 定义了插入 `%s` 和 `%d` 位置的数据。注意,和 `print` 函数不同,在没有明确指令时,输出不会转到下一行。出现转义字符 `\n` 时才会换行。 + +### Awk 脚本编程 + +这篇文章中出现的所有 `awk` 代码,都在 Bash 终端中执行过。面对更复杂的程序,将命令放在文件(*脚本*)中会更容易。`-f FILE` 选项(不要和 `-F` 弄混了,那个选项用于字段分隔符),可用于指明包含可执行程序的文件。 + +举个例子,下面是一个简单的 awk 脚本。创建一个名为 `example1.awk` 的文件,包含以下内容: + +``` +/^a/ {print "A: " $0} +/^b/ {print "B: " $0} +``` + +如果一个文件包含 `awk` 程序,那么在给文件命名时,最好写上 `.awk` 的扩展名。 这样命名不是强制的,但这么做,会给文件管理器、编辑器(和你)一个关于文件内容的很有用的提示。 + +执行这一脚本: + +``` +$ awk -f example1.awk colours.txt +A: raspberry  red    4 +B: banana     yellow 6 +A: apple      green  8 +``` + +一个包含 `awk` 命令的文件,在最开头一行加上释伴 `#!`,就能变成可执行脚本。创建一个名为 `example2.awk` 的文件,包含以下内容: + +``` +#!/usr/bin/awk -f +# +# 除了第一行,在其他行前显示行号 +# + +NR > 1 { + printf "%d: %s\n",NR,$0 +} +``` + +可以说,脚本中只有一行,大多数情况下没什么用。但在某些情况下,执行一个脚本,比记住,然后打一条命令要容易的多。一个脚本文件,也提供了一个记录命令具体作用的好机会。以 `#` 号开头的行是注释,`awk` 会忽略它们。 + +给文件可执行权限: + +``` +$ chmod u+x example2.awk +``` + +执行脚本: + +``` +$ ./example2.awk colours.txt +2: apple      red    4 +2: banana     yellow 6 +4: raspberry red    3 +5: grape      purple 10 +[...] +``` + +将 `awk` 命令放在脚本文件中,有一个好处就是,修改和格式化输出会更容易。在终端中,如果能用一行执行多条 `awk` 命令,那么输入多行,才能达到同样效果,就显得有些多余了。 + +### 试一试 + +你现在已经足够了解,`awk` 是如何执行指令的了。现在你应该能编写复杂的 `awk` 程序了。试着编写一个 awk 脚本,它需要: 至少包括一个条件模式,以及多个规则。如果你想使用除 `print` 和 `printf` 以外的函数,可以参考在线 [gawk 手册][4]。 + +下面这个例子是个很好的切入点: + +``` +#!/usr/bin/awk -f +# +# 显示所有记录 除了出现以下情况 +# 如果第一个记录 包含 “raspberry” +# 将 “red” 替换成 “pi” + +$1 == "raspberry" { +        gsub(/red/,"pi") +} + +{ print } +``` + +试着执行这个脚本,看看输出是什么。接下来就看你自己的了。 + +这一系列的下一篇文章,将会介绍更多,能在更复杂(更有用!) 脚本中使用的函数。 + +这篇文章改编自 [Hacker Public Radio][5] 系列,一个技术社区博客。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/fields-records-variables-awk + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wenwensnow](https://github.com/wenwensnow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_laptop_code_programming_mountain_view.jpg?itok=yx5buqkr (Man at laptop on a mountain) +[2]: https://www.gnu.org/software/gawk/manual/html_node/History.html#History +[3]: https://linux.cn/article-11543-1.html +[4]: https://www.gnu.org/software/gawk/manual/ +[5]: http://hackerpublicradio.org/eps.php?id=2129 diff --git a/published/20191104 How To Update a Fedora Linux System -Beginner-s Tutorial.md b/published/201911/20191104 How To Update a Fedora Linux System -Beginner-s Tutorial.md similarity index 100% rename from published/20191104 How To Update a Fedora Linux System -Beginner-s Tutorial.md rename to published/201911/20191104 How To Update a Fedora Linux System -Beginner-s Tutorial.md diff --git a/published/20191106 Bash Script to Generate Patching Compliance Report on CentOS-RHEL Systems.md b/published/201911/20191106 Bash Script to Generate Patching Compliance Report on CentOS-RHEL Systems.md similarity index 100% rename from published/20191106 Bash Script to Generate Patching Compliance Report on CentOS-RHEL Systems.md rename to published/201911/20191106 Bash Script to Generate Patching Compliance Report on CentOS-RHEL Systems.md diff --git a/published/20191106 How to Schedule and Automate tasks in Linux using Cron Jobs.md b/published/201911/20191106 How to Schedule and Automate tasks in Linux using Cron Jobs.md similarity index 98% rename from published/20191106 How to Schedule and Automate tasks in Linux using Cron Jobs.md rename to published/201911/20191106 How to Schedule and Automate tasks in Linux using Cron Jobs.md index 6d380030f0..93727092b0 100644 --- a/published/20191106 How to Schedule and Automate tasks in Linux using Cron Jobs.md +++ b/published/201911/20191106 How to Schedule and Automate tasks in Linux using Cron Jobs.md @@ -60,7 +60,7 @@ m h d moy dow /path/to/script * `h`:表示小时,范围是 0 到 23 * `d`:代表一个月中的某天,范围是 1 到 31 * `moy`:这是一年中的月份。范围是 1 到 12 -* `doy`:这是星期几。范围是 0 到 6,其中 0 代表星期日 +* `dow`:这是星期几。范围是 0 到 6,其中 0 代表星期日 * `command`:这是要执行的命令,例如备份命令、重新启动和复制命令等 ### 管理 cron 任务 @@ -197,9 +197,9 @@ m h d moy dow /path/to/script @daily /path/to/script ``` -3)`@weekly` 时间戳等效于 `0 0 1 * mon` +3)`@weekly` 时间戳等效于 `0 0 * * 0` -它在每周的第一分钟执行 cron 任务,一周第一天是从星期一开始的。 +它在每周的第一分钟执行 cron 任务,一周第一天是从星期日开始的。 ``` @weekly /path/to/script diff --git a/published/201911/20191107 Demystifying Kubernetes.md b/published/201911/20191107 Demystifying Kubernetes.md new file mode 100644 index 0000000000..f98c0d4387 --- /dev/null +++ b/published/201911/20191107 Demystifying Kubernetes.md @@ -0,0 +1,234 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11628-1.html) +[#]: subject: (Demystifying Kubernetes) +[#]: via: (https://opensourceforu.com/2019/11/demystifying-kubernetes/) +[#]: author: (Abhinav Nath Gupta https://opensourceforu.com/author/abhinav-gupta/) + +揭开 Kubernetes 的神秘面纱 +====== + +![][2] + +> Kubernetes 是一款生产级的开源系统,用于容器化应用程序的自动部署、扩展和管理。本文关于使用 Kubernetes 来管理容器。 + + “容器”已成为最新的流行语之一。但是,这个词到底意味着什么呢?说起“容器”,人们通常会把它和 Docker 联系起来,Docker 是一个被定义为软件的标准化单元容器。该容器将软件和运行软件所需的环境封装到一个易于交付的单元中。 + +容器是一个软件的标准单元,用它来打包代码及其所有依赖项,这样应用程序就可以从一个计算环境到另一个计算环境快速可靠地运行。容器通过创建类似于 ISO 镜像的方式来实现此目的。容器镜像是一个轻量级的、独立的、可执行的软件包,其中包含运行应用程序所需的所有信息,包括代码、运行时、系统工具、系统库和设置。 + +容器镜像在运行时变成容器,对于 Docker 容器,镜像在 Docker 引擎上运行时变成容器。容器将软件与环境隔离开来,确保不同环境下的实例,都可以正常运行。 + +###什么是容器管理? + +容器管理是组织、添加或替换大量软件容器的过程。容器管理使用软件来自动化创建、部署和扩展容器。这一过程就需要容器编排,容器编排是一个自动对基于容器的应用程序进行部署、管理、扩展、联网和提供可用性的工具。 + +### Kubernetes + +Kubernetes 是一个可移植的、可扩展的开源平台,用于管理容器化的工作负载和服务,它有助于配置和自动化。它最初由 Google 开发,拥有一个庞大且快速增长的生态系统。Kubernetes 的服务、技术支持和工具得到广泛应用。 + +Google 在 2014 年开源了 Kubernetes 项目。Kubernetes 建立在 Google 十五年大规模运行生产工作负载的经验基础上,并结合了社区中最好的想法和实践以及声明式句法的使用。 + +下面列出了与Kubernetes生态系统相关的一些常用术语。 + +**Pod**:Pod 是 Kubernetes 应用程序的基本执行单元,是你创建或部署的 Kubernetes 对象模型中的最小和最简单的单元。Pod 代表在 Kubernetes 集群上运行的进程。 + +Pod 将运行中的容器、存储、网络 IP(唯一)和控制容器应如何运行的命令封装起来。它代表 Kubernetes 生态系统内的单个部署单元,代表一个应用程序的单个实例,该程序可能包含一个或多个紧密耦合并共享资源的容器。 + +Kubernetes 集群中的 Pod 有两种主要的使用方式。第一种是运行单个容器。即“一个容器一个 Pod”,这种方式是最常见的。第二种是运行多个需要一起工作的容器。 + +Pod 可能封装一个由紧密关联且需要共享资源的多个同位容器组成的应用程序。 + +副本集ReplicaSet:副本集的目的是维护在任何给定时间运行的一组稳定的副本容器集。 副本集包含有关一个特定 Pod 应该运行多少个副本的信息。为了创建多个 Pod 以匹配副本集条件,Kubernetes 使用 Pod 模板。副本集与其 Pod 的链接是通过后者的 `metas.ownerReferences` 字段实现,该字段指定哪个资源拥有当前对象。 + +服务Services:服务是一种抽象,用来公开一组 Pod 功能。使用 Kubernetes,你无需修改应用程序即可使用陌生服务发现机制。Kubernetes 给 Pod 提供了其自己的 IP 地址和一组 Pod 的单个 DNS 名称,并且可以在它们之间负载平衡。 + +服务解决的一个主要问题是 Web 应用程序前端和后端的集成。由于 Kubernetes 将幕后的 IP 地址提供给 Pod,因此当 Pod 被杀死并复活时,IP 地址会更改。这给给定的后端 IP 地址连接到相应的前端 IP 地址带来一个大问题。服务通过在 Pod 上提供抽象来解决此问题,类似于负载均衡器。 + +Volumes: Kubernetes 卷具有明确的生命周期,与围绕它的 Pod 相同。 因此,卷超过了 Pod 中运行的任何容器的寿命,并且在容器重新启动后保留了数据。当然,当 Pod 不存在时,该卷也将不再存在。也许比这更重要的是 Kubernetes 支持多种类型的卷,并且 Pod 可以同时使用任意数量的卷。 + +卷的核心只是一个目录,其中可能包含一些数据,Pod 中的容器可以访问该目录。该目录是如何产生的,它后端基于什么存储介质,其中的数据内容是什么,这些都由使用的特定卷类型来决定的。 + +### 为什么选择 Kubernetes? + +容器是捆绑和运行应用程序的好方法。在生产环境中,你需要管理运行应用程序的容器,并确保没有停机时间。例如,如果一个容器发生故障,则需要启动另一个容器。如果由系统自动实现这一操作,岂不是更好? Kubernetes 就是来解决这个问题的!Kubernetes 提供了一个框架来弹性运行分布式系统。该框架负责扩展需求、故障转移、部署模式等。例如,Kubernetes 可以轻松管理系统的金丝雀部署。 + +Kubernetes 为用户提供了: + +1. 服务发现和负载平衡 +2. 存储编排 +3. 自动退出和回退 +4. 自动打包 +5. 自我修复 +6. 秘密配置管理 + +### Kubernetes 可以做什么? + +在本文中,我们将会看到一些从头构建 Web 应用程序时如何使用 Kubernetes 的代码示例。我们将在 Python 中使用 Flask 创建一个简单的后端服务器。 + +对于那些想从头开始构建 Web 应用程序的人,有一些前提条件,即: + +1. 对 Docker、Docker 容器和 Docker 镜像的基本了解。可以访问[这里][8]快速了解。 +2. 系统中应该安装 Docker。 +3. 系统中应该安装 Kubernetes,有关如何在本地计算机上安装的说明,请访问[这里][9]。 + +现在,创建一个目录,如下代码片段所示: + +``` +mkdir flask-kubernetes/app && cd flask-kubernetes/app +``` + +接下来,在 `flask-kubernetes/app` 目录中,创建一个名为 `main.py` 的文件,如下面的代码片段所示: + +``` +touch main.py +``` + +在新创建的 `main.py` 文件中,粘贴下面代码: + +``` +from flask import Flask +app = Flask(__name__) + +@app.route("/") +def hello(): + return "Hello from Kubernetes!" + +if __name__ == "__main__": + app.run(host='0.0.0.0') +``` + +使用下面命令在本地安装 Flask: + +``` +pip install Flask==0.10.1 +``` + +Flask 安装后,执行下面的命令: + +``` +python app.py +``` + +应该在本地 5000 端口运行 Flask 服务器,这是 Flask 应用程序的默认端口,并且你可以在 http://localhost:5000 上看到输出 “Hello from Kubernetes!”。服务器在本地运行之后,我们创建一个供 Kubernetes 使用的 Docker 镜像。创建一个名为 `Dockerfile` 的文件,并将以下代码片段粘贴到其中: + +``` +FROM python:3.7 + +RUN mkdir /app +WORKDIR /app +ADD . /app/ +RUN pip install -r requirements.txt + +EXPOSE 5000 +CMD ["python", "/app/main.py"] +``` + +`Dockerfile` 文件的说明如下: + +1. Docker 将从 DockerHub 获取 Python 3.7 镜像。 +2. 将在镜像中创建一个应用程序目录。 +3. 它将一个 `/app` 目录设置为工作目录。 +4. 将内容从主机中的应用程序目录复制到镜像应用程序目录。 +5. 发布端口 5000。 +6. 最后,它运行命令,启动 Flask 服务器。 + +接下来,我们将使用以下命令创建 Docker 镜像: + +``` +docker build -f Dockerfile -t flask-kubernetes:latest . +``` + +创建 Docker 镜像后,我们可以使用以下命令在本地运行该镜像进行测试: + +``` +docker run -p 5001:5000 flask-kubernetes +``` + +通过运行容器在本地完成测试之后,我们需要在 Kubernetes 中部署它。我们将首先使用 `kubectl` 命令验证 Kubernetes 是否正在运行。如果没有报错,则说明它正在工作。如果有报错,请参考[该信息][9]。 + +接下来,我们创建一个部署文件。这是一个 Yaml 文件,其中包含有关 Kubernetes 的说明,该说明涉及如何以声明性的方式创建 Pod 和服务。因为我们有 Flask Web 应用程序,我们将创建一个 `deployment.yaml` 文件,并在其中包含 Pod 和服务声明。 + +创建一个名为 `deployment.yaml` 的文件并向其中添加以下内容,然后保存: + +``` +apiVersion: v1 +kind: Service +metadata: + name: flask-kubernetes -service +spec: + selector: + app: flask-kubernetes + ports: + - protocol: "TCP" + port: 6000 + targetPort: 5000 + type: LoadBalancer + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: flask-kubernetes +spec: + replicas: 4 + template: + metadata: + labels: + app: flask-kubernetes + spec: + containers: + - name: flask-kubernetes + image: flask-kubernetes:latest + imagePullPolicy: Never + ports: + - containerPort: 5000 +``` + +使用以下命令将 yaml 文件发送到 Kubernetes: + +``` +kubectl apply -f deployment.yaml +``` + +如果执行以下命令,你会看到 Pod 正在运行: + +``` +kubectl get pods +``` + +现在,导航至 http://localhost:6000,你应该会看到 “Hello from Kubernetes!”消息。成功了! 该应用程序现在正在 Kubernetes 中运行! + +### Kubernetes 做不了什么? + +Kubernetes 不是一个传统的,包罗万象的 PaaS(平台即服务)系统。 由于 Kubernetes 运行在容器级别而非硬件级别,因此它提供了 PaaS 产品共有的一些普遍适用功能,如部署、扩展、负载平衡、日志记录和监控。Kubernetes 为开发人员平台提供了构建块,但在重要的地方保留了用户的选择和灵活性。 + +* Kubernetes 不限制所支持的应用程序的类型。如果应用程序可以在容器中运行,那么它应该可以在 Kubernetes 上更好地运行。 +* 它不部署和构建源代码。 +* 它不决定日志记录、监视或警报解决方案。 +* 它不提供或不要求配置语言/系统。它提供了一个声明式的 API 供所有人使用。 +* 它不提供或不采用任何全面的机器配置、维护、管理或自我修复系统。 + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/demystifying-kubernetes/ + +作者:[Abhinav Nath Gupta][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensourceforu.com/author/abhinav-gupta/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Gear-kubernetes.jpg?resize=696%2C457&ssl=1 (Gear kubernetes) +[2]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Gear-kubernetes.jpg?fit=800%2C525&ssl=1 +[3]: https://secure.gravatar.com/avatar/f65917facf5f28936663731fedf545c4?s=100&r=g +[4]: https://opensourceforu.com/author/abhinav-gupta/ +[5]: mailto:abhi.aec89@gmail.com +[6]: http://opensourceforu.com/wp-content/uploads/2013/10/assoc.png +[7]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US +[8]: https://www.docker.com/sites/default/files/Docker_CheatSheet_08.09.2016_0.pdf +[9]: https://kubernetes.io/docs/setup/learning-environment/minikube/ diff --git a/published/20191107 How to add a user to your Linux desktop.md b/published/201911/20191107 How to add a user to your Linux desktop.md similarity index 100% rename from published/20191107 How to add a user to your Linux desktop.md rename to published/201911/20191107 How to add a user to your Linux desktop.md diff --git a/published/20191107 Tuning your bash or zsh shell on Fedora Workstation and Silverblue.md b/published/201911/20191107 Tuning your bash or zsh shell on Fedora Workstation and Silverblue.md similarity index 100% rename from published/20191107 Tuning your bash or zsh shell on Fedora Workstation and Silverblue.md rename to published/201911/20191107 Tuning your bash or zsh shell on Fedora Workstation and Silverblue.md diff --git a/published/20191108 7 Best Open Source Tools that will help in AI Technology.md b/published/201911/20191108 7 Best Open Source Tools that will help in AI Technology.md similarity index 100% rename from published/20191108 7 Best Open Source Tools that will help in AI Technology.md rename to published/201911/20191108 7 Best Open Source Tools that will help in AI Technology.md diff --git a/published/20191108 Budget-friendly Linux Smartphone PinePhone Will be Available to Pre-order Next Week.md b/published/201911/20191108 Budget-friendly Linux Smartphone PinePhone Will be Available to Pre-order Next Week.md similarity index 100% rename from published/20191108 Budget-friendly Linux Smartphone PinePhone Will be Available to Pre-order Next Week.md rename to published/201911/20191108 Budget-friendly Linux Smartphone PinePhone Will be Available to Pre-order Next Week.md diff --git a/published/20191108 How to manage music tags using metaflac.md b/published/201911/20191108 How to manage music tags using metaflac.md similarity index 100% rename from published/20191108 How to manage music tags using metaflac.md rename to published/201911/20191108 How to manage music tags using metaflac.md diff --git a/published/20191111 Confirmed- Microsoft Edge Will be Available on Linux.md b/published/201911/20191111 Confirmed- Microsoft Edge Will be Available on Linux.md similarity index 100% rename from published/20191111 Confirmed- Microsoft Edge Will be Available on Linux.md rename to published/201911/20191111 Confirmed- Microsoft Edge Will be Available on Linux.md diff --git a/published/201911/20191112 Getting started with PostgreSQL.md b/published/201911/20191112 Getting started with PostgreSQL.md new file mode 100644 index 0000000000..6a987c22c0 --- /dev/null +++ b/published/201911/20191112 Getting started with PostgreSQL.md @@ -0,0 +1,201 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11593-1.html) +[#]: subject: (Getting started with PostgreSQL) +[#]: via: (https://opensource.com/article/19/11/getting-started-postgresql) +[#]: author: (Greg Pittman https://opensource.com/users/greg-p) + +PostgreSQL 入门 +====== + +> 安装、设置、创建和开始使用 PostgreSQL 数据库。 + +![](https://img.linux.net.cn/data/attachment/album/201911/20/085936u10q7eme1euu4ak3.jpg) + +每个人或许都有需要在数据库中保存的东西。即使你执着于使用纸质文件或电子文件,它们也会变得很麻烦。纸质文档可能会丢失或混乱,你需要访问的电子信息可能会隐藏在段落和页面的深处。 + +在我从事医学工作的时候,我使用 [PostgreSQL][2] 来跟踪我的住院患者名单并提交有关住院患者的信息。我将我的每日患者名单打印在口袋里,以便快速了解患者房间、诊断或其他细节的任何变化并做出快速记录。 + +我以为一切没问题,直到去年我妻子决定买一辆新车,我“接手”了她以前的那辆车。她保留了汽车维修和保养服务收据的文件夹,但随着时间的流逝,它变得杂乱。与其花时间筛选所有纸条以弄清楚什么时候做了什么,我认为 PostgreSQL 将是更好的跟踪此信息的方法。 + +### 安装 PostgreSQL + +自上次使用 PostgreSQL 以来已经有一段时间了,我已经忘记了如何使用它。实际上,我甚至没有在计算机上安装它。安装它是第一步。我使用 Fedora,因此在控制台中运行: + +``` +dnf list postgresql* +``` + +请注意,你无需使用 `sudo` 即可使用 `list` 选项。该命令返回了很长的软件包列表。看了眼后,我决定只需要三个:postgresql、postgresql-server 和 postgresql-docs。 + +为了了解下一步需要做什么,我决定查看 [PostgreSQL 文档][3]。文档参考内容非常丰富,实际上,丰富到令人生畏。幸运的是,我发现我在升级 Fedora 时曾经做过的一些笔记,希望有效地导出数据库,在新版本上重新启动 PostgreSQL,以及导入旧数据库。 + +### 设置 PostgreSQL + +与大多数其他软件不同,你不能只是安装好 PostgreSQL 就开始使用它。你必须预先执行两个基本步骤:首先,你需要设置 PostgreSQL,第二,你需要启动它。你必须以 `root` 用户身份执行这些操作(`sudo` 在这里不起作用)。 + +要设置它,请输入: + +``` +postgresql-setup –initdb +``` + +这将确定 PostgreSQL 数据库在计算机上的位置。然后(仍为 `root`)输入以下两个命令: + +``` +systemctl start postgresql.service +systemctl enable postgresql.service +``` + +第一个命令为当前会话启动 PostgreSQL(如果你关闭机器,那么 PostgreSQL 也将关闭)。第二个命令使 PostgreSQL 在随后的重启中自动启动。 + +### 创建用户 + +PostgreSQL 正在运行,但是你仍然不能使用它,因为你还没有用户。为此,你需要切换到特殊用户 `postgres`。当你仍以 `root` 身份运行时,输入: + +``` +su postgres +``` + +由于你是以 `root` 的身份执行此操作的,因此无需输入密码。root 用户可以在不知道密码的情况下以任何用户身份操作;这就是使其强大而危险的原因之一。 + +现在你就是 `postgres` 了,请运行下面两个命令,如下所示创建用户(创建用户 `gregp`): + +``` +createuser gregp +createdb gregp +``` + +你可能会看到错误消息,如:`Could not switch to /home/gregp`。这只是意味着用户 `postgres`不能访问该目录。尽管如此,你的用户和数据库已创建。接下来,输入 `exit` 并按回车两次,这样就回到了原来的用户下(`root`)。 + +### 设置数据库 + +要开始使用 PostgreSQL,请在命令行输入 `psql`。你应该在每行左侧看到类似 `gregp=>` 的内容,以显示你使用的是 PostgreSQL,并且只能使用它理解的命令。你自动获得一个数据库(我的名为 `gregp`),它里面完全没有内容。对 PostgreSQL 来说,数据库只是一个工作空间。在空间内,你可以创建*表*。表包含变量列表,而表中的每个变量是构成数据库的数据。 + +以下是我设置汽车服务数据库的方式: + +``` +CREATE TABLE autorepairs ( +        date            date, +        repairs         varchar(80), +        location        varchar(80), +        cost            numeric(6,2) +); +``` + +我本可以在一行内输入,但为了更好地说明结构,并表明 PostgreSQL 不会解释制表符和换行的空白,我分成了多行。字段包含在括号中,每个变量名和数据类型与下一个变量用逗号分隔(最后一个除外),命令以分号结尾。所有命令都必须以分号结尾! + +第一个变量名是 `date`,它的数据类型也是 `date`,这在 PostgreSQL 中没关系。第二个和第三个变量 `repairs` 和 `location` 都是 `varchar(80)` 类型,这意味着它们可以是最多 80 个任意字符(字母、数字等)。最后一个变量 `cost` 使用 `numeric` 类型。括号中的数字表示最多有六位数字,其中两位是小数。最初,我尝试了 `real` 类型,这将是一个浮点数。`real` 类型的问题是作为数据类型在使用时,在遇到 `WHERE` 子句,类似 `WHERE cost = 0` 或其他任何特定数字。由于 `real` 值有些不精确,因此特定数字将永远不会匹配。 + +### 输入数据 + +接下来,你可以使用 `INSERT INTO` 命令添加一些数据(在 PostgreSQL 中称为*行*): + +``` +INSERT INTO autorepairs VALUES ('2017-08-11', 'airbag recall', 'dealer', 0); +``` + +请注意,括号构成了一个值的容器,它必须以正确的顺序,用逗号分隔,并在命令末尾加上分号。`date` 和 `varchar(80)` 类型的值必须包含在单引号中,但数字值(如 `numeric`)不用。作为反馈,你应该会看到: + +``` +INSERT 0 1 +``` + +与常规终端会话一样,你会有输入命令的历史记录,因此,在输入后续行时,通常可以按向上箭头键来显示最后一个命令并根据需要编辑数据,从而节省大量时间。 + +如果出了什么问题怎么办?使用 `UPDATE` 更改值: + +``` +UPDATE autorepairs SET date = '2017-11-08' WHERE repairs = 'airbag recall'; +``` + +或者,也许你不再需要表中的行。使用 `DELETE`: + +``` +DELETE FROM autorepairs WHERE repairs = 'airbag recall'; +``` + +这将删除整行。 + +最后一件事:即使我在 PostgreSQL 命令中一直使用大写字母(在大多数文档中也这么做),你也可以用小写字母输入,我也经常如此。 + +### 输出数据 + +如果你想展示数据,使用 `SELECT`: + +``` +SELECT * FROM autorepairs ORDER BY date; +``` + +没有 `ORDER BY` 的话,行将不管你输入的内容来显示。例如,以下就是我终端中输出的我的汽车服务数据: + +``` +SELECT date, repairs FROM autorepairs ORDER BY date; + +    date   |                             repairs                              +-----------+----------------------------------------------------------------- +2008-08-08 | oil change, air filter, spark plugs +2011-09-30 | 35000 service, oil change, rotate tires/balance wheels +2012-03-07 | repl battery +2012-11-14 | 45000 maint, oil/filter +2014-04-09 | 55000 maint, oil/filter, spark plugs, air/dust filters +2014-04-21 | replace 4 tires +2014-04-21 | wheel alignment +2016-06-01 | 65000 mile service, oil change +2017-05-16 | oil change, replce oil filt housing +2017-05-26 | rotate tires +2017-06-05 | air filter, cabin filter,spark plugs +2017-06-05 | brake pads and rotors, flush brakes +2017-08-11 | airbag recall +2018-07-06 | oil/filter change, fuel filter, battery svc +2018-07-06 | transmission fl, p steering fl, rear diff fl +2019-07-22 | oil & filter change, brake fluid flush, front differential flush +2019-08-20 | replace 4 tires +2019-10-09 | replace passenger taillight bulb +2019-10-25 | replace passenger taillight assembly +(19 rows) +``` + +要将此发送到文件,将输出更改为: + + +``` +\o autorepairs.txt +``` + +然后再次运行 `SELECT` 命令。 + +### 退出 PostgreSQL + +最后,在终端中退出 PostgreSQL,输入: + +``` +quit +``` + +或者它的缩写版: + +``` +\q +``` + +虽然这只是 PostgreSQL 的简要介绍,但我希望它展示了将数据库用于这样的简单任务既不困难也不费时。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/getting-started-postgresql + +作者:[Greg Pittman][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/greg-p +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_code_programming_laptop.jpg?itok=ormv35tV (Guy on a laptop on a building) +[2]: https://www.postgresql.org/ +[3]: http://www.postgresql.org/docs diff --git a/published/201911/20191113 Getting Started With ZFS Filesystem on Ubuntu 19.10.md b/published/201911/20191113 Getting Started With ZFS Filesystem on Ubuntu 19.10.md new file mode 100644 index 0000000000..f416b4e5b7 --- /dev/null +++ b/published/201911/20191113 Getting Started With ZFS Filesystem on Ubuntu 19.10.md @@ -0,0 +1,166 @@ +[#]: collector: (lujun9972) +[#]: translator: (guevaraya) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11598-1.html) +[#]: subject: (Getting Started With ZFS Filesystem on Ubuntu 19.10) +[#]: via: (https://itsfoss.com/zfs-ubuntu/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +在 Ubuntu 19.10 上入门 ZFS 文件系统 +====== + +![][4] + +Ubuntu 19.10 的主要新特性之一就是 [ZFS][2]。现在你可以很容易的无需额外努力就可以在 Ubuntu 系统上安装 ZFS了。 + +一般情况下,安装 Linux 都会选择 Ext4 文件系统。但是如果是全新安装 Ubuntu 19.10,在安装的启动阶段可以看到 ZFS 选项。 + +![你可以在安装 Ubuntu 19.10 的时候选择 ZFS][3] + +让我们看看 ZFS 为何重要,以及如何在已经安装了 ZFS 的 Ubuntu 上使用它。 + +### ZFS 与其他文件系统有哪些区别? + +ZFS 的设计初衷是:处理海量存储和避免数据损坏。ZFS 可以处理 256 千万亿的 ZB 数据。(这就是 ZFS 的 Z)且它可以处理最大 16 EB 的文件。 + +如果你仅有一个单磁盘的笔记本电脑,你可以体验 ZFS 的数据保护特性。写时复制(COW)特性确保正在使用的数据不会被覆盖,相反,新的数据会被写到一个新的块中,同时文件系统的元数据会被更新到新块中。ZFS 可容易的创建文件系统的快照。这个快照可追踪文件系统的更改,并共享数据块确保节省数据空间。 + +ZFS 为磁盘上的每个文件分配一个校验和。它会不断的校验文件的状态和校验和。如果发现文件被损坏了,它就会尝试修复文件。 + +我写过一个文章详细介绍 [什么是 ZFS以及它有哪些特性][2]。如果你感兴趣可以去阅读下。 + +注:请谨记 ZFS 的数据保护特性会导致性能下降。 + +### Ubuntu 下使用 ZFS [适用于中高级用户] + +一旦你在你的主磁盘上全新安装了带有 ZFS 的 Ubuntu,你就可以开始体验它的特性。 + +请注意所有的 ZFS 设置过程都需要命令行。我不知道它有任何 GUI 工具。 + +#### 创建一个 ZFS 池 + +**这段仅针对拥有多个磁盘的系统。如果你只有一个磁盘,Ubuntu 会在安装的时候自动创建池。** + +在创建池之前,你需要为池找到磁盘的 id。你可以用命令 `lsblk` 查询出这个信息。 + +为三个磁盘创建一个基础池,用以下命令: + +``` +sudo zpool create pool-test /dev/sdb /dev/sdc /dev/sdd +``` + +请记得替换 `pool-test` 为你选择的的命名。 + +这个命令将会设置“无冗余 RAID-0 池”。这意味着如果一个磁盘被破坏或有故障,你将会丢失数据。如果你执行以上命令,还是建议做一个常规备份。 + +你可以用下面命令将另一个磁盘增加到池中: + +``` +sudo zpool add pool-name /dev/sdx +``` + +#### 查看 ZFS 池的状态 + +你可以用这个命令查询新建池的状态: + +``` +sudo zpool status pool-test +``` + +![Zpool 状态][6] + +#### 镜像一个 ZFS 池 + +为确保数据的安全性,你可以创建镜像。镜像意味着每个磁盘包含同样的数据。使用镜像设置,你可能会丢失三个磁盘中的两个,并且仍然拥有所有信息。 + +要创建镜像你可以用下面命令: + +``` +sudo zpool create pool-test mirror /dev/sdb /dev/sdc /dev/sdd +``` + +#### 创建 ZFS 用于备份恢复的快照 + +快照允许你创建一个后备,以防某个文件被删除或被覆盖。比如,我们创建一个快照,当在用户主目录下删除一些目录后,然后把它恢复。 + +首先,你需要找到你想要的快照数据集。你可以这样做: + +``` +zfs list +``` + +![Zfs List][7] + +你可以看到我的家目录位于 `rpool/USERDATA/johnblood_uwcjk7`。 + +我们用下面命令创建一个名叫 `1910` 的快照: + +``` +sudo zfs snapshot rpool/USERDATA/johnblood_uwcjk7@1019 +``` + +快照很快创建完成。现在你可以删除 `Downloads` 和 `Documents` 目录。 + +现在你用以下命令恢复快照: + +``` +sudo zfs rollback rpool/USERDATA/johnblood_uwcjk7@1019 +``` + +回滚的时间长短取决于有多少信息改变。现在你可以查看家目录,被删除的目录(和它的内容)将会被恢复过来。 + +### 要不要试试 ZFS ? + +这篇文章仅简单介绍的 Ubuntu下 ZFS 的用法。更多的信息请参考 [Ubuntu 的 ZFS Wiki页面][5]。我也推荐阅读 [ArsTechnica 的精彩文章][8]。 + +这个是试验性的功能。如果你还不了解 ZFS,你想用一个简单稳定的系统,请安装标准文件系统 EXT4。如果你想用闲置的机器体验,可以参照上面了解 ZFS。如果你是一个“专家”,并且知道自己在做什么,则可以随时随地随意尝试ZFS。 + +你之前用过 ZFS 吗?请在下面留言。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/zfs-ubuntu/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[guevaraya](https://github.com/guevaraya) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/ubuntu-19-04-release-features/ +[2]: https://itsfoss.com/what-is-zfs/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/zfs-ubuntu-19-10.jpg?ssl=1 +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/Using_ZFS_Ubuntu.jpg?resize=800%2C450&ssl=1 +[5]: https://wiki.ubuntu.com/Kernel/Reference/ZFS +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/zpool-status.png?ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/10/zfs-list.png?ssl=1 +[8]: https://arstechnica.com/information-technology/2019/10/a-detailed-look-at-ubuntus-new-experimental-zfs-installer/ +[9]: https://reddit.com/r/linuxusersgroup + know in the comments below. If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][9]. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/zfs-ubuntu/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/ubuntu-19-04-release-features/ +[2]: https://linux.cn/article-10034-1.html +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/zfs-ubuntu-19-10.jpg?ssl=1 +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/Using_ZFS_Ubuntu.jpg?resize=800%2C450&ssl=1 +[5]: https://wiki.ubuntu.com/Kernel/Reference/ZFS +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/zpool-status.png?ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/10/zfs-list.png?ssl=1 +[8]: https://arstechnica.com/information-technology/2019/10/a-detailed-look-at-ubuntus-new-experimental-zfs-installer/ +[9]: https://reddit.com/r/linuxusersgroup diff --git a/translated/tech/20191113 How to install and Configure Postfix Mail Server on CentOS 8.md b/published/201911/20191113 How to install and Configure Postfix Mail Server on CentOS 8.md similarity index 61% rename from translated/tech/20191113 How to install and Configure Postfix Mail Server on CentOS 8.md rename to published/201911/20191113 How to install and Configure Postfix Mail Server on CentOS 8.md index 66452903ae..6fa7ef3d4f 100644 --- a/translated/tech/20191113 How to install and Configure Postfix Mail Server on CentOS 8.md +++ b/published/201911/20191113 How to install and Configure Postfix Mail Server on CentOS 8.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11597-1.html) [#]: subject: (How to install and Configure Postfix Mail Server on CentOS 8) [#]: via: (https://www.linuxtechi.com/install-configure-postfix-mailserver-centos-8/) [#]: author: (James Kiarie https://www.linuxtechi.com/author/james/) @@ -10,9 +10,9 @@ 如何在 CentOS 8 上安装和配置 Postfix 邮件服务器 ====== -**Postfix** 是一个免费的开源 **MTA**(邮件传输代理),用于在 Linux 系统上路由或传递电子邮件。在本指南中,你将学习如何在 CentOS 8 上安装和配置 Postfix。 +Postfix 是一个自由开源的 MTA(邮件传输代理),用于在 Linux 系统上路由或传递电子邮件。在本指南中,你将学习如何在 CentOS 8 上安装和配置 Postfix。 -[![Install-configure-Postfx-Server-CentOS8][1]][2] +![Install-configure-Postfx-Server-CentOS8][2] 实验室设置: @@ -20,8 +20,6 @@ * IP 地址:192.168.1.13 * 主机名:server1.crazytechgeek.info(确保域名指向服务器的 IP) - - ### 步骤 1)更新系统 第一步是确保系统软件包是最新的。为此,请按如下所示更新系统: @@ -30,7 +28,7 @@ # dnf update ``` -继续之前,还请确保不存在其他 **MTA**(如 **Sendmail**),因为这将导致与 Postfix 配置冲突。例如,要删除 Sendmail,请运行以下命令: +继续之前,还请确保不存在其他 MTA(如 Sendmail),因为这将导致与 Postfix 配置冲突。例如,要删除 Sendmail,请运行以下命令: ``` # dnf remove sendmail @@ -38,14 +36,14 @@ ### 步骤 2)设置主机名并更新 /etc/hosts -使用下面的 hostnamectl 命令在系统上设置主机名, +使用下面的 `hostnamectl` 命令在系统上设置主机名: ``` # hostnamectl set-hostname server1.crazytechgeek.info # exec bash ``` -此外,你需要在 /etc/hosts 中添加系统的主机名和 IP。 +此外,你需要在 `/etc/hosts` 中添加系统的主机名和 IP: ``` # vim /etc/hosts @@ -62,7 +60,7 @@ # dnf install postfix ``` -[![Install-Postfix-Centos8][1]][3] +![Install-Postfix-Centos8][3] ### 步骤 4)启动并启用 Postfix 服务 @@ -73,29 +71,29 @@ # systemctl enable postfix ``` -要检查 Postfix 状态,请运行以下 systemctl 命令 +要检查 Postfix 状态,请运行以下 `systemctl` 命令: ``` # systemctl status postfix ``` -![Start-Postfix-check-status-centos8][1] +![Start-Postfix-check-status-centos8][9] 太好了,我们已经验证了 Postfix 已启动并正在运行。接下来,我们将配置 Postfix 从本地发送邮件到我们的服务器。 ### 步骤 5)安装 mailx 邮件客户端 -在配置 Postfix 服务器之前,我们需要安装 mailx,要安装它,请运行以下命令: +在配置 Postfix 服务器之前,我们需要安装 `mailx`,要安装它,请运行以下命令: ``` # dnf install mailx ``` -![Install-Mailx-CentOS8][1] +![Install-Mailx-CentOS8][10] ### 步骤 6)配置 Postfix 邮件服务器 -Postfix 的配置文件位于 **/etc/postfix/main.cf** 中。我们需要对配置文件进行一些修改,因此请使用你喜欢的文本编辑器将其打开。 +Postfix 的配置文件位于 `/etc/postfix/main.cf` 中。我们需要对配置文件进行一些修改,因此请使用你喜欢的文本编辑器将其打开: ``` # vi /etc/postfix/main.cf @@ -121,7 +119,7 @@ mynetworks = 192.168.1.0/24, 127.0.0.0/8 home_mailbox = Maildir/ ``` -完成后,保存并退出配置文件。重新启动 postfix 服务以使更改生效。 +完成后,保存并退出配置文件。重新启动 postfix 服务以使更改生效: ``` # systemctl restart postfix @@ -136,7 +134,7 @@ home_mailbox = Maildir/ # passwd postfixuser ``` -接下来,运行以下命令,从本地用户 **pkumar** 发送邮件到另一个用户 “**postfixuser**”。 +接下来,运行以下命令,从本地用户 `pkumar` 发送邮件到另一个用户 `postfixuser`。 ``` # telnet localhost smtp @@ -181,7 +179,7 @@ Escape character is '^]'. 250 SMTPUTF8 ``` -接下来,运行橙色高亮的命令,例如 “mail from”、“rcpt to”,“data”,最后输入 “quit”, +接下来,运行橙色高亮的命令,例如 `mail from`、`rcpt to`、`data`,最后输入 `quit`: ``` mail from: @@ -198,11 +196,11 @@ quit Connection closed by foreign host ``` -完成 telnet 命令可从本地用户 “**pkumar**” 发送邮件到另一个本地用户 “**postfixuser**”,如下所示: +完成 `telnet` 命令可从本地用户 `pkumar` 发送邮件到另一个本地用户 `postfixuser`,如下所示: -![Send-email-with-telnet-centos8][1] +![Send-email-with-telnet-centos8][11] -如果一切都按计划进行,那么你应该可以在新用户的家目录中查看发送的邮件。 +如果一切都按计划进行,那么你应该可以在新用户的家目录中查看发送的邮件: ``` # ls /home/postfixuser/Maildir/new @@ -216,37 +214,37 @@ Connection closed by foreign host # cat /home/postfixuser/Maildir/new/1573580091.Vfd02I20050b8M635437.server1.crazytechgeek.info ``` -![Read-postfix-email-linux][1] +![Read-postfix-email-linux][12] ### Postfix 邮件服务器日志 -Postfix 邮件服务器邮件日志保存在文件 “**/var/log/maillog**” 中,使用以下命令查看实时日志, +Postfix 邮件服务器邮件日志保存在文件 `/var/log/maillog` 中,使用以下命令查看实时日志, ``` # tail -f /var/log/maillog ``` -![postfix-maillogs-centos8][1] +![postfix-maillogs-centos8][13] ### 保护 Postfix 邮件服务器 -建议始终确保客户端和 postfix 服务器之间的通信安全,这可以使用 SSL 证书来实现,它们可以来自受信任的权威机构或自签名证书。在本教程中,我们将使用 **openssl** 命令生成用于 postfix 的自签名证书, +建议始终确保客户端和 Postfix 服务器之间的通信安全,这可以使用 SSL 证书来实现,它们可以来自受信任的权威机构或自签名证书。在本教程中,我们将使用 `openssl` 命令生成用于 Postfix 的自签名证书, -我假设 openssl 已经安装在你的系统上,如果未安装,请使用以下 dnf 命令, +我假设 `openssl` 已经安装在你的系统上,如果未安装,请使用以下 `dnf` 命令: ``` # dnf install openssl -y ``` -使用下面的 openssl 命令生成私钥和 CSR(证书签名请求), +使用下面的 `openssl` 命令生成私钥和 CSR(证书签名请求): ``` # openssl req -nodes -newkey rsa:2048 -keyout mail.key -out mail.csr ``` -![Postfix-Key-CSR-CentOS8][1] +![Postfix-Key-CSR-CentOS8][14] -现在,使用以下 openssl 命令生成自签名证书, +现在,使用以下 openssl 命令生成自签名证书: ``` # openssl x509 -req -days 365 -in mail.csr -signkey mail.key -out mail.crt @@ -256,13 +254,13 @@ Getting Private key # ``` -现在将私钥和证书文件复制到 /etc/postfix 目录下。 +现在将私钥和证书文件复制到 `/etc/postfix` 目录下: ``` # cp mail.key mail.crt /etc/postfix ``` -在 postfix 配置文件中更新私钥和证书文件的路径 +在 Postfix 配置文件中更新私钥和证书文件的路径: ``` # vi /etc/postfix/main.cf @@ -274,21 +272,21 @@ smtpd_tls_security_level = may ……… ``` -重启 postfix 服务以使上述更改生效。 +重启 Postfix 服务以使上述更改生效: ``` # systemctl restart postfix ``` -让我们尝试使用 mailx 客户端将邮件发送到内部本地域和外部域。 +让我们尝试使用 `mailx` 客户端将邮件发送到内部本地域和外部域。 -**从 pkumar 发送内部本地邮件到 postfixuser 中** +从 `pkumar` 发送内部本地邮件到 `postfixuser` 中: ``` # echo "test email" | mailx -s "Test email from Postfix MailServer" -r root@linuxtechi root@linuxtechi ``` -使用以下命令检查并阅读邮件, +使用以下命令检查并阅读邮件: ``` # cd /home/postfixuser/Maildir/new/ @@ -299,19 +297,19 @@ total 8 # cat 1573612845.Vfd02I20050bbM466643.server1.crazytechgeek.info ``` -![Read-Postfixuser-Email-CentOS8][1] +![Read-Postfixuser-Email-CentOS8][15] -**从 postfixuser 发送邮件到外部域 (( [root@linuxtechi][4]))** +从 `postfixuser` 发送邮件到外部域(`root@linuxtechi.com`): ``` # echo "External Test email" | mailx -s "Postfix MailServer" -r root@linuxtechi root@linuxtechi ``` -**注意:** 如果你的 IP 没有被任何地方列入黑名单,那么你发送到外部域的邮件将被发送,否则它将被退回,并提示你的 IP 被 spamhaus 之类的数据库列入黑名单。 +注意:如果你的 IP 没有被任何地方列入黑名单,那么你发送到外部域的邮件将被发送,否则它将被退回,并提示你的 IP 被 spamhaus 之类的数据库列入黑名单。 ### 检查 Postfix 邮件队列 -使用mailq命令列出队列中的邮件。 +使用 `mailq` 命令列出队列中的邮件: ``` # mailq @@ -321,13 +319,6 @@ Mail queue is empty 完成!我们的 Postfix 配置正常工作了!目前就这样了。我们希望你觉得本教程有见地,并且你可以轻松地设置本地 Postfix 服务器。 - * [Facebook][5] - * [Twitter][6] - * [LinkedIn][7] - * [Reddit][8] - - - -------------------------------------------------------------------------------- via: https://www.linuxtechi.com/install-configure-postfix-mailserver-centos-8/ @@ -335,7 +326,7 @@ via: https://www.linuxtechi.com/install-configure-postfix-mailserver-centos-8/ 作者:[James Kiarie][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -345,7 +336,10 @@ via: https://www.linuxtechi.com/install-configure-postfix-mailserver-centos-8/ [2]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Install-configure-Postfx-Server-CentOS8.jpg [3]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Install-Postfix-Centos8.png [4]: https://www.linuxtechi.com/cdn-cgi/l/email-protection -[5]: http://www.facebook.com/sharer.php?u=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-configure-postfix-mailserver-centos-8%2F&t=How%20to%20install%20and%20Configure%20Postfix%20Mail%20Server%20on%20CentOS%208 -[6]: http://twitter.com/share?text=How%20to%20install%20and%20Configure%20Postfix%20Mail%20Server%20on%20CentOS%208&url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-configure-postfix-mailserver-centos-8%2F&via=Linuxtechi -[7]: http://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-configure-postfix-mailserver-centos-8%2F&title=How%20to%20install%20and%20Configure%20Postfix%20Mail%20Server%20on%20CentOS%208 -[8]: http://www.reddit.com/submit?url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-configure-postfix-mailserver-centos-8%2F&title=How%20to%20install%20and%20Configure%20Postfix%20Mail%20Server%20on%20CentOS%208 +[9]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Start-Postfix-check-status-centos8.png +[10]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Install-Mailx-CentOS8.png +[11]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Send-email-with-telnet-centos8.png +[12]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Read-postfix-email-linux.png +[13]: https://www.linuxtechi.com/wp-content/uploads/2019/11/postfix-maillogs-centos8.png +[14]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Postfix-Key-CSR-CentOS8.png +[15]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Read-Postfixuser-Email-CentOS8.png diff --git a/published/201911/20191114 Cleaning up with apt-get.md b/published/201911/20191114 Cleaning up with apt-get.md new file mode 100644 index 0000000000..7ae6d9779b --- /dev/null +++ b/published/201911/20191114 Cleaning up with apt-get.md @@ -0,0 +1,87 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11601-1.html) +[#]: subject: (Cleaning up with apt-get) +[#]: via: (https://www.networkworld.com/article/3453032/cleaning-up-with-apt-get.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +使用 apt-get 清理 +====== + +> 大多数使用基于 Debian 的系统的人通常会使用 apt-get 来安装软件包和升级,但是我们多久才清理一次?让我们看下该工具本身的一些清理选项。 + +![](https://img.linux.net.cn/data/attachment/album/201911/22/082025p39oeuufdote517e.jpg) + +在基于 Debian 的系统上运行 `apt-get` 命令是很常规的。软件包的更新相当频繁,诸如 `apt-get update` 和 `apt-get upgrade` 之类的命令使此过程非常容易。另一方面,你多久使用一次 `apt-get clean`、`apt-get autoclean` 或 `apt-get autoremove`? + +这些命令会在 `apt-get` 的安装操作后清理并删除仍在系统上但不再需要的文件,这通常是因为需要它们的程序已经卸载。 + +### apt-get clean + +`apt-get clean` 命令清除遗留在 `/var/cache` 中的已取回的包文件的本地仓库。它清除的目录是 `/var/cache/apt/archives/` 和 `/var/cache/apt/archives/partial/`。它留在 `/var/cache/apt/archives` 中的唯一文件是 `lock` 文件和 `partial` 子目录。 + +在运行清理操作之前,目录中可能包含许多文件: + +``` +/var/cache/apt/archives/db5.3-util_5.3.28+dfsg1-0.6ubuntu1_amd64.deb +/var/cache/apt/archives/db-util_1%3a5.3.21~exp1ubuntu2_all.deb +/var/cache/apt/archives/lock +/var/cache/apt/archives/postfix_3.4.5-1ubuntu1_amd64.deb +/var/cache/apt/archives/sasl2-bin_2.1.27+dfsg-1build3_amd64.deb +``` + +之后,只会存在这些: + +``` +$ sudo ls -lR /var/cache/apt/archives +/var/cache/apt/archives: +total 4 +-rw-r----- 1 root root 0 Jan 5 2018 lock +drwx------ 2 _apt root 4096 Nov 12 07:24 partial + +/var/cache/apt/archives/partial: +total 0 <== 空 +``` + +`apt-get clean` 命令通常用于根据需要清除磁盘空间,一般作为定期计划维护的一部分。 + +### apt-get autoclean + +`apt-get autoclean` 类似于 `apt-get clean`,它会清除已检索包文件的本地仓库,但它只会删除不会再下载且几乎无用的文件。它有助于防止缓存过大。 + +### apt-get autoremove + +`apt-get autoremove` 将删除自动安装的软件包,因为某些其他软件包需要它们,但是在删除了其他软件包之后,而不再需要它们。有时会在升级时建议运行此命令。 + +``` +The following packages were automatically installed and are no longer required: + g++-8 gir1.2-mutter-4 libapache2-mod-php7.2 libcrystalhd3 + libdouble-conversion1 libgnome-desktop-3-17 libigdgmm5 libisl19 libllvm8 + liblouisutdml8 libmutter-4-0 libmysqlclient20 libpoppler85 libstdc++-8-dev + libtagc0 libvpx5 libx265-165 php7.2 php7.2-cli php7.2-common php7.2-json + php7.2-opcache php7.2-readline +Use 'sudo apt autoremove' to remove them. <== +``` + +要删除的软件包通常称为“未使用的依赖项”。实际上,一个好的做法是在卸载软件包后使用 `autoremove`,以确保不会留下不需要的文件。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3453032/cleaning-up-with-apt-get.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://unsplash.com/photos/nbKaLT4cmRM +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.networkworld.com/newsletters/signup.html +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/published/20191114 Microsoft Defender ATP is Coming to Linux- What Does it Mean.md b/published/201911/20191114 Microsoft Defender ATP is Coming to Linux- What Does it Mean.md similarity index 100% rename from published/20191114 Microsoft Defender ATP is Coming to Linux- What Does it Mean.md rename to published/201911/20191114 Microsoft Defender ATP is Coming to Linux- What Does it Mean.md diff --git a/published/20191114 Red Hat Responds to Zombieload v2.md b/published/201911/20191114 Red Hat Responds to Zombieload v2.md similarity index 100% rename from published/20191114 Red Hat Responds to Zombieload v2.md rename to published/201911/20191114 Red Hat Responds to Zombieload v2.md diff --git a/published/201911/20191115 Developing a Simple Web Application Using Flutter.md b/published/201911/20191115 Developing a Simple Web Application Using Flutter.md new file mode 100644 index 0000000000..e52d81885a --- /dev/null +++ b/published/201911/20191115 Developing a Simple Web Application Using Flutter.md @@ -0,0 +1,150 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11604-1.html) +[#]: subject: (Developing a Simple Web Application Using Flutter) +[#]: via: (https://opensourceforu.com/2019/11/developing-a-simple-web-application-using/) +[#]: author: (Jis Joe Mathew https://opensourceforu.com/author/jis-joe/) + +使用 Flutter 开发简单的 Web 应用 +====== + +![][2] + +> 本文指导读者如何使用 Flutter 运行和部署第一个 Web 应用。 + +Flutter 在 Android 和 iOS 开发方面走了很长一段路之后,已经迈入了一个新的阶段,即 Web 开发。Google 发布了 Flutter 1.5,同时支持 Web 应用开发。 + +### 为 Web 开发配置 Flutter + +为了使用 Web 包,输入命令 `flutter upgrade` 更新到 Flutter 1.5.4。 + + * 打开终端 + * 输入 `flutter upgrade` + * 输入 `flutter –version` 检查版本 + + +![图 1: 升级 Flutter 到最新版][3] + +也可以将 Android Studio 3.0 或更高版本用于 Flutter Web 开发,但在本教程中,我们使用 Visual Studio Code。 + +### 使用 Flutter Web 创建新项目 + +打开 Visual Studio Code,然后按 `Shift+Ctrl+P` 开始一个新项目。输入 `flutter` 并选择 “New Web Project”。 + +![图 2:在 VSC 中开始一个新的 Flatter 项目][4] + +现在,为项目命名。我将其命名为 `open_source_for_you`。 + +![图 3: 给项目命名][5] + +在 VSC 中打开终端窗口,然后输入以下命令: + +``` +flutter packages pub global activate webdev +flutter packages upgrade +``` + +现在,使用以下命令在 localhost 上运行网站,IP 地址是 127.0.0.1。 + +``` +flutter packages pub global run webdev serve +``` + +打开任何浏览器,然后输入 `http://127.0.0.1:8080/`。 + + +![图 4:运行于 8080 端口的 Flutter 演示应用][6] + +在项目目录中有个 Web 文件夹,其中包含了 `index.html`。`dart` 文件被编译成 JavaScript 文件,并使用以下代码包含在 HTML 文件中: + +``` + +``` + +### 编码和修改演示页面 + +让我们创建一个简单的应用,它会在网页上打印 “Welcome to OSFY”。 + +现在打开 Dart 文件,它位于 `lib` 文件夹 `main.dart`(默认名)中(参见图 5)。 + +![图 5:main.dart 文件的位置][7] + +现在,我们可以在 `MaterialApp` 的属性中删除调试标记,如下所示: + +``` +debugShowCheckedModeBanner: false +``` + +现在,向 Dart 中添加更多内容与用 Dart 编写 Flutter 很类似。为此,我们可以声明一个名为 `MyClass` 的类,它继承了 `StatelessWidget`。 + +我们使用 `Center` 部件将元素定位到中心。我们还可以添加 `Padding` 部件来添加填充。使用以下代码获得图 5 所示的输出。使用刷新按钮查看更改。 + +``` +class MyClass extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: EdgeInsets.all(20.0), + child: Text( + 'Welcome to OSFY', + style: TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold), + ), + ), + ], + ), + ), + ); + } +} +``` + +![图 6:MyClass 的输出][8] + +让我们从互联网中添加一张图片,我已经从一个杂志网站选择了一张 “Open Source for You” 徽标。我们使用 `Image.network`。 + +``` +Image.network( + 'https://opensourceforu.com/wp-content/uploads/2014/03/OSFY-Logo.jpg', + height: 100, + width: 150 +), +``` + +最终输出如图 7 所示。 + +![图 7:最终输出][9] + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/developing-a-simple-web-application-using/ + +作者:[Jis Joe Mathew][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensourceforu.com/author/jis-joe/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Screenshot-from-2019-11-15-16-20-30.png +[2]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Screenshot-from-2019-11-15-16-20-30.png +[3]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-1-Upgrading-Flutter-to-the-latest-version.jpg +[4]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-2-Starting-a-new-Flutter-Web-project-in-VSC.jpg +[5]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-3-Naming-the-project.jpg +[6]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-4-The-Flutter-demo-application-running-on-port-8080.jpg +[7]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-5-Location-of-main.dart-file.jpg +[8]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-6-Output-of-MyClass.jpg +[9]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-7-Final-output.jpg +[10]: https://secure.gravatar.com/avatar/64db0e07799ae14fd1b51d0633db6593?s=100&r=g +[11]: https://opensourceforu.com/author/jis-joe/ +[12]: mailto:jisjoemathew@gmail.com +[13]: https://opensourceforu.com/wp-content/uploads/2019/11/assoc.png +[14]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US diff --git a/published/201911/20191117 How to Install VirtualBox 6.0 on CentOS 8 - RHEL 8.md b/published/201911/20191117 How to Install VirtualBox 6.0 on CentOS 8 - RHEL 8.md new file mode 100644 index 0000000000..be7b3f9d4f --- /dev/null +++ b/published/201911/20191117 How to Install VirtualBox 6.0 on CentOS 8 - RHEL 8.md @@ -0,0 +1,151 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11627-1.html) +[#]: subject: (How to Install VirtualBox 6.0 on CentOS 8 / RHEL 8) +[#]: via: (https://www.linuxtechi.com/install-virtualbox-6-centos-8-rhel-8/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +如何在 CentOS 8 / RHEL 8 上安装 VirtualBox 6.0 +====== + +![](https://img.linux.net.cn/data/attachment/album/201911/30/095031gbnm59ux0dw979wb.jpg) + +VirtualBox 是一款自由开源的虚拟化工具,它允许技术人员同时运行多个不同风格的虚拟机(VM)。它通常用于运行桌面(Linux 和 Windows),当人们尝试探索新的 Linux 发行版的功能或希望在 VM 中安装 OpenStack、Ansible 和 Puppet 等软件时,它会非常方便,在这种情况下,我们可以使用 VirtualBox 启动 VM。 + +VirtualBox 被分类为 2 类虚拟机管理程序,这意味着它需要一个现有的操作系统,在上面安装 VirtualBox 软件。VirtualBox 提供功能来创建本机网络或 NAT 网络。在本文中,我们将演示如何在 CentOS 8 和 RHEL 8 系统上安装最新版本的 VirtualBox 6.0,并演示如何安装 VirtualBox 扩展。 + +### 在 CentOS 8 / RHEL 8 上安装 VirtualBox 6.0 的安装步骤 + +#### 步骤 1: 启用 VirtualBox 和 EPEL 仓库 + +登录到你的 CentOS 8 或 RHEL 8 系统并打开终端,执行以下命令并启用 VirtualBox 和 EPEL 包仓库: + +``` +[root@linuxtechi ~]# dnf config-manager --add-repo=https://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo +``` + +使用以下 `rpm` 命令导入 Oracle VirtualBox 公钥: + +``` +[root@linuxtechi ~]# rpm --import https://www.virtualbox.org/download/oracle_vbox.asc +``` + +使用以下 `dnf` 命令启用 EPEL 仓库: + +``` +[root@linuxtechi ~]# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y +``` + +#### 步骤 2: 安装 VirtualBox 构建工具和依赖项 + +运行以下命令来安装所有 VirtualBox 构建工具和依赖项: + +``` +[root@linuxtechi ~]# dnf install binutils kernel-devel kernel-headers libgomp make patch gcc glibc-headers glibc-devel dkms -y +``` + +成功安装上面的依赖项和构建工具后,使用 `dnf` 命令继续安装 VirtualBox。 + +#### 步骤 3: 在 CentOS 8 / RHEL 8 上安装 VirtualBox 6.0 + +如果希望在安装之前列出 VirtualBox 的可用版本,请执行以下 dnf 命令: + +``` +[root@linuxtechi ~]# dnf search virtualbox +Last metadata expiration check: 0:14:36 ago on Sun 17 Nov 2019 04:13:16 AM GMT. +=============== Summary & Name Matched: virtualbox ===================== +VirtualBox-5.2.x86_64 : Oracle VM VirtualBox +VirtualBox-6.0.x86_64 : Oracle VM VirtualBox +[root@linuxtechi ~]# +``` + +让我们使用以下 `dnf` 命令安装最新版本的 VirtualBox 6.0: + +``` +[root@linuxtechi ~]# dnf install VirtualBox-6.0 -y +``` + +如果有本地用户希望将 usb 设备连接到 VirtualBox VM,那么他/她应该是 `vboxusers` 组的一员,请使用下面的 `usermod` 命令将本地用户添加到 `vboxusers` 组。 + + +``` +[root@linuxtechi ~]# usermod -aG vboxusers pkumar +``` + +#### 步骤 4: 访问 CentOS 8 / RHEL 8 上的 VirtualBox + +有两种方法可以访问 VirtualBox,在命令行输入 `virtualbox` 然后回车: + +``` +[root@linuxtechi ~]# virtualbox +``` + +在桌面环境中,在搜索框中搜索 “VirtualBox”。 + +![Access-VirtualBox-CentOS8][3] + +单击 VirtualBox 图标: + +![VirtualBox-CentOS8][4] + +这确认 VirtualBox 6.0 已成功安装,让我们安装它的扩展包。 + +#### 步骤 5: 安装 VirtualBox 6.0 扩展包 + +顾名思义,VirtualBox 扩展包用于扩展 VirtualBox 的功能。它添加了以下功能: + + * USB 2.0 和 USB 3.0 支持 + * 虚拟 RDP(VRDP) + * 磁盘镜像加密 + * Intel PXE 启动 + * 主机网络摄像头 + +使用下面的 `wget` 命令下载 Virtualbox 扩展包到下载文件夹中: + +``` +[root@linuxtechi ~]$ cd Downloads/ +[root@linuxtechi Downloads]$ wget https://download.virtualbox.org/virtualbox/6.0.14/Oracle_VM_VirtualBox_Extension_Pack-6.0.14.vbox-extpack +``` + +下载后,打开 VirtualBox 并依次点击 “File -> Preferences -> Extension”,然后点击 “+” 号图标添加下载的扩展包: + +![Install-VirtualBox-Extension-Pack-CentOS8][5] + +单击 “Install” 开始安装扩展包: + +![Accept-VirtualBox-Extension-Pack-License-CentOS8][6] + +单击 “I Agree” 接受 VirtualBox 扩展包许可证。 + +成功安装 VirtualBox 扩展包后,我们将看到下面的页面,单击 “OK” 并开始使用 VirtualBox。 + +![VirtualBox-Extension-Pack-Install-Message-CentOS8][7] + +本文就是这些了,我希望这些步骤可以帮助你在 CentOS 8 和 RHEL 8 系统上安装 VirtualBox 6.0。请分享你的宝贵的反馈和意见。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/install-virtualbox-6-centos-8-rhel-8/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxtechi.com/dnf-command-examples-rpm-management-fedora-linux/ +[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Access-VirtualBox-CentOS8.jpg +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/11/VirtualBox-CentOS8.jpg +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Install-VirtualBox-Extension-Pack-CentOS8.jpg +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Accept-VirtualBox-Extension-Pack-License-CentOS8.jpg +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/11/VirtualBox-Extension-Pack-Install-Message-CentOS8.jpg +[9]: http://www.facebook.com/sharer.php?u=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-virtualbox-6-centos-8-rhel-8%2F&t=How%20to%20Install%20VirtualBox%206.0%20on%20CentOS%208%20%2F%20RHEL%208 +[10]: http://twitter.com/share?text=How%20to%20Install%20VirtualBox%206.0%20on%20CentOS%208%20%2F%20RHEL%208&url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-virtualbox-6-centos-8-rhel-8%2F&via=Linuxtechi +[11]: http://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-virtualbox-6-centos-8-rhel-8%2F&title=How%20to%20Install%20VirtualBox%206.0%20on%20CentOS%208%20%2F%20RHEL%208 +[12]: http://www.reddit.com/submit?url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-virtualbox-6-centos-8-rhel-8%2F&title=How%20to%20Install%20VirtualBox%206.0%20on%20CentOS%208%20%2F%20RHEL%208 diff --git a/published/201911/20191118 How containers work- overlayfs.md b/published/201911/20191118 How containers work- overlayfs.md new file mode 100644 index 0000000000..294e55e42b --- /dev/null +++ b/published/201911/20191118 How containers work- overlayfs.md @@ -0,0 +1,166 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11605-1.html) +[#]: subject: (How containers work: overlayfs) +[#]: via: (https://jvns.ca/blog/2019/11/18/how-containers-work--overlayfs/) +[#]: author: (Julia Evans https://jvns.ca/) + +容器如何工作:OverlayFS +====== + +今天早上,我为未来潜在容器[杂志][1]画了一幅 OverlayFS 的漫画,我对这个主题感到兴奋,想写一篇关于它的博客来提供更多详细信息。 + +![](https://jvns.ca/images/overlay.jpeg) + +### 容器镜像很大 + +容器镜像可能会很大(尽管有些很小,例如 [alpine linux 才 2.5MB][2])。Ubuntu 16.04 约为 27 MB,[Anaconda Python 发行版为 800MB 至 1.5GB][3]。 + +你以镜像启动的每个容器都是原始空白状态,仿佛它只是为使用容器而复制的一份镜像拷贝一样。但是对于大的容器镜像,像 800MB 的 Anaconda 镜像,复制一份拷贝既浪费磁盘空间也很慢。因此 Docker 不会复制,而是采用**叠加**。 + +### 叠加如何工作 + +OverlayFS,也被称为 **联合文件系统**或 **联合挂载**,它可让你使用 2 个目录挂载文件系统:“下层”目录和“上层”目录。 + +基本上: + + * 文件系统的**下层**目录是只读的 + * 文件系统的**上层**目录可以读写 + +当进程“读取”文件时,OverlayFS 文件系统驱动将在上层目录中查找并从该目录中读取文件(如果存在)。否则,它将在下层目录中查找。 + +当进程“写入”文件时,OverlayFS 会将其写入上层目录。 + +### 让我们使用 mount 制造一个叠加层! + +这有点抽象,所以让我们制作一个 OverlayFS 并尝试一下!这将只包含一些文件:我将创建上、下层目录,以及用来挂载合并的文件系统的 `merged ` 目录: + +``` +$ mkdir upper lower merged work +$ echo "I'm from lower!" > lower/in_lower.txt +$ echo "I'm from upper!" > upper/in_upper.txt +$ # `in_both` is in both directories +$ echo "I'm from lower!" > lower/in_both.txt +$ echo "I'm from upper!" > upper/in_both.txt +``` + +合并上层目录和下层目录非常容易:我们可以通过 `mount` 来完成! + +``` +$ sudo mount -t overlay overlay + -o lowerdir=/home/bork/test/lower,upperdir=/home/bork/test/upper,workdir=/home/bork/test/work + /home/bork/test/merged +``` + +在执行此操作时,我不断收到一条非常烦人的错误消息,内容为:`mount: /home/bork/test/merged: special device overlay does not exist.`。这条消息是错误的,实际上只是意味着我指定的一个目录缺失(我写成了 `~/test/merged`,但它没有被展开)。 + +让我们尝试从 OverlayFS 中读取其中一个文件!文件 `in_both.txt` 同时存在于 `lower/` 和 `upper/` 中,因此应从 `upper/` 目录中读取该文件。 + +``` +$ cat merged/in_both.txt +"I'm from upper! +``` + +可以成功! + +目录的内容就是我们所期望的: + +``` +find lower/ upper/ merged/ +lower/ +lower/in_lower.txt +lower/in_both.txt +upper/ +upper/in_upper.txt +upper/in_both.txt +merged/ +merged/in_lower.txt +merged/in_both.txt +merged/in_upper.txt +``` + +### 创建新文件时会发生什么? + +``` +$ echo 'new file' > merged/new_file +$ ls -l */new_file +-rw-r--r-- 1 bork bork 9 Nov 18 14:24 merged/new_file +-rw-r--r-- 1 bork bork 9 Nov 18 14:24 upper/new_file +``` + +这是有作用的,新文件会在 `upper` 目录创建。 + +### 删除文件时会发生什么? + +读写似乎很简单。但是删除会发生什么?开始试试! + +``` +$ rm merged/in_both.txt +``` + +发生了什么?让我们用 `ls` 看下: + +``` +ls -l upper/in_both.txt lower/lower1.txt merged/lower1.txt +ls: cannot access 'merged/in_both.txt': No such file or directory +-rw-r--r-- 1 bork bork 6 Nov 18 14:09 lower/in_both.txt +c--------- 1 root root 0, 0 Nov 18 14:19 upper/in_both.txt +``` + +所以: + + * `in_both.txt` 仍在 `lower` 目录中,并且保持不变 + * 它不在 `merged` 目录中。到目前为止,这就是我们所期望的。 + * 但是在 `upper` 中发生的事情有点奇怪:有一个名为 `upper/in_both.txt` 的文件,但是它是字符设备?我想这就是 overlayfs 驱动表示删除的文件的方式。 + +如果我们尝试复制这个奇怪的字符设备文件,会发生什么? + +``` +$ sudo cp upper/in_both.txt upper/in_lower.txt +cp: cannot open 'upper/in_both.txt' for reading: No such device or address +``` + +好吧,这似乎很合理,复制这个奇怪的删除信号文件并没有任何意义。 + +### 你可以挂载多个“下层”目录 + +Docker 镜像通常由 25 个“层”组成。OverlayFS 支持具有多个下层目录,因此你可以运行: + +``` +mount -t overlay overlay + -o lowerdir:/dir1:/dir2:/dir3:...:/dir25,upperdir=... +``` + +因此,我假设这是有多个 Docker 层的容器的工作方式,它只是将每个层解压缩到一个单独的目录中,然后要求 OverlayFS 将它们全部合并在一起,并使用一个空的上层目录,容器将对其进行更改。 + +### Docker 也可以使用 btrfs 快照 + +现在,我使用的是 ext4,而 Docker 使用 OverlayFS 快照来运行容器。但是我曾经用过 btrfs,接着 Docker 将改为使用 btrfs 的写时复制快照。(这是 Docker 何时使用哪种[存储驱动][4]的列表) + +以这种方式使用 btrfs 快照会产生一些有趣的结果:去年某个时候,我在笔记本上运行了数百个临时的 Docker 容器,这导致我用尽了 btrfs 元数据空间(像[这个人][5]一样)。这真的很令人困惑,因为我以前从未听说过 btrfs 元数据,而且弄清楚如何清理文件系统以便再次运行 Docker 容器非常棘手。([这个 docker github 上的提案][6]描述了 Docker 和 btrfs 的类似问题) + +### 以简单的方式尝试容器功能很有趣! + +我认为容器通常看起来像是在做“复杂的”事情,我认为将它们分解成这样很有趣。你可以运行一条 `mount` 咒语,而实际上并没有做任何与容器相关的其他事情,看看叠加层是如何工作的! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/11/18/how-containers-work--overlayfs/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://wizardzines.com +[2]: https://hub.docker.com/_/alpine?tab=tags +[3]: https://hub.docker.com/r/continuumio/anaconda3/tags +[4]: https://docs.docker.com/storage/storagedriver/select-storage-driver/ +[5]: https://www.reddit.com/r/archlinux/comments/5jrmfe/btrfs_metadata_and_docker/ +[6]: https://github.com/moby/moby/issues/27653 diff --git a/published/201911/20191119 How to use pkgsrc on Linux.md b/published/201911/20191119 How to use pkgsrc on Linux.md new file mode 100644 index 0000000000..8ca44c9dcc --- /dev/null +++ b/published/201911/20191119 How to use pkgsrc on Linux.md @@ -0,0 +1,204 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11613-1.html) +[#]: subject: (How to use pkgsrc on Linux) +[#]: via: (https://opensource.com/article/19/11/pkgsrc-netbsd-linux) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +如何在 Linux 上使用 pkgsrc +====== + +> NetBSD 的软件包管理器通用、灵活又容易。下面是如何使用它。 + +![](https://img.linux.net.cn/data/attachment/album/201911/26/064538fbktfzxba18wykde.jpg) + +NetBSD 以能在几乎所有平台上运行而闻名,但你知道它*第二*有名的 [pkgsrc][2] 包管理器吗?像 NetBSD 一样,pkgsrc 基本上可以在任何系统上运行,或者至少在任意 Unix 和类 Unix 的系统上上运行。你可以在 BSD、Linux、Illumos、Solaris 和 Mac 上安装 pkgsrc。它总共支持 20 多种操作系统。 + +### 为什么使用 pkgsrc? + +除了 MacOS 之外,所有 Unix 操作系统均自带包管理器。你不一定*需要* pkgsrc,但这可能是你想尝试的三个重要原因: + +* **打包**。如果你对打包感到好奇,但尚未尝试自己创建一个软件包,那么 pkgsrc 是一个相对简单的系统,尤其是如果你已经熟悉 Makefile 和类似 [GNU Autotools][3] 之类的构建系统时。 +* **通用**。如果你使用多个操作系统或发行版,那么可能会遇到每个系统的包管理器。你可以在不同的系统上使用 pkgsrc,以便你为一个系统打包了程序,就为所有系统打包了。 +* **灵活**。在许多打包系统中,如何选择二进制包或源码包并不总是很明显。使用 pkgsrc,区别很明显,两种安装方法都一样容易,并且都可以为你解决依赖关系。 + +### 如何安装 pkgsrc + +无论你使用的是 BSD、Linux、Illumos、Solaris 还是 MacOS,安装过程都基本相同: + +1. 使用 CVS 检出 pkgsrc 树 +2. 引导 pkgsrc 系统 +3. 安装软件包 + +#### 使用 CVS 检出 pkgsrc 树 + +在 Git 和 Subversion 之前,就有了 [CVS][4]。要检出代码你无需了解 CVS 太多,如果你习惯 Git,那么可以将检出checkout称为克隆clone。当你用 CVS 检出 pkgsrc 时,你就下载了详细说明如何构建每个软件包的“配方recipes”。它有很多文件,但是它们都很小,因为你实际上并没有拉取每个包的源码,而只有按需构建时需要的构建基础架构和 Makefile。使用 CVS,你可以轻松地在新版本发布时更新 pkgsrc 检出。 + +pkgsrc 文档建议将其源码树放在 `/usr` 目录下,因此你必须使用 `sudo`(或成为 root)运行此命令: + +``` +$ cd /usr +$ sudo cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2019Q3 -P pkgsrc +``` + +在我撰写本文时,最新版本是 2019Q3。请检查 [pkgsrc.org][6] 主页的新闻部分或 [NetBSD文档][7],以确定最新版本。 + +#### 引导 pkgsrc + +pkgsrc 树复制到你的计算机后,你会看到一个充满构建脚本的 `/usr/pkgsrc` 目录。在使用之前,你必须引导 pkgsrc,以便你可以轻松地访问构建和安装软件所需的相关命令。 + +引导 pkgsrc 的方式取决于你所使用操作系统。 + +对于 NetBSD,你只需使用捆绑的引导器: + +``` +# cd pkgsrc/bootstrap +# ./bootstrap +``` + +在其他系统上,还有更好的方法,包括一些自定义功能,它是由 Joyent 提供的。要了解运行的确切命令,请访问 [pkgsrc.joyent.com][8]。比如,在 Linux(Fedora、Debian、Slackware 等)上: + +``` +$ curl -O https://pkgsrc.joyent.com/packages/Linux/el7/bootstrap/bootstrap-trunk-x86_64-20170127.tar.gz +$ BOOTSTRAP_SHA="eb0d6911489579ca893f67f8a528ecd02137d43a" +``` + +尽管路径暗示文件适用于 RHEL 7,但二进制文件往往与所有(最前沿的 Linux 发行版)兼容。如果你发现二进制文件与你的发行版不兼容,你可以选择从源码构建。 + +验证 SHA1 校验和: + +``` +$ echo "${BOOTSTRAP_SHA}" bootstrap-trunk*gz > check-shasum +sha1sum -c check-shasum +``` + +你还可以验证 PGP 签名: + +``` +$ curl -O https://pkgsrc.joyent.com/packages/Linux/el7/bootstrap/bootstrap-trunk-x86_64-20170127.tar.gz.asc +$ curl -sS https://pkgsrc.joyent.com/pgp/56AAACAF.asc | gpg --import +$ gpg --verify ${BOOTSTRAP_TAR}{.asc,} +``` + +当你确认你已有正确的引导套件,将其安装到 `/usr/pkg`: + +``` +sudo tar -zxpf ${BOOTSTRAP_TAR} -C / +``` + +它为你提供了通常的 pkgsrc 命令。将这些位置添加到[你的 PATH 环境变量中][9]: + +``` +$ echo "PATH=/usr/pkg/sbin:/usr/pkg/bin:$PATH" >> ~/.bashrc +$ echo "MANPATH=/usr/pkg/man:$MANPATH" >> ~/.bashrc +``` + +如果你宁愿使用 pkgsrc 而不依赖于 Joyent 的构建,那么只需运行 pkgsrc 源码树的引导脚本即可。在运行特定于系统的脚本之前,请先阅读 `bootstrap` 目录中相关 `README` 文件。 + +![Bootstrapping pkgsrc on NetBSD][10] + +### 如何使用 pkgsrc 安装软件 + +使用 pkgsrc 安装预编译的二进制文件(就像使用 DNF 或 Apt 一样)是很容易的。二进制安装的命令是 `pgkin`,它有自己的专门网站 [pkgin.net][11]。对于任何用过 Linux 的人来说,这个过程应该感觉相当熟悉。 + +要搜索 `tmux` 包: + +``` +$ pkgin search tmux +``` + +要安装 tmux 包: + +``` +$ sudo pkgin install tmux +``` + +`pkgin` 命令的目的是模仿典型的 Linux 包管理器的行为,因此有选项可以列出可用的包、查找包提供的特定可执行文件,等等。 + +### 如何使用 pkgsrc 从源码构建 + +然而,pkgsrc 真正强大的地方是方便地从源码构建包。你在第一步中检出了所有 20000 多个构建脚本,你可以直接进入 pkgsrc 源码树来访问这些脚本。 + +例如,要从源码构建 `tcsh`,首先找到构建脚本: + +``` +$ find /usr/pkgsrc -type d -name "tcsh" +/usr/pkgsrc/shells/tcsh +``` + +接下来,进入源码目录: + +``` +$ cd /usr/pgksrc/shells/tcsh +``` + +构建脚本目录包含许多文件来帮助在你的系统上构建应用,但值得注意的是,这里面有包含了软件说明的 `DESCR` 文件,以及触发构建的 `Makefile`。 + +``` +$ ls +CVS    DESCR     Makefile +PLIST  distinfo  patches +$ cat DESCR +TCSH is an extended C-shell with many useful features like +filename completion, history editing, etc. +$ +``` + +准备就绪后,构建并安装: + +``` +$ sudo bmake install +``` + +pkgsrc 系统使用 `bmake` 命令(在第一步检出 pkgsrc 后提供),因此请务必使用 `bmake`(而不是出于习惯使用 `make`)。 + +如果要为多个系统构建,那么你可以创建一个包,而不是立即安装: + +``` +$ cd /usr/pgksrc/shells/tcsh +$ sudo bmake package +[...] +=> Creating binary package in /usr/pkgsrc/packages/All/tcsh-X.Y.Z.tgz +``` + +pkgsrc 创建的包是标准的 tarball,但它可以方便地通过 `pkg_add` 安装: + +``` +$ sudo pkg_add /usr/pkgsrc/packages/All/tcsh-X.Y.Z.tgz +tcsh-X.Y.Z: adding /usr/pkg/bin/tcsh to /etc/shells +$ tcsh +localhost% +``` + +pkgsrc 的 pkgtools 集合提供 `pkg_add`、`pkg_info`、`pkg_admin`、`pkg_create` 和 `pkg_delete` 命令,来帮助管理你在系统上构建和维护软件包。 + +### pkgsrc,易于管理 + +pkgsrc 系统提供了直接,容易上手的软件包管理方法。如果你正在寻找一个不妨碍你并且可以定制的包管理器,请在任何运行 Unix 或类 Unix 的系统上试试 pkgsrc。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/pkgsrc-netbsd-linux + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_code_woman.png?itok=vbYz6jjb (A person programming) +[2]: http://pkgsrc.org +[3]: https://opensource.com/article/19/7/introduction-gnu-autotools +[4]: http://www.netbsd.org/developers/cvs-repos/cvs_intro.html#intro +[5]: mailto:anoncvs@anoncvs.NetBSD.org +[6]: http://pkgsrc.org/ +[7]: http://www.netbsd.org/docs/pkgsrc/getting.html +[8]: http://pkgsrc.joyent.com/ +[9]: https://opensource.com/article/17/6/set-path-linux +[10]: https://opensource.com/sites/default/files/uploads/pkgsrc-bootstrap.jpg (Bootstrapping pkgsrc on NetBSD) +[11]: http://pkgin.net diff --git a/published/201911/20191120 How to Use TimeShift to Backup and Restore Ubuntu Linux.md b/published/201911/20191120 How to Use TimeShift to Backup and Restore Ubuntu Linux.md new file mode 100644 index 0000000000..e40aebfa8d --- /dev/null +++ b/published/201911/20191120 How to Use TimeShift to Backup and Restore Ubuntu Linux.md @@ -0,0 +1,155 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11619-1.html) +[#]: subject: (How to Use TimeShift to Backup and Restore Ubuntu Linux) +[#]: via: (https://www.linuxtechi.com/timeshift-backup-restore-ubuntu-linux/) +[#]: author: (James Kiarie https://www.linuxtechi.com/author/james/) + +如何使用 TimeShift 备份和还原 Ubuntu Linux +====== + +你是否曾经想过如何备份和还原 Ubuntu 或 Debian 系统?Timeshift 是一款自由开源工具,可让你创建文件系统的增量快照。你可以使用 RSYNC 或 BTRFS 两种方式创建快照。 + +![](https://img.linux.net.cn/data/attachment/album/201911/27/235959fejmb080e7z0jnu0.jpg) + +让我们深入研究并安装 Timeshift。在本教程,我们将安装在 Ubuntu 18.04 LTS 系统上。 + +### 在 Ubuntu / Debian Linux 上安装 TimeShift + +TimeShift 尚未正式托管在 Ubuntu 和 Debian 仓库中。考虑到这一点,我们将运行以下命令来添加 PPA: + +``` +# add-apt-repository -y ppa:teejee2008/ppa +``` + +![Add timeshift repository][3] + +接下来,使用以下命令更新系统软件包: + +``` +# apt update +``` + +成功更新系统后,使用以下 `apt` 命令安装 Timeshift: + +``` +# apt install timeshift +``` + +![apt install timeshift][4] + +### 准备备份存储设备 + +最佳实践要求我们将系统快照保存在系统硬盘之外的单独的存储卷上。对于本指南,我们将使用 16GB 闪存作为第二个驱动器,并在该驱动器上保存快照。 + +``` +# lsblk | grep sdb +``` + +![lsblk sdb ubuntu][5] + +为了将闪存用作快照的备份位置,我们需要在设备上创建一个分区表。运行以下命令: + +``` +# parted /dev/sdb mklabel gpt +# parted /dev/sdb mkpart primary 0% 100% +# mkfs.ext4 /dev/sdb1 +``` + +![create partition table on drive ubuntu][6] + +在 USB 闪存上创建分区表后,我们可以开始创建文件系统的快照! + +### 使用 Timeshift 创建快照 + +要启动 Timeshift,使用应用程序菜单搜索 “Timeshift”。 + +![Access timeshift][7] + +单击 Timeshift 图标,系统将提示你输入管理员密码。提供密码,然后单击验证。 + +![Authentication required][8] + +接下来,选择你喜欢的快照类型。 + +![Select rsync option][9] + +点击 “Next”。选择快照的目标驱动器。在这里,我的位置是标记为 `/dev/sdb` 的外部 USB 驱动器。 + +![Select snapshot location][10] + +接下来,定义快照级别。级别是指创建快照的时间间隔。你可以选择每月、每周、每天或每小时的快照级别。 + +![Select snapshot levels][11] + +点击 “Finish”。 + +在下一个窗口中,单击 “Create” 按钮开始创建快照。此后,系统将开始创建快照。 + +![Create snapshot][12] + +最后,你的快照将显示如下: + +![Snapshot created][13] + +### 从快照还原 Ubuntu / Debian + +创建系统快照后,现在让我们看看如何从同一快照还原系统。在同一个 Timeshift 中,单击快照,然后单击 “Restore” 按钮,如图所示。 + +![Restore snapshot][14] + +接下来,将提示你选择目标设备。保留默认选择,然后点击 “Next”。 + +![Select target device][15] + +恢复过程开始之前,Timeshift 将会试运行。 + +![Comparing files dry run][16] + +在下一个窗口中,点击 “Next” 按钮确认显示的操作。 + +![Confirm actions][17] + +如图所示,你会看到警告和免责声明。点击 “Next” 初始化恢复过程。 + +此后,将开始还原过程,最后,系统之后将重新启动到快照定义的早期版本。 + +![Restoring snapshot][18] + +### 总结 + +如你所见,使用 TimeShift 从快照还原系统非常容易。在备份系统文件时,它非常方便,并允许你在系统故障时进行恢复。因此,不要害怕修改系统或弄乱系统。TimeShift 使你能够返回到一切运行平稳的时间点。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/timeshift-backup-restore-ubuntu-linux/ + +作者:[James Kiarie][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/james/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/11/TimeShift-Backup-Restore-Tool-Ubuntu.png +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Add-timeshift-repository.png +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/11/apt-install-timeshift.png +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/11/lsblk-sdb-ubuntu.png +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/11/create-partition-table-on-drive-ubuntu.jpg +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Access-Timeshift-Ubuntu.jpg +[8]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Authentication-required-ubuntu.jpg +[9]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Select-Rsync-option-timeshift.jpg +[10]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Select-snapshot-location.png +[11]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Select-snapshot-levels-Timeshift.jpg +[12]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Create-snapshot-timeshift.jpg +[13]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Snapshot-created-TimeShift.jpg +[14]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Restore-snapshot-timeshift.jpg +[15]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Select-target-device-timeshift.jpg +[16]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Comparing-files-Dry-Run-timeshift.jpg +[17]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Confirm-actions-timeshift.jpg +[18]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Restoring-snapshot-timeshift.png diff --git a/published/201911/20191120 How to install Java on Linux.md b/published/201911/20191120 How to install Java on Linux.md new file mode 100644 index 0000000000..db94ace738 --- /dev/null +++ b/published/201911/20191120 How to install Java on Linux.md @@ -0,0 +1,215 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11614-1.html) +[#]: subject: (How to install Java on Linux) +[#]: via: (https://opensource.com/article/19/11/install-java-linux) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +如何在 Linux 上安装 Java +====== + +> 在桌面上拥抱 Java 应用程序,然后在所有桌面上运行它们。 + +![](https://img.linux.net.cn/data/attachment/album/201911/26/065307hk22caubakkos0u0.jpg) + +无论你运行的是哪种操作系统,通常都有几种安装应用程序的方法。有时你可能会在应用程序商店中找到一个应用程序,或者使用 Fedora 上的 DNF 或 Mac 上的 Brew 这样的软件包管理器进行安装,而有时你可能会从网站上下载可执行文件或安装程序。因为 Java 是这么多流行的应用程序的后端,所以最好了解安装它的不同方法。好消息是你有很多选择,本文涵盖了所有这些内容。 + +坏消息是 Java *太大*,我说的不仅仅是文件大小。Java 是一种开放源代码语言和规范,这意味着从理论上讲,任何人都可以创建它的实现版本。这意味着,在安装任何东西之前,必须确定要安装的 Java 发行版。 + +### 我需要 JVM 还是 JRE 或者 JDK? + +Java 大致分为两个下载类别。Java 虚拟机Java Virtual Machine(JVM)是运行时组件;它是使 Java 应用程序能够在计算机上启动和运行的“引擎”。它包含在 Java 运行时环境Java Runtime Environment(JRE)中。 + +Java 开发工具包Java Development Kit(JDK)是一个开发工具包:你可以将其视为一个车库,修理工可以坐在那里进行调整、修理和改进。JDK 包含 Java 运行时环境(JRE)。 + +以下载来说,这意味着: + +* 如果你是希望运行 Java 应用程序的用户,则只需 JRE(包括了 JVM)。 +* 如果你是希望使用 Java 进行编程的开发人员,则需要 JDK(包括 JRE 库,而 JRE 库又包括 JVM)。 +   +### OpenJDK、IcedTea 和 OracleJDK 有什么不同? + +当太阳微系统Sun Microsystems被 Oracle 收购时,Java 是该交易的主要部分。幸运的是,Java 是一种开源技术,因此,如果你对 Oracle 维护该项目的方式不满意,则可以选择其他方法。Oracle 将专有组件与 Java 下载捆绑在一起,而 OpenJDK 项目是完全开源的。 + +IcedTea 项目本质上是 OpenJDK,但其目标是使用户在使用完全自由开源的工具时更容易构建和部署 OpenJDK。 + +(LCTT 译注:阿里巴巴也有一个它自己维护的 Open JDK 发行版“龙井Dragonwell”。以下引自其官网:“Alibaba Dragonwell 是一款免费的,生产就绪型 Open JDK 发行版,提供长期支持,包括性能增强和安全修复。……Alibaba Dragonwell 作为 Java 应用的基石,支撑了阿里经济体内所有的 Java 业务。Alibaba Dragonwell 完全兼容 Java SE 标准,……”) + +### 我应该安装哪个 Java? + +如果你对这些选择感到不知所措,那么简单的答案就是你应该安装的 Java 实现应该是最容易安装的那个。当应用程序告诉你需要 Java 12,但你的存储库中只有 Java 8 时,可以安装可以从可靠来源中找到的 Java 12 的任何实现。在 Linux 上,你可以一次安装几个不同版本的 Java,它们不会互相干扰。 + +如果你是需要选择使用哪个版本的开发人员,则应考虑所需的组件。如果选择 Oracle 的版本,请注意,软件包中包含专有的插件和字体,可能会[影响你分发你的应用程序][2]。在 IcedTea 或 OpenJDK 上进行开发是最安全的。 + +### 从存储库安装 OpenJDK? + +现在,你已经知道要选择什么了,你可以使用软件包管理器搜索 OpenJDK 或 IcedTea,然后安装所需的版本。有些发行版使用关键字 `latest` 来指示最新版本,这通常是你要运行的应用程序所需要的。根据你使用的软件包管理器,你甚至可以考虑使用 `grep` 过滤搜索结果以仅包括最新版本。例如,在 Fedora 上: + +``` +$ sudo dnf search openjdk | grep latest | cut -f1 -d':' + +java-latest-openjdk-demo.x86_64 +java-openjdk.i686 +java-openjdk.x86_64 +java-latest-openjdk-jmods.x86_64 +java-latest-openjdk-src.x86_64 +java-latest-openjdk.x86_64 +[...] +``` + +只有当你尝试运行的应用程序坚持要求你使用 Java 的旧版本时,你才应该看看 `latest` 之前的版本。 + +在 Fedora 或类似系统上安装 Java: + +``` +$ sudo dnf install java-latest-openjdk +``` + +如果你的发行版不使用 `latest` 标签,则可以使用其他关键字,例如 `default`。以下是在 Debian 上搜索 OpenJDK 的信息: + +``` +$ sudo apt search openjdk | less +default-jdk +  Standard Java development kit + +default-jre +  Standard Java runtime + +openjdk-11-jdk +  OpenJDK development kit (JDK) + +[...] +``` + +在这种情况下,`default-jre` 软件包适合用户,而 `default-jdk` 则适合开发人员。 + +例如,要在 Debian 上安装 JRE: + +``` +$ sudo apt install default-jre +``` + +现在已安装好 Java。 + +你的存储库中可能有*许多*与 Java 相关的软件包。要搜索 OpenJDK,如果你是用户,则查找最新的 JRE 或 JVM,如果你是开发人员,则查找最新的 JDK。 + +### 从互联网上安装 Java + +如果在存储库中找不到 JRE 或 JDK,或者找不到满足你需求的 JRE 或 JDK,则可以从互联网上下载开源的 Java 软件包。你可以在 [openjdk.java.net][3] 中找到需要手动安装的 tar 形式的 OpenJDK 下载文件,或者可以从 Azul 下载 tar 形式的 [Zulu 社区版][4]或其可安装的 RPM 或 DEB 软件包。 + +#### 从 TAR 文件安装 Java + +如果从 Java.net 或 Azul 下载 TAR 文件,则必须手动安装。这通常称为“本地”安装,因为你没有将 Java 安装到“全局”位置。你可以在 `PATH` 中选择一个合适的位置。 + +如果你不知道 `PATH` 中包含什么,请查看一下以找出: + +``` +$ echo $PATH +/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/seth/bin +``` + +在此示例 `PATH` 中,位置 `/usr/local/bin` 和 `/home/seth/bin` 是不错的选择。如果你是计算机上的唯一用户,那么你自己的家目录就很有意义。如果你的计算机上有很多用户,则最好选择一个通用位置,例如 `/usr/local` 或 `/opt`。 + +如果你无权访问需要 `sudo` 权限的 `/usr/local` 之类的系统级目录,则可以在你自己的家目录中创建一个本地 `bin`(意思是 “二进制binary”,而不是“垃圾箱waste bin”)或 `Applications` 文件夹: + +``` +$ mkdir ~/bin +``` + +如果它不在你的 `PATH` 中,请将其添加到其中: + +``` +$ echo PATH=$PATH:$HOME/bin >> ~/.bashrc +$ source ~/.bashrc +``` + +最后,将压缩包解压缩到你选择的目录中。 + +``` +$ tar --extract --file openjdk*linux-x64_bin.tar.gz --directory=$HOME/bin +``` + +Java 现在安装好了。 + +#### 从 RPM 或 DEB 安装 Java + +如果从 Azul.com 下载 RPM 或 DEB 文件,则可以使用软件包管理器进行安装。 + +对于 Fedora、CentOS、RHEL 等,请下载 RPM 并使用 DNF 进行安装: + +``` +$ sudo dnf install zulu*linux.x86_64.rpm +``` + +对于 Debian、Ubuntu、Pop_OS 和类似发行版,请下载 DEB 软件包并使用 Apt 安装它: + +``` +$ sudo dpkg -i zulu*linux_amd64.deb +``` + +Java 现在安装好了。 + +#### 用 alternatives 安装你的 Java 版本 + +一些应用程序是为特定版本的 Java 开发的,不能与其他任何版本一起使用。这种情况很少见,但确实会发生,在 Linux 上,你可以使用本地安装方法(请参阅上面“从 TAR 文件安装 Java”一节)或使用 `alternatives` 应用程序来解决此冲突。 + +`alternatives` 命令会查找 Linux 系统上安装的应用程序,并让你选择要使用的版本。有些发行版,例如 Slackware,不提供 `alternatives` 命令,因此你必须使用本地安装方法。在 Fedora、CentOS 和类似的发行版上,该命令是 `alternatives`。在 Debian、Ubuntu 和类似的系统上,该命令是 `update-alternatives`。 + +要获取当前已安装在 Fedora 系统上的应用程序的可用版本列表: + +``` +$ alternatives --list +``` + +在 Debian 上,你必须指定可供替代的应用程序: + +``` +$ update-alternatives --list java +``` + +在 Fedora 上选择要使系统将哪个版本作为默认版本: + +``` +$ sudo alternatives --config java +``` + +在 Debian 上: + +``` +$ sudo updates-alternatives --config java +``` + +你可以根据需要运行的应用程序,根据需要更改默认的 Java 版本。 + +### 运行 Java 应用 + +Java 应用程序通常以 JAR 文件的形式分发。根据你安装 Java 的方式,你的系统可能已经为运行 Java 应用程序配置好了,这使你只需双击应用程序图标(或从应用程序菜单中选择它)即可运行。如果必须执行未与系统其余部分集成的本地 Java 安装,则可以直接从终端启动 Java 应用程序: + +``` +$ java -jar ~/bin/example.jar & +``` + +### Java 是个好东西 + +Java 是少数将跨平台开发放在首位的编程环境之一。没有什么比问一个应用程序是否能在你的平台上运行然后发现该应用程序是用 Java 编写要让人感到松一口气的了。它是如此简单,无论你是开发人员还是用户,你都可以摆脱任何平台上的焦虑。在桌面上拥抱 Java 应用程序,然后在*所有*桌面上运行它们吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/install-java-linux + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/java-coffee-beans.jpg?itok=3hkjX5We (Coffee beans) +[2]: https://www.oracle.com/technetwork/java/javase/overview/oracle-jdk-faqs.html +[3]: http://openjdk.java.net +[4]: https://www.azul.com/downloads/zulu-community +[5]: tmp.wuzOCnXHry#installing-java-from-a-tar-file diff --git a/published/201911/20191121 How to document Python code with Sphinx.md b/published/201911/20191121 How to document Python code with Sphinx.md new file mode 100644 index 0000000000..3b14624f5d --- /dev/null +++ b/published/201911/20191121 How to document Python code with Sphinx.md @@ -0,0 +1,175 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11624-1.html) +[#]: subject: (How to document Python code with Sphinx) +[#]: via: (https://opensource.com/article/19/11/document-python-sphinx) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +如何使用 Sphinx 给 Python 代码写文档 +====== + +> 最好将文档作为开发过程的一部分。Sphinx 加上 Tox,让文档可以轻松书写,并且外观漂亮。 + +![Python in a coffee cup.][1] + +Python 代码可以在源码中包含文档。这种方式默认依靠 **docstring**,它以三引号格式定义。虽然文档的价值是很大的,但是没有充足的文档的代码还是很常见。让我们演练一个场景,了解出色的文档的强大功能。 + +经历了太多在白板技术面试上要求你实现斐波那契数列,你已经受够了。你回家用 Python 写了一个可重用的斐波那契计算器,使用浮点技巧来实现 `O(1)` 复杂度。 + +代码很简单: + +``` +# fib.py +import math + +_SQRT_5 = math.sqrt(5) +_PHI = (1 + _SQRT_5) / 2 + +def approx_fib(n): + return round(_PHI**(n+1) / _SQRT_5) +``` + +(该斐波那契数列是四舍五入到最接近的整数的几何序列,这是我最喜欢的鲜为人知的数学事实之一。) + +作为一个好人,你可以将代码开源,并将它放在 [PyPI][2] 上。`setup.py` 文件很简单: + +``` +import setuptools + +setuptools.setup( + name='fib', + version='2019.1.0', + description='Fibonacci', + py_modules=["fib"], +) +``` + +但是,没有文档的代码是没有用的。因此,你可以向函数添加 docstring。我最喜欢的 docstring 样式之一是 [“Google” 样式][3]。标记很轻量,当它放在源代码中时很好。 + + +``` +def approx_fib(n): + """ + Approximate Fibonacci sequence + + Args: + n (int): The place in Fibonacci sequence to approximate + + Returns: + float: The approximate value in Fibonacci sequence + """ + # ... +``` + +但是函数的文档只是成功的一半。普通文档对于情境化代码用法很重要。在这种情况下,情景是恼人的技术面试。 + +有一种添加更多文档的方式,专业 Python 人的方式通常是在 `docs/` 添加 rst 文件( [reStructuredText][4] 的缩写)。因此 `docs/index.rst` 文件最终看起来像这样: + +``` +Fibonacci +========= + +Are you annoyed at tech interviewers asking you to implement +the Fibonacci sequence? +Do you want to have some fun with them? +A simple +:code:`pip install fib` +is all it takes to tell them to, +um, +fib off. + +.. automodule:: fib + :members: +``` + +我们完成了,对吧?我们已经将文本放在了文件中。人们应该会看的。 + +### 使 Python 文档更漂亮 + +为了使你的文档看起来更漂亮,你可以利用 [Sphinx][5],它旨在制作漂亮的 Python 文档。这三个 Sphinx 扩展特别有用: + +* `sphinx.ext.autodoc`:从模块内部获取文档 +* `sphinx.ext.napoleon`:支持 Google 样式的 docstring +* `sphinx.ext.viewcode`:将 ReStructured Text 源码与生成的文档打包在一起 + +为了告诉 Sphinx 该生成什么以及如何生成,我们在 `docs/conf.py` 中配置一个辅助文件: + +``` +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.napoleon', + 'sphinx.ext.viewcode', +] +# 该入口点的名称,没有 .rst 扩展名。 +# 惯例该名称是 index +master_doc = "index" +# 这些值全部用在生成的文档当中。 +# 通常,发布(release)与版本(version)是一样的, +# 但是有时候我们会有带有 rc 标签的发布。 +project = "Fib" +copyright = "2019, Moshe Zadka" +author = "Moshe Zadka" +version = release = "2019.1.0" +``` + +此文件使我们可以使用所需的所有元数据来发布代码,并注意扩展名(上面的注释说明了方式)。最后,要确保生成我们想要的文档,请使用 [Tox][6] 管理虚拟环境以确保我们顺利生成文档: + +``` +[tox] +# 默认情况下,`.tox` 是该目录。 +# 将其放在非点文件中可以从 +# 文件管理器或浏览器的 +# 打开对话框中打开生成的文档, +# 这些对话框有时会隐藏点文件。 +toxworkdir = {toxinidir}/build/tox + +[testenv:docs] +# 从 `docs` 目录内运行 `sphinx`, +# 以确保它不会拾取任何可能进入顶层目录下的 +# 虚拟环境或 `build/` 目录下的其他工件的杂散文件。 +changedir = docs +# 唯一的依赖关系是 `sphinx`。 +# 如果我们使用的是单独打包的扩展程序, +# 我们将在此处指定它们。 +# 更好的做法是指定特定版本的 sphinx。 +deps = + sphinx +# 这是用于生成 HTML 的 `sphinx` 命令。 +# 在其他情况下,我们可能想生成 PDF 或电子书。 +commands = + sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html +# 我们使用 Python 3.7。 +# Tox 有时会根据 testenv 的名称尝试自动检测它, +# 但是 `docs` 没有给出有用的线索,因此我们必须明确它。 +basepython = python3.7 +``` + +现在,无论何时运行 Tox,它都会为你的 Python 代码生成漂亮的文档。 + +### 在 Python 中写文档很好 + +作为 Python 开发人员,我们可以使用的工具链很棒。我们可以从 **docstring** 开始,添加 .rst 文件,然后添加 Sphinx 和 Tox 来为用户美化结果。 + +你对好的文档有何评价?你还有其他喜欢的方式么?请在评论中分享它们! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/document-python-sphinx + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_python.jpg?itok=G04cSvp_ (Python in a coffee cup.) +[2]: https://pypi.org/ +[3]: http://google.github.io/styleguide/pyguide.html#381-docstrings +[4]: http://docutils.sourceforge.net/rst.html +[5]: http://www.sphinx-doc.org/en/master/ +[6]: https://tox.readthedocs.io/en/latest/ diff --git a/published/201911/20191122 Zorin OS 15 Lite Release- Good Looking Lightweight Linux.md b/published/201911/20191122 Zorin OS 15 Lite Release- Good Looking Lightweight Linux.md new file mode 100644 index 0000000000..2f1932ddec --- /dev/null +++ b/published/201911/20191122 Zorin OS 15 Lite Release- Good Looking Lightweight Linux.md @@ -0,0 +1,125 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11603-1.html) +[#]: subject: (Zorin OS 15 Lite Release: Good Looking Lightweight Linux) +[#]: via: (https://itsfoss.com/zorin-os-lite/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Zorin OS 15 Lite 发布:好看的轻量级 Linux +====== + +> Zorin OS 15 Lite 版刚刚发布。我们将向你展示此新版本的桌面体验,并向你重点展示其主要功能。 + +[Zorin OS][1] 是一款日益流行的 Linux 发行版。它基于 Ubuntu,因此,毫不奇怪,它也正是[适合初学者的最佳 Linux 发行版][2]之一。 类似 Windows 的界面是许多从 Windows 到 Linux 的迁移者偏爱它的主要原因之一。 + +Zorin OS 有两个主要变体: + +* Zorin Core:它使用 GNOME 桌面,用于较新的机器。 +* Zorin Lite:它使用轻量级的 [Xfce 桌面][3],可以用作[老旧的笔记本电脑和计算机的 Linux][4]。 + +### Zorin OS 15 Lite:新特性 + +Zorin OS 15 Core 发布之后过了很久,Zorin OS 15 Lite 版终于出现了。你现在就可以使用免费的 Lite 版或付费的 Lite Ultimate 版。 + +我尝试了 Zorin OS 15 Lite Ultimate 版。在本文中,我将介绍此版本的详细信息以及在为你的计算机下载 Zorin OS 15 Lite 之前应了解的知识。 + +Zorin OS 15 Lite 与全面的 Zorin OS 15 版本基本差不多。你可以在我们的原来的报道中查看 [Zorin OS 15 的功能][6]。 + +此发行版重点关注资源,因此过去十年中任何类型的旧硬件配置都可以轻松地在其上运行。 + +![][7] + +在此版本中,它们依靠基于 Xfce 4.14 的轻量级桌面环境在低规格计算机上提供了最佳体验。除了 Xfce 桌面环境外,与使用 GNOME 的完整版本相比,它还做了一些底层更改。 + +#### Zorin OS 15 Lite 是针对 Windows 7 用户的 + +![][8] + +Zorin OS 15 Lite 主要针对 Windows 7 用户,因为对 Windows 7 的官方支持结束于今年 1 月。因此,如果你对 Windows 7 感到满意,可以尝试一下,切换到此版本应该是一种流畅的体验。 + +Zorin OS 15 Lite 允许你在 “Zorin 外观”设置中将布局切换为 macOS 风格/ Windows 风格的外观。 + +#### 32 位和 64 位支持 + +很高兴看到 Zorin OS 考虑到对 32 位/ 64 位 ISO 的支持,因为 Lite 版本是针对具有低规格硬件的用户的。 + +#### 默认启用 Flatpak 支持 + +![][9] + +你可以使用软件中心利用 Flathub 来立即安装 Flatpak 软件包。如果你不确定该怎么做,请务必查看有关[使用 Flatpak][10]的指南。 + +除此之外,你已经拥有 Snap 软件包支持。因此,通过软件中心安装任何内容应该更容易。 + +#### 用户界面的印象 + +![][11] + +老实说,默认的 Xfce 界面看起来很陈旧。有一些方法可以 [定制 Xfce][12],但是 Zorin 也可以开箱即用。定制外观给人以良好印象。它看起来非常整洁,可以按预期工作。 + +#### 性能 + +![][13] + +即使我没有在超级老旧的系统上尝试过,但我也在老式硬盘上安装了它,它难以启动 Ubuntu 或类似发行版。 + +根据我的体验,我可以肯定该性能非常出色。感觉就好像我将其安装在 SSD 上。这显然是一件好事。如果你碰巧在超级老旧的系统上尝试使用它,可以在本文底部的评论部分中告诉我您的经验。 + +### Ultimate Lite 版和免费的 Lite 版有何区别? + +![][14] + +没错,你可以免费下载 Zorin OS 15。 + +但是,有一个单独的“终极版”(Ultimate),其基本目的是用来支持该项目及其开发者。除此之外,它还捆绑了许多预安装的软件,作为计算机的“最终”软件包。 + +因此,如果你购买 Ultimate 版,则可以访问 Lite 版和完整版。 + +如果你不想为此付费,仍然可以根据需要选择免费版本(Core、Lite、Education)。你可以在它们的[下载页面][15]上了解更多信息。 + +### 如何下载 Zorin OS 15 Lite? + +你可以转到其[官方下载网页][15],然后向下滚动找到 Zorin OS 15 Lite 版。 + +你可以找到 32 位/ 64 位的 ISO,可以下载所需的 ISO。 + +- [Zorin OS 15 Lite] [15] + +安装 Zorin OS 与安装 Ubuntu 类似。 + +### 总结 + +虽然 Zorin OS 15 作为向 Windows / macOS 老手提供的 Linux 发行版已经是一个不错的产品,但新的 Lite 版本肯定会吸引更多的眼球。 + +您是否尝试过 Lite 版?在下面的评论中让我知道你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/zorin-os-lite/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://zorinos.com/ +[2]: https://itsfoss.com/best-linux-beginners/ +[3]: https://www.xfce.org/ +[4]: https://itsfoss.com/lightweight-linux-beginners/ +[5]: https://www.youtube.com/c/itsfoss?sub_confirmation=1 +[6]: https://linux.cn/article-11058-1.html +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/file-explorer-zorin-os-15-lite.jpg?ssl=1 +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/zorin-lite-ultimate-appearance.jpg?ssl=1 +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/zorin-os-software.png?ssl=1 +[10]: https://itsfoss.com/flatpak-guide/ +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/zorin-os-15-lite-appearance.jpg?ssl=1 +[12]: https://itsfoss.com/customize-xfce/ +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/homescreen-zorin-os-15-lite.jpg?ssl=1 +[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/11/zorin-os-ultimate.jpg?ssl=1 +[15]: https://zorinos.com/download/ diff --git a/published/201911/20191124 Bauh - Manage Snaps, Flatpaks and AppImages from One Interface.md b/published/201911/20191124 Bauh - Manage Snaps, Flatpaks and AppImages from One Interface.md new file mode 100644 index 0000000000..cc418f1713 --- /dev/null +++ b/published/201911/20191124 Bauh - Manage Snaps, Flatpaks and AppImages from One Interface.md @@ -0,0 +1,141 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11617-1.html) +[#]: subject: (Bauh – Manage Snaps, Flatpaks and AppImages from One Interface) +[#]: via: (https://itsfoss.com/bauh-package-manager/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +bauh:在一个界面中管理 Snap、Flatpak 和 AppImage +====== + +![](https://img.linux.net.cn/data/attachment/album/201911/27/092926pzzdtytda80yaany.jpg) + +[Snap][1]、[Flatpak][2] 和 [AppImage][3] 等通用软件包的最大问题之一就是管理它们。大多数内置的软件包管理器都不能全部支持这些新格式。 + +幸运的是,我偶然发现了一个支持这几种通用包格式的应用程序。 + +### bauh:多包装需求的管理器 + +[bauh][4](LCTT:我给该软件建议一个中文名:“包豪”)最初名为 fpakman,旨在处理 Flatpak、Snap、[AppImage][5] 和 [AUR][6] 软件包。创建者 [vinifmor][7] 在 2019 年 6 月启动了该项目,[意图][8]“为 Manjaro 用户提供管理 Flatpak 的图形界面”。此后,他扩展了该应用程序,以添加对基于 Debian 的系统的支持。 + +![Bauh About][9] + +首次打开 bauh 时,它将扫描已安装的应用程序并检查更新。如果有任何需要更新的内容,它们将列在前面并居中。更新所有软件包后,你将看到已安装的软件包列表。你可以取消选择不需要更新的软件包,以防止其被更新。你也可以选择安装该应用程序的早期版本。 + +![With Bauh you can manage various types of packages from one application][10] + +你也可以搜索应用程序。bauh 提供了有关已安装和已搜索软件包的详细信息。如果你对一种(或多种)软件包类型不感兴趣,则可以在设置中取消选择它们。 + +![Bauh Search][22] + +![Bauh Package Info][13] + +![Bauh Updating][19] + +### 在你的 Linux 发行版上安装 bauh + +让我们看看如何安装 bauh。 + +#### 基于 Arch 的发行版 + +如果你安装的是最近的 [Manjaro][11],则应该一切已经就绪。bauh 默认情况下已安装。如果你安装的是较早版本的 Manjaro(如我一样)或其他基于 Arch 的发行版,则可以在终端中输入以下内容从 [AUR][12] 中进行安装: + +``` +sudo pacman -S bauh +``` + +#### 基于 Debian/Ubuntu 的发行版 + +如果你拥有基于 Debian 或 Ubuntu 的 Linux 发行版,则可以使用 `pip` 安装 bauh。首先,请确保[在 Ubuntu 上安装了 pip][14]。 + +``` +sudo apt install python3-pip +``` + +然后使用它来安装 bauh: + +``` +pip3 install bauh +``` + +但是,该软件的创建者建议[手动][15]安装它,以避免弄乱系统的库。 + +要手动安装 bauh,你必须先下载其[最新版本][16]。下载后,可以[使用图形工具][17]或 [unzip 命令][18]解压缩。接下来,在终端中打开该文件夹。你将需要使用以下步骤来完成安装。 + +首先,在名为 `env` 的文件夹中创建一个虚拟环境: + +``` +python3 -m venv env +``` + +现在在该环境中安装该应用程序的代码: + +``` +env/bin/pip install . +``` + +启动该应用程序: + +``` +env/bin/bauh +``` + +一旦完成了 bauh 的安装,就可以通过更改环境设置和参数来对其进行[微调][20]。 + +### bauh 的未来之路 + +bauh 在短短的几个月中增长了很多。它有计划继续增长。当前的[路线图][21]包括: + +* 支持其他打包技术 +* 每种打包技术一个单独模块 +* 内存和性能改进 +* 改善用户体验 + +### 结语 + +当我尝试 bauh 时,遇到了两个问题。当我第一次打开它时,它告诉我尚未安装 Snap,如果要使用 Snap 软件包,则必须安装它。我知道我已经安装了 Snap,因为我在终端中运行了 `snap list`,并且可以正常工作。我重新启动系统,Snap 才工作正常。 + +我遇到的另一个问题是我的一个 AUR 软件包无法更新。我可以用 `yay` 更新软件包,而没有任何问题。可能是我的 Manjaro 有问题,我已经使用了它 3 到 4 年。 + +总体而言,bauh 可以工作。它做到了宣称的功能。我不能要求更多。 + +你有没有用过 hauh?如果有的话,你最喜欢的用于管理不同打包格式的工具是什么?在下面的评论中让我们知道。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/bauh-package-manager/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://snapcraft.io/ +[2]: https://flatpak.org/ +[3]: https://appimage.org/ +[4]: https://github.com/vinifmor/bauh +[5]: https://itsfoss.com/use-appimage-linux/ +[6]: https://itsfoss.com/best-aur-helpers/ +[7]: https://github.com/vinifmor +[8]: https://forum.manjaro.org/t/bauh-formerly-known-as-fpakman-a-gui-for-flatpak-and-snap-management/96180 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/bauh-about.jpg?ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/bauh.jpg?ssl=1 +[11]: https://manjaro.org/ +[12]: https://aur.archlinux.org/packages/bauh +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/11/bauh-package-info.jpg?ssl=1 +[14]: https://itsfoss.com/install-pip-ubuntu/ +[15]: https://github.com/vinifmor/bauh#manual-installation +[16]: https://github.com/vinifmor/bauh/releases +[17]: https://itsfoss.com/unzip-linux/ +[18]: https://linuxhandbook.com/unzip-command/ +[19]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/bauh-updating.jpg?ssl=1 +[20]: https://github.com/vinifmor/bauh#general-settings +[21]: https://github.com/vinifmor/bauh#roadmap +[22]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/bauh-search.png?resize=800%2C319&ssl=1 +[23]: https://reddit.com/r/linuxusersgroup diff --git a/published/201911/20191126 Google to Add Mainline Linux Kernel Support to Android.md b/published/201911/20191126 Google to Add Mainline Linux Kernel Support to Android.md new file mode 100644 index 0000000000..479ef5cdde --- /dev/null +++ b/published/201911/20191126 Google to Add Mainline Linux Kernel Support to Android.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11616-1.html) +[#]: subject: (Google to Add Mainline Linux Kernel Support to Android) +[#]: via: (https://itsfoss.com/mainline-linux-kernel-android/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +谷歌为安卓添加主线 Linux 内核支持 +====== + +当前的安卓生态系统被数百种不同版本的安卓所污染,每种版本都运行着 Linux 内核的不同变体。每个版本均针对不同的手机和不同的配置而设计。谷歌试图通过将主线 Linux 内核添加到安卓来解决该问题。 + +### 当前在安卓中是如何处理 Linux 内核的 + +在到达你的手机之前,你手机上的 Linux 内核经历了[三个主要步骤][1]。 + +首先,谷歌采用了 Linux 内核的 LTS(长期支持)版本,并添加了所有的安卓专用代码。这将成为“安卓通用内核”。 + +然后,谷歌将此代码发送给创建可运行在手机的片上系统(SoC)的公司。这通常是高通公司。 + +SoC 制造商添加了支持 CPU 和其他芯片的代码后,便会将该内核传递给实际的设备制造商,例如三星和摩托罗拉。然后,设备制造商添加代码以支持手机的其余部分,例如显示屏和摄像头。 + +每个步骤都需要一段时间才能完成,并且会导致该内核无法与其他任何设备一起使用。这也意味着内核会非常旧,通常是大约两年前的内核。例如,上个月交付的谷歌 Pixel 4 带有来自 2017 年 11 月的内核,而且它将永远不会得到更新。 + +谷歌承诺会为较旧的设备创建安全补丁,这意味着他们会一直盯着大量的旧代码。 + +### 将来 + +![][2] + +去年,谷歌宣布[计划][3]解决此问题。今年,他们在 2019 Linux Plumbers Conference 上展示了他们取得的进展。 + +> “我们知道运行安卓需要什么,但不一定是在任何给定的硬件上。因此,我们的目标是从根本上找出所有这些,然后将其交给上游,并尝试尽可能接近主线。” +> +> Sandeep Patil,[安卓内核团队负责人][1] + +他们确实炫耀了运行带有合适的 Linux 内核的小米 Poco F1。但是,有些东西[似乎没有工作][4],例如电池电量百分比一直留在 0%。 + +那么,谷歌计划如何使其工作呢?从他们的 [Treble 项目][5]计划中摘录。在 Treble 项目之前,与设备和安卓本身交互的底层代码是一大堆代码。Treble 项目将两者分开,并使它们模块化,以便可以更快地交付安卓更新,并且在更新时,这些低级代码可以保持不变。 + +谷歌希望为内核带来同样的模块化。他们的[计划][1]“涉及稳定 Linux 的内核 ABI,并为 Linux 内核和硬件供应商提供稳定的接口来进行写入。谷歌希望将 Linux 内核与其硬件支持脱钩。” + +因此,这意味着谷歌将交付一个内核,而硬件驱动程序将作为内核模块加载。目前,这只是一个草案。仍然有很多技术问题有待解决。因此,这不会很快有结果。 + +### 来自开源的反对意见 + +开源社区不会对将专有代码放入内核的想法感到满意。[Linux 内核准则][6]指出,驱动程序必须具有 GPL 许可证才能包含在内核中。他们还指出,如果驱动程序的更改导致错误,应由导致该错误的人来解决。从长远来看,这意味着设备制造商的工作量将减少。 + +### 关于将主线内核包含到安卓中的最终想法 + +到目前为止,这只是一个草案。谷歌有很大的可能会开始进行该项目,除非他们意识到这将需要多少工作后才会放弃。看看谷歌[已经放弃][7]了多少个项目! + +[Android Police][4] 指出谷歌正在开发其 [Fuchsia 操作系统][8],这似乎是为了有一天取代安卓。 + +那么,问题是谷歌会尝试完成那些艰巨的任务,使安卓以主线 Linux 内核运行,还是完成他们统一的安卓替代产品的工作?只有时间可以回答。 + +你对此话题有何看法?请在下面的评论中告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/mainline-linux-kernel-android/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://arstechnica.com/gadgets/2019/11/google-outlines-plans-for-mainline-linux-kernel-support-in-android/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/mainline_linux_kernel_android.png?ssl=1 +[3]: https://lwn.net/Articles/771974/ +[4]: https://www.androidpolice.com/2019/11/19/google-wants-android-to-use-regular-linux-kernel-potentially-improving-updates-and-security/ +[5]: https://www.computerworld.com/article/3306443/what-is-project-treble-android-upgrade-fix-explained.html +[6]: https://www.kernel.org/doc/Documentation/process/stable-api-nonsense.rst +[7]: https://killedbygoogle.com/ +[8]: https://itsfoss.com/fuchsia-os-what-you-need-to-know/ +[9]: https://reddit.com/r/linuxusersgroup diff --git a/published/201911/20191127 Displaying dates and times your way.md b/published/201911/20191127 Displaying dates and times your way.md new file mode 100644 index 0000000000..4366136a80 --- /dev/null +++ b/published/201911/20191127 Displaying dates and times your way.md @@ -0,0 +1,168 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11623-1.html) +[#]: subject: (Displaying dates and times your way) +[#]: via: (https://www.networkworld.com/article/3481602/displaying-dates-and-times-your-way-with-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +在终端里按你的方式显示日期和时间 +====== + +> Linux 的 date 命令提供了很多显示日期和时间的选项,要比你想的还要多。这是一些有用的选择。 + +![](https://img.linux.net.cn/data/attachment/album/201911/29/144555a8mq82mcc9cfttt9.jpg) + +在 Linux 系统上,`date` 命令非常简单。你键入 `date`,日期和时间将以一种有用的方式显示。它包括星期几、日期、时间和时区: + +``` +$ date +Tue 26 Nov 2019 11:45:11 AM EST +``` + +只要你的系统配置正确,你就会看到日期和当前时间以及时区。 + +但是,该命令还提供了许多选项来以不同方式显示日期和时间信息。例如,如果要显示日期以便进行排序,则可能需要使用如下命令: + +``` +$ date "+%Y-%m-%d" +2019-11-26 +``` + +在这种情况下,年、月和日按该顺序排列。请注意,我们使用大写字母 `Y` 来获得四位数的年份。如果我们使用小写的 `y`,则只会看到两位数字的年份(例如 19)。不要让这种做法使你错误地联想到如果 `%m` 给你一个数字月份,`%M` 可能会给你月份的名称。不,`%M` 将给你分钟数。要以缩写名称格式获得月份,你要使用 `%b`,而对于完全拼写的月份,则要使用 `%B`。 + +``` +$ date "+%b %B" +Nov November +``` + +或者,你可能希望以这种常用格式显示日期: + +``` +$ date "+%D" +11/26/19 +``` + +如果你需要四位数的年份,则可以执行以下操作: + +``` +$ date "+%x" +11/26/2019 +``` + +下面是一个可能有用的示例。假设你需要创建一个每日报告并在文件名中包含日期,则可以使用以下命令来创建文件(可能用在脚本中): + +``` +$ touch Report-`date "+%Y-%m-%d"` +``` + +当你列出你的报告时,它们将按日期顺序或反向日期顺序(如果你添加 `-r`)列出。 + +``` +$ ls -r Report* +Report-2019-11-26 +Report-2019-11-25 +Report-2019-11-22 +Report-2019-11-21 +Report-2019-11-20 +``` + +你还可以在日期字符串中添加其他详细信息。可用的各种选项多得令人惊讶。你可以使用 `date "+%q"` 来显示你所在的一年中的哪个季度,或使用类似以下命令来显示两个月前的日期: + +``` +$ date --date="2 months ago" +Thu 26 Sep 2019 09:02:43 AM EDT +``` + +是否想知道下周四的日期?你可以使用类似 `date --date="next thu"` 的命令,但是要理解,对于Linux,下个周四意味着今天之后的周四。如果今天是星期三,那就是明天,而不是下周的星期四。但是,你可以像下面的第二个命令一样指定下周的星期四。 + +``` +$ date --date="next thu" +Thu 28 Nov 2019 12:00:00 AM EST +$ date --date="next week thu" +Thu 05 Dec 2019 12:00:00 AM EST +``` + +`date` 命令的手册页列出了其所有选项。该列表多得令人难以置信,但是你可能会发现一些日期/时间显示选项非常适合你。以下是一些你可能会发现有趣的东西。 + +世界标准时间(UTC): + +``` +$ date -u +Tue 26 Nov 2019 01:13:59 PM UTC +``` + +自 1970 年 1 月 1 日以来的秒数(与 Linux 系统上日期的存储方式有关): + +``` +$ date +%s +1574774137 +``` + +以下是 `date` 命令选项的完整列表。正如我所说,它比我们大多数人想象的要广泛得多。 + +- `%%` 显示字母 % +- `%a` 本地语言环境的缩写星期名称(例如,日 / Sun) +- `%A` 本地语言环境的完整星期名称(例如,星期日 / Sunday) +- `%b` 本地语言环境的缩写月份名称(例如 一 / Jan) +- `%B` 本地语言环境的完整月份名称(例如,一月 / January) +- `%c` 本地语言环境的日期和时间(例如 2005年3月3日 星期四 23:05:25 / Thu Mar 3 23:05:25 2005) +- `%C` 世纪;类似于 `%Y`,但省略了后两位数字(例如,20) +- `%d` 月份的天(例如,01) +- `%D` 日期;与 `%m/%d/%y` 相同 +- `%e` 月份的天,填充前缀空格;与 `%_d` 相同 +- `%F` 完整日期;与 `%Y-%m-%d` 相同 +- `%g` ISO 周号的年份的后两位数字(请参见 `%G`) +- `%G` ISO 周号的年份(请参阅 `%V`);通常仅配合 `%V` 使用 +- `%h` 与 `%b` 相同 +- `%H` 24 小时制的小时(00..23) +- `%I` 12 小时制的小时(01..12) +- `%j` 一年的天(001..366) +- `%k` 24 小时制的小时,填充前缀空格( 0..23);与 `%_H` 相同 +- `%l` 12 小时制的小时,填充前缀空格( 1..12);与 `%_I` 相同 +- `%m` 月份(01..12) +- `%M` 分钟(00..59) +- `%n` 换行符 +- `%N` 纳秒(000000000..999999999) +- `%p` 本地语言环境中等同于 AM 或 PM 的字符串;如果未知,则为空白 +- `%P` 像 `%p`,但使用小写 +- `%q` 季度(1..4) +- `%r` 本地语言环境的 12 小时制时间(例如,晚上 11:11:04 / 11:11:04 PM) +- `%R` 24 小时制的小时和分钟;与 `%H:%M` 相同 +- `%s` 自 1970-01-01 00:00:00 UTC 以来的秒数 +- `%S` 秒(00..60) +- `%t` 制表符 +- `%T` 时间;与 `%H:%M:%S` 相同 +- `%u` 星期(1..7);1 是星期一 +- `%U` 年的周号,以星期日为一周的第一天,从 00 开始(00..53) +- `%V` ISO 周号,以星期一为一周的第一天,从 01 开始(01..53) +- `%w` 星期(0..6);0 是星期日 +- `%W` 年的周号,星期一为一周的第一天,从 00 开始(00..53) +- `%x` 本地语言环境的日期表示形式(例如,1999年12月31日 / 12/31/99) +- `%X` 本地语言环境的时间表示形式(例如,23:13:48) +- `%y` 年的最后两位数字(00..99) +- `%Y` 年份 +- `%z` +hhmm 格式的数字时区(例如,-0400) +- `%:z` +hh:mm 格式的数字时区(例如,-04:00) +- `%::z` +hh:mm:ss 格式的数字时区(例如,-04:00:00) +- `%:::z` 数字时区,`:` 指明精度(例如,-04, +05:30) +- `%Z` 字母时区缩写(例如,EDT) + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3481602/displaying-dates-and-times-your-way-with-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/20191101 Awk one-liners and scripts to help you sort text files.md b/published/20191101 Awk one-liners and scripts to help you sort text files.md new file mode 100644 index 0000000000..a22edd71eb --- /dev/null +++ b/published/20191101 Awk one-liners and scripts to help you sort text files.md @@ -0,0 +1,242 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11684-1.html) +[#]: subject: (Awk one-liners and scripts to help you sort text files) +[#]: via: (https://opensource.com/article/19/11/how-sort-awk) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +帮助你排序文本文件的 Awk 命令行或脚本 +====== + +> Awk 是一个强大的工具,可以执行某些可能由其它常见实用程序(包括 `sort`)来完成的任务。 + +![](https://img.linux.net.cn/data/attachment/album/201912/17/095222q7m5da4h8facvmtv.jpg) + +Awk 是个普遍存在的 Unix 命令,用于扫描和处理包含可预测模式的文本。但是,由于它具有函数功能,因此也可以合理地称之为编程语言。 + +令人困惑的是,有不止一个 awk。(或者,如果你认为只有一个,那么其它几个就是克隆。)有 `awk`(由Aho、Weinberger 和 Kernighan 编写的原始程序),然后有 `nawk` 、`mawk` 和 GNU 版本的 `gawk`。GNU 版本的 awk 是该实用程序的一个高度可移植的自由软件版本,具有几个独特的功能,因此本文是关于 GNU awk 的。 + +虽然它的正式名称是 `gawk`,但在 GNU+Linux 系统上,它的别名是 `awk`,并用作该命令的默认版本。 在其他没有带有 GNU awk 的系统上,你必须先安装它并将其称为 `gawk`,而不是 `awk`。本文互换使用术语 `awk` 和 `gawk`。 + +`awk` 既是命令语言又是编程语言,这使其成为一个强大的工具,可以处理原本留给 `sort`、`cut`、`uniq` 和其他常见实用程序的任务。幸运的是,开源中有很多冗余空间,因此,如果你面临是否使用 `awk` 的问题,答案可能是肯定的“随便”。 + +`awk` 的灵活之美在于,如果你已经确定使用 `awk` 来完成一项任务,那么无论接下来发生什么,你都可以继续使用 `awk`。这包括对数据排序而不是按交付给你的顺序的永恒需求。 + +### 样本数据集 + +在探索 `awk` 的排序方法之前,请生成要使用的样本数据集。保持简单,这样你就不会为极端情况和意想不到的复杂性所困扰。这是本文使用的样本集: + +``` +Aptenodytes;forsteri;Miller,JF;1778;Emperor +Pygoscelis;papua;Wagler;1832;Gentoo +Eudyptula;minor;Bonaparte;1867;Little Blue +Spheniscus;demersus;Brisson;1760;African +Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed +Eudyptes;chrysocome;Viellot;1816;Sothern Rockhopper +Torvaldis;linux;Ewing,L;1996;Tux +``` + +这是一个很小的数据集,但它提供了多种数据类型: + +* 属名和种名,彼此相关但又是分开的 +* 姓,有时是以逗号开头的首字母缩写 +* 代表日期的整数 +* 任意术语 +* 所有字段均以分号分隔 + +根据你的教育背景,你可能会认为这是二维数组或表格,或者只是行分隔的数据集合。你如何看待它只是你的问题,而 `awk` 只认识文本。由你决定告诉 `awk` 你想如何解析它。 + +### 只想排序 + +如果你只想按特定的可定义字段(例如电子表格中的“单元格”)对文本数据集进行排序,则可以使用 [sort 命令][2]。 + +### 字段和记录 + +无论输入的格式如何,都必须在其中找到模式才可以专注于对你重要的数据部分。在此示例中,数据由两个因素定界:行和字段。每行都代表一个新的*记录*,就如你在电子表格或数据库转储中看到的一样。在每一行中,都有用分号(`;`)分隔的不同的*字段*(将其视为电子表格中的单元格)。 + +`awk` 一次只处理一条记录,因此,当你在构造发给 `awk` 的这指令时,你可以只关注一行记录。写下你想对一行数据执行的操作,然后在下一行进行测试(无论是心理上还是用 `awk` 进行测试),然后再进行其它的一些测试。最后,你要对你的 `awk` 脚本要处理的数据做好假设,以便可以按你要的数据结构提供给你数据。 + +在这个例子中,很容易看到每个字段都用分号隔开。为简单起见,假设你要按每行的第一字段对列表进行排序。 + +在进行排序之前,你必须能够让 `awk` 只关注在每行的第一个字段上,因此这是第一步。终端中 awk 命令的语法为 `awk`,后跟相关选项,最后是要处理的数据文件。 + +``` +$ awk --field-separator=";" '{print $1;}' penguins.list +Aptenodytes +Pygoscelis +Eudyptula +Spheniscus +Megadyptes +Eudyptes +Torvaldis +``` + +因为字段分隔符是对 Bash shell 具有特殊含义的字符,所以必须将分号括在引号中或在其前面加上反斜杠。此命令仅用于证明你可以专注于特定字段。你可以使用另一个字段的编号尝试相同的命令,以查看数据的另一个“列”的内容: + +``` +$ awk --field-separator=";" '{print $3;}' penguins.list +Miller,JF +Wagler +Bonaparte +Brisson +Milne-Edwards +Viellot +Ewing,L +``` + +我们尚未进行任何排序,但这是良好的基础。 + +### 脚本编程 + +`awk` 不仅仅是命令,它是一种具有索引、数组和函数的编程语言。这很重要,因为这意味着你可以获取要排序的字段列表,将列表存储在内存中,进行处理,然后打印结果数据。对于诸如此类的一系列复杂操作,在文本文件中进行操作会更容易,因此请创建一个名为 `sort.awk` 的新文件并输入以下文本: + +``` +#!/bin/gawk -f + +BEGIN { +        FS=";"; +} +``` + +这会将该文件建立为 `awk` 脚本,该脚本中包含执行的行。 + +`BEGIN` 语句是 `awk` 提供的特殊设置功能,用于只需要执行一次的任务。定义内置变量 `FS`,它代表字段分隔符field separator,并且与你在 `awk` 命令中使用 `--field-separator` 设置的值相同,它只需执行一次,因此它包含在 `BEGIN` 语句中。 + +#### awk 中的数组 + +你已经知道如何通过使用 `$` 符号和字段编号来收集特定字段的值,但是在这种情况下,你需要将其存储在数组中而不是将其打印到终端。这是通过 `awk` 数组完成的。`awk` 数组的重要之处在于它包含键和值。 想象一下有关本文的内容;它看起来像这样:`author:"seth",title:"How to sort with awk",length:1200`。诸如作者、标题和长度之类的元素是键,跟着的内容为值。 + +在排序的上下文中这样做的好处是,你可以将任何字段分配为键,将任何记录分配为值,然后使用内置的 `awk` 函数 `asorti()`(按索引排序)按键进行排序。现在,随便假设你*只*想按第二个字段排序。 + +*没有*被特殊关键字 `BEGIN` 或 `END` 引起来的 `awk` 语句是在每个记录都要执行的循环。这是脚本的一部分,该脚本扫描数据中的模式并进行相应的处理。每次 `awk` 将注意力转移到一条记录上时,都会执行 `{}` 中的语句(除非以 `BEGIN` 或 `END` 开头)。 + +要将键和值添加到数组,请创建一个包含数组的变量(在本示例脚本中,我将其称为 `ARRAY`,虽然不是很原汁原味,但很清楚),然后在方括号中分配给它键,用等号(`=`)连接值。 + +``` +{   # dump each field into an array +    ARRAY[$2] = $R; +} +``` + +在此语句中,第二个字段的内容(`$2`)用作关键字,而当前记录(`$R`)用作值。 + +### asorti() 函数 + +除了数组之外,`awk` 还具有一些基本函数,你可以将它们用作常见任务的快速简便的解决方案。GNU awk中引入的函数之一 `asorti()` 提供了按键(*索引*)或值对数组进行排序的功能。 + +你只能在对数组进行填充后对其进行排序,这意味着此操作不能对每个新记录都触发,而只能在脚本的最后阶段进行。为此,`awk` 提供了特殊的 `END` 关键字。与 `BEGIN` 相反,`END` 语句仅在扫描了所有记录之后才触发一次。 + +将这些添加到你的脚本: + +``` +END { +    asorti(ARRAY,SARRAY); +    # get length +    j = length(SARRAY); +    +    for (i = 1; i <= j; i++) { +        printf("%s %s\n", SARRAY[i],ARRAY[SARRAY[i]]) +    } +} +``` + +`asorti()` 函数获取 `ARRAY` 的内容,按索引对其进行排序,然后将结果放入名为 `SARRAY` 的新数组(我在本文中发明的任意名称,表示“排序的 ARRAY”)。 + +接下来,将变量 `j`(另一个任意名称)分配给 `length()` 函数的结果,该函数计算 `SARRAY` 中的项数。 + +最后,使用 `for` 循环使用 `printf()` 函数遍历 `SARRAY` 中的每一项,以打印每个键,然后在 `ARRAY` 中打印该键的相应值。 + +### 运行该脚本 + +要运行你的 `awk` 脚本,先使其可执行: + +``` +$ chmod +x sorter.awk +``` + +然后针对 `penguin.list` 示例数据运行它: + +``` +$ ./sorter.awk penguins.list +antipodes Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed +chrysocome Eudyptes;chrysocome;Viellot;1816;Sothern Rockhopper +demersus Spheniscus;demersus;Brisson;1760;African +forsteri Aptenodytes;forsteri;Miller,JF;1778;Emperor +linux Torvaldis;linux;Ewing,L;1996;Tux +minor Eudyptula;minor;Bonaparte;1867;Little Blue +papua Pygoscelis;papua;Wagler;1832;Gentoo +``` + +如你所见,数据按第二个字段排序。 + +这有点限制。最好可以在运行时灵活选择要用作排序键的字段,以便可以在任何数据集上使用此脚本并获得有意义的结果。 + +### 添加命令选项 + +你可以通过在脚本中使用字面值 `var` 将命令变量添加到 `awk` 脚本中。更改脚本,以使迭代子句在创建数组时使用 `var`: + +``` +{ # dump each field into an array +    ARRAY[$var] = $R; +} +``` + +尝试运行该脚本,以便在执行脚本时使用 `-v var` 选项将其按第三字段排序: + +``` +$ ./sorter.awk -v var=3 penguins.list +Bonaparte Eudyptula;minor;Bonaparte;1867;Little Blue +Brisson Spheniscus;demersus;Brisson;1760;African +Ewing,L Torvaldis;linux;Ewing,L;1996;Tux +Miller,JF Aptenodytes;forsteri;Miller,JF;1778;Emperor +Milne-Edwards Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed +Viellot Eudyptes;chrysocome;Viellot;1816;Sothern Rockhopper +Wagler Pygoscelis;papua;Wagler;1832;Gentoo +``` + +### 修正 + +本文演示了如何在纯 GNU awk 中对数据进行排序。你可以对脚本进行改进,以便对你有用,花一些时间在`gawk` 的手册页上研究 [awk 函数][3]并自定义脚本以获得更好的输出。 + +这是到目前为止的完整脚本: + +``` +#!/usr/bin/awk -f +# GPLv3 appears here +# usage: ./sorter.awk -v var=NUM FILE + +BEGIN { FS=";"; } + +{ # dump each field into an array +    ARRAY[$var] = $R; +} + +END { +    asorti(ARRAY,SARRAY); +    # get length +    j = length(SARRAY); +    +    for (i = 1; i <= j; i++) { +        printf("%s %s\n", SARRAY[i],ARRAY[SARRAY[i]]) +    } +} +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/how-sort-awk + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_lead-steps-measure.png?itok=DG7rFZPk (Green graph of measurements) +[2]: https://opensource.com/article/19/10/get-sorted-sort +[3]: https://www.gnu.org/software/gawk/manual/html_node/Built_002din.html#Built_002din diff --git a/published/20191113 Edit images on Fedora easily with GIMP.md b/published/20191113 Edit images on Fedora easily with GIMP.md new file mode 100644 index 0000000000..c4fa6c8b67 --- /dev/null +++ b/published/20191113 Edit images on Fedora easily with GIMP.md @@ -0,0 +1,85 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11632-1.html) +[#]: subject: (Edit images on Fedora easily with GIMP) +[#]: via: (https://fedoramagazine.org/edit-images-on-fedora-easily-with-gimp/) +[#]: author: (Mehdi Haghgoo https://fedoramagazine.org/author/powergame/) + +在 Fedora 上使用 GIMP 轻松编辑图像 +====== + +![][1] + +GIMP(GNU Image Manipulation Program 的缩写)是自由开源的图像处理软件。它有很多的功能,从简单的图像编辑,到复杂的滤镜、脚本,甚至是动画,它是流行的商业同类软件的一款很好的替代品。 + +继续阅读来学习如何在 Fedora 上安装和使用 GIMP。这篇文章涉及基本的日常图像编辑工作。 + +### 安装 GIMP + +GIMP 在官方 Fedora 存储库中可获得。为安装它,运行: + +``` +sudo dnf install gimp +``` + +### 单窗口模式 + +在你打开应用程序后,它显示带有工具箱和主编辑区的暗色主题窗口。注意,它有两种窗口模式,你可以通过选择“窗口Windows -> 单窗口模式Single Window Mode”在其中切换。通过选中这个选项,用户界面的所有组件将显示在单个窗口中。否则,它们将是分离的。 + +### 加载图像 + +![][2] + +为加载图像,转到“文件File -> 打开Open”,然后选择你的文件并选择你的图像文件。 + +### 重新调整一个图像的大小 + +为重新调整图像大小,你可以基于一对参数重新调整大小,包括像素和百分比 —— 在编辑图像时,这两个参数很方便。 + +让我们假使我们需要缩小 Fedora 30 背景图像到它当前大小的 75%。为此,选择“图像 Image -> 比例Scale”,然后在比例对话框上,在单位下拉列表中选择“百分比percentage”。接下来,输入 “75” 作为宽度或高度,然后按 Tab 键。默认情况下,其它尺寸将自动地调整大小,以相应地与更改的尺寸保持纵横比。现在,保存其它选项不变,并按比例。 + +![][3] + +该图像缩小到其原始尺寸的 75%。 + +### 旋转图像 + +旋转是一种变换操作,因此,你可以从主菜单下的“图像Image -> 变换Transform”下找到它,其中有图像旋转 90° 或 180° 的选项。在上述选项下也有垂直或水平翻转图像的选项。 + +让我们假使我们需要旋转图像 90°。在应用一次 90° 顺时针旋转和水平翻转后,我们的图像将看起来像这样: + +![Transforming an image with GIMP][4] + +### 添加文本 + +添加文本非常简单。只需要从工具箱中选择 “A” 图标,然后,在你的图像上,单击你想要添加文本的位置。如果工具箱不可见,从“窗口Windows -> 新建工具箱New Toolbox”打开它。 + +当你编辑文本时,你可能注意到,文本对话框有字体自定义选项,包括字体系列、字体大小等等。 + +![Adding text to image in GIMP][5] + +### 保存和导出 + +你可以从“文件File -> 保存Save”或通过按 `Ctrl+S` 来将你的编辑保存为一个带有 `.xcf` 扩展名的 GIMP 工程。或者,你可以导出你的图像,例如,以 PNG 或 JPEG 格式。为导出图像,转到“文件File -> 导出为Export As”或按 `Ctrl+Shift+E`,接下来,在你面前将产生一个你可以选择输出图像和名称的对话框。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/edit-images-on-fedora-easily-with-gimp/ + +作者:[Mehdi Haghgoo][a] +选题:[lujun9972][b] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/powergame/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/10/gimp-magazine-816x346.jpg +[2]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-00-44-300x165.png +[3]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-17-33-300x262.png +[4]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-41-28-300x243.png +[5]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-47-54-300x237.png + diff --git a/published/20191114 Debugging Software Deployments with strace.md b/published/20191114 Debugging Software Deployments with strace.md new file mode 100644 index 0000000000..c3557e89ef --- /dev/null +++ b/published/20191114 Debugging Software Deployments with strace.md @@ -0,0 +1,345 @@ +[#]: collector: (lujun9972) +[#]: translator: (hanwckf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11667-1.html) +[#]: subject: (Debugging Software Deployments with strace) +[#]: via: (https://theartofmachinery.com/2019/11/14/deployment_debugging_strace.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) + +在软件部署中使用 strace 进行调试 +====== + +![](https://img.linux.net.cn/data/attachment/album/201912/12/130413poennny2pbrgy9ot.jpg) + +我的大部分工作都涉及到部署软件系统,这意味着我需要花费很多时间来解决以下问题: + +* 这个软件可以在原开发者的机器上工作,但是为什么不能在我这里运行? +* 这个软件昨天可以在我的机器上工作,但是为什么今天就不行? + +这是一种调试的类型,但是与一般的软件调试有所不同。一般的调试通常只关心代码的逻辑,但是在软件部署中的调试关注的是程序的代码和它所在的运行环境之间的相互影响。即便问题的根源是代码的逻辑错误,但软件显然可以在别的机器上运行的事实意味着这类问题与运行环境密切相关。 + +所以,在软件部署过程中,我没有使用传统的调试工具(例如 `gdb`),而是选择了其它工具进行调试。我最喜欢的用来解决“为什么这个软件无法在这台机器上运行?”这类问题的工具就是 `strace`。 + +### 什么是 strace? + +[strace][1] 是一个用来“追踪系统调用”的工具。它主要是一个 Linux 工具,但是你也可以在其它系统上使用类似的工具(例如 [DTrace][2] 和 [ktrace][3])。 + +它的基本用法非常简单。只需要在 `strace` 后面跟上你需要运行的命令,它就会显示出该命令触发的所有系统调用(你可能需要先安装好 `strace`): + +``` +$ strace echo Hello +...Snip lots of stuff... +write(1, "Hello\n", 6) = 6 +close(1) = 0 +close(2) = 0 +exit_group(0) = ? ++++ exited with 0 +++ +``` + +这些系统调用都是什么?它们就像是操作系统内核提供的 API。很久以前,软件拥有直接访问硬件的权限。如果软件需要在屏幕上显示一些东西,它将会与视频硬件的端口和内存映射寄存器纠缠不清。当多任务操作系统变得流行以后,这就导致了混乱的局面,因为不同的应用程序将“争夺”硬件,并且一个应用程序的错误可能致使其它应用程序崩溃,甚至导致整个系统崩溃。所以 CPU 开始支持多种不同的特权模式(或者称为“保护环”)。它们让操作系统内核在具有完全硬件访问权限的最高特权模式下运行,于此同时,其它在低特权模式下运行的应用程序必须通过向内核发起系统调用才能够与硬件进行交互。 + +在二进制级别上,发起系统调用相比简单的函数调用有一些区别,但是大部分程序都使用标准库提供的封装函数。例如,POSIX C 标准库包含一个 `write()` 函数,该函数包含用于进行 `write` 系统调用的所有与硬件体系结构相关的代码。 + +![][4] + +简单来说,一个应用程序与其环境(计算机系统)的交互都是通过系统调用来完成的。所以当软件在一台机器上可以工作但是在另一台机器无法工作的时候,追踪系统调用是一个很好的查错方法。具体地说,你可以通过追踪系统调用分析以下典型操作: + + * 控制台输入与输出 (IO) + * 网络 IO + * 文件系统访问以及文件 IO + * 进程/线程生命周期管理 + * 原始内存管理 + * 访问特定的设备驱动 + +### 什么时候可以使用 strace? + +理论上,`strace` 适用于任何用户空间程序,因为所有的用户空间程序都需要进行系统调用。`strace` 对于已编译的低级程序最有效果,但如果你可以避免运行时环境和解释器带来的大量额外输出,则仍然可以与 Python 等高级语言程序一起使用。 + +当软件在一台机器上正常工作,但在另一台机器上却不能正常工作,同时抛出了有关文件、权限或者不能运行某某命令等模糊的错误信息时,`strace` 往往能大显身手。不幸的是,它不能诊断高等级的问题,例如数字证书验证错误等。这些问题通常需要组合使用 `strace`(有时候是 [`ltrace`][5])和其它高级工具(例如使用 `openssl` 命令行工具调试数字证书错误)。 + +本文中的示例基于独立的服务器,但是对系统调用的追踪通常也可以在更复杂的部署平台上完成,仅需要找到合适的工具。 + +### 一个简单的例子 + +假设你正在尝试运行一个叫做 `foo` 的服务器应用程序,但是发生了以下情况: + +``` +$ foo +Error opening configuration file: No such file or directory +``` + +显然,它没有找到你已经写好的配置文件。之所以会发生这种情况,是因为包管理工具有时候在编译应用程序时指定了自定义的路径,所以你应当遵循特定发行版提供的安装指南。如果错误信息告诉你正确的配置文件应该在什么地方,你就可以在几秒钟内解决这个问题,但如果没有告诉你呢?你该如何找到正确的路径? + +如果你有权访问源代码,则可以通过阅读源代码来解决问题。这是一个好的备用计划,但不是最快的解决方案。你还可以使用类似 `gdb` 的单步调试器来观察程序的行为,但使用专门用于展示程序与系统环境交互作用的工具 `strace` 更加有效。 + +一开始, `strace` 产生的大量输出可能会让你不知所措,幸好你可以忽略其中大部分的无用信息。我经常使用 `-o` 参数把输出的追踪结果保存到单独的文件里: + +``` +$ strace -o /tmp/trace foo +Error opening configuration file: No such file or directory +$ cat /tmp/trace +execve("foo", ["foo"], 0x7ffce98dc010 /* 16 vars */) = 0 +brk(NULL) = 0x56363b3fb000 +access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) +openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 +fstat(3, {st_mode=S_IFREG|0644, st_size=25186, ...}) = 0 +mmap(NULL, 25186, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2f12cf1000 +close(3) = 0 +openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 +read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260A\2\0\0\0\0\0"..., 832) = 832 +fstat(3, {st_mode=S_IFREG|0755, st_size=1824496, ...}) = 0 +mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2f12cef000 +mmap(NULL, 1837056, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2f12b2e000 +mprotect(0x7f2f12b50000, 1658880, PROT_NONE) = 0 +mmap(0x7f2f12b50000, 1343488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f2f12b50000 +mmap(0x7f2f12c98000, 311296, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16a000) = 0x7f2f12c98000 +mmap(0x7f2f12ce5000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b6000) = 0x7f2f12ce5000 +mmap(0x7f2f12ceb000, 14336, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f2f12ceb000 +close(3) = 0 +arch_prctl(ARCH_SET_FS, 0x7f2f12cf0500) = 0 +mprotect(0x7f2f12ce5000, 16384, PROT_READ) = 0 +mprotect(0x56363b08b000, 4096, PROT_READ) = 0 +mprotect(0x7f2f12d1f000, 4096, PROT_READ) = 0 +munmap(0x7f2f12cf1000, 25186) = 0 +openat(AT_FDCWD, "/etc/foo/config.json", O_RDONLY) = -1 ENOENT (No such file or directory) +dup(2) = 3 +fcntl(3, F_GETFL) = 0x2 (flags O_RDWR) +brk(NULL) = 0x56363b3fb000 +brk(0x56363b41c000) = 0x56363b41c000 +fstat(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x8), ...}) = 0 +write(3, "Error opening configuration file"..., 60) = 60 +close(3) = 0 +exit_group(1) = ? ++++ exited with 1 +++ +``` + +`strace` 输出的第一页通常是低级的进程启动过程。(你可以看到很多 `mmap`、`mprotect`、`brk` 调用,这是用来分配原始内存和映射动态链接库的。)实际上,在查找错误时,最好从下往上阅读 `strace` 的输出。你可以看到 `write` 调用在最后返回了错误信息。如果你向上找,你将会看到第一个失败的系统调用是 `openat`,它在尝试打开 `/etc/foo/config.json` 时抛出了 `ENOENT` (“No such file or directory”)的错误。现在我们已经知道了配置文件应该放在哪里。 + +这是一个简单的例子,但我敢说在 90% 的情况下,使用 `strace` 进行调试不需要更多复杂的工作。以下是完整的调试步骤: + +1. 从程序中获得含糊不清的错误信息 +2. 使用 `strace` 运行程序 +3. 在输出中找到错误信息 +4. 往前追溯并找到第一个失败的系统调用 + +第四步中的系统调用很可能向你显示出问题所在。 + +### 小技巧 + +在开始更加复杂的调试之前,这里有一些有用的调试技巧帮助你高效使用 `strace`: + +#### man 是你的朋友 + +在很多 *nix 操作系统中,你可以通过 `man syscalls` 查看系统调用的列表。你将会看到类似于 `brk(2)` 之类的东西,这意味着你可以通过运行 `man 2 brk` 得到与此相关的更多信息。 + +一个小问题:`man 2 fork` 会显示出在 GNU `libc` 里封装的 `fork()` 手册页,而 `fork()` 现在实际上是由 `clone` 系统调用实现的。`fork` 的语义与 `clone` 相同,但是如果我写了一个含有 `fork()` 的程序并使用 `strace` 去调试它,我将找不到任何关于 `fork` 调用的信息,只能看到 `clone` 调用。如果将源代码与 `strace` 的输出进行比较的时候,像这种问题会让人感到困惑。 + +#### 使用 -o 将输出保存到文件 + +`strace` 可以生成很多输出,所以将输出保存到单独的文件是很有帮助的(就像上面的例子一样)。它还能够在控制台中避免程序自身的输出与 `strace` 的输出发生混淆。 + +#### 使用 -s 查看更多的参数 + +你可能已经注意到,错误信息的第二部分没有出现在上面的例子中。这是因为 `strace` 默认仅显示字符串参数的前 32 个字节。如果你需要捕获更多参数,请向 `strace` 追加类似于 `-s 128` 之类的参数。 + +#### -y 使得追踪文件或套接字更加容易 + +“一切皆文件”意味着 *nix 系统通过文件描述符进行所有 IO 操作,不管是真实的文件还是通过网络或者进程间管道。这对于编程而言是很方便的,但是在追踪系统调用时,你将很难分辨出 `read` 和 `write` 的真实行为。 + +`-y` 参数使 `strace` 在注释中注明每个文件描述符的具体指向。 + +#### 使用 -p 附加到正在运行的进程中 + +正如我们将在后面的例子中看到的,有时候你想追踪一个正在运行的程序。如果你知道这个程序的进程号为 1337 (可以通过 `ps` 查询),则可以这样操作: + +``` +$ strace -p 1337 +...system call trace output... +``` + +你可能需要 root 权限才能运行。 + +#### 使用 -f 追踪子进程 + +`strace` 默认只追踪一个进程。如果这个进程产生了一个子进程,你将会看到创建子进程的系统调用(一般是 `clone`),但是你看不到子进程内触发的任何调用。 + +如果你认为在子进程中存在错误,则需要使用 `-f` 参数启用子进程追踪功能。这样做的缺点是输出的内容会让人更加困惑。当追踪一个进程时,`strace` 显示的是单个调用事件流。当追踪多个进程的时候,你将会看到以 `` 开始的初始调用,接着是一系列针对其它线程的调用,最后才出现以 `<... foocall resumed>` 结束的初始调用。此外,你可以使用 `-ff` 参数将所有的调用分离到不同的文件中(查看 [strace 手册][6] 获取更多信息)。 + +#### 使用 -e 进行过滤 + +正如你所看到的,默认的追踪输出是所有的系统调用。你可以使用 `-e` 参数过滤你需要追踪的调用(查看 [strace 手册][6])。这样做的好处是运行过滤后的 `strace` 比起使用 `grep` 进行二次过滤要更快。老实说,我大部分时间都不会被打扰。 + +#### 并非所有的错误都是不好的 + +一个简单而常用的例子是一个程序在多个位置搜索文件,例如 shell 搜索哪个 `bin/` 目录包含可执行文件: + +``` +$ strace sh -c uname +... +stat("/home/user/bin/uname", 0x7ffceb817820) = -1 ENOENT (No such file or directory) +stat("/usr/local/bin/uname", 0x7ffceb817820) = -1 ENOENT (No such file or directory) +stat("/usr/bin/uname", {st_mode=S_IFREG|0755, st_size=39584, ...}) = 0 +... +``` + +“错误信息之前的最后一次失败调用”这种启发式方法非常适合于查找错误。无论如何,自下而上地查找是有道理的。 + +#### C 编程指南非常有助于理解系统调用 + +标准 C 库函数调用不属于系统调用,但它们仅是系统调用之上的唯一一个薄层。所以如果你了解(甚至只是略知一二)如何使用 C 语言,那么阅读系统调用追踪信息就非常容易。例如,如果你在调试网络系统调用,你可以尝试略读 [Beej 经典的《网络编程指南》][7]。 + +### 一个更复杂的调试例子 + +就像我说的那样,简单的调试例子表现了我在大部分情况下如何使用 `strace`。然而,有时候需要一些更加细致的工作,所以这里有一个稍微复杂(且真实)的例子。 + +[bcron][8] 是一个任务调度器,它是经典 *nix `cron` 守护程序的另一种实现。它已经被安装到一台服务器上,但是当有人尝试编辑作业时间表时,发生了以下情况: + +``` +# crontab -e -u logs +bcrontab: Fatal: Could not create temporary file +``` + +好的,现在 bcron 尝试写入一些文件,但是它失败了,也没有告诉我们原因。以下是 `strace` 的输出: + +``` +# strace -o /tmp/trace crontab -e -u logs +bcrontab: Fatal: Could not create temporary file +# cat /tmp/trace +... +openat(AT_FDCWD, "bcrontab.14779.1573691864.847933", O_RDONLY) = 3 +mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f82049b4000 +read(3, "#Ansible: logsagg\n20 14 * * * lo"..., 8192) = 150 +read(3, "", 8192) = 0 +munmap(0x7f82049b4000, 8192) = 0 +close(3) = 0 +socket(AF_UNIX, SOCK_STREAM, 0) = 3 +connect(3, {sa_family=AF_UNIX, sun_path="/var/run/bcron-spool"}, 110) = 0 +mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f82049b4000 +write(3, "156:Slogs\0#Ansible: logsagg\n20 1"..., 161) = 161 +read(3, "32:ZCould not create temporary f"..., 8192) = 36 +munmap(0x7f82049b4000, 8192) = 0 +close(3) = 0 +write(2, "bcrontab: Fatal: Could not creat"..., 49) = 49 +unlink("bcrontab.14779.1573691864.847933") = 0 +exit_group(111) = ? ++++ exited with 111 +++ +``` + +在程序结束之前有一个 `write` 的错误信息,但是这次有些不同。首先,在此之前没有任何相关的失败系统调用。其次,我们看到这个错误信息是由 `read` 从别的地方读取而来的。这看起来像是真正的错误发生在别的地方,而 `bcrontab` 只是在转播这些信息。 + +如果你查阅了 `man 2 read`,你将会看到 `read` 的第一个参数 (`3`) 是一个文件描述符,这是 *nix 操作系统用于所有 IO 操作的句柄。你该如何知道文件描述符 3 代表什么?在这种情况下,你可以使用 `-y` 参数运行 `strace`(如上文所述),它将会在注释里告诉你文件描述符的具体指向,但是了解如何从上面这种输出中分析追踪结果是很有用的。 + +一个文件描述符可以来自于许多系统调用之一(这取决于它是用于控制台、网络套接字还是真实文件等的描述符),但不论如何,我们都可以搜索返回值为 `3` 的系统调用(例如,在 `strace` 的输出中查找 `=3`)。在这次 `strace` 中可以看到有两个这样的调用:最上面的 `openat` 以及中间的 `socket`。`openat` 打开一个文件,但是紧接着的 `close(3)` 表明其已经被关闭。(注意:文件描述符可以在打开并关闭后重复使用。)所以 `socket` 调用才是与此相关的(它是在 `read` 之前的最后一个),这告诉我们 `brcontab` 正在与一个网络套接字通信。在下一行,`connect` 表明文件描述符 3 是一个连接到 `/var/run/bcron-spool` 的 Unix 域套接字。 + +因此,我们需要弄清楚 Unix 套接字的另一侧是哪个进程在监听。有两个巧妙的技巧适用于在服务器部署中调试。一个是使用 `netstat` 或者较新的 `ss`。这两个命令都描述了当前系统中活跃的网络套接字,使用 `-l` 参数可以显示出处于监听状态的套接字,而使用 `-p` 参数可以得到正在使用该套接字的程序信息。(它们还有更多有用的选项,但是这两个已经足够完成工作了。) + +``` +# ss -pl | grep /var/run/bcron-spool +u_str LISTEN 0 128 /var/run/bcron-spool 1466637 * 0 users:(("unixserver",pid=20629,fd=3)) +``` + +这告诉我们 `/var/run/bcron-spool` 套接字的监听程序是 `unixserver` 这个命令,它的进程 ID 为 20629。(巧合的是,这个程序也使用文件描述符 `3` 去连接这个套接字。) + +第二个常用的工具就是使用 `lsof` 查找相同的信息。它可以列出当前系统中打开的所有文件(或文件描述符)。或者,我们可以得到一个具体文件的信息: + +``` +# lsof /var/run/bcron-spool +COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME +unixserve 20629 cron 3u unix 0x000000005ac4bd83 0t0 1466637 /var/run/bcron-spool type=STREAM +``` + +进程 20629 是一个常驻进程,所以我们可以使用 `strace -o /tmp/trace -p 20629` 去查看该进程的系统调用。如果我们在另一个终端尝试编辑 cron 的计划任务表,就可以在错误发生时捕获到以下信息: + +``` +accept(3, NULL, NULL) = 4 +clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7faa47c44810) = 21181 +close(4) = 0 +accept(3, NULL, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set) +--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=21181, si_uid=998, si_status=0, si_utime=0, si_stime=0} --- +wait4(0, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG|WSTOPPED, NULL) = 21181 +wait4(0, 0x7ffe6bc36764, WNOHANG|WSTOPPED, NULL) = -1 ECHILD (No child processes) +rt_sigaction(SIGCHLD, {sa_handler=0x55d244bdb690, sa_mask=[CHLD], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7faa47ab9840}, {sa_handler=0x55d244bdb690, sa_mask=[CHLD], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7faa47ab9840}, 8) = 0 +rt_sigreturn({mask=[]}) = 43 +accept(3, NULL, NULL) = 4 +clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7faa47c44810) = 21200 +close(4) = 0 +accept(3, NULL, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set) +--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=21200, si_uid=998, si_status=111, si_utime=0, si_stime=0} --- +wait4(0, [{WIFEXITED(s) && WEXITSTATUS(s) == 111}], WNOHANG|WSTOPPED, NULL) = 21200 +wait4(0, 0x7ffe6bc36764, WNOHANG|WSTOPPED, NULL) = -1 ECHILD (No child processes) +rt_sigaction(SIGCHLD, {sa_handler=0x55d244bdb690, sa_mask=[CHLD], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7faa47ab9840}, {sa_handler=0x55d244bdb690, sa_mask=[CHLD], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7faa47ab9840}, 8) = 0 +rt_sigreturn({mask=[]}) = 43 +accept(3, NULL, NULL +``` + +(最后一个 `accept` 调用没有在追踪期间完成。)不幸的是,这次追踪没有包含我们想要的错误信息。我们没有观察到 `bcrontan` 往套接字发送或接受的任何信息。然而,我们看到了很多进程管理操作(`clone`、`wait4`、`SIGCHLD`,等等)。这个进程产生了子进程,我们猜测真实的工作是由子进程完成的。如果我们想捕获子进程的追踪信息,就必须往 `strace` 追加 `-f` 参数。以下是我们最终使用 `strace -f -o /tmp/trace -p 20629` 找到的错误信息: + +``` +21470 openat(AT_FDCWD, "tmp/spool.21470.1573692319.854640", O_RDWR|O_CREAT|O_EXCL, 0600) = -1 EACCES (Permission denied) +21470 write(1, "32:ZCould not create temporary f"..., 36) = 36 +21470 write(2, "bcron-spool[21470]: Fatal: logs:"..., 84) = 84 +21470 unlink("tmp/spool.21470.1573692319.854640") = -1 ENOENT (No such file or directory) +21470 exit_group(111) = ? +21470 +++ exited with 111 +++ +``` + +现在我们知道了进程 ID 21470 在尝试创建文件 `tmp/spool.21470.1573692319.854640` (相对于当前的工作目录)时得到了一个没有权限的错误。如果我们知道当前的工作目录,就可以得到完整路径并能指出为什么该进程无法在此处创建临时文件。不幸的是,这个进程已经退出了,所以我们不能使用 `lsof -p 21470` 去找出当前的工作目录,但是我们可以往前追溯,查找进程 ID 21470 使用哪个系统调用改变了它的工作目录。这个系统调用是 `chdir`(可以在搜索引擎很轻松地找到)。以下是一直往前追溯到服务器进程 ID 20629 的结果: + +``` +20629 clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7faa47c44810) = 21470 +... +21470 execve("/usr/sbin/bcron-spool", ["bcron-spool"], 0x55d2460807e0 /* 27 vars */) = 0 +... +21470 chdir("/var/spool/cron") = 0 +... +21470 openat(AT_FDCWD, "tmp/spool.21470.1573692319.854640", O_RDWR|O_CREAT|O_EXCL, 0600) = -1 EACCES (Permission denied) +21470 write(1, "32:ZCould not create temporary f"..., 36) = 36 +21470 write(2, "bcron-spool[21470]: Fatal: logs:"..., 84) = 84 +21470 unlink("tmp/spool.21470.1573692319.854640") = -1 ENOENT (No such file or directory) +21470 exit_group(111) = ? +21470 +++ exited with 111 +++ +``` + +(如果你在这里迷糊了,你可能需要阅读 [我之前有关 \*nix 进程管理和 shell 的文章][9]) + +现在 PID 为 20629 的服务器进程没有权限在 `/var/spool/cron/tmp/spool.21470.1573692319.854640` 创建文件。最可能的原因就是典型的 *nix 文件系统权限设置。让我们检查一下: + +``` +# ls -ld /var/spool/cron/tmp/ +drwxr-xr-x 2 root root 4096 Nov 6 05:33 /var/spool/cron/tmp/ +# ps u -p 20629 +USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND +cron 20629 0.0 0.0 2276 752 ? Ss Nov14 0:00 unixserver -U /var/run/bcron-spool -- bcron-spool +``` + +这就是问题所在!这个服务进程以 `cron` 用户运行,但是只有 `root` 用户才有向 `/var/spool/cron/tmp/` 目录写入的权限。一个简单 `chown cron /var/spool/cron/tmp/` 命令就能让 `bcron` 正常工作。(如果不是这个问题,那么下一个最有可能的怀疑对象是诸如 SELinux 或者 AppArmor 之类的内核安全模块,因此我将会使用 `dmesg` 检查内核日志。) + +### 总结 + +最初,系统调用追踪可能会让人不知所措,但是我希望我已经证明它们是调试一整套常见部署问题的快速方法。你可以设想一下尝试用单步调试器去调试多进程的 `bcron` 问题。 + +通过一连串的系统调用解决问题是需要练习的,但正如我说的那样,在大多数情况下,我只需要使用 `strace` 从下往上追踪并查找错误。不管怎样,`strace` 节省了我很多的调试时间。我希望这也对你有所帮助。 + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2019/11/14/deployment_debugging_strace.html + +作者:[Simon Arneaud][a] +选题:[lujun9972][b] +译者:[hanwckf](https://github.com/hanwckf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://theartofmachinery.com +[b]: https://github.com/lujun9972 +[1]: https://strace.io/ +[2]: http://dtrace.org/blogs/about/ +[3]: https://man.openbsd.org/ktrace +[4]: https://theartofmachinery.com/images/strace/system_calls.svg +[5]: https://linux.die.net/man/1/ltrace +[6]: https://linux.die.net/man/1/strace +[7]: https://beej.us/guide/bgnet/html/index.html +[8]: https://untroubled.org/bcron/ +[9]: https://theartofmachinery.com/2018/11/07/writing_a_nix_shell.html diff --git a/published/20191115 How to port an awk script to Python.md b/published/20191115 How to port an awk script to Python.md new file mode 100644 index 0000000000..f163b2db42 --- /dev/null +++ b/published/20191115 How to port an awk script to Python.md @@ -0,0 +1,201 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11654-1.html) +[#]: subject: (How to port an awk script to Python) +[#]: via: (https://opensource.com/article/19/11/awk-to-python) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +如何把 awk 脚本移植到 Python +====== + +> 将一个 awk 脚本移植到 Python 主要在于代码风格而不是转译。 + +![](https://img.linux.net.cn/data/attachment/album/201912/08/095256ko6xdfwooe8zctfz.jpg) + +脚本是解决问题的有效方法,而 awk 是编写脚本的出色语言。它特别擅长于简单的文本处理,它可以带你完成配置文件的某些复杂重写或目录中文件名的重新格式化。 + +### 何时从 awk 转向 Python + +但是在某些方面,awk 的限制开始显现出来。它没有将文件分解为模块的真正概念,它缺乏质量错误报告,并且缺少了现在被认为是编程语言工作原理的其他内容。当编程语言的这些丰富功能有助于维护关键脚本时,移植将是一个不错的选择。 + +我最喜欢的完美移植 awk 的现代编程语言是 Python。 + +在将 awk 脚本移植到 Python 之前,通常值得考虑一下其原始使用场景。例如,由于 awk 的局限性,通常从 Bash 脚本调用 awk 代码,其中包括一些对 `sed`、`sort` 之类的其它命令行常见工具的调用。 最好将所有内容转换为一个一致的 Python 程序。有时,脚本会做出过于宽泛的假设,例如,即使实际上只运行一个文件,该代码也可能允许任意数量的文件。 + +在仔细考虑了上下文并确定了要用 Python 替代的东西之后,该编写代码了。 + +### 标准 awk 到 Python 功能 + +以下 Python 功能是有用的,需要记住: + +``` +with open(some_file_name) as fpin: +    for line in fpin: +        pass # do something with line +``` + +此代码将逐行循环遍历文件并处理这些行。 + +如果要访问行号(相当于 awk 的 `NR`),则可以使用以下代码: + +``` +with open(some_file_name) as fpin: +    for nr, line in enumerate(fpin): +        pass # do something with line +``` + +### 在 Python 中实现多文件的 awk 式行为 + +如果你需要能够遍历任意数量的文件同时保持行数的持续计数(类似 awk 的 `FNR`),则此循环可以做到这一点: + +``` +def awk_like_lines(list_of_file_names): +    def _all_lines(): +        for filename in list_of_file_names: +            with open(filename) as fpin: +                yield from fpin +    yield from enumerate(_all_lines()) +``` + +此语法使用 Python 的*生成器*和 `yield from` 来构建*迭代器*,该迭代器将遍历所有行并保持一个持久计数。 + +如果你需要同时使用 `FNR` 和 `NR`,这是一个更复杂的循环: + +``` +def awk_like_lines(list_of_file_names): +    def _all_lines(): +        for filename in list_of_file_names: +            with open(filename) as fpin: +                yield from enumerate(fpin) +    for nr, (fnr, line) in _all_lines: +        yield nr, fnr, line +``` + +### 更复杂的 FNR、NR 和行数的 awk 行为 + +如果 `FNR`、`NR` 和行数这三个你全都需要,仍然会有一些问题。如果确实如此,则使用三元组(其中两个项目是数字)会导致混淆。命名参数可使该代码更易于阅读,因此最好使用 `dataclass`: + +``` +import dataclass + +@dataclass.dataclass(frozen=True) +class AwkLikeLine: +    content: str +    fnr: int +    nr: int + +def awk_like_lines(list_of_file_names): +    def _all_lines(): +        for filename in list_of_file_names: +            with open(filename) as fpin: +                yield from enumerate(fpin) +    for nr, (fnr, line) in _all_lines: +        yield AwkLikeLine(nr=nr, fnr=fnr, line=line) +``` + +你可能想知道,为什么不一直用这种方法呢?使用其它方式的的原因是总用这种方法太复杂了。如果你的目标是把一个通用库更容易地从 awk 移植到 Python,请考虑这样做。但是编写一个可以使你确切地了解特定情况所需的循环的方法通常更容易实现,也更容易理解(因而易于维护)。 + +### 理解 awk 字段 + +一旦有了与一行相对应的字符串,如果要转换 awk 程序,则通常需要将其分解为*字段*。Python 有几种方法可以做到这一点。这将把行按任意数量的连续空格拆分,返回一个字符串列表: + +``` +line.split() +``` + +如果需要另一个字段分隔符,比如以 `:` 分隔行,则需要 `rstrip` 方法来删除最后一个换行符: + +``` +line.rstrip("\n").split(":") +``` + +完成以下操作后,列表 `parts` 将存有分解的字符串: + +``` +parts = line.rstrip("\n").split(":") +``` + +这种拆分非常适合用来处理参数,但是我们处于[偏差一个的错误][2]场景中。现在 `parts[0]` 将对应于 awk 的 `$1`,`parts[1]` 将对应于 awk 的 `$2`,依此类推。之所以偏差一个,是因为 awk 计数“字段”从 1 开始,而 Python 从 0 开始计数。在 awk 中,`$0` 是整个行 —— 等同于 `line.rstrip("\n")`,而 awk 的 `NF`(字段数)更容易以 `len(parts)` 的形式得到。 + +### 移植 awk 字段到 Python + +例如,让我们将这个单行代码“[如何使用 awk 从文件中删除重复行][3]”转换为 Python。 + +`awk` 中的原始代码是: + +``` +awk '!visited[$0]++' your_file > deduplicated_file +``` + +“真实的” Python 转换将是: + +``` +import collections +import sys + +visited = collections.defaultdict(int) +for line in open("your_file"): +    did_visit = visited[line] +    visited[line] += 1 +    if not did_visit: +        sys.stdout.write(line) +``` + +但是,Python 比 awk 具有更多的数据结构。与其计数访问次数(除了知道是否看到一行,我们不使用它),为什么不记录访问的行呢? + +``` +import sys + +visited = set() +for line in open("your_file"): +    if line in visited: +        continue +    visited.add(line) +    sys.stdout.write(line) +``` + +### 编写 Python 化的 awk 代码 + +Python 社区提倡编写 Python 化的代码,这意味着它要遵循公认的代码风格。更加 Python 化的方法将区分*唯一性*和输入/输出的关注点。此更改将使对代码进行单元测试更加容易: + +``` +def unique_generator(things): +    visited = set() +    for thing in things: +        if thing in visited: +            continue +        visited.add(things) +        yield thing + +import sys +    +for line in unique_generator(open("your_file")): +    sys.stdout.write(line) +``` + +将所有逻辑置于输入/输出代码之外,可以更好地分离问题,并提高代码的可用性和可测试性。 + +### 结论:Python 可能是一个不错的选择 + +将 awk 脚本移植到 Python 时,通常是在考虑适当的 Python 代码风格时重新实现核心需求,而不是按条件/操作进行笨拙的音译。考虑原始上下文并产生高质量的 Python 解决方案。虽然有时候使用 awk 的 Bash 单行代码可以完成这项工作,但 Python 编码是通往更易于维护的代码的途径。 + +另外,如果你正在编写 awk 脚本,我相信您也可以学习 Python!如果你有任何疑问,请告诉我。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/awk-to-python + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_women_computing_4.png?itok=VGZO8CxT (Woman sitting in front of her laptop) +[2]: https://en.wikipedia.org/wiki/Off-by-one_error +[3]: https://opensource.com/article/19/10/remove-duplicate-lines-files-awk diff --git a/sources/tech/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md b/published/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md similarity index 53% rename from sources/tech/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md rename to published/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md index 85e70ba6a8..222e24b4c7 100644 --- a/sources/tech/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md +++ b/published/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md @@ -1,40 +1,26 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11661-1.html) [#]: subject: (6 Methods to Quickly Check if a Website is up or down from the Linux Terminal) [#]: via: (https://www.2daygeek.com/linux-command-check-website-is-up-down-alive/) [#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) -6 Methods to Quickly Check if a Website is up or down from the Linux Terminal +在 Linux 终端快速检测网站是否宕机的 6 个方法 ====== -This tutorial shows you how to quickly check whether a given website is up (alive) or down from a Linux terminal. +> 本教程教你怎样在 Linux 终端快速检测一个网站是否宕机。 -You may already know some of these commands to verify about this, namely ping, curl, and wget. +![](https://img.linux.net.cn/data/attachment/album/201912/10/093801u332115oocxz4531.jpg) -But we have added some other commands as well in this tutorial. +你可能已经了解了一些类似的命令,像 `ping`、`curl` 和 `wget`。我们在本教程中又加入了一些其他命令。同时,我们也加入了不同的选项来检测单个和多个主机的信息。 -Also, we have added various options to check this information for single host and multiple hosts. +本文将帮助你检测网站是否宕机。但是如果你在维护一些网站,希望网站宕掉时得到实时的报警,我推荐你去使用实时网站监控工具。这种工具有很多,有些是免费的,大部分收费。根据你的需求,选择合适的工具。在后续的文章中我们会涉及这个主题。 -This article will help you to check whether the website is up or down. +### 方法 1:使用 fping 命令检测一个网站是否宕机 -But if you maintain some websites and want to get real-time alerts when the website is down. - -I recommend you to use real-time website monitoring tools. There are many tools for this, and some are free and most of them are paid. - -So choose the preferred one based on your needs. We will cover this topic in our upcoming article. - -### Method-1: How to Check if a Website is up or down Using the fping Command - -**[fping command][1]** is a program such as ping, which uses the Internet Control Message Protocol (ICMP) echo request to determine whether a target host is responding. - -fping differs from ping because it allows users to ping any number of host in parallel. Also, hosts can be entered from a text file. - -fping sends an ICMP echo request, moves the next target in a round-robin fashion, and does not wait until the target host responds. - -If a target host replies, it is noted as active and removed from the list of targets to check; if a target does not respond within a certain time limit and/or retry limit it is designated as unreachable. +[fping 命令][1] 是一个类似 `ping` 的程序,使用互联网控制消息协议(ICMP)的回应请求报文echo request来判断目标主机是否能回应。`fping` 与 `ping` 的不同之处在于它可以并行地 `ping` 任意数量的主机,也可以从一个文本文件读入主机名称。`fping` 发送一个 ICMP 回应请求后不等待目标主机响应,就以轮询模式向下一个目标主机发请求。如果一个目标主机有响应,那么它就被标记为存活的,然后从检查目标列表里去掉。如果一个目标主机在限定的时间和(或)重试次数内没有响应,则被指定为网站无法到达的。 ``` # fping 2daygeek.com linuxtechnews.com magesh.co.in @@ -44,15 +30,9 @@ linuxtechnews.com is alive magesh.co.in is alive ``` -### Method-2: How to Quickly Check Whether a Website is up or down Using the http Command +### 方法 2:使用 http 命令检测一个网站是否宕机 -HTTPie (pronounced aitch-tee-tee-pie) is a command line HTTP client. - -The **[httpie tool][2]** is a modern command line http client which makes CLI interaction with web services. - -It provides a simple http command that allows for sending arbitrary HTTP requests using a simple and natural syntax, and displays colorized output. - -HTTPie can be used for testing, debugging, and generally interacting with HTTP servers. +HTTPie(读作 aitch-tee-tee-pie)是一个命令行 HTTP 客户端。[httpie][2] 是一个可以与 web 服务通过 CLI 进行交互的现代工具。httpie 工具提供了简单的 `http` 命令,可以通过发送简单的、自然语言语法的任意 HTTP 请求得到多彩的结果输出。HTTPie 可以用来对 HTTP 服务器进行测试、调试和基本的交互。 ``` # http 2daygeek.com @@ -69,15 +49,9 @@ Transfer-Encoding: chunked Vary: Accept-Encoding ``` -### Method-3: How to Check if a Website is up or down Using the curl Command +### 方法 3:使用 curl 命令检测一个网站是否宕机 -**[curl command][3]** is a tool to transfer data from a server or to server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP). - -The command is designed to work without user interaction. - -Also curl support proxy support, user authentication, FTP upload, HTTP post, SSL connections, cookies, file transfer resume, Metalink, and more. - -curl is powered by libcurl for all transfer-related features. +[curl 命令][3] 是一个用于在服务器间通过支持的协议(DICT、FILE、FTP、FTPS、GOPHER、HTTP、HTTPS、IMAP、IMAPS、LDAP、LDAPS、POP3、POP3S、RTMP、RTSP、SCP、SFTP、SMTP、SMTPS、TELNET 和 TFTP)传输数据的工具。这个工具不支持用户交互。`curl` 也支持使用代理、用户认证、FTP 上传、HTTP POST 请求、SSL 连接、cookie、断点续传、Metalink 等等。`curl `由 libcurl 库提供所有与传输有关的能力。 ``` # curl -I https://www.magesh.co.in @@ -95,14 +69,14 @@ server: cloudflare cf-ray: 535b74123ca4dbf3-LHR ``` -Use the following curl command if you want to see only the HTTP status code instead of entire output. +如果你只想看 HTTP 状态码而不是返回的全部信息,用下面的 `curl` 命令: ``` # curl -I "www.magesh.co.in" 2>&1 | awk '/HTTP\// {print $2}' 200 ``` -If you want to see if a given website is up or down, use the following Bash script. +如果你想看一个网站是否宕机,用下面的 bash 脚本: ``` # vi curl-url-check.sh @@ -115,7 +89,7 @@ else fi ``` -Once you have added the above script to a file, run the file to see the output. +当你把脚本内容添加到一个文件后,执行文件,查看结果: ``` # sh curl-url-check.sh @@ -124,7 +98,7 @@ HTTP/2 200 magesh.co.in is up ``` -Use the following shell script if you want to see the status of multiple websites. +如果你想看多个网站的状态,使用下面的 shell 脚本: ``` # vi curl-url-check-1.sh @@ -141,7 +115,7 @@ echo "----------------------------------" done ``` -Once you have added the above script to a file, run the file to see the output. +当你把上面脚本内容添加到一个文件后,执行文件,查看结果: ``` # sh curl-url-check-1.sh @@ -156,13 +130,9 @@ www.xyzzz.com is down ---------------------------------- ``` -### Method-4: How to Quickly Check Whether a Website is up or down Using the wget Command +### 方法 4:使用 wget 命令检测一个网站是否宕机 -**[wget command][4]** (formerly known as Geturl) is a Free, open source, command line download tool which is retrieving files using HTTP, HTTPS and FTP, the most widely-used Internet protocols. - -It is a non-interactive command line tool and Its name is derived from World Wide Web and get. - -wget handle download pretty much good compared with other tools, futures included working in background, recursive download, multiple file downloads, resume downloads, non-interactive downloads & large file downloads. +[wget 命令][4](前身是 Geturl)是一个自由开源的命令行下载工具,通过 HTTP、HTTPS、FTP 和其他广泛使用的互联网协议获取文件。`wget` 是非交互式的命令行工具,由 World Wide Web 和 get 得名。`wget` 相对于其他工具来说更优秀,功能包括后台运行、递归下载、多文件下载、断点续传、非交互式下载和大文件下载。 ``` # wget -S --spider https://www.magesh.co.in @@ -190,14 +160,14 @@ Remote file exists and could contain further links, but recursion is disabled -- not retrieving. ``` -Use the following wget command if you want to see only the HTTP status code instead of entire output. +如果你只想看 HTTP 状态码而不是返回的全部结果,用下面的 `wget` 命令: ``` # wget --spider -S "www.magesh.co.in" 2>&1 | awk '/HTTP\// {print $2}' 200 ``` -If you want to see if a given website is up or down, use the following Bash script. +如果你想看一个网站是否宕机,用下面的 bash 脚本: ``` # vi wget-url-check.sh @@ -210,7 +180,7 @@ else fi ``` -Once you have added the above script to a file, run the file to see the output. +当你把脚本内容添加到一个文件后,执行文件,查看结果: ``` # wget-url-check.sh @@ -219,7 +189,7 @@ HTTP/1.1 200 OK Google.com is up ``` -Use the following shell script if you want to see the status of multiple websites. +如果你想看多个网站的状态,使用下面的 shell 脚本: ``` # vi curl-url-check-1.sh @@ -236,7 +206,7 @@ echo "----------------------------------" done ``` -Once you have added the above script to a file, run the file to see the output. +当你把上面脚本内容添加到一个文件后,执行文件,查看结果: ``` # sh wget-url-check-1.sh @@ -251,9 +221,9 @@ www.xyzzz.com is down ---------------------------------- ``` -### Method-5: How to Quickly Check Whether a Website is up or down Using the lynx Command +### 方法 5:使用 lynx 命令检测一个网站是否宕机 -**[lynx][5]** is a highly configurable text-based web browser for use on cursor-addressable character cell terminals. It’s the oldest web browser and it’s still in active development. +[lynx][5] 是一个在可寻址光标字符单元终端cursor-addressable character cell terminals上使用的基于文本的高度可配的 web 浏览器,它是最古老的 web 浏览器并且现在仍在活跃开发。 ``` # lynx -head -dump http://www.magesh.co.in @@ -272,14 +242,14 @@ Server: cloudflare CF-RAY: 535fc5704a43e694-LHR ``` -Use the following lynx command if you want to see only the HTTP status code instead of entire output. +如果你只想看 HTTP 状态码而不是返回的全部结果,用下面的 `lynx` 命令: ``` # lynx -head -dump https://www.magesh.co.in 2>&1 | awk '/HTTP\// {print $2}' 200 ``` -If you want to see if a given website is up or down, use the following Bash script. +如果你想看一个网站是否宕机,用下面的 bash 脚本: ``` # vi lynx-url-check.sh @@ -292,7 +262,7 @@ else fi ``` -Once you have added the above script to a file, run the file to see the output. +当你把脚本内容添加到一个文件后,执行文件,查看结果: ``` # sh lynx-url-check.sh @@ -301,7 +271,7 @@ HTTP/1.1 200 OK magesh.co.in is up ``` -Use the following shell script if you want to see the status of multiple websites. +如果你想看多个网站的状态,使用下面的 shell 脚本: ``` # vi lynx-url-check-1.sh @@ -318,7 +288,7 @@ echo "----------------------------------" done ``` -Once you have added the above script to a file, run the file to see the output. +当你把上面脚本内容添加到一个文件后,执行文件,查看结果: ``` # sh lynx-url-check-1.sh @@ -333,13 +303,9 @@ www.xyzzz.com is down ---------------------------------- ``` -### Method-6: How to Check if a Website is up or down Using the ping Command +### 方法 6:使用 ping 命令检测一个网站是否宕机 -**[ping command][1]** stands for (Packet Internet Groper) command is a networking utility that used to test the target of a host availability/connectivity on an Internet Protocol (IP) network. - -It’s verify a host availability by sending Internet Control Message Protocol (ICMP) Echo Request packets to the target host and waiting for an ICMP Echo Reply. - -It summarize statistical results based on the packets transmitted, packets received, packet loss, typically including the min/avg/max times. +[ping 命令][1](Packet Internet Groper)是网络工具的代表,用于在互联网协议(IP)的网络中测试一个目标主机是否可用/可连接。通过向目标主机发送 ICMP 回应请求报文包并等待 ICMP 回应响应报文来检测主机的可用性。它基于已发送的包、接收到的包和丢失了的包来统计结果数据,通常包含最小/平均/最大响应时间。 ``` # ping -c 5 2daygeek.com @@ -356,15 +322,9 @@ PING 2daygeek.com (104.27.157.177) 56(84) bytes of data. rtt min/avg/max/mdev = 170.668/213.824/250.295/28.320 ms ``` -### Method-7: How to Quickly Check Whether a Website is up or down Using the telnet Command +### 附加 1:使用 telnet 命令检测一个网站是否宕机 -The Telnet command is an old network protocol used to communicate with another host over a TCP/IP network using the TELNET protocol. - -It uses port 23 to connect to other devices, such as computer and network equipment. - -Telnet is not a secure protocol and is now not recommended to use because the data sent to the protocol is not encrypted and can be intercepted by hackers. - -Everyone uses SSH protocol instead of telnet, which is encrypted and very secure. +`telnet` 命令是一个使用 TELNET 协议用于 TCP/IP 网络中多个主机相互通信的古老的网络协议。它通过 23 端口连接其他设备如计算机和网络设备。`telnet` 是不安全的协议,现在由于用这个协议发送的数据没有经过加密可能被黑客拦截,所以不推荐使用。大家都使用经过加密且非常安全的 SSH 协议来代替 `telnet`。 ``` # telnet google.com 80 @@ -377,13 +337,11 @@ telnet> quit Connection closed. ``` -### Method-8: How to Check if a Website is up or down Using the Bash Script +### 附加 2:使用 bash 脚本检测一个网站是否宕机 -In simple words, a **[shell script][6]** is a file that contains a series of commands. The shell reads this file and executes the commands one by one as they are entered directly on the command line. +简而言之,一个 [shell 脚本][6] 就是一个包含一系列命令的文件。shell 从文件读取内容按输入顺序逐行在命令行执行。为了让它更有效,我们添加一些条件。这也减轻了 Linux 管理员的负担。 -To make this more useful we can add some conditions. This reduces the Linux admin task. - -If you want to see the status of multiple websites using the wget command, use the following shell script. +如果你想想用 `wget` 命令看多个网站的状态,使用下面的 shell 脚本: ``` # vi wget-url-check-2.sh @@ -399,7 +357,7 @@ fi done ``` -Once you have added the above script to a file, run the file to see the output. +当你把上面脚本内容添加到一个文件后,执行文件,查看结果: ``` # sh wget-url-check-2.sh @@ -409,7 +367,7 @@ google.co.in is up www.xyzzz.com is down ``` -If you want to see the status of multiple websites using the curl command, use the following **[bash script][7]**. +如果你想用 `wget` 命令看多个网站的状态,使用下面的 [shell 脚本][7]: ``` # vi curl-url-check-2.sh @@ -425,7 +383,7 @@ fi done ``` -Once you have added the above script to a file, run the file to see the output. +当你把上面脚本内容添加到一个文件后,执行文件,查看结果: ``` # sh curl-url-check-2.sh @@ -441,8 +399,8 @@ via: https://www.2daygeek.com/linux-command-check-website-is-up-down-alive/ 作者:[Magesh Maruthamuthu][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20191119 Top 10 Vim plugins for programming in multiple languages.md b/published/20191119 Top 10 Vim plugins for programming in multiple languages.md new file mode 100644 index 0000000000..a4a6d82093 --- /dev/null +++ b/published/20191119 Top 10 Vim plugins for programming in multiple languages.md @@ -0,0 +1,138 @@ +[#]: collector: "lujun9972" +[#]: translator: "hello-wn" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-11644-1.html" +[#]: subject: "Top 10 Vim plugins for programming in multiple languages" +[#]: via: "https://opensource.com/article/19/11/vim-plugins" +[#]: author: "Maxim Burgerhout https://opensource.com/users/wzzrd" + +多语言编程必备的十大 Vim 插件 +====== + +> 使用这 10 个 Vim 插件,可以让你在写代码或运维时,感觉更棒。 + +![](https://img.linux.net.cn/data/attachment/album/201912/05/062256bnauidfsf7155d1n.jpeg) + +我使用 [Vim][2] 文本编辑器大约 20 年了。有一段时间,我一直在定制我的 Vim 配置,但在只有在最近两年我才会使用插件。 + +最近,当我重新安装系统时(就像我经常做的那样),我觉得这是一次好的机会,我想找出多种编程语言环境下的最佳 Vim 插件,以及如何将这些插件和每种语言结合起来。 + +有时,我会为特定的语言和配置使用特定的插件(例如,我只在 Ansible 配置中安装 Rocannon),在此不细讲了。不过下面介绍的 10 个 Vim 插件都是我的最爱,无论使用哪种编程语言,我几乎都会使用它们。 + +### 1、Volt + +我的首选并不是一个插件,但是它可以替换类似于 [Vundle][3] 的插件,所以在此介绍。 + +[Volt][4] 是一个不依存于 Vim 的 Vim 插件管理器。你可以用它安装插件,并创建名为“profile”的插件组合。你可以使用一个简单的命令 `volt profile set myprofile` 启用新的配置。这样我可以做到这样的事情,如为 Python 配置单独启用 [indentpython][5] 插件。Volt 还提供了一种针对每个插件配置的简单方法,这些配置会在“profile”之间共享,因此只需要安装一次插件,就可以在多个“profile”之间使用。 + +Volt 还是相对较新且不够完美(比如,不管你想要使用多少个“profile”,每个插件只能有一个配置文件),但除此之外,我发现它非常方便、快速和简单。 + +![Volt plugin][6] + +### 2、Vim-Rainbow + +除了 Python,几乎所有的主流编程语言都使用括号(小括号、方括号和大括号)。通常,它们会嵌套使用多对括号,因此很难搞清楚某个括号的开闭区间。我发现自己经常要数小括号,尤其是在复杂的 Bash 脚本中,以确保无误。 + +这时候就需要 [vim-rainbow][7] 插件!它为每对括号设置不同的颜色,因此很容易识别出哪些括号是一对括号。它非常有用而且五彩斑斓。 + +![vim-rainbow plugin][8] + +### 3、lightline + +Vim 有很多这种插件,例如 [Powerline][9],它会在底部栏显示你正在处理的文件、光标所在的文件位置以及文件类型等信息。这些插件各有利弊,在简单比较后,我选择了 [lightline][10]。它相对较小,便于安装和扩展,并且不依赖于其他工具或插件。 + +![Lightline plugin][11] + +### 4、NERDTree + +[NERDTree][12] 是一个很经典的插件。在大型项目中,你可能很难找到想要编辑的内容所在文件的确切名称和路径。使用快捷键(我使用的是 `F7`,因为我在 `.vimrc` 中配置了这个快捷键),搜索窗会以垂直分屏的方式打开,就可以轻松找到所需文件并打开它。对于大型项目,这是必备插件。对于那些经常忘记文件名的人也很有用,比如我。 + +![NERDTree vim plugin][13] + +### 5、NERD Commenter + +程序员们在写代码时,有时会遇到一些难以调试的问题,导致他们想要注释或不执行某段代码。这时候就需要 [NERD Commenter][14] 出场了。选择代码段,按 `Leader 键 + cc`,代码就会被注释掉。(标准的 Vim Leader 键 是 `/` 字符。)按 `Leader 键 + cn`,取消注释。对于大多数文件类型,NERD Commenter 会自动使用正确的注释符。例如,如果你正在编辑 [BIND 区域文件][15],并将文件类型设置为 BIND 区域文件,Vim 会正确地使用 `;`(分号)字符进行注释。 + +![NERD Commenter][16] + +### 6、Solarized + +我喜欢我的 Vim 主题配色。我也喜欢终端的主题色。我一直在 Vim 上使用 [Solarized][17] 配色,并且将我的终端、文件夹配色和 Vim 设为一致。 + +但是,有时我会根据周边环境、屏幕亮度以及是否需要分享投屏,来切换明暗模式。 + +显然,你可以选择自己喜欢的任何配色方案,但我喜欢 `Solarized`,因为它有明暗模式功能,它可以简单快捷地切换两种模式。我的第二个选择是 [Monokai][18]。Volt 插件管理器让我可以轻松地在两者之间切换,因此我在 Python 编程时,使用 Monokai;Bash 编程时,使用 Solarized。 + +我没有给 Solarized 找相应的图片,因为本文中的所有其他图片都使用了 Solarized 中的浅色或深色效果,可以确认一下这些图片。 + +### 7、fzf + +当寻找一个文件时,有时你想要一个文件浏览器,有时你只想在键盘上敲打出与文件名模糊匹配的内容,对吗? + +[fzf][19](全称 “模糊查找器”)插件提供了这一功能。打出 `:FZF` 并输入文件名内容。不断缩短的列表将显示出与你输入的文件名内容相匹配的一些文件。我经常使用它,最近使用它的频率估计比使用 NERDTree 还多。缺点是这个插件依赖于 `fzf binary`,因此也必须安装这个依赖包。它适用于 Fedora、Debian 和 Arch,据我所知并不在 EPEL 中。 + +![fzf Vim plugin][20] + +### 8、ack + +有时,你需要搜索包含特定行或特定单词的文件。我真的很喜欢使用 [ack][21] 插件,最好与 `ag` 结合使用,它俩的组合又被称为 “[silver searcher][22]”。这一组合的速度非常快,覆盖了 `grep` 或 `vimgrep` 的绝大多数使用场景。缺点是你需要安装 `ack` 或 `ag` 才能正常运行。好消息是 Fedora 和 EPEL7 都可以使用 `ag` 和 `ack`。 + +![ack vim plugin][23] + +### 9、gitgutter + +大多数 IT 人员都使用 [Git][24] 和 Git 仓库中的文件进行工作。[gitgutter][25] 插件在行号附近添加了一列,通过符号显示该行的状态为:已更改(`~`)、已添加(`+`)或者已删除(`-`)。这有利于跟踪你所做的更改,并且可以使你专注于手头的任务,例如编写补丁来修复一个关键错误。 + +![gitgutter vim plugin][26] + +### 10、Tag List + +如果你在一个很大的文件中编写代码,会很容易忘记当前所在的位置,你可能需要上下滚动来查找某个功能。使用 [Tag List][27] 插件,只需要输入 `:Tlist`,就能垂直分屏显示出包含变量、类型、类和函数的代码,你可以轻松跳转到这些变量、类型、类和函数。这个功能对于多语言同样适用,例如 Java、Python 以及任何能够使用 `ctags` 功能的文件类型。 + +![Tag List vim plugin][28] + +以上介绍的 10 个 Vim 插件使我作为系统管理员和兼职程序员的生活变得更轻松。你正在使用哪些 Vim 插件?请在评论中分享你最爱的插件。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/vim-plugins + +作者:[Maxim Burgerhout][a] +选题:[lujun9972][b] +译者:[hello-wn][c] +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/wzzrd +[b]: https://github.com/lujun9972 +[c]: https://github.com/hello-wn +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openstack_python_vim_1.jpg?itok=lHQK5zpm "OpenStack source code (Python) in VIM" +[2]: https://www.vim.org/ +[3]: https://github.com/VundleVim/Vundle.vim +[4]: https://github.com/vim-volt/volt +[5]: https://github.com/vim-scripts/indentpython.vim +[6]: https://opensource.com/sites/default/files/uploads/vim-volt.gif "Volt plugin" +[7]: http://github.com/frazrepo/vim-rainbow +[8]: https://opensource.com/sites/default/files/uploads/vim-rainbox.png "vim-rainbow plugin" +[9]: https://github.com/powerline/powerline +[10]: http://github.com/itchyny/lightline.vim +[11]: https://opensource.com/sites/default/files/uploads/lightline.png "Lightline plugin" +[12]: http://github.com/scrooloose/nerdtree +[13]: https://opensource.com/sites/default/files/uploads/nerdtree.gif "NERDTree vim plugin" +[14]: http://github.com/scrooloose/nerdcommenter +[15]: https://en.wikipedia.org/wiki/Zone_file#File_format +[16]: https://opensource.com/sites/default/files/uploads/nerdcommenter.gif "NERD Commenter" +[17]: https://github.com/altercation/vim-colors-solarized +[18]: https://github.com/sickill/vim-monokai +[19]: https://github.com/junegunn/fzf.vim +[20]: https://opensource.com/sites/default/files/uploads/fzf.gif "fzf Vim plugin" +[21]: https://github.com/mileszs/ack.vim +[22]: https://github.com/ggreer/the_silver_searcher +[23]: https://opensource.com/sites/default/files/uploads/ack.gif "ack vim plugin" +[24]: https://opensource.com/resources/what-is-git +[25]: https://github.com/airblade/vim-gitgutter +[26]: https://opensource.com/sites/default/files/uploads/gitgutter.png "gitgutter vim plugin" +[27]: https://github.com/vim-scripts/taglist.vim +[28]: https://opensource.com/sites/default/files/uploads/taglist.gif "Tag List vim plugin) ) ) " diff --git a/published/20191120 Switching from Python 2 to Python 3- What you need to know.md b/published/20191120 Switching from Python 2 to Python 3- What you need to know.md new file mode 100644 index 0000000000..f89984a90c --- /dev/null +++ b/published/20191120 Switching from Python 2 to Python 3- What you need to know.md @@ -0,0 +1,105 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11629-1.html) +[#]: subject: (Switching from Python 2 to Python 3: What you need to know) +[#]: via: (https://opensource.com/article/19/11/end-of-life-python-2) +[#]: author: (Katie McLaughlin https://opensource.com/users/glasnt) + +从 Python 2 切换到 Python 3 你所需要了解的 +====== + +> Python 2 将在几周内走到生命终点,这篇文章是你迁移到 Python 3 之前应该知道的。 + +![](https://img.linux.net.cn/data/attachment/album/201912/01/095336lbppn8qp1nnnwqqp.jpg) + +从 2020 年 1 月 1 日开始,Python 2.7 将不再得到正式支持。在此日期之后,将会发布一个[最终错误修复][2]计划,但是仅此而已。 + +Python 2 的生命终点(EOL)对你意味着什么?如果正在运行着 Python 2,你需要迁移。 + +### 是谁决定 Python 2 的生命终点? + +在 [2012][3] 年,维护 Python 编程语言的团队审查了其选项。有两个越来越不同的代码库,Python 2 和 Python 3。这两者都很流行,但是较新的版本并未得到广泛采用。 + +除了 Python 3 中完全重写的 Unicode 支持改变了处理数据的底层方式造成的断层,这个主要版本的变化还一次性出现了一些非向后兼容的更改。这种断层的决定成文于 [2006 年][4]。为了减轻该断层的影响,Python 2 继续保持了维护,并向后移植了一些 Python 3 的功能。为了进一步帮助社区过渡,EOL 日期[从 2015 年延长至 2020 年][5],又延长了五年。 + +该团队知道,维护不同的代码库是必须解决的麻烦。最终,他们[宣布了][6]一项决定: + +>“我们是制作和照料 Python 编程语言的志愿者。我们已决定 2020 年 1 月 1 日将是我们停止使用 Python 2 的日子。这意味着在这一天之后,即使有人发现其中存在安全问题,我们也将不再对其进行改进。你应尽快升级到 Python 3。” + +[Nick Coghlan][7] 是 CPython 的核心开发人员,也是 Python 指导委员会的现任成员,[在他的博客中添加了更多信息][8]。由 [Barry Warsaw][10](也是 Python 指导委员会的成员)撰写的 [PEP 404][9] 详细说明了 Python 2.8 永远不会面世的原因。 + +### 有人还在支持 Python 2 吗? + +提供者和供应商对 Python 2 的支持会有所不同。[Google Cloud 宣布了][11]它计划未来如何支持 Python 2。红帽还[宣布了红帽企业 Linux(RHEL)的计划][12],而 AWS 宣布了 AWS 命令行界面和 [SDK][14] 的[次要版本更新要求][13]。 + +你还可以阅读 [Vicki Boykis][16] 在 Stack Overflow 撰写的博客文章“[为什么迁移到 Python 3 需要这么长时间?][15]”,其中她指出了采用 Python 3 缓慢的三个原因。 + +### 使用 Python 3 的原因 + +不管是否有持续的支持,尽快迁移到 Python 3 是一个好主意。Python 3 将继续受到支持,它具有 Python 2 所没有的一些非常优雅的东西。 + +最近发布的 [Python 3.8][17] 包含 [海象运算符][19]、[位置参数][20]和[自描述的格式化字符串][21]等[功能][18]。Python 3 的早期版本引入的[功能][22],例如 [异步 IO][23]、[格式化字符串][24]、[类型提示][25] 和 [pathlib][26],这里只提及了一点点。 + +下载最多的前 360 个软件包[已迁移到 Python 3][27]。你可以使用 [caniusepython3][28] 软件包检查你的 `requirements.txt` 文件,以查看你依赖的任何软件包是否尚未迁移。 + +### 将 Python 2 移植到 Python 3 的参考资源 + +有许多参考资源可简化你向 Python 3 的迁移。例如,“[将 Python 2 移植到 Python 3 指南][29]”列出了许多工具和技巧,可帮助你实现与 Python 2/3 单一源代码的兼容性。在 [Python3statement.org][30] 上也有一些有用的技巧。 + +[Dustin Ingram][31] 和 [Chris Wilcox][32] 在 [Cloud Next '19][33]上作了一个演讲,详细介绍了向 Python 3 过渡的一些动机和迁移模式。[Trey Hunner][34] 在 [PyCon 2018 演讲][35]上介绍了 Python 3 最有用的功能,鼓励你进行迁移,以便你可以利用它们。 + +### 加入我们! + +距 2020 年 1 月 1 日仅有几周了。如果你需要每天提醒一下它即将到来的时间(并且你使用 Twitter 的话),请关注 [Python 2 日落倒计时][36] Twitter 机器人。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/end-of-life-python-2 + +作者:[Katie McLaughlin][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/glasnt +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/govt_a%20new%20dawn.png?itok=b4zU-VAY (A sunrise) +[2]: https://www.python.org/dev/peps/pep-0373/#maintenance-releases +[3]: https://github.com/python/peps/commit/a733bc927acbca16bfa3de486fb2c7d3f767a748 +[4]: https://www.python.org/dev/peps/pep-3000/#compatibility-and-transition +[5]: https://github.com/python/peps/commit/f82462002b86feff36215b4230be28967039b0cc +[6]: https://www.python.org/doc/sunset-python-2/ +[7]: https://twitter.com/ncoghlan_dev +[8]: http://python-notes.curiousefficiency.org/en/latest/python3/questions_and_answers.html +[9]: https://www.python.org/dev/peps/pep-0404/ +[10]: https://twitter.com/pumpichank +[11]: https://cloud.google.com/python/docs/python2-sunset/?utm_source=osdc&utm_medium=blog&utm_campaign=pysunset +[12]: https://access.redhat.com/solutions/4455511 +[13]: https://aws.amazon.com/blogs/developer/deprecation-of-python-2-6-and-python-3-3-in-botocore-boto3-and-the-aws-cli/ +[14]: https://aws.amazon.com/sdk-for-python/ +[15]: https://stackoverflow.blog/2019/11/14/why-is-the-migration-to-python-3-taking-so-long/ +[16]: https://twitter.com/vboykis +[17]: https://www.python.org/downloads/ +[18]: https://docs.python.org/3.8/whatsnew/3.8.html +[19]: https://docs.python.org/3.8/whatsnew/3.8.html#assignment-expressions +[20]: https://docs.python.org/3.8/whatsnew/3.8.html#positional-only-parameters +[21]: https://docs.python.org/3.8/whatsnew/3.8.html#f-strings-support-for-self-documenting-expressions-and-debugging +[22]: https://docs.python.org/3.8/whatsnew/index.html +[23]: https://docs.python.org/3.8/library/asyncio.html#module-asyncio +[24]: https://docs.python.org/3.7/whatsnew/3.6.html#pep-498-formatted-string-literals +[25]: https://docs.python.org/3.7/whatsnew/3.5.html#pep-484-type-hints +[26]: https://docs.python.org/3.8/library/pathlib.html#module-pathlib +[27]: http://py3readiness.org/ +[28]: https://pypi.org/project/caniusepython3/ +[29]: https://docs.python.org/3/howto/pyporting.html +[30]: https://python3statement.org/practicalities/ +[31]: https://twitter.com/di_codes +[32]: https://twitter.com/chriswilcox47 +[33]: https://www.youtube.com/watch?v=Bye7Rms0Vgw&utm_source=osdc&utm_medium=blog&utm_campaign=pysunset +[34]: https://twitter.com/treyhunner +[35]: https://www.youtube.com/watch?v=klaGx9Q_SOA +[36]: https://twitter.com/python2sunset diff --git a/published/20191121 Bash Script to View System Information on Linux Every Time You Log into Shell.md b/published/20191121 Bash Script to View System Information on Linux Every Time You Log into Shell.md new file mode 100644 index 0000000000..74bca82720 --- /dev/null +++ b/published/20191121 Bash Script to View System Information on Linux Every Time You Log into Shell.md @@ -0,0 +1,220 @@ +[#]: collector: "lujun9972" +[#]: translator: "lxbwolf" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-11645-1.html" +[#]: subject: "Bash Script to View System Information on Linux Every Time You Log into Shell" +[#]: via: "https://www.2daygeek.com/bash-shell-script-view-linux-system-information/" +[#]: author: "Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/" + +Bash 脚本实现每次登录到 Shell 时可以查看 Linux 系统信息 +====== + +Linux 中有很多可以查看系统信息如处理器信息、生产商名字、序列号等的命令。你可能需要执行多个命令来收集这些信息。同时,记住所有的命令和他们的选项也是有难度。 + +你可以写一个 [shell 脚本](https://www.2daygeek.com/category/shell-script/) 基于你的需求来自定义显示的信息。 + +以前我们出于不同的目的需要写很多个 [bash 脚本](https://www.2daygeek.com/category/bash-script/)。 + +现在我们写一个新的 shell 脚本,在每次登录到 shell 时显示需要的系统信息。 + +这个j脚本有 6 部分,细节如下: + +1. 通用系统信息 +2. CPU/内存当前使用情况 +3. 硬盘使用率超过 80% +4. 列出系统 WWN 详情 +5. Oracle DB 实例 +6. 可更新的包 + +我们已经基于我们的需求把可能需要到的信息加到了每个部分。之后你可以基于自己的意愿修改这个脚本。 + +这个j脚本需要用到很多工具,其中大部分我们之前已经涉及到了。 + +你可以参照以前文章,了解工具详情。 + +* [inxi – 在 Linux 上检查硬件信息的绝佳工具][3] +* [Dmidecode – 获取 Linux 系统硬件信息的简便方法][4] +* [LSHW(硬件列表程序)– 在 Linux 上获取硬件信息的漂亮工具][5] +* [hwinfo(硬件信息)– 在 Linux 上检测系统硬件信息的漂亮工具][6] +* [python-hwinfo:使用标准 Linux 实用工具显示硬件信息摘要][7] +* [如何使用 lspci、lsscsi、lsusb 和 lsblk 获取 Linux 系统设备信息][8] +* [如何在 Linux 中检查系统硬件制造商、型号和序列号][9] +* [如何在 Linux 中查找 HBA 卡的 WWN、WWNN 和 WWPN 号][10] +* [如何从 Linux 命令行检查 HP iLO 固件版本][11] +* [如何从 Linux 命令行检查无线网卡和 WiFi 信息][12] +* [如何在 Linux 上检查 CPU 和硬盘温度][13] +* [Hegemon – Linux 的模块化系统和硬件监视工具][14] +* [如何在 Linux 上检查系统配置和硬件信息][15] + +如果你想为这个脚本增加其他的信息,请在评论去留下你的需求,以便我们帮助你。 + +### Bash 脚本实现每次登录到 Shell 时可以查看 Linux 系统信息 + +这个脚本会在你每次登录 shell 时把系统信息打印到 terminal。 + +``` +# vi /opt/scripts/system-info.sh +``` + +``` +#!/bin/bash +echo -e "-------------------------------System Information----------------------------" +echo -e "Hostname:\t\t"`hostname` +echo -e "uptime:\t\t\t"`uptime | awk '{print $3,$4}' | sed 's/,//'` +echo -e "Manufacturer:\t\t"`cat /sys/class/dmi/id/chassis_vendor` +echo -e "Product Name:\t\t"`cat /sys/class/dmi/id/product_name` +echo -e "Version:\t\t"`cat /sys/class/dmi/id/product_version` +echo -e "Serial Number:\t\t"`cat /sys/class/dmi/id/product_serial` +echo -e "Machine Type:\t\t"`vserver=$(lscpu | grep Hypervisor | wc -l); if [ $vserver -gt 0 ]; then echo "VM"; else echo "Physical"; fi` +echo -e "Operating System:\t"`hostnamectl | grep "Operating System" | cut -d ' ' -f5-` +echo -e "Kernel:\t\t\t"`uname -r` +echo -e "Architecture:\t\t"`arch` +echo -e "Processor Name:\t\t"`awk -F':' '/^model name/ {print $2}' /proc/cpuinfo | uniq | sed -e 's/^[ \t]*//'` +echo -e "Active User:\t\t"`w | cut -d ' ' -f1 | grep -v USER | xargs -n1` +echo -e "System Main IP:\t\t"`hostname -I` +echo "" +echo -e "-------------------------------CPU/Memory Usage------------------------------" +echo -e "Memory Usage:\t"`free | awk '/Mem/{printf("%.2f%"), $3/$2*100}'` +echo -e "Swap Usage:\t"`free | awk '/Swap/{printf("%.2f%"), $3/$2*100}'` +echo -e "CPU Usage:\t"`cat /proc/stat | awk '/cpu/{printf("%.2f%\n"), ($2+$4)*100/($2+$4+$5)}' | awk '{print $0}' | head -1` +echo "" +echo -e "-------------------------------Disk Usage >80%-------------------------------" +df -Ph | sed s/%//g | awk '{ if($5 > 80) print $0;}' +echo "" + +echo -e "-------------------------------For WWN Details-------------------------------" +vserver=$(lscpu | grep Hypervisor | wc -l) +if [ $vserver -gt 0 ] +then +echo "$(hostname) is a VM" +else +cat /sys/class/fc_host/host?/port_name +fi +echo "" + +echo -e "-------------------------------Oracle DB Instances---------------------------" +if id oracle >/dev/null 2>&1; then +/bin/ps -ef|grep pmon +then +else +echo "oracle user does not exist on $(hostname)" +fi +echo "" + +if (( $(cat /etc/*-release | grep -w "Oracle|Red Hat|CentOS|Fedora" | wc -l) > 0 )) +then +echo -e "-------------------------------Package Updates-------------------------------" +yum updateinfo summary | grep 'Security|Bugfix|Enhancement' +echo -e "-----------------------------------------------------------------------------" +else +echo -e "-------------------------------Package Updates-------------------------------" +cat /var/lib/update-notifier/updates-available +echo -e "-----------------------------------------------------------------------------" +fi +``` + +把上面脚本内容保存到一个文件 `system-info.sh`,之后添加可执行权限: + +``` +# chmod +x ~root/system-info.sh +``` + +当脚本准备好后,把脚本文件的路径加到 `.bash_profile` 文件末尾(红帽系列的系统:CentOS、Oracle Linux 和 Fedora): + +``` +# echo "/root/system-info.sh" >> ~root/.bash_profile +``` + +执行以下命令,来让修改的内容生效: + +``` +# source ~root/.bash_profile +``` + +对于 Debian 系统的系统,你可能需要把文件路径加到 `.profile` 文件中: + +``` +# echo "/root/system-info.sh" >> ~root/.profile +``` + +运行以下命令使修改生效: + +``` +# source ~root/.profile +``` + +你以前运行上面 `source` 命令时可能见过类似下面的输出。从下次开始,你在每次登录 shell 时会看到这些信息。当然,如果有必要你也可以随时手动执行这个脚本。 + +``` +-------------------------------System Information--------------------------- +Hostname: daygeek-Y700 +uptime: 1:20 1 +Manufacturer: LENOVO +Product Name: 80NV +Version: Lenovo ideapad Y700-15ISK +Serial Number: AA0CMRN1 +Machine Type: Physical +Operating System: Manjaro Linux +Kernel: 4.19.80-1-MANJARO +Architecture: x86_64 +Processor Name: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz +Active User: daygeek renu thanu +System Main IP: 192.168.1.6 192.168.122.1 + +-------------------------------CPU/Memory Usage------------------------------ +Memory Usage: 37.28% +Swap Usage: 0.00% +CPU Usage: 15.43% + +-------------------------------Disk Usage >80%------------------------------- +Filesystem Size Used Avail Use Mounted on +/dev/nvme0n1p1 217G 202G 4.6G 98 / +/dev/loop0 109M 109M 0 100 /var/lib/snapd/snap/odrive-unofficial/2 +/dev/loop1 91M 91M 0 100 /var/lib/snapd/snap/core/6405 +/dev/loop2 90M 90M 0 100 /var/lib/snapd/snap/core/7713 + +-------------------------------For WWN Details------------------------------- +CentOS8.2daygeek.com is a VM + +-------------------------------Oracle DB Instances--------------------------- +oracle user does not exist on CentOS8.2daygeek.com + +-------------------------------Package Updates------------------------------- + 13 Security notice(s) + 9 Important Security notice(s) + 3 Moderate Security notice(s) + 1 Low Security notice(s) + 35 Bugfix notice(s) + 1 Enhancement notice(s) +----------------------------------------------------------------------------- +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/bash-shell-script-view-linux-system-information/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/category/shell-script/ +[2]: https://www.2daygeek.com/category/bash-script/ +[3]: https://www.2daygeek.com/inxi-system-hardware-information-on-linux/ +[4]: https://www.2daygeek.com/dmidecode-get-print-display-check-linux-system-hardware-information/ +[5]: https://www.2daygeek.com/lshw-find-check-system-hardware-information-details-linux/ +[6]: https://www.2daygeek.com/hwinfo-check-display-detect-system-hardware-information-linux/ +[7]: https://www.2daygeek.com/python-hwinfo-check-display-system-hardware-configuration-information-linux/ +[8]: https://www.2daygeek.com/check-system-hardware-devices-bus-information-lspci-lsscsi-lsusb-lsblk-linux/ +[9]: https://www.2daygeek.com/how-to-check-system-hardware-manufacturer-model-and-serial-number-in-linux/ +[10]: https://www.2daygeek.com/how-to-find-wwn-wwnn-and-wwpn-number-of-hba-card-in-linux/ +[11]: https://www.2daygeek.com/how-to-check-hp-ilo-firmware-version-from-linux-command-line/ +[12]: https://www.2daygeek.com/linux-find-out-wireless-network-wifi-speed-signal-strength-quality/ +[13]: https://www.2daygeek.com/view-check-cpu-hard-disk-temperature-linux/ +[14]: https://www.2daygeek.com/hegemon-a-modular-system-and-hardware-monitoring-tool-for-linux/ +[15]: https://www.2daygeek.com/check-linux-hardware-information-system-configuration/ diff --git a/published/20191125 How to Install Ansible (Automation Tool) on CentOS 8-RHEL 8.md b/published/20191125 How to Install Ansible (Automation Tool) on CentOS 8-RHEL 8.md new file mode 100644 index 0000000000..9128c142b5 --- /dev/null +++ b/published/20191125 How to Install Ansible (Automation Tool) on CentOS 8-RHEL 8.md @@ -0,0 +1,200 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11633-1.html) +[#]: subject: (How to Install Ansible (Automation Tool) on CentOS 8/RHEL 8) +[#]: via: (https://www.linuxtechi.com/install-ansible-centos-8-rhel-8/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +如何在 CentOS 8/RHEL 8 上安装 Ansible(自动化工具) +====== + +Ansible 是给 Linux 系统管理员使用的出色自动化工具。它是一种开源配置工具,能让系统管理员可以从一个中心节点(即 Ansible 服务器)管理数百台服务器。将 Ansible 与 Puppet、Chef 和 Salt 等类似工具进行比较时,它是首选的配置工具,因为它不需要任何代理,并且可以工作在 SSH 和 python 上。 + +![](https://img.linux.net.cn/data/attachment/album/201912/01/223012czkxt6dhku6snhxn.jpg) + +在本教程中,我们将学习如何在 CentOS 8 和 RHEL 8 系统上安装和使用 Ansble。 + +Ansible 实验环境信息: + +* 最小化安装的 CentOS 8 / RHEL 8 服务器(192.168.1.10),且有互联网连接 +* 两个 Ansible 节点 - Ubuntu 18.04 LTS (192.168.1.20) 和 CentOS 7 (192.168.1.30) + +### CentOS 8 上的 Ansible 安装步骤 + +Ansible 包不在 CentOS 8 默认的软件包仓库中。因此,我们需要执行以下命令启用 [EPEL 仓库][3]: + +``` +[root@linuxtechi ~]$ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y +``` + +启用 epel 仓库后,执行以下 `dnf` 命令安装 Ansible: + +``` +[root@linuxtechi ~]$ sudo dnf install ansible +``` + +上面命令的输出: + +![dnf-install-ansible-centos8][4] + +成功安装 Ansible 后,运行以下命令验证它的版本: + +``` +[root@linuxtechi ~]$ sudo ansible --version +``` + +![Ansible-version-CentOS8][5] + +上面的输出确认在 CentOS 8 上安装完成。 + +让我们看下 RHEL 8 系统。 + +### RHEL 8 上的 Ansible 安装步骤 + +如果你有有效的 RHEL 8 订阅,请使用以下订阅管理器命令启用 Ansble 仓库: + +``` +[root@linuxtechi ~]$ sudo subscription-manager repos --enable ansible-2.8-for-rhel-8-x86_64-rpms +``` + +启用仓库后,执行以下 `dnf` 命令安装 Ansible: + +``` +[root@linuxtechi ~]$ sudo dnf install ansible -y +``` + +安装 Ansible 及其依赖包后,执行以下命令来验证它的版本: + +``` +[root@linuxtechi ~]$ sudo ansible --version +``` + +### 在 CentOS 8 / RHEL 8 上通过 pip3 安装 Ansible 的可选方法 + +如果你希望使用 `pip`(Python 的包管理器)安装 Ansible,请首先使用以下命令安装 pyhton3 和 python3-pip 包: + +``` +[root@linuxtechi ~]$ sudo dnf install python3 python3-pip -y +``` + +安装 python3 后,运行以下命令来验证它的版本: + +``` +[root@linuxtechi ~]$ python3 -V +Python 3.6.8 +[root@linuxtechi ~]$ +``` + +用下面的 `pip3` 命令安装 Ansible: + +``` +[root@linuxtechi ~]$ pip3 install ansible --user +``` + +输出: + +![Ansible-Install-pip3-centos8][6] + +上面的输出确认 Ansible 已成功使用 `pip3` 安装。让我们看下如何使用 Ansible。 + +### 如何使用 Ansible 自动化工具? + +当我们使用 `yum` 或 `dnf` 命令安装 Ansible 时,它的配置文件、清单文件和角色目录会自动在 `/etc/ansible` 文件夹下创建。 + +让我们添加一个名称为 `labservers` 的组,并在 `/etc/ansible/hosts` 文件中给该组添加上述的 Ubuntu 18.04 和 CentOS 7 系统的 IP 地址: + +``` +[root@linuxtechi ~]$ sudo vi /etc/ansible/hosts +… +[labservers] +192.168.1.20 +192.168.1.30 +… +``` + +保存并退出文件。 + +更新清单文件(`/etc/ansible/hosts`)后,将用户的 ssh 公钥放到属于 `labservers` 组的远程系统。 + +让我们首先使用 `ssh-keygen` 命令生成本地用户的公钥和私钥: + +``` +[root@linuxtechi ~]$ ssh-keygen +``` + +现在使用以下命令在 Ansible 服务器及其客户端之间交换公钥: + +``` +[root@linuxtechi ~]$ ssh-copy-id root@linuxtechi +[root@linuxtechi ~]$ ssh-copy-id root@linuxtechi +``` + +现在,让我们尝试几个 Ansible 命令,首先使用 `ping` 模块验证 Ansible 服务器与客户端的连接: + +``` +[root@linuxtechi ~]$ ansible -m ping "labservers" +``` + +注意: 如果我们没有在上面的命令中指定清单文件,那么它将引用默认主机文件(即 `/etc/ansible/hosts`)。 + +输出: + +![ansible-ping-module-centos8][7] + +让我们使用 Ansible shell 命令检查每个客户端的内核版本: + +``` +[root@linuxtechi ~]$ ansible -m command -a "uname -r" "labservers" +192.168.1.30 | CHANGED | rc=0 >> +4.15.0-20-generic +192.168.1.20 | CHANGED | rc=0 >> +3.10.0-327.el7.x86_64 +[root@linuxtechi ~]$ +``` + +使用以下命令列出清单文件中的所有主机: + +``` +[root@linuxtechi ~]$ ansible all -i /etc/ansible/hosts --list-hosts + hosts (4): + 192.168.100.1 + 192.168.100.10 + 192.168.1.20 + 192.168.1.30 +[root@linuxtechi ~]$ +``` + +使用以下 Ansible 命令仅列出 `labservers` 组中的主机: + +``` +root@linuxtechi ~]$ ansible labservers -i /etc/ansible/hosts --list-hosts + hosts (2): + 192.168.1.20 + 192.168.1.30 +[root@linuxtechi ~]$ +``` + +本文就是这些了,我们成功演示了如何在 CentOS 8 和 RHEL 8 系统中安装和使用 Ansible。请分享你的反馈和意见。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/install-ansible-centos-8-rhel-8/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: http://www.linuxtechi.com/wp-content/uploads/2019/11/Install-Ansible-CentOS8-RHEL8.png +[3]: http://www.linuxtechi.com/enable-epel-repo-centos8-rhel8-server/ +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/11/dnf-install-ansible-centos8-1536x652.png +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Ansible-version-CentOS8.png +[6]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Ansible-Install-pip3-centos8-1536x545.png +[7]: https://www.linuxtechi.com/wp-content/uploads/2019/11/ansible-ping-module-centos8.png diff --git a/published/20191125 How to use loops in awk.md b/published/20191125 How to use loops in awk.md new file mode 100644 index 0000000000..35c2b33d7a --- /dev/null +++ b/published/20191125 How to use loops in awk.md @@ -0,0 +1,153 @@ +[#]: collector: "lujun9972" +[#]: translator: "lxbwolf" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-11636-1.html" +[#]: subject: "How to use loops in awk" +[#]: via: "https://opensource.com/article/19/11/loops-awk" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" + +在 awk 中怎么使用循环 +====== + +> 来学习一下多次执行同一条命令的不同类型的循环。 + +![](https://img.linux.net.cn/data/attachment/album/201912/02/232951h3ibohlh77bk77d7.jpg) + +`awk` 脚本有三个主要部分:`BEGIN` 和 `END` 函数(都可选),用户自己写的每次要执行的函数。某种程度上,`awk` 的主体部分就是一个循环,因为函数中的命令对每一条记录都会执行一次。然而,有时你希望对于一条记录执行多次命令,那么你就需要用到循环。 + +有多种类型的循环,分别适合不同的场景。 + +### while 循环 + +一个 `while` 循环检测一个表达式,如果表达式为 `true` 就执行命令。当表达式变为 `false` 时,循环中断。 + +``` +#!/bin/awk -f + +BEGIN { + # Loop through 1 to 10 + + i=1; + while (i <= 10) { + print i, " to the second power is ", i*i; + i = i+1; + } +exit; +} +``` + +在这个简单实例中,`awk` 打印了放在变量 `i` 中的整数值的平方。`while (i <= 10)` 语句告诉 `awk` 仅在 `i` 的值小于或等于 10 时才执行循环。在循环最后一次执行时(`i` 的值是 10),循环终止。 + +### do-while 循环 + +do-while 循环执行在关键字 `do` 之后的命令。在每次循环结束时检测一个测试表达式来决定是否终止循环。仅在测试表达式返回 `true` 时才会重复执行命令(即还没有到终止循环的条件)。如果测试表达式返回 `false`,因为到了终止循环的条件所以循环被终止。 + +``` +#!/usr/bin/awk -f +BEGIN { + + i=2; + do { + print i, " to the second power is ", i*i; + i = i + 1 + } + while (i < 10) + +exit; +} +``` + +### for 循环 + +`awk` 中有两种 `for` 循环。 + +一种 `for` 循环初始化一个变量,检测一个测试表达式,执行变量递增,当表达式的结果为 `true` 时循环就会一直执行。 + +``` +#!/bin/awk -f + +BEGIN { + for (i=1; i <= 10; i++) { + print i, " to the second power is ", i*i; + } +exit; +} +``` + +另一种 `for` 循环设置一个有连续索引的数组变量,对每一个索引执行一个命令集。换句话说,它用一个数组“收集”每一条命令执行后的结果。 + +本例实现了一个简易版的 Unix 命令 `uniq`。通过把一系列字符串作为键加到数组 `a` 中,当相同的键再次出现时就增加键值,可以得到某个字符串出现的次数(就像 `uniq` 的 `--count` 选项)。如果你打印该数组的所有键,将会得到出现过的所有字符串。 + +用演示文件 `colours.txt`(前一篇文章中的文件)来举例: + +``` +name       color  amount +apple      red    4 +banana     yellow 6 +raspberry  red    99 +strawberry red    3 +grape      purple 10 +apple      green  8 +plum       purple 2 +kiwi       brown  4 +potato     brown  9 +pineapple  yellow 5 +``` + +这是 `awk` 版的简易 `uniq -c`: + +``` +#! /usr/bin/awk -f + +NR != 1 { +    a[$2]++ +} +END { +    for (key in a) { +                print a[key] " " key +    } +} +``` + +示例数据文件的第三列是第一列列出的条目的计数。你可以用一个数组和 `for` 循环来按颜色统计第三列的条目。 + +``` +#! /usr/bin/awk -f + +BEGIN { +    FS=" "; +    OFS="\t"; +    print("color\tsum"); +} +NR != 1 { +    a[$2]+=$3; +} +END { +    for (b in a) { +        print b, a[b] +    } +} +``` + +你可以看到,在处理文件之前也需要在 `BEFORE` 函数(仅仅执行一次)中打印一列表头。 + +### 循环 + +在任何编程语言中循环都是很重要的一部分,`awk` 也不例外。使用循环你可以控制 `awk` 脚本怎样去运行,它可以统计什么信息,还有它怎么去处理你的数据。我们下一篇文章会讨论 `switch`、`continue` 和 `next` 语句。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/loops-awk + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fail_progress_cycle_momentum_arrow.png?itok=q-ZFa_Eh "arrows cycle symbol for failing faster" +[2]: http://hackerpublicradio.org/eps.php?id=2330 diff --git a/published/20191125 The many faces of awk.md b/published/20191125 The many faces of awk.md new file mode 100644 index 0000000000..53ac02c910 --- /dev/null +++ b/published/20191125 The many faces of awk.md @@ -0,0 +1,225 @@ +[#]: collector: (lujun9972) +[#]: translator: (luuming) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11658-1.html) +[#]: subject: (The many faces of awk) +[#]: via: (https://www.networkworld.com/article/3454979/the-many-faces-of-awk.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +千面 awk +====== + +> `awk` 命令不仅提供了简单的输入字符串筛选功能,还包含提取数据列、打印简单文本、筛选内容——甚至做一些数学计算。 + +![Thinkstock][6] + +如果你仅使用 `awk` 选取一行中的特定文本,那么你可能错过了它的很多功能。在这篇文章中,我们会来看看使用 `awk` 可以帮你做一些其他的什么事情,并提供一些例子。 + +### 提取数据列 + +`awk` 所提供的最简单与最常用的功能便是从文件或管道传输的数据中选取特定的内容。默认使用空格当做分隔符,这非常简单。 + +``` +$ echo one two three four five | awk ‘{print $4}’ +four +$ who | awk ‘{print $1}’ +jdoe +fhenry +``` + +空格指的是一系列的 `space` 或 `tab` 字符。在下面所展示的命令里,`awk` 从提供的数据中筛选第一和第四项。 + +`awk` 命令也可以通过在其后增加文件名参数的方式从文本文件中获取数据。 + +``` +$ awk '{print $1,$5,$NF}' HelenKellerQuote +The beautiful heart. +``` + +(LCTT 译注:“The best and most beautiful things in the world can not be seen or even touched , they must be felt with heart.” ——海伦凯勒) + +在这个例子中,`awk` 挑选了一行中的第一个、第五个和最后一个字段。 + +命令中的 `$NF` 指定选取每行的最后一个字段。这是因为 `NF` 代表一行中的字段数量Number of Field,也就是 23,而 `$NF` 就代表着那个字段的值,也就是`heart`。最后的句号也包含进去了,因为它是最后一个字符串的一部分。 + +字段能以任何有用的形式打印。在这个例子中,我们将字段以日期的格式进行打印输出。 + +``` +$ date | awk '{print $4,$3,$2}' +2019 Nov 22 +``` + +如果你省略了 `awk` 命令中字段指示符之间的逗号,输出将会挤成一个字符串。 + +``` +$ date | awk '{print $4 $3 $2}' +2019Nov21 +``` + +如果你将通常使用的逗号替换为连字符,`awk` 就会尝试将两个字段的值相减——或许这并不是你想要的。它不会将连字符插入到输出结果中。相反地,它对输出做了一些数学计算。 + +``` +$ date | awk '{print $4-$3-$2}' +1997 +``` + +在这个例子中,它将年 “2019” 和日期 “22” 相减,并忽略了中间的 “Nov”。 + +如果你想要空格之外的字符作为输出分隔符,你可以通过 `OFS`(输出分隔符output field separator)指定分隔符,就像这样: + +``` +$ date | awk '{OFS="-"; print $4,$3,$2}' +2019-Nov-22 +``` + +### 打印简单文本 + +你也可以使用 `awk` 简单地显示一些文本。当然了,比起 `awk` 你可能更想使用 `echo` 命令。但换句话说,作为 `awk` 脚本的一部分,打印某些相关性文本将会非常实用。这里有一个没什么用的例子: + +``` +$ awk 'BEGIN {print "Hello, World" }' +Hello, World +``` + +下面的例子更加合理,添加一行文本标签来更好的辨识数据。 + +``` +$ who | awk 'BEGIN {print "Current logins:"} {print $1}' +Current logins: +shs +nemo +``` + +### 指定字段分隔符 + +不是所有的输入都以空格作为分隔符的。如果你的文本通过其它的字符作为分隔符(例如:逗号、冒号、分号),你可以通过 `-F` 选项(输入分隔符)告诉 `awk`: + +``` +$ cat testfile +a:b:c,d:e +$ awk -F : '{print $2,$3}' testfile +b c,d +``` + +下面是一个更加有用的例子——从冒号分隔的 `/etc/passwd` 文件中获取数据: + +``` +$ awk -F: '{print $1}' /etc/passwd | head -11 +root +daemon +bin +sys +sync +games +man +lp +mail +news +uucp +``` + +### 筛选内容 + +你也可以使用 `awk` 命令评估字段。例如你仅仅想列出 `/etc/passwd` 中的用户账号,就可以对第三个字段做一些筛选。下面的例子中我们只关注大于等于 1000 的 UID: + +``` +$ awk -F":" ' $3 >= 1000 ' /etc/passwd +nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin +shs:x:1000:1000:Sandra Henry-Stocker,,,:/home/shs:/bin/bash +nemo:x:1001:1001:Nemo,,,:/home/nemo:/usr/bin/zsh +dory:x:1002:1002:Dory,,,:/home/dory:/bin/bash +... +``` + +如果你想为输出增加标题,可以添加 `BEGIN` 从句: + +``` +$ awk -F":" 'BEGIN {print "user accounts:"} $3 >= 1000 ' /etc/passwd +user accounts: +nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin +shs:x:1000:1000:Sandra Henry-Stocker,,,:/home/shs:/bin/bash +nemo:x:1001:1001:Nemo,,,:/home/nemo:/usr/bin/zsh +dory:x:1002:1002:Dory,,,:/home/dory:/bin/bash +``` + +如果你想要不止一行的标题,你可以通过 `"\n"` 分隔输出: + +``` +$ awk -F":" 'BEGIN {print "user accounts\n============="} $3 >= 1000 ' /etc/passwd +user accounts +============= +nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin +shs:x:1000:1000:Sandra Henry-Stocker,,,:/home/shs:/bin/bash +nemo:x:1001:1001:Nemo,,,:/home/nemo:/usr/bin/zsh +dory:x:1002:1002:Dory,,,:/home/dory:/bin/bash +``` + +### 在 awk 中进行数学计算 + +`awk` 提供了惊人的数学计算能力,并且可以开平方,算 `log`,算 `tan` 等等。 + +这里有一对例子: + +``` +$ awk 'BEGIN {print sqrt(2019)}' +44.9333 +$ awk 'BEGIN {print log(2019)}' +7.61036 +``` + +想要详细了解 `awk` 的数学计算能力,可以看《[使用 awk 进行数学计算][3]》这篇文章。 + +### awk 脚本 + +你也可以使用 `awk` 写一套单独的脚本。下面的例子模仿了之前写过的一个,不过还计算了系统里账户的数量。 + +``` +#!/usr/bin/awk -f + +# 这一行是注释 + +BEGIN { + printf "%s\n","User accounts:" + print "==============" + FS=":" + n=0 +} + +# 现在开始遍历数据 +{ + if ($3 >= 1000) { + print $1 + n ++ + } +} + +END { + print "==============" + print n " accounts" +} +``` + +注意 `BEGIN` 那一节是如何提供标题、指定字段分隔符和初始化计数器的,它仅在脚本初始化时期执行。这个脚本也包含 `END` 节,它仅在中间所有命令处理完成之后运行,显示了所有中间小节所筛选数据的最终行数(第三个字段大于等于 1000)。 + +作为一个长存于 Unix 之上的命令,`awk` 依旧提供着非常有用的服务,这也是我几十年前爱上 Unix 的原因之一。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3454979/the-many-faces-of-awk.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[LuuMing](https://github.com/LuuMing) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.networkworld.com/article/2974753/doing-math-with-awk.html +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world +[6]:https://images.techhive.com/images/article/2015/09/thinkstockphotos-512100549-100611755-large.jpg diff --git a/published/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md b/published/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md new file mode 100644 index 0000000000..eb23278dc6 --- /dev/null +++ b/published/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md @@ -0,0 +1,259 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11637-1.html) +[#]: subject: (5 Commands to Find the IP Address of a Domain in the Linux Terminal) +[#]: via: (https://www.2daygeek.com/linux-command-find-check-domain-ip-address/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +5 个用于在 Linux 终端中查找域名 IP 地址的命令 +====== + +![](https://img.linux.net.cn/data/attachment/album/201912/03/000402c0ekkgku1f011kzt.jpg) + +本教程介绍了如何在 Linux 终端验证域名或计算机名的 IP 地址。本教程将允许你一次检查多个域。你可能已经使用过这些命令来验证信息。但是,我们将教你如何有效使用这些命令在 Linux 终端中识别多个域的 IP 地址信息。 + +可以使用以下 5 个命令来完成此操作。 + +* `dig` 命令:它是一个用于查询 DNS 名称服务器的灵活命令行工具。 +* `host` 命令:它是用于执行 DNS 查询的简单程序。 +* `nslookup` 命令:它用于查询互联网域名服务器。 +* `fping` 命令:它用于向网络主机发送 ICMP ECHO_REQUEST 数据包。 +* `ping` 命令:它用于向网络主机发送 ICMP ECHO_REQUEST 数据包。 + +为了测试,我们创建了一个名为 `domains-list.txt` 的文件,并添加了以下域。 + +``` +# vi /opt/scripts/domains-list.txt + +2daygeek.com +magesh.co.in +linuxtechnews.com +``` + +### 方法 1:如何使用 dig 命令查找域的 IP 地址 + +[dig 命令][1]代表 “域名信息抓手Domain Information Groper”,它是一个功能强大且灵活的命令行工具,用于查询 DNS 名称服务器。 + +它执行 DNS 查询,并显示来自查询的名称服务器的返回信息。大多数 DNS 管理员使用 `dig` 命令来解决 DNS 问题,因为它灵活、易用且输出清晰。 + +它还有批处理模式,可以从文件读取搜索请求。 + +``` +# dig 2daygeek.com | awk '{print $1,$5}' + +2daygeek.com. 104.27.157.177 +2daygeek.com. 104.27.156.177 +``` + +使用以下 bash 脚本查找多个域的 IP 地址。 + +``` +# vi /opt/scripts/dig-command.sh + +#!/bin/bash +for server in `cat /opt/scripts/domains-list.txt` +do echo $server "-" +dig $server +short +done | paste -d " " - - - +``` + +添加以上内容到脚本后,给 `dig-command.sh` 文件设置可执行权限。 + +``` +# chmod +x /opt/scripts/dig-command.sh +``` + +最后运行 bash 脚本获得输出。 + +``` +# sh /opt/scripts/dig-command.sh + +2daygeek.com - 104.27.156.177 104.27.157.177 +magesh.co.in - 104.18.35.52 104.18.34.52 +linuxtechnews.com - 104.27.144.3 104.27.145.3 +``` + +如果要在一行中运行上面的脚本,请使用以下脚本。 + +``` +# for server in 2daygeek.com magesh.co.in linuxtechnews.com; do echo $server "-"; dig $server +short; done | paste -d " " - - - +``` + +或者,你可以使用以下 Shell 脚本查找多个域的 IP 地址。 + +``` +# for server in 2daygeek.com magesh.co.in linuxtechnews.com; do dig $server | awk '{print $1,$5}'; done + +2daygeek.com. 104.27.157.177 +2daygeek.com. 104.27.156.177 +magesh.co.in. 104.18.34.52 +magesh.co.in. 104.18.35.52 +linuxtechnews.com. 104.27.144.3 +linuxtechnews.com. 104.27.145.3 +``` + +### 方法 2:如何使用 host 命令查找域的 IP 地址 + +[host 命令][2]是一个简单的命令行程序,用于执行 [DNS 查询][3]。它通常用于将名称转换为 IP 地址,反之亦然。如果未提供任何参数或选项,`host` 将打印它的命令行参数和选项摘要。 + +你可以在 `host` 命令中添加特定选项或记录类型来查看域中的所有记录类型。 + +``` +# host 2daygeek.com | grep "has address" | sed 's/has address/-/g' + +2daygeek.com - 104.27.157.177 +2daygeek.com - 104.27.156.177 +``` + +使用以下 bash 脚本查找多个域的 IP 地址。 + +``` +# vi /opt/scripts/host-command.sh + +for server in `cat /opt/scripts/domains-list.txt` +do host $server | grep "has address" | sed 's/has address/-/g' +done +``` + +添加以上内容到脚本后,给 `host-command.sh` 文件设置可执行权限。 + +``` +# chmod +x /opt/scripts/host-command.sh +``` + +最后运行 bash 脚本获得输出。 + +``` +# sh /opt/scripts/host-command.sh + +2daygeek.com - 104.27.156.177 +2daygeek.com - 104.27.157.177 +magesh.co.in - 104.18.35.52 +magesh.co.in - 104.18.34.52 +linuxtechnews.com - 104.27.144.3 +linuxtechnews.com - 104.27.145.3 +``` + +### 方法 3:如何使用 nslookup 命令查找域的 IP 地址 + +[nslookup 命令][4]是用于查询互联网[域名服务器(DNS)] [5]的程序。 + +`nslookup` 有两种模式,分别是交互式和非交互式。交互模式允许用户查询名称服务器以获取有关各种主机和域的信息,或打印域中的主机列表。非交互模式用于仅打印主机或域的名称和请求的信息。 + +它是一个网络管理工具,可以帮助诊断和解决 DNS 相关问题。 + +``` +# nslookup -q=A 2daygeek.com | tail -n+4 | sed -e '/^$/d' -e 's/Address://g' | grep -v 'Name|answer' | xargs -n1 + +104.27.157.177 +104.27.156.177 +``` + +使用以下 bash 脚本查找多个域的 IP 地址。 + +``` +# vi /opt/scripts/nslookup-command.sh + +#!/bin/bash +for server in `cat /opt/scripts/domains-list.txt` +do echo $server "-" +nslookup -q=A $server | tail -n+4 | sed -e '/^$/d' -e 's/Address://g' | grep -v 'Name|answer' | xargs -n1 done | paste -d " " - - - +``` + +添加以上内容到脚本后,给 `nslookup-command.sh` 文件设置可执行权限。 + +``` +# chmod +x /opt/scripts/nslookup-command.sh +``` + +最后运行 bash 脚本获得输出。 + +``` +# sh /opt/scripts/nslookup-command.sh + +2daygeek.com - 104.27.156.177 104.27.157.177 +magesh.co.in - 104.18.35.52 104.18.34.52 +linuxtechnews.com - 104.27.144.3 104.27.145.3 +``` + +### 方法 4:如何使用 fping 命令查找域的 IP 地址 + +[fping 命令][6]是类似 `ping` 之类的程序,它使用互联网控制消息协议(ICMP)echo 请求来确定目标主机是否响应。 + +`fping` 与 `ping` 不同,因为它允许用户并行 ping 任意数量的主机。另外,它可以从文本文件输入主机。 + +`fping` 发送 ICMP echo 请求,并以循环方式移到下一个目标,并且不等到目标主机做出响应。 + +如果目标主机答复,那么将其标记为活动主机并从要检查的目标列表中删除;如果目标在特定时间限制和/或重试限制内未响应,那么将其指定为不可访问。 + +``` +# fping -A -d 2daygeek.com magesh.co.in linuxtechnews.com + +104.27.157.177 (104.27.157.177) is alive +104.18.35.52 (104.18.35.52) is alive +104.27.144.3 (104.27.144.3) is alive +``` + +### 方法 5:如何使用 ping 命令查找域的 IP 地址 + +[ping 命令][6](数据包互联网抓手Packet Internet Groper)是一个网络程序,用于测试 Internet 协议(IP)网络上主机的可用性/连接性。 + +通过向目标主机发送互联网控制消息协议(ICMP)Echo 请求数据包并等待 ICMP Echo 应答来验证主机的可用性。 + +它基于发送的数据包、接收的数据包、丢失的数据包,通常包含最小/平均/最大时间来汇总统计结果。 + +``` +# ping -c 2 2daygeek.com | head -2 | tail -1 | awk '{print $5}' | sed 's/[(:)]//g' + +104.27.157.177 +``` + +使用以下 bash 脚本查找多个域的 IP 地址。 + +``` +# vi /opt/scripts/ping-command.sh + +#!/bin/bash +for server in `cat /opt/scripts/domains-list.txt` +do echo $server "-" +ping -c 2 $server | head -2 | tail -1 | awk '{print $5}' | sed 's/[(:)]//g' +done | paste -d " " - - +``` + +添加以上内容到脚本后,给 `ping-command.sh` 文件设置可执行权限。 + +``` +# chmod +x /opt/scripts/ping-command.sh +``` + +最后运行 bash 脚本获得输出。 + +``` +# sh /opt/scripts/ping-command.sh + +2daygeek.com - 104.27.156.177 +magesh.co.in - 104.18.35.52 +linuxtechnews.com - 104.27.144.3 +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-command-find-check-domain-ip-address/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/dig-command-check-find-dns-records-lookup-linux/ +[2]: https://www.2daygeek.com/linux-host-command-check-find-dns-records-lookup/ +[3]: https://www.2daygeek.com/category/dns-lookup/ +[4]: https://www.2daygeek.com/nslookup-command-check-find-dns-records-lookup-linux/ +[5]: https://www.2daygeek.com/check-find-dns-records-of-domain-in-linux-terminal/ +[6]: https://www.2daygeek.com/how-to-use-ping-fping-gping-in-linux/ diff --git a/published/20191127 Nvidia quietly unveils faster, lower power Tesla GPU accelerator.md b/published/20191127 Nvidia quietly unveils faster, lower power Tesla GPU accelerator.md new file mode 100644 index 0000000000..cbb4c747d1 --- /dev/null +++ b/published/20191127 Nvidia quietly unveils faster, lower power Tesla GPU accelerator.md @@ -0,0 +1,54 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11640-1.html) +[#]: subject: (Nvidia quietly unveils faster, lower power Tesla GPU accelerator) +[#]: via: (https://www.networkworld.com/article/3482097/nvidia-quietly-unveils-faster-lower-power-tesla-gpu-accelerator.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Nvidia 悄悄推出更快、更低功耗的 Tesla GPU 加速器 +====== + +> Nvidia 升级了其 Volta 系列的 Tesla GPU 加速卡,使其能够以旧型号的相同功率更快地工作。 + +![](https://images.idgesg.net/images/article/2019/01/nvidia_logo-2-100785663-large.jpg) + +Nvidia 上周举行了 Supercomputing 19 大会,不出意外的是公布了很多新闻,这些我们将稍后提到。但被忽略的一条或许是其中最有趣的:一张更快、功耗更低的新一代图形加速卡。 + +多名与会者与多个新闻站点发现了这点,Nvidia 向我证实这确实是一张新卡。Nvidia 的 “Volta” 这代 Tesla GPU 加速卡在 2017 年就已淘汰,因此升级工作应该早已过期。 + +V100S 目前仅提供 PCI Express 3 接口,但有望最终支持 Nvidia 的 SXM2 接口。SXM 是 Nvidia 的双插槽卡设计,与 PCIe 卡不同,它不需要连接电源。SXM2 允许 GPU 通过 Nvidia 的 NVLink(一种高带宽、节能的互连)相互之间或与 CPU 进行通信,其数据传输速度比 PCIe 快十倍。 + +借助此卡,Nvidia 声称拥有单精度 16.4 TFLOPS,双精度 8.2 TFLOPS 并且 Tensor Core 性能高达 130 TFLOPS。这仅比 V100 SXM2 设计提高了 4% 至 5%,但比 PCIe V100 变体提高了 16% 至 17%。 + +内存容量保持在 32 GB,但 Nvidia 添加了 High Bandwidth Memory 2(HBM2),以将内存性能提高到 1,134 GB/s,这比 PCIe 和 SXM2 都提高了 26%。 + +通常情况下,性能提升将同时导致功率增加,但在这里,PCIe 卡的总体功率为 250 瓦,与上一代 PCIe 卡相同。因此,在相同功耗下,该卡可额外提供 16-17% 的计算性能,并增加 26% 的内存带宽。 + +### 其他新闻 + +Nvidia 在会上还发布了其他新闻: + +* 其 GPU 加速的基于 Arm 的高性能计算参考服务器的新参考设计和生态系统支持。该公司表示,它得到了 HPE/Cray、Marvell、富士通和 Ampere 的支持,Ampere 是 Intel 前高管勒尼·詹姆斯(Renee James)领导的一家初创公司,它希望建立基于 Arm 的服务器处理器。 +* 这些公司将使用 Nvidia 的参考设计(包括硬件和软件组件)来使用 GPU 构建从超大规模云提供商到高性能存储和百亿亿次超级计算等。该设计还带来了 CUDA-X,这是 Nvidia 用于 Arm 处理器的 CUDA GPU 的特殊版本开发语言。 +* 推出 Nvidia Magnum IO 套件,旨在帮助数据科学家和 AI 以及高性能计算研究人员在几分钟而不是几小时内处理大量数据。它经过优化,消除了存储和 I/O 瓶颈,可为多服务器、多 GPU 计算节点提供高达 20 倍的数据处理速度。 +* Nvidia 和 DDN (AI 以及多云数据管理开发商)宣布将 DDN 的 A3ITM 数据管理系统与 Nvidia 的 DGX SuperPOD 系统捆绑在一起,以便客户能够以最小的复杂性和更短的时限部署 HPC 基础架构。SuperPOD 还带有新的 NVIDIA Magnum IO 软件栈。 +* DDN 表示,SuperPOD 能够在数小时内部署,并且单个设备可扩展至 80 个节点。不同的深度学习模型的基准测试表明,DDN 系统可以使 DGXSuperPOD 系统完全保持数据饱和。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3482097/nvidia-quietly-unveils-faster-lower-power-tesla-gpu-accelerator.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/20191129 A quick introduction to Toolbox on Fedora.md b/published/20191129 A quick introduction to Toolbox on Fedora.md new file mode 100644 index 0000000000..bfcad3cc06 --- /dev/null +++ b/published/20191129 A quick introduction to Toolbox on Fedora.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11651-1.html) +[#]: subject: (A quick introduction to Toolbox on Fedora) +[#]: via: (https://fedoramagazine.org/a-quick-introduction-to-toolbox-on-fedora/) +[#]: author: (Ryan Walter https://fedoramagazine.org/author/rwaltr/) + +Fedora 中的 Toolbox 简介 +====== + +![][1] + +Toolbox 使你可以[在容器中分类和管理开发环境][2],而无需 root 权限或手动添加卷。它创建一个容器,你可以在其中安装自己的命令行工具,而无需在基础系统中安装它们。当你没有 root 权限或无法直接安装程序时,也可以使用它。本文会介绍 Toolbox 及其功能。 + +### 安装 Toolbox + +[Silverblue][3] 默认包含 Toolbox。对于 Workstation 和 Server 版本,你可以使用 `dnf install toolbox` 从默认仓库中获取它。 + +### 创建 Toolbox + +打开终端并运行 `toolbox enter`。程序将自动请求许可来下载最新的镜像,创建第一个容器并将你的 shell 放在该容器中。 + +``` +$ toolbox enter +No toolbox containers found. Create now? [y/N] y +Image required to create toolbox container. +Download registry.fedoraproject.org/f30/fedora-toolbox:30 (500MB)? [y/N]: y +``` + +当前,Toolbox 和你的基本系统之间没有区别。你的文件系统和软件包未曾改变。下面是一个使用仓库的示例,它包含 `~/src/resume` 文件夹下的简历的文档源文件。简历是使用 `pandoc` 工具构建的。 + +``` +$ pwd +/home/rwaltr +$ cd src/resume/ +$ head -n 5 Makefile +all: pdf html rtf text docx + +pdf: init + pandoc -s -o BUILDS/resume.pdf markdown/* + +$ make pdf +bash: make: command not found +$ pandoc -v +bash: pandoc: command not found +``` + +这个 toolbox 没有构建简历所需的程序。你可以通过使用 `dnf` 安装工具来解决此问题。由于正在容器中运行,因此不会提示你输入 root 密码。 + +``` +$ sudo dnf groupinstall "Authoring and Publishing" -y && sudo dnf install pandoc make -y +... +$ make all #Successful builds +mkdir -p BUILDS +pandoc -s -o BUILDS/resume.pdf markdown/* +pandoc -s -o BUILDS/resume.html markdown/* +pandoc -s -o BUILDS/resume.rtf markdown/* +pandoc -s -o BUILDS/resume.txt markdown/* +pandoc -s -o BUILDS/resume.docx markdown/* +$ ls BUILDS/ +resume.docx resume.html resume.pdf resume.rtf resume.txt +``` + +运行 `exit` 可以退出 toolbox。 + +``` +$ cd BUILDS/ +$ pandoc --version || ls +pandoc 2.2.1 +Compiled with pandoc-types 1.17.5.4, texmath 0.11.1.2, skylighting 0.7.5 +... +for a particular purpose. +resume.docx resume.html resume.pdf resume.rtf resume.txt +$ exit +logout +$ pandoc --version || ls +bash: pandoc: command not found... +resume.docx resume.html resume.pdf resume.rtf resume.txt +``` + +你会在主目录中得到由 toolbox 创建的文件。而在 toolbox 中安装的程序无法在外部访问。 + +### 提示和技巧 + +本介绍仅涉及 toolbox 的表面。还有一些其他提示,但是你也可以查看[官方文档][2]。 + +* `toolbox –help` 会显示 Toolbox 的手册页。 +* 你可以一次有多个 toolbox。使用 `toolbox create -c Toolboxname` 和 `toolbox enter -c Toolboxname`。 +* Toolbox 使用 [Podman][4] 来完成繁重的工作。使用 `toolbox list` 可以查找 Toolbox 创建的容器的 ID。Podman 可以使用这些 ID 来执行 `rm` 和 `stop` 之类的操作。 (你也可以在[此文章][5]中阅读有关 Podman 的更多信息。) + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/a-quick-introduction-to-toolbox-on-fedora/ + +作者:[Ryan Walter][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/rwaltr/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/11/toolbox-816x345.jpg +[2]: https://docs.fedoraproject.org/en-US/fedora-silverblue/toolbox/ +[3]: https://fedoramagazine.org/what-is-silverblue/ +[4]: https://podman.io/ +[5]: https://fedoramagazine.org/running-containers-with-podman/ +[6]: https://flickr.com/photos/florianric/ +[7]: https://flickr.com/photos/florianric/7263382550/ diff --git a/published/20191202 Use the Window Maker desktop on Linux.md b/published/20191202 Use the Window Maker desktop on Linux.md new file mode 100644 index 0000000000..d3225b5a59 --- /dev/null +++ b/published/20191202 Use the Window Maker desktop on Linux.md @@ -0,0 +1,63 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11650-1.html) +[#]: subject: (Use the Window Maker desktop on Linux) +[#]: via: (https://opensource.com/article/19/12/linux-window-maker-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +在 Linux 上使用 Window Maker 桌面 +====== +> 本文是 24 天 Linux 桌面特别系列的一部分。让我们和 Window Maker 一起时光倒流,它为如今的用户实现了老式 Unix NeXTSTEP 环境。 + +![Penguin with green background][1] + +在 Mac OS X 之前,有一个奇怪的闭源 Unix 系统,称为 [NeXTSTEP][2]。Sun Microsystems 后来将 NeXTSTEP 的底层设为开放规范,这使其它项目可以创建许多自由开源的 NeXT 库和组件。GNUStep 实现了许多 NeXTSTEP 库,而 [Window Maker][3] 实现了其桌面环境。 + +Window Maker 非常接近地模仿了 NeXTSTEP 桌面 GUI,并提供了一个有趣的视角,可以让人了解 80 年代末 90 年代初的 Unix 是什么样子的。它还揭示了窗口管理器(例如 Fluxbox 和 Openbox)背后的一些基本概念。 + +你可以从发行版的仓库中安装 Window Maker。要尝试它,请在安装完成后退出桌面会话。默认情况下,会话管理器(KDM、GDM、LightDM 或 XDM,这取决于你的设置)将继续将登录到默认桌面,因此登录时必须覆盖默认设置。 + +要在 GDM 上切换到 Window Maker: + +![Selecting the Window Maker desktop in GDM][4] + +在 KDM 上: + +![Selecting the Window Maker desktop in KDM][5] + +### Window Maker 程序坞 + +默认情况下,Window Maker 桌面是空的,但每个角落都有几个*程序坞*。像在 NeXTSTEP 中一样,在 Window Maker 中,在程序坞区域,应用可最小化成图标后停靠,可创建启动器来快速访问常见应用,并且可运行微型的 “dockapp”。 + +你可以在软件仓库中搜索 “dockapp” 来试用 dockapp。它们常常是网络和系统监控器、音频设置面板、时钟等。这是在 Fedora 上运行的 Window Maker: + +![Window Maker running on Fedora][6] + +### 应用菜单 + +要访问应用菜单,请右键单击桌面上的任意位置。要关闭它,请再次单击鼠标右键。Window Maker 不是桌面环境(DE),而是一个窗口管理器(DM)。它可以帮助你安排和管理窗口。它唯一捆绑的程序是 [WPrefs][7](或更常见的说法 Window Maker 偏好),它可帮助你配置常用设置,而应用菜单则提供对其他选项(包括主题)的访问。 + +运行什么应用完全由你决定。在 Window Maker 中,你可以选择运行 KDE 应用、GNOME 应用以及不被视为任何其他主流桌面应用的程序。你可以创建自己的工作环境,并且可以使用 Window Maker 对其进行管理。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/linux-window-maker-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux_penguin_green.png?itok=ENdVzW22 (Penguin with green background) +[2]: https://en.wikipedia.org/wiki/NeXTSTEP +[3]: https://www.windowmaker.org/ +[4]: https://opensource.com/sites/default/files/uploads/advent-windowmaker-gdm.jpg (Selecting the Window Maker desktop in GDM) +[5]: https://opensource.com/sites/default/files/uploads/advent-windowmaker-kdm.jpg (Selecting the Window Maker desktop in KDM) +[6]: https://opensource.com/sites/default/files/uploads/advent-windowmaker.jpg (Window Maker running on Fedora) +[7]: http://www.windowmaker.org/docs/guidedtour/prefs.html diff --git a/published/20191203 An idiot-s guide to Kubernetes, low-code developers, and other industry trends.md b/published/20191203 An idiot-s guide to Kubernetes, low-code developers, and other industry trends.md new file mode 100644 index 0000000000..6e13e0dbfd --- /dev/null +++ b/published/20191203 An idiot-s guide to Kubernetes, low-code developers, and other industry trends.md @@ -0,0 +1,72 @@ +[#]: collector: (lujun9972) +[#]: translator: (algzjh) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11681-1.html) +[#]: subject: (An idiot's guide to Kubernetes, low-code developers, and other industry trends) +[#]: via: (https://opensource.com/article/19/12/technology-advice-and-other-industry-trends) +[#]: author: (Tim Hildred https://opensource.com/users/thildred) + +每周开源点评:Kubernetes 傻瓜指南、低代码开发人员和其他行业趋势 +====== +> 每周开源社区、市场和行业趋势。 + +![Person standing in front of a giant computer screen with numbers, data][1] + +作为我在具有开源开发模型的企业软件公司担任高级产品营销经理的角色的一部分,我为产品营销人员、经理和其他影响者定期发布有关开源社区,市场和行业趋势的定期更新。这里有该更新中我和他们最喜欢的四篇文章。 + +### Kubernetes 傻瓜指南 + +- [文章链接][2] + +> Kubernetes 已经发展出了新的特性,这使其成为企业软件的更好的容器平台。安全性和高级网络等元素已被纳入 Kubernetes 上游代码的主体,并且现在可供所有人使用。 +> +> 然而,企业解决方案的其他方面总会有补充需求;比如日志记录和性能监控。这就是像 Istio 等辅助包发挥作用的地方,它带来了额外的功能,但是仍使 Kubernetes 的核心保持了合理的大小和特性集。 + +**影响**: 我总是发现,人们很容易把对技术发展的认识视为理所当然。当与你打交道的每个人都处于“最前沿”时,你的观点就会歪曲到这样的程度:你甚至可能会认为对最新的(*此处插入首选技术*)一无所知的人跟不上潮流,而实际上这并没有开始影响他们做自己需要做的事情的能力。那些人不是白痴;他们是我们的朋友、客户、合作伙伴、合作者和社区。 + +### Gartner: 采用低代码开发之前应该考虑什么 + +- [文章链接][3] + +> 尽管专注于商业 IT 团队,但 Gartner 发现,一个日益重要的开发人员社区是需要快速开发简单应用程序或构建最低可行产品或多体验功能的核心 IT 专业开发人员。当应用程序领导者在传统的应用程序项目中使用低代码时,他们可能希望使用标准的 IT DevOps 自动化方法和低代码工具。 + +**影响**: 越来越多的用例和用户体验可以通过需要更少时间和技能来创建的应用程序来处理和交互。而低代码开发人员也可能会结合成一个具有他们自己的规范和亚文化的独特群体。 + +### 诺基亚认为云原生对 5G 核心至关重要 + +- [文章链接][4] + +> 诺基亚概述了 5G 的五个关键业务目标,这些目标只能通过云原生环境来实现。其中包括:更好的带宽、延迟和密度;通过网络切片将服务扩展到新的企业、行业和[物联网][5]市场;根据敏捷性和效率定义的快速服务部署;超越传统带宽、语音和信息传递的新服务;以及利用端到端网络获取更多收入的数字服务的出现。 + +**影响**: 在越来越多的事物连接到网络的情况下,这是最有意义的。4G 主要与越来越多的手机有关;只有当你开始连接其他所有东西时,5G 才是真正必要的。4G 意味着我们的手机上有更丰富的应用程序,而 5G 几乎与手机无关。 + +### API:隐藏的业务加速器 + +- [文章链接][6] + +> 要想让组织成功地进行数字化转型,API 策略至关重要。从解锁有价值的数据到加快开发时间,API 都是数字时代的幕后英雄。那些已经尝试过 API 的人已经感受到了好处。例如,研究表明,使用 API 的企业中,有 53% 认为它们提高了生产力,而 29% 声称它们的收入增长是使用 API 的直接结果。当 API 被视为存在于一个项目之外的可发现和可重用的产品时,它有助于为持续的变更奠定灵活的基础。 + +**影响**: 隐藏的业务加速器实际上是这样一种思想,即功能应该以一种方式进行打包,使其能够在原始提供者没有预料到的环境中进行重新利用和组合。 + +我希望你喜欢这份上周给我留下深刻印象的列表,并于下周一回来了解更多开源社区、市场和行业的趋势。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/technology-advice-and-other-industry-trends + +作者:[Tim Hildred][a] +选题:[lujun9972][b] +译者:[algzjh](https://github.com/algzjh) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/thildred +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr "Person standing in front of a giant computer screen with numbers, data" +[2]: https://www.cbronline.com/feature/an-idiots-guide-to-kubernetes +[3]: https://www.computerweekly.com/feature/Gartner-What-to-consider-before-adopting-low-code-development +[4]: https://www.sdxcentral.com/articles/news/nokia-argues-cloud-native-is-essential-to-5g-core/2019/11/ +[5]: https://www.sdxcentral.com/5g/iot/ "IoT" +[6]: https://www.cbronline.com/opinion/digital-transformation-3 diff --git a/published/20191203 Using Ansible to organize your SSH keys in AWS.md b/published/20191203 Using Ansible to organize your SSH keys in AWS.md new file mode 100644 index 0000000000..ff844803c7 --- /dev/null +++ b/published/20191203 Using Ansible to organize your SSH keys in AWS.md @@ -0,0 +1,121 @@ +[#]: collector: (lujun9972) +[#]: translator: (hj24) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11653-1.html) +[#]: subject: (Using Ansible to organize your SSH keys in AWS) +[#]: via: (https://fedoramagazine.org/using-ansible-to-organize-your-ssh-keys-in-aws/) +[#]: author: (Daniel Leite de Abreu https://fedoramagazine.org/author/dabreu/) + +在 AWS 中使用 Ansible 来管理你的 SSH 密钥 +====== + +![][1] + +如果你长期使用亚马逊 Web 服务(AWS)中的实例,你可能会遇到下面这个常见的问题,它不是因为技术性的原因导致的,更多的是因为人类追求方便舒适的天性:当你登录一台你最近没有使用的区域的新实例,你最终会创建一个新的 SSH 密钥对,久而久之这最终就会造成个人拥有太多密钥,导致管理起来复杂混乱。 + +本文将会介绍一种在所有区域中使用你的公钥的方法。最近,一篇 [Fedora Magazine 的文章][2]介绍了另一种解决方案。但本文中的解决方案可以进一步的以更简洁和可扩展的方式实现自动化。 + +假设你有一个 Fedora 30 或 31 系统,其中存储了你的密钥,并且还安装了 Ansible。当这两件事同时满足时,就提供了解决这个问题的办法,甚至它还能做到更多。 + +使用 Ansible 的 [ec2_key 模块][3],你可以创建一个简单的 Ansible 剧本来在所有区域中维护你的 SSH 密钥对。如果你需要增加或者删除密钥,在 Ansible 中这就像从文件中添加和删除行一样简单。 + +### 设置和运行 Ansible 剧本 + +如果要使用剧本,首先需要安装 `ec2_key` 模块的必要依赖项: + +``` +$ sudo dnf install python3-boto python3-boto3 +``` + +该剧本很简单:你只需要像下面的例子一样,修改其中的密钥及其对应的名称。然后,运行该剧本,它会帮你遍历所有列出的公共 AWS 区域。该示例还包括一些你可能要访问的受限区域,只需根据需要来取消对应行的注释,然后,保存文件重新运行剧本即可。 + +``` +--- +- name: Maintain an ssh key pair in ec2 + hosts: localhost + connection: local + gather_facts: no + vars: + ansible_python_interpreter: python + tasks: + - name: Make available your ssh public key in ec2 for new instances + ec2_key: + name: "YOUR KEY NAME GOES HERE" + key_material: 'YOUR KEY GOES HERE' + state: present + region: "{{ item }}" + with_items: + - us-east-2 #US East (Ohio) + - us-east-1 #US East (N. Virginia) + - us-west-1 #US West (N. California) + - us-west-2 #US West (Oregon) + - ap-east-1 #Asia Pacific (Hong Kong) + - ap-south-1 #Asia Pacific (Mumbai) + - ap-northeast-2 #Asia Pacific (Seoul) + - ap-southeast-1 #Asia Pacific (Singapore) + - ap-southeast-2 #Asia Pacific (Sydney) + - ap-northeast-1 #Asia Pacific (Tokyo) + - ca-central-1 #Canada (Central) + - eu-central-1 #EU (Frankfurt) + - eu-west-1 #EU (Ireland) + - eu-west-2 #EU (London) + - eu-west-3 #EU (Paris) + - eu-north-1 #EU (Stockholm) + - me-south-1 #Middle East (Bahrain) + - sa-east-1 #South America (Sao Paulo) + # - us-gov-east-1 #AWS GovCloud (US-East) + # - us-gov-west-1 #AWS GovCloud (US-West) + # - ap-northeast-3 #Asia Pacific (Osaka-Local) + # - cn-north-1 #China (Beijing) + # - cn-northwest-1 #China (Ningxia) +``` + +这个剧本需要通过 API 访问 AWS,为此,请使用环境变量,如下所示: + +``` +$ AWS_ACCESS_KEY="aws-access-key-id" AWS_SECRET_KEY="aws-secret-key-id" ansible-playbook ec2-playbook.yml +``` + +另一个方式是安装 aws 命令行工具并添加凭据,如以前的一篇 [Fedora Magazine 文章][4]所述。如果你在线存储它们,这些参数将**不建议**插入到剧本中!你可以在 [GitHub][5] 中找到本文的剧本代码。 + +完成该剧本之后,请确认你的密钥在 AWS 控制台上可用。为此,可以做如下操作: + + 1. 登录你的 AWS 控制台 + 2. 转到 “EC2 > Key Pairs” + 3. 你应该会看到列出的密钥。唯一的限制是你必须使用此方法逐个区域来检查。 + +另一种方法是在 shell 中使用一个快速命令来为你做这些检查。 + +首先在剧本上创建一个包含所有区域的变量: + +``` +AWS_REGION="us-east-1 us-west-1 us-west-2 ap-east-1 ap-south-1 ap-northeast-2 ap-southeast-1 ap-southeast-2 ap-northeast-1 ca-central-1 eu-central-1 eu-west-1 eu-west-2 eu-west-3 eu-north-1 me-south-1 sa-east-1" +``` + +然后,执行如下循环,你就可以从 aws 的 API 获得结果: + +``` +for each in ${AWS_REGION} ; do aws ec2 describe-key-pairs --key-name ; done +``` + +请记住,要执行上述操作,你需要安装 aws 命令行。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/using-ansible-to-organize-your-ssh-keys-in-aws/ + +作者:[Daniel Leite de Abreu][a] +选题:[lujun9972][b] +译者:[hj24](https://github.com/hj24) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/dabreu/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/12/ansible-aws-keys-816x345.jpg +[2]: https://fedoramagazine.org/ssh-key-aws-regions/ +[3]: https://docs.ansible.com/ansible/latest/modules/ec2_key_module.html +[4]: https://fedoramagazine.org/aws-tools-fedora/ +[5]: https://github.com/dlabreu/aws diff --git a/published/20191203 Why use the Pantheon desktop for Linux Elementary OS.md b/published/20191203 Why use the Pantheon desktop for Linux Elementary OS.md new file mode 100644 index 0000000000..e54061f81e --- /dev/null +++ b/published/20191203 Why use the Pantheon desktop for Linux Elementary OS.md @@ -0,0 +1,72 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11660-1.html) +[#]: subject: (Why use the Pantheon desktop for Linux Elementary OS) +[#]: via: (https://opensource.com/article/19/12/pantheon-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +为何 Elementary OS 中使用 Pantheon 桌面 +====== + +> 本文是 Linux 桌面特别系列的一部分。通过在 Elementary OS 上运行 Pantheon 桌面获得广受喜爱的 Mac OS 特性。 + +![](https://img.linux.net.cn/data/attachment/album/201912/10/085342dfgngrpt6sgzl3af.jpg) + +你愿意为 Linux 桌面支付 20 美元吗?事实上,我会在下载自由软件时选择支付更多的钱!我这样做的原因是开源是值得的。对于 [Elementary OS][2] 的拷贝,默认价格是 20 美元(你可以选择 1 美元,如果你无法负担,你甚至可以用 0 美元下载)。作为回报,你将获得一个出色且精心制作的发行版,同时拥有它自己的 Pantheon 桌面设计。 + +你可能会发现 Pantheon 已包含在软件仓库中,因为它是开源的,但你更可能需要下载并安装 [Elementary][3] Linux 才能体验它。如果你还不准备在计算机上将 Elementary 作为主操作系统,那么可以将其安装到虚拟机中,例如 [GNOME Boxes][4] 中。 + +Pantheon 桌面整洁、吸引人,并且有许多用户希望在桌面中获得的东西,但在普通的 Linux 桌面上却无法获得。 + +### Pantheon 桌面之旅 + +乍一看,Pantheon 桌面看起来有点像 Cinnamon、Budgie 或 GNOME 3 的经典模式。但是,Pantheon 最令人兴奋的功能是极小的接触。它在你很少注意到的地方都表现出色,直到有一天这里成为了你一天都会看的地方,并且会意识到它的工作方式确实改善了你的生活质量,更不用说让你过得愉快多了。 + +最明显的例子是“文件名高亮”。几十年来,Mac OS 一直有一个广受欢迎的功能,你可以高亮显示重要文件的名称。人们使用此功能作为快速视觉指示器,来告诉自己哪个文件是这几个的“最佳”版本,或者哪个文件应该发送给朋友,或者哪个文件仍然需要处理。它们可以是任意颜色,可以表示用户想要的任何含义。最重要的是,它是引人注目的视觉元数据。 + +从 Mac OS 切换过来用户往往会在 GNOME 和 KDE 以及 Linux 提供的其它桌面里怀念这个功能。Pantheon 悄悄地随手解决了这个问题。 + +![A highlighted file in the Pantheon desktop][5] + +当然,那只是其中一个例子。Pantheon 有很多你直到用才会想到的小功能。 + +桌面精致而吸引人,有所有其他很多桌面缺少的直观组件。在许多方面,它充分吸取了其他桌面好的想法,并避免实现多余的东西。 + +![Pantheon desktop on Elementary OS][6] + +### 自定义 Pantheon 桌面 + +Pantheon 桌面表达了如何操作计算机的清晰愿景。这种设计的“问题”(至少在开源之外)是,一个人的偏好可能无法满足另一个人的效率。 + +但它是开源的。它可以更改,任何不能改变的东西都可以被丢弃。Pantheon 绝对是针对特定用户群的桌面,但是即使对于那些对桌面应该如何工作抱有自己期望的人,Pantheon 也会比初看上去更加灵活。许多内置设计都具有替代选项,当你无法根据自己的喜好进行调整时,你可以轻松选择其他应用。主题引擎可确保你的替换应用看起来与桌面的其它部分和谐一致,而通常的 Linux 系统兼容性可确保你选择的所有应用都能按预期相互配合。 + +![Which one is the guest?][7] + +这些替代品,可使你事半功倍。 + +### 受欢迎的补充 + +撇开这个桌面的词源不说,此桌面确实是许多 Linux 用户祈祷的答案(LCTT 译注:Pantheon 的意思是“万神庙”)。无论它是否是你的风格,Pantheon 桌面都是 Linux 用户体验中重要且受欢迎的补充。自己尝试一下,看看它是否是你一直期待的。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/pantheon-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_code_woman.png?itok=vbYz6jjb (A person programming) +[2]: https://elementary.io/ +[3]: http://elementary.io +[4]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization +[5]: https://opensource.com/sites/default/files/uploads/advent-pantheon-highlight.jpg (A highlighted file in the Pantheon desktop) +[6]: https://opensource.com/sites/default/files/uploads/advent-pantheon.jpg (Pantheon desktop on Elementary OS) +[7]: https://opensource.com/sites/default/files/uploads/advent-pantheon-pcmanfm.jpg (Which one is the guest?) diff --git a/published/20191204 Dell XPS 13 7390 Review- The Best Laptop For Desktop Linux Users.md b/published/20191204 Dell XPS 13 7390 Review- The Best Laptop For Desktop Linux Users.md new file mode 100644 index 0000000000..e97c3a570b --- /dev/null +++ b/published/20191204 Dell XPS 13 7390 Review- The Best Laptop For Desktop Linux Users.md @@ -0,0 +1,67 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11664-1.html) +[#]: subject: (Dell XPS 13 7390 Review: The Best Laptop For Desktop Linux Users) +[#]: via: (https://www.linux.com/articles/dell-xps-13-7390-review-the-best-laptop-for-desktop-linux-user/) +[#]: author: (Swapnil Bhartiya https://www.linux.com/author/swapnil/) + +Dell XPS 13 7390:最好的 Linux 桌面笔记本 +====== + +![](https://img.linux.net.cn/data/attachment/album/201912/11/090509vwdm33q8dwqdgnnx.jpg) + +曾经,我们必须进行大量研究、阅读大量评论,才能找到一种在所选的 Linux 桌面发行版上可以以最少的麻烦工作的机器。而如今,这种日子已经一去不复返了,几乎每台机器都可以运行 Linux。Linux 内核社区在设备驱动程序支持方面做得非常出色,可以使一切都开箱即用。 + +不过,有的是**可以**运行 Linux d 机器,有的是运行 Linux 的机器。戴尔计算机属于后一类。五年前,Barton George 在戴尔内部启动了一项计划,将桌面版 Linux 引入到消费级的高端戴尔系统。从一台机器开始,到现在整套从产品线的高端笔记本电脑和台式机都可以运行 Linux。 + +在这些机器中,XPS 13 是我的最爱。尽管我需要一个功能强大的台式机来处理 4K UHD、多机位视频制作,但我还需要一台超便携的笔记本电脑,可以随身携带,而不必担心笨重的背包和充电器。XPS 13 也是我的第一台笔记本电脑,陪了我 7 年多。因此,是的,这还有一个怀旧因素。 + +戴尔几乎每年都会更新其 XPS 产品线,并且最新的[产品展示宣布于 10 月][3]。[XPS 13(7390)] [4] 是该系列的增量更新,而且戴尔非常乐意向我寄来一台测评设备。 + +![](https://img.linux.net.cn/data/attachment/album/201912/11/090524z2xk670shp0080mx.jpg) + +它由 6 核 Core i7-10710U CPU 所支持。它配备 16GB 内存和 1TB SSD。在 1.10 GHz 的基本频率(可以超频到 4.1 GHz)的情况下,这是一台用于常规工作负载的出色机器。它没有使用任何专用的 GPU,因此它并不适合进行游戏或从源代码进行编译的 Gentoo Linux 或 Arch Linux。但是,我确实设法在上面运行了一些 Steam 游戏。 + +如果你想运行 Kubernetes 集群、AI 框架或虚拟现实,那么 Precision 系列中还有更强大的机器,这些机器可以运行 Red Hat Enterprise Linux 和 Ubuntu。 + +该机器的底盘与上一代相同。边框保持与上一代一样的薄,依旧比 MacBook 和微软的 Surface Pro 薄。 + +它具有三个端口,其中两个是 USB-C Thunderbolt 3,可用于连接 4K 显示器、USB 附件以及用于对等网络的计算机之间的高速数据传输。 + +它还具有一个 microSD 插槽。作为视频记者,SD 卡插槽会更有用。大量使用树莓派的用户也会喜欢这种卡。 + +它具有 4 个麦克风和一个改进的摄像头,该摄像头现在位于顶部(再见,鼻孔摄像头!)。 + +XPS 13(7390)光滑纤薄。它的重量仅为 2.7 磅(1.2kg),可以与苹果的 MacBook Air 相提并论。 这台机器可以成为你的旅行伴侣,并且可以执行日常任务,例如检查电子邮件、浏览网络和写作。 + +其 4K UHD 屏幕支持 HDR,这意味着你将可以尽享《The Mandalorian》的全部美妙之处。另外,车载扬声器并没有那么好,听起来有些沉闷。它们适合进行视频聊天或休闲的 YouTube 观看,但是如果你想在今年晚些时候观看《The Witcher》剧集,或者想欣赏 Amazon、Apple Music 或 YouTube Music 的音乐,则需要耳机或外接扬声器。 + +![](https://img.linux.net.cn/data/attachment/album/201912/11/091107p8de88jk5pwffd4a.jpg) + +但是,在插入充电线之前,你可以能使用这台机器多少时间?在正常工作量的情况下,它为我提供了大约 7-8 个小时的电池续航时间:我打开了几个选项卡浏览网络,只是看看电影或听音乐。多任务处理,尤其是各种 Web 活动,都会加速消耗电池电量。在 Linux 上进行一些微调可能会给你带来更多的续航时间,而在 Windows 10 上,我可以使用 10 多个小时呢! + +作为仍在从事大量写作工作的视频记者,我非常喜欢键盘。但是,我们这么多年来在 Linux 台式机上听到的触控板故事一直没变:它与 MacBook 或 Windows 上的品质相差甚远。这或许有一天能改变。值得称道的是,他们确实发布了可增强体验的触控板驱动程序,但我没有运行此系统随附的提供的 Ubuntu 18.04 LTS。我全新安装了 Ubuntu 19.10,因为 Gnome 在 18.04 中的运行速度非常慢。我尝试过 openSUSE Tumbleweed、Zorin OS、elementary OS、Fedora、KDE neon 和 Arch Linux。一切正常,尽管有些需要额外的努力才能运行。 + +那么,该系统适用于谁?显然,这是给那些想要设计精良的、他们信赖的品牌的高端机器的专业人士打造的。适用于喜欢 MacBook Air,但更喜欢 Linux 台式机生态系统的用户。适用于那些希望使用 Linux 来工作,而不是使 Linux 可以工作的人。 + +我使用这台机器一周的时间,进一步说明了为什么我如此喜欢戴尔的 XPS 系列。它们是目前最好的 Linux 笔记本电脑。这款 XPS 13(7390),你值得拥有! + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/articles/dell-xps-13-7390-review-the-best-laptop-for-desktop-linux-user/ + +作者:[Swapnil Bhartiya][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/author/swapnil/ +[b]: https://github.com/lujun9972 +[1]: https://www.linux.com/wp-content/uploads/2019/12/dell-xps-13-7390-1068x665.jpg (dell-xps-13-7390) +[2]: https://www.linux.com/wp-content/uploads/2019/12/dell-xps-13-7390.jpg +[3]: https://bartongeorge.io/2019/08/21/please-welcome-the-9th-generation-of-the-xps-13-developer-edition/ +[4]: https://blog.dell.com/en-us/dells-new-consumer-pc-portfolio-unveiled-ifa-2019/ diff --git a/published/20191204 Java vs. Python- Which should you choose.md b/published/20191204 Java vs. Python- Which should you choose.md new file mode 100644 index 0000000000..82e3d842c2 --- /dev/null +++ b/published/20191204 Java vs. Python- Which should you choose.md @@ -0,0 +1,130 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11679-1.html) +[#]: subject: (Java vs. Python: Which should you choose?) +[#]: via: (https://opensource.com/article/19/12/java-vs-python) +[#]: author: (Archit Modi https://opensource.com/users/architmodi) + +Java 与 Python:你应该选择哪个? +====== + +> 比较世界上最流行的两种编程语言,并在投票中让我们知道你喜欢哪一个。 + +![](https://img.linux.net.cn/data/attachment/album/201912/16/095025dppnl2lgtykgggkt.jpg) + +让我们比较一下世界上两种最受欢迎、最强大的编程语言:Java 和 Python!这两种语言有巨大的社区支持和库来执行几乎任何编程任务,尽管选择编程语言通常取决于开发人员的场景。在比较和对比之后,请投票分享你的观点。 + +### 是什么? + +* **Java** 是一门通用面向对象的编程语言,主要用于开发从移动端到 Web 到企业级应用的各种应用。 +* **Python** 是一门高级面向对象的编程语言,主要用于 Web 开发、人工智能、机器学习、自动化和其他数据科学应用。 + +### 创建者 + +* **Java** 是由 James Gosling(Sun Microsystems)创造的。 +* **Python** 是由 Guido van Rossum 创造的。 + +### 开源状态 + +* **Java** 是免费的,(大部分)开源,但商业用途除外。 +* **Python** 对于所有场景都是免费、开源的。 + +### 平台依赖 + +* **Java** 根据它的 WORA (“一次编写,到处运行write once, run anywhere”)哲学,它是平台无关的。 +* **Python** 依赖于平台。 + +### 编译或解释 + +* **Java** 是一门编译语言。Java 程序在编译时转换为字节码,而不是运行时。 +* **Python** 是一门解释性语言。Python 程序在运行时进行解释。 + +### 文件创建 + +* **Java**:编译后生成 `.class` 文件。 +* **Python**:在运行期,创建 `.pyc` 文件。 + +### 错误类型 + +* **Java** 有 2 种错误类型:编译和运行时错误。 +* **Python** 有 1 种错误类型:回溯(或运行时)错误。 + +### 静态或动态类型 + +* **Java** 是静态类型。当初始化变量时,需要在程序中指定变量的类型,因为类型检查是在编译时完成的。 +* **Python** 是动态类型。变量不需要在初始化时指定类型,因为类型检查是在运行时完成的。 + +### 语法 + +* **Java**:每个语句都需要以分号(`;` )结尾,并且代码块由大括号( `{}` )分隔。 +* **Python**:代码块通过缩进分隔(用户可以选择要使用的空格数,但在整个块中应保持一致)。 + +### 类的数量 + +* **Java**:在 Java 中的单个文件中只能存在一个公有顶级类。 +* **Python**:Python 中的单个文件中可以存在任意数量的类。 + +### 代码多少? + +* **Java** 通常比 Python 要写更多代码行。 +* **Python**通常比 Java 要写更少代码行。 + +### 多重继承 + +* **Java** 不支持多重继承(从两个或多个基类继承)。 +* **Python** 支持多重继承,但由于继承复杂性、层次结构、依赖等各种问题,它很少实现。 + +### 多线程 + +* **Java** 多线程可以支持同时运行的两个或多个并发线程。 +* **Python** 使用全局解释器锁 (GIL),一次只允许运行单个线程(一个 CPU 核)。 + +### 执行速度 + +* **Java** 的执行时间通常比 Python 快。 +* **Python** 的执行时间通常比 Java 慢。 + +### Hello world + +Java 的: + +``` +public class Hello { +   public static void main([String][3][] args) { +      [System][4].out.println("Hello Opensource.com from Java!"); +   } +} +``` + +Python 的: + +``` +print("Hello Opensource.com from Java!") +``` + +### 运行程序 + +![Java vs. Python][5] + +要运行 java 程序 `Hello.java`,你需要先编译它,这将创建一个 `Hello.class` 文件。只需运行类名 `java Hello`。对于 Python,只需运行文件 `python3 helloworld.py`。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/java-vs-python + +作者:[Archit Modi][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/architmodi +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_development_programming.png?itok=M_QDcgz5 (Developing code.) +[2]: tmp.Bpi8QYfp8j#poll +[3]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string +[4]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system +[5]: https://opensource.com/sites/default/files/uploads/python-java-hello-world_0.png (Java vs. Python) diff --git a/published/20191206 5 cool terminal pagers in Fedora.md b/published/20191206 5 cool terminal pagers in Fedora.md new file mode 100644 index 0000000000..8126cbc54d --- /dev/null +++ b/published/20191206 5 cool terminal pagers in Fedora.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11676-1.html) +[#]: subject: (5 cool terminal pagers in Fedora) +[#]: via: (https://fedoramagazine.org/5-cool-terminal-pagers-in-fedora/) +[#]: author: (Jacob Burns https://fedoramagazine.org/author/jaek/) + +5 个最酷的终端分页器 +====== + +![][1] + +像日志或源代码这样的大文件可能会多达成千上万行,这使得在文件内导航非常困难,尤其是在终端上。此外,大多数终端仿真器的回滚缓冲区只有几百行。这可能使得无法使用打印到标准输出的实用程序(例如 `cat`、`head` 和 `tail`)在终端中浏览大型文件。在计算时代的早期,程序员通过开发用于以虚拟“页面”形式显示文本的实用程序来解决这些问题,该实用程序被形象地描述为分页器pager。 + +*分页器*提供了许多使文本文件导航更加简单的功能,包括滚动、搜索功能,以及作为命令[管道][2]的一部分而具有的功能。与大多数文本编辑器相比,某些终端分页器不需要加载整个文件即可查看,这使得它们更快,特别是对于非常大的文件。 + +在现代 Linux 计算时代,终端仿真器比以往更加复杂。它们提供了对缤纷的色彩、终端尺寸调整以及许多其它功能的支持,这些功能使得辨析屏幕上的文本变得更加轻松和高效。从诸如 `pg` 和 `more` 这样极其简单的 UNIX 实用程序,到涵盖各种使用场景的、功能广泛的复杂程序,终端分页器也经历了类似的演变。考虑到这一点,我们或“多”或“少”地汇总了一些最受欢迎的终端分页实用程序的列表。 + +### more + +`more` 是最早的分页器之一,最初在 3.0 BSD 版本中出现。`more` 的第一个实现由 [Daniel Halbert][3] 编写于 1978 年。从那时起,`more` 已成为许多操作系统的普遍功能,包括 Windows、OS/2,MacOS 和大多数 Linux 发行版。 + +`more` 是一个非常轻量级的实用程序。util-linux 软件包中提供的版本只有不到 2100 行的 C 语言代码。但是,这种较小的代码大小是有代价的。大多数版本的 `more` 的功能相对有限,不支持向后滚动或搜索。命令也同样精简:按回车键可滚动一行,或按空格键滚动一页。其他一些有用的命令包括: + +* 在阅读时按 `v` 键以在默认的终端编辑器中打开当前文件。 +* `/模式` 可以让你搜索下一个出现的“模式”。 +* 以多个文件作为参数调用 `more` 时,`:n` 和 `:p` 将分别打开下一个和上一个文件 +   +### less + +`less` 最初被认为是 `more` 的继承者,解决了它的一些局限性。`less` 以 `more` 的功能为基础,增加了许多有用的功能,包括向后滚动、向后搜索。它也更适合窗口大小调整。 + +`less` 中的导航方式与 `more` 类似,尽管 `less` 也从 `vi` 编辑器借用了一些有用的命令。用户可以使用熟悉的主行导航键home row navigational keys(LCTT 译注:指 左手的 `A`、`S`、`D`、`F` 和右手的 `J`、`K`、`L`、`;`,及大拇指所在的空格键)浏览文档。看一眼 `less` 的手册页,就会发现相当多的可用命令。一些特别有用的示例包括: + +* `?模式` 可让你在文件中向后搜索“模式”。 +* `&模式` 仅显示具有“模式”特征的行。这对于发现自己经常要使用 `$ grep 模式 | less` 的人特别有用。 +* 使用 `-s`(或 `–sqeueeze-blank-lines`)标志来调用 `less`,使你可以查看空白较大的文本文件。 多个换行符被简化为单个中断行。 +* 在该程序中调用的 `s 文件名` 将输入保存到 `文件名`中(如果输入来自管道)。 +* 或者,使用 `-o 文件名` 标志来调用 `less` 将把 `less` 的输入保存到 `文件名` 中。 +   +随着这些增强的功能也带来了体积的略微增大。在写作本文时,Fedora 随附的 `less` 版本大约有 25000 行源代码。当然,除非是受存储限制最大的系统,在所有其它的系统上这都不是问题。`less` 比 `more` 功能更多。 + +### most + +`less` 旨在扩展 `more` 的现有功能,而 `most` 采用另一种方法。`most` 不是在传统的单个文件视图上进行扩展,而是使用户能够将其视图拆分为“窗口”。每个窗口以不同的查看模式包含不同的文件。 + +重要的是,`most` 考虑了其输入文本的宽度。默认的查看模式是不换行的(`less` 中的 `-S` 参数),此功能在处理“宽”文件时特别有用。尽管对于某些用户来说,这些设计决策可能代表着与传统的重大偏离,但最终结果却非常强大。 + +除了 `more` 提供的导航命令外,`most` 使用直观的助记符进行文件导航。例如,`t` 移至文件的顶部(Top),而 `b` 移至底部(Bottom)。这样,不熟悉 `vi` 及其衍生品的用户会发现 `most` 非常简单好用。 + +`most` 的与众不同之处在于它能够快速轻松地拆分窗口和上下文。例如,可以使用以下命令打开两个不同的文本文件: + +``` +$ most textFile1.txt textFile2.txt +``` + +为了水平拆分屏幕,请使用组合键 `Ctrl+x, 2` 或 `Ctrl+w, 2`。 `:n` 命令将在给定窗口中打开下一个文件参数,提供两个文件的分屏视图: + +![][4] + +如果在一个窗口中关闭自动换行,它不会影响其他窗口的行为。(行末的)`\` 字符表示换行或折叠,而 `$` 字符表示文件超出了当前窗口的限制。 + +### pspg + +使用 SQL 数据库的人员通常需要能够一目了然地检查数据库的内容。许多流行的开源 DBMS(例如 MySQL 和 PostGreSQL)的命令行界面都使用系统默认的分页器来查看无法显示在单个屏幕上的输出。诸如 `more` 和 `less` 之类的实用程序是围绕呈现文本文件的想法而设计的,但是对于更结构化的数据,还有一些不足之处。天真的文本分页程序没有宽的表格数据的概念,当处理大型查询时,这可能会令人感到沮丧。 + +[pspg][5] 试图通过为用户提供在查看时冻结列、*原位*排序数据并为输出着色的功能来解决此问题。尽管`pspg` 最初是专门用作 `psql` 的分页器的替代品,但该程序还支持查看 CSV 数据,并且是 `mysql` 和 `pgcli` 的合适的直接替代品。 + +### Vim + +在现代的颜色鲜明的终端中,无休止的黑色页面上的灰色文字感觉太过时了。强大的文本编辑器(如 `vim`)提供的语法高亮显示选项对于浏览源代码很有用。此外,`vim` 提供的搜索功能远远超过了竞争对手。考虑到这一点,`vim` 附带了一个 shell 脚本 `less.sh`,该脚本可以使 `vim` 替代传统的分页器。 + +要将 `vim` 设置为手册页的[默认分页器][6],请将以下内容添加到 shell 的配置中(如果使用默认的bash shell 的话是 `~/.bashrc`): + +``` +export MANPAGER="/bin/sh -c \"col -b | vim -c 'set ft=man ts=8 nomod nolist nonu noma' -\"" +``` + +或者,要将 `vim` 设置为系统范围内的默认分页器,请找到 `less.sh` 脚本。(你可以在当前 Fedora 系统上的 `/usr/share/vim/vim81/macros/` 找到它。)将此位置导出为变量 `PAGER` 以将其设置为默认值,或者将其设置为别名以显式调用它。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/5-cool-terminal-pagers-in-fedora/ + +作者:[Jacob Burns][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/jaek/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/11/5-pagers-816x345.jpg +[2]: https://fedoramagazine.org/command-line-quick-tips-using-pipes-to-connect-tools/ +[3]: https://danhalbert.org/more.html +[4]: https://fedoramagazine.org/wp-content/uploads/2019/11/image-2.png +[5]: https://github.com/okbob/pspg +[6]: https://zameermanji.com/blog/2012/12/30/using-vim-as-manpager/ +[7]: https://unsplash.com/@zyljosa?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[8]: https://unsplash.com/s/photos/pages?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/published/20191206 6 Ways to Send Email from the Linux Command Line.md b/published/20191206 6 Ways to Send Email from the Linux Command Line.md new file mode 100644 index 0000000000..dcfb8ff8ce --- /dev/null +++ b/published/20191206 6 Ways to Send Email from the Linux Command Line.md @@ -0,0 +1,225 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11663-1.html) +[#]: subject: (6 Ways to Send Email from the Linux Command Line) +[#]: via: (https://www.2daygeek.com/6-ways-to-send-email-from-the-linux-command-line/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +Linux 命令行发送邮件的 5 种方法 +====== + +当你需要在 shell 脚本中创建邮件时,就需要用到命令行发送邮件的知识。Linux 中有很多命令可以实现发送邮件。本教程中包含了最流行的 5 个命令行邮件客户端,你可以选择其中一个。这 5 个命令分别是: + + * `mail` / `mailx` + * `mutt` + * `mpack` + * `sendmail` + * `ssmtp` + +### 工作原理 + +我先从整体上来解释下 Linux 中邮件命令怎么把邮件传递给收件人的。邮件命令撰写邮件并发送给一个本地邮件传输代理(MTA,如 sendmail、Postfix)。邮件服务器和远程邮件服务器之间通信以实际发送和接收邮件。下面的流程可以看得更详细。 + +![](https://www.2daygeek.com/wp-content/uploads/2019/12/smtp-simple-mail-transfer-protocol.png) + +### 1) 如何在 Linux 上安装 mail/mailx 命令 + +`mail` 命令是 Linux 终端发送邮件用的最多的命令。`mailx` 是 `mail` 命令的更新版本,基于 Berkeley Mail 8.1,意在提供 POSIX `mailx` 命令的功能,并支持 MIME、IMAP、POP3、SMTP 和 S/MIME 扩展。mailx 在某些交互特性上更加强大,如缓冲邮件消息、垃圾邮件评分和过滤等。在 Linux 发行版上,`mail` 命令是 `mailx` 命令的软链接。可以运行下面的命令从官方发行版仓库安装 `mail` 命令。 + +对于 Debian/Ubuntu 系统,使用 [APT-GET 命令][3] 或 [APT 命令][4] 安装 mailutils。 + +``` +$ sudo apt-get install mailutils +``` + +对于 RHEL/CentOS 系统,使用 [YUM 命令][5] 安装 mailx。 + +``` +$ sudo yum install mailx +``` + +对于 Fedora 系统,使用 [DNF 命令][6] 安装 mailx。 + +``` +$ sudo dnf install mailx +``` + +#### 1a) 如何在 Linux 上使用 mail 命令发送邮件 + +`mail` 命令简单易用。如果你不需要发送附件,使用下面的 `mail` 命令格式就可以发送邮件了: + +``` +$ echo "This is the mail body" | mail -s "Subject" 2daygeek@gmail.com +``` + +如果你要发送附件,使用下面的 `mail` 命令格式: + +``` +$ echo "This is the mail body" | mail -a test1.txt -s "Subject" 2daygeek@gmail.com +``` + +- `-a`:用于在基于 Red Hat 的系统上添加附件。 +- `-A`:用于在基于 Debian 的系统上添加附件。 +- `-s`:指定消息标题。 + +### 2) 如何在 Linux 上安装 mutt 命令 + +`mutt` 是另一个很受欢迎的在 Linux 终端发送邮件的命令。`mutt` 是一个小而强大的基于文本的程序,用来在 unix 操作系统下阅读和发送电子邮件,并支持彩色终端、MIME、OpenPGP 和按邮件线索排序的模式。可以运行下面的命令从官方发行版仓库安装 `mutt` 命令。 + +对于 Debian/Ubuntu 系统,使用 [APT-GET 命令][3] 或 [APT 命令][4] 安装 mutt。 + +``` +$ sudo apt-get install mutt +``` + +对于 RHEL/CentOS 系统,使用 [YUM 命令][5] 安装 mutt。 + +``` +$ sudo yum install mutt +``` + +对于 Fedora 系统,使用 [DNF 命令][6] 安装 mutt。 + +``` +$ sudo dnf install mutt +``` + +#### 2b) 如何在 Linux 上使用 mutt 命令发送邮件 + +`mutt` 一样简单易用。如果你不需要发送附件,使用下面的 `mutt` 命令格式就可以发送邮件了: + +``` +$ echo "This is the mail body" | mutt -s "Subject" 2daygeek@gmail.com +``` + +如果你要发送附件,使用下面的 `mutt` 命令格式: + +``` +$ echo "This is the mail body" | mutt -s "Subject" 2daygeek@gmail.com -a test1.txt +``` + +### 3) 如何在 Linux 上安装 mpack 命令 + +`mpack` 是另一个很受欢迎的在 Linux 终端上发送邮件的命令。`mpack` 程序会在一个或多个 MIME 消息中对命名的文件进行编码。编码后的消息被发送到一个或多个收件人。可以运行下面的命令从官方发行版仓库安装 `mpack` 命令。 + +对于 Debian/Ubuntu 系统,使用 [APT-GET 命令][3] 或 [APT 命令][4] 安装 mpack。 + +``` +$ sudo apt-get install mpack +``` + +对于 RHEL/CentOS 系统,使用 [YUM 命令][5] 安装 mpack。 + +``` +$ sudo yum install mpack +``` + +对于 Fedora 系统,使用 [DNF 命令][6] 安装 mpack。 + +``` +$ sudo dnf install mpack +``` + +#### 3a) 如何在 Linux 上使用 mpack 命令发送邮件 + +`mpack` 同样简单易用。如果你不需要发送附件,使用下面的 `mpack` 命令格式就可以发送邮件了: + +``` +$ echo "This is the mail body" | mpack -s "Subject" 2daygeek@gmail.com +``` + +如果你要发送附件,使用下面的 mpack 命令格式: + +``` +$ echo "This is the mail body" | mpack -s "Subject" 2daygeek@gmail.com -a test1.txt +``` + +### 4) 如何在 Linux 上安装 sendmail 命令 + +sendmail 是一个上广泛使用的通用 SMTP 服务器,你也可以从命令行用 `sendmail` 发邮件。可以运行下面的命令从官方发行版仓库安装 `sendmail` 命令。 + +对于 Debian/Ubuntu 系统,使用 [APT-GET 命令][3] 或 [APT 命令][4]安装 sendmail。 + +``` +$ sudo apt-get install sendmail +``` + +对于 RHEL/CentOS 系统,使用 [YUM 命令][5] 安装 sendmail。 + +``` +$ sudo yum install sendmail +``` + +对于 Fedora 系统,使用 [DNF 命令][6] 安装 sendmail。 + +``` +$ sudo dnf install sendmail +``` + +#### 4a) 如何在 Linux 上使用 sendmail 命令发送邮件 + +`sendmail` 同样简单易用。使用下面的 `sendmail` 命令发送邮件。 + +``` +$ echo -e "Subject: Test Mail\nThis is the mail body" > /tmp/send-mail.txt +``` + +``` +$ sendmail 2daygeek@gmail.com < send-mail.txt +``` + +### 5) 如何在 Linux 上安装 ssmtp 命令 + +`ssmtp` 是类似 `sendmail` 的一个只发送不接收的工具,可以把邮件从本地计算机传递到配置好的 邮件主机(mailhub)。用户可以在 Linux 命令行用 `ssmtp` 把邮件发送到 SMTP 服务器。可以运行下面的命令从官方发行版仓库安装 `ssmtp` 命令。 + +对于 Debian/Ubuntu 系统,使用 [APT-GET 命令][3] 或 [APT 命令][4]安装 ssmtp。 + +``` +$ sudo apt-get install ssmtp +``` + +对于 RHEL/CentOS 系统,使用 [YUM 命令][5] 安装 ssmtp。 + +``` +$ sudo yum install ssmtp +``` + +对于 Fedora 系统,使用 [DNF 命令][6] 安装 ssmtp。 + +``` +$ sudo dnf install ssmtp +``` + +### 5a) 如何在 Linux 上使用 ssmtp 命令发送邮件 + +`ssmtp` 同样简单易用。使用下面的 `ssmtp` 命令格式发送邮件。 + +``` +$ echo -e "Subject: Test Mail\nThis is the mail body" > /tmp/ssmtp-mail.txt +``` + +``` +$ ssmtp 2daygeek@gmail.com < /tmp/ssmtp-mail.txt +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/6-ways-to-send-email-from-the-linux-command-line/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: https://www.2daygeek.com/wp-content/uploads/2019/12/smtp-simple-mail-transfer-protocol.png +[3]: https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ +[4]: https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ +[5]: https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/ +[6]: https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ diff --git a/published/20191206 Pekwm- A lightweight Linux desktop.md b/published/20191206 Pekwm- A lightweight Linux desktop.md new file mode 100644 index 0000000000..099fe46553 --- /dev/null +++ b/published/20191206 Pekwm- A lightweight Linux desktop.md @@ -0,0 +1,93 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11670-1.html) +[#]: subject: (Pekwm: A lightweight Linux desktop) +[#]: via: (https://opensource.com/article/19/12/pekwm-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Pekwm:一个轻量级的 Linux 桌面 +====== + +> 本文是 24 天 Linux 桌面特别系列的一部分。如果你是一个觉得传统桌面会妨碍你的极简主义者,那么试试 Pekwm Linux 桌面。 + +![](https://img.linux.net.cn/data/attachment/album/201912/13/133626l5t2z2awjstu9zbe.png) + +假设你想要一个轻量级桌面环境,它只需要能在屏幕上显示图形、四处移动窗口,而别无杂物。你会发现传统桌面的通知、任务栏和系统托盘会妨碍你的工作。你想主要通过终端工作,但也希望运行图形应用。如果听起来像是你的想法,那么 [Pekwm][2] 可能是你一直在寻找的东西。 + +Pekwm 的灵感大概来自于 Window Maker 和 Fluxbox 等。它提供了一个应用菜单、窗口装饰、而不是一大堆其他东西。它非常适合极简主义者,即那些希望节省资源的用户和喜欢在终端工作的用户。 + +从发行版仓库安装 Pekwm。安装后,请先退出当前桌面会话,以便可以登录到新桌面。默认情况下,会话管理器(KDM、GDM、LightDM 或 XDM,具体取决于你的设置)将继续登录到以前的桌面,因此需要在登录之前修改它。 + +在 GDM 中覆盖之前的桌面: + +![Selecting your desktop in GDM][3] + +在 KDM 中: + +![Selecting your desktop in KDM][4] + +第一次登录 Pekwm 时,你可能会看到黑屏。可能难以置信,但这是正常的。你看到的是一个空白桌面,没有背景壁纸。你可以使用 `feh` 命令设置壁纸(你可能需要从仓库中安装它)。此命令有几个用于设置背景的选项,包括 `--bg-fill` 用壁纸填充屏幕,`--bg-scale` 缩放到合适大小,等等。 + +``` +$ feh --bg-fill ~/Pictures/wallpapers/mybackground.jpg +``` + +### 应用菜单 + +默认情况下,Pekwm 自动生成一个菜单,可在桌面上的任意位置右键单击,从而可让你运行应用。此菜单还提供一些首选项设置,例如选择主题和注销 Pekwm 会话。 + +![Pekwm running on Fedora][5] + +### 配置 + +Pekwm 主要通过保存在 `$HOME/.pekwm` 下的文本配置文件来配置。`menu` 文件定义你的应用菜单,`keys` 文件定义键盘快捷键,等等。 + +`start` 文件是在 Pekwm 启动后执行的 shell 脚本。它类似于传统 Unix 系统上的 `rc.local`。它故意放在最后执行的,因此这里的东西将覆盖之前的一切。这是一个重要文件,它可能是你要设置背景的地方,以便*你的*选择会覆盖正在使用的主题的默认值。 + +`start` 文件也是可以启动 dockapp 的地方。dockapp 是一种小程序,它在 Window Maker 和 Fluxbox 引起了人们的关注。它们通常有网络监视器、时钟、音频设置,和其它你可能会在系统托盘或作为一个 KDE plasmoid 或者完整桌面环境中看到的小部件。你可能会在发行版仓库中找到一些 dockapp,或者可以在 [dockapps.net][6] 上在线查找它们。 + +你可以在启动时运行 dockapp,将它们列在 `start` 文件中,跟上 `&` 符号: + + +``` +feh --bg-fill ~/Pictures/wallpapers/mybackground.jpg +wmnd & +bubblemon -d & +``` + +`start` 文件必须[设置为可执行][7],才能在 Pekwm 启动时运行。 + +``` +$ chmod +x $HOME/.pekwm/start +``` + +### 功能 + +Pekwm 的功能不多,但这就是它的美。如果你希望在桌面上运行额外的服务,那么由你来启动这些服务。如果你仍在学习 Linux,这是了解那些与完整的桌面环境捆绑在一起时通常不会注意到的微小 GUI 组件的好方法(像是[任务栏][8])。这也习惯一些 Linux 命令(例如 [nmcli][9])的好方法。 + +Pekwm 是一个有趣的窗口管理器。它分散、简洁、轻巧。请试试看! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/pekwm-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux_penguin_green.png?itok=ENdVzW22 (Penguin with green background) +[2]: http://www.pekwm.org/ +[3]: https://opensource.com/sites/default/files/uploads/advent-gdm_1.jpg (Selecting your desktop in GDM) +[4]: https://opensource.com/sites/default/files/uploads/advent-enlightenment-kdm_0.jpg (Selecting your desktop in KDM) +[5]: https://opensource.com/sites/default/files/uploads/advent-pekwm.jpg (Pekwm running on Fedora) +[6]: http://dockapps.net +[7]: https://opensource.com/article/19/6/understanding-linux-permissions +[8]: https://opensource.com/article/19/1/productivity-tool-tint2 +[9]: https://opensource.com/article/19/5/set-static-network-connection-linux diff --git a/published/20191207 Getting started with the GNOME Linux desktop.md b/published/20191207 Getting started with the GNOME Linux desktop.md new file mode 100644 index 0000000000..d762dbe15c --- /dev/null +++ b/published/20191207 Getting started with the GNOME Linux desktop.md @@ -0,0 +1,67 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11675-1.html) +[#]: subject: (Getting started with the GNOME Linux desktop) +[#]: via: (https://opensource.com/article/19/12/gnome-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +GNOME Linux 桌面入门 +====== + +> 本文是 24 天 Linux 桌面特别系列的一部分。GNOME 是大多数现代 Linux 发行版的默认桌面,它干净、简单、组织良好。 + +![](https://img.linux.net.cn/data/attachment/album/201912/14/150510z2227x177x8liwww.jpg) + +[GNOME][2] 项目理所应当是 Linux 桌面的宠儿。它起初是专有桌面(当时包括 KDE)的自由开源的桌面替代品,此后一直发展强劲。GNOME 采用了[由 GIMP 项目开发][3]的 GTK+,并将其开发为强大的通用 GTK 框架。该项目开创了用户界面的先声,挑战了桌面“应有”外观的先入之见,并为用户提供了新的范例和选项。 + +在大多数主流现代 Linux 发行版(包括 RHEL、Fedora、Debian 和 Ubuntu)中,GNOME 作为默认桌面而广泛使用。如果你的发行版不提供它的某个版本,那么你可以从软件仓库中安装 GNOME。但是,在执行此操作之前,请注意,为了提供完整的桌面体验,这会随桌面一起安装许多 GNOME 应用。如果你在用其他桌面,那么你可能会发现有冗余的应用(两个 PDF 阅读器、两个媒体播放器、两个文件管理器,等等)。如果你只想尝试 GNOME 桌面,请考虑在虚拟机,如 [GNOME Boxes][4],中安装 GNOME 发行版。 + +### GNOME 功能 + +GNOME 桌面很干净,顶部有一个简单的任务栏,右上角的系统托盘中只有很少的图标。GNOME 上没有桌面图标,这是设计使然。如果你是喜欢在桌面上保存*任何东西*的用户,那么你可能会意识到桌面会定期地变得混乱,而且,更糟糕的是,由于你的应用掩盖了桌面,因此桌面永远不会显示出来。 + +GNOME 解决了两个问题:(在功能上)没有桌面,并且动态生成新的虚拟工作区,因此你可以在全屏模式下运行应用。如果你常把屏幕弄乱,那么可能需要一些时间来习惯,但实际上,从各个方面来说,这都是一种改进的工作流程。你将学习如何使文件井井有条(或者将它们分散在家目录中),并且可以像在手机上一样快速地在屏幕之间切换。 + +当然,并非所有应用都设计为在全屏模式下运行,因此,如果你更喜欢单击切换窗口,也可以这样做。 + +![GNOME running on Debian][5] + +GNOME 哲学褒扬了 Canonical 对常见任务的解决方案。在 GNOME 中,你通常不会发现“回字有四种写法”。你会找到一种或两种官方方法来完成一项任务,你了解了这些方法后,便只需记住这些即​​可。它非常简单,但由于它在 Linux 上运行,因此在技术上也很灵活(毕竟,你不必因为运行 GNOME 桌面而必须要使用 GNOME 应用)。 + +### 应用菜单 + +要访问名为“活动”的应用菜单,请在桌面的左上角单击。此菜单将占满整个屏幕,屏幕最左侧有一栏常见应用的 dock,或可以在网格中浏览应用的图标。你可以通过浏览已安装的应用,或输入软件的头几个字母来过滤列表,然后来启动应用。 + +![GNOME activities][6] + +### GNOME 应用 + +GNOME 不仅是桌面。它是一个桌面以及一组丰富的集成应用,例如 Gedit 文本编辑器、Evince PDF 查看器、Web 浏览器、图像查看器、Nautilus 文件管理器等等。GNOME 应用(例如桌面本身)遵循 [GNOME 人机界面指南][7],因此用户体验既愉悦又一致。无论你是否使用 GNOME 桌面,都可能使用 GTK 应用,也可能会使用 GNOME 应用。 + +### GNOME 3 及更高版本 + +GNOME 项目进展顺利,还有几个令人兴奋的项目(例如 MATE 和 [Cinnamon][8])。它流行、令人舒适,被视为 Linux 桌面的代表。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/gnome-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/custom_gnomes.png?itok=iG98iL8d (Gnomes in a window.) +[2]: https://www.gnome.org/ +[3]: https://www.gtk.org/overview.php +[4]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization +[5]: https://opensource.com/sites/default/files/uploads/advent-gnome.jpg (GNOME running on Debian) +[6]: https://opensource.com/sites/default/files/uploads/advent-gnome-activities.jpg (GNOME activities) +[7]: https://developer.gnome.org/hig/stable/ +[8]: https://opensource.com/article/19/11/advent-2019-cinnamon diff --git a/published/20191209 Counting down the days using bash.md b/published/20191209 Counting down the days using bash.md new file mode 100644 index 0000000000..d68dc742b6 --- /dev/null +++ b/published/20191209 Counting down the days using bash.md @@ -0,0 +1,125 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11672-1.html) +[#]: subject: (Counting down the days using bash) +[#]: via: (https://www.networkworld.com/article/3487712/counting-down-the-days-using-bash.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +用 bash 倒计时日期 +====== + +> 需要知道重要事件发生前有多少天吗?让 Linux bash 和 date 命令可以帮助你! + +![](https://img.linux.net.cn/data/attachment/album/201912/13/140725vdc3c7zj0o7ozc7j.jpg) + +随着即将来临的重要假期,你可能需要提醒你还要准备多久。 + +幸运的是,你可以从 `date` 命令获得很多帮助。在本篇中,我们将研究 `date` 和 bash 脚本如何告诉你从今天到你预期的事件之间有多少天。 + +首先,在进行之前有几个提示。`date` 命令的 `%j` 选项将以 1 至 366 之间的数字显示当前日期。如你所想的一样,1 月 1 日将显示为 1,12 月 31 日将显示为 365 或 366,这取决于是否是闰年。继续尝试。你应该会看到以下内容: + +``` +$ date +%j +339 +``` + +但是,你可以通过以下方式,在 `date` 命令中得到一年中*任何*一天的数字: + +``` +$ date -d "Mar 18" +%j +077 +``` + +要记住的是,即使该日期是过去的日期,上面命令也会向你显示*当年*的日期。但是,你可以在命令中添加年来修复该问题: + +``` +$ date -d "Apr 29" +%j +119 +$ date -d "Apr 29 2020" +%j +120 +``` + +在闰年中,4 月 29 日将是一年的 120 天,而不是 119 天。 + +如果你想倒数圣诞节之前的日子并且不想在挂历上留下指纹,你可以使用以下脚本: + +``` +#!/bin/sh + +XMAS=`date -d "Dec 25" +%j` +TODAY=`date +%j` +DAYS=$(($XMAS - $TODAY)) + +case $DAYS in + 0) echo "It's today! Merry Christmas!";; + [0-9]*) echo "$DAYS days remaining";; + -[0-9]*) echo "Oops, you missed it";; +esac +``` + +在此脚本中,我们获取 12 月 25 日和今天的日期,然后相减。如果结果是正数,我们将显示剩余天数。如果为零,则发出 “Merry Christmas” 的消息,如果为负,那么仅告诉运行脚本的人他们错过了假期。也许他们沉迷在蛋酒中了。 + +`case` 语句由用来打印信息的语句组成,当剩余时间等于 0,或任意数字或以 `-` 符号开头的数字(也就是过去)分别打印不同的信息。 + +对于人们想要关注的任何日期,都可以使用相同方法。实际上,我们可以要求运行脚本的人员提供日期,然后让他们知道从现在到那天还有多少天。这个脚本是这样的。 + +``` +#!/bin/sh + +echo -n "Enter event date (e.g., June 6): " +read dt +EVENT=`date -d "$dt" +%j` +TODAY=`date +%j` +DAYS=`expr $EVENT - $TODAY` + +case $DAYS in + 0) echo "It's today!";; + [0-9]*) echo "$DAYS days remaining";; + -[0-9]*) echo "Oops, you missed it";; +esac +``` + +使用此脚本会遇到的一个问题,如果运行该脚本的人希望知道到第二年这个特殊日子还有多少天,他们会感到失望。即使他们输入日期时提供了年,`date -d` 命令仍将仅提供今年中的天数,而不会提供从现在到那时的天数。 + +计算从今天到某年的日期之间的天数可能有些棘手。你需要包括所有中间年份,并注意那些闰年。 + +### 使用 Unix 纪元时间 + +计算从现在到某个特殊日期之间的天数的另一种方法是利用 Unix 系统存储日期的方法。如果将自 1970 年 1 月 1 日开始的秒数转换为天数,那么就可以很容易地执行此操作,如下脚本所示: + +``` +#!/bin/bash + +echo -n "Enter target date (e.g., Mar 18 2021)> " +read target_date +today=`echo $(($(date --utc --date "$1" +%s)/86400))` +target=`echo $(($(date --utc --date "$target_date" +%s)/86400))` +days=`expr $target - $today` +echo "$days days until $target_date" +``` + +解释一下,86400 是一天中的秒数。将自 Unix 纪元开始以来的秒数除该数即为天数。 + +``` +$ ./countdown +Enter target date (e.g., Mar 18 2021)> Mar 18 2020 +104 days until Mar 18 2020 +``` + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3487712/counting-down-the-days-using-bash.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/20191210 Breaking Linux files into pieces with the split command.md b/published/20191210 Breaking Linux files into pieces with the split command.md new file mode 100644 index 0000000000..0151b678df --- /dev/null +++ b/published/20191210 Breaking Linux files into pieces with the split command.md @@ -0,0 +1,108 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11682-1.html) +[#]: subject: (Breaking Linux files into pieces with the split command) +[#]: via: (https://www.networkworld.com/article/3489256/breaking-linux-files-into-pieces-with-the-split-command.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +使用 split 命令分割 Linux 文件 +====== + +> 一些简单的 Linux 命令能让你根据需要分割以及重新组合文件,来适应存储或电子邮件附件大小的限制。 + +![Marco Verch][1] + +Linux 系统提供了一个非常易于使用的命令来分割文件。在将文件上传到限制大小的存储网站或者作为邮件附件之前,你可能需要执行此操作。要将文件分割为多个文件块,只需使用 `split` 命令。 + +``` +$ split bigfile +``` + +默认情况下,`split` 命令使用非常简单的命名方案。文件块将被命名为 `xaa`、`xab`、`xac` 等,并且,大概地,如果你将足够大的文件分割,你甚至可能会得到名为 `xza` 和 `xzz` 的块。 + +除非你要求,否则该命令将无任何反馈地运行。但是,如果你想在创建文件块时看到反馈,可以使用 `--verbose` 选项。 + +``` +$ split –-verbose bigfile +creating file 'xaa' +creating file 'xab' +creating file 'xac' +``` + +你还可以给文件命名前缀。例如,要将你原始文件分割并命名为 `bigfile.aa`、`bigfile.ab` 等,你可以将前缀添加到 `split` 命令的末尾,如下所示: + +``` +$ split –-verbose bigfile bigfile. +creating file 'bigfile.aa' +creating file 'bigfile.ab' +creating file 'bigfile.ac' +``` + +请注意,上述命令中显示的前缀的末尾会添加一个点。否则,文件将是 `bigfileaa` 之类的名称,而不是 `bigfile.aa`。 + +请注意,`split` 命令*不会*删除你的原始文件,只是创建了文件块。如果要指定文件块的大小,可以使用 `-b` 选项将其添加到命令中。例如: + +``` +$ split -b100M bigfile +``` + +文件大小可以是 KB、MB,GB,最大可以是 YB!只需使 K、M、G、T、P、E、Z 和 Y 这些合适的字母。 + +如果要基于每个块中的行数而不是字节数来拆分文件,那么可以使用 `-l`(行)选项。在此示例中,每个文件将有 1000 行,当然,最后一个文件可能有较少的行。 + +``` +$ split --verbose -l1000 logfile log. +creating file 'log.aa' +creating file 'log.ab' +creating file 'log.ac' +creating file 'log.ad' +creating file 'log.ae' +creating file 'log.af' +creating file 'log.ag' +creating file 'log.ah' +creating file 'log.ai' +creating file 'log.aj' +``` + +如果你需要在远程站点上重新组合文件,那么可以使用如下所示的 `cat` 命令轻松地完成此操作: + +``` +$ cat x?? > original.file +$ cat log.?? > original.file +``` + +上面所示的分割和组合命令适合于二进制和文本文件。在此示例中,我们将 zip 二进制文件分割为 50KB 的块,之后使用 `cat` 重新组合了它们,然后比较了组合后的文件和原始文件。`diff` 命令验证文件是否相同。 + +``` +$ split --verbose -b50K zip zip. +creating file 'zip.aa' +creating file 'zip.ab' +creating file 'zip.ac' +creating file 'zip.ad' +creating file 'zip.ae' +$ cat zip.a? > zip.new +$ diff zip zip.new +$ <== 无输出 = 无差别 +``` + +我唯一要提醒的一点的是,如果你经常使用 `split` 并使用默认命名,那么某些文件块可能会覆盖其他的文件块,甚至会比你预期的更多,因为有些是更早之前分割的。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3489256/breaking-linux-files-into-pieces-with-the-split-command.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/08/chocolate-chunks-100767935-large.jpg +[2]: https://creativecommons.org/licenses/by/2.0/legalcode +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/published/20191211 How to Find High CPU Consumption Processes in Linux.md b/published/20191211 How to Find High CPU Consumption Processes in Linux.md new file mode 100644 index 0000000000..69516fa8b8 --- /dev/null +++ b/published/20191211 How to Find High CPU Consumption Processes in Linux.md @@ -0,0 +1,166 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11678-1.html) +[#]: subject: (How to Find High CPU Consumption Processes in Linux) +[#]: via: (https://www.2daygeek.com/how-to-find-high-cpu-consumption-processes-in-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +如何在 Linux 中找出 CPU 占用高的进程 +====== + +![](https://img.linux.net.cn/data/attachment/album/201912/15/152614cp9bjmfwpofwvsx1.jpg) + +在之前的文章中我们已经讨论过 [如何在 Linux 中找出内存消耗最大的进程][1]。你可能也会遇到在 Linux 系统中找出 CPU 占用高的进程的情形。如果是这样,那么你需要列出系统中 CPU 占用高的进程列表来确定。我认为只有两种方法能实现:使用 [top 命令][2] 和 [ps 命令][3]。出于一些理由,我更倾向于用 `top` 命令而不是 `ps` 命令。但是两个工具都能达到你要的目的,所以你可以根据需求决定使用哪个。这两个工具都被 Linux 系统管理员广泛使用。 + +### 1) 怎样使用 top 命令找出 Linux 中 CPU 占用高的进程 + +在所有监控 Linux 系统性能的工具中,Linux 的 `top` 命令是最好的也是最知名的一个。`top` 命令提供了 Linux 系统运行中的进程的动态实时视图。它能显示系统的概览信息和 Linux 内核当前管理的进程列表。它显示了大量的系统信息,如 CPU 使用、内存使用、交换内存、运行的进程数、目前系统开机时间、系统负载、缓冲区大小、缓存大小、进程 PID 等等。默认情况下,`top` 命令的输出结果按 CPU 占用进行排序,每 5 秒中更新一次结果。如果你想要一个更清晰的视图来更深入的分析结果,[以批处理模式运行 top 命令][4] 是最好的方法。同时,你需要 [理解 top 命令输出结果的含义][5] ,这样才能解决系统的性能问题。 + +``` +# top -b | head -50 + +top - 00:19:17 up 14:23, 1 user, load average: 2.46, 2.18, 1.97 +Tasks: 306 total, 1 running, 305 sleeping, 0 stopped, 0 zombie +%Cpu0 : 10.4 us, 3.0 sy, 0.0 ni, 83.9 id, 0.0 wa, 1.3 hi, 1.3 si, 0.0 st +%Cpu1 : 17.0 us, 3.0 sy, 0.0 ni, 78.7 id, 0.0 wa, 0.3 hi, 1.0 si, 0.0 st +%Cpu2 : 13.0 us, 4.0 sy, 0.0 ni, 81.3 id, 0.0 wa, 0.3 hi, 1.3 si, 0.0 st +%Cpu3 : 12.3 us, 3.3 sy, 0.0 ni, 82.5 id, 0.3 wa, 0.7 hi, 1.0 si, 0.0 st +%Cpu4 : 12.2 us, 3.0 sy, 0.0 ni, 82.8 id, 0.7 wa, 0.3 hi, 1.0 si, 0.0 st +%Cpu5 : 6.4 us, 2.7 sy, 0.0 ni, 89.2 id, 0.0 wa, 0.7 hi, 1.0 si, 0.0 st +%Cpu6 : 26.7 us, 3.4 sy, 0.0 ni, 68.6 id, 0.0 wa, 0.7 hi, 0.7 si, 0.0 st +%Cpu7 : 15.6 us, 4.0 sy, 0.0 ni, 78.8 id, 0.0 wa, 0.7 hi, 1.0 si, 0.0 st +KiB Mem : 16248556 total, 1448920 free, 8571484 used, 6228152 buff/cache +KiB Swap: 17873388 total, 17873388 free, 0 used. 4596044 avail Mem +PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 2179 daygeek 20 3106324 613584 327564 S 79.5 3.8 14:19.76 Web Content + 1714 daygeek 20 4603372 974600 403504 S 20.2 6.0 65:18.91 firefox + 1227 daygeek 20 4192012 376332 180348 S 13.9 2.3 20:43.26 gnome-shell +18324 daygeek 20 3296192 766040 127948 S 6.3 4.7 9:18.12 Web Content + 1170 daygeek 20 1008264 572036 546180 S 6.0 3.5 18:07.85 Xorg + 4684 daygeek 20 3363708 1.1g 1.0g S 3.6 7.2 13:49.92 VirtualBoxVM + 4607 daygeek 20 4591040 1.7g 1.6g S 3.0 11.0 14:09.65 VirtualBoxVM + 1211 daygeek 9 -11 2865268 21032 16588 S 2.0 0.1 10:46.37 pulseaudio + 4562 daygeek 20 1096888 28812 21044 S 1.7 0.2 4:42.93 VBoxSVC + 1783 daygeek 20 3123888 376896 134788 S 1.3 2.3 39:32.56 Web Content + 3286 daygeek 20 3089736 404088 184968 S 1.0 2.5 41:57.44 Web Content +``` + +上面的命令的各部分解释: + + * `top`:命令 + * `-b`:批次档模式 + * `head -50`:显示输出结果的前 50 个 + * `PID`:进程的 ID + * `USER`:进程的归属者 + * `PR`:进程的等级 + * `NI`:进程的 NICE 值 + * `VIRT`:进程使用的虚拟内存 + * `RES`:进程使用的物理内存 + * `SHR`:进程使用的共享内存 + * `S`:这个值表示进程的状态: `S` = 睡眠,`R` = 运行,`Z` = 僵尸进程 + * `%CPU`:进程占用的 CPU 比例 + * `%MEM`:进程使用的 RAM 比例 + * `TIME+`:进程运行了多长时间 + * `COMMAND`:进程名字 + +如果你想看命令的完整路径而不是命令名字,以运行下面的格式 `top` 命令: + +``` +# top -c -b | head -50 + +top - 00:28:49 up 14:33, 1 user, load average: 2.43, 2.49, 2.23 +Tasks: 305 total, 1 running, 304 sleeping, 0 stopped, 0 zombie +%Cpu0 : 11.7 us, 3.7 sy, 0.0 ni, 82.3 id, 0.0 wa, 1.0 hi, 1.3 si, 0.0 st +%Cpu1 : 13.6 us, 3.3 sy, 0.0 ni, 81.1 id, 0.7 wa, 0.3 hi, 1.0 si, 0.0 st +%Cpu2 : 10.9 us, 2.6 sy, 0.0 ni, 85.1 id, 0.0 wa, 0.3 hi, 1.0 si, 0.0 st +%Cpu3 : 16.0 us, 2.6 sy, 0.0 ni, 80.1 id, 0.0 wa, 0.3 hi, 1.0 si, 0.0 st +%Cpu4 : 9.2 us, 3.6 sy, 0.0 ni, 85.9 id, 0.0 wa, 0.3 hi, 1.0 si, 0.0 st +%Cpu5 : 15.6 us, 2.9 sy, 0.0 ni, 80.5 id, 0.0 wa, 0.3 hi, 0.7 si, 0.0 st +%Cpu6 : 11.6 us, 4.3 sy, 0.0 ni, 82.7 id, 0.0 wa, 0.3 hi, 1.0 si, 0.0 st +%Cpu7 : 8.0 us, 3.0 sy, 0.0 ni, 87.3 id, 0.0 wa, 0.7 hi, 1.0 si, 0.0 st +KiB Mem : 16248556 total, 1022456 free, 8778508 used, 6447592 buff/cache +KiB Swap: 17873388 total, 17873388 free, 0 used. 4201560 avail Mem +PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND +18527 daygeek 20 3151820 624808 325748 S 52.8 3.8 59:26.72 /usr/lib/firefox/firefox -contentproc -childID 18 -isForBrowser -prefsLen 10002 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /+ + 1714 daygeek 20 4764668 910940 443228 S 21.5 5.6 68:59.33 /usr/lib/firefox/firefox --new-window + 1227 daygeek 20 4193108 377344 181404 S 11.6 2.3 21:47.36 /usr/bin/gnome-shell + 1170 daygeek 20 1008820 572700 546844 S 5.6 3.5 19:05.10 /usr/lib/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -nolisten tcp -background none -noreset -keeptty -verbose 3 +18324 daygeek 20 3300288 789344 127948 S 5.0 4.9 9:46.89 /usr/lib/firefox/firefox -contentproc -childID 16 -isForBrowser -prefsLen 10002 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /+ + 4684 daygeek 20 3363708 1.1g 1.0g S 3.6 7.2 14:10.18 /usr/lib/virtualbox/VirtualBoxVM --comment CentOS7 --startvm 002f47b8-2af2-48f5-be1d-67b67e03514c --no-startvm-errormsgbox + 4607 daygeek 20 4591040 1.7g 1.6g S 3.0 11.0 14:28.86 /usr/lib/virtualbox/VirtualBoxVM --comment Ubuntu-18.04 --startvm e8c32dbb-8b01-41b0-977a-bf28b9db1117 --no-startvm-errormsgbox + 1783 daygeek 20 3132640 451924 132168 S 2.6 2.8 39:49.66 /usr/lib/firefox/firefox -contentproc -childID 1 -isForBrowser -prefsLen 1 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /usr/l+ + 1211 daygeek 9 -11 2865268 21272 16828 S 2.0 0.1 11:01.29 /usr/bin/pulseaudio --daemonize=no + 4562 daygeek 20 1096888 28812 21044 S 1.7 0.2 4:49.33 /usr/lib/virtualbox/VBoxSVC --auto-shutdown +16865 daygeek 20 3073364 430596 124652 S 1.3 2.7 8:04.02 /usr/lib/firefox/firefox -contentproc -childID 15 -isForBrowser -prefsLen 10002 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /+ + 2179 daygeek 20 2945348 429644 172940 S 1.0 2.6 15:20.90 /usr/lib/firefox/firefox -contentproc -childID 6 -isForBrowser -prefsLen 7821 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /us+ +``` + +### 2) 怎样使用 ps 命令找出 Linux 中 CPU 占用高的进程 + +`ps` 是进程状态process status的缩写,它能显示系统中活跃的/运行中的进程的信息。它提供了当前进程及其详细信息,诸如用户名、用户 ID、CPU 使用率、内存使用、进程启动日期时间、命令名等等的快照。 + +``` +# ps -eo pid,ppid,%mem,%cpu,cmd --sort=-%cpu | head + + PID PPID %MEM %CPU CMD +18527 1714 4.2 40.3 /usr/lib/firefox/firefox -contentproc -childID 18 -isForBrowser -prefsLen 10002 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 1714 true tab + 1714 1152 5.6 8.0 /usr/lib/firefox/firefox --new-window +18324 1714 4.9 6.3 /usr/lib/firefox/firefox -contentproc -childID 16 -isForBrowser -prefsLen 10002 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 1714 true tab + 3286 1714 2.0 5.1 /usr/lib/firefox/firefox -contentproc -childID 14 -isForBrowser -prefsLen 8078 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 1714 true tab + 1783 1714 3.0 4.5 /usr/lib/firefox/firefox -contentproc -childID 1 -isForBrowser -prefsLen 1 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 1714 true tab + 1227 1152 2.3 2.5 /usr/bin/gnome-shell + 1170 1168 3.5 2.2 /usr/lib/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -nolisten tcp -background none -noreset -keeptty -verbose 3 +16865 1714 2.5 2.1 /usr/lib/firefox/firefox -contentproc -childID 15 -isForBrowser -prefsLen 10002 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 1714 true tab + 2179 1714 2.7 1.8 /usr/lib/firefox/firefox -contentproc -childID 6 -isForBrowser -prefsLen 7821 -prefMapSize 213431 -parentBuildID 20191031132559 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 1714 true tab +``` + +上面的命令的各部分解释: + + * `ps`:命令名字 + * `-e`:选择所有进程 + * `-o`:自定义输出格式 + * `–sort=-%cpu`:基于 CPU 使用率对输出结果排序 + * `head`:显示结果的前 10 行 + * `PID`:进程的 ID + * `PPID`:父进程的 ID + * `%MEM`:进程使用的 RAM 比例 + * `%CPU`:进程占用的 CPU 比例 + * `Command`:进程名字 + +如果你只想看命令名字而不是命令的绝对路径,以运行下面的格式 `ps` 命令: + +``` +# ps -eo pid,ppid,%mem,%cpu,comm --sort=-%cpu | head + + PID PPID %MEM %CPU COMMAND +18527 1714 4.1 40.4 Web Content + 1714 1152 5.7 8.0 firefox +18324 1714 4.9 6.3 Web Content + 3286 1714 2.0 5.1 Web Content + 1783 1714 3.0 4.5 Web Content + 1227 1152 2.3 2.5 gnome-shell + 1170 1168 3.5 2.2 Xorg +16865 1714 2.4 2.1 Web Content + 2179 1714 2.7 1.8 Web Content +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/how-to-find-high-cpu-consumption-processes-in-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-11542-1.html +[2]: https://www.2daygeek.com/linux-top-command-linux-system-performance-monitoring-tool/ +[3]: https://www.2daygeek.com/linux-ps-command-find-running-process-monitoring/ +[4]: https://www.2daygeek.com/linux-run-execute-top-command-in-batch-mode/ +[5]: https://www.2daygeek.com/understanding-linux-top-command-output-usage/ diff --git a/sources/news/20191008 Kubernetes communication, SRE struggles, and more industry trends.md b/sources/news/20191008 Kubernetes communication, SRE struggles, and more industry trends.md deleted file mode 100644 index a3ba0a6a52..0000000000 --- a/sources/news/20191008 Kubernetes communication, SRE struggles, and more industry trends.md +++ /dev/null @@ -1,64 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Kubernetes communication, SRE struggles, and more industry trends) -[#]: via: (https://opensource.com/article/19/10/kubernetes-sre-more-industry-trends) -[#]: author: (Tim Hildred https://opensource.com/users/thildred) - -Kubernetes communication, SRE struggles, and more industry trends -====== -A weekly look at open source community and industry trends. -![Person standing in front of a giant computer screen with numbers, data][1] - -As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update. - -## [Review of pod-to-pod communications in Kubernetes][2] - -> In this article, we dive into pod-to-pod communications by showing you ways in which pods within a Kubernetes network can communicate with one another. -> -> While Kubernetes is opinionated in how containers are deployed and operated, it is very non-prescriptive of how the network should be designed in which pods are to be run. Kubernetes imposes the following fundamental requirements on any networking implementation (barring any intentional network segmentation policies) - -**The impact**: Networking is one of the most complicated parts of making computers work together to solve our problems. Kubernetes turns that complexity up to 11, and this article dials it back down to 10.75. - -## [One SRE's struggle and success to improve Infrastructure as Code][3] - -> Convergence is our goal because we expect our infrastructure to reach a desired state over time expressed in the code. Software idempotence means software can run as many times as it wants and unintended changes don’t happen. As a result, we built an in-house service that runs as specified to apply configurations in source control. Traditionally, we’ve aimed for a masterless configuration design so our configuration agent looks for information on the host. - -**The impact**: I've heard it said that the [human element][4] is the most important element of any digital transformation. While I don't know that the author would use that term to describe the outcome he was after, he does a great job of showing that it is not automation for automation's sake we want but rather automation that makes a meaningful impact on the lives of the people it supports. - -## [Why GitHub is the gold standard for developer-focused companies][5] - -> Now, with last year’s purchase by Microsoft supporting them, it is clear that GitHub has a real opportunity to continue building out a robust ecosystem, with billion dollar companies built upon what could turn into a powerful platform. Is GitHub the next ecosystem success story? In a word, yes. At my company, we bet on GitHub as a successful platform to build upon from the very start. We felt it was the place to build our solution if we wanted to streamline project management and keep software teams close to the code. - -**The impact**: It is one of the great ironies of open source that the most popular tool for open source development is not itself open source. The only way this works is if that tool is so good that open source developers are willing to overlook that inconsistency. - -## [KubeVirt joins Cloud Native Computing Foundation][6] - -> This month the Cloud Native Computing Foundation (CNCF) formally adopted [KubeVirt][7] into the CNCF Sandbox. KubeVirt allows you to provision, manage and run virtual machines from and within Kubernetes. In joining the CNCF Sandbox, KubeVirt now has a more substantial platform to grow as well as educate the CNCF community on the use cases for placing virtual machines within Kubernetes. The CNCF onboards projects into the CNCF Sandbox when they warrant experimentation on neutral ground to promote and foster collaborative development. - -**The impact**: The convergence of containers and virtual machines is clearly a direction vendors think is valuable. Moving this project to the CNCF gives a way to see whether this idea is going to be as popular with users and customers as vendors hope it will be. - -_I hope you enjoyed this list of what stood out to me from last week and come back next Monday for more open source community, market, and industry trends._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/kubernetes-sre-more-industry-trends - -作者:[Tim Hildred][a] -选题:[lujun9972][b] -译者:[译者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/thildred -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) -[2]: https://superuser.openstack.org/articles/review-of-pod-to-pod-communications-in-kubernetes/ -[3]: https://thenewstack.io/one-sres-struggle-and-success-to-improve-infrastructure-as-code/ -[4]: https://devops.com/the-secret-to-digital-transformation-is-human-connection/ -[5]: https://thenextweb.com/podium/2019/10/02/why-github-is-the-gold-standard-for-developer-focused-companies/ -[6]: https://blog.openshift.com/kubevirt-joins-cloud-native-computing-foundation/ -[7]: https://kubevirt.io/ diff --git a/sources/news/20191013 System76 will ship Coreboot-powered firmware, a new OS for the apocalypse, and more open source news.md b/sources/news/20191013 System76 will ship Coreboot-powered firmware, a new OS for the apocalypse, and more open source news.md deleted file mode 100644 index eab1e9bd0e..0000000000 --- a/sources/news/20191013 System76 will ship Coreboot-powered firmware, a new OS for the apocalypse, and more open source news.md +++ /dev/null @@ -1,103 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (System76 will ship Coreboot-powered firmware, a new OS for the apocalypse, and more open source news) -[#]: via: (https://opensource.com/article/19/10/news-october-13) -[#]: author: (Lauren Maffeo https://opensource.com/users/lmaffeo) - -System76 will ship Coreboot-powered firmware, a new OS for the apocalypse, and more open source news -====== -Catch up on the biggest open source headlines from the past two weeks. -![Weekly news roundup with TV][1] - -In this edition of our open source news roundup, we cover System76 shipping Coreboot-powered firmware, a new OS for the apocalypse, and more open source news! - -### System76 will ship 2 Linux laptops with Coreboot-powered open source firmware - -The Denver-based Linux PC manufacturer announced plans to start shipping two laptop models with its Coreboot-powered open source firmware later this month. Jason Evangelho, Senior Contributor at _Forbes_, cited this move as a march towards offering open source software and hardware from the ground up.  - -System76, which also develops [Pop OS][2], is now taking pre-orders for its Galago Pro and Darter Pro laptops. It claims that Coreboot will let users boot from power off to the desktop 29% faster. - -Coreboot is a lightweight firmware designed to simplify the boot cycle of systems using it. It requires the minimum number of tasks needed to load and run a modern 32-bit or 64-bit operating system. Coreboot can offer a replacement for proprietary firmware, though it omits features like execution environments. Our own [Don Watkins][3] asked if Coreboot will ship on other System76 machines. Their response, [as reported by _Forbes_][4]: - -> _"Yes. Long term, System76 is working to open source all aspects of the computer. Thelio Io, the controller board in the Thelio desktop, is both open hardware and open firmware. This is a long journey but we're picking up speed. It's been less than a year since the our open hardware Thelio desktop was released and we're now producing two laptops with System76 Open Firmware."_ - -### Collapse OS is an operating system for the post-apocalypse - -Virgil Dupras, a software developer based in Quebec, is convinced the world's global supply chain will collapse before 2030. And he's worried that most [electronics will get caught in the crosshairs][5] due to "a very complex supply chain that we won't be able to achieve again for decades (ever?)."  - -To prepare for the worst, Dupras built Collapse OS. It's [designed to run][6] on "minimal or improvised machines" and perform simple tasks that are helpful in a post-apocalyptic society. These include editing text files, collecting sources files for MCUs and CPUs, and reading/writing from several storage devices. - -Dupras says it's intended for worst-case scenarios, and that a "weak collapse" might not be enough to justify its use. If you err on the side of caution, the Collapse OS project is accepting new contributors [on GitHub][7].  - -Per the project website, Dupras says his goal is for Collapse OS to be as self-contained as possible with the ability for users to install the OS without Internet access or other resources. Ideally, the goal is for Collapse OS to not be used at all. - -### ExpressionEngine will stay open source post-acquisition - -The team behind open source CMS ExpressEngine was acquired by Packet Tide - EEHarbor's parent company - in early October. [This announcement ][8]comes one year after Digital Locations acquired EllisLab, which develops EE core.  - -[In an announcement][9] on ExpressionEngine's website, EllisLab founder Rick Ellis said Digital Locations wasn't a good fit for ExpressionEngine. Citing Digital Location's goals to build an AI business, Ellis realized several months ago that ExpressionEngine needed a new home: - -> _"We decided that what was best for ExpressionEngine was to seek a new owner, one that could devote all the resources necessary for ExpressionEngine to flourish. Our top candidate was Packet Tide due to their development capability, extensive catalog of add-ons, and deep roots in the ExpressionEngine community._ -> -> _We are thrilled that they immediately expressed enthusiastic interest in becoming the caretakers of ExpressionEngine."_ - -Ellis says Packet Tide's first goal is to finish building ExpressionEngine 6.0, which will have a new control panel with a dark theme (who doesn't love dark mode?). ExpressionEngine adopted the Apache License Version 2.0 in November 2018, after 16 years as a proprietary tool. - -The tool is still marketed as an open source CMS, and EE Harbor developer Tom Jaeger said [in the EE Slack][10] that their plan is to keep ExpressionEngine open source now. But he also left the door open to possible changes.  - -### McAfee and IBM Security to lead the Open Source Cybersecurity Alliance - -The two tech giants will contribute the initiative's first open source code and content, under guidance from the OASIS consortium. The Alliance aims to share best practices, tech stacks, and security solutions in an open source platform.  - -Carol Geyer, chief development officer of OASIS, said the lack of standard language makes it hard for businesses to share data between tools and products. Despite efforts to collaborate, the lack of a standardized format yields more integration costs that are expensive and time-consuming. - -In lieu of building connections and integrations, [the Alliance wants members][11] to "develop protocols and standards which enable tools to work together and share information across vendors."  - -According to _Tech Republic_, IBM Security will contribute [STIX-Shifter][12], an open source library that offer a universal security system. Meanwhile, McAfee added its [OpenDXL Standard Ontology][13], a cybersecurity messaging format. Other members of the Alliance include CrowdStrike, CyberArk, and SafeBreach. - -#### In other news - - * [Paris uses open source to get closer to the citizen][14] - * [SD Times open source project of the week: ABAP SDK for IBM Watson][15] - * [Google's keeping Knative development under its thumb 'for the foreseeable future'][16] - * [Devs engage in soul-searching on future of open source][17] - * [Why leading Formula 1 teams back 'copycat' open source design idea][18] - - - -_Thanks, as always, to Opensource.com staff members and moderators for their help this week._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/news-october-13 - -作者:[Lauren Maffeo][a] -选题:[lujun9972][b] -译者:[译者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/lmaffeo -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/weekly_news_roundup_tv.png?itok=B6PM4S1i (Weekly news roundup with TV) -[2]: https://system76.com/pop -[3]: https://opensource.com/users/don-watkins -[4]: https://www.forbes.com/sites/jasonevangelho/2019/10/10/system76-will-begin-shipping-2-linux-laptops-with-coreboot-based-open-source-firmware/#15a4da174e64 -[5]: https://collapseos.org/why.html -[6]: https://www.digitaltrends.com/cool-tech/collapse-os-after-societys-collapse/ -[7]: https://github.com/hsoft/collapseos -[8]: https://wptavern.com/expressionengine-under-new-ownership-will-remain-open-source-for-now -[9]: https://expressionengine.com/blog/expressionengine-has-a-new-owner -[10]: https://eecms.slack.com/?redir=%2Farchives%2FC04CUNNR9%2Fp1570576465005500 -[11]: https://www.techrepublic.com/article/mcafee-ibm-join-forces-for-global-open-source-cybersecurity-initiative/ -[12]: https://github.com/opencybersecurityalliance/stix-shifter -[13]: https://www.opendxl.com/ -[14]: https://www.smartcitiesworld.net/special-reports/special-reports/paris-uses-open-source-to-get-closer-to-the-citizen -[15]: https://sdtimes.com/os/sd-times-open-source-project-of-the-week-abap-sdk-for-ibm-watson/ -[16]: https://www.datacenterknowledge.com/google-alphabet/googles-keeping-knative-development-under-its-thumb-foreseeable-future -[17]: https://www.linuxinsider.com/story/86282.html -[18]: https://www.autosport.com/f1/news/146407/why-leading-f1-teams-back-copycat-design-proposal diff --git a/sources/news/20191023 Cisco issues critical security warning for IOS XE REST API container.md b/sources/news/20191023 Cisco issues critical security warning for IOS XE REST API container.md deleted file mode 100644 index 13bc238c2c..0000000000 --- a/sources/news/20191023 Cisco issues critical security warning for IOS XE REST API container.md +++ /dev/null @@ -1,68 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Cisco issues critical security warning for IOS XE REST API container) -[#]: via: (https://www.networkworld.com/article/3447558/cisco-issues-critical-security-warning-for-ios-xe-rest-api-container.html) -[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) - -Cisco issues critical security warning for IOS XE REST API container -====== -This Cisco IOS XE REST API vulnerability could lead to attackers obtaining the token-id of an authenticated user. -D3Damon / Getty Images - -Cisco this week said it issued a software update to address a vulnerability in its [Cisco REST API virtual service container for Cisco IOS XE][1] software that scored a critical 10 out of 10 on the Common Vulnerability Scoring System (CVSS) system. - -With the vulnerability an attacker could submit malicious HTTP requests to the targeted device and if successful, obtain the _token-id_ of an authenticated user. This _token-id_ could be used to bypass authentication and execute privileged actions through the interface of the REST API virtual service container on the affected Cisco IOS XE device, the company said. - -[[Get regularly scheduled insights by signing up for Network World newsletters.]][2] - -According to Cisco the REST API is an application that runs in a virtual services container. A virtual services container is a virtualized environment on a device and is delivered as an open virtual application (OVA).  The OVA package has to be installed and enabled on a device through the device virtualization manager (VMAN) CLI. - -**[ [Prepare to become a Certified Information Security Systems Professional with this comprehensive online course from PluralSight. Now offering a 10-day free trial!][3] ]** - -The Cisco REST API provides a set of RESTful APIs as an alternative method to the Cisco IOS XE CLI to provision selected functions on Cisco devices. - -Cisco said the vulnerability can be exploited under the  following conditions: - - * The device runs an affected Cisco IOS XE Software release. - * The device has installed and enabled an affected version of the Cisco REST API virtual service container. - * An authorized user with administrator credentials (level 15) is authenticated to the REST API interface. - - - -The REST API interface is not enabled by default. To be vulnerable, the virtual services container must be installed and activated. Deleting the OVA package from the device storage memory removes the attack vector. If the Cisco REST API virtual service container is not enabled, this operation will not impact the device's normal operating conditions, Cisco stated.    - -This vulnerability affects Cisco devices that are configured to use a vulnerable version of Cisco REST API virtual service container. This vulnerability affected the following products: - - * Cisco 4000 Series Integrated Services Routers - * Cisco ASR 1000 Series Aggregation Services Routers - * Cisco Cloud Services Router 1000V Series - * Cisco Integrated Services Virtual Router - - - -Cisco said it has [released a fixed version of the REST API][4] virtual service container and   a hardened IOS XE release that prevents installation or activation of a vulnerable container on a device. If the device was already configured with an active vulnerable container, the IOS XE software upgrade will deactivate the container, making the device not vulnerable. In that case, to restore the REST API functionality, customers should upgrade the Cisco REST API virtual service container to a fixed software release, the company said. - -Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3447558/cisco-issues-critical-security-warning-for-ios-xe-rest-api-container.html - -作者:[Michael Cooney][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Michael-Cooney/ -[b]: https://github.com/lujun9972 -[1]: https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20190828-iosxe-rest-auth-bypass -[2]: https://www.networkworld.com/newsletters/signup.html -[3]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fpaths%2Fcertified-information-systems-security-professional-cisspr -[4]: https://www.cisco.com/c/en/us/about/legal/cloud-and-software/end_user_license_agreement.html -[5]: https://www.facebook.com/NetworkWorld/ -[6]: https://www.linkedin.com/company/network-world diff --git a/sources/news/20191026 Netflix builds a Jupyter Lab alternative, a bug bounty to fight election hacking, Raspberry Pi goes microscopic, and more open source news.md b/sources/news/20191026 Netflix builds a Jupyter Lab alternative, a bug bounty to fight election hacking, Raspberry Pi goes microscopic, and more open source news.md deleted file mode 100644 index b50a93d8c1..0000000000 --- a/sources/news/20191026 Netflix builds a Jupyter Lab alternative, a bug bounty to fight election hacking, Raspberry Pi goes microscopic, and more open source news.md +++ /dev/null @@ -1,78 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Netflix builds a Jupyter Lab alternative, a bug bounty to fight election hacking, Raspberry Pi goes microscopic, and more open source news) -[#]: via: (https://opensource.com/article/19/10/news-october-26) -[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt) - -Netflix builds a Jupyter Lab alternative, a bug bounty to fight election hacking, Raspberry Pi goes microscopic, and more open source news -====== -Catch up on the biggest open source headlines from the past two weeks. -![Weekly news roundup with TV][1] - -In this edition of our open source news roundup, we take a look at a machine learning tool from Netflix, Microsoft's election software bug bounty, a cost-effective microscope built with Raspberry Pi, and more! - -### Netflix release Polynote machine learning tool - -While there have been numerous advances in machine learning over the last decade, it's still a difficult, laborious, and sometimes frustrating task. To help make that task easier, Netflix has [released a machine learning notebook environment][2] called Polynote as open source. - -Polynote enables "data scientists and AI researchers to integrate Netflix’s JVM-based machine learning framework with Python machine learning and visualization libraries". What make Polynote unique is its reproducibility feature, which "takes cells’ positions in the notebook into account before executing them, helping prevent bad practices that make notebooks difficult to rerun from the top." It's also quite flexible—Polynote works with Apache Spark and supports languages like Python, Scala, and SQL. - -You can grab Polynote [off GitHub][3] or learn more about it at the Polynote website. - -### Microsoft announces bug bounty program for its election software - -Hoping that more eyeballs on its code will make bugs shallow, Microsoft announced a [a bug bounty][4] for its open source ElectionGuard software development kit for voting machines. The goal of the program is to "uncover vulnerabilities and help bolster election security." - -The bounty is open to "security professionals, part-time hobbyists, and students." Successful submissions, which must include proofs of concept demonstrating how bugs could compromise the security of voters, are worth up to $15,000 (USD). - -If you're interested in participating, you can find ElectionGuard's code on [GitHub][5], and read more about the [bug bounty][6]. - -### microscoPI: a microscope built on Raspberry Pi - -It's not a stretch to say that the Raspberry Pi is one of the most flexible platforms for hardware and software hackers. Micropalaeontologist Martin Tetard saw the potential of the tiny computers in his field of study and [create the microscoPI][7]. - -The microscoPI is a Raspberry Pi-assisted microscope that can "capture, process, and store images and image analysis results." Using an old adjustable microscope with a movable stage as a base, Tetard added a Raspberry Pi B, a Raspberry Pi camera module, and a small touchscreen to the device. The result is a compact rig that's "completely portable and measuring less than 30 cm (12 inches) in height." The entire setup cost him €159 (about $177 USD). - -Tetard has set up [a website][8] for the microscoPI, where you can learn more about it. - -#### In other news - - * [Happy 15th birthday, Ubuntu][9] - * [Open-Source Arm Puts Robotics Within Reach][10] - * [Apache Rya matures open source triple store database][11] - * [UNICEF Launches Cryptocurrency Fund to Back Open Source Technology][12] - * [Open-source Delta Lake project moves to the Linux Foundation][13] - - - -_Thanks, as always, to Opensource.com staff members and moderators for their help this week._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/news-october-26 - -作者:[Scott Nesbitt][a] -选题:[lujun9972][b] -译者:[译者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 -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/weekly_news_roundup_tv.png?itok=B6PM4S1i (Weekly news roundup with TV) -[2]: https://venturebeat.com/2019/10/23/netflix-open-sources-polynote-to-simplify-data-science-and-machine-learning-workflows/ -[3]: https://github.com/polynote/polynote -[4]: https://thenextweb.com/security/2019/10/21/microsofts-open-source-election-software-now-has-a-bug-bounty-program/ -[5]: https://github.com/microsoft/ElectionGuard-SDK -[6]: https://www.microsoft.com/en-us/msrc/bounty -[7]: https://www.geeky-gadgets.com/raspberry-pi-microscope-07-10-2019/ -[8]: https://microscopiproject.wordpress.com/ -[9]: https://www.omgubuntu.co.uk/2019/10/happy-birthday-ubuntu-2019 -[10]: https://hackaday.com/2019/10/17/open-source-arm-puts-robotics-within-reach/ -[11]: https://searchdatamanagement.techtarget.com/news/252472464/Apache-Rya-matures-open-source-triple-store-database -[12]: https://www.coindesk.com/unicef-launches-cryptocurrency-fund-to-back-open-source-technology -[13]: https://siliconangle.com/2019/10/16/open-source-delta-lake-project-moves-linux-foundation/ diff --git a/sources/news/20191104 Hypervisor comeback, Linus says no and reads email, and more industry trends.md b/sources/news/20191104 Hypervisor comeback, Linus says no and reads email, and more industry trends.md deleted file mode 100644 index b8a6aafc80..0000000000 --- a/sources/news/20191104 Hypervisor comeback, Linus says no and reads email, and more industry trends.md +++ /dev/null @@ -1,70 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Hypervisor comeback, Linus says no and reads email, and more industry trends) -[#]: via: (https://opensource.com/article/19/11/hypervisor-stable-kernel-and-more-industry-trends) -[#]: author: (Tim Hildred https://opensource.com/users/thildred) - -Hypervisor comeback, Linus says no and reads email, and more industry trends -====== -A weekly look at open source community and industry trends. -![Person standing in front of a giant computer screen with numbers, data][1] - -As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update. - -## [Containers in 2019: They're calling it a [hypervisor] comeback][2] - -> So what does all this mean as we continue with rapid adoption and hyper-ecosystem growth around Kubernetes and containers? Let’s try and break that down into a few key areas and see what all the excitement is about. - -**The impact**: I'm pretty sure that the title of the article is an LL Cool J reference, which I wholeheartedly approve of. Even more important though is a robust unpacking of developments in the hypervisor space over the last year and how they square up against the trend towards cloud-native and container-based development. - -## [Linux kernel is getting more reliable, says Linus Torvalds. Plus: What do you need to do to be him?][3] - -> "In the end my job is to say no. Somebody has to be able to say no, because other developers know that if they do something bad I will say no. They hopefully in turn are more careful. But in order to be able to say no, I have to know the background, because otherwise I can't do my job. I spend all my time basically reading email about what people are working on. - -**The impact**: The rehabilitation of Linus as a much chiller guy continues; this one has some good advice for people leading distributed teams. - -## [Automated infrastructure in the on-premise datacenter—OpenShift 4.2 on OpenStack 15 (Stein)][4] - -> Up until now IPI (Installer Provision Infrastructure) has only supported public clouds: AWS, Azure, and Google. Now with OpenShift 4.2 it is supporting OpenStack. For the first time we can bring IPI into the on-premise datacenter where it is IMHO most needed. This single feature has the potential to revolutionize on-premise environments and bring them into the cloud-age with a single click and that promise is truly something to get excited about! - -**The impact**: So much tech press has started with the assumption that every company should run their infrastructure like a hyperscaler. The technology is catching up to make the user experience of that feasible. - -## [Kubernetes autoscaling 101: Cluster autoscaler, horizontal autoscaler, and vertical pod autoscaler][5] - -> I’m providing in this post a high-level overview of different scalability mechanisms inside Kubernetes and best ways to make them serve your needs. Remember, to truly master Kubernetes, you need to master different ways to manage the scale of cluster resources, that’s [the core of promise of Kubernetes][6]. -> -> _Configuring Kubernetes clusters to balance resources and performance can be challenging, and requires expert knowledge of the inner workings of Kubernetes. Just because your app or services’ workload isn’t constant, it rather fluctuates throughout the day if not the hour. Think of it as a journey and ongoing process._ - -**The impact**: You can tell whether someone knows what they're talking about if they can represent it in a simple diagram. Thanks to the excellent diagrams in this post, I know more day 2 concerns of Kubernetes operators than I ever wanted to. - -## [GitHub: All open source developers anywhere are welcome][7] - -> Eighty percent of all open-source contributions today, come from outside of the US. The top two markets for open source development outside of the US are China and India. These markets, although we have millions of developers in them, are continuing to grow faster than any others at about 30% year-over-year average. - -**The impact**: One of my open source friends likes to muse on the changing culture within the open source community. He posits that the old guard gatekeepers are already becoming irrelevant. I don't know if I completely agree, but I think you can look at the exponentially increasing contributions from places that haven't been on the open source map before and safely speculate that the open source culture of tomorrow will be radically different than that of today. - -_I hope you enjoyed this list of what stood out to me from last week and come back next Monday for more open source community, market, and industry trends._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/11/hypervisor-stable-kernel-and-more-industry-trends - -作者:[Tim Hildred][a] -选题:[lujun9972][b] -译者:[译者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/thildred -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) -[2]: https://www.infoq.com/articles/containers-hypervisors-2019/ -[3]: https://www.theregister.co.uk/2019/10/30/linux_kernel_is_getting_more_reliable_says_linus_torvalds/ -[4]: https://keithtenzer.com/2019/10/29/automated-infrastructure-in-the-on-premise-datacenter-openshift-4-2-on-openstack-15-stein/ -[5]: https://www.cncf.io/blog/2019/10/29/kubernetes-autoscaling-101-cluster-autoscaler-horizontal-autoscaler-and-vertical-pod-autoscaler/ -[6]: https://speakerdeck.com/thockin/everything-you-ever-wanted-to-know-about-resource-scheduling-dot-dot-dot-almost -[7]: https://www.zdnet.com/article/github-all-open-source-developers-anywhere-are-welcome/#ftag=RSSbaffb68 diff --git a/sources/news/20191105 Red Hat announces RHEL 8.1 with predictable release cadence.md b/sources/news/20191105 Red Hat announces RHEL 8.1 with predictable release cadence.md deleted file mode 100644 index 9addd4102c..0000000000 --- a/sources/news/20191105 Red Hat announces RHEL 8.1 with predictable release cadence.md +++ /dev/null @@ -1,92 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Red Hat announces RHEL 8.1 with predictable release cadence) -[#]: via: (https://www.networkworld.com/article/3451367/red-hat-announces-rhel-8-1-with-predictable-release-cadence.html) -[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) - -Red Hat announces RHEL 8.1 with predictable release cadence -====== - -[Clkr / Pixabay][1] [(CC0)][2] - -[Red Hat][3] has just today announced the availability of Red Hat Enterprise Linux (RHEL) 8.1, promising improvements in manageability, security and performance. - -RHEL 8.1 will enhance the company’s open [hybrid-cloud][4] portfolio and continue to provide a consistent user experience between on-premises and public-cloud deployments. - -[[Get regularly scheduled insights by signing up for Network World newsletters.]][5] - -RHEL 8.1 is also the first release that will follow what Red Hat is calling its "predictable release cadence". Announced at Red Hat Summit 2019, this means that minor releases will be available every six months. The expectation is that this rhythmic release cycle will make it easier both for customer organizations and other software providers to plan their upgrades. - -[][6] - -BrandPost Sponsored by HPE - -[Take the Intelligent Route with Consumption-Based Storage][6] - -Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. - -Red Hat Enterprise Linux 8.1 provides product enhancements in many areas. - -### Enhanced automation - -All supported RHEL subscriptions now include access to Red Hat's proactive analytics, **Red Hat Insights**. With more than 1,000 rules for operating RHEL systems whether on-premises or cloud deployments, Red Hat Insights help IT administrators flag potential configuration, security, performance, availability and stability issues before they impact production. - -### New system roles - -RHEL 8.1 streamlines the process for setting up subsystems to handle specific functions such as storage, networking, time synchronization, kdump and SELinux. This expands on the variety of Ansible system roles. - -### Live kernel patching - -RHEL 8.1 adds full support for live kernel patching. This critically important feature allows IT operations teams to deal with ongoing threats without incurring excessive system downtime. Kernel updates can be applied to remediate common vulnerabilities and exposures (CVE) while reducing the need for a system reboot. Additional security enhancements include enhanced CVE remediation, kernel-level memory protection and application whitelisting. - -### Container-centric SELinux profiles - -These profiles allow the creation of more tailored security policies to control how containerized services access host-system resources, making it easier to harden systems against security threats. - -### Enhanced hybrid-cloud application development - -A reliably consistent set of supported development tools is included, among them the latest stable versions of popular open-source tools and languages like golang and .NET Core as well as the ability to power modern data-processing workloads such as Microsoft SQL Server and SAP solutions. - -Red Hat Linux 8.1 is available now for RHEL subscribers via the [Red Hat Customer Portal][7]. Red Hat Developer program members may obtain the latest releases at no cost at the [Red Hat Developer][8] site. - -#### Additional resources - -Here are some links to  additional information: - - * More about [Red Hat Enterprise Linux][9] - * Get a [RHEL developer subscription][10] - * More about the latest features at [Red Hat Insights][11] - - - -Join the Network World communities on [Facebook][12] and [LinkedIn][13] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3451367/red-hat-announces-rhel-8-1-with-predictable-release-cadence.html - -作者:[Sandra Henry-Stocker][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ -[b]: https://github.com/lujun9972 -[1]: https://pixabay.com/vectors/red-hat-fedora-fashion-style-26734/ -[2]: https://creativecommons.org/publicdomain/zero/1.0/ -[3]: https://www.networkworld.com/article/3316960/ibm-closes-34b-red-hat-deal-vaults-into-multi-cloud.html -[4]: https://www.networkworld.com/article/3268448/what-is-hybrid-cloud-really-and-whats-the-best-strategy.html -[5]: https://www.networkworld.com/newsletters/signup.html -[6]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) -[7]: https://access.redhat.com/ -[8]: https://developer.redhat.com -[9]: https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux -[10]: https://developers.redhat.com/ -[11]: https://www.redhat.com/en/blog/whats-new-red-hat-insights-november-2019 -[12]: https://www.facebook.com/NetworkWorld/ -[13]: https://www.linkedin.com/company/network-world diff --git a/sources/news/20191105 System76 introduces laptops with open source BIOS coreboot.md b/sources/news/20191105 System76 introduces laptops with open source BIOS coreboot.md deleted file mode 100644 index 4d9c336304..0000000000 --- a/sources/news/20191105 System76 introduces laptops with open source BIOS coreboot.md +++ /dev/null @@ -1,57 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (System76 introduces laptops with open source BIOS coreboot) -[#]: via: (https://opensource.com/article/19/11/coreboot-system76-laptops) -[#]: author: (Don Watkins https://opensource.com/users/don-watkins) - -System76 introduces laptops with open source BIOS coreboot -====== -The company answers open hardware fans by revealing two laptops powered -with open source firmware coreboot. -![Guy on a laptop on a building][1] - -In mid-October, [System76][2] made an exciting announcement for open source hardware fans: It would soon begin shipping two of its laptop models, [Galago Pro][3] and [Darter Pro][4], with the open source BIOS [coreboot][5]. - -The coreboot project [says][6] its open source firmware "is a replacement for your BIOS / UEFI with a strong focus on boot speed, security, and flexibility. It is designed to boot your operating system as fast as possible without any compromise to security, with no back doors, and without any cruft from the '80s." Coreboot was previously known as LinuxBIOS, and the engineers who work on coreboot have also contributed to the Linux kernel. - -Most firmware on computers sold today is proprietary, which means even if you are running an open source operating system, you have no access to your machine's BIOS. This is not so with coreboot. Its developers share the improvements they make, rather than keeping them secret from other vendors. Coreboot's source code can be inspected, learned from, and modified, just like any other open source code. - -[Joshua Woolery][7], marketing director at System76, says coreboot differs from a proprietary BIOS in several important ways. "Traditional firmware is closed source and impossible to review and inspect. It's bloated with unnecessary features and unnecessarily complex [ACPI][8] implementations that lead to PCs operating in unpredictable ways. System76 Open Firmware, on the other hand, is lightweight, fast, and cleanly written." This means your computer boots faster and is more secure, he says. - -I asked Joshua about the impact of coreboot on open hardware overall. "The combination of open hardware and open firmware empowers users beyond what's possible when one or the other is proprietary," he says. "Imagine an open hardware controller like [System76's] [Thelio Io][9] without open source firmware. One could read the schematic and write software to control it, but why? With open firmware, the user starts from functioning hardware and software and can expand from there. Open hardware and firmware enable the community to learn from, adapt, and expand on our work, thus moving technology forward as a whole rather than requiring individuals to constantly re-implement what's already been accomplished." - -Joshua says System76 is working to open source all aspects of the computer, and we will see coreboot on other System76 machines. The hardware and firmware in Thelio Io, the controller board in the company's Thelio desktops, are both open. Less than a year after System76 introduced Thelio, the company is now marketing two laptops with open firmware. - -If you would like to see System76's firmware contributions to the coreboot project, visit the code repository on [GitHub][10]. You can also see the schematics for any supported System76 model by sending an [email][11] with the subject line: _Schematics for <MODEL>_. (Bear in mind that the only currently supported models are darp6 and galp4.) Using the coreboot firmware on other devices is not supported and may render them inoperable, - -Coreboot is licensed under the GNU Public License. You can view the [documentation][12] on the project's website and find out how to [contribute][13] to the project on GitHub. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/11/coreboot-system76-laptops - -作者:[Don Watkins][a] -选题:[lujun9972][b] -译者:[译者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/don-watkins -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_code_programming_laptop.jpg?itok=ormv35tV (Guy on a laptop on a building) -[2]: https://opensource.com/article/19/5/system76-secret-sauce -[3]: https://system76.com/laptops/galago -[4]: https://system76.com/laptops/darter -[5]: https://www.coreboot.org/ -[6]: https://www.coreboot.org/users.html -[7]: https://www.linkedin.com/in/joshuawoolery -[8]: https://en.wikipedia.org/wiki/Advanced_Configuration_and_Power_Interface -[9]: https://opensource.com/article/18/11/system76-thelio-desktop-computer -[10]: https://github.com/system76/firmware-open -[11]: mailto:productdev@system76.com -[12]: https://doc.coreboot.org/index.html -[13]: https://github.com/coreboot/coreboot diff --git a/sources/news/20191112 GitHub report surprises, serverless hotness, and more industry trends.md b/sources/news/20191112 GitHub report surprises, serverless hotness, and more industry trends.md deleted file mode 100644 index df2db0d6f8..0000000000 --- a/sources/news/20191112 GitHub report surprises, serverless hotness, and more industry trends.md +++ /dev/null @@ -1,74 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (GitHub report surprises, serverless hotness, and more industry trends) -[#]: via: (https://opensource.com/article/19/11/github-report-serverless-hotness-more-industry-trends) -[#]: author: (Tim Hildred https://opensource.com/users/thildred) - -GitHub report surprises, serverless hotness, and more industry trends -====== -A weekly look at open source community and industry trends. -![Person standing in front of a giant computer screen with numbers, data][1] - -As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update. - -## [GitHub tops 40 million developers as Python, data science, machine learning popularity surges][2] - -> In its annual Octoverse report, GitHub, owned by Microsoft, said it had more than 10 million new users, 44 million repositories created and 87 million pull requests in the last 12 months. The report is a good view of open source software and where the community is headed. - -**The impact:** The finding that hit home hardest for me is that "nearly 80% of GitHub users are outside of the US." While an important part of open source history comes from the east and west coasts of America, there is a good chance that the future of the movement will happen elsewhere. - -## [Serverless: Is it the Kubernetes killer?][3] - -> Serverless isn't here to destroy Kubernetes. The cloud infrastructure space race isn't a zero-sum game. Kubernetes is an obvious evolution following OpenStack and can be run successfully inside of it. There will be OpenStack users for a long time to come, and there are also reasons many companies have moved on from there. Serverless is another tool in the belt of forward-thinking development teams. And increasingly, it can be [run on top of Kubernetes][4] (see Knative), enabling you to get the benefits of the simplicity of serverless and the complexity of Kubernetes where it makes sense for both in your stack. - -**The impact:** The moral of the story is that legacy doesn't really go away, it just gets built in and around. - -## [When Quarkus meets Knative serverless workloads][5] - -> Now, let's discuss how developers can use Quarkus to bring Java into serverless, a place where previously, it was unable to go. Quarkus introduces a comprehensive and seamless approach to generating an operating system specific (aka native) executable from your Java code, as you do with languages like Go and C/C++. Environments such as event-driven and serverless, where you need to start a service to react to an event, require a low time-to-first-response, and traditional Java stacks simply cannot provide this. Knative enables developers to run cloud-native applications as serverless containers in seconds and the containers will go down to zero on demand. -> -> In addition to compiling Java to Knative, Quarkus aims to improve developer productivity. Quarkus works out of the box with popular Java standards, frameworks and libraries like Eclipse MicroProfile, Apache Kafka, RESTEasy, Hibernate, Spring, and many more. Developers familiar with these will feel at home with Quarkus, which should streamline code for the majority of common use cases while providing the flexibility to cover others that come up. - -**The impact:** It's good to start getting specific with how and where the new hotness can be used. The answer, in this case, is "with the other new hotness." - -## [Why you should join the CNCF Meetup Program][6] - -> With the recent changes to Meetup’s [policies][7], we wanted to share a reminder of the benefits of joining the [CNCF Meetup Program][8] and encourage Meetups in the CNCF ecosystem to apply.  -> -> As part of our Meetup Pro membership, CNCF is able to organize a network with an unlimited number of groups on a single account. - -**The impact:** The long term response to this unfortunate fallout from the WeWork debacle is to build a distributed open source Meetup alternative. Thankfully in the meantime, the CNCF has a more pragmatic response. - -## [Introducing your friends to automation (and overcoming their fear)][9] - -> My team and I were in a meeting a little while back with a third party vendor when they asked us what our stance was on automation. My reply was, "We want to automate everything." On top of my reply, my teammates added, "Well, we don’t want to automate ourselves out of a job." - -**The impact:** I've always thought it was a bit cavalier when someone would say, "I think it's my job to automate myself out of a job." There is plenty of circumstances where that is the last measure of success someone would want to be measured by. I'm happy to see this addressed head-on. - -_I hope you enjoyed this list of what stood out to me from last week and come back next Monday for more open source community, market, and industry trends._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/11/github-report-serverless-hotness-more-industry-trends - -作者:[Tim Hildred][a] -选题:[lujun9972][b] -译者:[译者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/thildred -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) -[2]: https://www.zdnet.com/article/github-tops-40-million-developers-as-python-data-science-machine-learning-popularity-surges/#ftag=RSSbaffb68 -[3]: https://www.forbes.com/sites/forbestechcouncil/2019/11/04/serverless-is-it-the-kubernetes-killer/#7e6740711f77 -[4]: https://github.com/knative -[5]: https://vmblog.com/archive/2019/10/29/when-quarkus-meets-knative-serverless-workloads.aspx#.XbiN1JNKiuN -[6]: https://www.cncf.io/blog/2019/11/01/why-you-should-join-the-cncf-meetup-program/ -[7]: https://www.meetup.com/lp/paymentchanges?mpId=9038 -[8]: https://www.meetup.com/pro/cncf -[9]: https://www.redhat.com/sysadmin/introducing-automation diff --git a/sources/news/20191207 New machine learning from Alibaba and Netflix, mimicking animal vision, and more open source news.md b/sources/news/20191207 New machine learning from Alibaba and Netflix, mimicking animal vision, and more open source news.md new file mode 100644 index 0000000000..93297c4cad --- /dev/null +++ b/sources/news/20191207 New machine learning from Alibaba and Netflix, mimicking animal vision, and more open source news.md @@ -0,0 +1,93 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (New machine learning from Alibaba and Netflix, mimicking animal vision, and more open source news) +[#]: via: (https://opensource.com/article/19/12/news-december-7) +[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt) + +New machine learning from Alibaba and Netflix, mimicking animal vision, and more open source news +====== +Catch up on the biggest open source headlines from the past two weeks. +![Weekly news roundup with TV][1] + +In this edition of our open source news roundup, we take a look an open source election auditing tool, new open source from Alibaba and Netflix, mimicking animal vision, and more! + +### Alibaba and Netflix share machine learning and data science software + +Two companies at the forefront of machine learning and data science have just released some of their tools under open source licenses. + +Chinese ecommerce giant Alibaba just [open sourced the algorithm libraries][2] for its Alink platform. The algorithms "are essential to support machine learning tasks such as online product recommendations and smart customer services." According to Jia Yangqing, president of Alibaba Cloud, Alink is a good fit for "developers seeking big data and machine-learning tools." You can find the source code for Alink (which is under an Apache 2.0 license) [on GitHub][3], with documentation in both Chinese and English. + +Not to be outdone, streaming service Netflix just released its [Metaflow Python library][4] under an Apache 2.0 license. Metaflow enables data scientists to "see early on whether a prototyped model would fail in production, allowing them to fix whatever the issue was". It also works with a number of Python data science libraries, like SciKit Learn, Pytorch, and Tensorflow. You can grab Metaflow's code from [its GitHub repository][5] or learn more about it at the [Metaflow website][6]. + +### Open source software to mimic animal vision + +Have you ever wondered how your dog or cat sees the world? Thanks to work by researchers at the University of Exeter in the UK and Australia's University of Queensland, you can find out. The team just released [software that allows humans to see the world as animals do][7]. + +Called micaToolbox, the software can interpret digital photos and process images of various environments by mimicking the limitations of animal vision. Anyone with a camera, a computer, or smartphone can use the software without knowing how to code. But micaToolbox isn't just a novelty. It's a serious scientific tool that can help "help biologists better understand a variety of animal behaviors, including mating systems, distance-dependent signalling and mimicry." And, according to researcher Jolyon Troscianko, the software can help identify "how an animal's camouflage works so that we can manage our land to protect certain species." + +You can [download micaBox][8] or [browse its source code][9] on GitHub. + +### New tool for post-election auditing + +More and more aspects of our lives and institutions are being automated. With that comes an increased danger of systems breaking down or malicious someones tampering with those systems. Open source gives us an opportunity to look at exactly how the automation works. + +Elections, in particular, are increasingly vulnerable. To combat election tampering, the US Cybersecurity and Infrastructure Security Agency (CISA) has joined forces with the non-profit organization VotingWorks to create a [web-based application for auditing ballots][10]. + +Called Arlo, the application is designed to ensure that "elections are secure, resilient, and transparent," said CISA's director Chris Krebs. Arlo works with a range of automated voting systems to help "officials compare audited votes to tabulated votes, and providing monitoring & reporting capabilities." Arlo was used to verify the results of recent state and local elections and is being further field-tested in the states of Georgia, Michigan, Missouri, Ohio, Pennsylvania, and Virginia. + +Arlo's source code, released under an AGPL-3.0 license, is [available on GitHub][11]. + +### Royal Navy debuts open source application development kit + +Consistency across user interfaces is key to a successful set of applications and services. The UK's Royal Navy understands the importance of this and has released the [open source NELSON standards toolkit][12] to help its developers and suppliers "save time and give users a consistent experience." + +Named after the legendary British admiral, NELSON is intended to "maintain high visual consistency and user-experience quality across the different applications developed or subcontracted by the Royal Navy." The toolkit consists of a set of components including visual styles, typographic elements, forms, elements like buttons and checkboxes, and notifications. + +NELSON has its own [GitHub repository][13], from which the Royal Navy encourages developers to make pull requests. + +#### In other news + + * [Council group plans for open source revenues and benefits platform][14] + * [Introducing Nebula, the open source global overlay network from Slack][15] + * [webOS Open Source Edition 2.0 keeps Palm's spirit alive in cars and IoT][16] + * [Duke University Introduces an Open Source Tool as an Alternative to a Monolithic LMS][17] + * [Open Source Technology Could Be a Boon to Farmers][18] + + + +_Thanks, as always, to Opensource.com staff members and moderators for their help this week._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/news-december-7 + +作者:[Scott Nesbitt][a] +选题:[lujun9972][b] +译者:[译者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 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/weekly_news_roundup_tv.png?itok=B6PM4S1i (Weekly news roundup with TV) +[2]: https://www.zdnet.com/article/alibaba-cloud-publishes-machine-learning-algorithm-on-github/ +[3]: https://github.com/alibaba/alink +[4]: https://www.zdnet.com/article/netflix-our-metaflow-python-library-for-faster-data-science-is-now-open-source/ +[5]: https://github.com/Netflix/metaflow +[6]: https://metaflow.org/ +[7]: https://www.upi.com/Science_News/2019/12/03/Novel-software-helps-scientists-see-what-animals-see/5961575389734/ +[8]: http://www.empiricalimaging.com/download/micatoolbox/ +[9]: https://github.com/troscianko/micaToolbox +[10]: https://www.zdnet.com/article/cisa-and-votingworks-release-open-source-post-election-auditing-tool/ +[11]: https://github.com/votingworks/arlo +[12]: https://joinup.ec.europa.eu/collection/open-source-observatory-osor/news/open-source-royal-navy +[13]: https://github.com/Royal-Navy/standards-toolkit +[14]: https://www.ukauthority.com/articles/council-group-plans-for-open-source-revenues-and-benefits/ +[15]: https://slack.engineering/introducing-nebula-the-open-source-global-overlay-network-from-slack-884110a5579 +[16]: https://www.slashgear.com/webos-open-source-edition-2-0-keeps-palms-spirit-alive-in-cars-and-iot-25601309/ +[17]: https://iblnews.org/duke-university-introduces-an-open-source-tool-as-an-alternative-to-a-monolithic-lms/ +[18]: https://civileats.com/2019/12/02/open-source-technology-could-be-a-boon-to-farmers/ diff --git a/sources/news/20191209 First Ever Release of Ubuntu Cinnamon Distribution is Finally Here.md b/sources/news/20191209 First Ever Release of Ubuntu Cinnamon Distribution is Finally Here.md new file mode 100644 index 0000000000..09af65568d --- /dev/null +++ b/sources/news/20191209 First Ever Release of Ubuntu Cinnamon Distribution is Finally Here.md @@ -0,0 +1,85 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (First Ever Release of Ubuntu Cinnamon Distribution is Finally Here!) +[#]: via: (https://itsfoss.com/ubuntu-cinnamon/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +First Ever Release of Ubuntu Cinnamon Distribution is Finally Here! +====== + +_**Brief: Ubuntu Cinnamon is a new distribution that utilizes Linux Mint’s Cinnamon desktop environment on top of Ubuntu code base. It’s first stable release is based on Ubuntu 19.10 Eoan Ermine.**_ + +[Cinnamon][1] is Linux Mint’s flagship desktop environment. Like [MATE desktop][2], Cinnamon is also a product of dissatisfaction with GNOME 3. With the GNOME Classic like user interface and relatively lower hardware requirements, Cinnamon soon gathered a dedicated userbase. + +Like any other desktop environment out there, you can [install Cinnamon on Ubuntu][3] and other distributions. + +Installing multiple [desktop environments][4] (DE) is not a difficult task but it often leads to conflicts (with other DE’s elements) and may not always provide the best experience. This is why major Linux distributions separate spins/flavors with various popular desktop environments. + +[Ubuntu also has various official flavors][5] featuring [KDE][6] (Kubuntu), [LXQt][7] (Lubuntu), Xfce (Xubuntu), Budgie ([Ubuntu Budgie][8]) etc. Cinnamon was not in this list but Ubuntu Cinnamon Remix project is trying to change that. + +### Ubuntu Cinnamon distribution + +![Ubuntu Cinnamon Desktop Screenshot][9] + +[Ubuntu Cinnamon][10] (website under construction) is a new Linux distribution that brings Cinnamon desktop to Ubuntu distribution. Joshua Peisach is the lead developer for the project and he is being helped by other volunteer contributors. The ex-developer of the now discontinued Ubuntu GNOME project and some members from Ubuntu team are also advising the team to help with the development. + +![Ubuntu Cinnamon Remix Screeenshot 1][11] + +Do note that Ubuntu Cinnamon is not an official flavor of Ubuntu. They are trying to get the flavorship but I think that will take a few more releases. + +The first stable release of Ubuntu Cinnamon is based on [Ubuntu 19.10 Eoan Ermine][12]. It uses Calamares installer from Lubuntu and features Cinnamon desktop version 4.0.10. Naturally, it uses Nemo file manager and LightDM. + +It supports EFI and UEFI and only comes with 64-bit support. + +You’ll get your regular goodies like LibreOffice, Firefox and some GNOME software and games. You can of course install more applications as per your need. + +### Download and install Ubuntu Cinnamon + +Do note that this is the first ever release of Ubuntu Cinnamon and the developers are not that experienced at this moment. + +If you don’t like troubleshooting, don’t use it on your main system. I expect this release to have a few bugs and issues which will be fixed eventually as more users test it out. + +You can download Ubuntu Cinnamon ISO from Sourceforge website: + +[Download Ubuntu Cinnamon][13] + +### What next from here? + +The dev team has a few improvements planned for the 20.04 release. The changes are mostly on the cosmetics though. There will be new GRUB and Plymouth theme, layout application and welcome screen. + +I downloaded it and tried it in a live session. Here’s what this distribution looks like: + +[Subscribe to our YouTube channel for more Linux videos][14] + +Meanwhile, if you manage to try it on your own, why not share your experience in the comments? If you use Linux Mint, will you switch to Ubuntu Cinnamon in near future? What are your overall opinion about this new project? Do share it in the comment section. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ubuntu-cinnamon/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Cinnamon_(desktop_environment) +[2]: https://mate-desktop.org/ +[3]: https://itsfoss.com/install-cinnamon-on-ubuntu/ +[4]: https://itsfoss.com/best-linux-desktop-environments/ +[5]: https://itsfoss.com/which-ubuntu-install/ +[6]: https://kde.org/ +[7]: https://lxqt.org/ +[8]: https://itsfoss.com/ubuntu-budgie-18-review/ +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/ubuntu_cinnamon_distribution_screenshot.jpg?ssl=1 +[10]: https://ubuntucinnamon.org/ +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/ubuntu_cinnamon_remix_screeenshot_1.jpg?ssl=1 +[12]: https://itsfoss.com/ubuntu-19-10-released/ +[13]: https://sourceforge.net/projects/ubuntu-cinnamon-remix/ +[14]: https://www.youtube.com/c/itsfoss?sub_confirmation=1 diff --git a/sources/news/20191209 KubeCon gets bigger, the kernel gets better, and more industry trends.md b/sources/news/20191209 KubeCon gets bigger, the kernel gets better, and more industry trends.md new file mode 100644 index 0000000000..81b00a0ec9 --- /dev/null +++ b/sources/news/20191209 KubeCon gets bigger, the kernel gets better, and more industry trends.md @@ -0,0 +1,65 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (KubeCon gets bigger, the kernel gets better, and more industry trends) +[#]: via: (https://opensource.com/article/19/12/kubecon-bigger-kernel-better-more-industry-trends) +[#]: author: (Tim Hildred https://opensource.com/users/thildred) + +KubeCon gets bigger, the kernel gets better, and more industry trends +====== +A weekly look at open source community, market, and industry trends. +![Person standing in front of a giant computer screen with numbers, data][1] + +As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update. + +## [KubeCon showed Kubernetes is big, but is it a Unicorn?][2] + +> It’s hard to remember now but there was a time when Kubernetes was a distant No. 3 in terms of container orchestrators being used in the market. It’s also eye opening to now realize that [the firms][3] that hatched the two platforms that [towered over][4] Kubernetes have had to completely re-jigger their business models under the Kubernetes onslaught. +> +> And full credit to the CNCF for attempting to diffuse some of that attention from Kubernetes by spending the vast majority of the KubeCon opening keynote address touting some of the nearly two dozen graduated, incubating, and sandbox projects it also hosts. But, it was really the Big K that stole the show. + +**The impact:** Open source is way more than the source code; governance is a big deal and can be the difference between longevity and irrelevance. Gathering, organizing, and maintaining humans is an entirely different skill set than doing the same for bits, but can have just as big an influence on the success of a project. + +## [Report: Kubernetes use on the rise][5] + +> At the same time, the Datadog report notes that container churn rates are approximately 10 times higher in orchestrated environments. Churn rates in container environments that lack an orchestration platform such as Kubernetes have increased in the last year as well. The average container lifespan at a typical company running infrastructure without orchestration is about two days, down from about six days in mid-2018. In 19% of those environments not running orchestration, the average container lifetime exceeded 30 days. That compares to only 3% of organizations running containers longer than 30 days in Kubernetes environments, according to the report’s findings. + +**The impact**: If your containers aren't churning, you're probably not getting the full benefit of the technology you've adopted. + +## [Upcoming Linux 5.5 kernel improves live patching, scheduling][6] + +> A new WFX Wi-Fi driver for the Silicon Labs WF200 ASIC transceiver is coming to Linux kernel 5.5. This particular wireless transceiver is geared toward low-power IoT devices and uses a 2.4 GHz 802.11b/g/n radio optimized for low power RF performance in crowded RF environments. This new driver can interface via both Serial Peripheral Interface (SPI) and Secure Digital Input Output (SDIO). + +**The impact**: The kernel's continued relevance is a direct result of the never-ending grind to keep being where people need it to be (i.e. basically everywhere). + +## [DigitalOcean Currents: December 2019][7] + +> In that spirit, this fall’s installment of our seasonal Currents report is dedicated to open source for the second year running. We surveyed more than 5800 developers around the world on the overall health and direction of the open source community. When we last checked in with the community in [2018][8], more than half of developers reported contributing to open source projects, and most felt the community was healthy and growing. + +**The impact**: While the good news outweighs the bad, there are a couple of things to keep an eye on: namely, making open source more inclusive and mitigating potential negative impact of big money. + +_I hope you enjoyed this list of what stood out to me from last week and come back next Monday for more open source community, market, and industry trends._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/kubecon-bigger-kernel-better-more-industry-trends + +作者:[Tim Hildred][a] +选题:[lujun9972][b] +译者:[译者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/thildred +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) +[2]: https://www.sdxcentral.com/articles/opinion-editorial/kubecon-showed-kubernetes-is-big-but-is-it-a-unicorn/2019/11/ +[3]: https://www.sdxcentral.com/articles/news/docker-unloads-enterprise-biz-to-mirantis/2019/11/ +[4]: https://www.sdxcentral.com/articles/news/mesosphere-is-now-d2iq-and-kubernetes-is-its-game/2019/08/ +[5]: https://containerjournal.com/topics/container-ecosystems/report-kubernetes-use-on-the-rise/ +[6]: https://thenewstack.io/upcoming-linux-5-5-kernel-improves-live-patching-scheduling/ +[7]: https://blog.digitalocean.com/digitalocean-currents-december-2019/ +[8]: https://www.digitalocean.com/currents/october-2018/ diff --git a/sources/news/20191214 Annual release cycle for Python, new Python Software Foundation fellows from Africa, and more updates.md b/sources/news/20191214 Annual release cycle for Python, new Python Software Foundation fellows from Africa, and more updates.md new file mode 100644 index 0000000000..85aef63325 --- /dev/null +++ b/sources/news/20191214 Annual release cycle for Python, new Python Software Foundation fellows from Africa, and more updates.md @@ -0,0 +1,75 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Annual release cycle for Python, new Python Software Foundation fellows from Africa, and more updates) +[#]: via: (https://opensource.com/article/19/12/python-news-december) +[#]: author: (Christian Heimes https://opensource.com/users/christian-heimes) + +Annual release cycle for Python, new Python Software Foundation fellows from Africa, and more updates +====== +Find out what's going on in the Python community in December. +![Python in a coffee cup.][1] + +The Python Software Foundation (PSF) is a nonprofit organization behind the Python programming language. I am fortunate to be a PSF Fellow (honorable member for life,) a Python core developer, and the liaison between my company, Red Hat, and the PSF. Part of that liaison work is providing updates on what’s happening in the Python community. Here’s a look at what we have going on in December. + +### Upcoming events + +A significant part of the Python community is its in-person events. These events are where users and contributors intermingle and learn together. Here are the big announcements of upcoming opportunities to connect. + +#### PyCon US 2020 + +[PyCon US][2] is by far the largest annual Python event. The next PyCon is April 15-23, 2020, in Pittsburgh. The call for proposals is open to all until December 20, 2019. I’m planning to attend PyCon for the conference and its [famous post-con sprints][3]. + +#### EuroPython + +EuroPython is the largest Python conference in Europe with about 1,000 attendees in the last years. [EP20][4] will be held in Dublin, Ireland, July 20-26, 2020. As a liaison for Red Hat, I’m proud to say that Red Hat sponsored EP18 in Edinburgh and donated the sponsoring tickets to Women Who Code Scotland. + +#### PyData + +[PyData][5] is a separate nonprofit related to the Python community through a focus on data science. They host many international events throughout the year, with upcoming events in [Austin, Texas][6], and [Warsaw, Poland][7] before the end of the year. + +### New PSF fellows from Africa + +The PSF promotes a few members to fellow every quarter. Yesterday, twelve new PSF fellows were [announced][8]. + +I’d like to highlight the four new fellows from Ghana, who are also the organizers of the first pan-African [PyCon Africa][9], which took place in August 2019 in Accra, Ghana. The Python community in Africa is growing at an amazing speed. PyCon Africa 2020 will be in Accra again, and I’m planning to spend my summer vacation there. + +### Annual release cycle for Python + +Python used to release a new major version about every 18 months. This timeline will change with the Python 3.9 release. With [PEP 602,][10] a new major version of Python will be released annually in October. The new cadence means fewer changes between releases and more predictable release dates. October was chosen to align with Linux distribution releases such as Fedora. Miro Hrončok from the Python maintenance team joined the discussion and has helped to find a convenient release date for us; for more details, please see . + +### Steering council election + +The Python Steering Council governs the development of Python. It was established after [Guido van Rossum stepped down][11] as benevolent dictator for life. Python core developers elect a new steering council for every major Python release. For the upcoming term, nine candidates were nominated for five seats on the council (with Guido being nominated, but [withdrawing][12]). See for all the details. Election results are expected to be announced mid-December. + +That covers what’s new in the Python community for December. Stay tuned for more updates in the future and mark your calendars for the conferences mentioned above. + +So you have a great business idea for a wonderful IT product or service, and you want to build your... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/python-news-december + +作者:[Christian Heimes][a] +选题:[lujun9972][b] +译者:[译者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/christian-heimes +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_python.jpg?itok=G04cSvp_ (Python in a coffee cup.) +[2]: https://us.pycon.org/2020/ +[3]: https://opensource.com/article/19/5/pycon-developer-sprints +[4]: https://www.europython-society.org/post/188741002380/europython-2020-venue-and-location-selected +[5]: https://pydata.org/ +[6]: https://pydata.org/austin2019/ +[7]: https://pydata.org/warsaw2019/ +[8]: https://pyfound.blogspot.com/2019/11/python-software-foundation-fellow.html +[9]: https://africa.pycon.org/ +[10]: https://www.python.org/dev/peps/pep-0602/ +[11]: https://opensource.com/article/19/6/command-line-heroes-python +[12]: https://discuss.python.org/t/steering-council-nomination-guido-van-rossum-2020-term/2657/11 diff --git a/sources/talk/20181018 Think global- How to overcome cultural communication challenges.md b/sources/talk/20181018 Think global- How to overcome cultural communication challenges.md deleted file mode 100644 index 1d36d5e88d..0000000000 --- a/sources/talk/20181018 Think global- How to overcome cultural communication challenges.md +++ /dev/null @@ -1,93 +0,0 @@ -Think global: How to overcome cultural communication challenges -====== -Use these tips to ensure that every member of your global development team feels involved and understood. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/people_remote_teams_world.png?itok=_9DCHEel) - -A few weeks ago, I witnessed an interesting interaction between two work colleagues—Jason, who is from the United States; and Raj, who was visiting from India. - -Raj typically calls into a daily standup meeting at 9:00am US Central Time from India, but since he was in the US, he and his teammates headed toward the scrum area for the meeting. Jason stopped Raj and said, “Raj, where are you going? Don’t you always call into the stand-up? It would feel strange if you don’t call in.” Raj responded, “Oh, is that so? No worries,” and headed back to his desk to call into the meeting. - -I went to Raj’s desk. “Hey, Raj, why aren’t you going to the daily standup?” Raj replied, “Jason asked me to call in.” Meanwhile, Jason was waiting for Raj to come to the standup. - -What happened here? Jason was obviously joking when he made the remark about Raj calling into the meeting. But how did Raj miss this? - -Jason’s statement was meant as a joke, but Raj took it literally. This was a clear example of a misunderstanding that occurred due to unfamiliarity with each other’s cultural context. - -I often encounter emails that end with “Please revert back to me.” At first, this phrase left me puzzled. I thought, "What changes do they want me to revert?" Finally, I figured out that “please revert” means “Please reply.” - -In his TED talk, “[Managing Cross Cultural Remote Teams,][1]” Ricardo Fernandez describes an interaction with a South African colleague who ended an IM conversation with “I’ll call you just now.” Ricardo went back to his office and waited for the call. After fifteen minutes, he called his colleague: “Weren’t you going to call me just now?” The colleague responded, “Yes, I was going to call you just now.” That's when Ricardo realized that to his South African colleague, the phrase “just now” meant “sometime in the future.” - -In today's workplace, our colleagues may not be located in the same office, city, or even country. A growing number of tech companies have a global workforce comprised of employees with varied experiences and perspectives. This diversity allows companies to compete in the rapidly evolving technological environment. - -But geographically dispersed teams can face challenges. Managing and maintaining high-performing development teams is difficult even when the members are co-located; when team members come from different backgrounds and locations, that makes it even harder. Communication can deteriorate, misunderstandings can happen, and teams may stop trusting each other—all of which can affect the success of the company. - -What factors can cause confusion in global communication? In her book, “[The Culture Map][2],” Erin Meyer presents eight scales into which all global cultures fit. We can use these scales to improve our relationships with international colleagues. She identifies the United States as a very low-context culture in the communication scale. In contrast, Japan is identified as a high-context culture. - -What does it mean to be a high- or low-context culture? In the United States, children learn to communicate explicitly: “Say what you mean; mean what you say” is a common principle of communication. On the other hand, Japanese children learn to communicate effectively by mastering the ability to “read the air.” That means they are able to read between the lines and pick up on social cues when communicating. - -Most Asian cultures follow the high-context style of communication. Not surprisingly, the United States, a young country composed of immigrants, follows a low-context culture: Since the people who immigrated to the United States came from different cultural backgrounds, they had no choice but to communicate explicitly and directly. - -### The three R’s - -How can we overcome challenges in cross-cultural communication? Americans communicating with Japanese colleagues, for example, should pay attention to the non-verbal cues, while Japanese communicating with Americans should prepare for more direct language. If you are facing a similar challenge, follow these three steps to communicate more effectively and improve relationships with your international colleagues. - -#### Recognize the differences in cultural context - -The first step toward effective cross-cultural communication is to recognize that there are differences. Start by increasing your awareness of other cultures. - -#### Respect the differences in cultural context - -Once you become aware that differences in cultural context can affect cross-cultural communication, the next step is to respect these differences. When you notice a different style of communication, learn to embrace the difference and actively listen to the other person’s point of view. - -#### Reconcile the differences in cultural context - -Merely recognizing and respecting cultural differences is not enough; you must also learn how to reconcile the cultural differences. Understanding and being empathetic towards the other culture will help you reconcile the differences and learn how to use them to better advance productivity. - -### 5 ways to improve communications for cultural context - -Over the years, I have incorporated various approaches, tips, and tricks to strengthen relationships among team members across the globe. These approaches have helped me overcome communication challenges with global colleagues. Here are a few examples: - -#### Always use video conferencing when communicating with global teammates - -Studies show that about 55% of communication is non-verbal. Body language offers many subtle cues that can help you decipher messages, and video conferencing enables geographically dispersed team members to see each other. Videoconferencing is my default choice when conducting remote meetings. - -#### Ensure that every team member gets an opportunity to share their thoughts and ideas - -Although I prefer to conduct meetings using video conferencing, this is not always possible. If video conferencing is not a common practice at your workplace, it might take some effort to get everyone comfortable with the concept. Start by encouraging everyone to participate in audio meetings. - -One of our remote team members, who frequently met with us in audio conferences, mentioned that she often wanted to share ideas and contribute to the meeting but since we couldn’t see her and she couldn’t see us, she had no idea when to start speaking. If you are using audio conferencing, one way to mitigate this is to ensure that every team member gets an opportunity to share their ideas. - -#### Learn from one another - -Leverage your international friends to learn about their cultural context. This will help you interact more effectively with colleagues from these countries. I have friends from South Asia and South America who have helped me better understand their cultures, and this knowledge has helped me professionally. - -For programmers, I recommend conducting code reviews with your global peers. This will help you understand how those from different cultures give and receive feedback, persuade others, and make technical decisions. - -#### Be empathetic - -Empathy is the key to strong relationships. The more you are able to put yourself in someone else's shoes, the better able you will be to gain trust and build long-lasting connections. Encourage “water-cooler” conversations among your global colleagues by allocating the first few minutes of each meeting for small talk. This offers the additional benefit of putting everyone in a more relaxed mindset. If you manage a global team, make sure every member feels included in the discussion. - -#### Meet your global colleagues in person - -The best way to build long-lasting relationships is to meet your team members in person. If your company can afford it, arrange for this to happen. Meeting colleagues with whom you have been working will likely strengthen your relationship with them. The companies I have worked for have a strong record of periodically sending US team members to other countries and global colleagues to the US office. - -Another way to bring teams together is to attend conferences. This not only creates educational and training opportunities, but you can also carve out some in-person team time. - -In today's increasingly global economy, it is becoming more important for companies to maintain a geographically diverse workforce to remain competitive. Although global teams can face communication challenges, it is possible to maintain a high-performing development team despite geographical and cultural differences. Share some of the techniques you use in the comments. - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/10/think-global-communication-challenges - -作者:[Avindra Fernando][a] -选题:[lujun9972][b] -译者:[译者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/avindrafernando -[b]: https://github.com/lujun9972 -[1]: https://www.youtube.com/watch?v=QIoAkFpN8wQ -[2]: https://www.amazon.com/The-Culture-Map-Invisible-Boundaries/dp/1610392507 diff --git a/sources/talk/20191004 What-s in an open source name.md b/sources/talk/20191004 What-s in an open source name.md deleted file mode 100644 index ae5ce6ee65..0000000000 --- a/sources/talk/20191004 What-s in an open source name.md +++ /dev/null @@ -1,198 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (laingke) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (What's in an open source name?) -[#]: via: (https://opensource.com/article/19/10/open-source-name-origins) -[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja) - -What's in an open source name? -====== -Ever wonder where the names of your favorite open source projects or -programming languages came from? Get the origin stories behind popular -tech nomenclature from A to Z. -![A person writing.][1] - -GNOME, Java, Jupyter, Python. If your friends or family members have ever eavesdropped on your work conversations, they might think you've made a career in Renaissance folklore, coffee roasting, astronomy, or zoology. Where did the names of these open source technologies come from? We asked our writer community for input and rounded up some of our favorite tech name origin stories. - -### Ansible - -The name "Ansible" is lifted directly from science fiction. Ursula Le Guin's book _Rocannon's World_ had devices allowing instantaneous (faster than light) communication called ansibles (derived, apparently, from the word "answerable"). Ansibles became a staple of science fiction, including in Orson Scott Card's _Ender's Game_ (which later became a popular film), where the device controlled many remote space ships. This seemed to be a good model for software that controls distributed machines, so Michael DeHaan (creator and founder of Ansible) borrowed the name. - -### Apache - -[Apache][2] is an open source web server that was originally released in 1995. Its name is not related to the famous Native American tribe; it instead refers to the repeated patches to its original software code. Hence, "A-patchy server." - -### awk - -"awk(1) Stands for Aho, Weinberger, Kernighan (authors)" —Michael Greenberg - -### Bash - -"The original Unix shell, the Bourne shell, was named after its creator. At the time Bash was being developed, csh (pronounced 'seashell') was actually more popular for interactive user logins. The Bash project aimed to give new life to the Bourne shell by making it more suitable for interactive use, thus it was named the 'Bourne again shell,' a pun on 'born again.'" —Ken Gaillot - -### C - -"In early days, Ken Thompson and Dennis Ritchie at AT&T found it interesting that you could use a higher-level programming language (instead of low-level and less-portable assembly programming) to write operating systems and tools. There was an early programming system called BCPL (Basic Combined Programming Language), and Thompson created a stripped-down version of BCPL called B. But B wasn't very flexible or fast. Ritchie then took the ideas of B and expanded it into a compiled language called C." —Jim Hall - -### dd - -"I don't think you can publish such an article without mentioning dd. My nickname is Didi. Correctly pronounced, it sounds like 'dd.' I first learned Unix, and then Linux, in 1993 as a student. Then I went to the army, arrived to one of the very few sections in my unit that used Unix (Ultrix) (the rest were mainly VMS), and one of the people there said: 'So, you are a hacker, right? You think you know Unix? OK, so what's the reason for the name dd?' I had no idea and tried to guess: "Data duplicator?" So he said, 'I'll tell you the story of dd. dd is short for _convert and copy_ (as anyone can still see today on the manpage), but since cc was already taken by the c compiler, it was named dd.' Only years later, I heard the true story about JCL's data definition and the non-uniform, semi-joking syntax for the Unix dd command somewhat being based on it." —Yedidyah Bar David - -### Emacs - -The classic anti-vi editor, the true etymology of the name is unremarkable, in that it derives from "Editing MACroS." Being an object of great religious opprobrium and worship it has, however, attracted many spoof bacronyms such as "Escape Meta Alt Control Shift" (to spoof its heavy reliance on keystrokes), "Eight Megabytes And Constantly Swapping" (from when that was a lot of memory), "Eventually malloc()s All Computer Storage," and "EMACS Makes A Computer Slow." —Adapted from the Jargon File/Hacker's Dictionary - -### Enarx - -[Enarx][3] is a new project in the confidential computing space. One of the project's design principles was that it should be "fungible." so an initial name was "psilocybin" (the famed magic mushroom). The general feeling was that manager types would probably be resistant, so new names were considered. The project's two founders, Mike Bursell and Nathaniel McCallum, are both ancient language geeks, so they considered lots of different ideas, including тайна (Tayna—Russian for secret or mystery—although Russian, admittedly, is not ancient, but hey), crypticon (total bastardization of Greek), cryptidion (Greek for small secret place), arcanus (Latin masculine adjective for secret), arcanum (Latin neuter adjective for secret), and ærn (Anglo-Saxon for place, secret place, closet, habitation, house, or cottage). In the end, for various reasons, including the availability of domains and GitHub project names, they settled on enarx, a combination of two Latin roots: en- (meaning within) and -arx (meaning citadel, stronghold, or fortress). - -### GIMP - -Where would we be without [GIMP][4]? The GNU Image Manipulation Project has been an open source staple for many years. [Wikipedia][5] states, "In 1995, [Spencer Kimball][6] and [Peter Mattis][7] began developing GIMP as a semester-long project at the University of California, Berkeley, for the eXperimental Computing Facility." - -### GNOME - -Have you ever wondered why GNOME is called GNOME? According to [Wikipedia][8], GNOME was originally an acronym that represented the "GNU Network Object Model Environment." Now that name no longer represents the project and has been dropped, but the name has stayed. [GNOME 3][9] is the default desktop environment for Fedora, Red Hat Enterprise, Ubuntu, Debian, SUSE Linux Enterprise, and more. - -### Java - -Can you imagine this programming language being named anything else? Java was originally called Oak, but alas, the legal team at Sun Microsystems vetoed that name due to its existing trademark. So it was back to the drawing board for the development team. [Legend has it][10] that a massive brainstorm was held by the language's working group in January 1995. Lots of other names were tossed around including Silk, DNA, WebDancer, and so on. The team did not want the new name to have anything to do with the overused terms, "web" or "net." Instead, they were searching for something more dynamic, fun, and easy to remember. Java met the requirements and miraculously, the team agreed! - -### Jupyter - -Many of today's data scientists and students use [Jupyter][11] notebooks in their work. The name Jupyter is an amalgamation of three open source computer languages that are used in the notebooks and prominent in data science: [Julia][12], [Python][13], and [R][14]. - -### Kubernetes - -Kubernetes is derived from the Greek word for helmsman. This etymology was corroborated in a [2015 Hacker News][15] response by a Kubernetes project founder, Craig McLuckie. Wanting to stick with the nautical theme, he explained that the technology drives containers, much like a helmsman or pilot drives a container ship. Thus, Kubernetes was the chosen name. Many of us are still trying to get the pronunciation right (koo-bur-NET-eez), so K8s is an acceptable substitute. Interestingly, it shares its etymology with the English word "governor," so has that in common with the mechanical negative-feedback device on steam engines. - -### KDE - -What about the K desktop? KDE originally represented the "Kool Desktop Environment." It was founded in 1996 by [Matthias Ettrich][16]. According to [Wikipedia][17], the name was a play on the words [Common Desktop Environment][18] (CDE) on Unix. - -### Linux - -[Linux][19] was named for its inventor, Linus Torvalds. Linus originally wanted to name his creation "Freax" as he thought that naming the creation after himself was too egotistical. According to [Wikipedia][19], "Ari Lemmke, Torvalds' coworker at the Helsinki University of Technology, who was one of the volunteer administrators for the FTP server at the time, did not think that 'Freax' was a good name. So, he named the project 'Linux' on the server without consulting Torvalds." - -Following are some of the most popular Linux distributions. - -#### CentOS - -[CentOS][20] is an acronym for Community Enterprise Operating System. It contains the upstream packages from Red Hat Enterprise Linux. - -#### Debian - -[Debian][21] Linux, founded in September 1993, is a portmanteau of its founder, Ian Murdock, and his then-girlfriend Debra Lynn. - -#### RHEL - -[Red Hat Linux][22] got its name from its founder Marc Ewing, who wore a red Cornell University fedora given to him by his grandfather. Red Hat was founded on March 26, 1993. [Fedora Linux][23] began as a volunteer project to provide extra software for the Red Hat distribution and got its name from Red Hat's "Shadowman" logo. - -#### Ubuntu - -[Ubuntu][24] aims to share open source widely and is named after the African philosophy of ubuntu, which can be translated as "humanity to others" or "I am what I am because of who we all are." - -### Moodle - -The open source learning platform [Moodle][25] is an acronym for "modular object-oriented dynamic learning environment." Moodle continues to be a leading platform for e-learning. There are nearly 104,000 registered Moodle sites worldwide. - -Two other popular open source content management systems are Drupal and Joomla. Drupal's name comes from the Dutch word for "druppel" which means "drop." Joomla is an [anglicized spelling][26] of the Swahili word "jumla," which means "all together" in Arabic, Urdu, and other languages, according to Wikipedia. - -### Mozilla - -[Mozilla][27] is an open source software community founded in 1998. According to its website, "The Mozilla project was created in 1998 with the release of the Netscape browser suite source code. It was intended to harness the creative power of thousands of programmers on the internet and fuel unprecedented levels of innovation in the browser market." The name was a portmanteau of [Mosaic][28] and Godzilla. - -### Nginx - -"Many tech people try to be cool and say it 'n' 'g' 'n' 'x'. Few actually did the basic actions of researching a bit more to find out very quickly that the name is actually supposed to be said as 'EngineX,' in reference to the powerful web server, like an engine." —Jean Sebastien Tougne - -### Perl - -Perl's founder Larry Wall originally named his project "Pearl." According to Wikipedia, Wall wanted to give the language a short name with positive connotations. Wall discovered the existing [PEARL][29] programming language before Perl's official release and changed the spelling of the name. - -### Piet and Mondrian - -"There are two programming language named after the artist Piet Mondrian. One is called 'Piet' and the other 'Mondrian.' [David Morgan-Mar [writes][30]]: 'Piet is a programming language in which programs look like abstract paintings. The language is named after Piet Mondrian, who pioneered the field of geometric abstract art. I would have liked to call the language Mondrian, but someone beat me to it with a rather mundane-looking scripting language. Oh well, we can't all be esoteric language writers, I suppose.'" —Yuval Lifshitz - -### Python - -The Python programming language received its unique name from its creator, Guido Van Rossum, who was a fan of the comedy group Monty Python. - -### Raspberry Pi - -Known for its tiny-but-mighty capabilities and wallet-friendly price tag, the Raspberry Pi is a favorite in the open source community. But where did its endearing (and yummy) name come from? In the '70s and '80s, it was a popular trend to name computers after fruit. Apple, Tangerine, Apricot... anyone getting hungry? According to a [2012 interview][31] with founder Eben Upton, the name "Raspberry Pi" is a nod to that trend. Raspberries are also tiny in size, yet mighty in flavor. The "Pi" in the name alludes to the fact that, originally, the computer could only run Python. - -### Samba - -[Server Message Block][32] for sharing Windows files on Linux. - -### ScummVM - -[ScummVM][33] (Script Creation Utility for Maniac Mansion Virtual Machine) is a program that makes it possible to run some classic computer adventure games on a modern computer. Originally, it was designed to play LucasArts adventure games that were built using SCUMM, which was originally used to develop Maniac Mansion before being used to develop most of LucasArts's other adventure games. Currently, ScummVM supports a large number of game engines, including Sierra Online's AGI and SCI, but still retains the name ScummVM. A related project, [ResidualVM][34], got its name because it covers the "residual" LucasArts adventure games not covered by ScummVM. The LucasArts games covered by ResidualVM were developed using GrimE (Grim Engine), which was first used to develop Grim Fandango, so the ResidualVM name is a double pun. - -### SQL - -"You may know [SQL] stands for Structured Query Language, but do you know why it's often pronounced 'sequel'? It was created as a follow-up (i.e. sequel) to the original 'QUEL' (QUEry Language)." —Ken Gaillot - -### XFCE - -[XFCE][35] is a popular desktop founded by [Olivier Fourdan][36]. It began as an alternative to CDE in 1996 and its name was originally an acronym for XForms Common Environment. - -### Zsh - -Zsh is an interactive login shell. In 1990, the first version of the shell was written by Princeton student Paul Falstad. He named it after seeing the login ID of Zhong Sha (zsh), then a teaching assistant at Princeton, and thought that it sounded like a [good name for a shell][37]. - -There are many more projects and names that we have not included in this list. Be sure to share your favorites in the comments. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/open-source-name-origins - -作者:[Joshua Allen Holm][a] -选题:[lujun9972][b] -译者:[laingke](https://github.com/laingke) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/holmja -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003784_02_os.comcareers_resume_rh1x.png?itok=S3HGxi6E (A person writing.) -[2]: https://httpd.apache.org/ -[3]: https://enarx.io -[4]: https://www.gimp.org/ -[5]: https://en.wikipedia.org/wiki/GIMP -[6]: https://en.wikipedia.org/wiki/Spencer_Kimball_(computer_programmer) -[7]: https://en.wikipedia.org/wiki/Peter_Mattis -[8]: https://en.wikipedia.org/wiki/GNOME -[9]: https://www.gnome.org/gnome-3/ -[10]: https://www.javaworld.com/article/2077265/so-why-did-they-decide-to-call-it-java-.html -[11]: https://jupyter.org/ -[12]: https://julialang.org/ -[13]: https://www.python.org/ -[14]: https://www.r-project.org/ -[15]: https://news.ycombinator.com/item?id=9653797 -[16]: https://en.wikipedia.org/wiki/Matthias_Ettrich -[17]: https://en.wikipedia.org/wiki/KDE -[18]: https://sourceforge.net/projects/cdesktopenv/ -[19]: https://en.wikipedia.org/wiki/Linux -[20]: https://www.centos.org/ -[21]: https://www.debian.org/ -[22]: https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux -[23]: https://getfedora.org/ -[24]: https://ubuntu.com/about -[25]: https://moodle.org/ -[26]: https://en.wikipedia.org/wiki/Joomla#Historical_background -[27]: https://www.mozilla.org/en-US/ -[28]: https://en.wikipedia.org/wiki/Mosaic_(web_browser) -[29]: https://en.wikipedia.org/wiki/PEARL_(programming_language) -[30]: http://www.dangermouse.net/esoteric/piet.html -[31]: https://www.techspot.com/article/531-eben-upton-interview/ -[32]: https://www.samba.org/ -[33]: https://www.scummvm.org/ -[34]: https://www.residualvm.org/ -[35]: https://www.xfce.org/ -[36]: https://en.wikipedia.org/wiki/Olivier_Fourdan -[37]: http://www.zsh.org/mla/users/2005/msg00951.html diff --git a/sources/talk/20191028 6 signs you might be a Linux user.md b/sources/talk/20191028 6 signs you might be a Linux user.md deleted file mode 100644 index d66d08cf35..0000000000 --- a/sources/talk/20191028 6 signs you might be a Linux user.md +++ /dev/null @@ -1,161 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (6 signs you might be a Linux user) -[#]: via: (https://opensource.com/article/19/10/signs-linux-user) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) - -6 signs you might be a Linux user -====== -If you're a heavy Linux user, you'll probably recognize these common -tendencies. -![Tux with binary code background][1] - -Linux users are a diverse bunch, but many of us share a few habits. You might not have any of the telltale signs listed in this article, and if you're a new Linux user, you may not recognize many of them... yet. - -Here are six signs you might be a Linux user. - -### 1\. As far as you know, the world began on January 1, 1970. - -There are many rumors about why a Unix computer clock always sets itself back to 1970-01-01 when it resets. But the mundane truth is that the Unix "epoch" serves as a common and simple reference point for synchronization. For example, Halloween is the 304th day of this year in the Julian calendar, but we commonly refer to the holiday as being "on the 31st". We know which 31st we mean because we have common reference points: We know that Halloween is celebrated in October and that October is the 10th month of the year, and we know how many days each preceding month contains. Without these values, we could use traditional methods of timekeeping, such as phases of the moon, to keep track of special seasonal events, but of course, a computer doesn't have that ability. - -A computer requires firm and clearly defined values, so the value 1970-01-01T00:00:00Z was chosen as the beginning of the Unix epoch. Any time a [POSIX][2] computer loses track of time, a service like the Network Time Protocol (NTP) can provide it the number of seconds since 1970-01-01T00:00:00Z, which the computer can convert to a human-friendly date. - -Date and time are a famously complex thing to track in computing, largely because there are exceptions to nearly standard. A month doesn't always have 30 days, a year doesn't always have 365 days, and even seconds tend to drift a little each year. If you're looking for a fun and frustrating programming exercise, try to program a reliable calendaring application! - -### 2\. You think it's a chore to type anything over two letters to get something done. - -The most common Unix commands are famously short. In addition to commands like **cd** and **ls** and **mv**, there's one command that literally can't get any shorter: **w** (which shows who is currently logged in according to the **/var/run/utmp** file). - -On the one hand, extremely short commands seem unintuitive. A new user probably isn't going to guess that typing **ls** would _list_ directories. Once you learn the commands, though, the shorter they are, the better. If you spend all day in a terminal, the fewer keystrokes you have to type means you can spend more time getting your work done. - -Luckily, single-letter commands are far and few between, which means you can use most letters for aliases. For example, I use Emacs often enough that I consider **emacs** too long to type, so I alias it to **e** by adding this line to my **.bashrc** file: - - -``` -`alias e='emacs'` -``` - -You can also alias commands temporarily. For instance, if you find yourself running [firewall-cmd][3] repeatedly while you troubleshoot a network issue, then you can create an alias just for your current session: - - -``` -$ alias f='firewall-cmd' -$ f -usage: see firewall-cmd man page -No option specified. -``` - -As long as the terminal is open, your alias persists. Once the terminal is closed, it's forgotten. - -### 3\. You think it's a chore to click more than two times to get something done. - -Linux users are fond of efficiency. While not every Linux user is always in a hurry to get things done, there are conventions in Linux desktops that seek to reduce the number of actions required to accomplish any given task. Here are some examples. - - * In the KDE file manager Dolphin, a single click opens a file or directory. It's assumed that if you want to select a file, you can either click and drag or else Ctrl+Click instead. This may confuse users who are used to double-clicking everything, but once you've tried single-click actions, you usually can't go back to laborious double-clicks. - * On most Linux desktops, a middle-click pastes the most recent contents of the clipboard. - * On many Linux desktops, drag actions can be modified by pressing the Alt, Ctrl, or Shift keys. For instance, Alt+Drag moves a window in KDE, and Ctrl+Drag in GNOME causes a file to be copied instead of moved. - - - -### 4\. You've never performed any action on a computer more than three times because you've already automated it by the third time. - -Pardon the hyperbole, but many Linux users expect their computer to work harder than they do. While it takes time to learn how to automate common tasks, it tends to be easier on Linux than on other platforms because the Linux terminal and the Linux operating system are so tightly integrated. The easy things to automate are the actions you already do in a terminal because commands are just strings that you type into an interpreter, and that interpreter (the terminal) doesn't care whether you typed the strings out manually or whether you're just pointing it to a script. - -For instance, if you find yourself frequently moving a set of files from one place to another, then you can probably use the same sequence of instructions as a script, which you can trigger with a single command. Imagine you are doing this manually each morning: - - -``` -$ cd Documents -$ trash reports-latest.txt -$ wget myserver.local/reports/daily/report-latest.txt -$ cp report-latest.txt reports_daily/2019-31-10.log -``` - -It's a simple sequence, but repeating it daily isn't the most efficient way of spending your time. With a little bit of abstraction, you could automate it with a simple script: - - -``` -#!/bin/sh - -trash $HOME/Documents/reports-latest.txt - -wget myserver.local/reports/daily/report-latest.txt \ --P $HOME/Documents/udpates_daily/`date --iso-8601`.log - -cp $HOME/Documents/udpates_daily/`date --iso-8601`.log \ -$HOME/Documents/reports-latest.txt -``` - -You could call your script **get-reports.sh** and launch it manually each morning, or you could even enter it into your crontab so that your computer performs the task without requiring any intervention from you. - -This can be confusing for a new user because it's not always obvious what's integrated with what. For instance, if you regularly find yourself opening images and scaling them down by 50%, then you're probably used to doing something like this: - - 1. Opening up your photo viewer or editor - 2. Scaling the image - 3. Exporting the image as a modified file - 4. Closing the application - - - -If you did this several times a day, you would probably get tired of the repetition. However, because you perform those actions in the graphical user interface (GUI), you would need to know how to script the GUI to automate it. Some applications, like [GIMP][4], have a rich scripting interface, but the process is obviously different than just adapting a bunch of commands and dumping those into a file. - -Then again, sometimes there are command-line equivalents to things you do in a GUI. Converting documents from one text format to another can be done with [Pandoc][5], images can be manipulated with [Image Magick][6], music and video can be edited and converted, and so on. It's a matter of knowing what to look for, and usually learning a new (and sometimes complex) command. Scaling images down, however, is notably simpler in the terminal than in a GUI: - - -``` -#!/bin/sh - -convert "${1}" -scale 50% `basename "${1}" .jpg`_50.jpg -``` - -It's worth investigating those bothersome, repetitious tasks. You never know how simple and fast your work is for a computer to do! - -### 5\. You distro hop - -I'm an ardent Slackware user at home and a RHEL user at work. Actually, that's not true; I'm a Fedora user at work now. Except when I use CentOS. And there was that time I ran [Mageia][7] for a while. - -![Debian on a PowerPC64 box, image CC BY SA Claudio Miranda][8] - -Debian on a PowerPC64 box - -It doesn't matter how great a distribution is; part of the guilty pleasure of being a Linux user is the freedom to be indecisive about which distro you run. At a glance, they're all basically the same, and that's refreshing. But depending on your mood, you might prefer the stability of CentOS to the constant updates of Fedora, or you might truly enjoy the centralized control center of Mageia one day and then frolic in the modularity of raw [Debian][9] configuration files another. And sometimes you turn to an alternate OS altogether. - -![OpenBSD, image CC BY SA Claudio Miranda][10] - -OpenBSD, not a Linux distro - -The point is, Linux distributions are passion projects, and it's fun to be a part of other people's open source passions. - -### 6\. You have a passion for open source. - -Regardless of your experience, if you're a Linux user, you undoubtedly have a passion for open source. Whether you express that on a daily basis through [Creative Commons artwork][11] or code or you sublimate it and just get your work done in a liberating (and liberated) environment, you're living in and building upon open source. It's because of you that there's an open source community, and the community is richer for having you as a member. - -There are lots of things I haven't mentioned. What else betrays you as a Linux user? Let us know in the comments! - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/signs-linux-user - -作者:[Seth Kenlon][a] -选题:[lujun9972][b] -译者:[译者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/seth -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tux_linux_penguin_code_binary.jpg?itok=TxGxW0KY (Tux with binary code background) -[2]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains -[3]: https://opensource.com/article/19/7/make-linux-stronger-firewalls -[4]: https://www.gimp.org/ -[5]: https://opensource.com/article/19/5/convert-markdown-to-word-pandoc -[6]: https://opensource.com/article/17/8/imagemagick -[7]: http://mageia.org -[8]: https://opensource.com/sites/default/files/uploads/debian.png (Debian on a PowerPC64 box) -[9]: http://debian.org -[10]: https://opensource.com/sites/default/files/uploads/openbsd.jpg (OpenBSD) -[11]: http://freesvg.org diff --git a/sources/talk/20191031 A Bird-s Eye View of Big Data for Enterprises.md b/sources/talk/20191031 A Bird-s Eye View of Big Data for Enterprises.md index c62169b830..23db96ce3d 100644 --- a/sources/talk/20191031 A Bird-s Eye View of Big Data for Enterprises.md +++ b/sources/talk/20191031 A Bird-s Eye View of Big Data for Enterprises.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (chai-yuan) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/talk/20191108 My Linux story- Learning Linux in the 90s.md b/sources/talk/20191108 My Linux story- Learning Linux in the 90s.md index ae9bb5c230..11ba748cc8 100644 --- a/sources/talk/20191108 My Linux story- Learning Linux in the 90s.md +++ b/sources/talk/20191108 My Linux story- Learning Linux in the 90s.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (alim0x) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/talk/20191119 Fortinet CEO- Network and security technologies give rise to security-driven networking.md b/sources/talk/20191119 Fortinet CEO- Network and security technologies give rise to security-driven networking.md new file mode 100644 index 0000000000..6a0ace8da9 --- /dev/null +++ b/sources/talk/20191119 Fortinet CEO- Network and security technologies give rise to security-driven networking.md @@ -0,0 +1,105 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Fortinet CEO: Network and security technologies give rise to security-driven networking) +[#]: via: (https://www.networkworld.com/article/3453326/fortinet-ceo-network-and-security-technologies-give-rise-to-security-driven-networking.html) +[#]: author: (Zeus Kerravala https://www.networkworld.com/author/Zeus-Kerravala/) + +Fortinet CEO: Network and security technologies give rise to security-driven networking +====== +A conversation about the future of network security with Fortinet CEO Ken Xie +The network and security industries both continue to evolve at a rate never seen before.  Historically, security and network operation teams have worked in parallel with one another, sometimes being at odds with each other's goals. + +However, that is changing as businesses rely on their networks to operate. It’s fair to say that today, for many companies, the network is the business. As this happens, network and security technologies need to be more closely aligned giving rise to the concept of security-driven networking. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][1] + +In this post, ZK Research had a chance to sit down with the co-founder and CEO of Fortinet Ken Xie to discuss the future of networking and security.  + +[][2] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][2] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +**ZK: With things like digital transformation and [5G][3] constantly changing networks, where are we in terms of security today? Is security keeping up?** + +**Xie:** Security has to always be evolving. For a long time, security was all about securing connections. First-generation [firewalls][4] were placed between a LAN and the Internet to prevent criminals from gaining access to network resources. As those connections became faster, and more data was embedded in applications, security had to switch its focus from connections to the content. That’s when the second generation of network security began, with the introduction of the [next-generation firewall] NGFW. + +While those second-generation security tools have served their purposes, they no longer meet the needs of today’s digital businesses. Security can no longer function as a moat around a castle. Instead, today’s digital networks and data are distributed across growing numbers of virtual clouds, edges, and physical devices. Data is not only highly mobile, but it is also at greater risk as the attack surface increases. And as new edge networks emerge, driven by 5G and [SD-WAN][5], the challenges will only get bigger. + +In this new digital world, security needs to not only be integrated into the network but also help drive its development. With many new networking environments, such as [multi-cloud][6], next-gen branch, and the mobile edge, the challenge many organizations face is building a consistent and manageable security framework that can span digital innovation. Achieving this requires a security-driven networking strategy that not only asks, “How do we secure this?” but also, “How will this become part of our larger security-fabric architecture?”  + +Part of the answer involves solutions that seamlessly interoperate with security deployed across the network, such as in the cloud. Security-driven networking ensures that whenever networking infrastructures evolve or expand, security automatically adapts as an integrated part of the network rather than waiting to respond to changes, as traditional overlay security solutions do, which can introduce security gaps and inefficiencies. + +Other top concerns for both networks and security are performance and interconnectivity. Network and security policies both need to follow applications at digital speeds, especially as they move across and between different connected networks. The days of bolting on security and expecting it to protect businesses and consumers are over. To keep pace with the ongoing digital transformation of our interconnected environments, security and the network will have to converge. This is the only way that threat detection and prevention can continue to span the evolving network and respond at network speeds. + +Only security-driven and security-enabled networks will be able to ensure that detection and prevention are woven into every transaction, and then follow those transactions from origin to completion to ensure they are protected along their entire data path. + +**ZK: How does [the edge][7] factor into security, both today and going forward?** + +**Xie**: Traditionally, we interacted with the cyber world through a specific interface, such as a laptop or smart device. However, in this new digital world, traditional networks are being completely transformed. [Data centers][8] are moving to the cloud. Technology is converging with our physical world in the form of smart cars and wearables and even embedded devices and interactive communities. And for that to work, data and compute services will also need to be positioned at the edge, processing data locally. And rather than relying on one or two interfaces, we are now interacting with technology everywhere. + +The number of connected things already outnumbers people and will continue to grow quickly. A smart home today can have many different edges – smart appliances, voice-activated assistants, laptops, smartphones, connected security systems such as smart locks, and entertainment systems. To provide consistent protection for all of these connections, security will have to exist simultaneously in all of them. It has to be woven directly into the infrastructure. There is really no other way for this to work. + +**ZK:** **What are some of the security challenges of the growing [WAN][9] edge?** + +**Xie:** Next-gen branches and SD-WAN are perfect examples of how second-generation security no longer supports modern networking challenges. Organizations are moving to SD-WAN because their [MPLS][10] connections are too rigid for device and application interconnectivity. Traditional hub and spoke models don’t work because the central network hub is disappearing. And while an overlay [VPN][11] solution can support meshed connections between different branch offices, encrypting traffic isn’t enough either. + +SD-WAN is a great starting point to deeply interconnect security and networking into a single solution and where Fortinet has focused. SD-WAN needs to provide connectivity plus support advanced routing protocols, such as load balancing and optimizing connections and provide advanced security. If not, that branch will become the weakest link in your security chain. By tying those elements together into a single solution, and integrating network and security management into a single interface, organizations can realize the performance and interconnectivity benefits of tying networking and security solutions together. +A Secure SD-WAN strategy not only provides business-critical SaaS and productivity applications, and enables and secures live connections between all branch and cloud environments, it can also tie the local-branch LAN to the WAN to support and secure its functions as well. A truly integrated solution can support things like true zero-touch deployment, integrated and centralized management, and advanced traffic and connection management for network and security functions. + +**ZK: How do we provide adequate security performance as the edge becomes everywhere?** + +**Xie:** As end-user devices, applications and [IoT][12] grow and converge, billions of new edges will be created. Many of these edges will create and enable new immersive technologies, such as VR and AR-based communications and interactive tools that tie multiple services together, which will further enable things like autonomous cars and smart cities.  As solutions like these continue to evolve, they will further converge the physical and cyber worlds. Transactions and decisions will need to be made in microseconds, and they will need to be made locally, which means that decision-making can no longer rely on human intervention, whether you are talking about routing traffic, reacting to a physical event or responding to a cyber threat. + +In this new digital world, performance and interconnectivity are table stakes. So network and security convergence is not just about policies and protocols. The true performance will require the implementation of specialized physical and virtual processors that can accelerate decision making. We have spent years refining specially designed security processors that provide unmatched performance at a fraction of the cost of the traditional CPUs used by other vendors. And these aren’t just limited to security. Our new SD-WAN solutions include the world’s first customized processors designed to accelerate both security and networking functions so branch offices can function at the speeds that the digital marketplace requires. +We have also taken those same specialized engineering skills and developed new virtual ASICs to provide the same level of performance acceleration in a virtual environment. These new virtual security processors provide up to two to three  times the performance of traditional virtualized security solutions. This enables us to extend full advanced security solutions to the new 5G-powered network edge and still inspect encrypted data, accelerate local decision making, and support edge networking and computing at network-required speeds. + +**ZK: Is the edge going to replace the cloud?** + +**Xie:** We are going to need both, and they are going to have to be closely aligned. But the edge is going to push digital transformation in another new direction, and organizations need to get ready for that now. +Because of transactional timing requirements, compute resources have always had to be as physically close to data as possible. Mainframes were deployed inside physical data centers for this reason. Applications forced smartphones to be faster and smarter so decisions didn’t have to be made on some remote server. Today, as we move data from the physical data center to the cloud, compute resources have been deployed there as well so that the large amounts of data being collected by today’s businesses can be processed with scale and agility. + +The next big migration of data will be to the remote edge. IoT and mobile devices will need to support immersive technologies, which will require massive amounts of data and processing power. And for those services to respond at the speeds that applications and consumers require, data and computing resources will need to be placed on edge devices. This change will not only have a significant impact on networks but on how and where we deploy and manage security. + +This will affect security in two ways. First, to secure an edge built from an enormous number of interconnected devices, security will need to focus on prevention, which is a lot harder. And second, security will need to operate natively on those edge devices. That’s because high-performance transactions will not only require immediate decision-making, but they will also be rapidly moving across any number of edge devices through new edge-based networks. If security is to keep up, it will need to be converged with the edge and live on new edge-based IoT and networking devices.   + +And even then, things like AI are going to have to be built into the next generation of security solutions to meet the performance demands of 5G networks and beyond. Which is why Fortinet has spent the past decade building, training, and refining the largest and most comprehensive artificial neural network designed for security in the world. This AI network currently includes over billions of interconnected nodes, and since its training cycles were completed, it has now taken over critical threat detection and analysis functions that previously required teams of trained researchers to accomplish. And this success is why we have now begun to weave its advanced AI technology into our portfolio of security solutions – a feat that, like our advanced security and networking processors, no other vendor is even close to replicating. + +**Now see** [**Network pros react to new Cisco certification curriculum**][13] + +Join the Network World communities on [Facebook][14] and [LinkedIn][15] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3453326/fortinet-ceo-network-and-security-technologies-give-rise-to-security-driven-networking.html + +作者:[Zeus Kerravala][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Zeus-Kerravala/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.networkworld.com/article/3203489/what-is-5g-how-is-it-better-than-4g.html +[4]: https://www.networkworld.com/article/3230457/what-is-a-firewall-perimeter-stateful-inspection-next-generation.html +[5]: https://www.networkworld.com/article/3031279/sd-wan-what-it-is-and-why-you-ll-use-it-one-day.html +[6]: https://www.networkworld.com/article/3429258/real-world-tools-for-multi-cloud-management.html +[7]: https://www.networkworld.com/article/3224893/what-is-edge-computing-and-how-it-s-changing-the-network.html +[8]: https://www.networkworld.com/article/3223692/what-is-a-data-centerhow-its-changed-and-what-you-need-to-know.html +[9]: https://www.networkworld.com/article/3248989/what-is-a-wan-wide-area-network-definition-and-examples.html +[10]: https://www.networkworld.com/article/2297171/network-security-mpls-explained.html +[11]: https://www.networkworld.com/article/3268744/understanding-virtual-private-networks-and-why-vpns-are-important-to-sd-wan.html +[12]: https://www.networkworld.com/article/3207535/what-is-iot-how-the-internet-of-things-works.html +[13]: https://www.networkworld.com/article/3446044/network-pros-react-to-new-cisco-certification-curriculum.html +[14]: https://www.facebook.com/NetworkWorld/ +[15]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191119 SD-WANs Enable Scalable Local Internet Breakout but Pose Security Risk.md b/sources/talk/20191119 SD-WANs Enable Scalable Local Internet Breakout but Pose Security Risk.md new file mode 100644 index 0000000000..00d559727b --- /dev/null +++ b/sources/talk/20191119 SD-WANs Enable Scalable Local Internet Breakout but Pose Security Risk.md @@ -0,0 +1,58 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (SD-WANs Enable Scalable Local Internet Breakout but Pose Security Risk) +[#]: via: (https://www.networkworld.com/article/3454282/sd-wans-enable-scalable-local-internet-breakout-but-pose-security-risk.html) +[#]: author: (Zeus Kerravala https://www.networkworld.com/author/Zeus-Kerravala/) + +SD-WANs Enable Scalable Local Internet Breakout but Pose Security Risk +====== + +NatalyaBurova/istock + +SD-WAN streamlines how application traffic is routed from the branch, making it easier to create local internet breakout and allowing users to access cloud services directly from the branch. In an ideal [SD-WAN][1] scenario, every remote location and device has its own local internet breakout and corresponding security services. Yet, reality looks a lot different for many companies.  + +This is something network professionals have wanted to enable for decades. The problem was that setting up local internet breakout using traditional routers was not trivial and required a tremendous amount of engineering work so most businesses, except for the ones that had high levels of technical talent shied away. The shift to cloud and edge computing has made local internet breakout almost mandatory today, so businesses have turned to SD-WAN as a simpler path to enable it. As this happens, organizations need to understand the security risks.  + +Using broadband internet services to quickly send enterprise application traffic has many benefits, but it’s also risky since it exposes users and their local networks to the untrusted public internet. As [previously mentioned][2] in another post, EMA’s [WAN Transformation research][3] found companies that exclusively relied on the native security features in their SD-WAN devices were 1.3 times more likely to have a data breach, compared to those who supplemented their SD-WAN with additional layers of security.  + +Local internet breakout is a modern approach to the SD-WAN; it provides application awareness and automation that cannot be achieved with traditional routers. However, security shouldn’t be an afterthought when deploying it. Not all local internet breakout solutions can administer application-specific security policies in real-time or keep up with SaaS/IaaS changes and updates. + +In order to deliver the highest SaaS and IaaS performance, there are several local internet breakout requirements that must be addressed: + + * Application-driven security policies must be supported for all apps running over broadband internet + * Performance must be optimized without compromising security + * Security must be enforced with an integrated firewall to safeguard the branch from potential threats + * Service chaining to next generation firewalls or cloud-delivered security services must be automated + + + +When security enforcement is positioned close to branch locations, local internet breakout can provide enterprises with the desired application performance and protection. + +That’s where moving security to the cloud comes in. Cloud-hosted security services help enterprises centralize the entire security stack in the cloud instead of deploying costly security appliances at each branch location. A cloud-hosted security stack, like [Zscaler][4] or [Check Point][5], includes next-gen firewall services, as well as intrusion detection and prevention, URL filtering, antivirus protection, sandboxing, and much more. + +By shifting away from a hub-and-spoke architecture to a cloud-enabled architecture, enterprises can reduce cost and complexity, offer a better user experience, simplify their operations, and deploy new services faster—all without compromising security.  + +Learn more about how we can help with secure local internet breakout with SD -WAN at [SilverPeak.com][6] + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3454282/sd-wans-enable-scalable-local-internet-breakout-but-pose-security-risk.html + +作者:[Zeus Kerravala][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Zeus-Kerravala/ +[b]: https://github.com/lujun9972 +[1]: https://www.silver-peak.com/sd-wan/sd-wan-explained +[2]: https://blog.silver-peak.com/integrations-are-essential-to-secure-sd-wan +[3]: https://www.enterprisemanagement.com/research/asset.php/3683/Wide-Area-Network-Transformation:-How-Enterprises-Succeed-with-Software-Defined-WAN +[4]: https://www.silver-peak.com/sites/default/files/infoctr/zscaler-silver-peak-solution-brief.pdf +[5]: https://www.silver-peak.com/sites/default/files/infoctr/silver-peak-solution-brief-point-silver-peak-1019.pdf +[6]: http://www.silverpeak.com/ diff --git a/sources/talk/20191120 3 emerging open source projects to keep an eye on.md b/sources/talk/20191120 3 emerging open source projects to keep an eye on.md new file mode 100644 index 0000000000..937dde5839 --- /dev/null +++ b/sources/talk/20191120 3 emerging open source projects to keep an eye on.md @@ -0,0 +1,102 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (3 emerging open source projects to keep an eye on) +[#]: via: (https://opensource.com/article/19/11/emerging-projects) +[#]: author: (James Mawson https://opensource.com/users/dxmjames) + +3 emerging open source projects to keep an eye on +====== +Check out these early-stage open source projects that show real promise. +![One lightbulb lit out of several][1] + +The exciting thing about open source is that nobody needs permission to try something new. That's a formula that allows new ideas to emerge all the time. + +Here are three open source projects that are still in their early stages but show real promise. + +### Glimpse + +[Glimpse][2] is a recent fork of the [GNU Image Manipulation Program][3], a well-known and long-running open source project. It's unusual in that the biggest (but not the only) reason for forking is to rebrand it. + +So what's wrong with the name GNU Image Manipulation Program? Well, it abbreviates as "gimp," and in large parts of the English-speaking world, that is a slang word with a variety of derogatory and sexual meanings. + +Headlines have characterized the problem as "[the name is offensive][4]." I'm not sure that totally nails the issue—when I dug into it, I couldn't find anyone claiming strong offense. + +What _does_ come up again and again is that people can't get a fair hearing for the application because of the name. In any kind of grown-up or professional context, the suggestion to use GIMP isn't taken seriously. For most of the world, there's probably little at stake in this, but English-speaking countries account for almost a quarter of the world's economy. That's not nothing. + +Tech journalist Bryan Lunduke thinks [Glimpse isn't ideal branding, either][5], and perhaps he has a point. But for everyone who just wants the open source option to get a fair hearing, that's a second-order concern. + +The Glimpse team has not declared any hostility to the parent project and has even shared some donation money upstream. + +One of the exciting possibilities of this friendlier brand name is that it could open the software up as an option in education settings. This would be a win for the free software movement as a whole. + +### The Editable PDF Initiative + +Anyone with a desk job eventually learns the displeasure of using multiple software packages to put together a really complex document. It's one thing to write a quick letter or article in a word processor. But when you're jugging charts, graphs, tables, data, and images between applications, databases, and programming libraries, it can be quite a headache. + +Often, people end up solving the problem by cutting-and-pasting things using the mouse—especially for the one-off jobs that crop up all the time. We do this manually, even when there are ways to automate the task, because the tools don't work the way we want them to, and different programs aren't written to talk to each other. + +Dr. Tamir Hassan is a document engineering veteran on a one-man mission to fix this with the [Editable PDF Initiative][6]. It is an open, universal standard for document files that any program could use to interact with a document or its individual elements, such as images or tables. + +Editable PDF aims to be an extension of existing PDF standards, which provide the only guarantee of consistent presentation across applications and devices. At the moment, PDF documents are basically just vector files, not built to edit at all. + +[As Dr. Hassan said recently][7]: "Perhaps you would like to edit the text in Word, but make fine adjustments to the layout in InDesign? It's very difficult to switch between different programs today, but Editable PDF, a universally editable format, will let you do exactly that." + +Editable PDF has great potential to benefit open source software in particular. In contrast to non-standard file formats, a universal format that's truly portable creates an even playing field for the best software to win. + +Moreover, one of the big barriers for Linux to go mainstream on the desktop is that so many business users feel extremely attached to Microsoft Word. The open source movement has replied by saying, "well, if we try, we could make ours just as good." But maybe the mindset we really need is, "hey, let's do something many times better." + +### Endeavour OS + +Ahh… [Arch][8]: the Linux so notorious, it became a meme. + +But there's more going on than just, "I use Arch, btw." Part of Arch's notoriety is how intimidating it can be to install. + +This is why some people have gravitated to other distributions built on Arch, such as [Manjaro][9] and—until recently—[Antergos][10]. + +When the Antergos developers had to abandon the project due to lack of time, they left quite a community behind. Out of this, [EndeavourOS][11] was born. + +EndeavourOS might be a spiritual successor to Antergos, but it's not a fork. The team has come up with a lightweight, Arch-based operating system of its own. + +So if Manjaro offers an "Arch made easy" experience, why would you install Endeavour OS? Well, while Manjaro is based on Arch, it's got quite a lot of its own thing going on as well. EndeavourOS is quite close to pure Arch—with an Xfce desktop environment and a graphical installer along for the ride. + +EndeavourOS also advertises an open and friendly community for curious beginners—its front page even says: "Stupid questions simply don't exist with us." + +In just a few months, EndeavourOS has already delivered its first stable release, but it is still an extremely young initiative. + +One thing that really appeals to me about EndeavourOS is the clarity of its ethos. Some Linuxes are all about the data center and the server room; others aim to be the most user-friendly desktop daily driver for the broadest audience. A few have an identity crisis, caught between these things. So, where does EndeavourOS fit in all this? + +This Linux is utterly unapologetic in catering to technology hobbyists, enthusiasts, and power users. It's for the amateurs, in that best and most original sense of the word—those who love what they do. Awesome. So isn't Endeavour the perfect name? + +If what you want is to roll your sleeves up and level up while still enjoying a gentle start and a friendly community, this could be a great way to go about it. + +_What other new open source projects are you keeping an eye on? Please share in the comments._ + +Explore the open source alternatives to Adobe Acrobat for reading, creating, and editing PDF files. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/emerging-projects + +作者:[James Mawson][a] +选题:[lujun9972][b] +译者:[译者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/dxmjames +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_lightbulbs.png?itok=pwp22hTw (One lightbulb lit out of several) +[2]: https://glimpse-editor.org/ +[3]: https://www.gimp.org/ +[4]: https://itsfoss.com/gimp-fork-glimpse/ +[5]: https://www.youtube.com/watch?v=CV1HZU4KFHc +[6]: https://editablepdf.org/ +[7]: https://dxmtechsupport.com.au/editable-pdf-interview +[8]: https://www.archlinux.org/ +[9]: https://manjaro.org/ +[10]: https://antergos.com/ +[11]: https://endeavouros.com/ diff --git a/sources/talk/20191120 Intel targets Nvidia (again) with GPU and cross-processor API.md b/sources/talk/20191120 Intel targets Nvidia (again) with GPU and cross-processor API.md new file mode 100644 index 0000000000..b145a22fc0 --- /dev/null +++ b/sources/talk/20191120 Intel targets Nvidia (again) with GPU and cross-processor API.md @@ -0,0 +1,80 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Intel targets Nvidia (again) with GPU and cross-processor API) +[#]: via: (https://www.networkworld.com/article/3454497/intel-targets-nvidia-again-with-gpu-and-cross-processor-api.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Intel targets Nvidia (again) with GPU and cross-processor API +====== +Intel is looking to offer a unified CPU, GPU, and platform architecture that Nvidia doesn’t have but AMD does. +Martyn Williams/IDG + +Third time’s the charm? Intel is hoping so. It released details of its Xe Graphics Architecture, with which it plans to span use cases from mobility to high-performance computing (HPC) servers – and which it hopes will succeed where its [Larrabee][1] GPU and [Xeon Phi][2] manycore processors failed. + +It’s no secret Intel wants a piece of the high-performance computing HPC action, given that it introduced the chip and other products at it Intel HPC Developer Conference in Denver, Colo., this week just ahead of the Supercomputing ’19 tradeshow. + +**Don't miss** [**10 of the world's fastest supercomputers**][3] + +[][4] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][4] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +Intel bills the Xe Graphics Architecture card as its first "exascale graphics card," based on a new 7nm architecture called “Ponte Vecchio.” Intel is splitting the Xe Architecture into three designs for different segments: [data center][5], consumer graphics cards, and AI use-cases; integrated graphics for processors; and the high-tier Xe HPC for high performance computing. + +Rather than use the large die for its graphics chips the way Nvidia and AMD do it, Intel is using the Multi-Chip Module (MCM) design that breaks up one big chip into smaller “chiplets” that are connected via a high speed fabric. This is how AMD designed the [Ryzen and EPYC CPUs][6], something Intel initially pooh-poohed but is since [adopting][7] for its Xeons. + +These modules also use other packaging technology advancements such as Foveros 3D chip-packaging technology, which allows for 3D stacking of dies and mixing of CPU, AI, and GPU processors, High Bandwidth Memory (HMB) and Embedded Multi-Die Bridge (EMIB) technology to tie the HBM packages to the compute die. + +Xe Architecture cards will also come with a new scalable fabric called XE Memory Fabric (XEMF), which ties compute and memory together with a coherent memory interface that Intel claims will allow Xe to scale to thousands of nodes. + +Kevin Krewell, principal analyst with Tirias Research, noted that this is not a brand-new graphic architecture, it’s an evolution from Intel’s integrated GPU technology that has been a part of its consumer Core CPUs for several years and has been steadily maturing. + +“This is a design that is more like traditional graphics. [Intel is starting] with their traditional integrated graphics cores and building on top of that. Larrabee tried a GPU built on a CPU. In this case they are building a ground up GPU with GPU-like features and not trying to do anything too weird. And now they've got a real GPU guy running the group,” he said. + +Krewell is referring to Raja Koduri, senior vice president of the company's Core and Visual Computing Group. Koduri has one hell of a resume. He was the brains behind AMD integrating CPU and GPU cores on one die (yet another example of AMD leading) and then went to Apple where he pioneered the [Retina display][8]. So if Intel can’t get graphics right with this guy there is no hope. + +### Taking Aim At CUDA + +One thing that has been a huge boon to Nvidia is its CUDA language for programming GPUs. Intel is taking aim and then some at CUDA with its new OneAPI programming model, which Intel designed to simplify programming across not only its GPU but CPU, FPGA, and AI accelerators as well. + +This means applications can move seamlessly between Intel's different types of compute architectures. If an application is best processed on an FPGA, then it will be processed there. Same for CPUs, GPUs, and AI accelerators. If that’s not enough, Intel has the Data Parallel C++ Conversion Tool to take CUDA code and port it to OneAPI. If they pull this off, it would be a huge advantage over Nvidia, since CUDA is only for its GPUs. + +Interestingly, Intel said OneAPI will be open-source and will also work with other vendors' hardware, although they didn’t say whose. If it ends up ported to AMD’s platform, well, that would be entertaining. + +“It’s more than a shot at CUDA because they want to replace CUDA,” said Krewell. “OneAPI is a very ambitious program, trying to combine all of the different processor elements under one umbrella API. So it’s a very aggressive program and they are building it out piece by piece.  But right now it’s at version 0.5. CUDA is at version ten. So they've got a ways to catch up.” + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][9] + +Join the Network World communities on [Facebook][10] and [LinkedIn][11] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3454497/intel-targets-nvidia-again-with-gpu-and-cross-processor-api.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/2239992/intel-nurses--black-eye--on-larrabee--as-amd--nvidia-get-to-work.html +[2]: https://www.networkworld.com/article/3296004/intel-ends-the-xeon-phi-product-line.html +[3]: https://www.networkworld.com/article/3236875/embargo-10-of-the-worlds-fastest-supercomputers.html +[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[5]: https://www.networkworld.com/article/3223692/what-is-a-data-centerhow-its-changed-and-what-you-need-to-know.html +[6]: https://www.networkworld.com/article/3321943/amd-s-road-to-the-data-center-and-hpc-isn-t-as-long-as-you-think.html +[7]: https://www.networkworld.com/article/3408177/intel-unveils-new-3d-chip-packaging-design.html +[8]: https://www.networkworld.com/article/2211314/iphone-4-s-retina-display-explained.html +[9]: https://www.networkworld.com/newsletters/signup.html +[10]: https://www.facebook.com/NetworkWorld/ +[11]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191120 What makes a programming exercise good.md b/sources/talk/20191120 What makes a programming exercise good.md new file mode 100644 index 0000000000..e924ffc090 --- /dev/null +++ b/sources/talk/20191120 What makes a programming exercise good.md @@ -0,0 +1,158 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What makes a programming exercise good?) +[#]: via: (https://jvns.ca/blog/2019/11/20/what-makes-a-programming-exercise-good/) +[#]: author: (Julia Evans https://jvns.ca/) + +What makes a programming exercise good? +====== + +I’ve been thinking about programming exercises lately, because I want to move into teaching people skills. But what makes a good programming exercise? I [asked about this on Twitter today][1] and got some useful responses so here are some criteria: + +### it’s fun + +This one is sort of self-explanatory and I think it’s really important. Programming is fun and learning is fun so I can’t see why programming exercises would need to be boring. + +### it teaches you something you care about + +I don’t think this has to strictly mean “relevant to your job right this second” – people don’t just have jobs, we also want to make art and games and fun personal projects and sometimes just understand the world around us. But it’s important to know what goals the exercise can help you with and what it’s related to! + +Some arbitrary examples: + + * take an image of something from a website and reproduce it from scratch with CSS (towards using CSS to make your own websites that look awesome) + * write a webserver from scratch without any frameworks (to learn the HTTP protocol, so that you can debug issues with a real webserver more easily) + * write a small raytracer (so you can make cool art with raytracing techniques on shaderhub!) + * write a tiny bit of assembly (as a very initial step towards understanding of what Spectre and Meltdown are even about and why we need to make all our computers run slower to prevent them) + + + +### it’s a challenge + +I don’t know if this is everyone’s experience but I often start programming exercises and get bored quickly (“oh, I know how to do this, this is boring”). For me it’s really important for the exercise to teach me something I really don’t know how to do and that’s a little bit hard for me. + +My favourite set of programming exercises is the [cryptopals crypto challenges][2] because they get harder pretty fast – by exercise #6, you’re already breaking toy encryption protocols, and by #12 you’re breaking an Actual Encryption Protocol (AES in ECB mode)! + +### you can tell if you succeeded + +It’s easy to write exercises that are too vaguely specified (“write a toy tcp stack!“). But what does that mean? How much of a TCP stack am I supposed to write? Having test cases and clear criteria for “yay! you did it! congratulations!” is really important. + +### you can do it quickly + +In less than 2-3 hours (an evening after work), say. It’s hard to find time to spend like 8 hours on an exercise unless it’s REALLY exciting. + +I also think that giving some specific real-world benchmark data seems nice (“I did this from scratch in 97 minutes”). + +### the author believes in you + +This is a bit fuzzier but very lovely – [this person on Twitter wrote][3]: + +> Similar to that, the writing is patient and gives me the impression that it believes in my ability to accomplish the task. … I learned a ton in the early days from Linux HOWTOs. Some gave me the sense that it was impossible to fail. Just follow the steps. It’s all there. + +Especially if you’re doing a somewhat challenging exercise like we talked about above, I think it’s nice for the author to believe in your! (and of course it’s crucial that they’ve actually written the exercises so that they’re _right_ and you can likely do the thing!) + +### it’s been tested + +I read the (great) biography [Dearie: The Remarkable Life of Julia Child][4] recently and one thing that stood out to me is that she _tested_ all of the recipes in Mastering the Art Of French Cooking. It took her _years_ to write the book and test the recipes and make sure that American home cooks actually had access to all the ingredients and had the. + +I don’t think all cookbook authors test their recipes, but I think testing really improves cookbooks. + +I started writing some SQL exercises (like [this prototype of one on GROUP BY][5]) a while back, and at some point I realized the big thing holding me back was that I didn’t have testers! I couldn’t find out if people were actually learning from them or not! + +This is a new thing for me because when I write blog posts I don’t test them (I barely even proofread them!). I just write them and publish and people often like them and that’s it! I said to [Amy Hoy][6] (who is amazing) on Twitter that I didn’t understand why you have to test exercises if you don’t have to test blog posts and she [pointed out][7] that people have much higher expectations for exercises than for blog posts – with the blog posts you maybe expect to learn 1-2 new facts, but with exercises you expect to actually develop a new skill! + +Also, people are often investing a lot more time in exercises (especially if they have to set up a dev environment or something!), so it’s extra important to make sure that they actually work. + +### you won’t get stuck + +It’s SO EASY to get stuck on some random irrelevant point in a programming exercise that’s totally unrelated to the skill you’re trying to learn. For example there might be an easily-avoidable mistake that you can make with the exercise and spend a lot of time debugging but it doesn’t actually teach you a lot. + +### it’s easy to get help + +If you’re doing a challenging exercise, you might want to get help from your friends / colleagues / the internet! + +Some things that can go wrong: + + * None of your friends have ever heard of the thing the exercise is teaching so you can’t talk about it with them + * The exercise expects you to be using the newest version of some software, but actually all the examples on the internet are for some older version so it’s difficult to search for help even though the exercise is technically correct + * The community around the tech used in the exercise is hostile/unhelpful + + + +One obvious way to accomplish this is by letting people use the programming language they’re most comfortable in, because they probably already know how to Google for help in that environment. + +### no time-consuming setup required + +Installing software is boring, and a lot of programming projects require installing software! A few things that can go wrong with this (though there are a lot more than this!) + + * I get a compiler error when I try to install this package on my computer + * The example actually requires some very specific package versions to work properly and if you don’t have those exact versions installed you get a bunch of cryptic errors and need to google for 3 hours to fix them + + + +This kind of thing is a huge waste of time and super demoralizing. And it’s not trivial to avoid! If you’re trying to teach someone a specific piece of software, often that software + +A few options I’ve seen or used to manage this: + + * tell people what you know works (“I’ve tested this in Mac/Linux but not Windows”) + * avoid requiring any software to be installed (“just use python”) + * use Docker to run everything + * run all the code in the person’s browser (because browsers usually do about the same thing) + * use a cloud system (so everything runs on someone else’s computer). This is what I do for my [pandas cookbook][8], which lets you run it in Binder, this really great free service for hosting Jupyter notebooks. + + + +### it’s easy to extend + +@tef has this great talk on Scratch [A million things to do with a computer!][9] which explains the 3 ideas of Scratch: + + * low floors + * wide walls + * high ceilings + + + +It sucks when you start learning something and then learn that what you can do with the Thing is very limited! It’s exciting when you learn something and see “oh, wow, there are SO MANY POSSIBILITIES, what if I did X instead?” + +### that’s a lot of things! + +The criteria we arrived at: + + * fun exercises + * that teach you something you care about + * that are challenging + * with clear success criteria + * that can be done quickly + * with no complicated setup + * and few hidden gotchas + * using a tech stack that’s easy for you to get help with + * where there’s a lot of room to grow + + + +That seems pretty hard, but it seems like a good goal to aspire to! I’m going to keep very slowly working on exercises! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/11/20/what-makes-a-programming-exercise-good/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://twitter.com/b0rk/status/1197282185230860288 +[2]: https://cryptopals.com/ +[3]: https://twitter.com/mojavelinux/status/1197323090427953152 +[4]: https://www.amazon.com/exec/obidos/ASIN/0307473414/metafilter-20/ref=nosim/ +[5]: https://joins-238123.netlify.com/aggregations/ +[6]: https://stackingthebricks.com/ +[7]: https://twitter.com/amyhoy/status/1197291805449940993 +[8]: https://github.com/jvns/pandas-cookbook +[9]: https://www.youtube.com/watch?v=vU9myNJI9l4 diff --git a/sources/talk/20191121 Cumulus Networks updates its network-centric Linux distribution.md b/sources/talk/20191121 Cumulus Networks updates its network-centric Linux distribution.md new file mode 100644 index 0000000000..77c718bde7 --- /dev/null +++ b/sources/talk/20191121 Cumulus Networks updates its network-centric Linux distribution.md @@ -0,0 +1,64 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Cumulus Networks updates its network-centric Linux distribution) +[#]: via: (https://www.networkworld.com/article/3454338/cumulus-networks-updates-its-network-centric-linux-distribution.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Cumulus Networks updates its network-centric Linux distribution +====== +Company says its Linux is to networking what Red Hat is to servers. +Thinkstock + +The [Linux][1] distribution ecosystem is pretty set, with Red Hat and Canonical in the leadership positions, followed closely by SuSe and home brews from the likes of IBM and other major vendors. Even Microsoft has its own distro for Azure users. + +And then there is Cumulus Networks, which specializes in networking software. It just released Cumulus Linux 4.0 and NetQ 2.4, its cloud network deployment and management console. With this release, Cumulus is claiming its Linux is its most stable and reliable software stack yet and NetQ is the most comprehensive end-to-end network automation product. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][2] + +Roopa Prabhu, chief Linux architect at Cumulus, said that just as Red Hat Enterprise Linux is designed for servers, Cumulus Linux is specifically designed for networking. + +**[ [Become a Microsoft Office 365 administrator in record time with this quick start course from PluralSight.][3] ]** + +"Unlike RHEL, Ubuntu or Suse, Cumulus Linux is specially designed for the unique needs of a network device, like a [data-center][4] switch," he said in an email to me. "Cumulus Linux comes packaged with drivers for data-center switch hardware, the latest and greatest in Linux-kernel networking, a rich networking protocol stack with Free Range Routing (FRR), multi-homing protocol software, networking tools and Linux defaults optimized for networking.” + +“RHEL for example, complements Cumulus Linux in the data center, rather than compete with it, allowing similar management and orchestration tools across compute and network devices," he added. + +By being native Linux, Cumulus says it provides support for all the tooling and applications of the Linux ecosystem while providing advanced networking features and support, including kernel additions for VRF, VxLAN or the upstreamed ifupdown2 network-interface manager.  + +Cumulus Linux 4.0 includes: + + * Support for 134 hardware platforms across 14 ASICs. + * Support for Mellanox’s Spectrum-2 chipset for faster performance, Broadcom’s Qumran chipset for deep buffering at the top of rack, Facebook’s Minipack – an open, modular chassis with a single 12.8TB chip, and additional campus networking platforms with Dell. + * Migration to the latest and most advanced Linux kernel for greater route scale, the latest security updates, and thousands of contributions from the broader Linux community. + * Support for SwitchDev, an open source in-kernel abstraction model, providing a standardized way to program switch ASICs and speed development time. + * Enhancements to its EVPN implementation (EVPN-PIM and EVPN multi-homing) for Layer 2/Layer3 connectivity. + * Comprehensive end-to-end automation for CI/CD workflows including simulation, validation, troubleshooting and NetDevOps practices such as Infrastructure-as-Code (IaC). + * The ability to build a single fabric across data center and campus environments enabling a common operational model. + *   + + + +Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3454338/cumulus-networks-updates-its-network-centric-linux-distribution.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3215226/what-is-linux-uses-featres-products-operating-systems.html +[2]: https://www.networkworld.com/newsletters/signup.html +[3]: https://pluralsight.pxf.io/c/321564/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fcourses%2Fadministering-office-365-quick-start +[4]: https://www.networkworld.com/article/3223692/what-is-a-data-centerhow-its-changed-and-what-you-need-to-know.html +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191121 IoT sensors must have two radios for efficiency.md b/sources/talk/20191121 IoT sensors must have two radios for efficiency.md new file mode 100644 index 0000000000..174b47e53f --- /dev/null +++ b/sources/talk/20191121 IoT sensors must have two radios for efficiency.md @@ -0,0 +1,71 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (IoT sensors must have two radios for efficiency) +[#]: via: (https://www.networkworld.com/article/3454404/iot-sensors-must-have-two-radios-for-efficiency.html) +[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) + +IoT sensors must have two radios for efficiency +====== +To extend battery life, IoT radios that send data should be powered only when there's data to send, and a second, power-sipper radio should just listen for a wake-up signal for the principal radio. Academics say they’re making progress getting that all to work. +Jorgen Norgaard / WhatAWin / Getty Images + +For the [Internet of Things][1] to become ubiquitous, many believe that inefficiencies in the powering of sensors and radios has got to be eliminated. Battery chemistry just isn’t good enough, and it’s simply too expensive to continually perform truck-rolls, for example, whenever batteries need changing out. In many cases, solar battery-top-ups aren’t the solution because that, usually-fixed, technology isn’t particularly suited to mobile, or impromptu, ad hoc networks. + +Consequently, there’s a dash going on to try to find either better chemistries that allow longer battery life or more efficient chips and electronics that just sip electricity. An angle of thought being followed is to wake-up network radios only when they need to transmit a burst of data. Universities say they are making significant progress in this area. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][2] + +“The problem now is that these [existing] devices do not know exactly when to synchronize with the network, so they periodically wake up to do this even when there’s nothing to communicate,” explains Patrick Mercier, a professor of electrical and computer engineering at the University of California, San Diego, in a [media release][3]. “By adding a wake-up receiver, we could improve the battery life of small IoT devices from months to years,” he says. + +[][4] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][4] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +### Wake-up + +The school says that the key to getting the wake-up receivers to be useful is to implement them at very high frequencies. The reason: everything gets smaller, including antennas the higher in spectrum one goes. It “allowed researchers to shrink everything, including the antenna, transformer and other off-chip components down into a much smaller package,” the school explains. The school’s solution is at 9 GHz, in X Band. + +The device functions using specific radio signals, called a wake-up signature, being directed at an IoT sensor’s dedicated wake-up receiver chip. That radio can operate with less energy consumption than the data radio chip because its only purpose is to listen for the wake-up signature. UC San Diego’s device uses only 22.3 nanowatts. That’s around half-a-millionth of the power that an LED night light uses, the school claims. Another, more energy-consuming radio, then, which is switched on as necessary by the wake-up radio, performs the more heavy-duty tasks – like actually sending the data. + +Stanford University has also been working on IoT wake-up solutions. [I wrote about its one nanowatt, ultrasound device in 2018][5]. That’s dog-whistle-like frequency. That school, too, is working on the premise that using higher frequencies means one can design smaller electronics packages. The university claimed then on its website that its chip used “about a billionth the power it takes to light a single old-fashioned Christmas bulb.” + +Importantly, both universities’ solutions allow the actual power-hog data radio to be off while not in use, not just dormant or sleeping as is common now. + +### High sensitivity + +UC San Diego believes its X Band device has advantages over anything that has come before on two additional counts. It explains that its design performs well in varied ambient temperatures: It claims usability from 14 F to 104 F. That temperature range means wake-up could be used in implementations outside, such as in the maritime vertical, for example. + +The university also says its sensitivity numbers are the best that have ever been [published in a study][6] at -69.5 dBm. Latency is a trade-off, though, as there’s a 540ms delay. But that’s likely not a problem for much IoT use, like short burst, periodic data sends, such as are used for environmental sensing, for example. + +“These numbers are pretty impressive in the field of wireless communications. Power consumption that low, while still retaining temperature robustness, all in a small, highly sensitive system,” Mercier says. "This will enable all sorts of new IoT applications.” + +Join the Network World communities on [Facebook][7] and [LinkedIn][8] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3454404/iot-sensors-must-have-two-radios-for-efficiency.html + +作者:[Patrick Nelson][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Patrick-Nelson/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3207535/what-is-iot-how-the-internet-of-things-works.html +[2]: https://www.networkworld.com/newsletters/signup.html +[3]: https://ucsdnews.ucsd.edu/pressrelease/new-chip-for-waking-up-small-wireless-devices-could-extend-battery-life +[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[5]: https://www.networkworld.com/article/3254200/small-wake-up-receivers-could-extend-iot-sensor-life.html +[6]: https://ieeexplore.ieee.org/document/8890666 +[7]: https://www.facebook.com/NetworkWorld/ +[8]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191121 Three-course professional specialization aims to close the gap between the use and understanding of open source in business.md b/sources/talk/20191121 Three-course professional specialization aims to close the gap between the use and understanding of open source in business.md new file mode 100644 index 0000000000..c2f840d1b5 --- /dev/null +++ b/sources/talk/20191121 Three-course professional specialization aims to close the gap between the use and understanding of open source in business.md @@ -0,0 +1,115 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Three-course professional specialization aims to close the gap between the use and understanding of open source in business) +[#]: via: (https://opensource.com/article/19/11/open-source-management-course) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) + +Three-course professional specialization aims to close the gap between the use and understanding of open source in business +====== +Quickly climb the learning curve of open source with lessons distilled +from experienced practitioners. +![Coding on a computer][1] + +Even though open source software (OSS) is pervasive in IT, many people in business don't understand what open source is and how it differs from proprietary software. [According to Brandeis University][2], "open source software now accounts for between 78% and 98% of all core digital infrastructure, yet few organizational managers understand the business behind it." + +In an effort to close the gap between open source usage and understanding, Brandeis and the [Open Source Initiative][3] (OSI) have launched a three-course specialization in [Open Source Technology Management][4]. After attending an information session about the new program at [All Things Open 2019][5], I was eager to learn more about it and how it will be delivered and assessed, so I reached out to the leadership at Brandeis and the OSI over email for more information. (The interview has been slightly edited for length and clarity.) + +**Don Watkins:** **How will the course prepare students to successfully deploy open source software and effectively engage in open source production?** + +[**Patrick Masson**][6]**,** **OSI general manager and board director:** The OSI receives many questions from all sorts of organizations—companies, governments, non-profits—and individuals who are just beginning to explore open source software. Many of these inquiries share a few common themes around acquisition, implementation, support, and development, such as: How do we "buy" open source software, and where do we send the RFP? Do we need to hire a programmer if we use open source software? Will the open source project provide end-user or technical support? + +The OSI hopes the courses can prepare students by introducing the business case for open source, including business models, the value proposition, organizational practices, and operational and community processes. There are actually three courses: [The Business of Open Source][2], [Open Source Community Development][7], and [Open Source Development Fundamentals][8]. + +**DW:** **How will students be challenged to assess traditional organizational practices and measure their capacity to manage reform in light of the differences presented by open source? Can you teach open source? How do you assess community building? Can it be assessed?** + +[**James Vasile**][9]**, Open Source Technology Management faculty:** I don't want to frame these classes as presenting an approach in opposition to traditional development models. Free and open source software (FOSS) is its own way of fostering technical collaboration. To think of it as "reform" or to define it in terms of other models is to miss the point. Open source strategies are useful, and they often appear right alongside other approaches. + +Open source is a range of practices, a set of licenses, a diverse community, a strategic approach, and even an ethos. There's no one thing to teach. Rather, it's a whole field. Engaging that field can be useful if you know what you're doing. Right now, the primary way people learn the field is by spending a decade contributing to open source efforts. We are distilling the lessons learned by many experienced practitioners and trying to help people climb the learning curve quicker. + +Metrics are, of course, a huge topic in the FOSS world right now. There's no one-size-fits-all way to measure or assess community health and growth. What we do have is a set of context-specific indicators that can fit narratives. These indicators tell you where to dig. You don't know whether you've struck truth or not until you get below the surface. + +**PM:** I'll echo James' comments. From an OSI perspective, we see successful open source projects using a variety of tools and techniques for governance and decision-making, communication and collaboration, community development, project management, design and development, etc. There is no single path to open source, so rather than telling students "how" to do open source, I am hoping we can help students understand "what" makes open source. I think it's about behavior and principles vs. step-by-step processes. + +That's not to say that working with open source software and communities won't introduce change into how organizations operate. Many examples exist. If an organization has formal procurement processes, it may need to reassess how to include open source options that may not be able to participate in typical RFI/RFPs. If an organization is accustomed to driving development around their technologies, they will need to adjust their practices to work with communities. + +One of the really exciting things the courses can provide is real-world case studies that exemplify how organizations—companies, governments, etc.—are successfully engaging with, contributing to, and developing open source software. Each of these companies, I expect, will have discovered unique approaches, but I suspect there will be common themes. The students will learn to identify and understand those so they can take them back to their own organizations. + +**DW:** **What best practice models will be used?** + +**PM:** Each faculty member will employ teaching methods they are most comfortable with. Brandeis also has a fantastic instructional design group that can help faculty develop the courses, create learning resources, and design activities. + +As to the course content, the courses will introduce successful open source projects, as well as provide case studies showing companies that are successful in their adoption of open source. Students will look at what the companies are doing to create community, raise awareness and adoption, manage development, and all the other things vital to open source communities of practice. Then students are tasked to find common themes, shared practices, and even unique traits. These will inform their own work as they move into open source careers. + +[**Carol Damm**][10]**,** **director of programs and assessment for graduate professional studies at Brandeis:** As Patrick explained, students will review examples or case studies of OSS adoption. This is an established teaching approach that enables students to apply the concepts that they are learning to real-world situations. + +**DW:** **How will students learn about the community? Will there be opportunities for them to join open source communities as members? How?** + +**PM:** We have a dedicated course, "[Open Source Community Development][7]," that is designed to help students understand the various roles in communities of practice supporting open source software development, adoption, and maintenance. + +This course presents a great opportunity to have students involved in open source communities as part of the course. The students may not be contributing directly to the projects, but they can do field observations. Getting students to engage with projects to discover how they share information, foster communication, manage financials, make decisions, and all the other critical practices that open source communities need to be successful. + +I'll also offer that the courses can incorporate any open source projects students' companies may be working with—especially if internal contributions are being made upstream. This would provide a powerful opportunity to assess the issues the students' companies are going through, how they resolved them, and what remains. + +**DW: The production of open, distributed, and community-driven software requires design and development methodologies and workflows that support the advantages of peer-to-peer, highly collaborative, iterative production. How will that be facilitated?** + +**CD**: The intent is to create activities and assignments around the workflow and processes that are part of the OSS organizational practices. These activities and assignments will require students to collaborate, creating a relational experience, common to the OSS community. + +**[Ken Udas][11], Open Source Initiative program chair at Brandeis**: Learning is an iterative process and will be facilitated in these courses through exposure to the practice of experienced faculty members and guest lecturers to guide hands-on practice. Although the activities will be determined and developed by the teaching staff, we all want the students to leave with the benefit of practicing under the guidance of knowledgeable practitioners and teachers. + +So, in a particular class, the production process might be introduced through a semester-long case study, perhaps based on an active OSS community or a situation in which there is an internal development or perhaps an effort within an organization to adopt an open source technology and contribute to a community. We are committed to having the teacher and course designer build learning experiences that expose students to practice such that learning can be meaningfully facilitated and iteratively applied. This process will be unique for each teacher. In short, the learner will participate in learning experiences that are facilitated by the instructor with OSS experience, based on practice. + +Iterative and peer-based production in the courses is promoted through exposure through faculty modeling and observation of active OSS communities in practice. Iterative methodologies will be embedded in weekly forum activities and assignments in each course. In addition, it is important to remember that the course itself is subject to interactive development and improvement. Students will also be expected to contribute, using iterative design principles, to the ongoing development of the course along with the teacher and staff. + +**DW:** **What metrics will be used to assess the effectiveness of instruction? How will credit be assigned? What will assessments look like?** + +**CD:** The students will work collaboratively on assignments that present cases either that are given to them or of their choosing, depending on the course, in which they apply the practice that they are learning about. Problem-based learning is a student-centered approach that creates a space for critical thinking and collaborative work. These assignments are graded and aligned to the course outcomes to evaluate students' achievement. + +**KU:** Instructional effectiveness is a matter of student assessment and self-assessment, which is also reflected in the success of learners, as illustrated through the products created during the class. Although the assessments will vary from class-to-class and teacher-to-teacher, they will take the form of artifacts and evidence of methodology in practice. Credit within the class will be in large part determined by the course developer and learning designer but will generally be a balance between group and individual assignment. + +**DW:** **What** **are** **the** **outcomes for students? An MBA focus? Digital badges?** + +**CD: **With the completion of the three courses, students will receive a digital credential in the form of a badge that will carry the details of the credential in its metadata. + +**DW:** **What's in it for the Open Source Initiative? What are the takeaways for the OSI?** + +**PM:** These courses fit squarely into the OSI's mission to "educate about and advocate for the benefits of open source and to build bridges among different constituencies in the open source community." We currently have several other educational initiatives, for example, in K-12 ([FLOSS Desktops for Kids][12]) and for government ([Open Source and Standards Working Group][13]). + +While the OSI has always been active in education and advocacy, our interest in formal educational opportunities was sparked after reading the [Open Source Program Management 2018 Survey][14]. Its key findings highlighted a growing demand for professionals, not necessarily from technical backgrounds, who may be supporting open source within a company: HR staff hiring for roles that support external projects, procurement officers and contract managers who need to engage open source communities, project and product managers who need to work with external organizations, budgeting staff who need to assess ROI on open source implementations. Where are students from MBA or marketing and communications programs, who are interested in working with technology, learning about open source software? + +There are a small but growing number of individual faculty and departments within colleges and universities that include open source software development in their curriculum—usually for technical programs (e.g., CompSci, EE)—however, open source specializations for non-technical disciplines are rare. I only know of [one][15]. The Brandeis specialization allows us to introduce open source into traditional academic programs. + +The Brandeis specialization also allows us to introduce open source to non-traditional learners. The OSI also needs to help the self-directed, self-motivated learners who may have discovered open source software and development through their own personal educational experiences. One of the great opportunities, rightly, touted by open source advocates is access to "learning by doing" made possible through open source communities. Open source projects can reduce barriers to access, allowing non-traditional students to learn to program, discover the latest technologies, gain new skills, even network to build professional relationships. Again, these opportunities are not limited to those seeking technical skills. Open source projects rely on those with business, finance, marketing, communications, and many other skills. Brandeis will also be offering the three courses as a digital badge for individuals who may not be interested in a degree program. + +The OSI recognizes that open source now spans all industries and impacts every department within the organization, from simple end users to maintainers of internally developed projects. The OSI wants to help both those seeking careers in open source and the industries that need those professionals. As a trusted source and recognized authority within the open source community, we feel we can provide guidance on the design and development of courses and content and lend credibility to assure both students and employers that the program will provide a quality, relevant, educational experience. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/open-source-management-course + +作者:[Don Watkins][a] +选题:[lujun9972][b] +译者:[译者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/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: https://www.brandeis.edu/gps/future-students/learn-about-our-programs/open-source-technology-management.html#business +[3]: https://opensource.org/ +[4]: https://www.brandeis.edu/gps/future-students/learn-about-our-programs/open-source-technology-management.html# +[5]: https://allthingsopen.org/ +[6]: https://www.linkedin.com/in/patrick-masson-4a09b53/ +[7]: https://www.brandeis.edu/gps/future-students/learn-about-our-programs/open-source-technology-management.html#community +[8]: https://www.brandeis.edu/gps/future-students/learn-about-our-programs/open-source-technology-management.html#development +[9]: https://www.linkedin.com/in/jamesvasile/ +[10]: https://www.linkedin.com/in/carol-damm-id/ +[11]: https://www.brandeis.edu/facultyguide/person.html?emplid=9ea81c0b94ebc262f10d2065827733c2e903cafd +[12]: https://opensource.com/article/17/9/floss-desktops-kids +[13]: https://wiki.opensource.org/bin/Working+Groups+%26+Incubator+Projects/OSandStandardsWG/ +[14]: https://todogroup.org/blog/survey-2018/ +[15]: https://www.rit.edu/study/free-and-open-source-software-and-free-culture-minor diff --git a/sources/talk/20191125 8 ways to prepare your data center for AI-s power draw.md b/sources/talk/20191125 8 ways to prepare your data center for AI-s power draw.md new file mode 100644 index 0000000000..2b05df201a --- /dev/null +++ b/sources/talk/20191125 8 ways to prepare your data center for AI-s power draw.md @@ -0,0 +1,142 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (8 ways to prepare your data center for AI’s power draw) +[#]: via: (https://www.networkworld.com/article/3454626/8-ways-to-prepare-your-data-center-for-ai-s-power-draw.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +8 ways to prepare your data center for AI’s power draw +====== +Artificial intelligence requires greater processor density, which increases the demand for cooling and raises power requirements. +Thinkstock + +As artificial intelligence takes off in enterprise settings, so will data center power usage. AI is many things, but power efficient is not one of them. + +For data centers running typical enterprise applications, the average power consumption for a rack is around 7 kW. Yet it’s common for AI applications to use more than 30 kW per rack, according to data center organization [AFCOM][1]. That’s because AI requires much higher processor utilization, and the processors – especially GPUs – are power hungry. Nvidia GPUs, for example, may run several orders of magnitude faster than a CPU, but they also consume twice as much power per chip. Complicating the issue is that many data centers are already power constrained. + +**READ MORE:** [Do you really need high performance computing?][2] + +Cooling is also an issue: AI-oriented servers require greater processor density, which means more chips crammed into the box, and they all run very hot. Greater density, along with higher utilization, increases the demand for cooling as compared to a typical back-office server. Higher cooling requirements in turn raise power demands.  + +[][3] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][3] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +So what can you do if you want to embrace AI for competitive reasons but the power capacity of your existing facility isn’t up to the high-density infrastructure requirements of AI? Here are some options. + +### Consider liquid cooling + +Fan cooling typically loses viability once a rack exceeds 15 kW. Water, however, has 3,000 times the heat capacity of air, according to [CoolIT Systems][4], a maker of enterprise liquid cooling products. As a result, server cabinet makers have been adding liquid pipes to their cabinets and connecting water piping to their heat sinks instead of fans. + +“Liquid cooling is definitely a very good option for higher density loads,” says John Sasser, senior vice president for data center operations at [Sabey][5], a developer and operator of data centers. “That removes the messy airflow issue. Water removes a lot more heat than air does, and you can direct it through pipes. A lot of HPC [high performance computing] is done with liquid cooling.” + +Most data centers are set up for air cooling, so liquid cooling will require a capital investment, “but that might be a much more sensible solution for these efforts, especially if a company decides to move in the direction [of AI],” Sasser says. + +### Run AI workloads at lower resolutions + +Existing data centers might be able to handle AI computational workloads but in a reduced fashion, says Steve Conway, senior research vice president for [Hyperion Research][6]. Many, if not most, workloads can be operated at half or quarter precision rather than 64-bit double precision. + +“For some problems, half precision is fine,” Conway says. “Run it at lower resolution, with less data. Or with less science in it.” + +Double-precision floating point calculations are primarily needed in scientific research, which is often done at the molecular level. Double precision is not typically used in AI training or inference on deep learning models because it is not needed. Even Nvidia [advocates][7] for use of single- and half-precision calculations in deep neural networks. + +### Build an AI containment segment + +AI will be a part of your business but not all, and that should be reflected in your data center. “The new facilities that are being built are contemplating allocating some portion of their facilities to higher power usage,” says Doug Hollidge, a partner with [Five 9s Digital][8], which builds and operates data centers. “You’re not going to put all of your facilities to higher density because there are other apps that have lower draw.” + +The first thing to do is assess the energy supply to the building, Hollidge says. “If you are going to increase energy use in the building, you’ve got to make sure the power provider can increase the power supply.” + +Bring in an engineer to assess which portion of the data center is best equipped for higher density capabilities. Workload requirements will determine the best solution, whether it be hot aisle containment or liquid cooling or some other technology. “It’s hard to give one-size-fits-all solution since all data centers are different,” Hollidge says. + +### Spread out your AI systems + +An alternative approach – rather than crowding all your AI systems into one spot hotter than Death Valley in August – is to spread them out among the racks. + +“Most of the apps are not high density. They run at eight to 10 kilowatts and up to 15 kilowatts. You can handle that with air,” says David McCall, chief innovation officer with [QTS][9], a builder of data centers. + +In an optimized heterogeneous environment, a collocation provider might have a rack or two in a cabinet to host an HPC or AI environment, and the rest of the racks in the cabinet are dedicated to hosting less power-hungry applications, such as databases and back-office apps. That won't yield a 5 kW rack, but it gets a rack closer to 12 kW or 15 kW, which is an environment that air cooling can handle, McCall says. + +### Control hot air flow in the data center + +Standard data center layout is hot aisle/cold aisle, where the cabinets are laid out in alternating rows so that cold air intakes face each other on one front-facing aisle, and hot air exhausts face each other on the alternating back-facing aisle. That works fine, but access can be tricky if an IT worker needs to get behind a cabinet to work on a server. + +The other problem is that air is “messy,” as Sasser put it. Power is often easier to model because it flows through conductors, and you can control (and thus plan and model) where power goes. Air goes where it wants and is hard to control. + +Sabey customers that want higher density environments use a hot aisle containment pod to control air flow. The company puts doors at the end of the hot aisle and plastic plates over the top, so heat is directed into a ceiling intake pipe and the barriers keep hot air and cold air from mixing. + +"In an air-cooled server world, the advice I give is go with a hot aisle containment environment,” Sasser says. "The other advice I would give is make sure the data center is tested for air flow, not just modeled for airflow. Modeling is dependent on a lot of variables, and they easily change." + +### Consider a chimney cabinet + +Another way to help manage temperatures in data centers is to use a chimney cabinet. Instead of venting the hot air out the back, a chimney cabinet uses good old physics convection to send hot air up into a chimney, which is then connected to an air conditioning vent. [Chatsworth Systems][10] is best known for this style of cabinets. + +“The air pathway is more constrained this way,” Sasser says. “Since that air pathway is more constrained, you can get greater density into a cabinet than with a hot aisle pod.” + +### Process data where it resides + +Moving data around has a very high energy cost: It can take up to 100 times more energy to move data than it takes to process data, Conway says. Any form of data movement requires electricity, and that power drain increases with the volume of data – a significant issue for data-intensive AI applications. “You want to move data as rarely and as little distance as you can,” Conway says. + +“The solution is not to have to move the data any more or further than is absolutely necessary. So people are striving to put data closer to where it is processed. One thing cloud services providers and people who use cloud services agree on is it doesn’t make sense to move a massive amount of data to a third-party cloud,” he says. + +### Consider leasing data center space + +Most of the companies looking to implement AI are corporations that lease data center space from a data center operator, Hollidge says. There are some data center operators that are not capable of handling high density AI computation, but some have transitioned to offering a portion of high density environments for AI. + +“You might have to go through a few providers before finding it, but there is more attention being paid to that on the data center operations side,” Hollidge says. And a third-party data center provider gives you more growth options. “Most of the time you are better off entering into a flexible lease that allows you to expand and grow your AI business as opposed to building ground up.” + +### Wait for next-generation servers + +Supercomputers to date haven’t been very data friendly, Conway says. As supercomputers have gotten bigger, the designs have gotten less data-centric. The result is that more data has to be moved around and shuttled between processors, memory, and storage systems. And as discussed above, it costs more power to move data than to process it. + +The first exascale systems will come with more accelerators and more powerful interconnections for moving around data. And many innovations that start in supercomputing, including GPUs and storage-class memory (SCM), eventually work their way down to more mainstream servers. + +Future servers also will come with a more heterogeneous chip layout; instead of all x86 CPUs, they will include GPUs, FPGAs, and AI accelerators. And for high speed storage, NVMe-over-Fabric and SCM will become more affordable. Servers are set to change in the coming years, and many of the advances will benefit enterprise AI application environments. + +**Learn more about HPC and supercomputers** + + * [HPE to buy Cray, offer HPC as a service][11] + * [Decommissioning the Titan supercomputer][12] + * [10 of the world's fastest supercomputers][13] + * [What’s quantum computing and why should enterprises care?][14] + * [Who’s developing quantum computers?][15] + + + +Join the Network World communities on [Facebook][16] and [LinkedIn][17] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3454626/8-ways-to-prepare-your-data-center-for-ai-s-power-draw.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://www.afcom.com/ +[2]: https://www.networkworld.com/article/3444399/high-performance-computing-do-you-need-it.html +[3]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[4]: https://www.coolitsystems.com/ +[5]: https://sabeydatacenters.com/ +[6]: https://hyperionresearch.com/ +[7]: https://devblogs.nvidia.com/mixed-precision-training-deep-neural-networks/ +[8]: https://five9sdigital.com/ +[9]: https://www.qtsdatacenters.com/ +[10]: https://www.chatsworth.com/en-us/products/families/teraframe +[11]: https://www.networkworld.com/article/3396220/hpe-to-buy-cray-offer-hpc-as-a-service.html +[12]: https://www.networkworld.com/article/3408176/the-titan-supercomputer-is-being-decommissioned-a-costly-time-consuming-project.html +[13]: https://www.networkworld.com/article/3236875/embargo-10-of-the-worlds-fastest-supercomputers.html#slide1 +[14]: https://www.networkworld.com/article/3275367/what-s-quantum-computing-and-why-enterprises-need-to-care.html#nww-fsb +[15]: https://www.networkworld.com/article/3275385/who-s-developing-quantum-computers.html +[16]: https://www.facebook.com/NetworkWorld/ +[17]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191125 My journey to becoming an open source maintainer.md b/sources/talk/20191125 My journey to becoming an open source maintainer.md new file mode 100644 index 0000000000..aee390002d --- /dev/null +++ b/sources/talk/20191125 My journey to becoming an open source maintainer.md @@ -0,0 +1,251 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (My journey to becoming an open source maintainer) +[#]: via: (https://opensource.com/article/19/11/journey-open-source-maintainer) +[#]: author: (Juliano Alves https://opensource.com/users/juliano) + +My journey to becoming an open source maintainer +====== +Hacktoberfest got me thinking. My first contribution to open source was +challenging, but everything I've learned since then has made me a better +developer. +![Guy on a laptop on a building][1] + +[Hacktoberfest][2] is an initiative that invites developers from around the world to participate and contribute to open source. This is the second year in a row that I participated to completion of the challenge, and I was so inspired by it that I want to share my slightly longer journey to open source software. + +### A long time ago, in a galaxy far, far away… + +The year was 2010. The universe made its move to make me cross paths with my good friend, [Jonas Abreu][3]. Jonas is the creator of [Mirror][4], a simple domain-specific language (DSL) layer over the Java Reflection API, which makes [meta-programming][5] easier. There was a feature request open for a proxy creation capability, and Jonas asked me if I was interested in implementing it. I accepted the challenge. + +I suffered for three days, dealing with code that I didn’t understand… until I did. I still remember the feeling that my triumph brought me that day. That pain was knowledge invading my brain! + +This code was my first contribution to open source. I took quite a lot away from my experience contributing to Mirror: + + * A lot about Java meta-programming + * The concept of proxy classes + * [Javassist][6] and [cglib][7] frameworks + * How to receive and provide useful and respectful feedback + * How to design a tool that will be used by others + * Some interesting [dark magic][8] + + + +Most importantly, I took away a sense of purpose. I love the idea of contributing to the greater good while challenging myself and working with brilliant engineers who were way smarter than me. + +### Exploring ways to contribute to open source + +I started taking part in community initiatives, like running coding dojos. While doing this, I met more great devs, and we started a small group. At some point, that group decided to learn Scala. We studied and coded together, and eventually started [Scaladores][9], the Scala user group of São Paulo. + +Eventually, Jonas started talking about a different approach for learning, called [deliberate practice][10]. + +> _What if we could put all this recently acquired knowledge altogether?_ + +The resulting project from studying this practice is [Aprenda][11], a learning platform that mixes gamification and deliberate practice to make it easier to learn HTML, regular expressions, or Git. Building something this significant felt like leveling up in my pursuit of open source contribution. I also found that I picked up more knowledge about programming and practices to motivate both others and myself.  + +As much as I enjoyed this pursuit, I couldn’t dedicate a lot of time to this project. At the same time as I was making progress on Aprenda, I had to shift focus to a new job. + +### Contributing through my own Ruby gem + +My new work had me in a common pattern: Every problem was solved by writing code that creates, reads, updates, or deletes data (CRUD). It gave me an idea, so I started a new project. I wanted to generate code the same way Ruby on Rails, a powerful web framework, allowed me to set up an environment with a simple command: **rails g scaffold**. Using [Thor][12], the same gem that powers Rails generators, I created [Spring MVC Scaffold][13]. Now, any time I needed to create a CRUD I typed: + + +``` +$ springmvc scaffold product name:string value:double active:boolean +``` + +The code I wrote reducing the work my team had to do to get their job done, and I shared it further by posting it publicly. Here are some of the highlights of what I learned: + + * Generating code and files with Thor + * Defining commands for a CLI + * Organizing Ruby lib code + * Creating a Ruby gem + * Building projects with [Travis CI][14] + * Publishing to RubyGems + + + +> _After solving a common problem, think about making that solution available. Most likely, other people have similar problems._ + +Even though it’s not being maintained anymore, Spring MVC Scaffold is still available on [RubyGems][15]. And I tell you what, after that project, I went to work in a tech environment full of problems. + +### Shifting technology + +My new work required a shift in languages. I started working with Microsoft .NET, and I found issues that other communities had already solved. That recognition excited me because I knew it was my opportunity. My new opportunity to contribute came in the form of porting those solutions. + +#### Selenia + +[Selenium][16] is the dominate way to programmatically interact with websites as if the code is a "real" user (accessing it via a web browser). The API has always been too complex in my opinion. So I built a tool, we called Selenia, that could be used to write concise UI tests in C#, so instead of using: + + +``` +IWebDriver driver; +ChromeOptions options = [new][17] ChromeOptions(); +options.addExtensions([new][17] File("/path/to/extension.crx")); +ChromeDriver driver = [new][17] ChromeDriver(options); +driver = [new][17] ChromeDriver(); +driver.Navigate().GoToUrl(""); + +IWebElement query = driver.FindElement(By.Name("q")); +query.SendKeys("Selenium"); +query.Submit(); + +driver.Quit(); +``` + +We can write as: + + +``` +Open(""); +S(By.Name("q").Value("Selenia").Enter(); +``` + +Selenium users may have a question at this point. If you are wondering, the answer is "no." It’s not necessary to close the driver yourself. + +#### Designing for immutability with Ioget + +Immutability, which means never changing an object that already exists, makes a developer’s life easy. This opinion is a newer one, however. Back in the day, ASP.NET MVCs would recommend updating information in place. The only way to instantiate objects was via **setters**. + +I built [Ioget][18] to help with unmarshalling request parameters in web applications. HTTP request parameters are strings, so Ioget looks for the best way to parse those params according to the given class, instantiating objects via their constructors and therefore making them immutable. + +I published this project publicly to NuGet, but I never managed to integrate Ioget with ASP.NET like I intended to. I stopped working with Microsoft technology, and thus this project fell behind from its once lofty goals. + +Continuing with my deliberate practice, I kept track of the lessons learned along the way. + + * [Reification][19] + * ASP.NET MVC internals + * Monad implementation + * .NET framework internals + + + +I also took note of a pattern I used with Selenia. I really like this snippet, which I used to close the driver: + + +``` +private void MarkForAutoClose(IWebDriver driver) => +  AppDomain.CurrentDomain.DomainUnload += (s, e) => driver.Quit(); +``` + +### Contributing to Quill + +I moved to London in 2016, which paused my contributions for a while. Eventually, I watched a talk by [Gustavo Amigo][20] about his project, [quill-pgsql][21], which is an extension to support PostgreSQL data types with [Quill][22]. He mentioned that this project was in its early moments, which meant it was ideal for someone to join, and I was interested in writing in Scala. After a few pull requests, I decided to contribute to the main project. + +Quill transforms regular collection-like code into SQL queries in compile-time. I consider it the most challenging (and interesting) project I have ever contributed to. It’s been a few years since I started, and today I am [one of the maintainers][23]. + +Here’s what I learned by working on Quill: + + * Abstract syntax trees (AST) + * The Dark Arts (also known as [Scala macros][24]) + * How to make code extensible via [implicits][25] + * Exclusive and weird [SQL rules][26] + + + +Quill has a module called quill-async, which uses [an asynchronous database driver][27] that is no longer maintained. Quill’s creator, [Flavio Brasil][28], suggested that we could write a new async driver. That’s how [Non-Blocking Database Connectivity (NDBC)][29] got started. + +NDBC is a fully async alternative to Java Database Connectivity (JDBC). Its architecture was designed to provide high-performance, non-blocking connectivity to the database on top of [Trane.io Futures][30] and [Netty 4][31]: + + +``` +// Create a Config with an Embedded Postgres +Config config = Config.create("io.trane.ndbc.postgres.netty4.DataSourceSupplier", "localhost", 0, "user") +                      .database("test_schema") +                      .password("test") +                      .embedded("io.trane.ndbc.postgres.embedded.EmbeddedSupplier"); + +// Create a DataSource +DataSource<[PreparedStatement][32], Row> ds = DataSource.fromConfig(config); + +// Define a timeout +Duration timeout = Duration.ofSeconds(10); + +// Send a query to the db defining a timeout and receiving back a List +List<Row> rows = ds.query("SELECT 1 AS value").get(timeout); + +// iterate over awesome strongly typed rows +rows.forEach(row -> [System][33].out.println(row.getLong("value"))); +``` + +More knowledge was acquired along the way: + + * Understanding binary protocols + * Using Netty 4 + * Weaknesses of the Java type system + * Fully implementing functional structures + + + +That’s where I am at the moment. I divide my attention between Quill and NDBC, trying to make them work together. + +### Plans for the future + +The contributions I have in mind for the near future are implementing: + + * Array support in [Finagle Postgres][34] + * A Clojure wrapper for NDBC + * A ndbc-spring module + * A CLI in [Rust][35] + + + +I now have almost 10 years of open source in my journey, and it taught me something extremely valuable: Open source is about sharing knowledge. When I am solving an issue, I am acquiring knowledge. When I send a pull request, I am spreading that knowledge. Knowledge brings more knowledge! + +I strongly recommend that you become part of the open source community. It can be difficult, especially in the beginning, but everything you will learn will make you a better developer. I promise. + +> _Open source is about sharing knowledge. When I am solving an issue, I am acquiring knowledge. When I send a pull request, I am spreading that knowledge. Knowledge brings more knowledge!_ + +_This article was originally posted on [Juliano Alves' Programming Blog][36]. It has been edited for style and clarity._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/journey-open-source-maintainer + +作者:[Juliano Alves][a] +选题:[lujun9972][b] +译者:[译者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/juliano +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_code_programming_laptop.jpg?itok=ormv35tV (Guy on a laptop on a building) +[2]: https://hacktoberfest.digitalocean.com/ +[3]: https://twitter.com/jonasabreu +[4]: http://projetos.vidageek.net/mirror/mirror/ +[5]: https://www.ibm.com/developerworks/library/l-metaprog1/index.html +[6]: https://www.javassist.org/ +[7]: https://github.com/cglib/cglib +[8]: https://github.com/vidageek/mirror/blob/master/src/main/java/net/vidageek/mirror/provider/java/ObjenesisConstructorBypassingReflectionProvider.java +[9]: https://www.meetup.com/scaladores/ +[10]: https://jamesclear.com/deliberate-practice-theory +[11]: https://aprenda.vidageek.net/ +[12]: http://whatisthor.com/ +[13]: https://github.com/juliano/springmvc-scaffold +[14]: https://travis-ci.com/ +[15]: https://rubygems.org/gems/springmvc-scaffold +[16]: https://www.seleniumhq.org/ +[17]: http://www.google.com/search?q=new+msdn.microsoft.com +[18]: https://www.nuget.org/packages/Ioget/ +[19]: https://en.wikipedia.org/wiki/Reification_(computer_science) +[20]: https://github.com/gustavoamigo +[21]: https://github.com/gustavoamigo/quill-pgsql +[22]: https://getquill.io/ +[23]: https://github.com/getquill/quill +[24]: http://scalamacros.org/ +[25]: https://docs.scala-lang.org/tour/implicit-parameters.html +[26]: https://teamsql.io/blog/?p=923 +[27]: https://github.com/mauricio/postgresql-async +[28]: https://twitter.com/flaviowbrasil +[29]: https://ndbc.io/ +[30]: http://trane.io/ +[31]: https://netty.io/ +[32]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+preparedstatement +[33]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system +[34]: https://github.com/finagle/finagle-postgres/issues/55 +[35]: https://opensource.com/tags/rust +[36]: https://juliano-alves.com/2019/11/02/the-journey-of-an-open-source-developer/ diff --git a/sources/talk/20191126 A framework for building products from open source projects.md b/sources/talk/20191126 A framework for building products from open source projects.md new file mode 100644 index 0000000000..2a8a109e07 --- /dev/null +++ b/sources/talk/20191126 A framework for building products from open source projects.md @@ -0,0 +1,124 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (A framework for building products from open source projects) +[#]: via: (https://opensource.com/article/19/11/products-open-source-projects) +[#]: author: (Kevin Xu https://opensource.com/users/kevin-xu) + +A framework for building products from open source projects +====== +Here is a roadmap for turning a project into a commercial open source +product. +![An airplane.][1] + +My first memory of playing with a computer was through an [MS-DOS][2] terminal on the x86 PC in my grandfather's pharmaceutical research lab in the early '90s—playing games stored on 3.5" floppy disks and doing touch-typing exercises. As technology improved, I spent an obscene amount of time taking my computer apart to add more RAM, a new graphics card, or a new fan, mostly so I could play cooler games. It was a fun, ongoing project, and I bonded with my father over it. It was also way cheaper than buying a new computer. + +What's the point of this in the context of open source? + +Well, even though I had no idea what "open source" was at the time, I was behaving like a typical developer does with open source projects today—spending my free time to piece together and build things I wanted, sometimes for a specific goal, sometimes to learn new things, sometimes as a way to connect with others. + +But, over time, I stopped tinkering. For whatever reason, I decided that my time was becoming too "valuable" to retrofit my older computers. I started using a MacBook, and when my older MacBook wasn't functioning well, I paid a pretty penny for a new one with a better configuration instead of unscrewing the bottom to see if I could jam in a new RAM card. + +My behavior became more like that of an enterprise buyer—saving time and trouble by spending money. + +### An open source software project is not a product you sell + +If your experience with technology resembles mine in any way, you know intuitively that the _projects_ we [DIY][3] are not the same as the _products_ we spend money buying. + +This isn't a new observation in the open source community. + +[Stephen Walli][4], an IT industry veteran and part of the [Open Container Initiative][5], has written [numerous detailed blog posts][6] on this topic. [Sarah Novotny][7], who led the Kubernetes community and was heavily involved in the Nginx and MySQL communities, [emphatically articulated][8] at the inaugural [Open Core Summit][9] that the open source project a company shepherds and the product that a company sells are two completely _different_ things. + +Yet, project and product continue to be conflated by maintainers-turned-founders of commercial open source software (COSS) companies, especially (and ironically) when the open source project gets traction. + +This mistake gets repeated, I believe, because it's hard to mentally conceptualize how and why a commercial product should be different when the open source project is already being used widely. + +### What makes a COSS product different? + +Two core elements differentiate a commercial product from its open source root: packaged experience and buyer-specific features. + +#### Packaged experience + +Packaging your project so that it has that out-of-the-box user experience isn't just about a polished user interface (UI) or hosting it on your server as SaaS (although that could be part of it). It's an expressed opinion of how you, the creator or maintainer of the project turned founder of the company, believe the technology should be used to solve your customer's business problem. That "opinion" is essentially the product experience the customer is paying for. + +When you are running an open source community project, it's usually good to be _not_ opinionated and let your community organically flourish. When you are developing a product for customers, it's usually good to _be_ opinionated. + +It's the retrofitted x86 PC versus the MacBook dynamic. + +[Dave McJannet][10], CEO of Hashicorp, and [Peter Reinhardt][11], CEO of Segment, both cited packaging as a crucial step to get right in order to turn an open source project into a scalable commercial product. + +#### Buyer-specific features + +A well-packaged product must also have the features that are necessary for your targeted buyer to justify a purchase. What these features are depends on the profile of your buyer, but the possibilities are finite and manageable. + +An enterprise buyer, say a Global 2000, will have a relatively consistent set of features that it must have to purchase a product. ([EnterpriseReady.io][12] is a great resource about what those features tend to be.) + +A small- or medium-sized business buyer, say your local mom-and-pop bakery, that has less financial resources and people power and is more price-sensitive, will need different things to be convinced to buy. + +A consumer service monetized via ads, where your buyers are the advertisers while your users are everyday people, will be different still. + +One thing is for sure: your buyer is almost _never_ your open source community. + +Know what your buyer requires for a purchase, and package that with your expert opinion on how to solve the buyer's problem; **that's what differentiates a product from a project.** + +Sid Sijbrandij's articulation of GitLab's [buyer-based open core][13] model is a good example for enterprises. + +Certainly, other elements can be added to further the differentiation. But a packaged experience with buyer-specific features is essential. Without one or the other, your prospective customers might as well just tinker on their own for free. + +### One metric that matters: Time-to-value + +A perennially difficult thing in product development is measuring progress and establishing a data-driven framework to determine whether you are on the right path or not. I'm a fan of the One Metric That Matters (OMTM) mentality, elaborated in [_Lean Analytics_][14], where you focus on one single number (above everything else) for your current stage. This approach enforces focus and discipline among a sea of data you can gather and distract yourself with (oftentimes vanity metrics like download numbers or GitHub stars). The single metric can effectively rally your entire company around one tangible goal or mission—especially critical for an early-stage company. And the metric you focus on will be different at different stages. + +So what's the right OMTM in the early days of product development? + +I propose **time-to-value** + +"Time" here is straightforward—the lower, the better. + +"Value" needs a precise, rigorous definition that is technology- and problem-specific. Your distributed database is valuable because it can serve data with no downtime when servers fail. Your continuous integration tool is valuable because it enables application developers to push improvements faster without breaking the application. You get the idea. + +How quickly can a customer see or feel the _one core piece of value_ that you measure and optimize for? Whatever is "a sufficiently short time" depends on the use case, but given the increasing consumerization of enterprise technology, any product's time-to-value that's more than 30 minutes is probably too long. + +Finding and tightly defining that "value" is hard and iterative, but also table stakes if you are looking to build a product company around an open source project. Without a deep understanding of what that value is for your customer, there's probably not much of a company to build. + +At the end of the day, as much fun as it was to "beef up" my x86 PC, I'm pretty satisfied with my MacBook and happy to pay the premium. So don't get too enamored with the joy of tinkering if your goal is actually to sell MacBook. + +(P.S. The mental framework outlined here may not apply if you are building a consultancy or support-oriented company that services open source project users. For more expansive reading on different COSS business models, see _[_COSS business model progressions_][15]_ by Joseph Jacks.) + +_Special thanks to Sarah Novotny for her feedback on this post's draft._ + +* * * + +_This article was [previously published on COSS Media][16] and is edited and republished with permission._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/products-open-source-projects + +作者:[Kevin Xu][a] +选题:[lujun9972][b] +译者:[译者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/kevin-xu +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/206308main_image_976_946-710.jpg?itok=U6hh3EIO (An airplane.) +[2]: https://en.wikipedia.org/wiki/MS-DOS +[3]: https://en.wikipedia.org/wiki/Do_it_yourself +[4]: https://stephesblog.blogs.com/about.html +[5]: https://www.opencontainers.org/ +[6]: https://medium.com/@stephenrwalli +[7]: https://sarahnovotny.com/about/ +[8]: https://www.linkedin.com/pulse/personal-reflection-open-core-summit-kevin-xu/ +[9]: https://opencoresummit.com/#speakers +[10]: https://founderrealtalk.ggvc.com/2019/04/25/episode-23-hashicorp-ceo-dave-mcjannet-reveals-the-secrets-of-commercializing-open-source-selling-to-enterprises-and-building-successful-relationships-with-founders/ +[11]: https://www.youtube.com/watch?v=Q75V35unztw&feature=youtu.be +[12]: https://www.enterpriseready.io/# +[13]: https://www.youtube.com/watch?v=G6ZupYzr_Zg +[14]: http://leananalyticsbook.com/ +[15]: https://coss.media/coss-business-model-progressions/ +[16]: https://coss.media/deriving-product-from-open-source/ diff --git a/sources/talk/20191126 How cloud providers- performance differs.md b/sources/talk/20191126 How cloud providers- performance differs.md new file mode 100644 index 0000000000..0abb0f11b7 --- /dev/null +++ b/sources/talk/20191126 How cloud providers- performance differs.md @@ -0,0 +1,88 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How cloud providers' performance differs) +[#]: via: (https://www.networkworld.com/article/3455197/how-cloud-providers-performance-differs.html) +[#]: author: (Zeus Kerravala https://www.networkworld.com/author/Zeus-Kerravala/) + +How cloud providers' performance differs +====== +The 2019 ThousandEyes Benchmark report shows that not all cloud providers are created equal across all regions +Denis Isakov / Getty Images + +Not all public cloud service providers are the same when it comes to network performance. + +Each one’s connectivity approach varies, which causes geographical discrepancies in network performance and predictability. As businesses consider moving to the cloud, especially software-defined wide-area networks ([SD-WAN][1]) and [multi-cloud][2], it’s important to understand what each public cloud service provider brings to the table and how they compare. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][3] + +In 2018, ThousandEyes first conducted [a benchmark study assessing three major public cloud providers][4]: Amazon Web Services (AWS), Microsoft Azure (Azure), and Google Cloud Platform (GCP). The study gathered data on network performance and connectivity architecture to guide businesses in the planning stage. + +[][5] + +BrandPost Sponsored by HPE + +[HPE Synergy For Dummies][5] + +Here’s how IT can provide an anytime, anywhere, any workload infrastructure. + +[This year’s study][6] offers a more comprehensive view of the competition, with two more providers added to the list: Alibaba Cloud and IBM Cloud. It compares 2018 and 2019 data to show changes that took place year-over-year and what triggered them. + +ThousandEyes periodically collected bi-directional network performance metrics—such as latency, packet loss and jitter—from 98 user vantage points in global [data centers][7] across all five public cloud providers over a four-week period. Additionally, it looked at network performance from leading U.S. broadband internet service providers (ISPs), including AT&T, Verizon, Comcast, CenturyLink, Cox, and Charter. + +The network management company then analyzed more than 320 million data points to create the benchmark. Here are the results. + +### Inconsistencies among providers + +In its initial study, ThousandEyes revealed that some cloud providers rely heavily on the public internet to carry user traffic while others don’t. In this year’s study, the cloud providers generally showed similar performance in bi-directional network latency. + +However, ThousandEyes found architectural and connectivity differences have a big impact on how traffic travels between users and certain cloud hosting regions. AWS and Alibaba mostly rely on the internet to transport user traffic. Azure and GCP use their private backbone networks. IBM is different from the rest and takes a hybrid approach. + +ThousandEyes tested the theory of whether AWS Global Accelerator out-performs the internet. AWS Global Accelerator launched in November 2018, offering users the option to utilize the AWS private backbone network for a fee instead of the default public internet. Although performance did improve in some regions around the world, there where other instances where the internet was faster and more reliable than AWS Global Accelerator. + +Broadband ISPs that businesses use to connect to each cloud also showed inconsistencies, even in the mature U.S. market. After evaluating network performance from the six U.S. ISPs, sub-optimal routing results were recorded, with up to 10 times the expected network latency in some cases. + +**Location, location, location** + +Cloud providers commonly experience packet loss when crossing through China’s content-filtering firewall, even those from the region like Alibaba. The 2019 study closely examined the performance toll cloud providers pay in China, which has a notoriously challenging geography for online businesses. For those with customers in China, ThousandEyes recommends Hong Kong as a hosting region since Alibaba Cloud traffic experienced the least packet loss there, followed by Azure and IBM. + +In other parts of the world, Latin America and Asia showed the highest performance variations for all cloud providers. For example, network latency was six times higher from Rio de Janeiro to GCP’s São Paulo hosting region because of a suboptimal reverse path, compared to other providers. But across North America and Western Europe, all five cloud providers demonstrated comparable, robust network performance. + +The study’s results confirm that location is a major factor, therefore, user-to-hosting-region performance data should be considered when selecting a public cloud provider. + +**Multi-cloud connectivity** + +In 2018, ThousandEyes discovered extensive connectivity between the backbone networks of AWS, GCP, and Azure. An interesting finding in this year’s study shows multi-cloud connectivity was erratic when IBM and Alibaba Cloud were added to the list. + +ThousandEyes found IBM and Alibaba Cloud don’t have fully established, direct connectivity with other providers. That’s because they typically use ISPs to connect their clouds to other providers. AWS, Azure, and GCP, on the other hand, peer directly with each other and don’t require third-party ISPs for multi-cloud communication. + +With multi-cloud initiatives on the rise, network performance should be included as a metric in evaluating multi-cloud connectivity since it appears to be inconsistent across providers and geographical boundaries. + +ThousandEyes’ comprehensive performance benchmark can serve as a guide for businesses deciding which public cloud provider best meets their needs. But to err on the side of caution, businesses selecting public cloud connectivity should consider the unpredictable nature of the internet, how it affects performance, creates risk, and increases operational complexity. Businesses should address those challenges by gathering their own network intelligence on a case-by-case basis. Only then they will benefit fully from what cloud providers have to offer. + +Join the Network World communities on [Facebook][8] and [LinkedIn][9] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3455197/how-cloud-providers-performance-differs.html + +作者:[Zeus Kerravala][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Zeus-Kerravala/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3031279/sd-wan-what-it-is-and-why-you-ll-use-it-one-day.html +[2]: https://www.networkworld.com/article/3429258/real-world-tools-for-multi-cloud-management.html +[3]: https://www.networkworld.com/newsletters/signup.html +[4]: https://www.networkworld.com/article/3319776/the-network-matters-for-public-cloud-performance.html +[5]: https://www.networkworld.com/article/3399618/hpe-synergy-for-dummies.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE19718&utm_content=sidebar (HPE Synergy For Dummies) +[6]: https://www.thousandeyes.com/press-releases/second-annual-cloud-performance-benchmark-research +[7]: https://www.networkworld.com/article/3223692/what-is-a-data-centerhow-its-changed-and-what-you-need-to-know.html +[8]: https://www.facebook.com/NetworkWorld/ +[9]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191126 SASE- Redefining the network and security architecture.md b/sources/talk/20191126 SASE- Redefining the network and security architecture.md new file mode 100644 index 0000000000..c92cb9eeda --- /dev/null +++ b/sources/talk/20191126 SASE- Redefining the network and security architecture.md @@ -0,0 +1,138 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (SASE: Redefining the network and security architecture) +[#]: via: (https://www.networkworld.com/article/3481519/sase-redefining-the-network-and-security-architecture.html) +[#]: author: (Matt Conran https://www.networkworld.com/author/Matt-Conran/) + +SASE: Redefining the network and security architecture +====== +Adoption of SASE reduces complexity and overhead, improves security and boosts application performance. +Getty Images + +In a cloud-centric world, users and devices require access to services everywhere. The focal point has changed. Now it is the identity of the user and device as opposed to the traditional model that focused solely on the data center. As a result, these environmental changes have created a new landscape that we need to protect and connect. + +This new landscape is challenged by many common problems. The enterprises are loaded with complexity and overhead due to deployed appliances for different technology stacks. The legacy network and security designs increase latency. In addition, the world is encrypted; this dimension needs to be inspected carefully, without degrading the application performance. + +These are some of the reasons that surface the need for a cloud-delivered secure access service edge (SASE). SASE consists of a tailored network fabric optimization where it makes the most sense for the user, device and application - at geographically dispersed PoPs. To deliver optimum network experience everywhere you should avoid the unpredictability of the Internet core. In the requirements for SASE, Gartner recommends that this backbone should not be based on AWS or Azure. Their PoP density is insufficient. It is not sufficient to offer a SASE service built solely on a hyper-scale. + +[][1] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][1] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +There are clear benefits that can be achieved by redefining the network and security architecture. Yes, the adoption of SASE reduces complexity and overhead, improves security. It increases the application performance, but practically, what does that mean? + +[Linda Musthaler had a great example in her conversation with Andrew Thomson, Director of IT at BioIVT,][2] a provider of biological materials and scientific services to research and development organizations, who adopted Cato Networks’ SASE platform nearly two years ago: + +_“We positioned it as a platform for everything that we wanted to be able to do over the next three years with the business,” he told Linda, “The big goal, the business strategy, is growth and acquisition. We presented this as a platform, as a base service that we just had to have in place in order to leverage things like voice over IP, Office 365, Azure, cloud-based computing services, hosting servers in the cloud. Without a common core solid foundation, we wouldn't have been able to do any of those things reliably without adding staff to do monitoring or maintenance or administrative overhead.”_ + +It’s that last line – “without adding staff to do monitoring or maintenance or administrative overhead” – that I found particularly striking. So, let’s understand why SASE can be so impactful from an architectural perspective. + +**[ Now read [20 hot jobs ambitious IT pros should shoot for][3]. ]** + +### Complexity and overhead + +Traditional mechanisms are limited by the hardware capacity of the physical appliances located at the customer's site. Such mechanisms create a lag in the hardware refresh rates that are needed to add new functionality. + +Hardware-based network and security solutions build into the hardware the differentiator of the offering. Primarily, with different hardware, you can accelerate the services and add new features. There are some features that are available only on the specific hardware, not the hardware you already have onsite. In this case, heavy lifting by the customer will be required. + +As the environment evolves, we should not depend on the new network and security features coming from the new generation of an appliance. Typically, this model is inefficient and complex. It creates high operational overhead and management complexity. + +Device upgrades for new features require a lot of management. From past experience, to change out a line card would involve multiple teams. The line card might run out of ports or you may simply need additional features from a new generation. Largely, this would involve project planning, on-site engineers, design guides, hopefully, line card testing and hours of work. For critical sites to ensure a successful refresh, team members may need to be backed up. Therefore, there are many touches that need to be managed. + +### SASE – Easing management + +The cloud-based SASE enables the updates for new features and functionality without the need for new deployments of appliances (physical or virtual) and software versions on the customer side. This has an immediate effect on the ease of management. + +Now the network and security deployment can occur without ever touching the enterprise network. This allows enterprises to adopt new capabilities quickly. Once the tight coupling between the features and the customer appliance is removed, this increases the agility and simplicity for the deployment of network and security services. + +With a SASE platform, when we create an object, such as a policy in the networking domain, it is then available in other domains as well. So any policies assigned to users are tied to that user, regardless of the network location. This significantly removes the complexity of managing both; network and security policies across multiple locations, users and types of devices. Supremely, all of this can be done from one platform. + +Also, when we examine the security solution, many buy individual appliances that focus just on one job. To troubleshoot, you need to gather information, such as the logs from each device. This is what a SIEM is useful for but it can only be used in some organizations as it’s resource-heavy. For the ones who don’t have ample resources, the process is backbreaking and there will be false positives. + +In addition, SASE enables easier troubleshooting because all the data is in one common repository. You no longer have normalized data from different appliances/solution and then import the data into a database for a common view. + +### Consolidation of vendors and technology stacks + +I recall an experience from a previous consultancy, wherein we were planning the next year's security budget. The network was packed with numerous security solutions. All these point solutions are expensive and there is never a fixed price. So how do you actually plan for this? + +Some new solutions we were considering charge on the usage models which at that time we didn’t have the quantity. SASE removes these types of headaches. By consolidating services into a single provider, there will be a reduction in the number of vendors and agents/clients on the end-user device. + +Overall, there will be high complexity saving from the consolidation of vendors and technology stacks. The complexity is pushed to the cloud away from the on-premise enterprise network. The SASE fabric abstracts the complexity and reduces costs. + +From a hardware point of view: for scale and additional capacity, the cloud-based SASE can add more PoPs of the same instance. This is known as vertical scaling. This scaling can also be carried in new locations, known as horizontal scaling. + +Additionally, the SASE-based cloud takes care of intensive processing. For example, since a large proportion of internet traffic is now encrypted, malware can use encryption to evade and hide from detection. Here, each of the PoPs can perform DPI on TLS-encrypted traffic. + +Traditional firewalls are not capable of inspecting encrypted traffic. Performing DPI on TLS-encrypted traffic would require extra modules or a new appliance. A SASE solution ensures that the decryption and inspection are done at the PoP. Consequently, there is no performance-hit or the need for new appliances on the customer sites. + +### Ways to improve performance + +Network congestion resulting in dropped and out of order packets is bad for applications. Latency-sensitive applications, such as collaboration, video, VoIP and web conferencing are hit hardest because of packet drops. Luckily, there are options to minimize latency and the effects of packet loss. + +SD-WAN solutions have WAN optimization features that can be applied on an application-by-application or site-by-site basis. Along with WAN optimization features, there are protocol and application acceleration techniques that can be employed. + +On top of the existing techniques to reduce the packet loss and latency, we can privatize the WAN as much as possible. You can control the adverse and varying effects that the last mile and middle mile have on the applications by privatizing with a global backbone consisting of a fabric of PoPs. + +Once privatized, we can have more control over traffic paths, packet loss and latency. A private network fabric is a key benefit gained from SASE as it drives the application performance. + +### SASE PoP optimizations + +Each PoP in the SASE cloud-based solution optimizes where it makes the most sense, not just at the WAN edge. Within the backbone, we have global route optimizations to determine which path is the best at the current time and it can also be changed for all traffic or certain applications. + +These routing algorithms factor in the performance metrics, such as latency, packet loss and jitter. These algorithms can help in selecting the optimal route for every network packet. The WAN backbone constantly analyzes and tries to improve the performance. This is unlike internet routing that favors cost over performance. + +As everything is privatized, we have all the information to create the largest packet size and use rate-based algorithms over traditional loss-based algorithms. As a result, you don't need to learn anything, and the end-to-end throughput can be maintained. + +As each PoP acts as a TCP proxy server, certain techniques are employed so that the TCP client and server think that they are closer. Therefore, a larger TCP window is set, allowing more data to be passed before waiting for an acknowledgment. + +### Preferred egress points + +We can also define preferred egress points to exit the cloud application traffic. These could be the points closest to the customer's application instance. The optimal global routing algorithms determine the best path to the customer's cloud application instance from anywhere in the world. + +The PoPs can be collocated in the data centers directly connected to the IXP that connects to all major Infrastructures as service providers. This provides a good on-ramp to access the services from Amazon AWS, Microsoft Azure and Google cloud. + +Therefore, you can keep the traffic on the private cloud for the majority of the time. Within a SASE design, the internet is used only to provide a short hop to the SASE fabric. + +### Security – Identity-centric perimeter + +SASE converges the networking and security pillars into a single platform. This allows multiple security solutions into a cloud service that enforces a unified policy across all the corporate locations, users and data. + +SASE recommends you employ the zero-trust principles. The initial path to zero trust starts with identifying that network access is based on the identity of user, device and application. It is not based on the IP address or physical location of the device. And this is for a good reason as there is no contextual information. + +The identity of the user/device must reflect the business context as opposed to being associated with binary constructs that are completely disjointed from the upper layers. This binds the identity to the world of networking and is the best way forward for policy enforcement. This way, the dependency on IP or applications as identifiers is removed. Now, the policy can be applied consistently, regardless of where the user/device is located. At the same time, the identity of the user/device/service can be factored into the applied policy. + +The SASE stack is dynamically applied based on the identity and context while serving zero trust at strategic points in the cloud. This is what enforces an identity-centric perimeter. + +_You can learn more about SASE and how it relates to [SD-WAN architectures][4] in a recent course I’ve rolled out. The course shines the torch on various SD-WAN solutions from Silver Peak, VMware, Cisco and Cato._ + +**This article is published as part of the IDG Contributor Network. [Want to Join?][5]** + +Join the Network World communities on [Facebook][6] and [LinkedIn][7] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3481519/sase-redefining-the-network-and-security-architecture.html + +作者:[Matt Conran][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Matt-Conran/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[2]: https://www.networkworld.com/article/3453030/sase-is-more-than-a-buzzword-for-bioivt.html +[3]: https://www.networkworld.com/article/3276025/careers/20-hot-jobs-ambitious-it-pros-should-shoot-for.html +[4]: https://www.pluralsight.com/courses/sd-wan-architectures-big-picture +[5]: https://www.networkworld.com/contributor-network/signup.html +[6]: https://www.facebook.com/NetworkWorld/ +[7]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191127 Is your code inclusive.md b/sources/talk/20191127 Is your code inclusive.md new file mode 100644 index 0000000000..5cb264032b --- /dev/null +++ b/sources/talk/20191127 Is your code inclusive.md @@ -0,0 +1,70 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Is your code inclusive?) +[#]: via: (https://opensource.com/article/19/11/inclusive-design-code) +[#]: author: (Peter Cheer https://opensource.com/users/petercheer) + +Is your code inclusive? +====== +Learn how developers can support assistive technology projects and +inclusivity. +![plastic game pieces on a board][1] + +I have been involved with assistive technology for about ten years now, beginning with a stint as an assistive technology tutor with the [Kenya Society for the Blind][2]. + +Assistive technology helps improve the lives of people with cognitive, physical or sensory challenges. It comprises a wide range of hardware, specialist software such as screen readers, as well as accessibility features in general software. + +Over the ten years that I have worked with assistive technology, it has vastly improved. This is due in part to the advent of more powerful technologies, as well as better education and stronger disability rights legislation across much of the world. However, progress has been uneven and much of the legislation, well-meaning as it is, is poorly enforced, so there is still work to be done. + +[The Association for the Advancement of Assistive Technology in Europe (AAATE)][3] is an interdisciplinary pan-European association devoted to all aspects of assistive technology, such as use, research, development, manufacture, supply, provision, and policy. Following the AAATE 2019 Conference in Bologna, the association published ["The Bologna Declaration."][4] + +The declaration is a call to action "to improve access to quality assistive technology for realizing fundamental human rights and achieving the sustainable development goals in a fully inclusive manner." + +It includes a list of ten important steps in an agenda for action. These points are not specifically aimed at the open source community; they are intended for policymakers and the whole assistive technology sector. This agenda for action is well thought out and deserves to be widely read across the technology sector. + +### Examples of open source assistive technology + +A look at the projects listed at [Open Assistive][5] offers an idea of the range of open source assistive technology projects that are already out there. A good example of mainstream open source software embracing accessibility is the Mozilla Firefox web browser "reader view" feature, which removes ads, background images, and other clutter for distraction-free viewing. The spoken text option in "reader view" also aids accessibility. This feature has certainly improved my user experience and has the great advantage of being a standard option rather than an add-on. + +Some of the open source assistive tools that I have used with my clients include: + + * [Vinux][6] — a Linux distro that is optimized for users with visual impairments + * [NVDA][7] — a capable screen reader for MS Windows + * [Autohotkey][8] — automates almost anything in MS Windows by sending keystrokes and mouse clicks + * [Mulberry symbol set][9] — Mulberry symbols, or pictograms, are a set of scalable SVG graphic images designed for communications use. They are ideal for software, devices, or any online accessibility use. + + + +There is a huge range of open source assistive technology projects; one large subset that I am interested to explore is the growing list of open source assistive technology hardware projects. If you have a favorite project that you use or contribute to, share it with us in the comments! + +You can support assistive technology by encouraging users to try it, by contributing coding work to assistive technology projects, or by working on documentation and user guides. Even if they’re not working specifically on assistive technology, all developers should keep in mind the need for inclusive design in their projects. If you would like to endorse the Bologna Declaration "to raise awareness so people take action and do everything in their power to actively implementing the points on the agenda," please visit .  + +Assistive technology such as Augmented/Assisted Communication (AAC), Text-to-Speech and Speech-to-... + +Assistive technology software is any program or operating system feature designed to let a user... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/inclusive-design-code + +作者:[Peter Cheer][a] +选题:[lujun9972][b] +译者:[译者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/petercheer +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/team-game-play-inclusive-diversity-collaboration.png?itok=8sUXV7W1 (plastic game pieces on a board) +[2]: http://www.ksblind.org/ +[3]: https://opensource.com/article/19/11/www.aaate.net +[4]: https://aaate.net/the-bologna-declaration/ +[5]: https://openassistive.org +[6]: https://wiki.vinuxproject.org/ +[7]: https://www.nvaccess.org/ +[8]: https://www.autohotkey.com/ +[9]: https://mulberrysymbols.org/ diff --git a/sources/talk/20191127 Why do we contribute to open source software.md b/sources/talk/20191127 Why do we contribute to open source software.md new file mode 100644 index 0000000000..3277dcf6f8 --- /dev/null +++ b/sources/talk/20191127 Why do we contribute to open source software.md @@ -0,0 +1,97 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Why do we contribute to open source software?) +[#]: via: (https://opensource.com/article/19/11/why-contribute-open-source-software) +[#]: author: (Gordon Haff https://opensource.com/users/ghaff) + +Why do we contribute to open source software? +====== +Dive into the research supporting the open source ecosystem and +developers’ motivations for participating. +![question mark in chalk][1] + +Organizations as a whole contribute to open source software projects for a variety of reasons. + +One of the most important is that the open source development model is such an effective way to collaborate with other companies on projects of mutual interest. But they also want to better understand the technologies they use. They also want to influence direction. + +The specific rationale will vary by organization but it usually boils down to the simple fact that working in open source benefits their business. + +But why do individuals contribute to open source? They mostly see some kind of personal benefit too, but what specifically motivates them? + +### The types of motivation + +When we talk about motivations, one common way to do so is in terms of incentive theory. This theory began to emerge during the 1940s and 1950s, building on the earlier drive-reduction theories established by psychologists such as Clark Hull and Kenneth Spence. Incentive theory was originally based on the idea that motivation is largely fueled by the prospect of an external reward or incentive. + +Money is a classic extrinsic motivator. So is winning an award, getting a grade, or obtaining a certification that is likely to lead to a better job. + +However, in the 1970s, researchers began to also consider intrinsic motivations, which do not require an apparent reward other than the activity itself. Self-determination theory, developed by Edward Deci and Richard Ryan, would later evolve from studies comparing intrinsic and extrinsic motives, and from a growing understanding of the dominant role intrinsic motivations can play in behavior. + +While intrinsic motivations can come from a number of different sources, the most straightforward one is the simple enjoyment of a particular activity. You play in a softball league after work because you like playing softball. You enjoy the exercise, the camaraderie, the game itself. + +Researchers have also proposed a further distinction between this enjoyment-based intrinsic motivation and obligation/community-based intrinsic motivation, which is more about adherence to social or community norms. Maybe you don’t really like having the relatives over for Thanksgiving but you do it anyway because you know you should. + +Today’s psychology literature also includes the idea of internalized extrinsic motivations. These are extrinsic motivations such as gaining skills to enhance career opportunities—but they’ve been internalized so that the motivation comes from within rather than the desire for whatever carrot is being dangled by someone else. + +### What motivates open source developers? + +In 2012, four researchers at [ETH Zurich][2] surveyed the prior ten years of study into open source software contribution. Among their results, they were able to group study findings into the following three categories: extrinsic motivation, intrinsic motivation, and internalized extrinsic motivation—as well as some common sub-groupings within those broader categories. + +No surprise that money showed up as an extrinsic motivator. During the period studied, there were fewer large projects associated with successful commercially-supported products than is the case today. Even so, most of the open source projects the researchers examined had a significant number of contributors whose companies had paid them to work on open source. + +Career obviously goes hand in hand with pay, but is open source software any different from proprietary software development in this regard? There’s some evidence that it is. + +Lerner and Tirole [first suggested in 2002][3] that "individual developers would be motivated by career concerns when developing open source software. By publishing software that was free for all to inspect, they could signal their talent to potential employers and thus increase their value in the labor market." + +More recently, there’s been significant empirical evidence that there are career advantages to developing code and making it available for others to see and work with. It has become almost an expectation in some industry segments for job applicants to have public GitHub code repositories, which are effectively part of their resume. + +It’s reasonable to ask whether this trend has gone too far. After all, many highly qualified developers work on proprietary code. But it’s clear that, fair or not, at least some career prospects can come specifically from being an open source developer. + +Among intrinsic motivators, ideology and altruism often seem closely related. + +Free software was primarily an ideological statement at first, even if user control also had an important practical side; several researchers have found support for ideological motives in developer surveys. + +Altruism can also be a developer motive, though research on this is mixed. One paper identified the “desire to give a present to the programmer community” as a crucial pattern in open source software. But other studies have qualified the importance of altruism as a motive, especially among programmers getting a paycheck. Other work found that altruism could be a motivator but only among developers who were otherwise satisfied. + +There’s also the motivational power of fun and enjoyment, a classic intrinsic motivator. This should come as no surprise to anyone who hangs around open source developers. Almost all of them like working on open source projects. One large 2007 study determined that fun accounted for 28 percent of the effort (in terms of number of hours) dedicated to projects. One implication of this research is that activities developers typically enjoy less–tech support often tops this list–may require alternative forms of motivation. + +Much of the research into reputation as an internalized extrinsic motivator has focused specifically on peer recognition. Your reputation among your peers can be a source of your own pride, but it also signals your talent to community insiders and potential employers. The suggestion that reputation could be an important motivator in contributing to open source goes back at least as far as 1998, in Eric Raymond’s essay ["Homesteading the Noosphere."][4] However, since then, a variety of surveys have supported the idea that peer reputation is a driver for participation. + +Another motivator in this category is what researchers call "own-use value" but is more recognizably described as something like "scratch your own itch"–develop something that you want for yourself and in the process, create something valuable to others. The initial motivation essentially comes from a selfish need but that can evolve into more of an internalized desire to contribute. + +Its unsurprising research would identify own-use value as a good motivator. Certainly, the folk wisdom is that many developers get into open source by developing something they themselves need—such as when Linus Torvalds wrote Git because Linux needed an appropriate distributed version control system. + +As we’ve seen, contributors to open source software have a variety of different motivations but there are a few general threads worth highlighting in closing. + +Motivators can actually be counterproductive when a single motivator is relied upon too heavily. One study reported that developers scratching their own itch worked "eclectically," fixing bugs that annoyed them and then quitting until the next time. + +In particular, don’t expect non-extrinsic motivators to carry too much of the load. Fun isn’t a good motivator if the task is not actually fun. Altruism motivates some but it also doesn’t pay their bills. + +That said, developers do contribute for reasons that aren’t purely about money or other extrinsic reasons. Learning, peer reputation, and recognition are important to many (and not just in open source development.) Organizations should not neglect the role these can play in motivating developers and should implement incentive programs around them, such as peer reward systems. + +* * * + +This post is based on material from _[How Open Source Ate Software][5]_ (Apress, 2018) by the author. + +There are lots of non-code ways to contribute to open source: Here are three alternatives. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/why-contribute-open-source-software + +作者:[Gordon Haff][a] +选题:[lujun9972][b] +译者:[译者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/ghaff +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/question-mark_chalkboard.jpg?itok=DaG4tje9 (question mark in chalk) +[2]: https://pdfs.semanticscholar.org/7712/3726f65f8fd88126357c12cad230cc832f41.pdf +[3]: https://onlinelibrary.wiley.com/doi/abs/10.1111/1467-6451.00174 +[4]: https://pdfs.semanticscholar.org/98a6/c566a7e28a48facb664c8689607a52c57a5d.pdf +[5]: https://www.apress.com/gp/book/9781484238936 diff --git a/sources/talk/20191128 -We follow a holistic approach to drive open source adoption across the client base at Infosys.md b/sources/talk/20191128 -We follow a holistic approach to drive open source adoption across the client base at Infosys.md new file mode 100644 index 0000000000..23353b3a40 --- /dev/null +++ b/sources/talk/20191128 -We follow a holistic approach to drive open source adoption across the client base at Infosys.md @@ -0,0 +1,109 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (“We follow a holistic approach to drive open source adoption across the client base at Infosys”) +[#]: via: (https://opensourceforu.com/2019/11/we-follow-a-holistic-approach-to-drive-open-source-adoption-across-the-client-base-at-infosys/) +[#]: author: (Rahul Chopra https://opensourceforu.com/author/rahul-chopra/) + +“We follow a holistic approach to drive open source adoption across the client base at Infosys” +====== + +[![][1]][2] + +_As a global services company operating in fiercely competitive environments, Infosys has set up a well-established open source practice. **Gautam Khanna, VP & head – modernization practice, Infosys**, shares with **Rahul Chopra, editorial director, EFY Group**, how the company keeps its employees up-to-date with open source, motivates and helps them to contribute to the open source ecosystem, and more._ + +**Q. What are your thoughts about the pace at which open source software (OSS) is being adopted amongst global enterprises (Top 2000 or 5000)? Is it accelerating?** +**A.** Open source adoption in enterprises is growing more rapidly than ever. A recent global survey of IT leaders revealed that nearly 90 per cent see open source as necessary to their enterprises. Open source usage is increasingly seen in categories like cloud management, security, analytics and storage, which have historically been more associated with proprietary products. Over two-thirds of the participants in the survey have increased their open source adoption in the last 12 months, and nearly 60 per cent expect to improve adoption levels over the next year as well. + +These numbers reinforce what we have observed among our clients across industry verticals – they are using open source more than ever in their modernization journeys. This is driven by the trifecta of unmatched innovation, quality, and value that open source delivers. However, what we have also observed is that there are differing levels of adoption across verticals. The retail and communication verticals are strategically and consistently adopting open source while financial institutions are a bit more cautious in doing so. + +**Q. Are there any specific countries or geographic regions that are leading this trend?** +**A.** We see the growth as pervasive across geographies. India, for example, has some amazing stories of open source adoption in government, in initiatives like Aadhaar. + +**Q. Are you seeing an increase in the number of deals that require systems integrators (SIs) like Infosys to have expertise on various open source stacks?** +**A.** As clients look to reduce their dependence on proprietary software, manage costs, and introduce increased agility and innovation, most application modernization deals today have open source as an integral component. We see this trend only getting stronger, so building open source competencies at scale is a must for every global SI. + +**Q. In the earlier days, there were a lot of myths about open source. Some proprietary brands were deliberately spreading FUD (fear, uncertainty and doubt) too. Today, what are the common myths or other inhibiting factors that prevent firms from adopting open source?** +**A.** While the awareness and acceptability of open source has certainly increased a lot over the years, we still notice the prevalence of some myths. Most of them are related to open source support, security, enterprise scalability and reliability. + +Clients also face challenges in adopting open source at the enterprise scale – including identifying the best-fit solutions from a plethora of technologies, navigating a complex vendor ecosystem and making their open source journeys cost-neutral. In all our client conversations, we focus on debunking any myths and helping our clients make informed and optimal decisions in their open source journeys. + +**Q. How is Infosys gearing up to become a leading SI in the open source space? What new initiatives has the company taken in the last few years?** +**A.** Open source is a strong focus area for Infosys. We have established an open source practice that works with all our services lines to execute client engagements, drive internal innovation, open source contribution and talent enablement. We have a comprehensive set of service offerings – spanning open source advisory services, architecture consulting, implementation, migration and support – to help our clients accelerate open source adoption. + +Our architects bring both depth and breadth across the stack to deliver end-to-end solutions. We have built a suite of in-house tools and accelerators to further speed up open source based modernization and migration initiatives. + +We have a strong ecosystem of more than 25 partners, which helps us offer end-to-end services and a single commercial interface to our clients by bundling product subscription and support along with our application services. + +We have a razor-sharp focus on talent enablement at scale – we have over 330 open source courses, which our employees can access via our ‘learn anywhere’ platforms, and to date, over 65,000 people have been trained on open source. + +**Q. Are there any major open source case studies that you’d like to share with our audience, particularly a case study from India?** +**A.** There are several exciting case studies, none more impressive than from our own backyard – the GSTN project and the platform behind the most extensive indirect tax reforms in Indian history. This is also one of the largest and most complex in the world. + +Infosys had the privilege of designing and building this ‘population-scale’ platform using an entirely open source stack, based on fundamental principles like openness, no vendor lock-in, security, reliability, availability and scalability. The system is capable of handling some astonishing volumes – around 50,000 invoices per second and 1.2 billion invoices on the last day of filing, with extremely high availability and performance. The system has been tested to handle up to 135,000 concurrent user filings and 2,000,000 tax returns on a single day. It also collects US$ 3.7 billion of tax revenues on the peak day across 800,000 transactions. + +Case studies like GSTN showcase the power of open source in every aspect and should convince any sceptics about its suitability at the enterprise scale. + +**Q. How does your team empower or enable other teams at Infosys, when it comes to open source?** +**A.** Enablement of architects and developers across the company is one of the key responsibilities of our open source practice. There are three pillars of enablement – internal learning systems, partners and hackathons. We have dedicated open source technology trainers within the education, training and assessment team to enable employees at scale. Our partner and open source practice SMEs offer webinars on the latest topics related to their products, every week. Partner training courses and certifications are integrated with our anytime, anywhere, learning system LEX. We have a well-structured refactoring program for employees who may have adjacent skills to follow a defined learning path by getting themselves trained in at least one open source technology followed by certification. It is only after this that we deploy employees on an open source project, and post gaining hands-on experience, we tag them as open source professionals. We also run open source hackathons at the organization level. In these hackathons, that we run for multiple weeks, we do a mass enablement of our employees, post which they work on solving various industry problems using open source technologies. + +**Q. How do you ensure that your team keeps pace with the rapid changes in the open source space, and is ready to offer solutions based on the latest technology stacks?** +**A.** We have a strong team of SMEs and full-stack architects in our open source practice. A portion of our architects’ time is dedicated to learning and certifying themselves on new technologies. They are also encouraged to contribute to open source community projects. Open source SMEs participate in various forums and partner summits to share our experiences as well as learn from others experiences. They also monitor the latest trends in the industry. + +We have a strong ecosystem of partners that we work closely with in order to understand the latest enhancements in their products and how to take these forward with clients. In the hackathons that we conduct, we encourage hackers to unleash their imagination, innovate and build new solutions leveraging latest features. + +We believe in building joint solutions with our partners and in solving our clients’ business problems. We have a dedicated engineering team to explore and develop new tools and accelerators to solve client problems by embracing the latest open source technologies. For example, we have built a solution using the offline capability of Couchbase in collaboration with the Couchbase team. + +**Q. Do members of your team contribute back to the open source ecosystem too? Can you share some details?** +**A.** Yes, we do. Infosys has a structured contribution process and has created an OS Contribution Portal internally. A contributor builds a contribution and submits it for review and IP checking. Post the IP check, the contribution can be published. Infosys has contributed homegrown products like the Infosys DevOps Platform and tools like Infosys Data Rapid, NIADataRConnector, High Availability Hadoop, HBase to Hive, etc. to the open source ecosystem. + +Infosys has executed a Corporate Contributor License Agreement (CCLA) with the Cloud Native Computing Foundation (CNCF) and is actively participating in the Kubernetes project. We have made over 50 contributions in Kubernetes in the form of bug fixes, blogs and query responses. Apart from Kubernetes, Infosys has also contributed to PostgreSQL, Elastic, Couchbase, Apache Beam and Neo4J communities. Infosys has also collaborated with the Microsoft product engineering team to enable PostgreSQL and MariaDB in Azure Data Services. This is one focus area of our open source practice. There are many more contributions in the pipeline. + +**Q. Does Infosys motivate its employees to contribute back to the open source ecosystem or is it their individual decision?** +**A.** It’s both. Infosys motivates employees to contribute to the open source ecosystem. We conduct internal and external events. Kubernetes Day was organized at Infosys Bengaluru this March, where thousands of people participated. We invited some industry-level open source contributors to share their open source journey and experiences. These talks were webcast to all Infoscions across locations. We have a reward and recognition process to acknowledge and appreciate open source contributors. + +**Q. Is there a shortage of skilled professionals? Are there any specific skillsets that are badly needed, even in countries like India?** +**A.** The average age of an S&P 500 company is under 20 years, down from 60 years in the 1950s, according to Credit Suisse. This trend is accelerating and the leading reason for this is the disruptive nature of new technologies. + +As per a 2018 Gartner survey, talent shortage ranks third among the Top 5 business risks. Digital transformation initiatives have increased this pressure and companies are finding that retaining and hiring talent with niche skills is a key challenge. + +Today, just 20 per cent of the current workforce has the skills required for 60 per cent of the future jobs – those that will be available in the next five to ten years. The unprecedented scale at which new technologies are getting adopted into the mainstream due to the competitive edge they provide makes it almost impossible to find talent at scale on these technologies. + +Catering to the skills diversity needed in an organization and hiring/retaining people are key challenges. In this new harsh reality, hiring talent that is passionate about learning becomes more important than finding talent with the right skills. +At Infosys, we are trying to address this challenge through a combination of hiring and reskilling. + +**Q. What would be your advice to tech professionals who want to benefit from these opportunities but don’t know where to start?** +**A.** My advice to tech professionals is straightforward; we are living in exciting times with limitless opportunities. Never before in the history of humanity have we seen such democratization of knowledge and technology, as today. There is no defined starting line, but what is most important is to learn and apply the knowledge in real business problems continuously. Knowledge begets knowledge, if shared with a broader community. So we should also look at sharing knowledge through contributions, participation at various forums and collaboration. At Infosys, we have always believed and invested heavily in learning, and we have enabled our employees to learn anytime, anywhere, through our mobile learning platform, LEX, which has over 40K resources and 600+ courses. Employees are also encouraged to and recognised for sharing their knowledge, both externally and internally. We are collaborating with our strategic partners to contribute to open source communities jointly. As we speak, we are working with one of our partners to launch an open source academy. + +**Q. Has there been an increase in the number of open source related professionals being hired at Infosys?** +**A.** We are seeing a huge demand for open source technologies and most of our Top 200 clients are increasingly moving their legacy systems to open source technologies. We use a combination of refactoring our existing talent pool and hiring to meet the demand. + +![Avatar][3] + +[Rahul Chopra][4] + +The author is the Editor-in-Chief of Open Source For You magazine. + +[![][5]][6] + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/we-follow-a-holistic-approach-to-drive-open-source-adoption-across-the-client-base-at-infosys/ + +作者:[Rahul Chopra][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensourceforu.com/author/rahul-chopra/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Gautam-Khanna-VP-head-modernization-practice-Infosys.jpg?resize=500%2C627&ssl=1 (Gautam Khanna, VP & head - modernization practice, Infosys) +[2]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Gautam-Khanna-VP-head-modernization-practice-Infosys.jpg?fit=500%2C627&ssl=1 +[3]: https://secure.gravatar.com/avatar/372bbe65753ca17bcceb2b0e9692af8f?s=100&r=g +[4]: https://opensourceforu.com/author/rahul-chopra/ +[5]: https://opensourceforu.com/wp-content/uploads/2019/11/assoc.png +[6]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US diff --git a/sources/talk/20191129 My Linux story- Covering open source in Spanish.md b/sources/talk/20191129 My Linux story- Covering open source in Spanish.md new file mode 100644 index 0000000000..df6edf8ecd --- /dev/null +++ b/sources/talk/20191129 My Linux story- Covering open source in Spanish.md @@ -0,0 +1,111 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (My Linux story: Covering open source in Spanish) +[#]: via: (https://opensource.com/article/19/11/linux-open-source-spanish) +[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen) + +My Linux story: Covering open source in Spanish +====== +Meet Lorenzo Carbonell, who brings GNU/Linux and open source to the +Spanish-speaking community through his blog site, El Atareao, and +applications. +![Guy on a laptop on a building][1] + +From time to time, when I'm looking for some help on how to do something on my GNU/Linux desktop or server, I'll come across an article or conversation in a language other than English. If that language happens to be French or Spanish, that's fine for me. If it's in Portuguese or Italian, I can stumble through it. And, for other languages, occasionally, I'll give one of those online AI translators a go in the hopes of gleaning something useful. + +But for folks who are comfortable only in English, I suspect that many potentially useful (and sometimes very entertaining) sources are unknown and ignored. And what are the options for people who aren't comfortable in English, when so much that is written about open source (and many other topics) is in English? + +Last year, while researching [open source music players][2], I had the good fortune to stumble on [El Atareao – Linux para legos][3], a well-written, gorgeously illustrated Castilian Spanish blog that focuses on GNU/Linux and open source topics. El Atareao contains tutorials, discussions about applications, and podcasts. Its author, Lorenzo Carbonell, writes beautifully clear and entertaining text and generously shares his accumulating wisdom in a very practical form. He also develops open source applications, including LPlayer, which is how I found his blog. + +I had a discussion with Lorenzo about what it takes to create a great non-English, open source-oriented blog. Here is our conversation, translated from Spanish and edited for clarity. + +**Q: Lorenzo, I've been a fan of your blog since May 2018. I like everything about it—very interesting articles, solid content, beautiful images, great design overall. What motivated you to start this fine project? And what motivates you today?** + +**A:** I got to know GNU/Linux at university about 25 years ago; it attracted my attention, and I used it for several months. For whatever reason—maybe I wasn't sufficiently prepared, maybe the distribution, Slackware, was too much for me—I decided to abandon it when I started working. However, it stuck in my memory. + +About 10 years ago, I was tired of bringing office work home, and I decided to come up with a solution. At that moment, some recollection of that GNU/Linux operating system came back to me, and I thought using a different operating system might be the solution. The incompatibility between the two would make it hard to bring work home, I thought. + +I chose Ubuntu as my platform, and this distribution has stayed with me until today, a distribution that showed me my mistake: With Ubuntu, or really any other distro, I can still do office work at home! + +Yes, in the beginning, I had some difficulties. And these difficulties were what led to the birth of Atareao.es, because that was where I posted the lessons I learned from this incredible operating system. + +Using an open source operating system, which provides the opportunity to get into the guts of the system and adapt its functions to my needs, stole my heart. Implementing applications like [LPlayer][4], [Touchpad-Indicator][5], or [My Weather Indicator][6] and seeing other people finding them useful filled me with satisfaction. Not only the satisfaction of implementing applications and bringing them to the attention of other users through Atareao.es, but also the satisfaction of being able (or at least trying) to show the potential of this operating system. The potential of this operating system is that it allows you to do almost anything you can imagine, for the simple reason that the code is there and available so that you can study it and adapt it to your needs. + +What motivates me? To have an operating system with so much potential; that is the great unknown. This is what motivates me: having successes to shout to the four winds to let everyone know. And once everyone knows, each one can decide. This is one of the reasons for free applications that can make life simpler or at least help the newly arrived. + +**Q: Please explain the name "El Atareao"… is it local slang? I understand "el atareado" (the busy person).** + +**A:** "El Atareao" was something that arose from work 10 years ago. At that time, I was always busy with work. A close friend mentioned that phrase to me, and it branded itself in my mind. Now it's "el atareao" that will support the company. And to honor and respect this, I used the name for this site. + +So with respect to "atareao" in place of "atareado," effectively it's local slang. + +**Q: So when you aren't "atareao," what do you do? Are you a software developer? Do you work in open source by day?** + +**A:** Currently, I'm working as a developer and in part as a system administrator. And I must say that this came about thanks to Atareao.es. Before, I was working in something completely and totally different, but software development has been my passion. And so, relatively recently, a visionary (or a crazy person) rescued me from my old job and brought me to this incredible world of development, where you can convert anything you can imagine to reality. I say "visionary" because he knew how to see what I could not, and "crazy" because he has to be really bold to make that bet. Today I'm like a kid in a candy store. + +**Q: Your articles provide a solid amount of useful detail. For example, this [article about Rsync][7]. How do you decide on a topic? How do you determine your readers' level of ability so you can write in a way they can understand?** + +**A:** Normally, the articles arise from my need to solve a problem or a situation that I'm facing or that someone has contacted me to ask for help. Though the latter is less common because interactivity in the world 2.0 is not always what I, and I suppose others, would like. + +The objective of any article is to be sufficiently detailed so that any person reading it can reproduce it and can succeed at putting the material to work. It's very frustrating to read an article about some technology that is apparently really simple and not be able to make it work—because the person who wrote the article did not try it out, or because it's vaguely documented, or because it's explained in a technically excessive manner. + +My objective is to try to acquaint as many people as possible to the greatest extent possible with this operating system. How can I tell you about something if you can't make it work because I didn't explain it sufficiently or with enough detail? When someone writes to me and tells me they were unable to follow something or that it wasn't well explained or that there is some error, it makes me very uneasy and motivates me to write better, to strengthen myself, to study more, to learn. + +With respect to the readers' level of ability, this is probably my biggest worry. I know that the majority who read Atareao.es are beginners or "legos" (in the sense of not being professionals), and I try to orient myself to these people. Nevertheless, some of the readers are professionals and are quite challenging to satisfy. In whatever way, I always try for the most straightforward and simple result. Or, at least to be sufficiently clear, so that I can understand it without problems. + +**Q: Do you have other hobbies apart from this blog?** + +**A:** Currently, the blog, the podcast, and developing applications absorb nearly all of my free time. An article or a podcast takes a couple of hours. Creating an application never ends and sucks up all my available time. + +But one hobby that I am dedicated to is running; this is something I do every day or nearly so. And so, as I mention in the "[Who am I?][8]" section of the blog, if one day you visit Silla, the town in Valencia where I live, early in the morning, you can find me on my running circuits. When we travel, which is the other hobby that I have and share with my wife, my running shoes and my laptop always come with me. You can always find me traveling or running or sitting in a coffee shop writing an article. + +**Q: As someone who is not a native speaker of (Castilian) Spanish, I nevertheless enjoy your use of the language; I feel that how one expresses oneself is as important as what is written. Can you elaborate on this?** + +**A:** It seems to me very important that an article, whether it's technical or not, should have the best possible wording. And not only to be correct, syntactically and semantically, but to be able to tell a story, a story that engages. + +For this reason, whenever I can, I try to write the technical article within an experience, a situation, or a circumstance that has happened to me. From my perspective, writing about real, daily successes that frame a technical article works better for readers and makes them feel much more involved. + +**Q: There are a lot of people who prefer information in their mother tongue. As someone who writes in Spanish, what do you think about this issue? Do you have any idea of the level of demand for information about open source software in Spanish?** + +**A:** I think that Spanish speakers, and especially those born in Spain, prefer (Castilian) Spanish as their working language. In Spain, they don't teach us English; rather, they teach us how to pass the English course, which is a real shame. I would enjoy speaking, writing, and expressing myself in English as well as you, but there isn't a means, despite the fact that every day, I consume more video and audio in English, and every day I push myself more with it. I need English more and more; I need to develop myself better in this language. + +With respect to the demand for open source software in Spanish, as far as I understand, it's very low, too low for my liking. In general, open source software is the unknown. Few know Linux, and few understand that it's what is behind open source software. A significant number come at first for the simple fact that it's free. This is a great advantage because it's a way to first approach open source. Nevertheless, it's necessary to go deeper, to take a radical turn, because to the Spanish speaker, or at least to the Spaniard, when something is free or very cheap, it seems that it is of low quality. And "free" software is not synonymous with "no cost"; it must be defined based on its high quality. + +**Q: Where is** **El Atareao** **going in the future? More podcasts? YouTube channels? Adding other authors? Syndicated content?** + +**A:** Where is Atareao.es going? I know where I'd like it to go. I'd like to dedicate myself to it full time. I'd like to live on [income from] the site, although I know that's really difficult. One approach that I'm exploring is to convert it to a membership site, although providing the content for free. This is something that I need to keep working on. + +As a part of this, I'm trying to participate in related events and give talks at conferences. I started down this road last year at [Ubucon][9] Europe 2018, I continued this year, and next year I'd like to deepen this involvement. "De-virtualization" is important, putting faces to names, seeing that open source software isn't something far away, distant, or cold; quite the contrary. + +In the short term, I'd like to work on my [YouTube channel][10] while working on talks and attending conferences. I'm planning to start a series on YouTube, although I don't have it completed, and only my wife and now you (all) know about it. + +### Conclusion + +Thanks very much, Lorenzo, for taking the time to share your thoughts with us, and best wishes for the continued success of El Atareao. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/linux-open-source-spanish + +作者:[Chris Hermansen][a] +选题:[lujun9972][b] +译者:[译者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/clhermansen +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_code_programming_laptop.jpg?itok=ormv35tV (Guy on a laptop on a building) +[2]: https://opensource.com/article/18/6/open-source-music-players +[3]: https://www.atareao.es/ +[4]: https://github.com/atareao/lplayer +[5]: https://github.com/atareao/Touchpad-Indicator +[6]: https://github.com/atareao/my-weather-indicator +[7]: https://www.atareao.es/podcast/sincronizacion-en-red-y-vpn/ +[8]: https://www.atareao.es/quien-soy/ +[9]: https://wiki.ubuntu.com/Ubucon +[10]: https://www.youtube.com/c/atareao diff --git a/sources/talk/20191203 Ampere preps an 80-core Arm processor for the cloud.md b/sources/talk/20191203 Ampere preps an 80-core Arm processor for the cloud.md new file mode 100644 index 0000000000..37cc439790 --- /dev/null +++ b/sources/talk/20191203 Ampere preps an 80-core Arm processor for the cloud.md @@ -0,0 +1,70 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Ampere preps an 80-core Arm processor for the cloud) +[#]: via: (https://www.networkworld.com/article/3482248/ampere-preps-an-80-core-arm-processor-for-the-cloud.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Ampere preps an 80-core Arm processor for the cloud +====== +A new Ampere chip due out next year is single-threaded to avoid the 'noisy neighbor' problem that can impede customer workloads in multi-tenant cloud-provider networks. +Thinkstock + +[Ampere Computing][1], the semiconductor startup led by former Intel president Renee James that designs Arm-based server processors, is preparing to launch its next-generation CPU by mid-2020. + +The upcoming chip will have 80 cores, much more than the 32-core processor the company shipped last year and vastly more than x86 CPUs by Intel and AMD. Ampere’s design is different. Instead of multiple threads per core, each core is single threaded. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][2] + +Jeff Wittich, Ampere’s senior vice president of products, said that was by design, to avoid some of the CPU vulnerabilities that crept into x86 chips but also to avoid the “noisy neighbor” problem in cloud service-provider networks. + +[][3] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][3] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +Because of their many cores and threads, users of AWS and other cloud providers never get a CPU all to themselves unless they pay dearly for it. More often than not your instance is sharing CPU cycles with someone else, and if their app makes a lot of hits on the CPU cache, especially the L1 cache, it can impede your performance. + +“We designed the product to be single-threaded and many cores to provide as much isolation as possible, with no sharing of threads,” he says. “We intentionally made the product single-threaded, so there is no sharing L1 cache or registers between threads.” + +Ampere is specifically targeting cloud providers and hyperscale data-center operators, which includes the usual suspects – Google, Facebook, Amazon – and second-tier cloud providers as well and companies like Twitter and Uber. That may not be a lot of vendors but they buy in the tens if not hundreds of thousands of servers every quarter. + +“We’re taking a different approach to this in that we have a product targeted at the cloud vs a product targeted at general data centers trying to shoehorn that into every workload,” he said. “The services and infrastructure architecture [hyperscalers] are deploying are totally different from what people were doing 15 to 20 years ago when x86 came in to play. Things like multi-tenant, quality of service, isolation, and manageability are what’s important now.” + +He also notes that hyperscalers have spent the last 10 years optimizing their entire software stack, with custom Linux distributions and their own hypervisor. What they haven’t done is optimize or customize the CPU, because they can’t. + +To that end, Ampere is operating like a software provider using Agile development techniques, which means an annual release of new CPUs, faster iterations than seen by Intel, AMD, and Marvell, which owns the Cavium line of Arm server processors. This means extensive simulation testing and less time updating and fixing actual silicon. + +Wittich said each core has considerably more performant than the eMAG generation, but he was waiting for silicon to do actual benchmarks. Wittich declined to go into detail on the new processor, even on the product name, beyond that it would run at a TDW of 45 to 200 watts, come in single- and dual-socket designs, use PCI Express Gen 4 and eight channels of memory. + +The new processor takes the company into workloads that do run in the cloud now, like database, storage, analytics, media, and machine-learning inference. + +It has a few ODM wins so far, China’s Wiwynn and Lenovo and Gigabyte as well. While the company is targeting the public cloud providers it will go after the private cloud to a certain extent if there are opportunities “that make sense,” as he put it. + +Silicon samples will be coming back this month and sent to partners before end of year. Taiwan’s TSMC is making the chips using 7nm designs. Wittich said the company is targeting mid-year 2020 for high-volume production. + +Join the Network World communities on [Facebook][4] and [LinkedIn][5] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3482248/ampere-preps-an-80-core-arm-processor-for-the-cloud.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3306447/a-new-arm-based-server-processor-challenges-for-the-data-center.html +[2]: https://www.networkworld.com/newsletters/signup.html +[3]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191203 What we risk when we open up to customers (and why it-s worth it).md b/sources/talk/20191203 What we risk when we open up to customers (and why it-s worth it).md new file mode 100644 index 0000000000..d231839a46 --- /dev/null +++ b/sources/talk/20191203 What we risk when we open up to customers (and why it-s worth it).md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What we risk when we open up to customers (and why it's worth it)) +[#]: via: (https://opensource.com/open-organization/19/12/customer-empowerment-trust) +[#]: author: (Tracy Giuliani https://opensource.com/users/tgiuliani23) + +What we risk when we open up to customers (and why it's worth it) +====== +Empowering your customers means opening up to them—but it won't work if +you don't trust each other. +![Open for business][1] + +Customer empowerment is one consequence of digital transformation. And as we explained in the [first part of this series][2], it's a powerful one. Empowering customers can deepen their relationship with your organization—but it won't work if they don't trust you. + +In this article, we'll explain how acting openly can create that foundation of trust—and why it can lead to business success. + +### A foundation of trust + +At the heart of customer empowerment is trust—sharing and creating opportunities to _use_ information and knowledge. After all, if we don't share information and create opportunities, then customers will have trouble using the information or taking any action. They're limited. + +We can think of the empowered customer as a type of mature "user experience," asking: "What kinds of information and opportunities could customers use to [insert verb here] our products, services, and external processes better?" and "How and where in our products, services, and processes do we provide opportunities to use information and knowledge?" Those questions may not be consecutive; we might need to answer them at the same time. + +Trust is the foundation of customer empowerment. We need to trust that our customers are capable, wise, and so on; we must _assume_ they are trustworthy (difficult when we don't know them, since trust is based on personal relationships and consistent actions). Still, when we create opportunities to empower, we need to build them with trust in mind (and sometimes with ways to remove the opportunity if necessary). + +In open source software communities, for instance, we note that opportunities to contribute are part of the openness and meritocracy of the community. Communities often _extend trust by default_, allowing anyone to join and modify code—and only if behavior doesn't meet community policy and membership agreement is access revoked. The community assumed participants' positive intent, extending trust in the first place. + +Trust is the foundation of customer empowerment. + +The question of customer empowerment isn't a "yes or no" question. It's a question of degree. As we mentioned above, empowered customers exist on a continuum. Enabling a _little_ empowerment still qualifies as customer empowerment. But as such empowerment increases, so does the risk involved for the business (and the more reward if the empowerment benefits the business). We could say that customer empowerment is a function of the relationship between customer and business in terms of the: + + * Amount and quality of information + * Amount and quality of opportunities + * Frequency of interactions and opportunities + * And other characteristics pertaining to the unique situation + + + +Think about a synthesizer—an adjustable knob for each quality that influences customer empowerment. There is no single, perfect way to empower customers. + +### Managing risk + +As we mentioned earlier: Trust is an important aspect in these relationships—trust between a business and its employees, or trust between businesses. Beginning such a relationship by empowering a customer 100% is difficult, and even so you probably don't want to. But you _can_ begin somewhere. + +When you risk something, you can ask for your relational partner to risk something too—that way, there's something at stake for both parties. + +Between businesses, empowering partners and trusted customers is a great way to start and build empowerment. When you risk something, you can ask for your relational partner to risk something too—that way, there's something at stake for both parties. Confidentiality agreements. Sales data. Customer references. System environment details. Multiproduct stacks built with a few competitor products. Reputation for contribution. Whatever it you choose to share, you'll need to view the relationships as a "give and take" of risk. For instance, a business might provide test case data to a trusted partner, with the intention of improving testing within the organization, but it might ask for the partner to share anonymous details in an online forum about product testing. + +Empowerment cannot be a one-way street, or it won't be empowerment. Reach _agreements_ on what can be done (or not done) with the information and activities that are available. + +### What's in it for the business? + +In [employee empowerment][3], open leaders get the benefit of a more agile and nimble organization, ready to respond to many multi-faceted issues at once. + +What do leaders get if they empower customers and partners? In the past, an organization's business model might have been to profit from specific knowledge it possess or by using specific, proprietary processes. But customer empowerment means that those are more "open"? So what's the benefit? + + * Increased customer satisfaction: Just like job satisfaction increases with transparency and meaningful work for associates, customers are more satisfied by themselves being empowered. + * Deeper expertise for the originating business: And as a result, improved knowledge and processes as they mature further. In other words, by opening current knowledge and processes, the business can elevate its knowledge and processes that maintain profitability or make the business more profitable. + * Stronger customer centricity: Through increased collaboration with customers, businesses can enhance their current customer experience by using data capturing and analytics to improve their customer-centric perspectives and marketing programs + + + +None of this comes for free. The cost is trust—the work of developing stronger and more trusting relationships with customers and partners. You'll need to decide what that looks like, and what the benefit is, for your own organization. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/19/12/customer-empowerment-trust + +作者:[Tracy Giuliani][a] +选题:[lujun9972][b] +译者:[译者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/tgiuliani23 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_openseries.png?itok=rCtTDz5G (Open for business) +[2]: https://opensource.com/open-organization/19/11/customer-empowerment-open-communities +[3]: https://opensource.com/open-organization/19/4/managed-enabled-empowered diff --git a/sources/talk/20191204 Amazon joins the quantum computing crowd with Braket testbed.md b/sources/talk/20191204 Amazon joins the quantum computing crowd with Braket testbed.md new file mode 100644 index 0000000000..7c4acb0f53 --- /dev/null +++ b/sources/talk/20191204 Amazon joins the quantum computing crowd with Braket testbed.md @@ -0,0 +1,62 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Amazon joins the quantum computing crowd with Braket testbed) +[#]: via: (https://www.networkworld.com/article/3487421/amazon-joins-the-quantum-computing-crowd-with-braket-testbed.html) +[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/) + +Amazon joins the quantum computing crowd with Braket testbed +====== +The newest part of AWS’ huge public-cloud ecosystem is Braket, a way for companies to experiment with quantum computing without having to own quantum computers. +Vizio + +Amazon’s initial foray into the heavily hyped world of [quantum computing][1] is a virtual sandbox in which companies can test potential quantum-enabled applications and generally get to grips with the new technology, the company announced Monday. + +The product is named Braket, after a system of notation used in quantum physics. The idea, according to Amazon, is to democratize access to quantum computing in a small way. Most organizations aren’t going to own their own quantum computers for the foreseeable future; they’re impractically expensive and require a huge amount of infrastructure even for the limited proof-of-concept models at the current cutting-edge. + +[10 of the world's fastest supercomputers][2] + +Hence, providing cloud-based access to three of those proofs-of-concept – the D-Wave 2000Q, Rigetti 16Q , Aspen-4 and IonQ linear ion trap – offers businesses the opportunity to learn firsthand about the way qubits work and how the basic building blocks of quantum programming might look. Braket will let users work remotely with those quantum computers or try out quantum algorithms in a classically driven simulated environment. + +[][3] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][3] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +“Our goal is to make sure you know enough about quantum computing to start looking for some appropriate use cases and conducting some tests and experiments,” said chief AWS evangelist Jeff Barr in [a blog post][4]. + +To help guide those efforts, Amazon also announced that it would form the AWS Center for Quantum Computing in partnership with Cal Tech. The idea here seems to be to create a center of excellence for research into both how quantum computers can be put to use and how they can be manufactured on a slightly larger scale. Furthermore, the new Amazon Quantum Solutions Lab would allow for a collaborative space in which companies can partner to share newfound expertise in quantum computing, as well as workshops and brainstorming sessions for education on quantum topics. + +“Quantum computing is rapidly evolving, but the limited scale of the quantum hardware available today, fragmented development tools, and general shortage of quantum expertise, make it difficult to build near-term quantum applications,” said Amazon in a statement. + +Quantum computing technology is still in the very early stages of development – something like classical computing in the days of the Bletchley Park codebreaking machines, or ENIAC at the latest. Yet major tech companies have been eager to grab headlines in the field. Google boasted in October of [having achieved quantum supremacy][5], the ability to solve a problem with a quantum computer more quickly than with a classical one. + +This sort of cloud-based quantum testbed isn’t a wholly new idea. IBM has offered its Q Experience platform since 2016, and the company recently announced that more than 10 million experiments have been run there to date. And Amazon’s cloud rival Microsoft announced its Azure Quantum service just last month, offering a similar combination of cloud access, quantum programming tools, and remote access to prototype quantum computers. + +Join the Network World communities on [Facebook][6] and [LinkedIn][7] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3487421/amazon-joins-the-quantum-computing-crowd-with-braket-testbed.html + +作者:[Jon Gold][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Jon-Gold/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3275367/what-s-quantum-computing-and-why-enterprises-need-to-care.html +[2]: https://www.networkworld.com/article/3236875/embargo-10-of-the-worlds-fastest-supercomputers.html +[3]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[4]: https://aws.amazon.com/blogs/aws/amazon-braket-get-started-with-quantum-computing/ +[5]: https://www.networkworld.com/article/3447743/google-claims-quantum-supremacy-over-supercomputers.html +[6]: https://www.facebook.com/NetworkWorld/ +[7]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191205 Researchers experiment with glass-based storage that doesn-t require electronics cooling.md b/sources/talk/20191205 Researchers experiment with glass-based storage that doesn-t require electronics cooling.md new file mode 100644 index 0000000000..fdcf998fc8 --- /dev/null +++ b/sources/talk/20191205 Researchers experiment with glass-based storage that doesn-t require electronics cooling.md @@ -0,0 +1,85 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Researchers experiment with glass-based storage that doesn't require electronics cooling) +[#]: via: (https://www.networkworld.com/article/3488556/researchers-experiment-with-glass-based-storage-that-doesnt-require-electronics-cooling.html) +[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) + +Researchers experiment with glass-based storage that doesn't require electronics cooling +====== +A Microsoft Research project uses laser optics and artificial intelligence to store data in quartz glass. +Thinkstock + +Hard drives aren’t going to be capacious enough for future data archiving and retrieval requirements, scientists believe, as applications such as artificial intelligence, wide-scale Internet of Things connectivity, and virtual and augmented reality take hold. Glass could be the answer. + +Encoding in glass would have advantages over hard drives and other mediums, experts suggest. Holding capacity is greater, and the slivers of quartz being experimented with don’t need cooling or dehumidifying environments. + +Microsoft Research, working in the UK along with the University of Southampton, [announced][1] that it has been able to store an entire movie on a quartz, glass-based storage medium. The team stored and retrieved a full-length Superman film on a small slab of the special material that measures about 3 inches square and less than a tenth of an inch thick. . + +[][2] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][2] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +“It looks like we’re now in a phase where we’re working on refinement and experimentation, rather asking the question ‘can we do it?’” said Mark Russinovich, Microsoft Azure’s chief technology officer, in a statement. + +### Laser improvements fuel glass-based storage technology + +Improvements in laser technology are behind the proof of concept Microsoft Research dubbed Project Silica. The femtosecond infrared lasers that are used in the process function similarly to eye surgery lasers. Those kinds of laser beams are much better and more precise than traditional ones. They don’t crack the glass, for one thing. + +The glass is, in fact, structurally changed by the laser, which means that the data could last as long as the material does—possibly centuries, unlike existing mediums like tape. It’s robust, too. Interestingly, even if one were to break the glass, the data remains encoded in the shards, the researchers say. + +“It’s somewhat like creating upside down icebergs at a nanoscale level, with different depths and sizes and grooves that make them unique,” Microsoft said. Voxels, which are a three-dimensional version of a pixel, are embedded in the glass, one-time, rather than just written to the top, as occurs with other mediums. That three-dimensional aspect, along with the inherent opaqueness, helps with low-latency retrieval—the reading can occur rapidly along all of the axis (x, y and z). + + * [Backup vs. archive: Why it’s important to know the difference][3] + * [How to pick an off-site data-backup method][4] + * [Tape vs. disk storage: Why isn’t tape dead yet?][5] + * [The correct levels of backup save time, bandwidth, space][6] + + + +### Cloud storage alternatives + +Glass isn’t the only potential replacement for old-school magnetic, solid-state and tape storage as the world increasingly collects data. Chemical, molecule and DNA options are all being suggested as potential alternatives to existing cloud storage. + +Fitting transistors onto individual molecules is one answer, [say researchers at Arizona State University][7]. + +Synthetic DNA is another proposed option. Large amounts of information last a long time in DNA; a 45,000-year-old human bone was DNA-decoded a few years ago, for example. [Synthetic DNA could end up having similar advantages to that organic version][8], scientists think. + +A third option, at a chemical level, is storing data on molecules and then dissolving that mix into liquids. [Massive amounts of data could be held in small containers][9], Brown University has said of its experiments in that area. + +Perhaps most interestingly, with all of the these potential storage replacements (should any of them take off), the traditional environmental controls that we require for heat-generating electronics in data center environments would become moot. + +“Quartz glass doesn’t need energy-intensive air conditioning to keep material at a constant temperature or systems that remove moisture from the air,” Microsoft said of Project Silica. “Both of which could lower the environmental footprint of large-scale data storage.” + +Join the Network World communities on [Facebook][10] and [LinkedIn][11] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3488556/researchers-experiment-with-glass-based-storage-that-doesnt-require-electronics-cooling.html + +作者:[Patrick Nelson][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Patrick-Nelson/ +[b]: https://github.com/lujun9972 +[1]: https://news.microsoft.com/innovation-stories/ignite-project-silica-superman/ +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.networkworld.com/article/3285652/storage/backup-vs-archive-why-its-important-to-know-the-difference.html +[4]: https://www.networkworld.com/article/3328488/backup-systems-and-services/how-to-pick-an-off-site-data-backup-method.html +[5]: https://www.networkworld.com/article/3315156/storage/tape-vs-disk-storage-why-isnt-tape-dead-yet.html +[6]: https://www.networkworld.com/article/3302804/storage/the-correct-levels-of-backup-save-time-bandwidth-space.html +[7]: https://www.networkworld.com/article/3344599/new-chemistry-based-data-storage-would-blow-moores-law-out-of-the-water.html +[8]: https://www.networkworld.com/article/3268646/dna-data-storage-closer-to-becoming-reality.html +[9]: https://www.networkworld.com/article/3251071/data-could-one-day-be-stored-on-molecules.html +[10]: https://www.facebook.com/NetworkWorld/ +[11]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191205 The current state of blockchain and where it-s going.md b/sources/talk/20191205 The current state of blockchain and where it-s going.md new file mode 100644 index 0000000000..1bd4b3bce4 --- /dev/null +++ b/sources/talk/20191205 The current state of blockchain and where it-s going.md @@ -0,0 +1,90 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (The current state of blockchain and where it's going) +[#]: via: (https://opensource.com/article/19/12/blockchain-evolution) +[#]: author: (axel simon https://opensource.com/users/axel) + +The current state of blockchain and where it's going +====== +Take a look at the ecosystem and the projects trying to solve some of +the limitations of blockchain technology. +![Arrows moving a process forward][1] + +In an earlier post, [_Blockchain evolution: A quick guide and why open source is at the heart of it_][2], I discussed the first generations of blockchains: the public Bitcoin and cryptocurrency blockchains, followed by the Ethereum blockchain capable of executing programs ("smart contracts"), leading to permissioned versions of code-executing blockchains (e.g., Hyperledger Fabric, Quorum). + +Let's step back into the blockchain jungle and take a look at the current state of the ecosystem and the projects trying to solve some of the limitations of blockchain technology: speed and throughput, cross-blockchain information and value exchange, governance, and identity and account management. + +### Speeding things up + +One of the oft-heard gripes about current blockchain technologies is their limited speed, often measured by the number of transactions per second (TPS) that they can manage. This issue strongly limits their use in systems that need to process massive amounts of events. For instance, it has often been said (correctly) that Bitcoin can't handle more than seven transactions per second, and Ethereum can't do much more. Possibly the simplest way of defining the next generation of blockchains is with novel ways to try to solve the scalability problems that current generations of blockchains constantly battle. (Permissionless ones especially. I will return to what separates permissionless and permissioned chains below.) + +The most obvious option—and one of the most fiercely debated one in the Bitcoin community—is "simply" to make the blocks of transactions bigger so that they can handle more transactions per block, and thus per second. Opposing interests in Bitcoin have made this solution very hard to implement (a clear problem with the "governance by code" model I mentioned in my previous article, which I will return to in a future article), but it nonetheless remains a relatively straightforward option for blockchain projects in general. Increasing the frequency at which blocks are created is another one. + +I also mentioned another way to handle more transactions per second in the first article: changing the constraints of the problem. Going from a permissionless network—one that anyone can join and participate in—to a permissioned one—where joining requires permission—changes the constraints and offers the option of reconsidering the security requirements. When you know everyone in a consortium—and have legal ties to them—you can choose to use consensus mechanisms, which don't assume everything should be verified at all times and thus speed things up. Furthermore, permissioned blockchain frameworks, such as Hyperledger Fabric, will typically offer the option to choose the number of transactions contained in a block and their frequency. Whether it's the number of transactions per block or the number of blocks generated that increases, the end result will be an increase in TPS. + +This is how permissioned systems can reach tens of thousands of TPS, numbers far beyond the major permissionless networks. It is also unsurprising, then, that Facebook's recently announced Libra cryptocurrency plans to use a permissioned model (although its "blockchainness" is debated) to handle a high number of transactions, in line with its stated goals. + +### Holding out for consensus + +However, private, permissioned ledgers will not be suited to all use cases. There need to be improvements in general to permissionless networks' capacity to manage more events at a time. This leads us to where the most ambitious work might be happening: consensus mechanisms. + +Getting all participants to come to a consensus on the "truth" of all the transactions (i.e., the changes) that happen on the network and on their order is one of the great difficulties of distributed systems. As a type of distributed system, blockchains inevitably contend with it, too. + +Bitcoin's solution is to organize a race every 10 minutes to solve a computational puzzle and let the winner settle what transactions happened in the last time period and in which order, which everyone else can then easily verify and agree on. By virtue of the kind of puzzle used, the winner is essentially random, but the problem with this "Nakamoto-style proof of work" is that the puzzles used in this race also require horrendously high computational resources to solve (by design), and the work of everyone but the winner is thrown away after each round. + +While it is secure, proof of work is also energy-consuming and slow. + +What we need are better consensus mechanisms that will allow participants of blockchain networks to come to agreement more efficiently, making it possible for the whole system to process more events per second. + +Ethereum, notably, is working on numerous innovations to solve these limitations. First of all, it plans to let go of proof of work to move to a proof of stake consensus mechanism, often referred to as the [Casper protocol][3]. It uses economic incentives and disincentives to get the nodes to secure the network and make cheating (very) costly. + +Another problem a blockchain that can execute smart contracts must contend with is how the execution of code is guaranteed to be correct and what impact this has on the processing capacity of the overall network. Currently, Ethereum requires each validating node to execute the code to verify that the results offered by other nodes are correct. This poses scalability issues, as the greater the success of the Ethereum "world computer," the more code validators need to check: all the nodes need to agree on the order _and_ the validity of each line of code executed and will inevitably be held back by the slowest node. + +One of the options to alleviate this issue is [_sharding_][4], a solution where only part of the network executes the code and returns results the rest of the network can verify. + +Pushing this idea further, [ZEXE][5], a project by the team behind Zcash, deals with this situation by making it possible to submit the result of the execution of code along with a cryptographic proof that the result is correct. Other nodes can then take this proof and check it very quickly without redoing the computation. This, combined with bounties for proving results wrong, creates a system where code can be executed by a single node and checked by many, and it makes for a clever way of speeding up the execution of distributed applications (dapps). + +Consensus in distributed systems is not exactly a new research field, but as blockchains have become popular, there has been renewed interest in consensus research. I could mention many more (Tendermint, Ouroboros, and Algorand come to mind), but I'll offer one other interesting approach regarding consensus: consensus agility. For instance, Hyperledger Sawtooth can [change consensus][6] on the fly, "putting all blockchain configuration on the chain itself." This makes it possible to start a network using a given consensus mechanism and switch to a different, more adapted one when the network and its users have changed, say going from a small-scale deployment to a large consortium. + +This is starting to shed light on an important aspect of the evolution of blockchains: modularity. While the first projects were very tightly integrated, over time, efforts have been made to separate the different layers: networking, consensus, application, and even information storage. + +### Layer 2 solutions: Generation 2.5? + +Solutions baked directly into the blockchain—such as the ones above—are considered to be layer 1. Solutions built on top of a blockchain are called layer 2 solutions. + +These layer 2 solutions, such as the [Lightning Network][7] for Bitcoin or [Raiden][8] for Ethereum, are designed to speed up the overall system by offloading transactions to a secondary network. It's designed to achieve much higher throughput while still connecting to the main blockchain and maintaining its important characteristics: distributed, permissionless, and trust-minimizing. While similar to some degree to sidechains (connecting another system to the main chain, an idea I will return to in the next article), they don't use the idea of a secondary chain. Instead, they build overlay networks that rely on the underlying chain for security and accountability but can exchange information much, much faster and in a peer-to-peer manner. + +Layer 2 solutions are essentially built for cryptocurrencies and create payment tunnels anchored to the underlying cryptocurrency's blockchain, where the amounts exchanged between two parties are eventually settled. By taking most transactions off-chain and alleviating how much needs to happen on the main chain and offloading most transactions to the second layer, they help speed up the entire system. + +### Conclusion + +Speed is the great limiter on the potential of permissionless blockchains. There is a great deal of work going on to explore solutions to this challenge while maintaining the integrity of the chain. Recent research on consensus is leading to new approaches which offer less environmentally unfriendly guarantees on accuracy. + +Open source software is constantly evolving, and as an open source ecosystem, blockchains are a prime example of this reality: Many projects are experimenting with various solutions to shared problems, and these solutions are being studied, refined, and improved by the rest of the community. + +The next installment of this series will examine how current generations of blockchain technologies are trying not just to make individual blockchains more efficient but also capable of working together. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/blockchain-evolution + +作者:[axel simon][a] +选题:[lujun9972][b] +译者:[译者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/axel +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_twoforward.png?itok=exkV49ts (Arrows moving a process forward) +[2]: https://opensource.com/article/18/6/blockchain-guide-next-generation +[3]: https://github.com/ethereum/eth2.0-specs/tree/dev/specs/core +[4]: https://github.com/ethereum/wiki/wiki/Sharding-FAQ +[5]: https://eprint.iacr.org/2018/962.pdf +[6]: https://www.hyperledger.org/blog/2017/11/22/un-pluggable-consensus-with-hyperledger-sawtooth +[7]: https://lightning.network/ +[8]: https://raiden.network/ diff --git a/sources/talk/20191209 5G in 2020- Still just a private party.md b/sources/talk/20191209 5G in 2020- Still just a private party.md new file mode 100644 index 0000000000..45d7b48d5f --- /dev/null +++ b/sources/talk/20191209 5G in 2020- Still just a private party.md @@ -0,0 +1,77 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (5G in 2020: Still just a private party) +[#]: via: (https://www.networkworld.com/article/3488563/5g-in-2020-still-just-a-private-party.html) +[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/) + +5G in 2020: Still just a private party +====== + +Vertigo3D / Getty Images + +To hear the major mobile carriers talk about it, [5G][1] is here. They’ve deployed it, it works, and it’s ready to start changing the world just about right away, with ultra-fast connectivity, low latency and a dramatically improved ability to handle huge numbers of different connections at once. + +Eventually, that will all be true – but, according to experts in the field, it isn’t yet, and most of it won’t take place within the coming calendar year. The 3GPP standards that will underpin all new-radio 5G technology are still not yet finalized, although that is expected to happen in early 2020, which means the much-touted 5G deployments in the U.S. are based partially on pre-standard technology. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][2] + +Those deployments are also, at this point, quite limited in size, confined to a few major cities, and only covering centrally located intersections and occasional landmarks. It’s worth noting, though, that the parts of the 5G standard that work over some of the same frequencies as existing LTE have been finalized. + +[][3] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][3] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +Babak Beheshti, a member of the IEEE’s board of directors, said that the main way 5G will make a mark in 2020 will be in private deployments. A company can use pre-standard versions of 5G to create very fast, low-latency networks within its own facilities. Vendors like Ericsson and Nokia are already getting ready to sell the requisite equipment, and a private 5G network has a number of potential upsides, thanks in part to it being based on existing carrier technology. + +“Because of its inherent privacy and security, in that sense, it’ll provide wireless access to employees at a much more secure level,” he said. + +Beheshti also noted that there are potential downsides to the use of private 5G – including cost and the fact that it will require a fairly dense deployment of access points, given its use of comparatively high-frequency radio waves. + +According to Forrester Research vice president Glenn O’Donnell, another potential issue is power consumption – compared to a [Wi-Fi 6][4] network of similar capacity, at least – but that’s an arguable point, and both technologies will be competitive for this type of deployment. + +“This is one of the many holy wars we’ve seen in technology,” he said. “You’ll get people who fall into one camp or the other – a lot of it, unfortunately, is going to come down to who’s marketing better.” + +Still, it seems clear that there’s a potential market there in the enterprise sector for a fast, low-latency network that’s also highly secure. O’Donnell said that the manufacturing, warehousing and logistics verticals might be particularly interested in private 5G, given the networking needs created by IoT and related developments and a lesser incidence of highly sophisticated Wi-Fi implementations. + +Beheshti concurred, saying that a relatively green field makes the most sense for private 5G deployment. + +“Given the expenditure involved, where it would really provide most ROI is for companies that have no private wireless or very little private wireless setup or infrastructure,” he said. + +Widespread carrier-based implementation of 5G technology, however, is unlikely to happen over the course of 2020, and a big part of the reason why is that the devices on the market that are compatible with 5G networks are slim to non-existent. + +According to O’Donnell, software-defined 5G radios are present on some of the latest Samsung phones and a few handsets made in China, and they’re likely capable of being reconfigured with OTA updates to mesh with any final standard for the millimeter-wave technology that provides 5G’s most impressive connection speeds. Yet that’s not a guarantee. + +“If a new band opened up that nobody foresaw as a possibility, that could cause hiccups,” he said. + +It’s easy to understand the reason behind all the hype. The mobile carriers are eager to tout their cutting-edge technology, and full-fledged 5G will be an undeniably impressive achievement. It will enable a huge range of new wireless applications, and improve overall connectivity for just about every user. But the fact remains that it’s not going to do all that in 2020, and, beyond the limited use case for private implementations of the technology, 5G isn’t something that enterprise users will need to concern themselves with too heavily in the coming year. + +“I fully believe 5G is going to be transformative, but it needs to be built out,” said O’Donnell. “This is going to take time and a lot of money.” + +Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3488563/5g-in-2020-still-just-a-private-party.html + +作者:[Jon Gold][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Jon-Gold/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3203489/what-is-5g-how-is-it-better-than-4g.html +[2]: https://www.networkworld.com/newsletters/signup.html +[3]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[4]: https://www.networkworld.com/article/3356838/how-to-determine-if-wi-fi-6-is-right-for-you.html +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191209 Data centers in 2020- Automation, cheaper memory.md b/sources/talk/20191209 Data centers in 2020- Automation, cheaper memory.md new file mode 100644 index 0000000000..fdea7c35c8 --- /dev/null +++ b/sources/talk/20191209 Data centers in 2020- Automation, cheaper memory.md @@ -0,0 +1,132 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Data centers in 2020: Automation, cheaper memory) +[#]: via: (https://www.networkworld.com/article/3487684/data-centers-in-2020-automation-cheaper-memory.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Data centers in 2020: Automation, cheaper memory +====== +As data centers grow in 2020, enterprises will refine the balance between on-premises and cloud resources, adopt AI on servers and try to manage data sprawl effectively. +[Arthur Ogleznev / Unsplash][1] [(CC0)][2] + +It’s that time of year again when those of us in the press make our annual prognostications for the coming year. Some things we saw coming; the rise of the cloud and the advance of SSD. Others, like the return of many cloud migrations to on-premises or the roaring comeback of AMD, went right by us. We do our best but occasionally there are surprises. + +So with that, let’s take a peek into the always cloudy (no pun intended) crystal ball and make 10 data-center-oriented predictions. + +### IoT spawns data-center growth in urban areas + +This isn’t a hard prediction to make since it’s already happening. For the longest time, [data centers][3] were placed in the middle of nowhere near renewable energy (usually hydro), but need is going to force more expansion in major metro areas. [IoT][3] will be one driver but so will the increasing use of data center providers like Equinix and DRT as interconnection providers. + +[][4] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][4] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +### Rise of network accelerators + +Big Data and artificial intelligence of all flavors mean enormous amounts of data, and not all of it can be found in one place. Add to it that for now, CPUs are required to power network traffic controllers, thus taking them away from their main job of crunching data. + +So you will see more and more network accelerators coming to market like Mellanox’s [ConnectX line][5] to let CPUs do the job of processing data and accelerators do the job of moving around massive amounts of data faster than is done now. + +### NVMe over fabrics grows + +Non-volatile memory express ([NVMe][6]) is a storage interface, like serial advanced technology attachment (SATA). The downside of SATA is that its legacy is in hard disks so it fails to take full advantage of the speed and parallelism of [SSD][7]s. But early enterprise SSDs had a problem: They could only talk to the physical server in which they were installed. Either that or a server needed storage arrays, which meant network hops, which meant latency. + +NVMe over fabrics ([NVMeoF][8]) is an important advance. It lets an SSD in one server communicate over the network to another drive somewhere else on the network. This direct communication will be vital for improved data movement in enterprise computing and digital transformation. + + * [Backup vs. archive: Why it’s important to know the difference][9] + * [How to pick an off-site data-backup method][10] + * [Tape vs. disk storage: Why isn’t tape dead yet?][11] + * [The correct levels of backup save time, bandwidth, space][12] + + + +### Cheaper storage-class memory + +Storage-class memory is memory that goes in a DRAM slot and can function like DRAM but can also function like an SSD. It has near-DRAM-like speed but has storage capabilities, too, effectively turning it into a cache for SSD. + +Intel and Micron were working on SCM together but parted company. Intel released its SCM product, [Optane][13], in May, and Micron came to market in October with QuantX. South Korean memory giant SK Hynix is also working on a SCM product that’s different from the 3D XPoint technology Micron and Intel use as well. + +All of this should do wonders to advance the technology and hopefully bring the price down. Right now a 512GB stick of Optane runs an insane $8,000. Granted, Xeons sell for even more than that, but after a while it becomes prohibitively expensive to assemble a fully decked-out server. Advancement of the technology and competition should lower prices, which will make this class of memory more attractive to enterprises. + +### AI automation on brand-name servers + +All of the server vendors are adding AI to their systems but Oracle is really taking the lead with its autonomous everything, from the hardware through OS and application and middleware stack. HPE, Dell, and Lenovo will continue to make their own advances as well but the hyperscale-server vendors like Inspur and Supermicro will lag because they have only the hardware stack and have done next to nothing in the OS space. They also are lagging in storage, something the big-three server vendors excel at. + +Oracle may not be a top-five server vendor, but no one can ignore what they are doing in the automation space. Expect the other brand name-vendors to provide their own increasing levels of automation. + +### Cloud migrations slow + +Remember when everyone was looking forward to shutting down their data centers entirely and moving to the cloud? So much for that idea. IDC’s latest CloudPulse survey suggests that 85% of enterprises plan to move workload from public to private environments over the next year. And a recent survey by Nutanix found 73% of respondents reported that they are moving some applications off the public cloud and back on-prem. Security was cited as the primary reason. + +And since it’s doubtful security will ever be good enough for some companies and some data, it seems the mad rush to the cloud will likely slow a little as people become more picky about what they put in the cloud and what they keep behind their firewall. + +### Data sprawl, Part 1 + +Most data is not where it should be, according to IDC. Only 10% of corporate data is “hot” –  data that is repeatedly accessed and used – while 30% is “warm ” – used semi-regularly – and the other 60% belongs in cold storage where it is rarely if ever accessed. + +But the problem is that data is scattered all over the place and often in the wrong tier. Many storage firms have focused on deduplication but not on storage tiers. A startup called Spectra Logic is targeting that very problem, and I suspect it won’t be the last firm to make such an effort. If it really takes off, I expect HPE and Dell to lock horns over the company, too. + +### Data sprawl, Part 2 + +IDC [predicts][14] the total global data haul to weigh in at 175 zettabytes by 2025, and we are already at 32ZB of data, much of it useless. There was a time when data warehousing ruled that data was sorted and processed and stored as something useful. Now people fill data lakes with an endless supply of data from a growing number of sources, like social media and IoT. + +Sooner or later, something will have to give. People will take a look at petabytes of data-lake junk and say enough is enough and start to become considerably more picky about what they store. They will question the rationale behind spending a fortune on hard disks and storage arrays to store vast quantities of unused and valueless data. The pendulum will swing back to the data-warehouse model of keeping usable data. It has to or people will be overwhelmed. + +### More servers with a mix of processors + +Ten years ago, it didn’t matter if your definition of a server was a single-socket Xeon tower sitting under a desk or four-socket rack-mount in a seven-foot cabinet, they were defined by an x86 processor. But now we are seeing more server designs with on-board GPUs, Arm processors, AI accelerators, and network accelerators. + +This will require some changes in server designs. First, liquid cooling will become more necessary with this multitude of chips running faster and hotter and in an enclosed space. Second, the software stack will need to be more robust to handle all these chips, requiring some work on the part of Microsoft and the Linux distros. + +### IT workload will change + +Don’t think that automation means you can sit around playing games on your iPhone. Thanks to their ever-evolving systems, IT pros will have a bunch of new headaches including: + + * Combating shadow IT + * Addressing digital transformation + * Developing AI strategies to keep up with competitors + * Reacting appropriately to the fallout from new AI strategies + * Maintaining security governance across the company + * Handling an increasing inflow of data and figuring out what to do with it + * Responding faster than ever to customers and to company reputation on social media + + + +Join the Network World communities on [Facebook][15] and [LinkedIn][16] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3487684/data-centers-in-2020-automation-cheaper-memory.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://unsplash.com/photos/rWDumHFt8E8 +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.networkworld.com/article/3223692/what-is-a-data-centerhow-its-changed-and-what-you-need-to-know.html +[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[5]: https://www.networkworld.com/article/3433924/mellanox-introduces-smartnics-to-eliminate-network-load-on-cpus.html +[6]: https://www.networkworld.com/article/3280991/what-is-nvme-and-how-is-it-changing-enterprise-storage.html +[7]: https://www.networkworld.com/article/3326058/what-is-an-ssd.html +[8]: https://www.networkworld.com/article/3394296/nvme-over-fabrics-creates-data-center-storage-disruption.html +[9]: https://www.networkworld.com/article/3285652/storage/backup-vs-archive-why-its-important-to-know-the-difference.html +[10]: https://www.networkworld.com/article/3328488/backup-systems-and-services/how-to-pick-an-off-site-data-backup-method.html +[11]: https://www.networkworld.com/article/3315156/storage/tape-vs-disk-storage-why-isnt-tape-dead-yet.html +[12]: https://www.networkworld.com/article/3302804/storage/the-correct-levels-of-backup-save-time-bandwidth-space.html +[13]: https://www.networkworld.com/article/3279271/intel-launches-optane-the-go-between-for-memory-and-storage.html +[14]: https://www.networkworld.com/article/3325397/idc-expect-175-zettabytes-of-data-worldwide-by-2025.html +[15]: https://www.facebook.com/NetworkWorld/ +[16]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191209 Google Cloud bare-metal initiative targets migrating legacy apps from on-prem.md b/sources/talk/20191209 Google Cloud bare-metal initiative targets migrating legacy apps from on-prem.md new file mode 100644 index 0000000000..bb87e12189 --- /dev/null +++ b/sources/talk/20191209 Google Cloud bare-metal initiative targets migrating legacy apps from on-prem.md @@ -0,0 +1,87 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Google Cloud bare-metal initiative targets migrating legacy apps from on-prem) +[#]: via: (https://www.networkworld.com/article/3487626/google-cloud-bare-metal-initiative-targets-migrating-legacy-apps-from-on-prem.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Google Cloud bare-metal initiative targets migrating legacy apps from on-prem +====== +Google Cloud now offers Google Bare Metal Solution, a service that supplies hardware in the cloud for enterprises that want full control of the entire stack from operating system on up to their most important legacy apps. +Google + +In the cloud-services market, [bare metal offerings][1] have lagged behind virtualized ones, mostly because the use of the cloud for things like elastic apps and developer environments are better suited to instances with a native operating system. + +The term “bare metal” simply means no software of any kind, not even a [hypervisor][2]. Customers provide their own operating environments, and the provider offers nothing more than CPUs, memory, and storage. Up to now, IBM has led the charge with bare-metal services because SoftLayer, the major data-center provider it acquired in 2014, was heavily involved in that business. + +Now Google Cloud is going after that market, especially targeting “lift and shift” of an entire operating environment – OS, hypervisor, apps, and data -- from on-premises data centers to the cloud. + +[][3] + +BrandPost Sponsored by HPE + +[HPE Synergy For Dummies][3] + +Here’s how IT can provide an anytime, anywhere, any workload infrastructure. + +Google [recently announced][4] the Google Bare Metal Solution for legacy applications that must run on dedicated hardware and have strict hardware certification requirements, as well as dedicated, low-latency and highly resilient interconnects, and connections to all native Google Cloud services. + +Bare Metal Solution uses OEM hardware that is certified for many ISV software applications as well as custom-built applications, with Oracle Database the one commercial software product specifically named. The hardware is a bit of a mystery, since Google, like most hyperscale data-center operators, uses off-brand hardware from Gigabyte, Inspur, and Supermicro, but it’s usually hardware from HPE, Dell, and Lenovo that gets those kinds of certifications. Not that the white-box brands don’t have it, but it’s usually not as much of a priority for them. + +These hardware configurations are offered as a subscription, billed monthly with a preferred term length of 36 months, which means they want you to stick around a while. There are no data ingress and egress charges between Bare Metal Solution and Google Cloud in the same region, however for now, Bare Metal Solutions are only available in East Coast data centers. + +Moving an Oracle database to the cloud isn’t trivial. If the database stretches into the petabytes, that could get very expensive. Not to mention Oracle is doing its darnedest to keep that business by making it easier for customers to migrate their databases into Oracle’s cloud infrastructure. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][5] + +Storage comes in 1TB increments, either a mix of HDD and SSD or all-flash. As for the rest of the configurations: + +Dual-socket x86 systems + + * 16 core with 384 GB DRAM + * 24 core with 768 GB DRAM + * 56 core with 1536 GB DRAM + + + +Quad-socket x86 systems + + * 56 core with 1536 GB DRAM + * 112 core with 3072 GB DRAM + + + +Other benefits of the service are: + + * End-to-end infrastructure management such as compute, storage and networking, as well as fully managed and monitored environments such as power, cooling and facilities. + * Support for infrastructure, including defined SLAs for initial response; 24X7 coverage for all Priority 1 and 2 issues; unified billing across Google Cloud and Bare Metal Solution. + * Enterprise-grade SLAs for hardware uptime and interconnect availability. + + + +Bare metal has its appeal but caveats, too. The allure of the cloud is its bursty elasticity. Many on-prem apps are used to running all out for much if not all of the day. In a cloud setting that can get expensive in a hurry, so it’s up to IT staff to decide if it’s a good idea to migrate an Oracle database to the cloud. If it's serving up reads and writes constantly, any savings from moving it off premises will be immediately offset by paying to run it at high utilization in the cloud. + +Join the Network World communities on [Facebook][6] and [LinkedIn][7] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3487626/google-cloud-bare-metal-initiative-targets-migrating-legacy-apps-from-on-prem.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3261113/why-a-bare-metal-cloud-provider-might-be-just-what-you-need.html +[2]: https://www.networkworld.com/article/3243262/what-is-a-hypervisor.html +[3]: https://www.networkworld.com/article/3399618/hpe-synergy-for-dummies.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE19718&utm_content=sidebar (HPE Synergy For Dummies) +[4]: https://cloud.google.com/blog/products/gcp/bare-metal-solution-enabling-specialized-workloads-in-google-cloud +[5]: https://www.networkworld.com/newsletters/signup.html +[6]: https://www.facebook.com/NetworkWorld/ +[7]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191209 LibreCorps mentors humanitarian startups on how to run the open source way.md b/sources/talk/20191209 LibreCorps mentors humanitarian startups on how to run the open source way.md new file mode 100644 index 0000000000..3d3674e7db --- /dev/null +++ b/sources/talk/20191209 LibreCorps mentors humanitarian startups on how to run the open source way.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (LibreCorps mentors humanitarian startups on how to run the open source way) +[#]: via: (https://opensource.com/article/19/12/humanitarian-startups-open-source) +[#]: author: (Justin W. Flory https://opensource.com/users/jflory) + +LibreCorps mentors humanitarian startups on how to run the open source way +====== +NGOs and nonprofits can increase their reach by building open source +communities. +![Two diverse hands holding a globe][1] + +Free and open source software are no longer workplace taboos, at least not in the same way they were fifteen years ago. Today, distributed collaboration platforms and tools empower people around the world to contribute code, documentation, design, leadership, and other skills to open source projects. But do newcomers actually have a deep understanding of free and open source software? + +If you hang around in open source communities for long enough, you realize there is more to open source than slapping a free software license on a project and throwing it over an imaginary fence to wait for contributors who never come. To address this problem in the humanitarian sector, the LibreCorps program, led by Rochester Institute of Technology's FOSS initiative at the [Center for Media, Arts, Interaction & Creativity][2] (MAGIC,) partnered with UNICEF to develop a set of resources to help new open source maintainers chart an "open source roadmap" to build a community. + +![Grassroots presentation in UNICEF office ][3] + +### What is LibreCorps? + +[LibreCorps][4] connects RIT students interested in open source to humanitarian and civic coding opportunities; specifically, opportunities for co-operative education placements (co-ops,) which are full-time paid internships included in the university's graduation requirements. + +LibreCorps students work in two major areas on co-ops. The first, not surprisingly, is technology. The second is FOSS community and processes. Many NGOs and civic organizations put openly licensed work in repositories but need a plan to build and maintain a community of contributors around their technology. + +LibreCorps has worked with numerous humanitarian projects over the years. Recently, LibreCorps was contracted by [UNICEF Innovation][5] to support the [Innovation Fund][6] by mentoring several cohorts of international start-ups in adopting best practices to meet the open source requirement of their funding. + +Periodically, the UNICEF Innovation Fund invites the companies together for cohort workshops, with hands-on mentorship a primary component of the workshop. [Stephen Jacobs][7] and [Justin W. Flory][8] represented LibreCorps at [two UNICEF Innovation Fund workshops][9] to help these teams better understand free and open source, as well as how to successfully build communities and teams that operate as [open organizatio][10][ns][10]. Most of these teams have either never worked in open source projects or only have a basic understanding of licenses and GitHub. Often, for these teams, working on your code in a way where anyone can see what you are doing is a radical shift in process. + +UNICEF Innovation has engaged with open source for years and currently provides funded teams with a course on [open source business models][11]. + +> "We'd approached open-source pretty tentatively and definitely naively. We were keen to move to open source for transparency and perception but, beyond that, had no plans around deriving or creating value, and we were nervous about the perceived risks. The mentorship from Mike Nolan has given us clear direction and a deeper understanding that open source isn't a compromise but a communication channel and a way to build a community, and he's giving us the tools that enable that." — Michael Nunan, Director at Tupaia. + +### How do we create workable community strategy guides? + +This past summer, LibreCorps began developing and evolving resources to help these teams take the complex and difficult challenge of building an open source community and break it down into smaller, more manageable steps. [Mike Nolan][12] and [Kent Reese][13] developed a roadmap template for teams to evaluate their current status in maintainership best practices and chart out milestones for where to go next. For a cohort working in open source for the first time, the LibreCorps team offers advice and suggestions on crafting a mission statement, choosing the right license for your project, and more. The rubrics provide an interactive, color-coded reference to unlock a deeper understanding of their progress towards each milestone. + +Let's explore each resource in more detail to understand how they work: + +### Roadmap template + +The [roadmap template][14] is a resource that gets hands-on and personal to a specific open source project. There are five tracks within the roadmaps with different tasks to gradually ramp up the areas of focus for community management. + +The first track includes milestones like writing a mission statement, choosing a free software license, and establishing a code of conduct, and provides a set of open source tools or frameworks for users to learn more about. The second track includes gradually more advanced milestones like documenting how to set up a development environment, learning the pull request workflow, choosing a project hosting platform, and more. Further tracks include milestones like implementing continuous integration (CI,) organizing community events, and gathering user testimonials. + +The LibreCorps team works with each Innovation Fund team within the cohort to create a rubric specific to their projects. The cohort identifies their current position based on which milestone they are currently working toward. Then, we work together to determine next steps for growing their open source community, then create a strategy to reach and accomplish those goals. + +### Self-evaluation rubric + +The milestone template provides high-level guidance on which direction to go, but the [self-evaluation rubric][15] is a feedback mechanism to give cohorts a picture of exceptional, acceptable, and poor implementations for each assigned task. The self-evaluation rubrics enable LibreCorps cohorts to independently self-evaluate progress towards building a sustainable and open community. + +The rubric is organized into five tracks: + + * Community outreach + * Continuous integration and health checks + * Documentation + * Project management + * Workflow + + + +Each track includes detailed sets of sub-tasks or specific components of building an open source community. For example, documentation includes writing guidelines for how to contribute, and community outreach includes maintaining a project website and engaging with an upstream project community, if one exists. + +The LibreCorps team mostly works with the rubric to evaluate whether Innovation Fund cohort teams sufficiently meet the open source requirement for their project. Some teams make use of the rubric to get a more detailed understanding of whether they are heading in the right direction with their community work. + +### Contribute to these resources + +Do these resources sound useful or interesting? Fortunately, the LibreCorps content is licensed under Creative Commons licenses. Learn more about LibreCorps on the [FOSS@MAGIC website][4] and keep up with what we are doing on [our GitHub][16]. To get in touch with us, visit our community Discourse forums on [fossrit.community][17]. + +A few months ago, we profiled open source projects working to make the world a better place. In... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/humanitarian-startups-open-source + +作者:[Justin W. Flory][a] +选题:[lujun9972][b] +译者:[译者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/jflory +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/world_hands_diversity.png?itok=zm4EDxgE (Two diverse hands holding a globe) +[2]: https://www.rit.edu/magic/ +[3]: https://opensource.com/sites/default/files/uploads/unicef-flory_0.jpg (Grassroots presentation in UNICEF office ) +[4]: https://fossrit.github.io/librecorps/ +[5]: https://www.wired.com/story/wired25-stories-people-racing-to-save-us/ +[6]: https://unicefinnovationfund.org/ +[7]: https://www.rit.edu/magic/affiliate-spotlight-stephen-jacobs +[8]: https://justinwflory.com/ +[9]: https://fossrit.github.io/announcements/2019/04/01/unicef-foss-community-building/ +[10]: https://opensource.com/open-organization/resources/open-org-maturity-model +[11]: https://www.google.com/url?q=https://agora.unicef.org/course/info.php?id%3D18096&sa=D&ust=1573658770972000&usg=AFQjCNGemgWoJ3kCoKImLCDok7opIo2RCA +[12]: https://nolski.rocks/ +[13]: https://kentr.itch.io/ +[14]: https://docs.google.com/document/d/1M2nVwh7ArjAU31M7QZWP4AQz1cOyMhw90iP8Wg9lZNo/edit?usp=sharing +[15]: https://docs.google.com/spreadsheets/d/11DaQxbiOv9_EiZEozEkUapf2AsVQ4vBFelhnZ0a8R4w/edit?usp=sharing +[16]: https://github.com/librecorps/ +[17]: https://fossrit.community/ diff --git a/sources/talk/20191210 Italian job- Translating our mission statement in the open.md b/sources/talk/20191210 Italian job- Translating our mission statement in the open.md new file mode 100644 index 0000000000..4ef0c383ff --- /dev/null +++ b/sources/talk/20191210 Italian job- Translating our mission statement in the open.md @@ -0,0 +1,106 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Italian job: Translating our mission statement in the open) +[#]: via: (https://opensource.com/open-organization/19/12/translating-mission-statement) +[#]: author: (Antonella Iecle https://opensource.com/users/aiecle) + +Italian job: Translating our mission statement in the open +====== +A seemingly straightforward translation exercise turned into a lesson +about the power of open decision making. +![Yellow arrows going both ways with texture][1] + +At Red Hat, part of my job is to ensure that company messages maintain their meaning and effectiveness in my native language—Italian—so that customers in my region can learn not only about our products and services but also about [our organizational values][2]. + +The work tends to be simple and straightforward. But in an open organization, even the tasks that seem small can present big opportunities for learning about the power of working the open way. + +That was the case for me recently, when what I thought would be a quick translation exercise turned into a lesson in the [benefits of open decision making][3]. + +### A crowdsourced decision + +A few months ago, I noticed a post on our company's internal collaboration platform that seemed to be calling my name. Colleagues from around the world were leaving comments on translated versions of one particular (and very important) corporate message: the [company's mission statement][4]. And they had questions about the Italian translation. + +So I joined the conversation with no hesitation, assuming I'd engage in a quick exchange of opinions and reach a conclusion about the best way to translate Red Hat's mission statement: + +_To be the catalyst in communities of customers, contributors, and partners creating better technology the open source way._ + +That's a single sentence consisting of less than 20 words. Translating it into another language should be a no-brainer, right? If anything, the work should take no longer than a few minutes: Read it out loud, spot room for improvement, swap a word for a more effective synonym, maybe rephrase a bit, and you're done! + +As a matter of fact, that's not always the case. + +Translations of the mission statement in a few languages were already available, but comments from colleagues reflected a need for some review. And as more Red Hatters from different parts of the globe joined the discussion and shared their perspectives, I began to see many possibilities for solving this translation problem—and the challenges that come with this abundance of ideas. + +Seeing so many inspiring comments can make reaching a decision much more complicated. One might put concepts into words in a _number_ of ways, but how do we all agree on the _best_ way? How do we deliver a message that reflects our common goal? How do we make sure that all employees can identify with it? And how do we ensure that our customers understand how we can help them grow? + +It's true: When you're about to make a decision that has an impact on other people, you have to ask yourself—and each other—a lot of questions. + +It's true: When you're about to make a decision that has an impact on other people, you have to ask yourself—and each other—a lot of questions. + +### Found in translation + +Localising a message for our readers around the world means more than just translating it word by word. A literal translation may not be fully understandable, especially when the original message was written with English native speakers in mind. On the other hand, a creative translation may be just one of many possible interpretations of the original text. And then there are personal preferences: Which translation sounds better to me? Is there a particular reason? If so, how do I get my point across? + +Linguistic debates can highlight complex aspects of communication, from the subtle nuances in the meaning of a particular word to the cultural traits, mindsets, and levels of familiarity with a topic that define how the same message can be perceived by readers from different countries. Our own conversations delved into known linguistic dilemmas like the use of anglicisms and the disambiguation of expressions that can have more than one interpretation. + +Localisation teams must ensure that messages are delivered accurately and consistently. Working collaboratively is essential to achieving this goal. + +To get started, we only had to look at how our original mission statement had come together in the first place. Since we were trying to do something that someone else had done before, we needed to ask: "[How did Red Hat find its mission][5]?" + +The answer? By asking the whole company what it should be. + +Opening up the conversation doesn't always accelerate the decision making process. + +It may be counterintuitive, but engaging the broader community can be a very efficient way to overcome uncertainties and address problems you weren't even aware of. Opening up the conversation doesn't always accelerate the decision making process, but by bringing people together you allow them to draw a clearer picture of the problem and provide you with the elements you need to make better decisions. + +With that in mind, all you have to do is ask other teams to contribute, then give them a reasonable amount of time to make room in their busy schedule and think about how they can help. Suggestions will come, and how you will channel the incoming information is up to you. + +Surveys are often a great way to gather feedback and keep track of incoming responses, and this is the approach we chose. We submitted a new translation, and asked our teams in Italy to tell us if they were happy with it. The majority of the respondents were. However, a few participants had their own versions to share (and valid comments to add). + +After considering everyone's input, we submitted a second survey. We asked the participants to choose between the solution we offered in the first survey and a _newer_ version, one we obtained by incorporating the feedback we'd received from our recent collaborative discussion. + +The second option was the winner. + +The initial translation did not represent Red Hat's mission as clearly and faithfully as the improved statement did. For example, in the original version, Red Hat was a “point of reference” rather than a "catalyst," and worked with "a community" rather than a larger and more diverse number of "communities." We were using the word "collaborators" instead of "contributors," and our actions were following a set of "principles" rather than the open source "way." + +The changes we made reaffirmed Red Hat's role in the communities and its commitment to open source technology, but also to open source as a way of working. + +Don't be afraid to jump into a conversation—or even to take the lead—if you think you can help to make better decisions. + +So here is some advice this experience taught me: Don't be afraid to jump into a conversation—or even to take the lead—if you think you can help to make better decisions. Because as Jim Whitehurst likes to say, in the open source world, we believe [the best ideas should win][6], no matter where they come from. + +In short, here is my five-point checklist for open decision-making, regardless of the task you face: + + 1. Encourage wide participation. + 2. Welcome all responses as they arrive. + 3. Identify the best ideas and get the most out of everyone's suggestions. + 4. Answer questions and address concerns. + 5. Communicate the outcome, and summarize the steps of the decision process. In doing so, reassert the value of broad collaboration. + + + +One more thing (I know I said I only had five more points, but don't switch off yet): Keep listening to what people might have to say about the decision you just made together. + +The best ideas may take longer to brew. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/19/12/translating-mission-statement + +作者:[Antonella Iecle][a] +选题:[lujun9972][b] +译者:[译者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/aiecle +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/arrows_translation_lead.jpg?itok=S4vAh9CP (Yellow arrows going both ways with texture) +[2]: https://www.redhat.com/en/book-of-red-hat#our-values +[3]: https://opensource.com/open-organization/resources/open-decision-framework +[4]: https://www.redhat.com/en/book-of-red-hat#our-vision-intro +[5]: https://www.managementexchange.com/blog/how-red-hat-used-open-source-way-develop-company-mission +[6]: https://opensource.com/open-organization/16/8/how-make-meritocracy-work diff --git a/sources/talk/20191211 Passive optical LAN- Its day is dawning.md b/sources/talk/20191211 Passive optical LAN- Its day is dawning.md new file mode 100644 index 0000000000..4250c357af --- /dev/null +++ b/sources/talk/20191211 Passive optical LAN- Its day is dawning.md @@ -0,0 +1,91 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Passive optical LAN: Its day is dawning) +[#]: via: (https://www.networkworld.com/article/3489477/passive-optical-lan-its-day-is-dawning.html) +[#]: author: (Zeus Kerravala https://www.networkworld.com/author/Zeus-Kerravala/) + +Passive optical LAN: Its day is dawning +====== + +Getty Images + +The concept of using passive optical LANs in enterprise campuses has been around for years, but hasn’t taken off because most businesses consider all-fiber networks to be overkill for their needs. I’ve followed this market for the better part of two decades, and now I believe we’re on the cusp of seeing POL go mainstream, starting in certain verticals. + +The primary driver of change from copper to optical is that the demands on the network have evolved. Every company now considers its network to be business critical where just a few years ago, it was considered best effort in nature.  Downtime or a congested network meant inconvenienced users, but today they mean the business is likely losing big money. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][1] + +There are also a number of new trends driving the evolution of the campus network.  These include: + +[][2] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][2] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + + * Cloud services. The cloud is certainly the way of the future but it’s playing havoc with enterprise networks. As data centers evolved to modernized systems, East-West traffic was superseded by North-South. Today, businesses are connecting direct to cloud for [hybrid-cloud][3] deployments driving more North-South traffic.  Traditional networks can be a bottleneck.  + * [Internet of Things][4] (IoT). [Wi-Fi 6 and 5G][5] will enable more devices to be connected in more places leading to more bandwidth on the network. For the first time in history, wireless speeds will match wired speeds straining the campus network. + * Video of all kinds is on the rise.  Surveillance, collaboration, room systems, streaming and other kinds of video usage are on the rise.  Video requires high-quality, low-latency connectivity. + + + +### Copper is running out of life + +The increased speeds pose quite a predicament for companies. If the organization has Cat5 cabling, the speed is capped at 1Gbps. If Cat6 is deployed, speeds of 10Gbps can be reached but only 55 meter’s distance. If the company wants to reach the full 100M length of copper, Cat6A or higher must be used.  Optical cable has no distance limitations because POL is completely passive and requires no electronics to boost the signal.  Optical cabling can carry petabytes of bandwidth over long distances.  Also, with optical, there’s no concern over what type of cable is being used and having the quality degrade over time.  Lastly, upgrading speeds is easier.  The cabling can stay in place and just the optics get changed out at the ends of the cable making the process simple. + +### POL is a cheaper, longer lasting than copper upgrades + +If businesses are faced with having to upgrade their networks from Cat5 to another type of cabling, it might make sense to look at POL as it can be the foundation for the campus network for years. + +The early adopters of POL are companies that are highly distributed with large campuses and need to get more network services in more places. This includes manufacturing organizations, universities, hospitality, cities and airports. Although I’ve highlighted a few verticals, the fact is that any business can take advantage of POL. + +### POL in a mixed-use development + +At a Huawei conference earlier this year the company showcased the Dubai Creek Harbor project being built by Emaar Properties – a six-square-mile development including residences, offices, retail and cultural facilities. The complex is designed to be fully digital and the network has to support IoT, cloud computing, AI-based analytics and more. + +The project features an optical network built on Huawei’s Campus OptiX solution that simplifies the network as the architecture moves from a three-tier hierarchical design to a two-tier one. That design uses less equipment and reduces power and cooling requirements. Also, the flat, 10Gbps network obviates the need for parallel overlay networks, making it easier to manage and giving it a degree of future-proofing as the network can easily be upgraded. The all-optical network resulted in a 60% improvement in operational efficiency and a deployment time that was cut in half compared a similar network using Ethernet. + +### Cost effective ** + +** + +Although there are many benefits to POL, adoption has been light. The biggest impediment to its adoption is a general lack of awareness and a misunderstanding of cost. The actual cost of fiber cabling is higher than copper, but I’ve talked to many companies that have looked at fully loaded costs and often optical is cheaper. Optical isn’t subject to electromagnetic interference like copper is so there’s no need to lay a pipeline down first. Also, copper cabling requires distribution cabinets to boost the signal and that adds the cost of UPSes, cooling and power that fiber does not. + +North American buyers may not have the same awareness of POL as those in China, where: + + * The engineering standard of POL was released in June, outlining the system, design, cabling, testing and acceptance rules. + * An alliance was established Oct. 22 bringing together a number of companies including Nokia, Huawei, and Yangtze Optical Fiber and Cable. + + + +Both of these will help drive innovation and standardization. + +Copper has been the preferred campus backbone, but businesses are changing and so is the network. It’s not enough to just change the infrastructure but the cabling that connects everything should be looked at and POL used as a next-generation backbone. + +Join the Network World communities on [Facebook][6] and [LinkedIn][7] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3489477/passive-optical-lan-its-day-is-dawning.html + +作者:[Zeus Kerravala][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Zeus-Kerravala/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.networkworld.com/article/3268448/what-is-hybrid-cloud-really-and-whats-the-best-strategy.html +[4]: https://www.networkworld.com/article/3207535/what-is-iot-how-the-internet-of-things-works.html +[5]: https://www.networkworld.com/article/3402316/when-to-use-5g-when-to-use-wi-fi-6.html +[6]: https://www.facebook.com/NetworkWorld/ +[7]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191211 Passive optical networking- Its day is dawning.md b/sources/talk/20191211 Passive optical networking- Its day is dawning.md new file mode 100644 index 0000000000..c8e61f2c4c --- /dev/null +++ b/sources/talk/20191211 Passive optical networking- Its day is dawning.md @@ -0,0 +1,91 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Passive optical networking: Its day is dawning) +[#]: via: (https://www.networkworld.com/article/3489477/passive-optical-networking-its-day-is-dawning.html) +[#]: author: (Zeus Kerravala https://www.networkworld.com/author/Zeus-Kerravala/) + +Passive optical networking: Its day is dawning +====== + +Getty Images + +The concept of using passive optical LANs in enterprise campuses has been around for years, but hasn’t taken off because most businesses consider all-fiber networks to be overkill for their needs. I’ve followed this market for the better part of two decades, and now I believe we’re on the cusp of seeing POL go mainstream, starting in certain verticals. + +The primary driver of change from copper to optical is that the demands on the network have evolved. Every company now considers its network to be business critical where just a few years ago, it was considered best effort in nature.  Downtime or a congested network meant inconvenienced users, but today they mean the business is likely losing big money. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][1] + +There are also a number of new trends driving the evolution of the campus network.  These include: + +[][2] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][2] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + + * Cloud services. The cloud is certainly the way of the future but it’s playing havoc with enterprise networks. As data centers evolved to modernized systems, East-West traffic was superseded by North-South. Today, businesses are connecting direct to cloud for [hybrid-cloud][3] deployments driving more North-South traffic.  Traditional networks can be a bottleneck.  + * [Internet of Things][4] (IoT). [Wi-Fi 6 and 5G][5] will enable more devices to be connected in more places leading to more bandwidth on the network. For the first time in history, wireless speeds will match wired speeds straining the campus network. + * Video of all kinds is on the rise.  Surveillance, collaboration, room systems, streaming and other kinds of video usage are on the rise.  Video requires high-quality, low-latency connectivity. + + + +### Copper is running out of life + +The increased speeds pose quite a predicament for companies. If the organization has Cat5 cabling, the speed is capped at 1Gbps. If Cat6 is deployed, speeds of 10Gbps can be reached but only 55 meter’s distance. If the company wants to reach the full 100M length of copper, Cat6A or higher must be used.  Optical cable has no distance limitations because POL is completely passive and requires no electronics to boost the signal.  Optical cabling can carry petabytes of bandwidth over long distances.  Also, with optical, there’s no concern over what type of cable is being used and having the quality degrade over time.  Lastly, upgrading speeds is easier.  The cabling can stay in place and just the optics get changed out at the ends of the cable making the process simple. + +### POL is a cheaper, longer lasting than copper upgrades + +If businesses are faced with having to upgrade their networks from Cat5 to another type of cabling, it might make sense to look at POL as it can be the foundation for the campus network for years. + +The early adopters of POL are companies that are highly distributed with large campuses and need to get more network services in more places. This includes manufacturing organizations, universities, hospitality, cities and airports. Although I’ve highlighted a few verticals, the fact is that any business can take advantage of POL. + +### POL in a mixed-use development + +At a Huawei conference earlier this year the company showcased the Dubai Creek Harbor project being built by Emaar Properties – a six-square-mile development including residences, offices, retail and cultural facilities. The complex is designed to be fully digital and the network has to support IoT, cloud computing, AI-based analytics and more. + +The project features an optical network built on Huawei’s Campus OptiX solution that simplifies the network as the architecture moves from a three-tier hierarchical design to a two-tier one. That design uses less equipment and reduces power and cooling requirements. Also, the flat, 10Gbps network obviates the need for parallel overlay networks, making it easier to manage and giving it a degree of future-proofing as the network can easily be upgraded. The all-optical network resulted in a 60% improvement in operational efficiency and a deployment time that was cut in half compared a similar network using Ethernet. + +### Cost effective ** + +** + +Although there are many benefits to POL, adoption has been light. The biggest impediment to its adoption is a general lack of awareness and a misunderstanding of cost. The actual cost of fiber cabling is higher than copper, but I’ve talked to many companies that have looked at fully loaded costs and often optical is cheaper. Optical isn’t subject to electromagnetic interference like copper is so there’s no need to lay a pipeline down first. Also, copper cabling requires distribution cabinets to boost the signal and that adds the cost of UPSes, cooling and power that fiber does not. + +North American buyers may not have the same awareness of POL as those in China, where: + + * The engineering standard of POL was released in June, outlining the system, design, cabling, testing and acceptance rules. + * An alliance was established Oct. 22 bringing together a number of companies including Nokia, Huawei, and Yangtze Optical Fiber and Cable. + + + +Both of these will help drive innovation and standardization. + +Copper has been the preferred campus backbone, but businesses are changing and so is the network. It’s not enough to just change the infrastructure but the cabling that connects everything should be looked at and POL used as a next-generation backbone. + +Join the Network World communities on [Facebook][6] and [LinkedIn][7] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3489477/passive-optical-networking-its-day-is-dawning.html + +作者:[Zeus Kerravala][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Zeus-Kerravala/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.networkworld.com/article/3268448/what-is-hybrid-cloud-really-and-whats-the-best-strategy.html +[4]: https://www.networkworld.com/article/3207535/what-is-iot-how-the-internet-of-things-works.html +[5]: https://www.networkworld.com/article/3402316/when-to-use-5g-when-to-use-wi-fi-6.html +[6]: https://www.facebook.com/NetworkWorld/ +[7]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191212 Companies Prefer Hybrid Cloud to Escape Public Cloud Data Grabbity.md b/sources/talk/20191212 Companies Prefer Hybrid Cloud to Escape Public Cloud Data Grabbity.md new file mode 100644 index 0000000000..3b58213cf7 --- /dev/null +++ b/sources/talk/20191212 Companies Prefer Hybrid Cloud to Escape Public Cloud Data Grabbity.md @@ -0,0 +1,59 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Companies Prefer Hybrid Cloud to Escape Public Cloud Data Grabbity) +[#]: via: (https://www.linux.com/articles/companies-prefer-hybrid-cloud-to-escape-public-cloud-data-grabbity/) +[#]: author: (Swapnil Bhartiya https://www.linux.com/author/swapnil/) + +Companies Prefer Hybrid Cloud to Escape Public Cloud Data Grabbity +====== + +[![][1]][2] + +[![][1]][2] + +As the cloud native space is maturing, customers have started to discern the pros and cons of public cloud. They can see not just the facade of convenience and promised cost savings, but also the bills piling up and having to hand over critical business data to public cloud companies. + +[Red Hat recently conducted a global customer survey][3] about this and results indicate that customers prefer hybrid cloud over public cloud. More than 31% respondents actually used the term hybrid cloud as their cloud strategy. + +Rob Hirschfeld, founder and CEO of RackN and attendee of the recent [Gartner IT Infrastructure, Operations & Cloud Strategies Conference][4], noticed a similar tone. “Discussions and data from the Gartner IO Summit support that hybrid is preferred. There’s just so much existing infrastructure that it’s not practical to be ‘pure’ anything! It’s not so much that they want hybrid but that it’s the reality they are facing.” + +There are many reasons why customers prefer hybrid over public cloud or pure private cloud. Red Hat says it boils down to three factors: data security, cost benefits, and data integration. + +“Everyone accepts that cloud is secure; however, operators are starting to question how well they can control their data in cloud. Also, some of them don’t trust the cloud vendors, especially with some of the new analytics services,” said Hirschfeld. + +Hybrid cloud enables customers to balance all three factors highlighted in the Red Hat survey. They can move pieces of their infrastructure between public and private cloud depending on the need. It lets them reap the benefits of public cloud without having to compromise their data. + +Although 31% might seem like a small number, it doesn’t mean that the remaining 69% is running their workloads on public cloud. In fact, only 12% described themselves as having either a public cloud first strategy or a strategy to standardize on a single public cloud. Red Hat says 6% described their strategy as multi-cloud based on multiple public clouds, while 21% have a private cloud first strategy. + +In particular, EMEA respondents described themselves as having a private cloud strategy, not hybrid. This region is concerned about handing over their data to US-based cloud companies, given its current political landscape. A simple embargo on your country will cut your entire business out of the public cloud run by Google, AWS, and Azure. Some of the biggest use cases in this region involve companies building their own private and public cloud using OpenStack. + +Perhaps the most worrisome finding is that there are still companies without any concrete cloud strategy. Around 17% of the respondents were still working on a plan, while 12% respondents didn’t have any plan at all. Unfortunately, these companies are so far behind the curve that their future hangs in the balance. Hirschfeld warns that there is an urgency to cut their technical debt and embrace cloud now or they will find it hard to survive in the modern world. + +In fact, Hirschfeld states that you need to have a cloud strategy even if you don’t use cloud. “The reality is that cloud is the default deployment choice for everything — from demos and proof-of-concept to training — because it’s predictable and accessible.” Teams must adapt to the patterns, even if they are not adopting. + +The Red Hat survey found that companies do recognize the importance of building up technical skills. When asked to choose their top non-IT funding priorities, respondents chose both technical skills training (16%) and a digital transformation strategy (16%). + +However, new technologies and jargon are emerging at such a fast pace that it’s virtually impossible to find experts (or even skilled professionals) in technologies that were open-sourced at CNCF just a month ago. The hype/adoption curve is so accelerated that it has gotten silly. Therefore, porting to the latest shiny requires evaluation. + +“The reality is that new projects, even Kubernetes, still need baking time for scale operations. If there are not enough people with knowledge, then it’s OK (really, it’s required) to pick your battles or slow your adoption,” said Hirschfeld. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/articles/companies-prefer-hybrid-cloud-to-escape-public-cloud-data-grabbity/ + +作者:[Swapnil Bhartiya][a] +选题:[lujun9972][b] +译者:[译者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/author/swapnil/ +[b]: https://github.com/lujun9972 +[1]: https://www.linux.com/wp-content/uploads/2019/12/computer-2930704_1280-1068x634.jpg (computer-2930704_1280) +[2]: https://www.linux.com/wp-content/uploads/2019/12/computer-2930704_1280.jpg +[3]: https://www.redhat.com/en/blog/red-hat-global-customer-tech-outlook-2020-hybrid-cloud-leads-strategy-aiml-leaps-forefront +[4]: https://www.gartner.com/en/conferences/na/infrastructure-operations-cloud-us diff --git a/sources/talk/20191212 Liquid cooling and edge computing are featured at Gartner show.md b/sources/talk/20191212 Liquid cooling and edge computing are featured at Gartner show.md new file mode 100644 index 0000000000..26d95b835c --- /dev/null +++ b/sources/talk/20191212 Liquid cooling and edge computing are featured at Gartner show.md @@ -0,0 +1,69 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Liquid cooling and edge computing are featured at Gartner show) +[#]: via: (https://www.networkworld.com/article/3489467/liquid-cooling-and-edge-computing-are-featured-at-gartner-show.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +Liquid cooling and edge computing are featured at Gartner show +====== +Non-traditional hardware makes the news at Gartner’s show focused on data-center operations. +ExaScaler + +Research firm Gartner is holding its IT Infrastructure, Operations, and Cloud Strategies Conference (IOCS) in Las Vegas this week, and a few news announcements from the show give an indication as to where [data-center][1] technology is headed. + +First up, Schneider Electric and Iceotope formally introduced their integrated rack with chassis-based immersive liquid-cooling designs. The deal was [announced][2] in October but now the details are out. In addition to Schneider and Iceotope, the alliance also includes Avnet, an electronic-component distributor. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][3] + +The server is optimized for compute-intensive applications such as analytics and artificial intelligence. It combines a high-powered GPU server with Iceotope’s liquid-cooling technology, while Avnet integrates the server with Schneider’s NetShelter liquid-cooled enclosure system for simple deployment into data centers or edge-computing environments. + +[][4] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][4] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +This is a big advance because most immersion solutions have been using a bathtub design where the motherboard sat vertically in the immersion fluid and the ports stuck out at the top. It was something of a clumsy design that just begged for spillage. Here, the chassis looks like any other rack-mounted server, but it is enclosed and sealed. + +The system is certified EcoStruxure Ready, meaning it works with Schneider’s enclosures, and comes with next-generation data center management software EcoStruxure IT Expert and digital service EcoStruxure Asset Advisor. + +“This latest development marks a significant step toward industrializing chassis-based immersion solutions which offer the efficiency and effectiveness of tank-based solutions while providing the compatibility and serviceability of more traditional, ‘direct-to-chip’ liquid-cooling designs. Given the growth of compute-intensive applications, we believe this approach is very promising,” said Kevin Brown, CTO and senior vice president of innovation, secure power at Schneider Electric in a statement. + +### Scale Computing: Tiny edge device + +Scale Computing introduced the HE150 at the show, the latest addition to its HC3 Edge product line intended for space-constrained and edge customers. + +The HE150 is a very small device based on the [Intel NUC][5] design, and Scale notes it is about the size of three smartphones, with a width and depth of just over 11 centimeters and a height of just over three centimeters. + +The HE150 appliance is a small, all-flash, [NVMe][6] storage-based compute appliance that supports disaster recovery, high availability clustering, rolling upgrades and integrated data protection. As it is, Scale sells them in three-node clusters. + +Scale also announced it plans to make its HC3 Edge software for Intel NUC-based systems from other hardware suppliers. HC3 Edge software will be available soon for Lenovo’s new Smart Edge portfolio of fan-less, small-form-factor PCs. + +Join the Network World communities on [Facebook][7] and [LinkedIn][8] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3489467/liquid-cooling-and-edge-computing-are-featured-at-gartner-show.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3223692/what-is-a-data-centerhow-its-changed-and-what-you-need-to-know.html +[2]: https://www.networkworld.com/article/3444624/schneider-electric-launches-wall-mounted-server-rack.html +[3]: https://www.networkworld.com/newsletters/signup.html +[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[5]: https://www.intel.com/content/www/us/en/products/boards-kits/nuc.html +[6]: https://www.networkworld.com/article/3280991/what-is-nvme-and-how-is-it-changing-enterprise-storage.html +[7]: https://www.facebook.com/NetworkWorld/ +[8]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191212 Secure SD-WAN- The security vendors and their SD-WAN offerings.md b/sources/talk/20191212 Secure SD-WAN- The security vendors and their SD-WAN offerings.md new file mode 100644 index 0000000000..9d3e799da4 --- /dev/null +++ b/sources/talk/20191212 Secure SD-WAN- The security vendors and their SD-WAN offerings.md @@ -0,0 +1,136 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Secure SD-WAN: The security vendors and their SD-WAN offerings) +[#]: via: (https://www.networkworld.com/article/3489480/secure-sd-wan-the-security-vendors-and-their-sd-wan-offerings.html) +[#]: author: (Matt Conran https://www.networkworld.com/author/Matt-Conran/) + +Secure SD-WAN: The security vendors and their SD-WAN offerings +====== +A networking vendor simply can’t jump into this space. Some SD-WANs add stateful packet filters and call this security. +[Gerd Altmann][1] [(CC0)][2] + +During its inception, we had the early adopters and pure SD-WAN players. Soon it became obvious that something was missing, and that missing component was “security.” However, security vendors have highlighted the importance of security from the very beginning. + +Today, the market seems to be moving in the direction where the security vendors are focusing on delivering SD-WAN features around pervasive security. The Magic Quadrant for WAN Edge Infrastructure has made a substantial prediction. It states, “By 2024, 50% of new firewall purchases in distributed enterprises will utilize SD-WAN features with the growing adoption of cloud-based services, up from less than 20% today.” + +Nowadays we have security vendors like Forcepoint, SonicWall and Barracuda that follow the pattern of Fortinet. The vendors offer a built-in security stack to the WAN edge architecture for distributed enterprise use cases. + +[][3] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][3] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +### Introducing secure SD-WAN + +Pronouncedly, secure SD-WAN includes the best-of-breed next-generation firewall security, SD-WAN, advanced routing, and WAN optimization to deliver a security-driven WAN edge. It combines the SD-WAN feature and security features together.   + +The secure SD-WAN solution can be placed fully in the branch and the cloud or a hybrid approach can be adopted. For those who don’t want to put everything in the cloud, a hybrid approach could be more viable. + +To me, it is quite interesting seeing how the queries are coming into the analysts and how customers are giving attention to this field. Markedly, Gartner estimates that Fortinet has more than 21,000 WAN edge customers. That’s a considerable user base and makes a compelling case, especially when strong and built-in security capabilities are the key requirements. + +### Adding security to networking + +It is definitely easier for a security company to add new networking features than for an SD-WAN company to add 20 years of advanced security features. We can safely assume that no SD-WAN vendor is going to become a security vendor. + +**[ Now read [20 hot jobs ambitious IT pros should shoot for][4]. ]** + +As the market developed, in due course, some features had to be renamed: when we talk about application identification, encryption, path monitoring, routing protocols and WAN link load balancing. Fundamentally, all of these advanced routing features are not new and specific to SD-WAN. These are not overnight successes and have been in the market even before the market existed. + +However, in some scenarios, maybe you have to implement a proprietary routing protocol across the WAN. In this case, yes, of course, you require a new device. But for most of the part, a comprehensive firewall at the edge will suffice. + +### The firewall at the WAN edge + +Firewalls are evolving into network security platforms, thereby offering SD-WAN capabilities. The Magic Quadrant for Network Firewalls states “The SMB multifunction firewall market grew 10.1% in 2018, with SD-WAN adoption being a strong driver.” + +When you think about it, you will realize that the firewall has been acting as a router for a long time. Essentially, the firewall can provide all the routing protocols to facilitate private WAN, internet and internal routing. This functionality is usually provided by a basic device that just does the routing. However, now we are witnessing the replacement of these by an edge appliance with firewalls. + +Firewalls have resided in the networks for decades. Their role has not just been confined to doing the firewalling but also participating in the routed networks. Time and again, they have been providing a routed WAN edge device. + +### Issues with legacy security design + +How do you integrate security with SD-WAN? Primarily, the common design involves the integration of multiple security point solutions. Now, let’s learn about the aftermath of these point solutions. + +### Complexity + +The point solution only addresses one issue and requires a considerable amount of integration with others. Because of this, they are often service-chained together. Each part must be carefully integrated with the other. + +You must continuously add solutions to the stack, which is likely to result in management overhead and increased complexity. Not to mention the challenges with NOC and SOC team integration. Contrarily, the original selling point for SD-WAN was to reduce complexity and not intensify it. + +If we examine security in the world of SD-WAN; the way it has been geared up at the moment is provided in parts that actually increase complexity. It’s like building a house with individual pieces when you actually just want to buy a house. + +If you analyze, you will find that many SD-WANs are merely bringing in security technologies from other vendors, joined together to sell them to the customers. + +### Associated costs + +Having multiple point solutions often from different vendors dispersed around the network is expensive. There’s never a fixed price. Some security vendors may charge on usage models which you may not have the quantity for yet. So, how do you effectively plan for this when you have multiples?  + +As the costs keep adding up, the security professionals may decide to trade-off certain point solutions due to the associated costs. We know now this is not an effective risk management strategy. Ideally, in terms of security, you don't do something when it is needed; you do it before it is needed. This means threat intelligence is the key, which is often overlooked by many SD-WAN vendors. + +It’s far more critical from both technical and cost perspective to bring each of the security point solution functionalities together under one hood. And to do this, someone that specializes in security from day one would fit the bill. This is why there has been a move to provide SD-WAN features along with advanced security into one comprehensive integrated platform. + +Secure SD-WAN is what combines both network and security into one integrated platform. This leads to no more complex management, licensing issues, high costs or unnecessary service chaining. + +### SD-WAN is not about features + +There is a lot of noise in the SD-WAN market about the features. Let’s face it ‘features really don’t draw much value to create market separation’. Practically, the value proposition for SD-WAN is not about the feature. Everyone is doing a good job in classifying applications and sending them across the best path. Let’s understand the true value proposition for SD-WAN. + +### Performance and scalability + +When it comes to SD-WAN, the bell to ring is often application steering, but if you don’t have, for example, the deep TLS1.3 inspection with solid performance, how can you get accurate identification and make sure your branch is secure? Not enough people are talking about this. + +For this, we need custom SD-WAN-specific application-specific integrated circuits (ASICs). This offers an incredible advantage for the high resource intensive encryption/decryption and overlay scalability. + +With IPSec, there are intensive encrypting operations that consume a lot of CPU and RAM. Therefore, a purpose-built SD-WAN ASIC is built just to do that so it consumes less CPU and RAM per tunnel. + +In general, the scalability stops at 1,000 or 1,500. With the proper ASIC, this number can be scaled to over 100,000, which may be useful for some hub site designs. By using the ASIC, you can run the networking stack and security stack in the same appliance, making a very efficient and cost-effective solution. + +### The importance of threat intelligence + +The next-generation firewall is in the datasheets for many SD-WAN vendors. However, what about the threat detection and threat prevention? A big piece missing from the many SD-WAN vendors is threat intelligence in alliance with threat research. The threat landscape is evolving, so too should the security solution to keep in line with today’s and tomorrow's threats. + +Threat prevention has core features from layer 4 to layer 7 such as IPS, content filtering, deep SSL inspection, and anti-malware. Furthermore, we also have a threat detection piece. Nowadays, you can no longer rely on detecting known threats, you have to detect unknown threats too. So having a stack of both prevention and detection features is very important. With the two features glued together, we can have experienced security research and analyst teams. It is significant to observe whether the SD-WAN vendor has its own threat intelligence. + +For this, we really do need the security company pedigree. The core value for any security vendor comes with their level of intelligence research. This is what creates market separation, not SD-WAN features. + +However, there is another step, which is to confirm if the proposed features have been validated by 3rd parties such as NSS labs. NSS Labs has evaluated some of these security vendors for their SD-WAN leading products on areas such as the quality of experience (QoE) of VoIP and video, performance (WAN impairments and HA), the total cost of ownership (TCO) along with security effectiveness. + +Also, we must question how often does the ‘SD-WAN device providing firewalling’ gets updated with the latest threat information. Is this process carried a few times per day or per week? Some SD-WAN solutions market them as a secure SD-WAN vendor, but if we go back to the point of building effective security, we need a solid threat intelligence team. Do startups have enough manpower to do that? A networking vendor simply can’t jump into this space. Some SD-WANs add stateful packet filters and call this security. + +Let’s be honest, a next-generation firewall can be used by anyone. However, the importance of the breadth of the features, the intelligence they provide and the recognition in the market play a huge role. This is what builds trust in the next-generation firewall in the branch and ensures that the best security posture remains the best. + +When you’re looking for secure SD-WAN vendors, highlight these questions and examine how old their security stack is. Also, assess if they have an experienced threat intelligence team. + +The market is moving towards a secure SD-WAN solution. The industry analysis and the rise of the customer base have a great impact in today’s time. It is not the case that people are recognizing security vendors as strong SD-WAN players. + +However, recognizing the market demands secure SD-WAN in one integrated comprehensive platform. + +**This article is published as part of the IDG Contributor Network. [Want to Join?][5]** + +Join the Network World communities on [Facebook][6] and [LinkedIn][7] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3489480/secure-sd-wan-the-security-vendors-and-their-sd-wan-offerings.html + +作者:[Matt Conran][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Matt-Conran/ +[b]: https://github.com/lujun9972 +[1]: https://pixabay.com/illustrations/network-control-block-chain-hexagon-4478145/ +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[4]: https://www.networkworld.com/article/3276025/careers/20-hot-jobs-ambitious-it-pros-should-shoot-for.html +[5]: https://www.networkworld.com/contributor-network/signup.html +[6]: https://www.facebook.com/NetworkWorld/ +[7]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191213 Space-data-as-a-service gets going.md b/sources/talk/20191213 Space-data-as-a-service gets going.md new file mode 100644 index 0000000000..c2c840e831 --- /dev/null +++ b/sources/talk/20191213 Space-data-as-a-service gets going.md @@ -0,0 +1,83 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Space-data-as-a-service gets going) +[#]: via: (https://www.networkworld.com/article/3489484/space-data-as-a-service-gets-going.html) +[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) + +Space-data-as-a-service gets going +====== +Development of IoT services in space will require ruggedized edge computing. OrbitsEdge, a vendor has announced a deal with HPE for development. +[REUTERS/Joe Skipper/File Photo][1] + +Upcoming space commercialization will require hardened edge-computing environments in a small footprint with robust links back to Earth, says vendor [OrbitsEdge][2], which recently announced that it had started collaborating with Hewlett Packard Enterprise on computing-in-orbit solutions. + +OrbitsEdge says it’s the first to provide a commercial [data-center][3] environment for installing in orbit, and will be using HPE’s Edgeline Converged Edge System in a hardened, satellite [micro-data-center][4] platform that it’s selling called SatFrame. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][5] + +The idea is “to run analytics such as artificial intelligence (AI) on the vast amounts of data that will be created as space is commercialized,” says Barbara Stinnett, CEO of OrbitsEdge, in a [press release][6]. + +[][7] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][7] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +### Why data in space? + +[IoT][8] data collection along with analysis and experimental testing are two examples of space industrialization that the company gives as use cases for its micro-data center product. However, commercial use of space also includes imagery, communications, weather forecasting and navigation. Space tourism and commercial recovery of space resources, such as mined raw materials from asteroids are likely to be future space-uses, too. + +Also, manufacturing – taking advantage of vacuums and zero-gravity environments – is among the economic activities that could take advantage of number crunching in orbit. + +Additionally, [Cloud Constellation Corp., a company I wrote about in 2017, unrelated to OrbitsEdge or HPE, reckons highly sensitive data should be stored isolated][9] [in][9] [space][9]. That would be the “ultimate air-gap security,” it describes its [SpaceBelt][10] product. + +### Why edge in space? + +OrbitsEdge believes that data must be processed where it is collected, in space, in order to reduce transmission bottlenecks as streams are piped back to Earth stations. “Due to the new wave of low-cost commercial space activity, the bottleneck will get worse,” the company explains on its website. + +What it means is that getting satellites into space is now cheap and is getting cheaper (due primarily to reusable rocket technology), but that there’s a problem getting the information back to traditional cloud environments on the surface of the Earth; there’s not enough backhaul data capacity, and that increases processing costs. Therefore, the cloud needs to move to the data-collection point: It’s “IoT above the cloud,” ObitsEdge cleverly taglines. + +### How it works + +Satellite-mounted solar arrays collect power from the sun. They fill batteries to be used when the satellite is in the shadow of Earth. + +Cooling- and radiation-shielding protect a standard 5U, 19-inch server rack. There’s a separate rack for the avionics. Then integrated, traditional space-to-space, and space-to-ground radio communications handle the comms. Future-proofing is also considered: laser data pipes, too, could be supported, the company says. + +#### On Earth option + +Interestingly, the company is also pitching its no-maintenance, low Earth orbit (LEO)-geared product as being suitable for terrestrial extreme environments, too. OrbitsEdge claims that SatFrame is robust enough for extreme chemical and temperature environments on Earth. Upselling, it also says that one could combine two micro-data centers: a LEO SatFrame running HPE’s Edgeline, communicating with another one in an extreme on-Earth location—one at the Poles, maybe. + +“To keep up with the rate of change and the number of satellites being launched into low Earth orbit, new services have to be made available,” OrbitsEdge says. “Shipping data back to terrestrial clouds is impractical, however today it is the only choice,” it says. + +Join the Network World communities on [Facebook][11] and [LinkedIn][12] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3489484/space-data-as-a-service-gets-going.html + +作者:[Patrick Nelson][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Patrick-Nelson/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3489484/Reuters +[2]: https://orbitsedge.com/ +[3]: https://www.networkworld.com/article/3223692/what-is-a-data-centerhow-its-changed-and-what-you-need-to-know.html +[4]: https://www.networkworld.com/article/3445382/10-hot-micro-data-center-startups-to-watch.html +[5]: https://www.networkworld.com/newsletters/signup.html +[6]: https://orbitsedge.com/press-releases/f/orbitsedge-oem-agreement-with-hewlett-packard-enterprise +[7]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[8]: https://www.networkworld.com/article/3207535/what-is-iot-the-internet-of-things-explained.html +[9]: https://www.networkworld.com/article/3200242/data-should-be-stored-data-in-space-firm-says.html +[10]: http://spacebelt.com/ +[11]: https://www.facebook.com/NetworkWorld/ +[12]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191213 What-s hot at the edge for 2020- Everything.md b/sources/talk/20191213 What-s hot at the edge for 2020- Everything.md new file mode 100644 index 0000000000..5f15b10d12 --- /dev/null +++ b/sources/talk/20191213 What-s hot at the edge for 2020- Everything.md @@ -0,0 +1,119 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What’s hot at the edge for 2020? Everything) +[#]: via: (https://www.networkworld.com/article/3489938/what-s-hot-at-the-edge-for-2020-everything.html) +[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) + +What’s hot at the edge for 2020? Everything +====== +From SD-WAN and cloud interconnection to security, the edge will be one active place in 2020 +Thinkstock + +Few areas of the enterprise face as much churn as the edge of the network.  Experts say a variety of challenges drive this change – from increased [SD-WAN][1] access demand to cloud interconnected resources and [IoT][2], the traditional perimeter of the enterprise is shifting radically and will continue to do so throughout 2020. + +One indicator: Gartner research that says by 2023, more than 50% of enterprise-generated data will be created and processed outside the [data center][3] or cloud, up from less than 10% in 2019. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][4] + +Hand-in-hand with that change is a shift in what technologies are supported at the edge of the network – and that means information processing, content collection and delivery are placed closer to the sources, repositories and consumers of this information. Edge networking tries to keep the traffic and processing local to reduce latency, exploit the capabilities of the edge and enable greater autonomy at the edge, [Gartner says][5]. + +[][6] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][6] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +The scope of enterprise WAN networks is broadening. No longer is it only from a branch edge to a data-center edge. Now the boundaries have shifted across the LAN from individual clients and devices on the one end and across the WAN to individual containers in data centers or clouds on the other, said Sanjay Uppal, vice president and general manager of VMware’s VeloCloud Business Unit. “This broadening of the WAN scope is a direct consequence of the democratization of data generation and the need to secure that data. So, we end up with edges at clients, servers, devices, branches, private data centers, public data centers, telco POP, RAN and the list goes on. Additionally, with IoT and mobility taking hold at the enterprise, the edge is moving out from the traditional ‘branch’ to the individual clients and devices.” + +“The evolution of business applications from monolithic constructs to flexible containerized workloads necessitates the evolution of the edge itself to move closer to the application data,” Uppal said. “This, in turn, requires the enterprise network to adjust and meet and exceed the requirements of the modern enterprise.” + +Such changes will ultimately make defining what constitutes the edge of the network more difficult. + +“With increased adoption of cloud-delivered services, unmanaged mobile and IoT devices, and integration of networks outside the enterprise (particularly partners), the edge is more difficult to define. Each of these paradigms extend the boundaries of today's organizations,” said Martin Kuppinger,  principal analyst with [KuppingerCole Analysts A][7]G.  “On the other hand, there is a common perception that there is no such perimeter anymore with statements such as “the device is the perimeter” or “identity is the new perimeter”. To some extent, all of this is true – and wrong. There still might be perimeters in defined micro-segments. But there is not that one, large perimeter anymore.” + +The enterprise is not the only arena that will see continued change in 2020, there are big changes afoot on the WAN was well.  + +Analysts from [IDC wrote][8] earlier this year that traditional enterprise WANs are increasingly not meeting the needs of digital businesses, especially as it relates to supporting SaaS apps and multi- and [hybrid-cloud][9] usage. Enterprises are interested in easier management of multiple connection types across their WAN to improve application performance and end-user experience – hence the growth of SD-WAN technologies. + +“The market for branch-office WAN-edge functionality continues to shift from dedicated routing, security and WAN optimization appliances to feature-rich software-defined WAN and, to a lesser extent, [universal customer-premises equipment] platforms,” [Gartner wrote][10].  “SD-WAN is replacing routing and adding application-aware path selection among multiple links, centralized orchestration and native security, as well as other functions. Consequently, it includes incumbent and emerging vendors from multiple markets (namely routing, security, WAN optimization and SD-WAN), each bringing its own differentiators and limitations.” + +One of the biggest changes for 2020 could come around the SD-WAN. One of the drivers stems from the relationships that networking vendors such as Cisco, VMware, Juniper, Arista and others have with the likes of Amazon Web Services, Microsoft Azure, Google Anthos and IBM RedHat.  + +An indicator of those changes came this month when AWS announced a slew of services for its cloud offering that included new integration technologies such as [AWS Transit Gateway][11], which lets customers connect their Amazon Virtual Private Clouds (VPCs) and their on-premises networks to a single gateway. Aruba, Aviatrix Cisco, Citrix Systems, Silver Peak and Versa already announced support for the technology which promises to simplify and enhance the performance of SD-WAN integration with AWS cloud resources. + +The ecosystem around this type of cloud interconnection is likely one of the hottest areas of growth for 2020, experts say. + +SD-WAN is critical for businesses adopting cloud services, acting as a connective tissue between the campus, branch, IoT, data center and cloud, said Sachin Gupta, senior vice president, product management, with Cisco Enterprise Networking in a recent [Network World][12] article. “It brings all the network domains together and delivers the outcomes business requires." + +"It must align user and device policies, and provide assurance to meet application service-level agreements. It must deliver robust security to every device and every cloud that the enterprise’s data touches.” The AWS Transit Gateway will let IT teams implement consistent network and data security rules, he said. + +All of these edge transformations will most certainly bring with it security challenges. Kuppinger noted a few including: + + * Has "shadow IT" subscribed to SaaS, which now contains important business data? How is it managed? + * Does the IT department use IaaS for dev/test or pre-production? Is it loaded with copies of production data? How is that controlled? + * Does IT use IaaS and PaaS for line-of-business applications? Is it managed centrally like legacy applications? + * Does the enterprise allow BYOD? Are unified endpoint-management or mobile anti-malware solutions mandated for such devices? + * Are IoT devices on the networks? Are they outside of your networks, but delivering critical services for customers? + * Are third-party risks enumerated and controlled? + + + +“Each of these situations is beyond the traditional edge and can increase your enterprise attack surface and risk,” Kuppinger said. “Once identified, enterprises must figure out how to secure the edges and get more complete visibility to all risks and mitigations. New tools may be needed. Some organizations may choose to engage more managed security services,” he said. + +The perimeter needs to be everywhere and hence the advent of the zero-trust architecture, VMware’s Uppal said. “This requires an end-to-end view where posture is checked at the edge, and based on that assessment network traffic is segmented both to reduce the attack surface and also the blast radius. i.e., first reduce the likelihood that something is going to go wrong, but if it does then minimize the impact,” Uppal said.  + +“As traffic traverses the network, security services, both letting through the good while blocking the bad are inserted based on policy. Here again the network of cloud services that dynamically sequences security based on business policy is critical,” Uppal said.  + +Going forward enterprise organizations might need to focus less on the network itself. “Protect the services, protect the communication between devices and services, protect the devices and the identities of the users accessing these devices. This is very much what the “[zero trust][13]” paradigm has in mind – notably, this is not primarily “zero-trust networks”, but zero trust at all levels,” Kuppinger said. + +“The most important learning is: Protecting just the network at its edge is not sufficient anymore. If there is a defined network – either physical such as in OT or virtual such as in many data centers – this adds to protection,” Kuppinger said. + +The mixture of cloud and security services at the edge will lead to another trend in 2020, one that Gartner calls secure access service edge (SASE) which is basically the melding of network and security-as-a-service capabilities into a cloud-delivered package. By 2024, at least 40% of enterprises will have explicit strategies to adopt [SASE][14], up from less than 1% at year-end 2018, Gartner says.  + +“SASE is in the early stages of development,” Gartner says. “Its evolution and demand are being driven by the needs of digital business transformation due to the adoption of SaaS and other cloud-based services accessed by increasingly distributed and mobile workforces, and to the adoption of edge computing.” + +Early manifestations of SASE are in the form of SD-WAN vendors adding network security capabilities and cloud-based security vendors offering secure web gateways, zero-trust network access and cloud-access security broker services, Gartner says. + +Regardless of what it’s called, it is clear the melding of cloud applications, security and new edge WAN services will be increasing in 2020. + +“We are seeing the rise of microservices in application development, allowing applications to be built based upon a collection of discrete technology elements.  Beyond new application architectures, there are demands for new applications to support IoT initiatives and to push compute closer to the user for lower latency and better application performance,” VMware’s Uppal said. “With the maturation of Kubernetes, what is needed is the next set of application-development and -deployment tools that work cooperatively with the underlying infrastructure, compute, network and storage to serve the needs of that distributed application.” + +[See more predictions about what's big in IT tech for the coming year.][15] + +Join the Network World communities on [Facebook][16] and [LinkedIn][17] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3489938/what-s-hot-at-the-edge-for-2020-everything.html + +作者:[Michael Cooney][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Michael-Cooney/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3031279/sd-wan-what-it-is-and-why-you-ll-use-it-one-day.html +[2]: https://www.networkworld.com/article/3207535/what-is-iot-the-internet-of-things-explained.html +[3]: https://www.networkworld.com/article/3223692/what-is-a-data-centerhow-its-changed-and-what-you-need-to-know.html +[4]: https://www.networkworld.com/newsletters/signup.html +[5]: https://www.networkworld.com/article/3447397/gartner-10-infrastructure-trends-you-need-to-know.html +[6]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[7]: https://twitter.com/kuppingercole +[8]: https://www.idc.com/getdoc.jsp?containerId=prUS45380319 +[9]: https://www.networkworld.com/article/3268448/what-is-hybrid-cloud-really-and-whats-the-best-strategy.html +[10]: https://www.networkworld.com/article/3489480/secure-sd-wan-the-security-vendors-and-their-sd-wan-offerings.html +[11]: https://aws.amazon.com/transit-gateway/ +[12]: https://www.networkworld.com/article/3487831/what-s-hot-for-cisco-in-2020.html +[13]: https://www.networkworld.com/article/3487720/the-vpn-is-dying-long-live-zero-trust.html +[14]: https://www.networkworld.com/article/3481519/sase-redefining-the-network-and-security-architecture.html +[15]: https://www.networkworld.com/article/3488562/whats-big-in-it-tech-for-the-coming-year.html +[16]: https://www.facebook.com/NetworkWorld/ +[17]: https://www.linkedin.com/company/network-world diff --git a/sources/talk/20191216 10 tips for onboarding open source contributors.md b/sources/talk/20191216 10 tips for onboarding open source contributors.md new file mode 100644 index 0000000000..cd080e085d --- /dev/null +++ b/sources/talk/20191216 10 tips for onboarding open source contributors.md @@ -0,0 +1,192 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (10 tips for onboarding open source contributors) +[#]: via: (https://opensource.com/article/19/12/open-source-contributors) +[#]: author: (rowasc https://opensource.com/users/rowasc) + +10 tips for onboarding open source contributors +====== +Making new contributors feel welcome in your community is essential to +your project's future, so it's important to put time and attention into +onboarding them. +![Women programming][1] + +Contributors are the lifeblood of many open source projects because they enable smaller projects to grow and improve without a lot of financial support and they bring fresh perspectives to the project. That is the case at [Ushahidi][2], a non-profit organization that is building and using software to help raise the voices of underserved, marginalized communities. Our products enable local observers to submit reports about local humanitarian crises (such as political unrest and natural disasters) using their mobile phones or the internet, while simultaneously creating a temporal and geospatial archive of events. + +Ushahidi always strives for openness, but **it's very hard to evaluate how open your organization works from the inside**. Staff and longtime contributors know too much: they are cursed by knowledge and access to the people who know how things work. While a crisis brings out the good in people who want to help, getting involved with an open source project during a crisis is complex. The maintainers are usually going through a stressful time. New requests for features are coming every day. New bugs are being reported all the time. + +There are never enough people to fix everything, which is why it's so important for projects to have a good process for onboarding new contributors. + +### Why Ushahidi needed to re-engage with its community + +In the beginning, Ushahidi had a really big community and did a lot of community engagement. We had community dev calls, where core developers and community developers talked about what they were working on. We had t-shirts and swag; we had community badges and blog posts celebrating the top contributor of the month. We sponsored tech events and made sure to have a booth or a presentation showcasing the platform. + +Our documentation was good and extensive with toolkits and examples for different use cases, our forum was active, we were active! + +But then a few things happened. The software got outdated, and the core team started working on a new version. At the same time, we adopted a new strategy around sustainability and started a Software-as-a-Service model, spanning from free grassroots deployments to more complex enterprise plans, to try to bring much-needed financial stability and sustainability and serve new use cases and needs. + +All of this took longer than expected, and we did not want to bring in new contributors "just yet." Not getting our contributors engaged from the beginning resulted in our docs being unclear, unfinished, and unstructured. We did not adjust the software to be easy for our open source users to install or use. **Nothing was intentional, but we were not serving our open source community as well as we would like.** Now, our main focus is to re-engage with our community. + +The following are 10 things we've learned and done that may help you improve your contributor onboarding processes if you're in a similar situation. + +### 1\. Evaluate your processes + +To evaluate how open your organization's processes are and how they are working for new contributors, source new folks who can try to answer questions like: "How do you get new code into production?" and "Who can trigger a production release?" or "How does testing happen?" + +Some things to look for: + + * Is it clear to new contributors about how to get started? Are getting-started guides hard to find, too complex, or disorganized? + * Are communication and coordination happening in the open? Or are they hidden in Slack rooms, making it hard to know what is going on? + * Is the process for code reviews and merges clear? What about the safety nets for code contributions and the QA process? + + + +When you're deep into a project with your community, it's difficult to know how it looks to new contributors. We learned that **what feels like an open process from the inside can feel very closed from the perspective of a new contributor**. + +### 2\. Set the foundation + +Diversity and inclusion are core to Ushahidi; about 80% of people working on the project are women and non-binary genders, a majority of our team are people of color, and we live on four continents. This reflects the reality that many of our users live in. They are not all in the United States, they are from diverse backgrounds, and they have different goals. What unites them is that they are all working to improve their communities in their own way. + +For us, **having a good foundation starts with having a diverse team that represents our users and stakeholders**. But that's not all; we have also improved our contributor resources with: + + * A new developers hub + * New and updated documentation + * New pathways to contributing + * Videos + * FAQs + + + +We're also restarting our community engagement by: + + * Doing webinars + * Hosting hackathons + * Proactively organizing and triaging issues + * Announcing releases and contributors to each release + + + +### 3\. Make "getting started" clear + +When someone wants to start contributing, there needs to be clarity on how to start. We label good starter contributions as first-timer issues; these describe in detail what needs to be done, how to find the code, and what you need to do. It takes us longer to write these issues than it would to fix the actual thing ourselves, but that is not the goal. The goal is to **give people who may be new to open source a chance to contribute and learn about the work we do**. + +#### Find the blockers + +It is also important to understand where the blockers for getting started are. One of Ushahidi's biggest blockers was installing the software in development environments. We assumed that because our engineers could get things set up, others would be able to do so. But other people may not have the same environment, and they absolutely did not have the amount of support that our core engineering team gets. + +To resolve this, we created videos on installation procedures, and we also created an **installation-helper** feature that checks common things that people forget during configuration and installation and also gives hints on how to solve problems. + +![Ushahidi's installation-helper][3] + +### 4\. Learn from diverse perspectives + +It's important to ask others to evaluate and double-check the documentation we provide to our contributors. We are really lucky that our team has people in programs, community, and design roles that really care about open source, and their input often helps us figure out how to **reach people who are less experienced with coding or who may want to contribute in different ways than writing code or doing QA**. + +When we were creating videos for our new developers hub, our community engagement officer was a big help. She is not a developer, and she is an excellent writer, so she helped by watching us go through the documentation, taking notes, then writing the initial scripts for our videos. She ensured that the things that we encounter daily—and know how to deal with by heart—are addressed in the documentation. + +Input like this is very valuable, since it reminds us what we know and take for granted that could confuse and turn away new contributors. + +### 5\. When possible, make short calls + +Try to invest in calls when needed and when your schedule allows. **Sometimes a five-minute call with a new contributor will give a better return than a 30-minute text chat.** If you reach a point in a chat that it's clear your instructions aren't working for the person, ask them to jump on a call to show you what they are doing. It's important to set a time limit (e.g., "I have 10 minutes now, so let's see if we can solve it right away"); otherwise, you may end up spending the whole day fixing unrelated things, which is not a great way to scale yourself. + +Make sure to use what you learn from these interactions to improve your documentation. Otherwise, you will find yourself doing so many 10-minute calls that you will never get anything done. + +### 6\. Always say thank you + +**Thank people even when it feels all you are getting are requests to do more work.** We say thank you for everything. We say thank you for bug reports, feature requests, for code contributions. We say thank you for reaching out and asking for help. + +It is hard for some people to reach out, and thanking them validates that it was OK to do so. This validation may also help people not only for the current situation but also for other projects and situations in the future. + +### 7\. Be kind in code reviews + +Someone has found you, gotten set up, fixed a bug, and finally sent a pull request. It's time to review the code. Step away from your personal opinions on how things should be. It's not time to be nit-picky and rude. + +When performing code reviews, **ensure you are helping the person make the code better** and not just following your personal preferences. Find at least one good thing to say about the pull request, and _always thank the contributor_. + +If you get a pull request that you don't plan to merge, maybe because it's the wrong scope or direction or simply something you don't want to add, it is important to deal with it straightaway instead of ignoring it. It does not help anyone to ignore pull requests, and it only serves to clutter your repository. Thank the contributor, explain why you don't plan to merge the changes, and close the pull request. + +If you merge the changes, make sure to tag the contributor when it goes out so that they know it had an impact. + +### 8\. Be responsive + +Throughout this process, **it is important to be responsive and not let people wait**. Giving someone some kind of response—even if you can't help them right now—and setting the expectation for when you'll be able to follow up is super-important. + +Sometimes a comment goes undiscovered—you miss a notification and find it three months later. It's tricky to respond in those situations, but it's still better to acknowledge the message, apologize for the delay, and ask if they still want help (with this or something else) rather than just ignoring them forever. It sets the tone that you care about your work and community, even when you make mistakes. + +### 9\. Help contributors thrive + +Sometimes a contributor comes in, sends their contributions, and leaves without much interaction. But, on some occasions, you get the opportunity to work with people over a longer time. Working with new contributors over a period of weeks or months is extremely valuable because you will gain insights into how people—especially those new to your project or tech—see your work and what challenges they face. It's also a chance to help people grow and learn. It's a win-win for everyone. + +In 2019, we participated in the [Google Summer of Code][4] and [Outreachy][5], and these experiences helped both the interns and our team learn new things. By working with interns, we get to understand what it's like to join our project, what onboarding looks like for a very junior engineer, and what blockers there might be to them contributing to our project. + +#### Prevent imposter syndrome + +On a related note, it's important to help prevent [impostor syndrome][6]. The feeling of not belonging or of "how did I even get here" is so common, especially among underrepresented groups in tech. It is written and talked about a lot, especially in the past tense, but rarely by people who are actively going through it. + +How do you spot it? How do you know someone is feeling like they aren't accomplishing enough or are feeling like a fraud? + +**Showing senior folks failing and learning from their mistakes helps to create an inclusive environment.** Things like pair programming, sharing your past experiences, discussing your career path, and telling people about when you made mistakes are ways to help to bridge gaps between senior engineers and new people. It helps new folks feel like they belong in tech because the smart, senior people in front of them also had concerns and made mistakes, but they picked themselves up and kept going. + +### 10\. Avoid communication barriers + +This may be obvious, but not all your contributors speak English as their first language. For many, it'll be their second, or maybe even third or fourth, language. A lot of your contributors may not speak English at a level that allows them to collaborate seamlessly, and it's important to remember that broken English is fine, even expected, in a global project. Be empathetic, be nice, and support these folks. Don't assume that someone is "dumb" just because they have bad grammar in English. Just because someone does not speak perfect English, it does not mean they aren't talented. It literally only means they don't speak perfect English. + +Another potential communication barrier is using mannerisms that others may perceive in different ways than we intended. For example, signing an email "Thanks, Romina" or saying "OK, bye!" sound perfectly appropriate to me, but they could signal to someone else that you don't respect them. To assign the label "rude" to someone because of this would be… quite rude? + +**When you are dealing with a multicultural, global network of contributors, try not to worry about language barriers or mannerisms that aren't meant to be offensive.** + +This doesn't mean that you should excuse bad behavior. There are no excuses for calling another person names, putting someone down, or misgendering someone on purpose, and maintainers are obligated to act on the code of conduct and resolve the situation. + +### In summary + +Making new contributors feel welcome in your community is essential to your project's future, so it's important to put time and attention into onboarding them. + + * Make sure to see your community from the contributors' side. + * Enabling underrepresented minorities to thrive creates a more welcoming community for everyone. + * Be aware of the community you are serving and ask yourself what their specific needs are. + * Allow questions both in private and public. + * Be nice, set the tone. + * Say thank you. + * Be responsive. + * Be consistent. + + + +### Other resources + + * [Ushahidi's documentation][7] + * [First Timers Only][8] offers good tips for first-time contributors + * [GitHub's all-contributors repository][9] provides specs for recognizing all types of open source contributors + * [Up For Grabs][10] to find open issues for OSS and how to label issues + + + +The four-day-long siege of a Nairobi mall ended Tuesday with a death toll of more than 60 people –... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/open-source-contributors + +作者:[rowasc][a] +选题:[lujun9972][b] +译者:[译者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/rowasc +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/collab-team-pair-programming-code-keyboard2.png?itok=WnKfsl-G (Women programming) +[2]: https://www.ushahidi.com/ +[3]: https://opensource.com/sites/default/files/uploads/ushahidi_installation-helper.png (Ushahidi's installation-helper) +[4]: https://summerofcode.withgoogle.com/archive/ +[5]: https://www.outreachy.org/ +[6]: https://opensource.com/open-organization/17/5/team-impostor-syndrome +[7]: https://docs.ushahidi.com/index/ +[8]: https://www.firsttimersonly.com/ +[9]: https://github.com/all-contributors/all-contributors +[10]: https://up-for-grabs.net/ diff --git a/sources/talk/20191216 7 considerations when buying network-automation tools.md b/sources/talk/20191216 7 considerations when buying network-automation tools.md new file mode 100644 index 0000000000..cec4eed0a8 --- /dev/null +++ b/sources/talk/20191216 7 considerations when buying network-automation tools.md @@ -0,0 +1,93 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (7 considerations when buying network-automation tools) +[#]: via: (https://www.networkworld.com/article/3490459/7-considerations-when-buying-network-automation-tools.html) +[#]: author: (Zeus Kerravala https://www.networkworld.com/author/Zeus-Kerravala/) + +7 considerations when buying network-automation tools +====== +Here’s the factors you need to weigh so you can make a smart decision about the network automation tool that’s best for your organization. +bananajazz / Getty Images + +The concept of network automation has been around for as long as there have been networks, and until now the uptake has been slow for a number of reasons including resistance from network engineers.  But now forces are coming together to create a perfect storm of sorts, driving a need for network automation tools. + +One factor is that more and more network teams are starting to feel the pain of working in the fast-paced digital world where doing things the old way simply does not work.  The manual, box-by-box, method of configuring and updating routers and switches through a command-line interface (CLI) is too slow and error prone.  + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][1] + +Also, the rise of software-defined networks ([SDN][2]), including software-defined WANs ([SD-WAN][3]), has enabled network-automation tools to evolve from operationally focused point products that address things like change management and configuration into policy and orchestration tools. + +[][4] + +BrandPost Sponsored by HPE + +[Take the Intelligent Route with Consumption-Based Storage][4] + +Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. + +Today, network-automation tools are strategic, enable business alignment, and provide a roadmap to the utopian state of a fully intent-based system where the network runs and secures itself. Their time is now, but there is a wide range of them. Below are seven key criteria that enterprises should consider when deciding which is best for them. + +### Single vendor or multi-vendor? + +There are several third-party and vendor-specific network automation tools.  Red Hat, NetBrain and Forward Networks are three of the leading multi-vendor tools.  All of the major network vendors including Cisco, Juniper, Arista and Extreme have their own automation platforms. + +Customers need to determine if they want to go all in with a single vendor or strive for multiple vendors. Neither is better per se; it’s a choice the enterprise needs to make. If a single vendor platform is chosen, ensure it works with the vendor's entire product line and not just a subset. If a third-party tool is chosen, seek out one that that supports the current and likely future vendors whose gear will be in the organization’s network. + +### Breadth of APIs + +It’s important that network-automation tools interface with other tools such as ServiceNow and Splunk. This means every feature should be available as an API, which isn’t always the case. Even if a tool is being used standalone today, it will likely need to interface with another application in the near future for broader automation capabilities, so this should not be overlooked. + +### Orchestration + +When network devices change, it’s often the case that another element of the infrastructure must also change. For example, when a network device is added, it may require changing a [firewall][5] setting or connecting to a load balancer. This drives up the need for orchestration capabilities so the network-automation tool can trigger other automation frameworks to change devices that are upstream or downstream from it. + +### AI/intent-based networking capabilities + +The concept of an [intent-based network][6] is that it runs, heals and secures itself. This can’t be done with a bevy of rules because the environment changes too fast. Instead, AI capabilities should be included in the system to fully automate all operations so the network itself can adapt to changes. + +ZK Research recommends that the system have two modes of operation – one that recommends changes for the engineer to execute on and then one that fully executes changes without requiring human intervention.  This will let the customer get comfortable with AI first. (One question ZK Research gets a lot is how one knows it’s really AI based. The answer is that the tool gets smarter over time.  All changes should feed back into the system as part of the learning data set and make the system smarter.  Rules-based systems will not.) + +### SaaS or on-prem? + +Traditional network-automation tools have been offered only as on-premises software or appliances. There is a growing number of companies that prefer to buy the tools in a software as a service (SaaS) model to ensure rapid deployment and continuous updates. + +Again, there’s no wrong choice.  The company needs to determine which option best fits its operating model and compliance requirements. + +One important note: It’s the belief of ZK Research that all solutions will eventually be hybrid where customers may keep the data on the local premises, but advanced, artificial intelligence capabilities and cross-company comparisons will be done in the cloud.  On-prem solutions do not have the necessary horsepower to deliver real-time AI capabilities + +### Compliance and security reporting + +There’s a growing push from leading organizations to bring IT and security operations together.  This means network-automation tools need to provide information that shows security policies are continually being adhered to and compliance mandates are being met. The reporting capabilities need to provide visibility into every phase of the network lifecycle including planning, deploying and optimization. + +### Ease of use + +This is an often-overlooked component of management platforms. Feature-rich tools with long learning curves can require years before IT teams realize their full value.  Also, when a product is too technical, the company is put at risk if people with the best knowledge of it exit the organization. + +Network automation tools should be fully GUI based, which means every feature available via the CLI should also be accessible through the graphical interface.  The tools should be easy to use as well so lower level engineers can work with it. This will obviate the need to always include a senior, more expensive engineer. + +Join the Network World communities on [Facebook][7] and [LinkedIn][8] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3490459/7-considerations-when-buying-network-automation-tools.html + +作者:[Zeus Kerravala][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Zeus-Kerravala/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.networkworld.com/article/3209131/what-sdn-is-and-where-its-going.html +[3]: https://www.networkworld.com/article/3031279/sd-wan-what-it-is-and-why-you-ll-use-it-one-day.html +[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[5]: https://www.networkworld.com/article/3230457/what-is-a-firewall-perimeter-stateful-inspection-next-generation.html +[6]: https://www.networkworld.com/article/3202699/what-is-intent-based-networking.html +[7]: https://www.facebook.com/NetworkWorld/ +[8]: https://www.linkedin.com/company/network-world diff --git a/sources/tech/20171027 Share And Upload Files To Compatible Hosting Sites Automatically.md b/sources/tech/20171027 Share And Upload Files To Compatible Hosting Sites Automatically.md deleted file mode 100644 index 356a64222f..0000000000 --- a/sources/tech/20171027 Share And Upload Files To Compatible Hosting Sites Automatically.md +++ /dev/null @@ -1,248 +0,0 @@ -Share And Upload Files To Compatible Hosting Sites Automatically -====== -![](https://www.ostechnix.com/wp-content/uploads/2017/10/Upload-720x340.png) -A while ago, we have written a guide about [**Transfer.sh**][1] which allows you to share files over Internet from command-line. Today, we will see yet another file sharing utility called **Anypaste**. It is a simple script to share and upload files to compatible hosting sites depending upon the type of the files, automatically. You don 't need to manually log in to the hosting sites and upload or share your files. Anypaste will **pick the right hosting sites depends upon the type of the file** you want to upload. To put this simply, photos will get uploaded to image hosting sites, videos to video sites, code to pastebins. Cool, yeah? Anypaste is completely free, open source and light-weight script and you can do everything from command line. You don't need to depend on any heavy, memory-consuming GUI apps to upload and share files. - -### Anypaste - Share And Upload Files To Compatible Hosting Sites Automatically - -#### Installation - -Like I already said, it's just a script. So, there won't be any complex installation steps. Just download it somewhere where you can run it, for example /usr/bin/anypaste, make it as executable and start using it in no time. Alternatively, you can run the following two commands to quickly install Anypaste. -``` -sudo curl -o /usr/bin/anypaste https://anypaste.xyz/sh -``` -``` -sudo chmod +x /usr/bin/anypaste -``` - -That's it. To update the old Anypaste version, just overwrite the old executable file with new one. - -Now, let us see some practical examples. - -#### Configuration - -Anypaste will work just out of the box. No special configuration is required! The default configuration file is **~/.config/anypaste.conf** and it will be automatically created when you run Anypaste for the first time. - -The only required configuration option is **ap_plugins**. Anypaste uses plugin system to upload files. Each hosting (upload) site is represented by a specific plugin. You can view the list of enabled plugins under **ap-plugins directive** in anypaste.conf file. -``` -# List of plugins -# If there are multiple compatible plugins, precedence is determined -# by which one is listed first in this array -ap_plugins=( -# Videos/Gifs -'sendvid' 'streamable' 'gfycat' -# Images -'tinyimg' 'vgyme' -# Audio -'instaudio' -# Text -'hastebin' 'ixio' 'sprunge' -# Documents -'docdroid' -# Any file -'jirafeau' 'fileio' -) -[...] -``` - -If you install a new plugin, add it to this list. If you want to disable a default plugin, just remove it! If multiple plugins are compatible, the first one in the array is selected, so **order matters**. - -#### Usage - -To upload a single file, for example test.png, run: -``` -anypaste test.png -``` - -Sample output would be: -``` -Current file: test.png -Attempting to upload with plugin 'tinyimg' -######################################################################## 100.0% - -Direct Link: https://tinyimg.io/i/Sa1zsjj.png - -Upload complete. -All files processed. Have a nice day! -``` - -As you can see in the above output, Anypaste has automatically found the compatible hosting site (https://tinyimg.io) to the given image file **test.png** and uploaded into it. Also, it gave us the direct link to view/download the uploaded file. - -Not just .png files, you can upload any other image file types. For example, the following command will upload file.gif: -``` -$ anypaste file.gif -Current file: file.gif -Plugin 'streamable' is compatible, but missing config parameters: 'streamable_email' 'streamable_password' -You can set them in /home/sk/.config/anypaste.conf -Attempting to upload with plugin 'gfycat' -######################################################################## 100.0% -Reminder: Gfycat needs time to encode. Your video will not appear right away. - -Link: https://gfycat.com/MisguidedQuaintBergerpicard -Direct(ish) Link: https://thumbs.gfycat.com/MisguidedQuaintBergerpicard-size_restricted.gif - -Upload complete. -All files processed. Have a nice day! -``` - -You can share the link to your family, friends and colleagues. Here is the screenshot of an image that I just uploaded it to **gfycat** website. - -[![][2]][3] - -It also possible to multiple files (same file type or different) at once. - -Have a look at the following example. In this example, I am uploading two different files, an image and a video file: -``` -anypaste image.png video.mp4 -``` - -**Sample output:** -``` -Current file: image.png -Attempting to upload with plugin 'tinyimg' -######################################################################## 100.0% - -Direct Link: https://tinyimg.io/i/au1PHpg.png - -Upload complete. -Current file: video.mp4 -Plugin 'streamable' is compatible, but missing config parameters: 'streamable_email' 'streamable_password' -You can set them in /home/sk/.config/anypaste.conf -Attempting to upload with plugin 'sendvid' -######################################################################## 100.0% - -Link: http://sendvid.com/wwy7w96h -Delete/Edit: http://sendvid.com/wwy7w96h?secret=39c0af2d-d8bf-4d3d-bad3-ad37432a40a5 - -Upload complete. -All files processed. Have a nice day! -``` - -Anypaste has automatically found the compatible hosting sites to both files and uploaded them successfully. - -As you may noticed in above examples in the usage section, Anypaste has picked the "best" plugin automatically. Also, you can upload files with a specific plugin. For instance, to upload files to **gfycat** site, run: -``` -anypaste -p gfycat file.gif -``` - -Sample output: -``` -Current file: file.gif -Plugin 'streamable' is compatible, but missing config parameters: 'streamable_email' 'streamable_password' -You can set them in /home/sk/.config/anypaste.conf -Attempting to upload with plugin 'gfycat' -######################################################################## 100.0% -Reminder: Gfycat needs time to encode. Your video will not appear right away. - -Link: https://gfycat.com/GrayDifferentCollie -Direct(ish) Link: https://thumbs.gfycat.com/GrayDifferentCollie-size_restricted.gif - -Upload complete. -All files processed. Have a nice day! -``` - -To upload with a specific plugin, bypassing compatibility checks, run: -``` -anypaste -fp gfycat file.gif -``` - -If you find a specific plugin is missing in the config file, you still can force Anypaste to use that specific plugin with '-xp' parameter. -``` -anypaste -xp gfycat file.gif -``` - -To upload files with interactive mode, run it with "-i" flag: -``` -$ anypaste -i file.gif -Current file: file.gif -Determine compatible plugins automatically? [Y/n] **n** -The following plugins were found: 'sendvid' 'streamable' 'gfycat' 'tinyimg' 'vgyme' 'instaudio' 'hastebin' 'ixio' 'sprunge' 'docdroid' 'jirafeau' 'fileio' - -Enter the (partial) name of a plugin, or nothing for automatic selection -**gfycat** -Attempt to upload with plugin 'gfycat'? [Y/n] **y** -Attempting to upload with plugin 'gfycat' -######################################################################## 100.0% -Reminder: Gfycat needs time to encode. Your video will not appear right away. - -Link: https://gfycat.com/WaryAshamedBlackbear -Direct(ish) Link: https://thumbs.gfycat.com/WaryAshamedBlackbear-size_restricted.gif - -Upload complete. -All files processed. Have a nice day! -``` - -As you see, Anypaste first asked me to determine plugins automatically. I don't want it to find plugins automatically, so I answered "No". Then, it listed the available plugins and asked me to pick one from the list. Similarly, you can upload and share files of different types. The given files will uploaded to the compatible sites. - -Whenever you try to upload a video file, it will uploaded to the any one of following sites: - - 1. sendvid - 2. streamable - 3. gfycat - - - -Here note the order. Anypaste will first try to upload the file to sendvid site. If there is no plugin for sendvid, it will try the other two sites in the given order. Of course, you can change this in the config file. - -Images will be uploaded to: - - 1. tinyimg.io - 2. vgy.me - - - -Audio files will uploaded to: - - 1. instaud - - - -Text files will uploaded to: - - 1. hastebin - 2. ix.io - 3. sprunge.us - - - -Documents will be uploaded to: - - 1. docdroid - - - -Any other files will uploaded to: - - 1. jirafeau - 2. file.io - - - -Some of the above listed sites will delete the contents after a particular period of time. So, check the those website's terms and conditions before uploading and sharing contents. - -Recommended Read: - -#### Conclusion - -In my opinion, the idea of file identification to determine where to upload the files is really brilliant, and the developer has perfectly used it in the right way. Anypaste will definitely be useful to everyone who share files frequently over Internet. I hope you will find it useful too. - -And, that's all for now. More good stuffs to come. - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/anypaste-share-upload-files-compatible-hosting-sites-automatically/ - -作者:[SK][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.ostechnix.com/author/sk/ -[1]:https://www.ostechnix.com/easy-fast-way-share-files-internet-command-line/ -[2]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[3]:http://www.ostechnix.com/wp-content/uploads/2017/10/gfycat.png () diff --git a/sources/tech/20180207 23 open source audio-visual production tools.md b/sources/tech/20180207 23 open source audio-visual production tools.md deleted file mode 100644 index b6b748ec39..0000000000 --- a/sources/tech/20180207 23 open source audio-visual production tools.md +++ /dev/null @@ -1,262 +0,0 @@ -luming translating -23 open source audio-visual production tools -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-photo-camera-blue.png?itok=AsIMZ9ga) - -Open source is well established in cloud infrastructure, web hosting, embedded devices, and many other areas. Fewer people know that open source is a great option for producing professional-level audio-visual materials. - -As a product owner and sometimes marketing support person, I produce a lot of content for end users: documentation, web articles, video tutorials, event booth materials, white papers, interviews, and more. I have found plenty of great open source software that helps me do my job producing audio, video, print, and screen graphics. There are a lot of [reasons][1] that people choose open source over proprietary options, and I've compiled this list of open source audio and video tools for people who: - - * want to switch to GNU/Linux, but need to start slowly with cross-platform software on their regular operating system; - * are already open source enthusiasts, but are new to open source A/V software and want to know which options to trust; - * want to discover new tools to fuel their creativity and don't want to use the same approaches or software everyone else uses; or - * have some other reason to use open source A/V solutions (if this is you, share your reason in the comments). - - - -Fortunately, there is a lot of open source software available for A/V creators, as well as hardware that supports those applications. All of the software on this list meets the following criteria: - - * cross-platform - * open source (for software and drivers) - * stable - * actively maintained - * well documented and supported - - - -I've divided this list into graphics, audio, video, and animation solutions. Note that the software applications in this article are not exact equivalents of well-known proprietary software, they'll require you to learn new applications, and you may need to modify your workflow, but learning new tools enables you to create differently. - -### Graphics - -I create a lot of graphics for print and web, including logos, banners, video titles, and mockups. Here are some of the open source applications I use, as well as the hardware I use with them. - -#### Software - -**1.[Inkscape][2]** (vector graphics) -Inkscape is a good vector graphics editor for creating SVG and PDF files in the RGB color space. (It can create CMYK images, but that's not the main aim.) It's a lifesaver for manipulating SVG maps and charts for web applications; not only can you open files with the integrated XML editor, you can also see all of an object's parameters. One drawback: it is not well optimized on Mac. For examples, see [Inkscape's gallery][3]. - -**2.[GIMP][4]** (picture editor) -GIMP is my favorite application to edit images, including manipulating color, cropping and resizing, and (especially) optimizing file size for the web (many of my Photoshop-using colleagues ask me to do that last step for them). You can also create and draw images from scratch, but GIMP is not my favorite tool for that. See [GIMP Artists on DeviantArt][5] for examples. - -**3.[Krita][6]** (digital painting) -So you have this beautiful Wacom drawing tablet on your desk, and you want to try a true digital painting application? Krita is what you need to create beautiful drawings and paintings. See [Krita's Gallery][7] to see what I mean. - -**4.[Scribus][8]** (desktop publishing) -You can use Scribus to create a complete document, or just to convert a PDF from Inkscape or Libre Office from RGB to CMYK. One feature I really like: You can simulate and check what people with visual disabilities will experience with a Scribus document. I count on Scribus when I send PDF files to a commercial printer. While printing companies may be used to files created with proprietary solutions like InDesign, if your Scribus file is done correctly, your printer won't have any issues. Free trick: The first time you send a file, don't tell the printer the name of the software you used to create it. See [Made with Scribus][9] for examples of documents created with this software. - -**5.[RawTherapee][10]** (RAW image photo development) -RawTherapee is the only completely cross-platform alternative to Lightroom I know of. You can use your camera in RAW mode, and then use RawTherapee to "develop" your picture. It provides a very powerful engine and a non-destructive editor. For examples, see [RawTherapee screenshots][11]. - -**6.[LibreOffice Draw][12]** (desktop publishing) -Although you may not think of LibreOffice Draw as a professional desktop publishing solution, it can save you in many situations; for example, if you are creating whitepapers, diagrams, or posters that other people (even those who don't know graphics software) can update later. Not only is it easy to use, it's also a great alternative to Impress or PowerPoint for creating interesting documents. - -#### Graphics hardware - -**Graphics tablets** -[Wacom][13] tablets (and compatibles) are usually well supported on all operating systems. - -**Color calibration** -Color calibration products are available on all operating systems, including GNU/Linux. The [Spyder][14] products by Datacolor are well supported with applications for all platforms. - -**Scanners and printers** -Graphic artists need the colors they output (whether print or electronic) to be accurate. But devices that are truly cross-platform, with easy-to-install drivers for all platform, are not as common as you'd think. Your best choices are scanners that are compatible with TWAIN and printers that are compatible with Postscript. In my experience, professional-range printers and scanners from Epson and Xerox are less likely to have driver issues, and they always work out of the box, with beautiful and accurate colors. - -### Audio - -There are plenty of open source audio software options for musicians, video makers, game makers, music publishers, and others. Here are the ones that I've used for content creation and audio recording. - -#### Software - -**7. [Ardour][15] **(digital audio recording) -For recording and editing audio, the best alternative to the professional Pro Tools music-creation software is, hands down, Ardour. It sounds great, the mixer section is complete and flexible, it supports your favorite plugins, and it makes it very easy to edit, listen, and compare your modifications. I use it a lot for audio recording or mixing sound on videos. It's not easy to find music recorded with Ardour, because musicians rarely credit the software they use. However, you can get an idea of its capabilities by looking at its [features and screenshots][16]. - -(If you are looking for an "analog feeling" in term of sound and workflow, you can try [Harrison Mixbus][17], which is not an open source project, but is heavily based on Ardour, with Harrison's analog console emulator. I really like to work with it and my customers like the sound. Mixbus is cross platform.) - -**8.[Audacity][18]** (audio editing) -Audacity is the "Swiss Army knife" of audio software. It's not perfect, but you can do almost everything with it. Plus it's very easy to use, and anyone can learn it in a few minutes. Like Ardour, it's hard to find work credited to Audacity, but you can find ways to use it on these [screenshots][19]. - -**9.[LMMS][20]** (music production) -LMMS, designed as an alternative to FL Studio, might not be as popular, but it is very complete and easy to use. You can use your favorite plugins, edit instruments using "piano roll" sequencing, play drum samples with a step sequencer, mix your tracks ... almost anything is possible. I use it to create audio loops for videos when I don't have the time to record musicians. See [The Best of LMMS][21] playlists for examples. - -**10.[Mixxx][22]** (DJ, music mixing) -If you need powerful software to mix music and play DJ, Mixx is the one to use. It's compatible with most MIDI controllers, timecoded discs, and dedicated sound cards. You can manage your music library, add effects, and have fun. Take a look at the [features][23] to see how it works. - -#### Audio interface hardware - -While you can record audio with any computer's sound card, to record well, you need an audio interface—a specialized type of external sound card that records high-quality audio input. For cross-platform compatibility, most "USB Class Compliant" or "compatible with iOS" audio interface devices should work for MIDI or other audio. Below is a list of cross-platform devices I use and know well. - -**[Behringer U-PHORIA UMC22][24]** -The UMC22 is the cheapest option you should consider. With less expensive options, the preamps are too noisy and the quality of the box is very low. - -**[Presonus AudioBox USB][25]** -The AudioBox USB is one of the first USB Class Compliant (and thereby cross-platform) recording systems out there. It is very robust and available on the second-hand market. - -**[Focusrite Scarlett][26]** -The Scarlett range is, in my opinion, the highest quality cross-platform sound card available. The various options range from devices with two to 18 input/outputs. You can find first-version models on the second-hand market, and the new second version offers better preamps and specs. I've worked a lot with the [2i2][27] model. - -**[Arturia AudioFuse][28]** -The AudioFuse allows you to plug in nearly anything, from a microphone to a vinyl disc player to various digital inputs. It provides both great sound and great design, and it's what I'm using the most now. It is cross-platform, but the configuration software is not yet available for GNU/Linux. It remembers my configuration even after I unplug it from my Windows PC, but really, Arturia, please be serious and make the software available for GNU/Linux. - -#### MIDI controllers - -A MIDI controller is a musical instrument—e.g., keyboards, drum pads, etc.—that allow you to control music software and hardware. Most of the recent USB MIDI controllers are cross-platform and compatible with the main software used to record and edit audio. Web-based tutorials will help you configure them for different software; although it may be harder to find info on GNU/Linux configurations, they will work. I've used many Akai and M-Audio devices without any issues. It's best to try a musical instrument before you buy, at least to listen to the sound quality or to touch the buttons. - -#### Audio codecs - -Audio codecs compress and decompress digital audio to deliver the best-quality audio at the smallest possible file size. Fortunately, the best codec for listening and streaming happens to be open source: [FLAC][29]. [Ogg Vorbis][30] is another open source audio codec worth checking out; it's far better than MP3 at the same bitrate. If you need to export audio in different file formats, I recommend always exporting and archiving audio at the best possible quality, then compressing a specific version if it's needed. - -### Video - -The impact of video in brand communications is significant. Even if you are not a video specialist, it's smart to learn the basics. - -#### Software - -**11.[VLC][31]** (video player and converter) -Originally developed for media streaming, VLC is now known for its ability to read all video formats on all devices. It's very useful; for example, you can also use it to convert a video into another codec or container or to recover a broken video. - -**12.[OpenShot][32]** (video editor) -OpenShot is simple software that produces great results, especially for short videos. (It is a bit limited in terms of editing or improving the sound of a video, but it will do the job.) I especially like the tool to move, resize, or crop a clip; it's perfect to create intros and outros that you can export, then use in a more complex editor. You can see [examples][33] (and get more information) on OpenShot's website. - -**13.[Shotcut][34]** (video editor) -I think Shotcut is a bit more complete than OpenShot—it's a very good competitor to the basic editors in your operating system, and it supports 4K and professional codecs. Give it a try, I think you will love it. You can see examples in these [video tutorials][35]. - -**14.[Blender Velvets][36]** (vdeo editing, compositing, effects) -While the learning curve is not the lightest on this list, Blender Velvets is one of the most powerful solutions you will find. It is a collection of extensions and scripts, created by movie makers, that transform the Blender 3D creation software into a 2D video editor. While it's complexity means it's not my top choice for video editing, you can find plenty of tutorials on YouTube and other sites, and once you learn it, you can do everything with this software. Watch this [tutorial video][37] to see its functions and how it works. - -**15.[Natron][38]** (compositing) -I don't use Natron, but I've gotten great feedback from people who do. It's an alternative to Adobe's After Effects, but works differently. To learn more, watch a few video tutorials, like these on [Natron's YouTube][39] channel. - -**16.[OBS][40]** (live editing, recording, and streaming) -Open Broadcaster Software (OBS) is the leading solution for recording or [livestreaming][41] e-sports and video games on YouTube or Twitch. I use it a lot to record users' screens, conferences, meetups, etc. For more information, see the tutorial I wrote for Opensource.com about recording live presentations, [Part 1: Choosing your equipment][42] and [Part 2: Software setup][43]. - -#### Video hardware - -First things first: You will need a powerful workstation with a fast hard drive and updated software and drivers. - -**Graphics processing unit (GPU)** -Some software on this list, including Blender and Shotcut, use OpenGL and hardware acceleration, which have high GPU demands. I recommend the most powerful GPU you can afford. I've had good experience with AMD and Nvidia, depending on the platform. Don't forget to install the latest drivers. - -**Hard drives** -In general, the faster and bigger the hard drive, the better it is for video. Don't forget to configure your software to use the right path. - -**Video capture hardware** - - * [Blackmagic Design][44]: Blackmagic provides very good, professional-grade video capture and playback hardware. Drivers are available for Mac, Windows, and GNU/Linux (but not all distributions). - * [Epiphan][45]: Among Epiphan's professional USB video capture devices is a new USB Class Compliant model for HDMI and high screen resolutions. However, you can find the older VGA devices on the secondhand market, for which they continue to provide dedicated drivers for GNU/Linux and Windows. - - - -#### Video codecs - -Unfortunately, it is still difficult to work with open source codecs. For example, many cameras use proprietary codecs to record videos in H.264 and sound in AC3, in a format called AVCHD. Therefore, we have to be pragmatic and use what is available. - -The good news is that the content industry is moving to open source codecs to avoid fees and to use open standards. For distribution and streaming, [Google'][46][s WebM][46] is a good open source codec, and most video editors can export in that format. Also, [GoPro's][47][Cineform][47] codec for very high resolution and 360° video is now open source. Hopefully more devices and vendors will use it soon. - -### 2D and 3D animation - -Animation is not my field of expertise, so I've asked my friends who are working on animated content, including movies and series for kids, for their recommendations to compile this list. - -#### Software - -**17. [Blender][48] **(3D modeling and rendering) -Blender is the top open source and cross-platform software for 3D modeling and rendering. You can do your entire project directly in Blender, or use it to create 3D effects for a movie or video. You will find a lot of video tutorials on the web, so even though it isn't simple software, it's very easy to get started. Blender is a very active project and regularly produces short movies to showcase the technology. You can see some of them on [Blender Open Movies][49]. - -**18.[Synfig Studio][50]** (2D animation) -The first time I used Synfig, it reminded me of the good, old Macromedia Flash editor. Since then, it has grown into a full-featured 2D animation studio. You can use it to produce promotional stories, commercials, presentations, or original intros, outros, and transitions for your videos, or even to work on full animated movies. See [Synfig's portfolio][51] for some examples. - -**19.[TupiTube][52]** (stop-motion, 2D animation) -TupiTube is an excellent way to learn the basics of 2D animation. You can transform a set of drawings or other pictures into a video or create an animated GIF or small loops. It's quite simple software, but very complete. Check out [TupiTube's YouTube][53] channel for some tutorials and examples. - -#### Hardware - -Animation uses the same hardware as graphic design, so look at the hardware list in the first section of this article for recommendations. - -One additional note: You will need a powerful GPU for 3D modeling and rendering. The choices can be limited, depending on your platform or PC maker, but don't forget to install the latest drivers. Carefully choose your graphics card: they are expensive and critical for big 3D projects, particularly in the rendering step. - -### Linux options - -If you are a GNU/Linux user, I have some more good options for you. They aren't fully cross-platform, but some of them have a Windows installer, and some can be installed on Mac with Macports. - -**20.[Kdenlive][54]** (video editor) -With its last release (a few months ago), Kdenlive became my favorite video editor, especially when I work on a long video on my Linux machine. If you are a regular user of popular non-linear video editors, Kdenlive (which stands for KDE Non-Linear Video Editor) will be easy for you to use. It has good video and audio effects, is great when you need to work on details, and works on BSD and MacOS (although it's aimed at GNU/Linux) and is being ported to Windows. - -**21.[Darktable][55]** (RAW development) -Darktable is a very complete alternative to DxO that is made by photographers for photographers. Some research projects are using it as a platform for development and testing of new image processing algorithms. It is a very active project, and I can't wait until it becomes truly cross-platform. - -**22.[MyPaint][56]** (digital painting) -MyPaint is like a light table for digital painting. It works well with Wacom devices, and its brush engine is particularly appreciated, so GIMP developers are looking closely at it. - -**23.[Shutter][57]** (desktop screenshots) -When I create tutorials, I use a lot of screenshots to illustrate them. My favorite screenshot tool for GNU/Linux is Shutter; actually, I can't find an equivalent in terms of features for Windows or Mac. One missing piece: I would like to see Shutter add a feature to create animated GIF screenshots over a few seconds. - -I hope this has convinced you that open source software is an excellent, viable solution for A/V content producers. If you are using other open source software—or have advice about using cross-platform software and hardware—for audio and video projects, please share your ideas in the comments. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/2/open-source-audio-visual-production-tools - -作者:[Antoine Thomas][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/ttoine -[1]:https://opensource.com/resources/what-open-source -[2]:https://inkscape.org/ -[3]:https://inkscape.org/en/gallery/ -[4]:https://www.gimp.org/ -[5]:https://gimp-artists.deviantart.com/gallery/ -[6]:https://krita.org/ -[7]:https://krita.org/en/features/gallery/ -[8]:https://www.scribus.net/ -[9]:https://www.scribus.net/category/made-with-scribus/ -[10]:http://rawtherapee.com/ -[11]:http://rawtherapee.com/blog/screenshots -[12]:https://www.libreoffice.org/discover/draw/ -[13]:http://www.wacom.com/en-us -[14]:http://www.datacolor.com/photography-design/product-overview/#workflow_2 -[15]:https://www.ardour.org/ -[16]:http://ardour.org/features.html -[17]:http://harrisonconsoles.com/site/mixbus.html -[18]:http://www.audacityteam.org/ -[19]:http://www.audacityteam.org/about/screenshots/ -[20]:https://lmms.io/ -[21]:https://lmms.io/showcase/ -[22]:https://www.mixxx.org/ -[23]:https://www.mixxx.org/features/ -[24]:http://www.musictri.be/Categories/Behringer/Computer-Audio/Interfaces/UMC22/p/P0AUX -[25]:https://www.presonus.com/products/audiobox-usb -[26]:https://us.focusrite.com/scarlett-range -[27]:https://us.focusrite.com/usb-audio-interfaces/scarlett-2i2 -[28]:https://www.arturia.com/products/audio/audiofuse/overview -[29]:https://en.wikipedia.org/wiki/FLAC -[30]:https://xiph.org/vorbis/ -[31]:https://www.videolan.org/ -[32]:https://www.openshot.org/ -[33]:https://www.openshot.org/videos/ -[34]:https://shotcut.com/ -[35]:https://shotcut.org/tutorials/ -[36]:http://blendervelvets.org/ -[37]:http://blendervelvets.org/video-tutorial-new-functions-for-the-blender-velvets/ -[38]:https://natron.fr/ -[39]:https://www.youtube.com/playlist?list=PL2n8LbT_b5IeMwi3AIzqG4Rbg8y7d6Amk -[40]:https://obsproject.com/ -[41]:https://opensource.com/article/17/7/obs-studio-pro-level-streaming -[42]:https://opensource.com/article/17/9/equipment-recording-presentations -[43]:https://opensource.com/article/17/9/equipment-setup-live-presentations -[44]:https://www.blackmagicdesign.com/ -[45]:https://www.epiphan.com/ -[46]:https://www.webmproject.org/ -[47]:https://fr.gopro.com/news/gopro-open-sources-the-cineform-codec -[48]:https://www.blender.org/ -[49]:https://www.blender.org/about/projects/ -[50]:https://www.synfig.org/ -[51]:https://www.synfig.org/#portfolio -[52]:https://maefloresta.com/ -[53]:https://www.youtube.com/channel/UCBavSfmoZDnqZalr52QZRDw -[54]:https://kdenlive.org/ -[55]:https://www.darktable.org/ -[56]:http://mypaint.org/ -[57]:http://shutter-project.org/ diff --git a/sources/tech/20181109 Must-Have Tools for Writers on the Linux Platform.md b/sources/tech/20181109 Must-Have Tools for Writers on the Linux Platform.md deleted file mode 100644 index 0ab375a008..0000000000 --- a/sources/tech/20181109 Must-Have Tools for Writers on the Linux Platform.md +++ /dev/null @@ -1,118 +0,0 @@ -Must-Have Tools for Writers on the Linux Platform -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/writing-main.jpg?itok=qe96IkKm) -I’ve been a writer for more than 20 years. I’ve written thousands of articles and how-tos on various technical topics and have penned more than 40 works of fiction. So, the written word is not only important to me, it’s familiar to the point of being second nature. And through those two decades (and counting) I’ve done nearly all my work on the Linux platform. I must confess, during those early years it wasn’t always easy. Formats didn’t always mesh with what an editor required and, in some cases, the open source platform simply didn’t have the necessary tools required to get the job done. - -That was then, this is now. - -A perfect storm of Linux evolution and web-based tools have made it such that any writer can get the job done (and done well) on Linux. But what tools will you need? You might be surprised to find out that, in some instances, the job cannot be efficiently done with 100% open source tools. Even with that caveat, the job can be done. Let’s take a look at the tools I’ve been using as both a tech writer and author of fiction. I’m going to outline this by way of my writing process for both nonfiction and fiction (as the process is different and requires specific tools). - -A word of warning to seriously hard-core Linux users. A long time ago, I gave up on using tools like LaTeX and DocBook for my writing. Why? Because, for me, the focus must be on the content, not the process. When you’re facing deadlines, efficiency must take precedent. - -### Nonfiction - -We’ll start with nonfiction, as that process is the simpler of the two. For writing technical how-tos, I collaborate with different editors and, in some cases, have to copy/paste content into a CMS. But like with my fiction, the process always starts with Google Drive. This is the point at which many open source purists will check out. Fear not, you can always opt to either keep all of your files locally, or use a more open-friendly cloud service (such as [Zoho][1] or [nextCloud][2]). - -Why start on the cloud? Over the years, I’ve found I need to be able to access that content from anywhere at any time. The simplest solution was to migrate the cloud. I’ve also become paranoid about losing work. To that end, I make use of a tool like [Insync][3] to keep my Google Drive in sync with my desktop. With that desktop sync in place, I know there’s always a backup of my work, in case something should go awry with Google Drive. - -For those clients with whom I must enter content into a Content Management System (CMS), the process ends there. I can copy/paste directly from a Google Doc into the CMS and be done with it. Of course, with technical content, there are always screenshots involved. For that, I use [Gimp][4], which makes taking screenshots simple: - -![screenshot with Gimp][6] - -Figure 1: Taking a screenshot with Gimp. - -[Used with permission][7] - - 1. Open Gimp. - - 2. Click File > Create > Screenshot. - - 3. Select from a single window, the entire screen, or a region to grab (Figure 1). - - 4. Click Snap. - - - - -The majority of my clients tend to prefer I work with Google Docs, because I can share folders so that they have reliable access to the content. There are a few clients I have that do not work with Google Docs, and so I must download the files into a format that can be used. What I do for this is download in .odt format, open the document in [LibreOffice][8] (Figure 2), format as needed, save in a format required by the client, and send the document on. - -![Google Doc][10] - -Figure 2: My Google Doc download opened in LibreOffice. - -[Used with permission][7] - -And that, is the end of the line for nonfiction. - -### Fiction - -This is where it gets a bit more complicated. The beginning steps are the same, as I always write every first draft of a novel in Google Docs. Once that is complete, I then download the file to my Linux desktop, open the file in LibreOffice, format as necessary, and then save as a file type supported by my editor (unfortunately, that means .docx). - -The next step in the process gets a bit dicey. My editor prefers to use comments over track changes (as it makes it easier for both of us to read the document as we make changes). Because of this, a 60k word doc can include hundreds upon hundreds of comments, which slows LibreOffice to a useless crawl. Once upon a time, you could up the memory used for documents, but as of LibreOffice 6, that is no longer possible. This means any larger, novel-length, document with numerous comments will become unusable. Because of that, I’ve had to take drastic measures and use [WPS Office][11] (Figure 3). Although this isn’t an open source solution, WPS Office does a fine job with numerous comments in a document, so there’s no need to deal with the frustration that is LibreOffice (when working with these large files with hundreds of comments). - -![comments][13] - -Figure 3: WPS handles numerous comments with ease. - -[Used with permission][7] - -Once my editor and I finish up the edits for the book (and all comments have been removed), I can then open the file in LibreOffice for final formatting. When the formatting is complete, I save the file in .html format and then open the file in [Calibre][14] for exporting the file to .mobi and .epub formats. - -Calibre is a must-have for anyone looking to publish on Amazon, Barnes & Noble, Smashwords, or other platforms. One thing Calibre does better than other, similar, solutions is enable you to directly edit the .epub files (Figure 4). For the likes of Smashword, this is an absolute necessity (as the export process will add elements not accepted on the Smashwords conversion tool). - -![Calibre][16] - -Figure 4: Editing an epub file directly in Calibre. - -[Creative Commons Zero][17] - -After the writing process is over (or sometimes while waiting for an editor to complete a pass), I’ll start working on the cover for the book. That task is handled completely in Gimp (Figure 5). - -![Using Gimp][19] - -Figure 5: Creating the cover of POTUS in Gimp. - -[Used with permission][7] - -And that finishes up the process of creating a work of fiction on the Linux platform. Because of the length of the documents, and how some editors work, it can get a bit more complicated than the process of creating nonfiction, but it’s far from challenging. In fact, creating fiction on Linux is just as simple (and more reliable) than other platforms. - -### HTH - -I hope this helps aspiring writers to have the confidence to write on the Linux platform. There are plenty of other tools available to use, but the ones I have listed here have served me quite well over the years. And although I do make use of a couple of proprietary tools, as long as they keep working well on Linux, I’m okay with that. - -Learn more about Linux in the[ Introduction to Open Source Development, Git, and Linux (LFD201) ][20]training course from The Linux Foundation, and sign up now to start your open source journey. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/2018/11/must-have-tools-writers-linux-platform - -作者:[Jack Wallen][a] -选题:[lujun9972][b] -译者:[译者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 -[b]: https://github.com/lujun9972 -[1]: https://www.zoho.com/ -[2]: https://nextcloud.com/ -[3]: https://www.insynchq.com -[4]: https://www.gimp.org/ -[5]: /files/images/writingtools1jpg -[6]: https://www.linux.com/sites/lcom/files/styles/floated_images/public/writingtools_1.jpg?itok=Uko7DZ8U (screenshot with Gimp) -[7]: /licenses/category/used-permission -[8]: https://www.libreoffice.org/ -[9]: /files/images/writingtools2jpg -[10]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/writingtools_2.jpg?itok=vDgxd8hu (Google Doc) -[11]: https://www.wps.com/en-US/ -[12]: /files/images/writingtools3jpg -[13]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/writingtools_3.jpg?itok=AYrsfz01 (comments) -[14]: https://calibre-ebook.com/ -[15]: /files/images/writingtools4jpg -[16]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/writingtools_4.jpg?itok=wFMEsL7b (Calibre) -[17]: /licenses/category/creative-commons-zero -[18]: /files/images/writingtools5jpg -[19]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/writingtools_5.jpg?itok=e7SZCgip (Using Gimp) -[20]: https://training.linuxfoundation.org/training/introduction-to-open-source-development-git-and-linux/?utm_source=linux.com&utm_medium=article&utm_campaign=lfd201 diff --git a/sources/tech/20181231 Easily Upload Text Snippets To Pastebin-like Services From Commandline.md b/sources/tech/20181231 Easily Upload Text Snippets To Pastebin-like Services From Commandline.md deleted file mode 100644 index 58b072f2fc..0000000000 --- a/sources/tech/20181231 Easily Upload Text Snippets To Pastebin-like Services From Commandline.md +++ /dev/null @@ -1,259 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Easily Upload Text Snippets To Pastebin-like Services From Commandline) -[#]: via: (https://www.ostechnix.com/how-to-easily-upload-text-snippets-to-pastebin-like-services-from-commandline/) -[#]: author: (SK https://www.ostechnix.com/author/sk/) - -Easily Upload Text Snippets To Pastebin-like Services From Commandline -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/12/wgetpaste-720x340.png) - -Whenever there is need to share the code snippets online, the first one probably comes to our mind is Pastebin.com, the online text sharing site launched by **Paul Dixon** in 2002. Now, there are several alternative text sharing services available to upload and share text snippets, error logs, config files, a command’s output or any sort of text files. If you happen to share your code often using various Pastebin-like services, I do have a good news for you. Say hello to **Wgetpaste** , a command line BASH utility to easily upload text snippets to pastebin-like services. Using Wgetpaste script, anyone can quickly share text snippets to their friends, colleagues, or whoever wants to see/use/review the code from command line in Unix-like systems. - -### Installing Wgetpaste - -Wgetpaste is available in Arch Linux [Community] repository. To install it on Arch Linux and its variants like Antergos and Manjaro Linux, just run the following command: - -``` -$ sudo pacman -S wgetpaste -``` - -For other distributions, grab the source code from [**Wgetpaste website**][1] and install it manually as described below. - -First download the latest Wgetpaste tar file: - -``` -$ wget http://wgetpaste.zlin.dk/wgetpaste-2.28.tar.bz2 -``` - -Extract it: - -``` -$ tar -xvjf wgetpaste-2.28.tar.bz2 -``` - -It will extract the contents of the tar file in a folder named “wgetpaste-2.28”. - -Go to that directory: - -``` -$ cd wgetpaste-2.28/ -``` - -Copy the wgetpaste binary to your $PATH, for example **/usr/local/bin/**. - -``` -$ sudo cp wgetpaste /usr/local/bin/ -``` - -Finally, make it executable using command: - -``` -$ sudo chmod +x /usr/local/bin/wgetpaste -``` - -### Upload Text Snippets To Pastebin-like Services - -Uploading text snippets using Wgetpaste is trivial. Let me show you a few examples. - -**1\. Upload text files** - -To upload any text file using Wgetpaste, just run: - -``` -$ wgetpaste mytext.txt -``` - -This command will upload the contents of mytext.txt file. - -Sample output: - -``` -Your paste can be seen here: https://paste.pound-python.org/show/eO0aQjTgExP0wT5uWyX7/ -``` - -![](https://www.ostechnix.com/wp-content/uploads/2018/12/wgetpaste-1.png) - -You can share the pastebin URL via any medium like mail, message, whatsapp or IRC etc. Whoever has this URL can visit it and view the contents of the text file in a web browser of their choice. - -Here is the contents of mytext.txt file in web browser: - -![](https://www.ostechnix.com/wp-content/uploads/2018/12/wgetpaste-2.png) - -You can also use **‘tee’** command to display what is being pasted, instead of uploading them blindly. - -To do so, use **-t** option like below. - -``` -$ wgetpaste -t mytext.txt -``` - -![][3] - -**2. Upload text snippets to different services -** - -By default, Wgetpaste will upload the text snippets to **poundpython** () service. - -To view the list of supported services, run: - -``` -$ wgetpaste -S -``` - -Sample output: - -``` -Services supported: (case sensitive): -Name: | Url: -=============|================= -bpaste | https://bpaste.net/ -codepad | http://codepad.org/ -dpaste | http://dpaste.com/ -gists | https://api.github.com/gists -*poundpython | https://paste.pound-python.org/ -``` - -Here, ***** indicates the default service. - -As you can see, Wgetpaste currently supports five text sharing services. I didn’t try all of them, but I believe all services will work. - -To upload the contents to other services, for example **bpaste.net** , use **-s** option like below. - -``` -$ wgetpaste -s bpaste mytext.txt -Your paste can be seen here: https://bpaste.net/show/5199e127e733 -``` - -**3\. Read input from stdin** - -Wgetpaste can also read the input from stdin. - -``` -$ uname -a | wgetpaste -``` - -This command will upload the output of ‘uname -a’ command. - -**4. Upload the COMMAND and the output of COMMAND together -** - -Sometimes, you may need to paste a COMMAND and its output. To do so, specify the contents of the command within quotes like below. - -``` -$ wgetpaste -c 'ls -l' -``` - -This will upload the command ‘ls -l’ along with its output to the pastebin service. - -This can be useful when you wanted to let others to clearly know what was the exact command you just ran and its output. - -![][4] - -As you can see in the output, I ran ‘ls -l’ command. - -**5. Upload system log files, config files -** - -Like I already said, we can upload any sort of text files, not just an ordinary text file, in your system such as log files, a specific command’s output etc. Say for example, you just updated your Arch Linux box and ended up with a broken system. You ask your colleague how to fix it and s/he wants to read the pacman.log file. Here is the command to upload the contents of the pacman.log file: - -``` -$ wgetpaste /var/log/pacman.log -``` - -Share the pastebin URL with your Colleague, so s/he will review the pacman.log and may help you to fix the problem by reviewing the log file. - -Usually, the contents of log files might be too long and you don’t want to share them all. In such cases, just use **cat** command to read the output and use **tail** command with the **-n** switch to define the number of lines to share and finally pipe the output to Wgetpaste as shown below. - -``` -$ cat /var/log/pacman.log | tail -n 50 | wgetpaste -``` - -The above command will upload only the **last 50 lines** of pacman.log file. - -**6\. Convert input url to tinyurl** - -By default, Wgetpaste will display the full pastebin URL in the output. If you want to convert the input URL to a tinyurl, just use **-u** option. - -``` -$ wgetpaste -u mytext.txt -Your paste can be seen here: http://tinyurl.com/y85d8gtz -``` - -**7. Set language -** - -By default, Wgetpaste will upload text snippets in **plain text**. - -To list languages supported by the specified service, use **-L** option. - -``` -$ wgetpaste -L -``` - -This command will list all languages supported by default service i.e **poundpython** (). - -We can change this using **-l** option. - -``` -$ wgetpaste -l Bash mytext.txt -``` - -**8\. Disable syntax highlighting or html in the output** - -As I mentioned above, the text snippets will be displayed in a specific language format (plaintext, Bash etc.). - -You can, however, change this behaviour to display the raw text snippets using **-r** option. - -``` -$ wgetpaste -r mytext.txt -Your raw paste can be seen here: https://paste.pound-python.org/raw/CUJhQ3jEmr2UvfmD2xCL/ -``` - -![](https://www.ostechnix.com/wp-content/uploads/2018/12/wgetpaste-5.png) - -As you can see in the above output, there is no syntax highlighting, no html formatting. Just a raw output. - -**9\. Change Wgetpaste defaults** - -All Defaults values (DEFAULT_{NICK,LANGUAGE,EXPIRATION}[_${SERVICE}] and DEFAULT_SERVICE) can be changed globally in **/etc/wgetpaste.conf** or per user in **~/.wgetpaste.conf** files. These files, however, are not available by default in my system. I guess we need to manually create them. The developer has given the sample contents for both files [**here**][5] and [**here**][6]. Just create these files manually with given sample contents and modify the parameters accordingly to change Wgetpaste defaults. - -**10\. Getting help** - -To display the help section, run: - -``` -$ wgetpaste -h -``` - -And, that’s all for now. Hope this was useful. We will publish more useful content in the days to come. Stay tuned! - -On behalf of **OSTechNix** , I wish you all a very **Happy New Year 2019**. I am grateful to all our readers, contributors, and mentors for supporting us from the beginning of our journey. We couldn’t come this far without your support and guidance. Thank you everyone! Have a great year ahead!! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/how-to-easily-upload-text-snippets-to-pastebin-like-services-from-commandline/ - -作者:[SK][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.ostechnix.com/author/sk/ -[b]: https://github.com/lujun9972 -[1]: http://wgetpaste.zlin.dk/ -[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[3]: http://www.ostechnix.com/wp-content/uploads/2018/12/wgetpaste-3.png -[4]: http://www.ostechnix.com/wp-content/uploads/2018/12/wgetpaste-4.png -[5]: http://wgetpaste.zlin.dk/zlin.conf -[6]: http://wgetpaste.zlin.dk/wgetpaste.example diff --git a/sources/tech/20190217 Install Android 8.1 Oreo on Linux To Run Apps - Games.md b/sources/tech/20190217 Install Android 8.1 Oreo on Linux To Run Apps - Games.md index 88798037c5..f20d24e5cf 100644 --- a/sources/tech/20190217 Install Android 8.1 Oreo on Linux To Run Apps - Games.md +++ b/sources/tech/20190217 Install Android 8.1 Oreo on Linux To Run Apps - Games.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (robsean) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20190322 Easy means easy to debug.md b/sources/tech/20190322 Easy means easy to debug.md deleted file mode 100644 index 4b0b4d52d2..0000000000 --- a/sources/tech/20190322 Easy means easy to debug.md +++ /dev/null @@ -1,83 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Easy means easy to debug) -[#]: via: (https://arp242.net/weblog/easy.html) -[#]: author: (Martin Tournoij https://arp242.net/) - - -What does it mean for a framework, library, or tool to be “easy”? There are many possible definitions one could use, but my definition is usually that it’s easy to debug. I often see people advertise a particular program, framework, library, file format, or something else as easy because “look with how little effort I can do task X, this is so easy!” That’s great, but an incomplete picture. - -You only write software once, but will almost always go through several debugging cycles. With debugging cycle I don’t mean “there is a bug in the code you need to fix”, but rather “I need to look at this code to fix the bug”. To debug code, you need to understand it, so “easy to debug” by extension means “easy to understand”. - -Abstractions which make something easier to write often come at the cost of make things harder to understand. Sometimes this is a good trade-off, but often it’s not. In general I will happily spend a little but more effort writing something now if that makes things easier to understand and debug later on, as it’s often a net time-saver. - -Simplicity isn’t the only thing that makes programs easier to debug, but it is probably the most important. Good documentation helps too, but unfortunately good documentation is uncommon (note that quality is not measured by word count!) - -This is not exactly a novel insight; from the 1974 The Elements of Programming Style by Brian W. Kernighan and P. J. Plauger: - -> Everyone knows that debugging is twice as hard as writing a program in the first place. So if you’re as clever as you can be when you write it, how will you ever debug it? - -A lot of stuff I see seems to be written “as clever as can be” and is consequently hard to debug. I’ll list a few examples of this pattern below. It’s not my intention to argue that any of these things are bad per se, I just want to highlight the trade-offs in “easy to use” vs. “easy to debug”. - - * When I tried running [Let’s Encrypt][1] a few years ago it required running a daemon as root(!) to automatically rewrite nginx files. I looked at the source a bit to understand how it worked and it was all pretty complex, so I was “let’s not” and opted to just pay €10 to the CA mafia, as not much can go wrong with putting a file in /etc/nginx/, whereas a lot can go wrong with complex Python daemons running as root. - -(I don’t know the current state/options for Let’s Encrypt; at a quick glance there may be better/alternative ACME clients that suck less now.) - - * Some people claim that systemd is easier than SysV init.d scripts because it’s easier to write systemd unit files than it is to write shell scripts. In particular, this is the argument Lennart Poettering used in his [systemd myths][2] post (point 5). - -I think is completely missing the point. I agree with Poettering that shell scripts are hard – [I wrote an entire post about that][3] – but by making the interface easier doesn’t mean the entire system becomes easier. Look at [this issue][4] I encountered and [the fix][5] for it. Does that look easy to you? - - * Many JavaScript frameworks I’ve used can be hard to fully understand. Clever state keeping logic is great and all, until that state won’t work as you expect, and then you better hope there’s a Stack Overflow post or GitHub issue to help you out. - - * Docker is great, right up to the point you get: - -``` - ERROR: for elasticsearch Cannot start service elasticsearch: -oci runtime error: container_linux.go:247: starting container process caused "process_linux.go:258: -applying cgroup configuration for process caused \"failed to write 898 to cgroup.procs: write -/sys/fs/cgroup/cpu,cpuacct/docker/b13312efc203e518e3864fc3f9d00b4561168ebd4d9aad590cc56da610b8dd0e/cgroup.procs: -invalid argument\"" -``` - -or - -``` -ERROR: for elasticsearch Cannot start service elasticsearch: EOF -``` - -And … now what? - - * Many testing libraries can make things harder to debug. Ruby’s rspec is a good example where I’ve occasionally used the library wrong by accident and had to spend quite a long time figuring out what exactly went wrong (as the errors it gave me were very confusing!) - -I wrote a bit more about that in my [Testing isn’t everything][6] post. - - * ORM libraries can make database queries a lot easier, at the cost of making things a lot harder to understand once you want to solve a problem. - - - - - --------------------------------------------------------------------------------- - -via: https://arp242.net/weblog/easy.html - -作者:[Martin Tournoij][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://arp242.net/ -[b]: https://github.com/lujun9972 -[1]: https://en.wikipedia.org/wiki/Let%27s_Encrypt -[2]: http://0pointer.de/blog/projects/the-biggest-myths.html -[3]: https://arp242.net/weblog/shell-scripting-trap.html -[4]: https://unix.stackexchange.com/q/185495/33645 -[5]: https://cgit.freedesktop.org/systemd/systemd/commit/?id=6e392c9c45643d106673c6643ac8bf4e65da13c1 -[6]: /weblog/testing.html -[7]: mailto:martin@arp242.net -[8]: https://github.com/Carpetsmoker/arp242.net/issues/new diff --git a/sources/tech/20190328 Can Better Task Stealing Make Linux Faster.md b/sources/tech/20190328 Can Better Task Stealing Make Linux Faster.md deleted file mode 100644 index bae14a2f5c..0000000000 --- a/sources/tech/20190328 Can Better Task Stealing Make Linux Faster.md +++ /dev/null @@ -1,133 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Can Better Task Stealing Make Linux Faster?) -[#]: via: (https://www.linux.com/blog/can-better-task-stealing-make-linux-faster) -[#]: author: (Oracle ) - -Can Better Task Stealing Make Linux Faster? -====== - -_Oracle Linux kernel developer Steve Sistare contributes this discussion on kernel scheduler improvements._ - -### Load balancing via scalable task stealing - -The Linux task scheduler balances load across a system by pushing waking tasks to idle CPUs, and by pulling tasks from busy CPUs when a CPU becomes idle. Efficient scaling is a challenge on both the push and pull sides on large systems. For pulls, the scheduler searches all CPUs in successively larger domains until an overloaded CPU is found, and pulls a task from the busiest group. This is very expensive, costing 10's to 100's of microseconds on large systems, so search time is limited by the average idle time, and some domains are not searched. Balance is not always achieved, and idle CPUs go unused. - -I have implemented an alternate mechanism that is invoked after the existing search in idle_balance() limits itself and finds nothing. I maintain a bitmap of overloaded CPUs, where a CPU sets its bit when its runnable CFS task count exceeds 1. The bitmap is sparse, with a limited number of significant bits per cacheline. This reduces cache contention when many threads concurrently set, clear, and visit elements. There is a bitmap per last-level cache. When a CPU becomes idle, it searches the bitmap to find the first overloaded CPU with a migratable task, and steals it. This simple stealing yields a higher CPU utilization than idle_balance() alone, because the search is cheap, costing 1 to 2 microseconds, so it may be called every time the CPU is about to go idle. Stealing does not offload the globally busiest queue, but it is much better than running nothing at all. - -### Results - -Stealing improves utilization with only a modest CPU overhead in scheduler code. In the following experiment, hackbench is run with varying numbers of groups (40 tasks per group), and the delta in /proc/schedstat is shown for each run, averaged per CPU, augmented with these non-standard stats: - - * %find - percent of time spent in old and new functions that search for idle CPUs and tasks to steal and set the overloaded CPUs bitmap. - * steal - number of times a task is stolen from another CPU. Elapsed time improves by 8 to 36%, costing at most 0.4% more find time. - - - -![load balancing][1] - -[Used with permission][2] - -​​CPU busy utilization is close to 100% for the new kernel, as shown by the green curve in the following graph, versus the orange curve for the baseline kernel: - -![][3] - -Stealing improves Oracle database OLTP performance by up to 9% depending on load, and we have seen some nice improvements for mysql, pgsql, gcc, java, and networking. In general, stealing is most helpful for workloads with a high context switch rate. - -### The code - -As of this writing, this work is not yet upstream, but the latest patch series is at [https://lkml.org/lkml/2018/12/6/1253. ][4]If your kernel is built with CONFIG_SCHED_DEBUG=y, you can verify that it contains the stealing optimization using - -``` -# grep -q STEAL /sys/kernel/debug/sched_features && echo Yes -Yes -``` - -If you try it, note that stealing is disabled for systems with more than 2 NUMA nodes, because hackbench regresses on such systems, as I explain in [https://lkml.org/lkml/2018/12/6/1250 .][5]However, I suspect this effect is specific to hackbench and that stealing will help other workloads on many-node systems. To try it, reboot with kernel parameter sched_steal_node_limit = 8 (or larger). - -### Future work - -After the basic stealing algorithm is pushed upstream, I am considering the following enhancements: - - * If stealing within the last-level cache does not find a candidate, steal across LLC's and NUMA nodes. - * Maintain a sparse bitmap to identify stealing candidates in the RT scheduling class. Currently pull_rt_task() searches all run queues. - * Remove the core and socket levels from idle_balance(), as stealing handles those levels. Remove idle_balance() entirely when stealing across LLC is supported. - * Maintain a bitmap to identify idle cores and idle CPUs, for push balancing. - - - -_This article originally appeared at[Oracle Developers Blog][6]._ - -_Oracle Linux kernel developer Steve Sistare contributes this discussion on kernel scheduler improvements._ - -### Load balancing via scalable task stealing - -The Linux task scheduler balances load across a system by pushing waking tasks to idle CPUs, and by pulling tasks from busy CPUs when a CPU becomes idle. Efficient scaling is a challenge on both the push and pull sides on large systems. For pulls, the scheduler searches all CPUs in successively larger domains until an overloaded CPU is found, and pulls a task from the busiest group. This is very expensive, costing 10's to 100's of microseconds on large systems, so search time is limited by the average idle time, and some domains are not searched. Balance is not always achieved, and idle CPUs go unused. - -I have implemented an alternate mechanism that is invoked after the existing search in idle_balance() limits itself and finds nothing. I maintain a bitmap of overloaded CPUs, where a CPU sets its bit when its runnable CFS task count exceeds 1. The bitmap is sparse, with a limited number of significant bits per cacheline. This reduces cache contention when many threads concurrently set, clear, and visit elements. There is a bitmap per last-level cache. When a CPU becomes idle, it searches the bitmap to find the first overloaded CPU with a migratable task, and steals it. This simple stealing yields a higher CPU utilization than idle_balance() alone, because the search is cheap, costing 1 to 2 microseconds, so it may be called every time the CPU is about to go idle. Stealing does not offload the globally busiest queue, but it is much better than running nothing at all. - -### Results - -Stealing improves utilization with only a modest CPU overhead in scheduler code. In the following experiment, hackbench is run with varying numbers of groups (40 tasks per group), and the delta in /proc/schedstat is shown for each run, averaged per CPU, augmented with these non-standard stats: - - * %find - percent of time spent in old and new functions that search for idle CPUs and tasks to steal and set the overloaded CPUs bitmap. - * steal - number of times a task is stolen from another CPU. Elapsed time improves by 8 to 36%, costing at most 0.4% more find time. - - - -![load balancing][1] - -[Used with permission][2] - -​​CPU busy utilization is close to 100% for the new kernel, as shown by the green curve in the following graph, versus the orange curve for the baseline kernel: - -![][3] - -Stealing improves Oracle database OLTP performance by up to 9% depending on load, and we have seen some nice improvements for mysql, pgsql, gcc, java, and networking. In general, stealing is most helpful for workloads with a high context switch rate. - -### The code - -As of this writing, this work is not yet upstream, but the latest patch series is at [https://lkml.org/lkml/2018/12/6/1253. ][4]If your kernel is built with CONFIG_SCHED_DEBUG=y, you can verify that it contains the stealing optimization using - -``` -# grep -q STEAL /sys/kernel/debug/sched_features && echo Yes -Yes -``` - -If you try it, note that stealing is disabled for systems with more than 2 NUMA nodes, because hackbench regresses on such systems, as I explain in [https://lkml.org/lkml/2018/12/6/1250 .][5]However, I suspect this effect is specific to hackbench and that stealing will help other workloads on many-node systems. To try it, reboot with kernel parameter sched_steal_node_limit = 8 (or larger). - -### Future work - -After the basic stealing algorithm is pushed upstream, I am considering the following enhancements: - - * If stealing within the last-level cache does not find a candidate, steal across LLC's and NUMA nodes. - * Maintain a sparse bitmap to identify stealing candidates in the RT scheduling class. Currently pull_rt_task() searches all run queues. - * Remove the core and socket levels from idle_balance(), as stealing handles those levels. Remove idle_balance() entirely when stealing across LLC is supported. - * Maintain a bitmap to identify idle cores and idle CPUs, for push balancing. - - - -_This article originally appeared at[Oracle Developers Blog][6]._ - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/can-better-task-stealing-make-linux-faster - -作者:[Oracle][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: -[b]: https://github.com/lujun9972 -[1]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/linux-load-balancing.png?itok=2Uk1yALt (load balancing) -[2]: /LICENSES/CATEGORY/USED-PERMISSION -[3]: https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50425/b7a700fe-edc3-4ea0-876a-c91e1850b59b/Image/00c074f4282bcbaf0c10dd153c5dfa76/steal_graph.png -[4]: https://lkml.org/lkml/2018/12/6/1253 -[5]: https://lkml.org/lkml/2018/12/6/1250 -[6]: https://blogs.oracle.com/linux/can-better-task-stealing-make-linux-faster diff --git a/sources/tech/20190513 How To Set Password Complexity On Linux.md b/sources/tech/20190513 How To Set Password Complexity On Linux.md deleted file mode 100644 index e9a3171c6b..0000000000 --- a/sources/tech/20190513 How To Set Password Complexity On Linux.md +++ /dev/null @@ -1,243 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How To Set Password Complexity On Linux?) -[#]: via: (https://www.2daygeek.com/how-to-set-password-complexity-policy-on-linux/) -[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) - -How To Set Password Complexity On Linux? -====== - -User management is one of the important task of Linux system administration. - -There are many aspect is involved in this and implementing the strong password policy is one of them. - -Navigate to the following URL, if you would like to **[generate a strong password on Linux][1]**. - -It will Restrict unauthorized access to systems. - -By default Linux is secure that everybody know. however, we need to make necessary tweak on this to make it more secure. - -Insecure password will leads to breach security. So, take additional care on this. - -Navigate to the following URL, if you would like to see the **[password strength and score][2]** of the generated strong password. - -In this article, we will teach you, how to implement the best security policy on Linux. - -We can use PAM (the “pluggable authentication module”) to enforce password policy On most Linux systems. - -The file can be found in the following location. - -For Redhat based systems @ `/etc/pam.d/system-auth` and Debian based systems @ `/etc/pam.d/common-password`. - -The default password aging details can be found in the `/etc/login.defs` file. - -I have trimmed this file for better understanding. - -``` -# vi /etc/login.defs - -PASS_MAX_DAYS 99999 -PASS_MIN_DAYS 0 -PASS_MIN_LEN 5 -PASS_WARN_AGE 7 -``` - -**Details:** - - * **`PASS_MAX_DAYS:`**` ` Maximum number of days a password may be used. - * **`PASS_MIN_DAYS:`**` ` Minimum number of days allowed between password changes. - * **`PASS_MIN_LEN:`**` ` Minimum acceptable password length. - * **`PASS_WARN_AGE:`**` ` Number of days warning given before a password expires. - - - -We will show you, how to implement the below eleven password policies in Linux. - - * Password Max days - * Password Min days - * Password warning days - * Password history or Deny Re-Used Passwords - * Password minimum length - * Minimum upper case characters - * Minimum lower case characters - * Minimum digits in password - * Minimum other characters (Symbols) - * Account lock – retries - * Account unlock time - - - -### What Is Password Max days? - -This parameter limits the maximum number of days a password can be used. It’s mandatory for user to change his/her account password before expiry. - -If they forget to change, they are not allowed to login into the system. They need to work with admin team to get rid of it. - -It can be set in `/etc/login.defs` file. I’m going to set `90 days`. - -``` -# vi /etc/login.defs - -PASS_MAX_DAYS 90 -``` - -### What Is Password Min days? - -This parameter limits the minimum number of days after password can be changed. - -Say for example, if this parameter is set to 15 and user changed password today. Then he won’t be able to change the password again before 15 days from now. - -It can be set in `/etc/login.defs` file. I’m going to set `15 days`. - -``` -# vi /etc/login.defs - -PASS_MIN_DAYS 15 -``` - -### What Is Password Warning Days? - -This parameter controls the password warning days and it will warn the user when the password is going to expires. - -A warning will be given to the user regularly until the warning days ends. This can helps user to change their password before expiry. Otherwise we need to work with admin team for unlock the password. - -It can be set in `/etc/login.defs` file. I’m going to set `10 days`. - -``` -# vi /etc/login.defs - -PASS_WARN_AGE 10 -``` - -**Note:** All the above parameters only applicable for new accounts and not for existing accounts. - -### What Is Password History Or Deny Re-Used Passwords? - -This parameter keep controls of the password history. Keep history of passwords used (the number of previous passwords which cannot be reused). - -When the users try to set a new password, it will check the password history and warn the user when they set the same old password. - -It can be set in `/etc/pam.d/system-auth` file. I’m going to set `5` for history of password. - -``` -# vi /etc/pam.d/system-auth - -password sufficient pam_unix.so md5 shadow nullok try_first_pass use_authtok remember=5 -``` - -### What Is Password Minimum Length? - -This parameter keeps the minimum password length. When the users set a new password, it will check against this parameter and warn the user if they try to set the password length less than that. - -It can be set in `/etc/pam.d/system-auth` file. I’m going to set `12` character for minimum password length. - -``` -# vi /etc/pam.d/system-auth - -password requisite pam_cracklib.so try_first_pass retry=3 minlen=12 -``` - -**try_first_pass retry=3** : Allow users to set a good password before the passwd command aborts. - -### Set Minimum Upper Case Characters? - -This parameter keeps, how many upper case characters should be added in the password. These are password strengthening parameters ,which increase the password strength. - -When the users set a new password, it will check against this parameter and warn the user if they are not including any upper case characters in the password. - -It can be set in `/etc/pam.d/system-auth` file. I’m going to set `1` character for minimum password length. - -``` -# vi /etc/pam.d/system-auth - -password requisite pam_cracklib.so try_first_pass retry=3 minlen=12 ucredit=-1 -``` - -### Set Minimum Lower Case Characters? - -This parameter keeps, how many lower case characters should be added in the password. These are password strengthening parameters ,which increase the password strength. - -When the users set a new password, it will check against this parameter and warn the user if they are not including any lower case characters in the password. - -It can be set in `/etc/pam.d/system-auth` file. I’m going to set `1` character. - -``` -# vi /etc/pam.d/system-auth - -password requisite pam_cracklib.so try_first_pass retry=3 minlen=12 lcredit=-1 -``` - -### Set Minimum Digits In Password? - -This parameter keeps, how many digits should be added in the password. These are password strengthening parameters ,which increase the password strength. - -When the users set a new password, it will check against this parameter and warn the user if they are not including any digits in the password. - -It can be set in `/etc/pam.d/system-auth` file. I’m going to set `1` character. - -``` -# vi /etc/pam.d/system-auth - -password requisite pam_cracklib.so try_first_pass retry=3 minlen=12 dcredit=-1 -``` - -### Set Minimum Other Characters (Symbols) In Password? - -This parameter keeps, how many Symbols should be added in the password. These are password strengthening parameters ,which increase the password strength. - -When the users set a new password, it will check against this parameter and warn the user if they are not including any Symbol in the password. - -It can be set in `/etc/pam.d/system-auth` file. I’m going to set `1` character. - -``` -# vi /etc/pam.d/system-auth - -password requisite pam_cracklib.so try_first_pass retry=3 minlen=12 ocredit=-1 -``` - -### Set Account Lock? - -This parameter controls users failed attempts. It locks user account after reaches the given number of failed login attempts. - -It can be set in `/etc/pam.d/system-auth` file. - -``` -# vi /etc/pam.d/system-auth - -auth required pam_tally2.so onerr=fail audit silent deny=5 -account required pam_tally2.so -``` - -### Set Account Unlock Time? - -This parameter keeps users unlock time. If the user account is locked after consecutive failed authentications. - -It’s unlock the locked user account after reaches the given time. Sets the time (900 seconds = 15 minutes) for which the account should remain locked. - -It can be set in `/etc/pam.d/system-auth` file. - -``` -# vi /etc/pam.d/system-auth - -auth required pam_tally2.so onerr=fail audit silent deny=5 unlock_time=900 -account required pam_tally2.so -``` - --------------------------------------------------------------------------------- - -via: https://www.2daygeek.com/how-to-set-password-complexity-policy-on-linux/ - -作者:[Magesh Maruthamuthu][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.2daygeek.com/author/magesh/ -[b]: https://github.com/lujun9972 -[1]: https://www.2daygeek.com/5-ways-to-generate-a-random-strong-password-in-linux-terminal/ -[2]: https://www.2daygeek.com/how-to-check-password-complexity-strength-and-score-in-linux/ diff --git a/sources/tech/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md b/sources/tech/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md deleted file mode 100644 index e3a533b3b2..0000000000 --- a/sources/tech/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md +++ /dev/null @@ -1,200 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server) -[#]: via: (https://www.linuxtechi.com/install-lemp-stack-fedora-30-server/) -[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) - -How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server -====== - -In this article, we’ll be looking at how to install **LEMP** stack on Fedora 30 Server. LEMP Stands for: - - * L -> Linux - * E -> Nginx - * M -> Maria DB - * P -> PHP - - - -I am assuming **[Fedora 30][1]** is already installed on your system. - -![LEMP-Stack-Fedora30][2] - -LEMP is a collection of powerful software setup that is installed on a Linux server to help in developing popular development platforms to build websites, LEMP is a variation of LAMP wherein instead of **Apache** , **EngineX (Nginx)** is used as well as **MariaDB** used in place of **MySQL**. This how-to guide is a collection of separate guides to install Nginx, Maria DB and PHP. - -### Install Nginx, PHP 7.3 and PHP-FPM on Fedora 30 Server - -Let’s take a look at how to install Nginx and PHP along with PHP FPM on Fedora 30 Server. - -### Step 1) Switch to root user - -First step in installing Nginx in your system is to switch to root user. Use the following command : - -``` -root@linuxtechi ~]$ sudo -i -[sudo] password for pkumar: -[root@linuxtechi ~]# -``` - -### Step 2) Install Nginx, PHP 7.3 and PHP FPM using dnf command - -Install Nginx using the following dnf command: - -``` -[root@linuxtechi ~]# dnf install nginx php php-fpm php-common -y -``` - -### Step 3) Install Additional PHP modules - -The default installation of PHP only comes with the basic and the most needed modules installed. If you need additional modules like GD, XML support for PHP, command line interface Zend OPCache features etc, you can always choose your packages and install everything in one go. See the sample command below: - -``` -[root@linuxtechi ~]# sudo dnf install php-opcache php-pecl-apcu php-cli php-pear php-pdo php-pecl-mongodb php-pecl-redis php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml -y -``` - -### Step 4) Start & Enable Nginx and PHP-fpm Service - -Start and enable Nginx service using the following command - -``` -[root@linuxtechi ~]# systemctl start nginx && systemctl enable nginx -Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service. -[root@linuxtechi ~]# -``` - -Use the following command to start and enable PHP-FPM service - -``` -[root@linuxtechi ~]# systemctl start php-fpm && systemctl enable php-fpm -Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service. -[root@linuxtechi ~]# -``` - -**Verify Nginx (Web Server) and PHP installation,** - -**Note:** In case OS firewall is enabled and running on your Fedora 30 system, then allow 80 and 443 ports using beneath commands, - -``` -[root@linuxtechi ~]# firewall-cmd --permanent --add-service=http -success -[root@linuxtechi ~]# -[root@linuxtechi ~]# firewall-cmd --permanent --add-service=https -success -[root@linuxtechi ~]# firewall-cmd --reload -success -[root@linuxtechi ~]# -``` - -Open the web browser, type the following URL: http:// - -[![Test-Page-HTTP-Server-Fedora-30][3]][4] - -Above screen confirms that NGINX is installed successfully. - -Now let’s verify PHP installation, create a test php page(info.php) using the beneath command, - -``` -[root@linuxtechi ~]# echo "" > /usr/share/nginx/html/info.php -[root@linuxtechi ~]# -``` - -Type the following URL in the web browser, - -http:///info.php - -[![Php-info-page-fedora30][5]][6] - -Above page confirms that PHP 7.3.5 has been installed successfully. Now let’s install MariaDB database server. - -### Install MariaDB on Fedora 30 - -MariaDB is a great replacement for MySQL DB as it is works much similar to MySQL and also compatible with MySQL steps too. Let’s look at the steps to install MariaDB on Fedora 30 Server - -### Step 1) Switch to Root User - -First step in installing MariaDB in your system is to switch to root user or you can use a local user who has root privilege. Use the following command below: - -``` -[root@linuxtechi ~]# sudo -i -[root@linuxtechi ~]# -``` - -### Step 2) Install latest version of MariaDB (10.3) using dnf command - -Use the following command to install MariaDB on Fedora 30 Server - -``` -[root@linuxtechi ~]# dnf install mariadb-server -y -``` - -### Step 3) Start and enable MariaDB Service - -Once the mariadb is installed successfully in step 2), next step is to start the MariaDB service. Use the following command: - -``` -[root@linuxtechi ~]# systemctl start mariadb.service ; systemctl enable mariadb.service -``` - -### Step 4) Secure MariaDB Installation - -When we install MariaDB server, so by default there is no root password, also anonymous users are created in database. So, to secure MariaDB installation, run the beneath “mysql_secure_installation” command - -``` -[root@linuxtechi ~]# mysql_secure_installation -``` - -Next you will be prompted with some question, just answer the questions as shown below: - -![Secure-MariaDB-Installation-Part1][7] - -![Secure-MariaDB-Installation-Part2][8] - -### Step 5) Test MariaDB Installation - -Once you have installed, you can always test if MariaDB is successfully installed on the server. Use the following command: - -``` -[root@linuxtechi ~]# mysql -u root -p -Enter password: -``` - -Next you will be prompted for a password. Enter the password same password that you have set during MariaDB secure installation, then you can see the MariaDB welcome screen. - -``` -Welcome to the MariaDB monitor. Commands end with ; or \g. -Your MariaDB connection id is 17 -Server version: 10.3.12-MariaDB MariaDB Server - -Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. - -Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. - -MariaDB [(none)]> -``` - -And finally, we’ve completed everything to install LEMP (Linux, Nginx, MariaDB and PHP) on your server successfully. Please post all your comments and suggestions in the feedback section below and we’ll respond back at the earliest. - --------------------------------------------------------------------------------- - -via: https://www.linuxtechi.com/install-lemp-stack-fedora-30-server/ - -作者:[Pradeep Kumar][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.linuxtechi.com/author/pradeep/ -[b]: https://github.com/lujun9972 -[1]: https://www.linuxtechi.com/fedora-30-workstation-installation-guide/ -[2]: https://www.linuxtechi.com/wp-content/uploads/2019/06/LEMP-Stack-Fedora30.jpg -[3]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Test-Page-HTTP-Server-Fedora-30-1024x732.jpg -[4]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Test-Page-HTTP-Server-Fedora-30.jpg -[5]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Php-info-page-fedora30-1024x732.jpg -[6]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Php-info-page-fedora30.jpg -[7]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Secure-MariaDB-Installation-Part1.jpg -[8]: https://www.linuxtechi.com/wp-content/uploads/2019/06/Secure-MariaDB-Installation-Part2.jpg diff --git a/sources/tech/20190711 DevOps for introverted people.md b/sources/tech/20190711 DevOps for introverted people.md index b356d5de7d..da1778573c 100644 --- a/sources/tech/20190711 DevOps for introverted people.md +++ b/sources/tech/20190711 DevOps for introverted people.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: ( XLCYun ) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20190718 What you need to know to be a sysadmin.md b/sources/tech/20190718 What you need to know to be a sysadmin.md deleted file mode 100644 index 55947b8456..0000000000 --- a/sources/tech/20190718 What you need to know to be a sysadmin.md +++ /dev/null @@ -1,121 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (What you need to know to be a sysadmin) -[#]: via: (https://opensource.com/article/19/7/be-a-sysadmin) -[#]: author: (Seth Kenlon https://opensource.com/users/sethhttps://opensource.com/users/marcobravohttps://opensource.com/users/kimvila) - -What you need to know to be a sysadmin -====== -Kickstart your sysadmin career by gaining these minimum competencies. -![People work on a computer server with devices][1] - -The system administrator of yesteryear jockeyed users and wrangled servers all day, in between mornings and evenings spent running hundreds of meters of hundreds of cables. This is still true today, with the added complexity of cloud computing, containers, and virtual machines. - -Looking in from the outside, it can be difficult to pinpoint what exactly a sysadmin does, because they play at least a small role in so many places. Nobody goes into a career already knowing everything they need for a job, but everyone needs a strong foundation. If you're looking to start down the path of system administration, here's what you should be concentrating on in your personal or formal training. - -### Bash - -When you learn the Bash shell, you don't just learn the Bash shell. You learn a common interface to Linux systems, BSD, MacOS, and even Windows (under the right conditions). You learn the importance of syntax, so you can quickly adapt to systems like Cisco routers' command line or Microsoft's PowerShell, and eventually, you can even learn more powerful languages like Python or Go. And you also begin to think procedurally so you can analyze complex problems and break them down into individual components, which is key because _that's_ how systems, like the internet, or an organization's intranet, or a web server, or a backup solution, are designed. - -But wait. There's more. - -Knowing the Bash shell has become particularly important because of the recent trend toward DevOps and [containers][2]. Your career as a sysadmin may lead you into a world where infrastructure is treated like code, which usually means you'll have to know the basics of scripting, the structure of [YAML-based][3] configuration, and how to [interact][4] with [containers][5] (tiny Linux systems running inside a [sandboxed file][6]). Knowing Bash is the gateway to efficient management of the most exciting open source technology, so go get [Bourne Again][7]. - -#### Resources - -There are many ways to get practice in the Bash shell. - -Try a [portable Linux distribution][8]. You don't have to install Linux to use Linux, so grab a spare thumb drive and spend your evenings or weekends getting comfortable with a text-based interface. - -There are several excellent [Bash articles][9] available here on opensource.com as well as [on Enable SysAdmin][10]. - -The problem with telling someone to practice with Bash is that to practice, you must have something to do. And until you know how to use Bash, you probably won't be able to think of anything to do. If that's your situation, go to Over The Wire and play [Bandit][11]. It's a game aimed at absolute beginners, with 34 levels of interactive basic hacking to get you comfortable with the Linux shell. - -### Web server setup - -Once you're comfortable with Bash, you should try setting up a web server. Not all sysadmins go around setting up web servers or even maintain web servers, but the skills you acquire while installing and starting the HTTP daemon, configuring Apache or Nginx, setting up the [correct permissions][12], and [configuring a firewall][13], are the same skills you need on a daily basis. After a little bit of effort, you may start to notice certain patterns in your labor. There are concepts you probably took for granted before trying to administer production-ready software and hardware, and you're no longer shielded from them in your fledgling role as an administrator. It might be frustrating at first because everyone likes to be good at everything they do, but that's actually a good thing. Let yourself be bad at new skills. That's how you learn. - -And besides, the more you struggle through your first steps, the sweeter it is when you finally see that triumphant "it works!" default index.html. - -#### Resources - -David Both wrote an excellent article on [Apache web server][14] configuration. For extra credit, step through his follow-up article on how to [host multiple sites][15] on one machine. - -### DHCP - -The Dynamic Host Configuration Protocol (DHCP) is the system that assigns IP addresses to devices on a network. At home, the modem or router your ISP (internet service provider) supports probably has an embedded DHCP server in it, so it's likely out of your purview. If you've ever logged into your home router to adjust the IP address range or set up a static address for some of your network devices, then you're at least somewhat familiar with the concept. You may understand that devices on a network are assigned the equivalent of phone numbers in the form of IP addresses, and you may realize that computers communicate with one another by broadcasting messages addressed to a specific IP address. Message headers are read by routers along the path, each of which works to direct the message to the next most logical router along the path toward its ultimate goal. - -Even if you understand these concepts, the inevitable escalation of basic familiarity with DHCP is to set up a DHCP server. Installing and configuring your own DHCP server provides you the opportunity to introduce DHCP collisions on your home network (try to avoid that, if you can, as it will definitely kill your network until it's resolved), control the distribution of addresses, create subnets, and monitor connections and lease times. - -More importantly, setting up DHCP and experimenting with different configurations helps you understand inter-networking. You understand how networks represent "partitions" in data transference and what steps you have to take to pass information from one to the other. That's vital for a sysadmin to know because the network is easily one of the most important aspects of the job. - -#### Resources - -Before running your own DHCP server, ensure that the DHCP server in your home router (if you have one) is inactive. Once you have it up and running, read Archit Modi's [guide to network commands][16] for tips on how to explore your network. - -### Network cables - -It might sound mundane, but getting familiar with how network cables work not only makes for a really fun weekend but also gives you a whole new understanding of how data gets across the wires. The best way to learn is to go to your local hobby shop and purchase a Cat 5 cutter and crimper and a few Cat 5 terminators. Then head home, grab a spare Ethernet cable, and cut the terminators off. Spend whatever amount of time it takes to get that cable back in commission. - -Once you have solved that puzzle, do it again, this time creating a working [crossover cable][17]. - -You should also start obsessing _now_ about cable management. If you're not naturally inclined to run cables neatly along the floor molding or the edges of a desk or to bind cables together to keep them orderly, then make it a goal to permanently condition yourself with a phobia of messy cables. You won't understand why this is necessary at first, but the first time you walk into a server room, you will immediately know. - -### Ansible - -[Ansible][18] is configuration management software, and it's a bit of a bridge between sysadmin and DevOps. Sysadmins use Ansible to configure fresh installs of an operating system and to maintain specific states on machines. DevOps uses Ansible to reduce time and effort spent on tooling so that more time and effort gets spent on developing. You should learn Ansible as part of your sysadmin training, with an eye toward the practices of DevOps, because most of what DevOps is pioneering now will end up as part of your workflow in the system administration of the future. - -The good thing about Ansible is that you can start using it now. It's cross-platform, and it scales both up and down. Ansible may be overkill for a single-user computer, but then again, Ansible could change the way you spin up virtual machines, or it could help you synchronize the states of all the computers in your home or [home lab][19]. - -#### Resources - -Read "[How to manage your workstation configuration with Ansible][20]" by Jay LaCroix for the quintessential introduction to get started with Ansible on a casual basis. - -### Break stuff - -Problems arise on computers because of user error, buggy software, administrator (that's you!) error, and any number of other factors. There's no way to predict what's going to fail or why, so part of your personal sysadmin training regime should be to poke at the systems you set up until they fail. The worse you are to your own lab infrastructure, the more likely you are to find weak points. And the more often you repair those weak spots, the more confident you become in your problem-solving skills. - -Aside from the rigors of setting up all the usual software and hardware, your primary job as a sysadmin is to find solutions. There will be times when you encounter a problem outside your job description, and it may not even be possible for you to fix it, but it'll be up to you to find a workaround. - -The more you break stuff now and work to fix it, the better prepared you will be to work as a sysadmin. - -* * * - -Are you a working sysadmin? Are there tasks you wish you'd prepared better for? Add them in the comments below! - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/7/be-a-sysadmin - -作者:[Seth Kenlon][a] -选题:[lujun9972][b] -译者:[译者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/sethhttps://opensource.com/users/marcobravohttps://opensource.com/users/kimvila -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux11x_cc.png?itok=XMDOouJR (People work on a computer server with devices) -[2]: https://opensource.com/article/19/6/kubernetes-dump-truck -[3]: https://www.redhat.com/sysadmin/yaml-tips -[4]: https://opensource.com/article/19/6/how-ssh-running-container -[5]: https://opensource.com/resources/what-are-linux-containers -[6]: https://opensource.com/article/18/11/behind-scenes-linux-containers -[7]: https://opensource.com/article/18/7/admin-guide-bash -[8]: https://opensource.com/article/19/6/linux-distros-to-try -[9]: https://opensource.com/tags/bash -[10]: https://www.redhat.com/sysadmin/managing-files-linux-terminal -[11]: http://overthewire.org/wargames/bandit -[12]: https://opensource.com/article/19/6/understanding-linux-permissions -[13]: https://www.redhat.com/sysadmin/secure-linux-network-firewall-cmd -[14]: https://opensource.com/article/18/2/how-configure-apache-web-server -[15]: https://opensource.com/article/18/3/configuring-multiple-web-sites-apache -[16]: https://opensource.com/article/18/7/sysadmin-guide-networking-commands -[17]: https://en.wikipedia.org/wiki/Ethernet_crossover_cable -[18]: https://opensource.com/sitewide-search?search_api_views_fulltext=ansible -[19]: https://opensource.com/article/19/6/create-centos-homelab-hour -[20]: https://opensource.com/article/18/3/manage-workstation-ansible diff --git a/sources/tech/20190725 24 sysadmin job interview questions you should know.md b/sources/tech/20190725 24 sysadmin job interview questions you should know.md deleted file mode 100644 index c80bf8f86e..0000000000 --- a/sources/tech/20190725 24 sysadmin job interview questions you should know.md +++ /dev/null @@ -1,292 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (24 sysadmin job interview questions you should know) -[#]: via: (https://opensource.com/article/19/7/sysadmin-job-interview-questions) -[#]: author: (DirectedSoul https://opensource.com/users/directedsoul) - -24 sysadmin job interview questions you should know -====== -Have a sysadmin job interview coming up? Read this article for some -questions you might encounter and possible answers. -![Question and answer.][1] - -As a geek who always played with computers, a career after my masters in IT was a natural choice. So, I decided the sysadmin path was the right one. In the process of my career, I have grown quite familiar with the job interview process. Here is a look at what to expect, the general career path, and a set of common questions and my answers to them. - -### Typical sysadmin tasks and duties - -Organizations need someone who understands the basics of how a system works so that they can keep their data safe, and keep their services running smoothly. You might ask: "Wait, isn’t there more that a sysadmin can do?" - -You are right. Now, in general, let’s look at what might be a typical sysadmin’s day-to-day tasks. Depending on their company’s needs and the person’s skill level, a sysadmin’s tasks vary from managing desktops, laptops, networks, and servers, to designing the organization’s IT policies. Sometimes sysadmins are even in charge of purchasing and placing orders for new IT equipment. - -Those seeking system administration as their career paths might find it difficult to keep their skills and knowledge up to date, as rapid changes in the IT field are inevitable. The next natural question that arises out of anyone’s mind is how IT professionals keep up with the latest updates and skills. - -### Low difficulty questions - -Here are some of the more basic questions you will encounter, and my answers: - - 1. What are the first five commands you type on a *nix server after login? - - - -> * **lsblk** to see information on all block devices -> * **who** to see who is logged into the server -> * **top** to get a sense of what is running on the server -> * **df -khT** to view the amount of disk space available on the server -> * **netstat** to see what TCP network connections are active -> - - - 2. How do you make a process run in the background, and what are the advantages of doing so? - - - -> You can make a process run in the background by adding the special character **&** at the end of the command. Generally, applications that take too long to execute, and don’t require user interaction are sent to the background so that we can continue our work in the terminal. ([Citation][2]) - - 3. Is running these commands as root a good or bad idea? - - - -> Running (everything) as root is bad due to two major issues. The first is _risk_. Nothing prevents you from making a careless mistake when you are logged in as **root**. If you try to change the system in a potentially harmful way, you need to use **sudo**, which introduces a pause (while you’re entering the password) to ensure that you aren’t about to make a mistake. -> -> The second reason is _security_. Systems are harder to hack if you don’t know the admin user’s login information. Having access to root means you already have one half of the working set of admin credentials. - - 4. What is the difference between **rm** and **rm -rf**? - - - -> The **rm** command by itself only deletes the named files (and not directories). With **-rf** you add two additional features: The **-r**, **-R**, or --**recursive** flag recursively deletes the directory’s contents, including hidden files and subdirectories, and the **-f**, or --**force**, flag makes **rm** ignore nonexistent files, and never prompt for confirmation. - - 5. **Compress.tgz** has a file size of approximately 15GB. How can you list its contents, and how do you list them only for a specific file? - - - -> To list the file’s contents: -> -> **tar tf archive.tgz** -> -> To extract a specific file: -> -> **tar xf archive.tgz filename** - -### Medium difficulty questions - -Here are some harder questions you might encounter, and my answers: - - 6. What is RAID? What is RAID 0, RAID 1, RAID 5, RAID 6, and RAID 10? - - - -> A RAID (Redundant Array of Inexpensive Disks) is a technology used to increase the performance and/or reliability of data storage. The RAID levels are: -> -> * RAID 0: Also known as disk striping, which is a technique that breaks up a file, and spreads the data across all of the disk drives in a RAID group. There are no safeguards against failure. ([Citation][3]) -> * RAID 1: A popular disk subsystem that increases safety by writing the same data on two drives. Called _mirroring_, RAID1 does not increase write performance, but read performance may increase up to the sum of each disks’ performance. Also, if one drive fails, the second drive is used, and the failed drive is manually replaced. After replacement, the RAID controller duplicates the contents of the working drive onto the new one. -> * RAID 5: A disk subsystem that increases safety by computing parity data and increasing speed. RAID 5 does this by interleaving data across three or more drives (striping). Upon failure of a single drive, subsequent reads can be calculated from the distributed parity such that no data is lost. -> * RAID 6: Which extends RAID 5 by adding another parity block. This level requires a minimum of four disks, and can continue to execute read/write with any two concurrent disk failures. RAID 6 does not have a performance penalty for reading operations, but it does have a performance penalty on write operations because of the overhead associated with parity calculations. -> * RAID 10: Also known as RAID 1+0, RAID 10 combines disk mirroring and disk striping to protect data. It requires a minimum of four disks, and stripes data across mirrored pairs. As long as one disk in each mirrored pair is functional, data can be retrieved. If two disks in the same mirrored pair fail, all data will be lost because there is no parity in the striped sets. ([Citation][4]) -> - - - 7. Which port is used for the **ping** command? - - - -> The **ping** command uses ICMP. Specifically, it uses ICMP echo requests and ICMP echo reply packets. -> -> ICMP does not use either UDP or TCP communication services: Instead, it uses raw IP communication services. This means that the ICMP message is carried directly in an IP datagram data field. - - 8. What is the difference between a router and a gateway? What is the default gateway? - - - -> _Router_ describes the general technical function (layer 3 forwarding), or a hardware device intended for that purpose, while _gateway_ describes the function for the local segment (providing connectivity to elsewhere). You could also state that you "set up a router as a gateway." Another term is _hop_, which describes forwarding between subnets. -> -> The term _default gateway_ is used to mean the router on your LAN, which has the responsibility of being the first point of contact for traffic to computers outside the LAN. - - 9. Explain the boot process for Linux. - - - -> BIOS -> Master Boot Record (MBR) -> GRUB -> the kernel -> init -> runlevel - - 10. How do you check the error messages while the server is booting up? - - - -> Kernel messages are always stored in the kmsg buffer, visible via the **dmesg** command. -> -> Boot issues and errors call for a system administrator to look into certain important files, in conjunction with particular commands, which are each handled differently by different versions of Linux: -> -> * **/var/log/boot.log** is the system boot log, which contains all that unfolded during the system boot. -> * **/var/log/messages** stores global system messages, including the messages logged during system boot. -> * **/var/log/dmesg** contains kernel ring buffer information. -> - - - 11. What is the difference between a symbolic link and a hard link? - - - -> A _symbolic_ or _soft link_ is an actual link to the original file, whereas a _hard link_ is a mirror copy of the original file. If you delete the original file, the soft link has no value, because it then points to a non-existent file. In the case of a hard link, it is entirely the opposite. If you delete the original file, the hard link still contains the data from the original file. ([Citation][5]) - - 12. How do you change kernel parameters? What kernel options might you need to tune? - - - -> To set the kernel parameters in Unix-like systems, first edit the file **/etc/sysctl.conf**. After making the changes, save the file and run the **sysctl -p** command. This command makes the changes permanent without rebooting the machine - - 13. Explain the **/proc** filesystem. - - - -> The **/proc** filesystem is virtual, and provides detailed information about the kernel, hardware, and running processes. Since **/proc** contains virtual files, it is called the _virtual file system_. These virtual files have unique qualities. Most of them are listed as zero bytes in size. -> -> Virtual files such as **/proc/interrupts**, **/proc/meminfo**, **/proc/mounts** and **/proc/partitions** provide an up-to-the-moment glimpse of the system’s hardware. Others, such as **/proc/filesystems** and the **/proc/sys** directory provide system configuration information and interfaces. - - 14. How do you run a script as another user without their password? - - - -> For example, if you were editing the sudoers file (such as **/private/etc/sudoers**), you might use **visudo** to add the following: -> -> [**user1 ALL=(user2) NOPASSWD: /opt/scripts/bin/generate.sh**][2] - - 15. What is the UID 0 toor account? Have you been compromised? - - - -> The toor user is an alternative superuser account, where toor is root spelled backward. It is intended to be used with a non-standard shell, so the default shell for root does not need to change. -> -> This purpose is important. Shells which are not part of the base distribution, but are instead installed from ports or packages, are installed in **/usr/local/bin**; which, by default, resides on a different file system. If root’s shell is located in **/usr/local/bin** and the file system containing **/usr/local/bin** is not mounted, root could not log in to fix a problem, and the sysadmin would have to reboot into single-user mode to enter the shell’s path. - -### Advanced questions - -Here are the even more difficult questions you may encounter: - - 16. How does **tracert** work and what protocol does it use? - - - -> The command **tracert**—or **traceroute** depending on the operating system—allows you to see exactly what routers you touch as you move through the chain of connections to your final destination. If you end up with a problem where you can’t connect to or **ping** your final destination, a **tracert** can help in that you can tell exactly where the chain of connections stops. ([Citation][6]) -> -> With this information, you can contact the correct people; whether it be your own firewall, your ISP, your destination’s ISP, or somewhere in the middle. The **tracert** command—like **ping**—uses the ICMP protocol, but also can use the first step of the TCP three-way handshake to send SYN requests for a response. - - 17. What is the main advantage of using **chroot**? When and why do we use it? What is the purpose of the **mount /dev**, **mount /proc**, and **mount /sys** commands in a **chroot** environment?  - - - -> An advantage of having a **chroot** environment is that the filesystem is isolated from the physical host, since **chroot** has a separate filesystem inside your filesystem. The difference is that **chroot** uses a newly created root (**/**) as its root directory. -> -> A **chroot** jail lets you isolate a process and its children from the rest of the system. It should only be used for processes that don’t run as **root**, as **root** users can break out of the jail easily. -> -> The idea is that you create a directory tree where you copy or link in all of the system files needed for the process to run. You then use the **chroot()** system call to tell it the root directory now exists at the base of this new tree, and then start the process running in that **chroot**’d environment. Since the command then can’t reference paths outside the modified root directory, it can’t perform operations (read, write, etc.) maliciously on those locations. ([Citation][7]) - - 18. How do you protect your system from getting hacked? - - - -> By following the principle of least privileges and these practices: -> -> * Encrypt with public keys, which provides excellent security. -> * Enforce password complexity. -> * Understand why you are making exceptions to the rules above. -> * Review your exceptions regularly. -> * Hold someone to account for failure. (It keeps you on your toes.) ([Citation][8]) -> - - - 19. What is LVM, and what are the advantages of using it? - - - -> LVM, or Logical Volume Management, uses a storage device management technology that gives users the power to pool and abstract the physical layout of component storage devices for easier and flexible administration. Using the device mapper Linux kernel framework, the current iteration (LVM2) can be used to gather existing storage devices into groups and allocate logical units from the combined space as needed. - - 20. What are sticky ports? - - - -> Sticky ports are one of the network administrator’s best friends and worst headaches. They allow you to set up your network so that each port on a switch only permits one (or a number that you specify) computer to connect on that port, by locking it to a particular MAC address. - - 21. Explain port forwarding? - - - -> When trying to communicate with systems on the inside of a secured network, it can be very difficult to do so from the outside—and with good reason. Therefore, the use of a port forwarding table within the router itself, or other connection management device, can allow specific traffic to automatically forward to a particular destination. For example, if you had a web server running on your network and you wanted to grant access to it from the outside, you would set up port forwarding to port 80 on the server in question. This would mean that anyone entering your IP address in a web browser would connect to the server’s website immediately. -> -> Please note, it is usually not recommended to allow access to a server from the outside directly into your network. - - 22. What is a false positive and false negative in the case of IDS? - - - -> When the Intrusion Detection System (IDS) device generates an alert for an intrusion which has actually not happened, this is false positive. If the device has not generated any alert and the intrusion has actually happened, this is the case of a false negative. - - 23. Explain **:(){ :|:& };:** and how to stop this code if you are already logged into the system? - - - -> This is a fork bomb. It breaks down as follows: -> -> * **:()** defines the function, with **:** as the function name, and the empty parenthesis shows that it will not accept any arguments. -> * **{ }** shows the beginning and end of the function definition. -> * **:|:** loads a copy of the function **:** into memory, and pipes its output to another copy of the **:** function, which also has to be loaded into memory. -> * **&** makes the previous item a background process, so that the child processes will not get killed even though the parent gets auto-killed. -> * **:** at the end executes the function again, and hence the chain reaction begins. -> - -> -> The best way to protect a multi-user system is to use Privileged Access Management (PAM) to limit the number of processes a user can use. -> -> The biggest problem with a fork bomb is the fact it takes up so many processes. So, we have two ways of attempting to fix this if you are already logged into the system. One option is to execute a SIGSTOP command to stop the process, such as: -> -> **killall -STOP -u user1** -> -> If you can’t use the command line due to all processes being used, you will have to use **exec** to force it to run: -> -> **exec killall -STOP -u user1** -> -> With fork bombs, your best option is preventing them from becoming too big of an issue in the first place - - 24. What is OOM killer and how does it decide which process to kill first? - - - -> If memory is exhaustively used up by processes to the extent that possibly threatens the system’s stability, then the out of memory (OOM) killer comes into the picture. -> -> An OOM killer first has to select the best process(es) to kill. _Best_ here refers to the process which will free up the maximum memory upon being killed, and is also the least important to the system. The primary goal is to kill the least number of processes to minimize the damage done, and at the same time maximize the amount of memory freed. -> -> To facilitate this goal, the kernel maintains an oom_score for each of the processes. You can see the oom_score of each of the processes in the **/proc** filesystem under the **pid** directory: -> -> **$ cat /proc/10292/oom_score** -> -> The higher the value of oom_score for any process, the higher its likelihood is of being killed by the OOM Killer in an out-of-memory situation. ([Citation][9]) - -### Conclusion - -System administration salaries have a [wide range][10] with some sites mentioning $70,000 to $100,000 a year, depending on the location, the size of the organization, and your education level plus years of experience. In the end, the system administration career path boils down to your interest in working with servers and solving cool problems. Now, I would say go ahead and achieve your dream path. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/7/sysadmin-job-interview-questions - -作者:[DirectedSoul][a] -选题:[lujun9972][b] -译者:[译者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/directedsoul -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_HowToFish_520x292.png?itok=DHbdxv6H (Question and answer.) -[2]: https://github.com/trimstray/test-your-sysadmin-skills -[3]: https://www.waytoeasylearn.com/2016/05/netapp-filer-tutorial.html -[4]: https://searchstorage.techtarget.com/definition/RAID-10-redundant-array-of-independent-disks -[5]: https://www.answers.com/Q/What_is_hard_link_and_soft_link_in_Linux -[6]: https://www.wisdomjobs.com/e-university/network-administrator-interview-questions.html -[7]: https://unix.stackexchange.com/questions/105/chroot-jail-what-is-it-and-how-do-i-use-it -[8]: https://serverfault.com/questions/391370/how-to-prevent-zero-day-attacks -[9]: https://unix.stackexchange.com/a/153586/8369 -[10]: https://blog.netwrix.com/2018/07/23/systems-administrator-salary-in-2018-how-much-can-you-earn/ diff --git a/sources/tech/20190827 curl exercises.md b/sources/tech/20190827 curl exercises.md deleted file mode 100644 index 36eae2743b..0000000000 --- a/sources/tech/20190827 curl exercises.md +++ /dev/null @@ -1,84 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (curl exercises) -[#]: via: (https://jvns.ca/blog/2019/08/27/curl-exercises/) -[#]: author: (Julia Evans https://jvns.ca/) - -curl exercises -====== - -Recently I’ve been interested in how people learn things. I was reading Kathy Sierra’s great book [Badass: Making Users Awesome][1]. It talks about the idea of _deliberate practice_. - -The idea is that you find a small micro-skill that can be learned in maybe 3 sessions of 45 minutes, and focus on learning that micro-skill. So, as an exercise, I was trying to think of a computer skill that I thought could be learned in 3 45-minute sessions. - -I thought that making HTTP requests with `curl` might be a skill like that, so here are some curl exercises as an experiment! - -### what’s curl? - -curl is a command line tool for making HTTP requests. I like it because it’s an easy way to test that servers or APIs are doing what I think, but it’s a little confusing at first! - -Here’s a drawing explaining curl’s most important command line arguments (which is page 6 of my [Bite Size Networking][2] zine). You can click to make it bigger. - - - -### fluency is valuable - -With any command line tool, I think having fluency is really helpful. It’s really nice to be able to just type in the thing you need. For example recently I was testing out the Gumroad API and I was able to just type in: - -``` -curl https://api.gumroad.com/v2/sales \ - -d "access_token=" \ - -X GET -d "before=2016-09-03" -``` - -and get things working from the command line. - -### 21 curl exercises - -These exercises are about understanding how to make different kinds of HTTP requests with curl. They’re a little repetitive on purpose. They exercise basically everything I do with curl. - -To keep it simple, we’re going to make a lot of our requests to the same website: . httpbin is a service that accepts HTTP requests and then tells you what request you made. - - 1. Request - 2. Request . httpbin.org/anything will look at the request you made, parse it, and echo back to you what you requested. curl’s default is to make a GET request. - 3. Make a POST request to - 4. Make a GET request to , but this time add some query parameters (set `value=panda`). - 5. Request google’s robots.txt file ([www.google.com/robots.txt][3]) - 6. Make a GET request to and set the header `User-Agent: elephant`. - 7. Make a DELETE request to - 8. Request and also get the response headers - 9. Make a POST request to with the JSON body `{"value": "panda"}` - 10. Make the same POST request as the previous exercise, but set the Content-Type header to `application/json` (because POST requests need to have a content type that matches their body). Look at the `json` field in the response to see the difference from the previous one. - 11. Make a GET request to and set the header `Accept-Encoding: gzip` (what happens? why?) - 12. Put a bunch of a JSON in a file and then make a POST request to with the JSON in that file as the body - 13. Make a request to and set the header ‘Accept: image/png’. Save the output to a PNG file and open the file in an image viewer. Try the same thing with with different `Accept:` headers. - 14. Make a PUT request to - 15. Request , save it to a file, and open that file in your image editor. - 16. Request . You’ll get an empty response. Get curl to show you the response headers too, and try to figure out why the response was empty. - 17. Make any request to and just set some nonsense headers (like `panda: elephant`) - 18. Request and . Request them again and get curl to show the response headers. - 19. Request and set a username and password (with `-u username:password`) - 20. Download the Twitter homepage () in Spanish by setting the `Accept-Language: es-ES` header. - 21. Make a request to the Stripe API with curl. (see for how, they give you a test API key). Try making exactly the same request to . - - - --------------------------------------------------------------------------------- - -via: https://jvns.ca/blog/2019/08/27/curl-exercises/ - -作者:[Julia Evans][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://jvns.ca/ -[b]: https://github.com/lujun9972 -[1]: https://www.amazon.com/Badass-Making-Awesome-Kathy-Sierra/dp/1491919019 -[2]: https://wizardzines.com/zines/bite-size-networking -[3]: http://www.google.com/robots.txt diff --git a/sources/tech/20190927 5 tips for GNU Debugger.md b/sources/tech/20190927 5 tips for GNU Debugger.md deleted file mode 100644 index faedf4240d..0000000000 --- a/sources/tech/20190927 5 tips for GNU Debugger.md +++ /dev/null @@ -1,230 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (5 tips for GNU Debugger) -[#]: via: (https://opensource.com/article/19/9/tips-gnu-debugger) -[#]: author: (Tim Waugh https://opensource.com/users/twaugh) - -5 tips for GNU Debugger -====== -Learn how to use some of the lesser-known features of gdb to inspect and -fix your code. -![Bug tracking magnifying glass on computer screen][1] - -The [GNU Debugger][2] (gdb) is an invaluable tool for inspecting running processes and fixing problems while you're developing programs. - -You can set breakpoints at specific locations (by function name, line number, and so on), enable and disable those breakpoints, display and alter variable values, and do all the standard things you would expect any debugger to do. But it has many other features you might not have experimented with. Here are five for you to try. - -### Conditional breakpoints - -Setting a breakpoint is one of the first things you'll learn to do with the GNU Debugger. The program stops when it reaches a breakpoint, and you can run gdb commands to inspect it or change variables before allowing the program to continue. - -For example, you might know that an often-called function crashes sometimes, but only when it gets a certain parameter value. You could set a breakpoint at the start of that function and run the program. The function parameters are shown each time it hits the breakpoint, and if the parameter value that triggers the crash is not supplied, you can continue until the function is called again. When the troublesome parameter triggers a crash, you can step through the code to see what's wrong. - - -``` -(gdb) break sometimes_crashes -Breakpoint 1 at 0x40110e: file prog.c, line 5. -(gdb) run -[...] -Breakpoint 1, sometimes_crashes (f=0x7fffffffd1bc) at prog.c:5 -5      fprintf(stderr, -(gdb) continue -Breakpoint 1, sometimes_crashes (f=0x7fffffffd1bc) at prog.c:5 -5      fprintf(stderr, -(gdb) continue -``` - -To make this more repeatable, you could count how many times the function is called before the specific call you are interested in, and set a counter on that breakpoint (for example, "continue 30" to make it ignore the next 29 times it reaches the breakpoint). - -But where breakpoints get really powerful is in their ability to evaluate expressions at runtime, which allows you to automate this kind of testing. Enter: conditional breakpoints. - - -``` -break [LOCATION] if CONDITION - -(gdb) break sometimes_crashes if !f -Breakpoint 1 at 0x401132: file prog.c, line 5. -(gdb) run -[...] -Breakpoint 1, sometimes_crashes (f=0x0) at prog.c:5 -5      fprintf(stderr, -(gdb) -``` - -Instead of having gdb ask what to do every time the function is called, a conditional breakpoint allows you to make gdb stop at that location only when a particular expression evaluates as true. If the execution reaches the conditional breakpoint location, but the expression evaluates as false, the - -debugger automatically lets the program continue without asking the user what to do. - -### Breakpoint commands - -An even more sophisticated feature of breakpoints in the GNU Debugger is the ability to script a response to reaching a breakpoint. Breakpoint commands allow you to write a list of GNU Debugger commands to run whenever it reaches a breakpoint. - -We can use this to work around the bug we already know about in the **sometimes_crashes** function and make it return from that function harmlessly when it provides a null pointer. - -We can use **silent** as the first line to get more control over the output. Without this, the stack frame will be displayed each time the breakpoint is hit, even before our breakpoint commands run. - - -``` -(gdb) break sometimes_crashes -Breakpoint 1 at 0x401132: file prog.c, line 5. -(gdb) commands 1 -Type commands for breakpoint(s) 1, one per line. -End with a line saying just "end". ->silent ->if !f - >frame - >printf "Skipping call\n" - >return 0 - >continue - >end ->printf "Continuing\n" ->continue ->end -(gdb) run -Starting program: /home/twaugh/Documents/GDB/prog -warning: Loadable section ".note.gnu.property" outside of ELF segments -Continuing -Continuing -Continuing -#0  sometimes_crashes (f=0x0) at prog.c:5 -5      fprintf(stderr, -Skipping call -[Inferior 1 (process 9373) exited normally] -(gdb) -``` - -### Dump binary memory - -GNU Debugger has built-in support for examining memory using the **x** command in various formats, including octal, hexadecimal, and so on. But I like to see two formats side by side: hexadecimal bytes on the left, and ASCII characters represented by those same bytes on the right. - -When I want to view the contents of a file byte-by-byte, I often use **hexdump -C** (hexdump comes from the [util-linux][3] package). Here is gdb's **x** command displaying hexadecimal bytes: - - -``` -(gdb) x/33xb mydata -0x404040 <mydata>:    0x02    0x01    0x00    0x02    0x00    0x00    0x00    0x01 -0x404048 <mydata+8>:    0x01    0x47    0x00    0x12    0x61    0x74    0x74    0x72 -0x404050 <mydata+16>:    0x69    0x62    0x75    0x74    0x65    0x73    0x2d    0x63 -0x404058 <mydata+24>:    0x68    0x61    0x72    0x73    0x65    0x75    0x00    0x05 -0x404060 <mydata+32>:    0x00 -``` - -What if you could teach gdb to display memory just like hexdump does? You can, and in fact, you can use this method for any format you prefer. - -By combining the **dump** command to store the bytes in a file, the **shell** command to run hexdump on the file, and the **define** command, we can make our own new **hexdump** command to use hexdump to display the contents of memory. - - -``` -(gdb) define hexdump -Type commands for definition of "hexdump". -End with a line saying just "end". ->dump binary memory /tmp/dump.bin $arg0 $arg0+$arg1 ->shell hexdump -C /tmp/dump.bin ->end -``` - -Those commands can even go in the **~/.gdbinit** file to define the hexdump command permanently. Here it is in action: - - -``` -(gdb) hexdump mydata sizeof(mydata) -00000000  02 01 00 02 00 00 00 01  01 47 00 12 61 74 74 72  |.........G..attr| -00000010  69 62 75 74 65 73 2d 63  68 61 72 73 65 75 00 05  |ibutes-charseu..| -00000020  00                                                |.| -00000021 -``` - -### Inline disassembly - -Sometimes you want to understand more about what happened leading up to a crash, and the source code is not enough. You want to see what's going on at the CPU instruction level. - -The **disassemble** command lets you see the CPU instructions that implement a function. But sometimes the output can be hard to follow. Usually, I want to see what instructions correspond to a certain section of source code in the function. To achieve this, use the **/s** modifier to include source code lines with the disassembly. - - -``` -(gdb) disassemble/s main -Dump of assembler code for function main: -prog.c: -11    { -   0x0000000000401158 <+0>:    push   %rbp -   0x0000000000401159 <+1>:    mov      %rsp,%rbp -   0x000000000040115c <+4>:    sub      $0x10,%rsp - -12      int n = 0; -   0x0000000000401160 <+8>:    movl   $0x0,-0x4(%rbp) - -13      sometimes_crashes(&n); -   0x0000000000401167 <+15>:    lea     -0x4(%rbp),%rax -   0x000000000040116b <+19>:    mov     %rax,%rdi -   0x000000000040116e <+22>:    callq  0x401126 <sometimes_crashes> -[...snipped...] -``` - -This, along with **info registers** to see the current values of all the CPU registers and commands like **stepi** to step one instruction at a time, allow you to have a much more detailed understanding of the program. - -### Reverse debug - -Sometimes you wish you could turn back time. Imagine you've hit a watchpoint on a variable. A watchpoint is like a breakpoint, but instead of being set at a location in the program, it is set on an expression (using the **watch** command). Whenever the value of the expression changes, execution stops, and the debugger takes control. - -So imagine you've hit this watchpoint, and the memory used by a variable has changed value. This can turn out to be caused by something that occurred much earlier; for example, the memory was freed and is now being re-used. But when and why was it freed? - -The GNU Debugger can solve even this problem because you can run your program in reverse! - -It achieves this by carefully recording the state of the program at each step so that it can restore previously recorded states, giving the illusion of time flowing backward. - -To enable this state recording, use the **target record-full** command. Then you can use impossible-sounding commands, such as: - - * **reverse-step**, which rewinds to the previous source line - * **reverse-next**, which rewinds to the previous source line, stepping backward over function calls - * **reverse-finish**, which rewinds to the point when the current function was about to be called - * **reverse-continue**, which rewinds to the previous state in the program that would (now) trigger a breakpoint (or anything else that causes it to stop) - - - -Here is an example of reverse debugging in action: - - -``` -(gdb) b main -Breakpoint 1 at 0x401160: file prog.c, line 12. -(gdb) r -Starting program: /home/twaugh/Documents/GDB/prog -[...] - -Breakpoint 1, main () at prog.c:12 -12      int n = 0; -(gdb) target record-full -(gdb) c -Continuing. - -Program received signal SIGSEGV, Segmentation fault. -0x0000000000401154 in sometimes_crashes (f=0x0) at prog.c:7 -7      return *f; -(gdb) reverse-finish -Run back to call of #0  0x0000000000401154 in sometimes_crashes (f=0x0) -        at prog.c:7 -0x0000000000401190 in main () at prog.c:16 -16      sometimes_crashes(0); -``` - -These are just a handful of useful things the GNU Debugger can do. There are many more to discover. Which hidden, little-known, or just plain amazing feature of gdb is your favorite? Please share it in the comments. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/9/tips-gnu-debugger - -作者:[Tim Waugh][a] -选题:[lujun9972][b] -译者:[译者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/twaugh -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bug_software_issue_tracking_computer_screen.jpg?itok=6qfIHR5y (Bug tracking magnifying glass on computer screen) -[2]: https://www.gnu.org/software/gdb/ -[3]: https://en.wikipedia.org/wiki/Util-linux diff --git a/sources/tech/20191007 7 Java tips for new developers.md b/sources/tech/20191007 7 Java tips for new developers.md deleted file mode 100644 index 8ad9a70f8a..0000000000 --- a/sources/tech/20191007 7 Java tips for new developers.md +++ /dev/null @@ -1,222 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (robsean) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (7 Java tips for new developers) -[#]: via: (https://opensource.com/article/19/10/java-basics) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) - -7 Java tips for new developers -====== -If you're just getting started with Java programming, here are seven -basics you need to know. -![Coffee and laptop][1] - -Java is a versatile programming language used, in some way, in nearly every industry that touches a computer. Java's greatest power is that it runs in a Java Virtual Machine (JVM), a layer that translates Java code into bytecode compatible with your operating system. As long as a JVM exists for your operating system, whether that OS is on a server (or [serverless][2], for that matter), desktop, laptop, mobile device, or embedded device, then a Java application can run on it. - -This makes Java a popular language for both programmers and users. Programmers know that they only have to write one version of their software to end up with an application that runs on any platform, and users know that an application will run on their computer regardless of what operating system they use. - -Many languages and frameworks are cross-platform, but none deliver the same level of abstraction. With Java, you target the JVM, not the OS. For programmers, that's the path of least resistance when faced with several programming challenges, but it's only useful if you know how to program Java. If you're just getting started with Java programming, here are seven basic tips you need to know. - -But first, if you're not sure whether you have Java installed, you can find out in a terminal (such as [Bash][3] or [PowerShell][4]) by running: - - -``` -$ java --version -openjdk 12.0.2 2019-07-16 -OpenJDK Runtime Environment 19.3 (build 12.0.2+9) -OpenJDK 64-Bit Server VM 19.3 (build 12.0.2+9, mixed mode, sharing) -``` - -If you get an error or nothing in return, then you should install the [Java Development Kit][5] (JDK) to get started with Java development. Or install a Java Runtime Environment ****(JRE) if you just need to run Java applications. - -### 1\. Java packages - -In Java, related classes are grouped into a _package_. The basic Java libraries you get when you download the JDK are grouped into packages starting with **java** or **javax**. Packages serve a similar function as folders on your computer: they provide structure and definition for related elements (in programming terminology, a _namespace_). Additional packages can be obtained from independent coders, open source projects, and commercial vendors, just as libraries can be obtained for any programming language. - -When you write a Java program, you should declare a package name at the top of your code. If you're just writing a simple application to get started with Java, your package name can be as simple as the name of your project. If you're using a Java integrated development environment (IDE), like [Eclipse][6], it generates a sane package name for you when you start a new project. - - -``` -package helloworld; - -/** - * @author seth - * An application written in Java. - */ -``` - -Otherwise, you can determine the name of your package by looking at its path in relation to the broad definition of your project. For instance, if you're writing a set of classes to assist in game development and the collection is called **jgamer**, then you might have several unique classes within it. - - -``` -package jgamer.avatar; - -/** - * @author seth - * An imaginary game library. - */ -``` - -The top level of your package is **jgamer**, and each package inside it is a descendant, such as **jgamer.avatar** and **jgamer.score** and so on. In your filesystem, the structure reflects this, with **jgamer** being the top directory containing the files **avatar.java** and **score.java**. - -### 2\. Java imports - -The most fun you'll ever have as a polyglot programmer is trying to keep track of whether you **include**, **import**, **use**, **require**, or **some other term** a library in whatever programming language you're writing in. Java, for the record, uses the **import** keyword when importing libraries needed for your code. - - -``` -package helloworld; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; - -/** - * @author seth - * A GUI hello world. - */ -``` - -Imports work based on an environment's Java path. If Java doesn't know where Java libraries are stored on a system, then an import cannot be successful. As long as a library is stored in a system's Java path, then an import can succeed, and a library can be used to build and run a Java application. - -If a library is not expected to be in the Java path (because, for instance, you are writing the library yourself), then the library can be bundled with your application (license permitting) so that the import works as expected. - -### 3\. Java classes - -A Java class is declared with the keywords **public class** along with a unique class name mirroring its file name. For example, in a file **Hello.java** in project **helloworld**: - - -``` -package helloworld; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; - -/** - * @author seth - * A GUI hello world. - */ - -public class Hello { -        // this is an empty class -} -``` - -You can declare variables and functions inside a class. In Java, variables within a class are called _fields_. - -### 4\. Java methods - -Java methods are, essentially, functions within an object. They are defined as being **public** (meaning they can be accessed by any other class) or **private** (limiting their use) based on the expected type of returned data, such as **void**, **int**, **float**, and so on. - - -``` -    public void helloPrompt([ActionEvent][7] event) { -        [String][8] salutation = "Hello %s"; -  -        string helloMessage = "World"; -        message = [String][8].format(salutation, helloMessage); -        [JOptionPane][9].showMessageDialog(this, message); -    } -  -    private int someNumber (x) { -        return x*2; -    } -``` - -When calling a method directly, it is referenced by its class and method name. For instance, **Hello.someNumber** refers to the **someNumber** method in the **Hello** class. - -### 5\. Static - -The **static** keyword in Java makes a member in your code accessible independently of the object that contains it. - -In object-oriented programming, you write code that serves as a template for "objects" that get spawned as the application runs. You don't code a specific window, for instance, but an _instance_ of a window based upon a window class in Java (and modified by your code). Since nothing you are coding "exists" until the application generates an instance of it, most methods and variables (and even nested classes) cannot be used until the object they depend upon has been created. - -However, sometimes you need to access or use data in an object before it is created by the application (for example, an application can't generate a red ball without first knowing that the ball is meant to be red). For those cases, there's the **static** keyword. - -### 6\. Try and catch - -Java is excellent at catching errors, but it can only recover gracefully if you tell it what to do. The cascading hierarchy of attempting to perform an action in Java starts with **try**, falls back to **catch**, and ends with **finally**. Should the **try** clause fail, then **catch** is invoked, and in the end, there's always **finally** to perform some sensible action regardless of the results. Here's an example: - - -``` -try { -        cmd = parser.parse(opt, args);  -        -        if(cmd.hasOption("help")) { -                HelpFormatter helper = new HelpFormatter(); -                helper.printHelp("Hello <options>", opt); -                [System][10].exit(0); -                } -        else { -                if(cmd.hasOption("shell") || cmd.hasOption("s")) { -                [String][8] target = cmd.getOptionValue("tgt"); -                } // else -        } // fi -} catch ([ParseException][11] err) { -        [System][10].out.println(err); -        [System][10].exit(1); -        } //catch -        finally { -                new Hello().helloWorld(opt); -        } //finally -} //try -``` - -It's a robust system that attempts to avoid irrecoverable errors or, at least, to provide you with the option to give useful feedback to the user. Use it often, and your users will thank you! - -### 7\. Running a Java application - -Java files, usually ending in **.java**, theoretically can be run with the **java** command. If an application is complex, however, whether running a single file results in anything meaningful is another question. - -To run a **.java** file directly: - - -``` -`$ java ./Hello.java` -``` - -Usually, Java applications are distributed as Java Archives (JAR) files, ending in **.jar**. A JAR file contains a manifest file specifying the main class, some metadata about the project structure, and all the parts of your code required to run the application. - -To run a JAR file, you may be able to double-click its icon (depending on how you have your OS set up), or you can launch it from a terminal: - - -``` -`$ java -jar ./Hello.jar` -``` - -### Java for everyone - -Java is a powerful language, and thanks to the [OpenJDK][12] project and other initiatives, it's an open specification that allows projects like [IcedTea][13], [Dalvik][14], and [Kotlin][15] to thrive. Learning Java is a great way to prepare to work in a wide variety of industries, and what's more, there are plenty of [great reasons to use it][16]. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/java-basics - -作者:[Seth Kenlon][a] -选题:[lujun9972][b] -译者:[译者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/seth -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_cafe_brew_laptop_desktop.jpg?itok=G-n1o1-o (Coffee and laptop) -[2]: https://www.redhat.com/en/resources/building-microservices-eap-7-reference-architecture -[3]: https://www.gnu.org/software/bash/ -[4]: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-6 -[5]: http://openjdk.java.net/ -[6]: http://www.eclipse.org/ -[7]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+actionevent -[8]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string -[9]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+joptionpane -[10]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system -[11]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+parseexception -[12]: https://openjdk.java.net/ -[13]: https://icedtea.classpath.org/wiki/Main_Page -[14]: https://source.android.com/devices/tech/dalvik/ -[15]: https://kotlinlang.org/ -[16]: https://opensource.com/article/19/9/why-i-use-java diff --git a/sources/tech/20191007 Understanding Joins in Hadoop.md b/sources/tech/20191007 Understanding Joins in Hadoop.md index ea0025a9d2..4c34ed896c 100644 --- a/sources/tech/20191007 Understanding Joins in Hadoop.md +++ b/sources/tech/20191007 Understanding Joins in Hadoop.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: (heguangzhi) +[#]: translator: ( ) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20191017 How to type emoji on Linux.md b/sources/tech/20191017 How to type emoji on Linux.md index ff85c55938..f4396b8240 100644 --- a/sources/tech/20191017 How to type emoji on Linux.md +++ b/sources/tech/20191017 How to type emoji on Linux.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (HankChow) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20191017 Using multitail on Linux.md b/sources/tech/20191017 Using multitail on Linux.md deleted file mode 100644 index 3b6fc7ca78..0000000000 --- a/sources/tech/20191017 Using multitail on Linux.md +++ /dev/null @@ -1,132 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (wenwensnow) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Using multitail on Linux) -[#]: via: (https://www.networkworld.com/article/3445228/using-multitail-on-linux.html) -[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) - -Using multitail on Linux -====== - -[Glen Bowman][1] [(CC BY-SA 2.0)][2] - -The **multitail** command can be very helpful whenever you want to watch activity on a number of files at the same time – especially log files. It works like a multi-windowed **tail -f** command. That is, it displays the bottoms of files and new lines as they are being added. While easy to use in general, **multitail** does provide some command-line and interactive options that you should be aware of before you start to use it routinely. - -### Basic multitail-ing - -The simplest use of **multitail** is to list the names of the files that you wish to watch on the command line. This command splits the screen horizontally (i.e., top and bottom), displaying the bottom of each of the files along with updates. - -[[Get regularly scheduled insights by signing up for Network World newsletters.]][3] - -``` -$ multitail /var/log/syslog /var/log/dmesg -``` - -The display will be split like this: - -[][4] - -BrandPost Sponsored by HPE - -[Take the Intelligent Route with Consumption-Based Storage][4] - -Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. - -``` -+-----------------------+ -| | -| | -+-----------------------| -| | -| | -+-----------------------+ -``` - -The lines displayed from each of the files would be followed by a single line per file that includes the assigned file number (starting with 00), the file name, the file size, and the date and time the most recent content was added. Each of the files will be allotted half the space available regardless of its size or activity. For example: - -``` -content lines from my1.log -more content -more lines - -00] my1.log 59KB - 2019/10/14 12:12:09 -content lines from my2.log -more content -more lines - -01] my2.log 120KB - 2019/10/14 14:22:29 -``` - -Note that **multitail** will not complain if you ask it to display non-text files or files that you have no permission to view; you just won't see the contents. - -You can also use wild cards to specify the files that you want to watch: - -``` -$ multitail my*.log -``` - -One thing to keep in mind is that **multitail** is going to split the screen evenly. If you specify too many files, you will see only a few lines from each and you will only see the first seven or so of the requested files if you list too many unless you take extra steps to view the later files (see the scrolling option described below). The exact result depends on the how many lines are available in your terminal window. - -Press **q** to quit **multitail** and return to your normal screen view. - -### Dividing the screen - -**Multitail** will split your terminal window vertically (i.e., left and right) if you prefer. For this, use the **-s** option. If you specify three files, the right side of your screen will be divided horizontally as well. With four, you'll have four equal-sized windows. - -``` -+-----------+-----------+ +-----------+-----------+ +-----------+-----------+ -| | | | | | | | | -| | | | | | | | | -| | | | +-----------+ +-----------+-----------+ -| | | | | | | | | -| | | | | | | | | -+-----------+-----------+ +-----------+-----------+ +-----------+-----------+ - 2 files 3 files 4 files -``` - -Use **multitail -s 3 file1 file2 file3** if you want to split the screen into three columns. - -``` -+-------+-------+-------+ -| | | | -| | | | -| | | | -| | | | -| | | | -+-------+-------+-------+ - 3 files with -s 3 -``` - -### Scrolling - -You can scroll up and down through displayed files, but you need to press **b** to bring up a selection menu and then use the up and arrow buttons to select the file you wish to scroll through. Then press the **enter** key. You can then scroll through the lines in an enlarged area, again using the up and down arrows. Press **q** when you're done to go back to the normal view. - -### Getting Help - -Pressing **h** in **multitail** will open a help menu describing some of the basic operations, though the man page provides quite a bit more information and is worth perusing if you want to learn even more about using this tool. - -**Multitail** will not likely be installed on your system by default, but using **apt-get** or **yum** should get you to an easy install. The tool provides a lot of functionality, but with its character-based display, window borders will just be strings of **q**'s and **x**'s. It's a very handy when you need to keep an eye on file updates. - -Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3445228/using-multitail-on-linux.html - -作者:[Sandra Henry-Stocker][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ -[b]: https://github.com/lujun9972 -[1]: https://www.flickr.com/photos/glenbowman/7992498919/in/photolist-dbgDtv-gHfRRz-5uRM4v-gHgFnz-6sPqTZ-5uaP7H-USFPqD-pbtRUe-fiKiYn-nmgWL2-pQNepR-q68p8d-dDsUxw-dbgFKG-nmgE6m-DHyqM-nCKA4L-2d7uFqH-Kbqzk-8EwKg-8Vy72g-2X3NSN-78Bv84-buKWXF-aeM4ok-yhweWf-4vwpyX-9hu8nq-9zCoti-v5nzP5-23fL48r-24y6pGS-JhWDof-6zF75k-24y6nHS-9hr19c-Gueh6G-Guei7u-GuegFy-24y6oX5-26qu5iX-wKrnMW-Gueikf-24y6oYh-27y4wwA-x4z19F-x57yP4-24BY6gc-24y6nPo-QGwbkf -[2]: https://creativecommons.org/licenses/by-sa/2.0/legalcode -[3]: https://www.networkworld.com/newsletters/signup.html -[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) -[5]: https://www.facebook.com/NetworkWorld/ -[6]: https://www.linkedin.com/company/network-world diff --git a/sources/tech/20191018 How to use Protobuf for data interchange.md b/sources/tech/20191018 How to use Protobuf for data interchange.md deleted file mode 100644 index 4de9e2120a..0000000000 --- a/sources/tech/20191018 How to use Protobuf for data interchange.md +++ /dev/null @@ -1,516 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to use Protobuf for data interchange) -[#]: via: (https://opensource.com/article/19/10/protobuf-data-interchange) -[#]: author: (Marty Kalin https://opensource.com/users/mkalindepauledu) - -How to use Protobuf for data interchange -====== -Protobuf encoding increases efficiency when exchanging data between -applications written in different languages and running on different -platforms. -![metrics and data shown on a computer screen][1] - -Protocol buffers ([Protobufs][2]), like XML and JSON, allow applications, which may be written in different languages and running on different platforms, to exchange data. For example, a sending application written in Go could encode a Go-specific sales order in Protobuf, which a receiver written in Java then could decode to get a Java-specific representation of the received order. Here is a sketch of the architecture over a network connection: - - -``` -`Go sales order--->Pbuf-encode--->network--->Pbuf-decode--->Java sales order` -``` - -Protobuf encoding, in contrast to its XML and JSON counterparts, is binary rather than text, which can complicate debugging. However, as the code examples in this article confirm, the Protobuf encoding is significantly more efficient in size than either XML or JSON encoding. - -Protobuf is efficient in another way. At the implementation level, Protobuf and other encoding systems serialize and deserialize structured data. Serialization transforms a language-specific data structure into a bytestream, and deserialization is the inverse operation that transforms a bytestream back into a language-specific data structure. Serialization and deserialization may become the bottleneck in data interchange because these operations are CPU-intensive. Efficient serialization and deserialization is another Protobuf design goal. - -Recent encoding technologies, such as Protobuf and FlatBuffers, derive from the [DCE/RPC][3] (Distributed Computing Environment/Remote Procedure Call) initiative of the early 1990s. Like DCE/RPC, Protobuf contributes to both the [IDL][4] (interface definition language) and the encoding layer in data interchange. - -This article will look at these two layers then provide code examples in Go and Java to flesh out Protobuf details and show that Protobuf is easy to use. - -### Protobuf as an IDL and encoding layer - -DCE/RPC, like Protobuf, is designed to be language- and platform-neutral. The appropriate libraries and utilities allow any language and platform to play in the DCE/RPC arena. Furthermore, the DCE/RPC architecture is elegant. An IDL document is the contract between the remote procedure on the one side and callers on the other side. Protobuf, too, centers on an IDL document. - -An IDL document is text and, in DCE/RPC, uses basic C syntax along with syntactic extensions for metadata (square brackets) and a few new keywords such as **interface**. Here is an example: - - -``` -[uuid (2d6ead46-05e3-11ca-7dd1-426909beabcd), version(1.0)] -interface echo { -   const long int ECHO_SIZE = 512; -   void echo( -      [in]          handle_t h, -      [in, string]  idl_char from_client[ ], -      [out, string] idl_char from_service[ECHO_SIZE] -   ); -} -``` - -This IDL document declares a procedure named **echo**, which takes three arguments: the **[in]** arguments of type **handle_t** (implementation pointer) and **idl_char** (array of ASCII characters) are passed to the remote procedure, whereas the **[out]** argument (also a string) is passed back from the procedure. In this example, the **echo** procedure does not explicitly return a value (the **void** to the left of **echo**) but could do so. A return value, together with one or more **[out]** arguments, allows the remote procedure to return arbitrarily many values. The next section introduces a Protobuf IDL, which differs in syntax but likewise serves as a contract in data interchange. - -The IDL document, in both DCE/RPC and Protobuf, is the input to utilities that create the infrastructure code for exchanging data: - - -``` -`IDL document--->DCE/PRC or Protobuf utilities--->support code for data interchange` -``` - -As relatively straightforward text, the IDL is likewise human-readable documentation about the specifics of the data interchange—in particular, the number of data items exchanged and the data type of each item. - -Protobuf can used in a modern RPC system such as [gRPC][5]; but Protobuf on its own provides only the IDL layer and the encoding layer for messages passed from a sender to a receiver. Protobuf encoding, like the DCE/RPC original, is binary but more efficient. - -At present, XML and JSON encodings still dominate in data interchange through technologies such as web services, which make use of in-place infrastructure such as web servers, transport protocols (e.g., TCP, HTTP), and standard libraries and utilities for processing XML and JSON documents. Moreover, database systems of various flavors can store XML and JSON documents, and even legacy relational systems readily generate XML encodings of query results. Every general-purpose programming language now has libraries that support XML and JSON. What, then, recommends a return to a _binary_ encoding system such as Protobuf? - -Consider the negative decimal value **-128**. In the 2's complement binary representation, which dominates across systems and languages, this value can be stored in a single 8-bit byte: 10000000. The text encoding of this integer value in XML or JSON requires multiple bytes. For example, UTF-8 encoding requires four bytes for the string, literally **-128**, which is one byte per character (in hex, the values are 0x2d, 0x31, 0x32, and 0x38). XML and JSON also add markup characters, such as angle brackets and braces, to the mix. Details about Protobuf encoding are forthcoming, but the point of interest now is a general one: Text encodings tend to be significantly less compact than binary ones. - -### A code example in Go using Protobuf - -My code examples focus on Protobuf rather than RPC. Here is an overview of the first example: - - * The IDL file named _dataitem.proto_ defines a Protobuf **message** with six fields of different types: integer values with different ranges, floating-point values of a fixed size, and strings of two different lengths. - * The Protobuf compiler uses the IDL file to generate a Go-specific version (and, later, a Java-specific version) of the Protobuf **message** together with supporting functions. - * A Go app populates the native Go data structure with randomly generated values and then serializes the result to a local file. For comparison, XML and JSON encodings also are serialized to local files. - * As a test, the Go application reconstructs an instance of its native data structure by deserializing the contents of the Protobuf file. - * As a language-neutrality test, the Java application also deserializes the contents of the Protobuf file to get an instance of a native data structure. - - - -This IDL file and two Go and one Java source files are available as a ZIP file on [my website][6]. - -The all-important Protobuf IDL document is shown below. The document is stored in the file _dataitem.proto_, with the customary _.proto_ extension. - -#### Example 1. Protobuf IDL document - - -``` -syntax = "proto3"; - -package main; - -message DataItem { -  int64  oddA  = 1; -  int64  evenA = 2; -  int32  oddB  = 3; -  int32  evenB = 4; -  float  small = 5; -  float  big   = 6; -  string short = 7; -  string long  = 8; -} -``` - -The IDL uses the current proto3 rather than the earlier proto2 syntax. The package name (in this case, **main**) is optional but customary; it is used to avoid name conflicts. The structured **message** contains eight fields, each of which has a Protobuf data type (e.g., **int64**, **string**), a name (e.g., **oddA**, **short**), and a numeric tag (aka key) after the equals sign **=**. The tags, which are 1 through 8 in this example, are unique integer identifiers that determine the order in which the fields are serialized. - -Protobuf messages can be nested to arbitrary levels, and one message can be the field type in the other. Here's an example that uses the **DataItem** message as a field type: - - -``` -message DataItems { -  repeated DataItem item = 1; -} -``` - -A single **DataItems** message consists of repeated (none or more) **DataItem** messages. - -Protobuf also supports enumerated types for clarity: - - -``` -enum PartnershipStatus { -  reserved "FREE", "CONSTRAINED", "OTHER"; -} -``` - -The **reserved** qualifier ensures that the numeric values used to implement the three symbolic names cannot be reused. - -To generate a language-specific version of one or more declared Protobuf **message** structures, the IDL file containing these is passed to the _protoc_ compiler (available in the [Protobuf GitHub repository][7]). For the Go code, the supporting Protobuf library can be installed in the usual way (with **%** as the command-line prompt): - - -``` -`% go get github.com/golang/protobuf/proto` -``` - -The command to compile the Protobuf IDL file _dataitem.proto_ into Go source code is: - - -``` -`% protoc --go_out=. dataitem.proto` -``` - -The flag **\--go_out** directs the compiler to generate Go source code; there are similar flags for other languages. The result, in this case, is a file named _dataitem.pb.go_, which is small enough that the essentials can be copied into a Go application. Here are the essentials from the generated code: - - -``` -var _ = proto.Marshal - -type DataItem struct { -   OddA  int64   `protobuf:"varint,1,opt,name=oddA" json:"oddA,omitempty"` -   EvenA int64   `protobuf:"varint,2,opt,name=evenA" json:"evenA,omitempty"` -   OddB  int32   `protobuf:"varint,3,opt,name=oddB" json:"oddB,omitempty"` -   EvenB int32   `protobuf:"varint,4,opt,name=evenB" json:"evenB,omitempty"` -   Small float32 `protobuf:"fixed32,5,opt,name=small" json:"small,omitempty"` -   Big   float32 `protobuf:"fixed32,6,opt,name=big" json:"big,omitempty"` -   Short string  `protobuf:"bytes,7,opt,name=short" json:"short,omitempty"` -   Long  string  `protobuf:"bytes,8,opt,name=long" json:"long,omitempty"` -} - -func (m *DataItem) Reset()         { *m = DataItem{} } -func (m *DataItem) String() string { return proto.CompactTextString(m) } -func (*DataItem) ProtoMessage()    {} -func init() {} -``` - -The compiler-generated code has a Go structure **DataItem**, which exports the Go fields—the names are now capitalized—that match the names declared in the Protobuf IDL. The structure fields have standard Go data types: **int32**, **int64**, **float32**, and **string**. At the end of each field line, as a string, is metadata that describes the Protobuf types, gives the numeric tags from the Protobuf IDL document, and provides information about JSON, which is discussed later. - -There are also functions; the most important is **proto.Marshal** for serializing an instance of the **DataItem** structure into Protobuf format. The helper functions include **Reset**, which clears a **DataItem** structure, and **String**, which produces a one-line string representation of a **DataItem**. - -The metadata that describes Protobuf encoding deserves a closer look before analyzing the Go program in more detail. - -### Protobuf encoding - -A Protobuf message is structured as a collection of key/value pairs, with the numeric tag as the key and the corresponding field as the value. The field names, such as **oddA** and **small**, are for human readability, but the _protoc_ compiler does use the field names in generating language-specific counterparts. For example, the **oddA** and **small** names in the Protobuf IDL become the fields **OddA** and **Small**, respectively, in the Go structure. - -The keys and their values both get encoded, but with an important difference: some numeric values have a fixed-size encoding of 32 or 64 bits, whereas others (including the **message** tags) are _varint_ encoded—the number of bits depends on the integer's absolute value. For example, the integer values 1 through 15 require 8 bits to encode in _varint_, whereas the values 16 through 2047 require 16 bits. The _varint_ encoding, similar in spirit (but not in detail) to UTF-8 encoding, favors small integer values over large ones. (For a detailed analysis, see the Protobuf [encoding guide][8].) The upshot is that a Protobuf **message** should have small integer values in fields, if possible, and as few keys as possible, but one key per field is unavoidable. - -Table 1 below gives the gist of Protobuf encoding: - -**Table 1. Protobuf data types** - -Encoding | Sample types | Length ----|---|--- -varint | int32, uint32, int64 | Variable length -fixed | fixed32, float, double | Fixed 32-bit or 64-bit length -byte sequence | string, bytes | Sequence length - -Integer types that are not explicitly **fixed** are _varint_ encoded; hence, in a _varint_ type such as **uint32** (**u** for unsigned), the number 32 describes the integer's range (in this case, 0 to 232 \- 1) rather than its bit size, which differs depending on the value. For fixed types such as **fixed32** or **double**, by contrast, the Protobuf encoding requires 32 and 64 bits, respectively. Strings in Protobuf are byte sequences; hence, the size of the field encoding is the length of the byte sequence. - -Another efficiency deserves mention. Recall the earlier example in which a **DataItems** message consists of repeated **DataItem** instances: - - -``` -message DataItems { -  repeated DataItem item = 1; -} -``` - -The **repeated** means that the **DataItem** instances are _packed_: the collection has a single tag, in this case, 1. A **DataItems** message with repeated **DataItem** instances is thus more efficient than a message with multiple but separate **DataItem** fields, each of which would require a tag of its own. - -With this background in mind, let's return to the Go program. - -### The dataItem program in detail - -The _dataItem_ program creates a **DataItem** instance and populates the fields with randomly generated values of the appropriate types. Go has a **rand** package with functions for generating pseudo-random integer and floating-point values, and my **randString** function generates pseudo-random strings of specified lengths from a character set. The design goal is to have a **DataItem** instance with field values of different types and bit sizes. For example, the **OddA** and **EvenA** values are 64-bit non-negative integer values of odd and even parity, respectively; but the **OddB** and **EvenB** variants are 32 bits in size and hold small integer values between 0 and 2047. The random floating-point values are 32 bits in size, and the strings are 16 (**Short**) and 32 (**Long**) characters in length. Here is the code segment that populates the **DataItem** structure with random values: - - -``` -// variable-length integers -n1 := rand.Int63()        // bigger integer -if (n1 & 1) == 0 { n1++ } // ensure it's odd -... -n3 := rand.Int31() % UpperBound // smaller integer -if (n3 & 1) == 0 { n3++ }       // ensure it's odd - -// fixed-length floats -... -t1 := rand.Float32() -t2 := rand.Float32() -... -// strings -str1 := randString(StrShort) -str2 := randString(StrLong) - -// the message -dataItem := &DataItem { -   OddA:  n1, -   EvenA: n2, -   OddB:  n3, -   EvenB: n4, -   Big:   f1, -   Small: f2, -   Short: str1, -   Long:  str2, -} -``` - -Once created and populated with values, the **DataItem** instance is encoded in XML, JSON, and Protobuf, with each encoding written to a local file: - - -``` -func encodeAndserialize(dataItem *DataItem) { -   bytes, _ := xml.MarshalIndent(dataItem, "", " ")  // Xml to dataitem.xml -   ioutil.WriteFile(XmlFile, bytes, 0644)            // 0644 is file access permissions - -   bytes, _ = json.MarshalIndent(dataItem, "", " ")  // Json to dataitem.json -   ioutil.WriteFile(JsonFile, bytes, 0644) - -   bytes, _ = proto.Marshal(dataItem)                // Protobuf to dataitem.pbuf -   ioutil.WriteFile(PbufFile, bytes, 0644) -} -``` - -The three serializing functions use the term _marshal_, which is roughly synonymous with _serialize_. As the code indicates, each of the three **Marshal** functions returns an array of bytes, which then are written to a file. (Possible errors are ignored for simplicity.) On a sample run, the file sizes were: - - -``` -dataitem.xml:  262 bytes -dataitem.json: 212 bytes -dataitem.pbuf:  88 bytes -``` - -The Protobuf encoding is significantly smaller than the other two. The XML and JSON serializations could be reduced slightly in size by eliminating indentation characters, in this case, blanks and newlines. - -Below is the _dataitem.json_ file resulting eventually from the **json.MarshalIndent** call, with added comments starting with **##**: - - -``` -{ - "oddA":  4744002665212642479,                ## 64-bit >= 0 - "evenA": 2395006495604861128,                ## ditto - "oddB":  57,                                 ## 32-bit >= 0 but < 2048 - "evenB": 468,                                ## ditto - "small": 0.7562016,                          ## 32-bit floating-point - "big":   0.85202795,                         ## ditto - "short": "ClH1oDaTtoX$HBN5",                 ## 16 random chars - "long":  "xId0rD3Cri%3Wt%^QjcFLJgyXBu9^DZI"  ## 32 random chars -} -``` - -Although the serialized data goes into local files, the same approach would be used to write the data to the output stream of a network connection. - -### Testing serialization/deserialization - -The Go program next runs an elementary test by deserializing the bytes, which were written earlier to the _dataitem.pbuf_ file, into a **DataItem** instance. Here is the code segment, with the error-checking parts removed: - - -``` -filebytes, err := ioutil.ReadFile(PbufFile) // get the bytes from the file -... -testItem.Reset()                            // clear the DataItem structure -err = proto.Unmarshal(filebytes, testItem)  // deserialize into a DataItem instance -``` - -The **proto.Unmarshal** function for deserializing Protbuf is the inverse of the **proto.Marshal** function. The original **DataItem** and the deserialized clone are printed to confirm an exact match: - - -``` -Original: -2041519981506242154 3041486079683013705 1192 1879 -0.572123 0.326855 -boPb#T0O8Xd&Ps5EnSZqDg4Qztvo7IIs 9vH66AiGSQgCDxk& - -Deserialized: -2041519981506242154 3041486079683013705 1192 1879 -0.572123 0.326855 -boPb#T0O8Xd&Ps5EnSZqDg4Qztvo7IIs 9vH66AiGSQgCDxk& -``` - -### A Protobuf client in Java - -The example in Java is to confirm Protobuf's language neutrality. The original IDL file could be used to generate the Java support code, which involves nested classes. To suppress warnings, however, a slight addition can be made. Here is the revision, which specifies a **DataMsg** as the name for the outer class, with the inner class automatically named **DataItem** after the Protobuf message: - - -``` -syntax = "proto3"; - -package main; - -option java_outer_classname = "DataMsg"; - -message DataItem { -... -``` - -With this change in place, the _protoc_ compilation is the same as before, except the desired output is now Java rather than Go: - - -``` -`% protoc --java_out=. dataitem.proto` -``` - -The resulting source file (in a subdirectory named _main_) is _DataMsg.java_ and about 1,120 lines in length: Java is not terse. Compiling and then running the Java code requires a JAR file with the library support for Protobuf. This file is available in the [Maven repository][9]. - -With the pieces in place, my test code is relatively short (and available in the ZIP file as _Main.java_): - - -``` -package main; -import java.io.FileInputStream; - -public class Main { -   public static void main(String[] args) { -      String path = "dataitem.pbuf";  // from the Go program's serialization -      try { -         DataMsg.DataItem deserial = -           DataMsg.DataItem.newBuilder().mergeFrom(new FileInputStream(path)).build(); - -         System.out.println(deserial.getOddA()); // 64-bit odd -         System.out.println(deserial.getLong()); // 32-character string -      } -      catch(Exception e) { System.err.println(e); } -    } -} -``` - -Production-grade testing would be far more thorough, of course, but even this preliminary test confirms the language-neutrality of Protobuf: the _dataitem.pbuf_ file results from the Go program's serialization of a Go **DataItem**, and the bytes in this file are deserialized to produce a **DataItem** instance in Java. The output from the Java test is the same as that from the Go test. - -### Wrapping up with the numPairs program - -Let's end with an example that highlights Protobuf efficiency but also underscores the cost involved in any encoding technology. Consider this Protobuf IDL file: - - -``` -syntax = "proto3"; -package main; - -message NumPairs { -  repeated NumPair pair = 1; -} - -message NumPair { -  int32 odd = 1; -  int32 even = 2; -} -``` - -A **NumPair** message consists of two **int32** values together with an integer tag for each field. A **NumPairs** message is a sequence of embedded **NumPair** messages. - -The _numPairs_ program in Go (below) creates 2 million **NumPair** instances, with each appended to the **NumPairs** message. This message can be serialized and deserialized in the usual way. - -#### Example 2. The numPairs program - - -``` -package main - -import ( -   "math/rand" -   "time" -   "encoding/xml" -   "encoding/json" -   "io/ioutil" -   "github.com/golang/protobuf/proto" -) - -// protoc-generated code: start -var _ = proto.Marshal -type NumPairs struct { -   Pair []*NumPair `protobuf:"bytes,1,rep,name=pair" json:"pair,omitempty"` -} - -func (m *NumPairs) Reset()         { *m = NumPairs{} } -func (m *NumPairs) String() string { return proto.CompactTextString(m) } -func (*NumPairs) ProtoMessage()    {} -func (m *NumPairs) GetPair() []*NumPair { -   if m != nil { return m.Pair } -   return nil -} - -type NumPair struct { -   Odd  int32 `protobuf:"varint,1,opt,name=odd" json:"odd,omitempty"` -   Even int32 `protobuf:"varint,2,opt,name=even" json:"even,omitempty"` -} - -func (m *NumPair) Reset()         { *m = NumPair{} } -func (m *NumPair) String() string { return proto.CompactTextString(m) } -func (*NumPair) ProtoMessage()    {} -func init() {} -// protoc-generated code: finish - -var numPairsStruct NumPairs -var numPairs = &numPairsStruct - -func encodeAndserialize() { -   // XML encoding -   filename := "./pairs.xml" -   bytes, _ := xml.MarshalIndent(numPairs, "", " ") -   ioutil.WriteFile(filename, bytes, 0644) - -   // JSON encoding -   filename = "./pairs.json" -   bytes, _ = json.MarshalIndent(numPairs, "", " ") -   ioutil.WriteFile(filename, bytes, 0644) - -   // ProtoBuf encoding -   filename = "./pairs.pbuf" -   bytes, _ = proto.Marshal(numPairs) -   ioutil.WriteFile(filename, bytes, 0644) -} - -const HowMany = 200 * 100  * 100 // two million - -func main() { -   rand.Seed(time.Now().UnixNano()) - -   // uncomment the modulus operations to get the more efficient version -   for i := 0; i < HowMany; i++ { -      n1 := rand.Int31() // % 2047 -      if (n1 & 1) == 0 { n1++ } // ensure it's odd -      n2 := rand.Int31() // % 2047 -      if (n2 & 1) == 1 { n2++ } // ensure it's even - -      next := &NumPair { -                 Odd:  n1, -                 Even: n2, -              } -      numPairs.Pair = append(numPairs.Pair, next) -   } -   encodeAndserialize() -} -``` - -The randomly generated odd and even values in each **NumPair** range from zero to 2 billion and change. In terms of raw rather than encoded data, the integers generated in the Go program add up to 16MB: two integers per **NumPair** for a total of 4 million integers in all, and each value is four bytes in size. - -For comparison, the table below has entries for the XML, JSON, and Protobuf encodings of the 2 million **NumPair** instances in the sample **NumsPairs** message. The raw data is included, as well. Because the _numPairs_ program generates random values, output differs across sample runs but is close to the sizes shown in the table. - -**Table 2. Encoding overhead for 16MB of integers** - -Encoding | File | Byte size | Pbuf/other ratio ----|---|---|--- -None | pairs.raw | 16MB | 169% -Protobuf | pairs.pbuf | 27MB | — -JSON | pairs.json | 100MB | 27% -XML | pairs.xml | 126MB | 21% - -As expected, Protobuf shines next to XML and JSON. The Protobuf encoding is about a quarter of the JSON one and about a fifth of the XML one. But the raw data make clear that Protobuf incurs the overhead of encoding: the serialized Protobuf message is 11MB larger than the raw data. Any encoding, including Protobuf, involves structuring the data, which unavoidably adds bytes. - -Each of the serialized 2 million **NumPair** instances involves _four_ integer values: one apiece for the **Even** and **Odd** fields in the Go structure, and one tag per each field in the Protobuf encoding. As raw rather than encoded data, this would come to 16 bytes per instance, and there are 2 million instances in the sample **NumPairs** message. But the Protobuf tags, like the **int32** values in the **NumPair** fields, use _varint_ encoding and, therefore, vary in byte length; in particular, small integer values (which include the tags, in this case) require fewer than four bytes to encode. - -If the _numPairs_ program is revised so that the two **NumPair** fields hold values less than 2048, which have encodings of either one or two bytes, then the Protobuf encoding drops from 27MB to 16MB—the very size of the raw data. The table below summarizes the new encoding sizes from a sample run. - -**Table 3. Encoding with 16MB of integers < 2048** - -Encoding | File | Byte size | Pbuf/other ratio ----|---|---|--- -None | pairs.raw | 16MB | 100% -Protobuf | pairs.pbuf | 16MB | — -JSON | pairs.json | 77MB | 21% -XML | pairs.xml | 103MB | 15% - -In summary, the modified _numPairs_ program, with field values less than 2048, reduces the four-byte size for each integer value in the raw data. But the Protobuf encoding still requires tags, which add bytes to the Protobuf message. Protobuf encoding does have a cost in message size, but this cost can be reduced by the _varint_ factor if relatively small integer values, whether in fields or keys, are being encoded. - -For moderately sized messages consisting of structured data with mixed types—and relatively small integer values—Protobuf has a clear advantage over options such as XML and JSON. In other cases, the data may not be suited for Protobuf encoding. For example, if two applications need to share a huge set of text records or large integer values, then compression rather than encoding technology may be the way to go. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/protobuf-data-interchange - -作者:[Marty Kalin][a] -选题:[lujun9972][b] -译者:[译者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/mkalindepauledu -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_data_dashboard_system_computer_analytics.png?itok=oxAeIEI- (metrics and data shown on a computer screen) -[2]: https://developers.google.com/protocol-buffers/ -[3]: https://en.wikipedia.org/wiki/DCE/RPC -[4]: https://en.wikipedia.org/wiki/Interface_description_language -[5]: https://grpc.io/ -[6]: http://condor.depaul.edu/mkalin -[7]: https://github.com/protocolbuffers/protobuf -[8]: https://developers.google.com/protocol-buffers/docs/encoding -[9]: https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java diff --git a/sources/tech/20191020 14 SCP Command Examples to Securely Transfer Files in Linux.md b/sources/tech/20191020 14 SCP Command Examples to Securely Transfer Files in Linux.md deleted file mode 100644 index e34b1d825c..0000000000 --- a/sources/tech/20191020 14 SCP Command Examples to Securely Transfer Files in Linux.md +++ /dev/null @@ -1,241 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (14 SCP Command Examples to Securely Transfer Files in Linux) -[#]: via: (https://www.linuxtechi.com/scp-command-examples-in-linux/) -[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) - -14 SCP Command Examples to Securely Transfer Files in Linux -====== - -**SCP** (Secure Copy) is command line tool in Linux and Unix like systems which is used to transfer files and directories across the systems securely over the network. When we use scp command to copy files and directories from our local system to remote system then in the backend it makes **ssh connection** to remote system. In other words, we can say scp uses the same **SSH security mechanism** in the backend, it needs either password or keys for authentication. - -[![scp-command-examples-linux][1]][2] - -In this tutorial we will discuss 14 useful Linux scp command examples. - -**Syntax of scp command:** - -### scp <options> <files_or_directories> [root@linuxtechi][3]_host:/<folder> - -### scp <options> [root@linuxtechi][3]_host:/files   <folder_local_system> - -First syntax of scp command demonstrate how to copy files or directories from local system to target host under the specific folder. - -Second syntax of scp command demonstrate how files from target host is copied into local system. - -Some of the most widely used options in scp command are listed below, - - *  -C         Enable Compression - *  -i           identity File or private key - *  -l           limit the bandwidth while copying - *  -P          ssh port number of target host - *  -p          Preserves permissions, modes and access time of files while copying - *  -q          Suppress warning message of SSH - *   -r          Copy files and directories recursively - *   -v          verbose output - - - -Let’s jump into the examples now!!!! - -###### Example:1) Copy a file from local system to remote system using scp - -Let’s assume we want to copy jdk rpm package from our local Linux system to remote system (172.20.10.8) using scp command, use the following command, - -``` -[root@linuxtechi ~]$ scp jdk-linux-x64_bin.rpm root@linuxtechi:/opt -root@linuxtechi's password: -jdk-linux-x64_bin.rpm 100% 10MB 27.1MB/s 00:00 -[root@linuxtechi ~]$ -``` - -Above command will copy jdk rpm package file to remote system under /opt folder. - -###### Example:2) Copy a file from remote System to local system using scp - -Let’s suppose we want to copy a file from remote system to our local system under the /tmp folder, execute the following scp command, - -``` -[root@linuxtechi ~]$ scp root@linuxtechi:/root/Technical-Doc-RHS.odt /tmp -root@linuxtechi's password: -Technical-Doc-RHS.odt 100% 1109KB 31.8MB/s 00:00 -[root@linuxtechi ~]$ ls -l /tmp/Technical-Doc-RHS.odt --rwx------. 1 pkumar pkumar 1135521 Oct 19 11:12 /tmp/Technical-Doc-RHS.odt -[root@linuxtechi ~]$ -``` - -######  Example:3) Verbose Output while transferring files using scp (-v) - -In scp command, we can enable the verbose output using -v option, using verbose output we can easily find what exactly is happening in the background. This becomes very useful in **debugging connection**, **authentication** and **configuration problems**. - -``` -root@linuxtechi ~]$ scp -v jdk-linux-x64_bin.rpm root@linuxtechi:/opt -Executing: program /usr/bin/ssh host 172.20.10.8, user root, command scp -v -t /opt -OpenSSH_7.8p1, OpenSSL 1.1.1 FIPS 11 Sep 2018 -debug1: Reading configuration data /etc/ssh/ssh_config -debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf -debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config -debug1: /etc/ssh/ssh_config.d/05-redhat.conf line 8: Applying options for * -debug1: Connecting to 172.20.10.8 [172.20.10.8] port 22. -debug1: Connection established. -………… -debug1: Next authentication method: password -root@linuxtechi's password: -``` - -###### Example:4) Transfer multiple files to remote system - -Multiple files can be copied / transferred to remote system using scp command in one go, in scp command specify the multiple files separated by space, example is shown below - -``` -[root@linuxtechi ~]$ scp install.txt index.html jdk-linux-x64_bin.rpm root@linuxtechi:/mnt -root@linuxtechi's password: -install.txt 100% 0 0.0KB/s 00:00 -index.html 100% 85KB 7.2MB/s 00:00 -jdk-linux-x64_bin.rpm 100% 10MB 25.3MB/s 00:00 -[root@linuxtechi ~]$ -``` - -###### Example:5) Transfer files across two remote hosts - -Using scp command we can copy files and directories between two remote hosts, let’s suppose we have a local Linux system which can connect to two remote Linux systems, so from my local linux system I can use scp command to copy files across these two systems, - -Syntax: - -### scp [root@linuxtechi][3]_hosts1:/<files_to_transfer>  [root@linuxtechi][3]_host2:/<folder> - -Example is shown below, - -``` -# scp root@linuxtechi:~/backup-Oct.zip root@linuxtechi:/tmp -# ssh root@linuxtechi "ls -l /tmp/backup-Oct.zip" --rwx------. 1 root root 747438080 Oct 19 12:02 /tmp/backup-Oct.zip -``` - -###### Example:6) Copy files and directories recursively (-r) - -Use -r option in scp command to recursively copy the entire directory from one system to another, example is shown below, - -``` -[root@linuxtechi ~]$ scp -r Downloads root@linuxtechi:/opt -``` - -Use below command to verify whether Download folder is copied to remote system or not, - -``` -[root@linuxtechi ~]$ ssh root@linuxtechi "ls -ld /opt/Downloads" -drwxr-xr-x. 2 root root 75 Oct 19 12:10 /opt/Downloads -[root@linuxtechi ~]$ -``` - -###### Example:7) Increase transfer speed by enabling compression (-C) - -In scp command, we can increase the transfer speed by enabling the compression using -C option, it will automatically enable compression at source and decompression at destination host. - -``` -root@linuxtechi ~]$ scp -r -C Downloads root@linuxtechi:/mnt -``` - -In the above example we are transferring the Download directory with compression enabled. - -###### Example:8) Limit bandwidth while copying ( -l ) - -Use ‘-l’ option in scp command to put limit on bandwidth usage while copying. Bandwidth is specified in Kbit/s, example is shown below, - -``` -[root@linuxtechi ~]$ scp -l 500 jdk-linux-x64_bin.rpm root@linuxtechi:/var -``` - -###### Example:9) Specify different ssh port while scp ( -P) - -There can be some scenario where ssh port is changed on destination host, so while using scp command we can specify the ssh port number using ‘-P’ option. - -``` -[root@linuxtechi ~]$ scp -P 2022 jdk-linux-x64_bin.rpm root@linuxtechi:/var -``` - -In above example, ssh port for remote host is “2022” - -###### Example:10) Preserves permissions, modes and access time of files while copying (-p) - -Use “-p” option in scp command to preserve permissions, access time and modes while copying from source to destination - -``` -[root@linuxtechi ~]$ scp -p jdk-linux-x64_bin.rpm root@linuxtechi:/var/tmp -jdk-linux-x64_bin.rpm 100% 10MB 13.5MB/s 00:00 -[root@linuxtechi ~]$ -``` - -###### Example:11) Transferring files in quiet mode ( -q) in scp - -Use ‘-q’ option in scp command to suppress transfer progress, warning and diagnostic messages of ssh. Example is shown below, - -``` -[root@linuxtechi ~]$ scp -q -r Downloads root@linuxtechi:/var/tmp -[root@linuxtechi ~]$ -``` - -###### Example:12) Use Identify file in scp while transferring ( -i ) - -In most of the Linux environments, keys-based authentication is preferred. In scp command we specify the identify file or private key file using ‘-i’ option, example is shown below, - -``` -[root@linuxtechi ~]$ scp -i my_key.pem -r Downloads root@linuxtechi:/root -``` - -In above example, “my_key.pem” is the identity file or private key file. - -###### Example:13) Use different ‘ssh_config’ file in scp ( -F) - -There are some scenarios where you use different networks to connect to Linux systems, may be some network is behind proxy servers, so in that case we must have different **ssh_config** file. - -Different ssh_config file in scp command is specified via ‘-F’ option, example is shown below - -``` -[root@linuxtechi ~]$ scp -F /home/pkumar/new_ssh_config -r Downloads root@linuxtechi:/root -root@linuxtechi's password: -jdk-linux-x64_bin.rpm 100% 10MB 16.6MB/s 00:00 -backup-Oct.zip 100% 713MB 41.9MB/s 00:17 -index.html 100% 85KB 6.6MB/s 00:00 -[root@linuxtechi ~]$ -``` - -###### Example:14) Use Different Cipher in scp command (-c) - -By default, scp uses ‘AES-128’ cipher to encrypt the files. If you want to use another cipher in scp command then use ‘-c’ option followed by cipher name, - -Let’s suppose we want to use ‘3des-cbc’ cipher in scp command while transferring the files, run the following scp command - -``` -[root@linuxtechi ~]# scp -c 3des-cbc -r Downloads root@linuxtechi:/root -``` - -Use the below command to list ssh and scp ciphers, - -``` -[root@linuxtechi ~]# ssh -Q cipher localhost | paste -d , -s - -3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc,root@linuxtechi,aes128-ctr,aes192-ctr,aes256-ctr,root@linuxtechi,root@linuxtechi,root@linuxtechi -[root@linuxtechi ~]# -``` - -That’s all from this tutorial, to get more details about scp command, kindly refer its man page. Please do share your feedback and comments in comments section below. - --------------------------------------------------------------------------------- - -via: https://www.linuxtechi.com/scp-command-examples-in-linux/ - -作者:[Pradeep Kumar][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.linuxtechi.com/author/pradeep/ -[b]: https://github.com/lujun9972 -[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[2]: https://www.linuxtechi.com/wp-content/uploads/2019/10/scp-command-examples-linux.jpg -[3]: https://www.linuxtechi.com/cdn-cgi/l/email-protection diff --git a/sources/tech/20191022 How to program with Bash- Logical operators and shell expansions.md b/sources/tech/20191022 How to program with Bash- Logical operators and shell expansions.md deleted file mode 100644 index 024af38122..0000000000 --- a/sources/tech/20191022 How to program with Bash- Logical operators and shell expansions.md +++ /dev/null @@ -1,498 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to program with Bash: Logical operators and shell expansions) -[#]: via: (https://opensource.com/article/19/10/programming-bash-logical-operators-shell-expansions) -[#]: author: (David Both https://opensource.com/users/dboth) - -How to program with Bash: Logical operators and shell expansions -====== -Learn about logical operators and shell expansions, in the second -article in this three-part series on programming with Bash. -![Women in computing and open source v5][1] - -Bash is a powerful programming language, one perfectly designed for use on the command line and in shell scripts. This three-part series (which is based on my [three-volume Linux self-study course][2]) explores using Bash as a programming language on the command-line interface (CLI). - -The [first article][3] explored some simple command-line programming with Bash, including using variables and control operators. This second article looks into the types of file, string, numeric, and miscellaneous logical operators that provide execution-flow control logic and different types of shell expansions in Bash. The third and final article in the series will explore the **for**, **while**, and **until** loops that enable repetitive operations. - -Logical operators are the basis for making decisions in a program and executing different sets of instructions based on those decisions. This is sometimes called flow control. - -### Logical operators - -Bash has a large set of logical operators that can be used in conditional expressions. The most basic form of the **if** control structure tests for a condition and then executes a list of program statements if the condition is true. There are three types of operators: file, numeric, and non-numeric operators. Each operator returns true (0) if the condition is met and false (1) if the condition is not met. - -The functional syntax of these comparison operators is one or two arguments with an operator that are placed within square braces, followed by a list of program statements that are executed if the condition is true, and an optional list of program statements if the condition is false: - - -``` -if [ arg1 operator arg2 ] ; then list -or -if [ arg1 operator arg2 ] ; then list ; else list ; fi -``` - -The spaces in the comparison are required as shown. The single square braces, **[** and **]**, are the traditional Bash symbols that are equivalent to the **test** command: - - -``` -`if test arg1 operator arg2 ; then list` -``` - -There is also a more recent syntax that offers a few advantages and that some sysadmins prefer. This format is a bit less compatible with different versions of Bash and other shells, such as ksh (the Korn shell). It looks like: - - -``` -`if [[ arg1 operator arg2 ]] ; then list` -``` - -#### File operators - -File operators are a powerful set of logical operators within Bash. Figure 1 lists more than 20 different operators that Bash can perform on files. I use them quite frequently in my scripts. - -Operator | Description ----|--- --a filename | True if the file exists; it can be empty or have some content but, so long as it exists, this will be true --b filename | True if the file exists and is a block special file such as a hard drive like **/dev/sda** or **/dev/sda1** --c filename | True if the file exists and is a character special file such as a TTY device like **/dev/TTY1** --d filename | True if the file exists and is a directory --e filename | True if the file exists; this is the same as **-a** above --f filename | True if the file exists and is a regular file, as opposed to a directory, a device special file, or a link, among others --g filename | True if the file exists and is **set-group-id**, **SETGID** --h filename | True if the file exists and is a symbolic link --k filename | True if the file exists and its "sticky'" bit is set --p filename | True if the file exists and is a named pipe (FIFO) --r filename | True if the file exists and is readable, i.e., has its read bit set --s filename | True if the file exists and has a size greater than zero; a file that exists but that has a size of zero will return false --t fd | True if the file descriptor **fd** is open and refers to a terminal --u filename | True if the file exists and its **set-user-id** bit is set --w filename | True if the file exists and is writable --x filename | True if the file exists and is executable --G filename | True if the file exists and is owned by the effective group ID --L filename | True if the file exists and is a symbolic link --N filename | True if the file exists and has been modified since it was last read --O filename | True if the file exists and is owned by the effective user ID --S filename | True if the file exists and is a socket -file1 -ef file2 | True if file1 and file2 refer to the same device and iNode numbers -file1 -nt file2 | True if file1 is newer (according to modification date) than file2, or if file1 exists and file2 does not -file1 -ot file2 | True if file1 is older than file2, or if file2 exists and file1 does not - -_**Fig. 1: The Bash file operators**_ - -As an example, start by testing for the existence of a file: - - -``` -[student@studentvm1 testdir]$ File="TestFile1" ; if [ -e $File ] ; then echo "The file $File exists." ; else echo "The file $File does not exist." ; fi -The file TestFile1 does not exist. -[student@studentvm1 testdir]$ -``` - -Next, create a file for testing named **TestFile1**. For now, it does not need to contain any data: - - -``` -`[student@studentvm1 testdir]$ touch TestFile1` -``` - -It is easy to change the value of the **$File** variable rather than a text string for the file name in multiple locations in this short CLI program: - - -``` -[student@studentvm1 testdir]$ File="TestFile1" ; if [ -e $File ] ; then echo "The file $File exists." ; else echo "The file $File does not exist." ; fi -The file TestFile1 exists. -[student@studentvm1 testdir]$ -``` - -Now, run a test to determine whether a file exists and has a non-zero length, which means it contains data. You want to test for three conditions: 1. the file does not exist; 2. the file exists and is empty; and 3. the file exists and contains data. Therefore, you need a more complex set of tests—use the **elif** stanza in the **if-elif-else** construct to test for all of the conditions: - - -``` -[student@studentvm1 testdir]$ File="TestFile1" ; if [ -s $File ] ; then echo "$File exists and contains data." ; fi -[student@studentvm1 testdir]$ -``` - -In this case, the file exists but does not contain any data. Add some data and try again: - - -``` -[student@studentvm1 testdir]$ File="TestFile1" ; echo "This is file $File" > $File ; if [ -s $File ] ; then echo "$File exists and contains data." ; fi -TestFile1 exists and contains data. -[student@studentvm1 testdir]$ -``` - -That works, but it is only truly accurate for one specific condition out of the three possible ones. Add an **else** stanza so you can be somewhat more accurate, and delete the file so you can fully test this new code: - - -``` -[student@studentvm1 testdir]$ File="TestFile1" ; rm $File ; if [ -s $File ] ; then echo "$File exists and contains data." ; else echo "$File does not exist or is empty." ; fi -TestFile1 does not exist or is empty. -``` - -Now create an empty file to test: - - -``` -[student@studentvm1 testdir]$ File="TestFile1" ; touch $File ; if [ -s $File ] ; then echo "$File exists and contains data." ; else echo "$File does not exist or is empty." ; fi -TestFile1 does not exist or is empty. -``` - -Add some content to the file and test again: - - -``` -[student@studentvm1 testdir]$ File="TestFile1" ; echo "This is file $File" > $File ; if [ -s $File ] ; then echo "$File exists and contains data." ; else echo "$File does not exist or is empty." ; fi -TestFile1 exists and contains data. -``` - -Now, add the **elif** stanza to discriminate between a file that does not exist and one that is empty: - - -``` -[student@studentvm1 testdir]$ File="TestFile1" ; touch $File ; if [ -s $File ] ; then echo "$File exists and contains data." ; elif [ -e $File ] ; then echo "$File exists and is empty." ; else echo "$File does not exist." ; fi -TestFile1 exists and is empty. -[student@studentvm1 testdir]$ File="TestFile1" ; echo "This is $File" > $File ; if [ -s $File ] ; then echo "$File exists and contains data." ; elif [ -e $File ] ; then echo "$File exists and is empty." ; else echo "$File does not exist." ; fi -TestFile1 exists and contains data. -[student@studentvm1 testdir]$ -``` - -Now you have a Bash CLI program that can test for these three different conditions… but the possibilities are endless. - -It is easier to see the logic structure of the more complex compound commands if you arrange the program statements more like you would in a script that you can save in a file. Figure 2 shows how this would look. The indents of the program statements in each stanza of the **if-elif-else** structure help to clarify the logic. - - -``` -File="TestFile1" -echo "This is $File" > $File -if [ -s $File ] -   then -   echo "$File exists and contains data." -elif [ -e $File ] -   then -   echo "$File exists and is empty." -else -   echo "$File does not exist." -fi -``` - -_**Fig. 2: The command line program rewritten as it would appear in a script**_ - -Logic this complex is too lengthy for most CLI programs. Although any Linux or Bash built-in commands may be used in CLI programs, as the CLI programs get longer and more complex, it makes more sense to create a script that is stored in a file and can be executed at any time, now or in the future. - -#### String comparison operators - -String comparison operators enable the comparison of alphanumeric strings of characters. There are only a few of these operators, which are listed in Figure 3. - -Operator | Description ----|--- --z string | True if the length of string is zero --n string | True if the length of string is non-zero -string1 == string2 -or -string1 = string2 | True if the strings are equal; a single **=** should be used with the test command for POSIX conformance. When used with the **[[** command, this performs pattern matching as described above (compound commands). -string1 != string2 | True if the strings are not equal -string1 < string2 | True if string1 sorts before string2 lexicographically (refers to locale-specific sorting sequences for all alphanumeric and special characters) -string1 > string2 | True if string1 sorts after string2 lexicographically - -_**Fig. 3: Bash string logical operators**_ - -First, look at string length. The quotes around **$MyVar** in the comparison must be there for the comparison to work. (You should still be working in **~/testdir**.) - - -``` -[student@studentvm1 testdir]$ MyVar="" ; if [ -z "" ] ; then echo "MyVar is zero length." ; else echo "MyVar contains data" ; fi -MyVar is zero length. -[student@studentvm1 testdir]$ MyVar="Random text" ; if [ -z "" ] ; then echo "MyVar is zero length." ; else echo "MyVar contains data" ; fi -MyVar is zero length. -``` - -You could also do it this way: - - -``` -[student@studentvm1 testdir]$ MyVar="Random text" ; if [ -n "$MyVar" ] ; then echo "MyVar contains data." ; else echo "MyVar is zero length" ; fi -MyVar contains data. -[student@studentvm1 testdir]$ MyVar="" ; if [ -n "$MyVar" ] ; then echo "MyVar contains data." ; else echo "MyVar is zero length" ; fi -MyVar is zero length -``` - -Sometimes you may need to know a string's exact length. This is not a comparison, but it is related. Unfortunately, there is no simple way to determine the length of a string. There are a couple of ways to do it, but I think using the **expr** (evaluate expression) command is easiest. Read the man page for **expr** for more about what it can do. Note that quotes are required around the string or variable you're testing. - - -``` -[student@studentvm1 testdir]$ MyVar="" ; expr length "$MyVar" -0 -[student@studentvm1 testdir]$ MyVar="How long is this?" ; expr length "$MyVar" -17 -[student@studentvm1 testdir]$ expr length "We can also find the length of a literal string as well as a variable." -70 -``` - -Regarding comparison operators, I use a lot of testing in my scripts to determine whether two strings are equal (i.e., identical). I use the non-POSIX version of this comparison operator: - - -``` -[student@studentvm1 testdir]$ Var1="Hello World" ; Var2="Hello World" ; if [ "$Var1" == "$Var2" ] ; then echo "Var1 matches Var2" ; else echo "Var1 and Var2 do not match." ; fi -Var1 matches Var2 -[student@studentvm1 testdir]$ Var1="Hello World" ; Var2="Hello world" ; if [ "$Var1" == "$Var2" ] ; then echo "Var1 matches Var2" ; else echo "Var1 and Var2 do not match." ; fi -Var1 and Var2 do not match. -``` - -Experiment some more on your own to try out these operators. - -#### Numeric comparison operators - -Numeric operators make comparisons between two numeric arguments. Like the other operator classes, most are easy to understand. - -Operator | Description ----|--- -arg1 -eq arg2 | True if arg1 equals arg2 -arg1 -ne arg2 | True if arg1 is not equal to arg2 -arg1 -lt arg2 | True if arg1 is less than arg2 -arg1 -le arg2 | True if arg1 is less than or equal to arg2 -arg1 -gt arg2 | True if arg1 is greater than arg2 -arg1 -ge arg2 | True if arg1 is greater than or equal to arg2 - -_**Fig. 4: Bash numeric comparison logical operators**_ - -Here are some simple examples. The first instance sets the variable **$X** to 1, then tests to see if **$X** is equal to 1. In the second instance, **X** is set to 0, so the comparison is not true. - - -``` -[student@studentvm1 testdir]$ X=1 ; if [ $X -eq 1 ] ; then echo "X equals 1" ; else echo "X does not equal 1" ; fi -X equals 1 -[student@studentvm1 testdir]$ X=0 ; if [ $X -eq 1 ] ; then echo "X equals 1" ; else echo "X does not equal 1" ; fi -X does not equal 1 -[student@studentvm1 testdir]$ -``` - -Try some more experiments on your own. - -#### Miscellaneous operators - -These miscellaneous operators show whether a shell option is set or a shell variable has a value, but it does not discover the value of the variable, just whether it has one. - -Operator | Description ----|--- --o optname | True if the shell option optname is enabled (see the list of options under the description of the **-o** option to the Bash set builtin in the Bash man page) --v varname | True if the shell variable varname is set (has been assigned a value) --R varname | True if the shell variable varname is set and is a name reference - -_**Fig. 5: Miscellaneous Bash logical operators**_ - -Experiment on your own to try out these operators. - -### Expansions - -Bash supports a number of types of expansions and substitutions that can be quite useful. According to the Bash man page, Bash has seven forms of expansions. This article looks at five of them: tilde expansion, arithmetic expansion, pathname expansion, brace expansion, and command substitution. - -#### Brace expansion - -Brace expansion is a method for generating arbitrary strings. (This tool is used below to create a large number of files for experiments with special pattern characters.) Brace expansion can be used to generate lists of arbitrary strings and insert them into a specific location within an enclosing static string or at either end of a static string. This may be hard to visualize, so it's best to just do it. - -First, here's what a brace expansion does: - - -``` -[student@studentvm1 testdir]$ echo {string1,string2,string3} -string1 string2 string3 -``` - -Well, that is not very helpful, is it? But look what happens when you use it just a bit differently: - - -``` -[student@studentvm1 testdir]$ echo "Hello "{David,Jen,Rikki,Jason}. -Hello David. Hello Jen. Hello Rikki. Hello Jason. -``` - -That looks like something useful—it could save a good deal of typing. Now try this: - - -``` -[student@studentvm1 testdir]$ echo b{ed,olt,ar}s -beds bolts bars -``` - -I could go on, but you get the idea. - -#### Tilde expansion - -Arguably, the most common expansion is the tilde (**~**) expansion. When you use this in a command like **cd ~/Documents**, the Bash shell expands it as a shortcut to the user's full home directory. - -Use these Bash programs to observe the effects of the tilde expansion: - - -``` -[student@studentvm1 testdir]$ echo ~ -/home/student -[student@studentvm1 testdir]$ echo ~/Documents -/home/student/Documents -[student@studentvm1 testdir]$ Var1=~/Documents ; echo $Var1 ; cd $Var1 -/home/student/Documents -[student@studentvm1 Documents]$ -``` - -#### Pathname expansion - -Pathname expansion is a fancy term expanding file-globbing patterns, using the characters **?** and *****, into the full names of directories that match the pattern. File globbing refers to special pattern characters that enable significant flexibility in matching file names, directories, and other strings when performing various actions. These special pattern characters allow matching single, multiple, or specific characters in a string. - - * **?** — Matches only one of any character in the specified location within the string - * ***** — Matches zero or more of any character in the specified location within the string - - - -This expansion is applied to matching directory names. To see how this works, ensure that **testdir** is the present working directory (PWD) and start with a plain listing (the contents of my home directory will be different from yours): - - -``` -[student@studentvm1 testdir]$ ls -chapter6  cpuHog.dos    dmesg1.txt  Documents  Music       softlink1  testdir6    Videos -chapter7  cpuHog.Linux  dmesg2.txt  Downloads  Pictures    Templates  testdir -testdir  cpuHog.mac    dmesg3.txt  file005    Public      testdir    tmp -cpuHog     Desktop       dmesg.txt   link3      random.txt  testdir1   umask.test -[student@studentvm1 testdir]$ -``` - -Now list the directories that start with **Do**, **testdir/Documents**, and **testdir/Downloads**: - - -``` -Documents: -Directory01  file07  file15        test02  test10  test20      testfile13  TextFiles -Directory02  file08  file16        test03  test11  testfile01  testfile14 -file01       file09  file17        test04  test12  testfile04  testfile15 -file02       file10  file18        test05  test13  testfile05  testfile16 -file03       file11  file19        test06  test14  testfile09  testfile17 -file04       file12  file20        test07  test15  testfile10  testfile18 -file05       file13  Student1.txt  test08  test16  testfile11  testfile19 -file06       file14  test01        test09  test18  testfile12  testfile20 - -Downloads: -[student@studentvm1 testdir]$ -``` - -Well, that did not do what you wanted. It listed the contents of the directories that begin with **Do**. To list only the directories and not their contents, use the **-d** option. - - -``` -[student@studentvm1 testdir]$ ls -d Do* -Documents  Downloads -[student@studentvm1 testdir]$ -``` - -In both cases, the Bash shell expands the **Do*** pattern into the names of the two directories that match the pattern. But what if there are also files that match the pattern? - - -``` -[student@studentvm1 testdir]$ touch Downtown ; ls -d Do* -Documents  Downloads  Downtown -[student@studentvm1 testdir]$ -``` - -This shows the file, too. So any files that match the pattern are also expanded to their full names. - -#### Command substitution - -Command substitution is a form of expansion that allows the STDOUT data stream of one command to be used as the argument of another command; for example, as a list of items to be processed in a loop. The Bash man page says: "Command substitution allows the output of a command to replace the command name." I find that to be accurate if a bit obtuse. - -There are two forms of this substitution, **`command`** and **$(command)**. In the older form using back tics (**`**), using a backslash (**\**) in the command retains its literal meaning. However, when it's used in the newer parenthetical form, the backslash takes on its meaning as a special character. Note also that the parenthetical form uses only single parentheses to open and close the command statement. - -I frequently use this capability in command-line programs and scripts where the results of one command can be used as an argument for another command. - -Start with a very simple example that uses both forms of this expansion (again, ensure that **testdir** is the PWD): - - -``` -[student@studentvm1 testdir]$ echo "Todays date is `date`" -Todays date is Sun Apr  7 14:42:46 EDT 2019 -[student@studentvm1 testdir]$ echo "Todays date is $(date)" -Todays date is Sun Apr  7 14:42:59 EDT 2019 -[student@studentvm1 testdir]$ -``` - -The **-w** option to the **seq** utility adds leading zeros to the numbers generated so that they are all the same width, i.e., the same number of digits regardless of the value. This makes it easier to sort them in numeric sequence. - -The **seq** utility is used to generate a sequence of numbers: - - -``` -[student@studentvm1 testdir]$ seq 5 -1 -2 -3 -4 -5 -[student@studentvm1 testdir]$ echo `seq 5` -1 2 3 4 5 -[student@studentvm1 testdir]$ -``` - -Now you can do something a bit more useful, like creating a large number of empty files for testing: - - -``` -`[student@studentvm1 testdir]$ for I in $(seq -w 5000) ; do touch file-$I ; done` -``` - -In this usage, the statement **seq -w 5000** generates a list of numbers from one to 5,000. By using command substitution as part of the **for** statement, the list of numbers is used by the **for** statement to generate the numerical part of the file names. - -#### Arithmetic expansion - -Bash can perform integer math, but it is rather cumbersome (as you will soon see). The syntax for arithmetic expansion is **$((arithmetic-expression))**, using double parentheses to open and close the expression. - -Arithmetic expansion works like command substitution in a shell program or script; the value calculated from the expression replaces the expression for further evaluation by the shell. - -Once again, start with something simple: - - -``` -[student@studentvm1 testdir]$ echo $((1+1)) -2 -[student@studentvm1 testdir]$ Var1=5 ; Var2=7 ; Var3=$((Var1*Var2)) ; echo "Var 3 = $Var3" -Var 3 = 35 -``` - -The following division results in zero because the result would be a decimal value of less than one: - - -``` -[student@studentvm1 testdir]$ Var1=5 ; Var2=7 ; Var3=$((Var1/Var2)) ; echo "Var 3 = $Var3" -Var 3 = 0 -``` - -Here is a simple calculation I often do in a script or CLI program that tells me how much total virtual memory I have in a Linux host. The **free** command does not provide that data: - - -``` -[student@studentvm1 testdir]$ RAM=`free | grep ^Mem | awk '{print $2}'` ; Swap=`free | grep ^Swap | awk '{print $2}'` ; echo "RAM = $RAM and Swap = $Swap" ; echo "Total Virtual memory is $((RAM+Swap))" ; -RAM = 4037080 and Swap = 6291452 -Total Virtual memory is 10328532 -``` - -I used the **`** character to delimit the sections of code used for command substitution. - -I use Bash arithmetic expansion mostly for checking system resource amounts in a script and then choose a program execution path based on the result. - -### Summary - -This article, the second in this series on Bash as a programming language, explored the Bash file, string, numeric, and miscellaneous logical operators that provide execution-flow control logic and the different types of shell expansions. - -The third article in this series will explore the use of loops for performing various types of iterative operations. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/programming-bash-logical-operators-shell-expansions - -作者:[David Both][a] -选题:[lujun9972][b] -译者:[译者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/dboth -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_women_computing_5.png?itok=YHpNs_ss (Women in computing and open source v5) -[2]: http://www.both.org/?page_id=1183 -[3]: https://opensource.com/article/19/10/programming-bash-part-1 diff --git a/sources/tech/20191023 How to program with Bash- Loops.md b/sources/tech/20191023 How to program with Bash- Loops.md deleted file mode 100644 index e582bda447..0000000000 --- a/sources/tech/20191023 How to program with Bash- Loops.md +++ /dev/null @@ -1,352 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to program with Bash: Loops) -[#]: via: (https://opensource.com/article/19/10/programming-bash-loops) -[#]: author: (David Both https://opensource.com/users/dboth) - -How to program with Bash: Loops -====== -Learn how to use loops for performing iterative operations, in the final -article in this three-part series on programming with Bash. -![arrows cycle symbol for failing faster][1] - -Bash is a powerful programming language, one perfectly designed for use on the command line and in shell scripts. This three-part series, based on my [three-volume Linux self-study course][2], explores using Bash as a programming language on the command-line interface (CLI). - -The [first article][3] in this series explored some simple command-line programming with Bash, including using variables and control operators. The [second article][4] looked into the types of file, string, numeric, and miscellaneous logical operators that provide execution-flow control logic and different types of shell expansions in Bash. This third (and final) article examines the use of loops for performing various types of iterative operations and ways to control those loops. - -### Loops - -Every programming language I have ever used has at least a couple types of loop structures that provide various capabilities to perform repetitive operations. I use the for loop quite often but I also find the while and until loops useful. - -#### for loops - -Bash's implementation of the **for** command is, in my opinion, a bit more flexible than most because it can handle non-numeric values; in contrast, for example, the standard C language **for** loop can deal only with numeric values. - -The basic structure of the Bash version of the **for** command is simple: - - -``` -`for Var in list1 ; do list2 ; done` -``` - -This translates to: "For each value in list1, set the **$Var** to that value and then perform the program statements in list2 using that value; when all of the values in list1 have been used, it is finished, so exit the loop." The values in list1 can be a simple, explicit string of values, or they can be the result of a command substitution (described in the second article in the series). I use this construct frequently. - -To try it, ensure that **~/testdir** is still the present working directory (PWD). Clean up the directory, then look at a trivial example of the **for** loop starting with an explicit list of values. This list is a mix of alphanumeric values—but do not forget that all variables are strings and can be treated as such. - - -``` -[student@studentvm1 testdir]$ rm * -[student@studentvm1 testdir]$ for I in a b c d 1 2 3 4 ; do echo $I ; done -a -b -c -d -1 -2 -3 -4 -``` - -Here is a bit more useful version with a more meaningful variable name: - - -``` -[student@studentvm1 testdir]$ for Dept in "Human Resources" Sales Finance "Information Technology" Engineering Administration Research ; do echo "Department $Dept" ; done -Department Human Resources -Department Sales -Department Finance -Department Information Technology -Department Engineering -Department Administration -Department Research -``` - -Make some directories (and show some progress information while doing so): - - -``` -[student@studentvm1 testdir]$ for Dept in "Human Resources" Sales Finance "Information Technology" Engineering Administration Research ; do echo "Working on Department $Dept" ; mkdir "$Dept"  ; done -Working on Department Human Resources -Working on Department Sales -Working on Department Finance -Working on Department Information Technology -Working on Department Engineering -Working on Department Administration -Working on Department Research -[student@studentvm1 testdir]$ ll -total 28 -drwxrwxr-x 2 student student 4096 Apr  8 15:45  Administration -drwxrwxr-x 2 student student 4096 Apr  8 15:45  Engineering -drwxrwxr-x 2 student student 4096 Apr  8 15:45  Finance -drwxrwxr-x 2 student student 4096 Apr  8 15:45 'Human Resources' -drwxrwxr-x 2 student student 4096 Apr  8 15:45 'Information Technology' -drwxrwxr-x 2 student student 4096 Apr  8 15:45  Research -drwxrwxr-x 2 student student 4096 Apr  8 15:45  Sales -``` - -The **$Dept** variable must be enclosed in quotes in the **mkdir** statement; otherwise, two-part department names (such as "Information Technology") will be treated as two separate departments. That highlights a best practice I like to follow: all file and directory names should be a single word. Although most modern operating systems can deal with spaces in names, it takes extra work for sysadmins to ensure that those special cases are considered in scripts and CLI programs. (They almost certainly should be considered, even if they're annoying because you never know what files you will have.) - -So, delete everything in **~/testdir**—again—and do this one more time: - - -``` -[student@studentvm1 testdir]$ rm -rf * ; ll -total 0 -[student@studentvm1 testdir]$ for Dept in Human-Resources Sales Finance Information-Technology Engineering Administration Research ; do echo "Working on Department $Dept" ; mkdir "$Dept"  ; done -Working on Department Human-Resources -Working on Department Sales -Working on Department Finance -Working on Department Information-Technology -Working on Department Engineering -Working on Department Administration -Working on Department Research -[student@studentvm1 testdir]$ ll -total 28 -drwxrwxr-x 2 student student 4096 Apr  8 15:52 Administration -drwxrwxr-x 2 student student 4096 Apr  8 15:52 Engineering -drwxrwxr-x 2 student student 4096 Apr  8 15:52 Finance -drwxrwxr-x 2 student student 4096 Apr  8 15:52 Human-Resources -drwxrwxr-x 2 student student 4096 Apr  8 15:52 Information-Technology -drwxrwxr-x 2 student student 4096 Apr  8 15:52 Research -drwxrwxr-x 2 student student 4096 Apr  8 15:52 Sales -``` - -Suppose someone asks for a list of all RPMs on a particular Linux computer and a short description of each. This happened to me when I worked for the State of North Carolina. Since open source was not "approved" for use by state agencies at that time, and I only used Linux on my desktop computer, the pointy-haired bosses (PHBs) needed a list of each piece of software that was installed on my computer so that they could "approve" an exception. - -How would you approach that? Here is one way, starting with the knowledge that the **rpm –qa** command provides a complete description of an RPM, including the two items the PHBs want: the software name and a brief summary. - -Build up to the final result one step at a time. First, list all RPMs: - - -``` -[student@studentvm1 testdir]$ rpm -qa -perl-HTTP-Message-6.18-3.fc29.noarch -perl-IO-1.39-427.fc29.x86_64 -perl-Math-Complex-1.59-429.fc29.noarch -lua-5.3.5-2.fc29.x86_64 -java-11-openjdk-headless-11.0.ea.28-2.fc29.x86_64 -util-linux-2.32.1-1.fc29.x86_64 -libreport-fedora-2.9.7-1.fc29.x86_64 -rpcbind-1.2.5-0.fc29.x86_64 -libsss_sudo-2.0.0-5.fc29.x86_64 -libfontenc-1.1.3-9.fc29.x86_64 -<snip> -``` - -Add the **sort** and **uniq** commands to sort the list and print the unique ones (since it's possible that some RPMs with identical names are installed): - - -``` -[student@studentvm1 testdir]$ rpm -qa | sort | uniq -a2ps-4.14-39.fc29.x86_64 -aajohan-comfortaa-fonts-3.001-3.fc29.noarch -abattis-cantarell-fonts-0.111-1.fc29.noarch -abiword-3.0.2-13.fc29.x86_64 -abrt-2.11.0-1.fc29.x86_64 -abrt-addon-ccpp-2.11.0-1.fc29.x86_64 -abrt-addon-coredump-helper-2.11.0-1.fc29.x86_64 -abrt-addon-kerneloops-2.11.0-1.fc29.x86_64 -abrt-addon-pstoreoops-2.11.0-1.fc29.x86_64 -abrt-addon-vmcore-2.11.0-1.fc29.x86_64 -<snip> -``` - -Since this gives the correct list of RPMs you want to look at, you can use this as the input list to a loop that will print all the details of each RPM: - - -``` -`[student@studentvm1 testdir]$ for RPM in `rpm -qa | sort | uniq` ; do rpm -qi $RPM ; done` -``` - -This code produces way more data than you want. Note that the loop is complete. The next step is to extract only the information the PHBs requested. So, add an **egrep** command, which is used to select **^Name** or **^Summary**. The carat (**^**) specifies the beginning of the line; thus, any line with Name or Summary at the beginning of the line is displayed. - - -``` -[student@studentvm1 testdir]$ for RPM in `rpm -qa | sort | uniq` ; do rpm -qi $RPM ; done | egrep -i "^Name|^Summary" -Name        : a2ps -Summary     : Converts text and other types of files to PostScript -Name        : aajohan-comfortaa-fonts -Summary     : Modern style true type font -Name        : abattis-cantarell-fonts -Summary     : Humanist sans serif font -Name        : abiword -Summary     : Word processing program -Name        : abrt -Summary     : Automatic bug detection and reporting tool -<snip> -``` - -You can try **grep** instead of **egrep** in the command above, but it will not work. You could also pipe the output of this command through the **less** filter to explore the results. The final command sequence looks like this: - - -``` -`[student@studentvm1 testdir]$ for RPM in `rpm -qa | sort | uniq` ; do rpm -qi $RPM ; done | egrep -i "^Name|^Summary" > RPM-summary.txt` -``` - -This command-line program uses pipelines, redirection, and a **for** loop—all on a single line. It redirects the output of your little CLI program to a file that can be used in an email or as input for other purposes. - -This process of building up the program one step at a time allows you to see the results of each step and ensure that it is working as you expect and provides the desired results. - -From this exercise, the PHBs received a list of over 1,900 separate RPM packages. I seriously doubt that anyone read that list. But I gave them exactly what they asked for, and I never heard another word from them about it. - -### Other loops - -There are two more types of loop structures available in Bash: the **while** and **until** structures, which are very similar to each other in both syntax and function. The basic syntax of these loop structures is simple: - - -``` -`while [ expression ] ; do list ; done` -``` - -and - - -``` -`until [ expression ] ; do list ; done` -``` - -The logic of the first reads: "While the expression evaluates as true, execute the list of program statements. When the expression evaluates as false, exit from the loop." And the second: "Until the expression evaluates as true, execute the list of program statements. When the expression evaluates as true, exit from the loop." - -#### While loop - -The **while** loop is used to execute a series of program statements while (so long as) the logical expression evaluates as true. Your PWD should still be **~/testdir**. - -The simplest form of the **while** loop is one that runs forever. The following form uses the true statement to always generate a "true" return code. You could also use a simple "1"—and that would work just the same—but this illustrates the use of the true statement: - - -``` -[student@studentvm1 testdir]$ X=0 ; while [ true ] ; do echo $X ; X=$((X+1)) ; done | head -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -[student@studentvm1 testdir]$ -``` - -This CLI program should make more sense now that you have studied its parts. First, it sets **$X** to zero in case it has a value left over from a previous program or CLI command. Then, since the logical expression **[ true ]** always evaluates to 1, which is true, the list of program instructions between **do** and **done** is executed forever—or until you press **Ctrl+C** or otherwise send a signal 2 to the program. Those instructions are an arithmetic expansion that prints the current value of **$X** and then increments it by one. - -One of the tenets of [_The Linux Philosophy for Sysadmins_][5] is to strive for elegance, and one way to achieve elegance is simplicity. You can simplify this program by using the variable increment operator, **++**. In the first instance, the current value of the variable is printed, and then the variable is incremented. This is indicated by placing the **++** operator after the variable: - - -``` -[student@studentvm1 ~]$ X=0 ; while [ true ] ; do echo $((X++)) ; done | head -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -``` - -Now delete **| head** from the end of the program and run it again. - -In this version, the variable is incremented before its value is printed. This is specified by placing the **++** operator before the variable. Can you see the difference? - - -``` -[student@studentvm1 ~]$ X=0 ; while [ true ] ; do echo $((++X)) ; done | head -1 -2 -3 -4 -5 -6 -7 -8 -9 -``` - -You have reduced two statements into a single one that prints the value of the variable and increments that value. There is also a decrement operator, **\--**. - -You need a method for stopping the loop at a specific number. To accomplish that, change the true expression to an actual numeric evaluation expression. Have the program loop to 5 and stop. In the example code below, you can see that **-le** is the logical numeric operator for "less than or equal to." This means: "So long as **$X** is less than or equal to 5, the loop will continue. When **$X** increments to 6, the loop terminates." - - -``` -[student@studentvm1 ~]$ X=0 ; while [ $X -le 5 ] ; do echo $((X++)) ; done -0 -1 -2 -3 -4 -5 -[student@studentvm1 ~]$ -``` - -#### Until loop - -The **until** command is very much like the **while** command. The difference is that it will continue to loop until the logical expression evaluates to "true." Look at the simplest form of this construct: - - -``` -[student@studentvm1 ~]$ X=0 ; until false  ; do echo $((X++)) ; done | head -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -[student@studentvm1 ~]$ -``` - -It uses a logical comparison to count to a specific value: - - -``` -[student@studentvm1 ~]$ X=0 ; until [ $X -eq 5 ]  ; do echo $((X++)) ; done -0 -1 -2 -3 -4 -[student@studentvm1 ~]$ X=0 ; until [ $X -eq 5 ]  ; do echo $((++X)) ; done -1 -2 -3 -4 -5 -[student@studentvm1 ~]$ -``` - -### Summary - -This series has explored many powerful tools for building Bash command-line programs and shell scripts. But it has barely scratched the surface on the many interesting things you can do with Bash; the rest is up to you. - -I have discovered that the best way to learn Bash programming is to do it. Find a simple project that requires multiple Bash commands and make a CLI program out of them. Sysadmins do many tasks that lend themselves to CLI programming, so I am sure that you will easily find tasks to automate. - -Many years ago, despite being familiar with other shell languages and Perl, I made the decision to use Bash for all of my sysadmin automation tasks. I have discovered that—sometimes with a bit of searching—I have been able to use Bash to accomplish everything I need. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/programming-bash-loops - -作者:[David Both][a] -选题:[lujun9972][b] -译者:[译者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/dboth -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fail_progress_cycle_momentum_arrow.png?itok=q-ZFa_Eh (arrows cycle symbol for failing faster) -[2]: http://www.both.org/?page_id=1183 -[3]: https://opensource.com/article/19/10/programming-bash-part-1 -[4]: https://opensource.com/article/19/10/programming-bash-part-2 -[5]: https://www.apress.com/us/book/9781484237298 diff --git a/sources/tech/20191024 Get sorted with sort at the command line.md b/sources/tech/20191024 Get sorted with sort at the command line.md deleted file mode 100644 index ff291f39bc..0000000000 --- a/sources/tech/20191024 Get sorted with sort at the command line.md +++ /dev/null @@ -1,250 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Get sorted with sort at the command line) -[#]: via: (https://opensource.com/article/19/10/get-sorted-sort) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) - -Get sorted with sort at the command line -====== -Reorganize your data in a format that makes sense to you—right from the -Linux, BSD, or Mac terminal—with the sort command. -![Coding on a computer][1] - -If you've ever used a spreadsheet application, then you know that rows can be sorted by the contents of a column. For instance, if you have a list of expenses, you might want to sort them by date or by ascending price or by category, and so on. If you're comfortable using a terminal, you may not want to have to use a big office application just to sort text data. And that's exactly what the [**sort**][2] command is for. - -### Installing - -You don't need to install **sort** because it's invariably included on any [POSIX][3] system. On most Linux systems, the **sort** command is bundled in a collection of utilities from the GNU organization. On other POSIX systems, such as BSD and Mac, the default **sort** command is not from GNU, so some options may differ. I'll attempt to account for both GNU and BSD implementations in this article. - -### Sort lines alphabetically - -The **sort** command, by default, looks at the first character of each line of a file and outputs each line in ascending alphabetic order. In the event that two characters on multiple lines are the same, it considers the next character. For example: - - -``` -$ cat distro.list -Slackware -Fedora -Red Hat Enterprise Linux -Ubuntu -Arch -1337 -Mint -Mageia -Debian -$ sort distro.list -1337 -Arch -Debian -Fedora -Mageia -Mint -Red Hat Enterprise Linux -Slackware -Ubuntu -``` - -Using **sort** doesn't change the original file. Sort is a filter, so if you want to preserve your data in its sorted form, you must redirect the output using either **>** or **tee**: - - -``` -$ sort distro.list | tee distro.sorted -1337 -Arch -Debian -[...] -$ cat distro.sorted -1337 -Arch -Debian -[...] -``` - -### Sort by column - -Complex data sets sometimes need to be sorted by something other than the first letter of each line. Imagine, for instance, a list of animals and each one's species and genus, and each "field" (a "cell" in a spreadsheet) is defined by a predictable delimiter character. This is such a common data format for spreadsheet exports that the CSV (comma-separated values) file extension exists to identify such files (although a CSV file doesn't have to be comma-separated, nor does a delimited file have to use the CSV extension to be valid and usable). Consider this example data set: - - -``` -Aptenodytes;forsteri;Miller,JF;1778;Emperor -Pygoscelis;papua;Wagler;1832;Gentoo -Eudyptula;minor;Bonaparte;1867;Little Blue -Spheniscus;demersus;Brisson;1760;African -Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed -Eudyptes;chrysocome;Viellot;1816;Southern Rockhopper -Torvaldis;linux;Ewing,L;1996;Tux -``` - -Given this sample data set, you can use the **\--field-separator** (use **-t** on BSD and Mac—or on GNU to reduce typing) option to set the delimiting character to a semicolon (because this example uses semicolons instead of commas, but it could use any character), and use the **\--key** (**-k** on BSD and Mac or on GNU to reduce typing) option to define which field to sort by. For example, to sort by the second field (starting at 1, not 0) of each line: - - -``` -sort --field-separator=";" --key=2 -Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed -Eudyptes;chrysocome;Viellot;1816;Sothern Rockhopper -Spheniscus;demersus;Brisson;1760;African -Aptenodytes;forsteri;Miller,JF;1778;Emperor -Torvaldis;linux;Ewing,L;1996;Tux -Eudyptula;minor;Bonaparte;1867;Little Blue -Pygoscelis;papua;Wagler;1832;Gentoo -``` - -That's somewhat difficult to read, but Unix is famous for its _pipe_ method of constructing commands, so you can use the **column** command to "prettify" the output. Using GNU **column**: - - -``` -$ sort --field-separator=";" \ -\--key=2 penguins.list | \ -column --table --separator ";" -Megadyptes   antipodes   Milne-Edwards  1880  Yellow-eyed -Eudyptes     chrysocome  Viellot        1816  Southern Rockhopper -Spheniscus   demersus    Brisson        1760  African -Aptenodytes  forsteri    Miller,JF      1778  Emperor -Torvaldis    linux       Ewing,L        1996  Tux -Eudyptula    minor       Bonaparte      1867  Little Blue -Pygoscelis   papua       Wagler         1832  Gentoo -``` - -Slightly more cryptic to the new user (but shorter to type), the command options on BSD and Mac: - - -``` -$ sort -t ";" \ --k2 penguins.list | column -t -s ";" -Megadyptes   antipodes   Milne-Edwards  1880  Yellow-eyed -Eudyptes     chrysocome  Viellot        1816  Southern Rockhopper -Spheniscus   demersus    Brisson        1760  African -Aptenodytes  forsteri    Miller,JF      1778  Emperor -Torvaldis    linux       Ewing,L        1996  Tux -Eudyptula    minor       Bonaparte      1867  Little Blue -Pygoscelis   papua       Wagler         1832  Gentoo -``` - -The **key** definition doesn't have to be set to **2**, of course. Any existing field may be used as the sorting key. - -### Reverse sort - -You can reverse the order of a sorted list with the **\--reverse** (**-r** on BSD or Mac or GNU for brevity): - - -``` -$ sort --reverse alphabet.list -z -y -x -w -[...] -``` - -You can achieve the same result by piping the output of a normal sort through [tac][4]. - -### Sorting by month (GNU only) - -In a perfect world, everyone would write dates according to the ISO 8601 standard: year, month, day. It's a logical method of specifying a unique date, and it's easy for computers to understand. And yet quite often, humans use other means of identifying dates, including months with pretty arbitrary names. - -Fortunately, the GNU **sort** command accounts for this and is able to sort correctly by month name. Use the **\--month-sort** (**-M**) option: - - -``` -$ cat month.list -November -October -September -April -[...] -$ sort --month-sort month.list -January -February -March -April -May -[...] -November -December -``` - -Months may be identified by their full name or some portion of their names. - -### Human-readable numeric sort (GNU only) - -Another common point of confusion between humans and computers is groups of numbers. For instance, humans often write "1024 kilobytes" as "1KB" because it's easier and quicker for the human brain to parse "1KB" than "1024" (and it gets easier the larger the number becomes). To a computer, though, a string such as 9KB is larger than, for instance, 1MB (even though 9KB is only a fraction of a megabyte). The GNU **sort** command provides the **\--human-numeric-sort** (**-h**) option to help parse these values correctly. - - -``` -$ cat sizes.list -2M -12MB -1k -9k -900 -7000 -$ sort --human-numeric-sort -900 -7000 -1k -9k -2M -12MB -``` - -There are some inconsistencies. For example, 16,000 bytes is greater than 1KB, but **sort** fails to recognize that: - - -``` -$ cat sizes0.list -2M -12MB -16000 -1k -$ sort -h sizes0.list -16000 -1k -2M -12MB -``` - -Logically, 16,000 should be written 16KB in this context, so GNU **sort** is not entirely to blame. As long as you are sure that your numbers are consistent, the **\--human-numeric-sort** can help parse human-readable numbers in a computer-friendly way. - -### Randomized sort (GNU only) - -Sometimes utilities provide the option to do the opposite of what they're meant to do. In a way, it makes no sense for a **sort** command to have the ability to "sort" a file randomly. Then again, the workflow of the command makes it a convenient feature to have. You _could_ use a different command, like [**shuf**][5], or you could just add an option to the command you're using. Whether it's bloat or ingenious UX design, the GNU **sort** command provides the means to sort a file arbitrarily. - -The purest form of arbitrary sorting is the **\--random-sort** or **-R** option (not to be confused with the **-r** option, which is short for **\--reverse**). - - -``` -$ sort --random-sort alphabet.list -d -m -p -a -[...] -``` - -You can run a random sort multiple times on a file for different results each time. - -### Sorted - -There are many more features available with the **sort** GNU and BSD commands, so spend some time getting to know the options. You'll be surprised at how flexible **sort** can be, especially when it's combined with other Unix utilities. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/get-sorted-sort - -作者:[Seth Kenlon][a] -选题:[lujun9972][b] -译者:[译者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/seth -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) -[2]: https://en.wikipedia.org/wiki/Sort_(Unix) -[3]: https://en.wikipedia.org/wiki/POSIX -[4]: https://opensource.com/article/19/9/tac-command -[5]: https://www.gnu.org/software/coreutils/manual/html_node/shuf-invocation.html diff --git a/sources/tech/20191028 Enterprise JavaBeans, infrastructure predictions, and more industry trends.md b/sources/tech/20191028 Enterprise JavaBeans, infrastructure predictions, and more industry trends.md index f1d2b48d0d..e915fe74d9 100644 --- a/sources/tech/20191028 Enterprise JavaBeans, infrastructure predictions, and more industry trends.md +++ b/sources/tech/20191028 Enterprise JavaBeans, infrastructure predictions, and more industry trends.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: (warmfrog) +[#]: translator: ( ) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20191028 How to remove duplicate lines from files with awk.md b/sources/tech/20191028 How to remove duplicate lines from files with awk.md deleted file mode 100644 index 0282a26768..0000000000 --- a/sources/tech/20191028 How to remove duplicate lines from files with awk.md +++ /dev/null @@ -1,243 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to remove duplicate lines from files with awk) -[#]: via: (https://opensource.com/article/19/10/remove-duplicate-lines-files-awk) -[#]: author: (Lazarus Lazaridis https://opensource.com/users/iridakos) - -How to remove duplicate lines from files with awk -====== -Learn how to use awk '!visited[$0]++' without sorting or changing their -order. -![Coding on a computer][1] - -Suppose you have a text file and you need to remove all of its duplicate lines. - -### TL;DR - -To remove the duplicate lines while _preserving their order in the file_, use: - - -``` -`awk '!visited[$0]++' your_file > deduplicated_file` -``` - -### How it works - -The script keeps an associative array with _indices_ equal to the unique lines of the file and _values_ equal to their occurrences. For each line of the file, if the line occurrences are zero, then it increases them by one and _prints the line_, otherwise, it just increases the occurrences _without printing the line_. - -I was not familiar with **awk**, and I wanted to understand how this can be accomplished with such a short script (**awk**ward). I did my research, and here is what is going on: - - * The awk "script" **!visited[$0]++** is executed for _each line_ of the input file. - * **visited[]** is a variable of type [associative array][2] (a.k.a. [Map][3]). We don't have to initialize it because **awk** will do it the first time we access it. - * The **$0** variable holds the contents of the line currently being processed. - * **visited[$0]** accesses the value stored in the map with a key equal to **$0** (the line being processed), a.k.a. the occurrences (which we set below). - * The **!** negates the occurrences' value: - * In awk, [any nonzero numeric value or any nonempty string value is true][4]. - * By default, [variables are initialized to the empty string][5], which is zero if converted to a number. - * That being said: - * If **visited[$0]** returns a number greater than zero, this negation is resolved to **false**. - * If **visited[$0]** returns a number equal to zero or an empty string, this negation is resolved to **true**. - * The **++** operation increases the variable's value (**visited[$0]**) by one. - * If the value is empty, **awk** converts it to **0** (number) automatically and then it gets increased. - * **Note:** The operation is executed after we access the variable's value. - - - -Summing up, the whole expression evaluates to: - - * **true** if the occurrences are zero/empty string - * **false** if the occurrences are greater than zero - - - -**awk** statements consist of a [_pattern-expression_ and an _associated action_][6]. - - -``` -` { }` -``` - -If the pattern succeeds, then the associated action is executed. If we don't provide an action, **awk**, by default, **print**s the input. - -> An omitted action is equivalent to **{ print $0 }**. - -Our script consists of one **awk** statement with an expression, omitting the action. So this: - - -``` -`awk '!visited[$0]++' your_file > deduplicated_file` -``` - -is equivalent to this: - - -``` -`awk '!visited[$0]++ { print $0 }' your_file > deduplicated_file` -``` - -For every line of the file, if the expression succeeds, the line is printed to the output. Otherwise, the action is not executed, and nothing is printed. - -### Why not use the **uniq** command? - -The **uniq** command removes only the _adjacent duplicate lines_. Here's a demonstration: - - -``` -$ cat test.txt -A -A -A -B -B -B -A -A -C -C -C -B -B -A -$ uniq < test.txt -A -B -A -C -B -A -``` - -### Other approaches - -#### Using the sort command - -We can also use the following [**sort**][7] command to remove the duplicate lines, but _the line order is not preserved_. - - -``` -`sort -u your_file > sorted_deduplicated_file` -``` - -#### Using cat, sort, and cut - -The previous approach would produce a de-duplicated file whose lines would be sorted based on the contents. [Piping a bunch of commands][8] can overcome this issue: - - -``` -`cat -n your_file | sort -uk2 | sort -nk1 | cut -f2-` -``` - -##### How it works - -Suppose we have the following file: - - -``` -abc -ghi -abc -def -xyz -def -ghi -klm -``` - -**cat -n test.txt** prepends the order number in each line. - - -``` -1       abc -2       ghi -3       abc -4       def -5       xyz -6       def -7       ghi -8       klm -``` - -**sort -uk2** sorts the lines based on the second column (**k2** option) and keeps only the first occurrence of the lines with the same second column value (**u** option). - - -``` -1       abc -4       def -2       ghi -8       klm -5       xyz -``` - -**sort -nk1** sorts the lines based on their first column (**k1** option) treating the column as a number (**-n** option). - - -``` -1       abc -2       ghi -4       def -5       xyz -8       klm -``` - -Finally, **cut -f2-** prints each line starting from the second column until its end (**-f2-** option: _Note the **-** suffix, which instructs it to include the rest of the line_). - - -``` -abc -ghi -def -xyz -klm -``` - -### References - - * [The GNU awk user's guide][9] - * [Arrays in awk][2] - * [Awk—Truth values][4] - * [Awk expressions][5] - * [How can I delete duplicate lines in a file in Unix?][10] - * [Remove duplicate lines without sorting [duplicate]][11] - * [How does awk '!a[$0]++' work?][12] - - - -That's all. Cat photo. - -![Duplicate cat][13] - -* * * - -_This article originally appeared on the iridakos blog by [Lazarus Lazaridis][14] under a [CC BY-NC 4.0 License][15] and is republished with the author's permission._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/10/remove-duplicate-lines-files-awk - -作者:[Lazarus Lazaridis][a] -选题:[lujun9972][b] -译者:[译者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/iridakos -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) -[2]: http://kirste.userpage.fu-berlin.de/chemnet/use/info/gawk/gawk_12.html -[3]: https://en.wikipedia.org/wiki/Associative_array -[4]: https://www.gnu.org/software/gawk/manual/html_node/Truth-Values.html -[5]: https://ftp.gnu.org/old-gnu/Manuals/gawk-3.0.3/html_chapter/gawk_8.html -[6]: http://kirste.userpage.fu-berlin.de/chemnet/use/info/gawk/gawk_9.html -[7]: http://man7.org/linux/man-pages/man1/sort.1.html -[8]: https://stackoverflow.com/a/20639730/2292448 -[9]: https://www.gnu.org/software/gawk/manual/html_node/ -[10]: https://stackoverflow.com/questions/1444406/how-can-i-delete-duplicate-lines-in-a-file-in-unix -[11]: https://stackoverflow.com/questions/11532157/remove-duplicate-lines-without-sorting -[12]: https://unix.stackexchange.com/questions/159695/how-does-awk-a0-work/159734#159734 -[13]: https://opensource.com/sites/default/files/uploads/duplicate-cat.jpg (Duplicate cat) -[14]: https://iridakos.com/about/ -[15]: http://creativecommons.org/licenses/by-nc/4.0/ diff --git a/sources/tech/20191101 Awk one-liners and scripts to help you sort text files.md b/sources/tech/20191101 Awk one-liners and scripts to help you sort text files.md deleted file mode 100644 index 2ce53e1d7e..0000000000 --- a/sources/tech/20191101 Awk one-liners and scripts to help you sort text files.md +++ /dev/null @@ -1,254 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Awk one-liners and scripts to help you sort text files) -[#]: via: (https://opensource.com/article/19/11/how-sort-awk) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) - -Awk one-liners and scripts to help you sort text files -====== -Awk is a powerful tool for doing tasks that might otherwise be left to -other common utilities, including sort. -![Green graph of measurements][1] - -Awk is the ubiquitous Unix command for scanning and processing text containing predictable patterns. However, because it features functions, it's also justifiably called a programming language. - -Confusingly, there is more than one awk. (Or, if you believe there can be only one, then there are several clones.) There's **awk**, the original program written by Aho, Weinberger, and Kernighan, and then there's **nawk**, **mawk**, and the GNU version, **gawk**. The GNU version of awk is a highly portable, free software version of the utility with several unique features, so this article is about GNU awk. - -While its official name is gawk, on GNU+Linux systems it's aliased to awk and serves as the default version of that command. On other systems that don't ship with GNU awk, you must install it and refer to it as gawk, rather than awk. This article uses the terms awk and gawk interchangeably. - -Being both a command and a programming language makes awk a powerful tool for tasks that might otherwise be left to **sort**, **cut**, **uniq**, and other common utilities. Luckily, there's lots of room in open source for redundancy, so if you're faced with the question of whether or not to use awk, the answer is probably a solid "maybe." - -The beauty of awk's flexibility is that if you've already committed to using awk for a task, then you can probably stay in awk no matter what comes up along the way. This includes the eternal need to sort data in a way other than the order it was delivered to you. - -### Sample set - -Before exploring awk's sorting methods, generate a sample dataset to use. Keep it simple so that you don't get distracted by edge cases and unintended complexity. This is the sample set this article uses: - - -``` -Aptenodytes;forsteri;Miller,JF;1778;Emperor -Pygoscelis;papua;Wagler;1832;Gentoo -Eudyptula;minor;Bonaparte;1867;Little Blue -Spheniscus;demersus;Brisson;1760;African -Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed -Eudyptes;chrysocome;Viellot;1816;Sothern Rockhopper -Torvaldis;linux;Ewing,L;1996;Tux -``` - -It's a small dataset, but it offers a good variety of data types: - - * A genus and species name, which are associated with one another but considered separate - * A surname, sometimes with first initials after a comma - * An integer representing a date - * An arbitrary term - * All fields separated by semi-colons - - - -Depending on your educational background, you may consider this a 2D array or a table or just a line-delimited collection of data. How you think of it is up to you, because awk doesn't expect anything more than text. It's up to you to tell awk how you want to parse it. - -### The sort cheat - -If you just want to sort a text dataset by a specific, definable field (think of a "cell" in a spreadsheet), then you can use the [sort command][2]. - -### Fields and records - -Regardless of the format of your input, you must find patterns in it so that you can focus on the parts of the data that are important to you. In this example, the data is delimited by two factors: lines and fields. Each new line represents a new _record_, as you would likely see in a spreadsheet or database dump. Within each line, there are distinct _fields_ (think of them as cells in a spreadsheet) that are separated by semicolons (;). - -Awk processes one record at a time, so while you're structuring the instructions you will give to awk, you can focus on just one line. Establish what you want to do with one line, then test it (either mentally or with awk) on the next line and a few more. You'll end up with a good hypothesis on what your awk script must do in order to provide you with the data structure you want. - -In this case, it's easy to see that each field is separated by a semicolon. For simplicity's sake, assume you want to sort the list by the very first field of each line. - -Before you can sort, you must be able to focus awk on just the first field of each line, so that's the first step. The syntax of an awk command in a terminal is **awk**, followed by relevant options, followed by your awk command, and ending with the file of data you want to process. - - -``` -$ awk --field-separator=";" '{print $1;}' penguins.list -Aptenodytes -Pygoscelis -Eudyptula -Spheniscus -Megadyptes -Eudyptes -Torvaldis -``` - -Because the field separator is a character that has special meaning to the Bash shell, you must enclose the semicolon in quotes or precede it with a backslash. This command is useful only to prove that you can focus on a specific field. You can try the same command using the number of another field to view the contents of another "column" of your data: - - -``` -$ awk --field-separator=";" '{print $3;}' penguins.list -Miller,JF -Wagler -Bonaparte -Brisson -Milne-Edwards -Viellot -Ewing,L -``` - -Nothing has been sorted yet, but this is good groundwork. - -### Scripting - -Awk is more than just a command; it's a programming language with indices and arrays and functions. That's significant because it means you can grab a list of fields you want to sort by, store the list in memory, process it, and then print the resulting data. For a complex series of actions such as this, it's easier to work in a text file, so create a new file called **sort.awk** and enter this text: - - -``` -#!/bin/gawk -f - -BEGIN { -        FS=";"; -} -``` - -This establishes the file as an awk script that executes the lines contained in the file. - -The **BEGIN** statement is a special setup function provided by awk for tasks that need to occur only once. Defining the built-in variable **FS**, which stands for _field separator_ and is the same value you set in your awk command with **\--field-separator**, only needs to happen once, so it's included in the **BEGIN** statement. - -#### Arrays in awk - -You already know how to gather the values of a specific field by using the **$** notation along with the field number, but in this case, you need to store it in an array rather than print it to the terminal. This is done with an awk array. The important thing about an awk array is that it contains keys and values. Imagine an array about this article; it would look something like this: **author:"seth",title:"How to sort with awk",length:1200**. Elements like **author** and **title** and **length** are keys, with the following contents being values. - -The advantage to this in the context of sorting is that you can assign any field as the key and any record as the value, and then use the built-in awk function **asorti()** (sort by index) to sort by the key. For now, assume arbitrarily that you _only_ want to sort by the second field. - -Awk statements _not_ preceded by the special keywords **BEGIN** or **END** are loops that happen at each record. This is the part of the script that scans the data for patterns and processes it accordingly. Each time awk turns its attention to a record, statements in **{}** (unless preceded by **BEGIN** or **END**) are executed. - -To add a key and value to an array, create a variable (in this example script, I call it **ARRAY**, which isn't terribly original, but very clear) containing an array, and then assign it a key in brackets and a value with an equals sign (**=**). - - -``` -{   # dump each field into an array -    ARRAY[$2] = $R; -} -``` - -In this statement, the contents of the second field (**$2**) are used as the key term, and the current record (**$R**) is used as the value. - -### The asorti() function - -In addition to arrays, awk has several basic functions that you can use as quick and easy solutions for common tasks. One of the functions introduced in GNU awk, **asorti()**, provides the ability to sort an array by key (or _index_) or value. - -You can only sort the array once it has been populated, meaning that this action must not occur with every new record but only the final stage of your script. For this purpose, awk provides the special **END** keyword. The inverse of **BEGIN**, an **END** statement happens only once and only after all records have been scanned. - -Add this to your script: - - -``` -END { -    asorti(ARRAY,SARRAY); -    # get length -    j = length(SARRAY); -    -    for (i = 1; i <= j; i++) { -        printf("%s %s\n", SARRAY[i],ARRAY[SARRAY[i]]) -    } -} -``` - -The **asorti()** function takes the contents of **ARRAY**, sorts it by index, and places the results in a new array called **SARRAY** (an arbitrary name I invented for this article, meaning _Sorted ARRAY_). - -Next, the variable **j** (another arbitrary name) is assigned the results of the **length()** function, which counts the number of items in **SARRAY**. - -Finally, use a **for** loop to iterate through each item in **SARRAY** using the **printf()** function to print each key, followed by the corresponding value of that key in **ARRAY**. - -### Running the script - -To run your awk script, make it executable: - - -``` -`$ chmod +x sorter.awk` -``` - -And then run it against the **penguin.list** sample data: - - -``` -$ ./sorter.awk penguins.list -antipodes Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed -chrysocome Eudyptes;chrysocome;Viellot;1816;Sothern Rockhopper -demersus Spheniscus;demersus;Brisson;1760;African -forsteri Aptenodytes;forsteri;Miller,JF;1778;Emperor -linux Torvaldis;linux;Ewing,L;1996;Tux -minor Eudyptula;minor;Bonaparte;1867;Little Blue -papua Pygoscelis;papua;Wagler;1832;Gentoo -``` - -As you can see, the data is sorted by the second field. - -This is a little restrictive. It would be better to have the flexibility to choose at runtime which field you want to use as your sorting key so you could use this script on any dataset and get meaningful results. - -### Adding command options - -You can add a command variable to an awk script by using the literal value **var** in your script. Change your script so that your iterative clause uses **var** when creating your array: - - -``` -{ # dump each field into an array -    ARRAY[$var] = $R; -} -``` - -Try running the script so that it sorts by the third field by using the **-v var** option when you execute it: - - -``` -$ ./sorter.awk -v var=3 penguins.list -Bonaparte Eudyptula;minor;Bonaparte;1867;Little Blue -Brisson Spheniscus;demersus;Brisson;1760;African -Ewing,L Torvaldis;linux;Ewing,L;1996;Tux -Miller,JF Aptenodytes;forsteri;Miller,JF;1778;Emperor -Milne-Edwards Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed -Viellot Eudyptes;chrysocome;Viellot;1816;Sothern Rockhopper -Wagler Pygoscelis;papua;Wagler;1832;Gentoo -``` - -### Fixes - -This article has demonstrated how to sort data in pure GNU awk. The script can be improved so, if it's useful to you, spend some time researching [awk functions][3] on gawk's man page and customizing the script for better output. - -Here is the complete script so far: - - -``` -#!/usr/bin/awk -f -# GPLv3 appears here -# usage: ./sorter.awk -v var=NUM FILE - -BEGIN { FS=";"; } - -{ # dump each field into an array -    ARRAY[$var] = $R; -} - -END { -    asorti(ARRAY,SARRAY); -    # get length -    j = length(SARRAY); -    -    for (i = 1; i <= j; i++) { -        printf("%s %s\n", SARRAY[i],ARRAY[SARRAY[i]]) -    } -} -``` - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/11/how-sort-awk - -作者:[Seth Kenlon][a] -选题:[lujun9972][b] -译者:[译者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/seth -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_lead-steps-measure.png?itok=DG7rFZPk (Green graph of measurements) -[2]: https://opensource.com/article/19/10/get-sorted-sort -[3]: https://www.gnu.org/software/gawk/manual/html_node/Built_002din.html#Built_002din diff --git a/sources/tech/20191104 Fields, records, and variables in awk.md b/sources/tech/20191104 Fields, records, and variables in awk.md deleted file mode 100644 index 0c0d18adbf..0000000000 --- a/sources/tech/20191104 Fields, records, and variables in awk.md +++ /dev/null @@ -1,252 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (liwenwensnow) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Fields, records, and variables in awk) -[#]: via: (https://opensource.com/article/19/11/fields-records-variables-awk) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) - -Fields, records, and variables in awk -====== -In the second article in this intro to awk series, learn about fields, -records, and some powerful awk variables. -![Man at laptop on a mountain][1] - -Awk comes in several varieties: There is the original **awk**, written in 1977 at AT&T Bell Laboratories, and several reimplementations, such as **mawk**, **nawk**, and the one that ships with most Linux distributions, GNU awk, or **gawk**. On most Linux distributions, awk and gawk are synonyms referring to GNU awk, and typing either invokes the same awk command. See the [GNU awk user's guide][2] for the full history of awk and gawk. - -The [first article][3] in this series showed that awk is invoked on the command line with this syntax: - - -``` -`$ awk [options] 'pattern {action}' inputfile` -``` - -Awk is the command, and it can take options (such as **-F** to define the field separator). The action you want awk to perform is contained in single quotes, at least when it's issued in a terminal. To further emphasize which part of the awk command is the action you want it to take, you can precede your program with the **-e** option (but it's not required): - - -``` -$ awk -F, -e '{print $2;}' colours.txt -yellow -blue -green -[...] -``` - -### Records and fields - -Awk views its input data as a series of _records_, which are usually newline-delimited lines. In other words, awk generally sees each line in a text file as a new record. Each record contains a series of _fields_. A field is a component of a record delimited by a _field separator_. - -By default, awk sees whitespace, such as spaces, tabs, and newlines, as indicators of a new field. Specifically, awk treats multiple _space_ separators as one, so this line contains two fields: - - -``` -`raspberry red` -``` - -As does this one: - - -``` -`tuxedo                  black` -``` - -Other separators are not treated this way. Assuming that the field separator is a comma, the following example record contains three fields, with one probably being zero characters long (assuming a non-printable character isn't hiding in that field): - - -``` -`a,,b` -``` - -### The awk program - -The _program_ part of an awk command consists of a series of rules. Normally, each rule begins on a new line in the program (although this is not mandatory). Each rule consists of a pattern and one or more actions: - - -``` -`pattern { action }` -``` - -In a rule, you can define a pattern as a condition to control whether the action will run on a record. Patterns can be simple comparisons, regular expressions, combinations of the two, and more. - -For instance, this will print a record _only_ if it contains the word "raspberry": - - -``` -$ awk '/raspberry/ { print $0 }' colours.txt -raspberry red 99 -``` - -If there is no qualifying pattern, the action is applied to every record. - -Also, a rule can consist of only a pattern, in which case the entire record is written as if the action was **{ print }**. - -Awk programs are essentially _data-driven_ in that actions depend on the data, so they are quite a bit different from programs in many other programming languages. - -### The NF variable - -Each field has a variable as a designation, but there are special variables for fields and records, too. The variable **NF** stores the number of fields awk finds in the current record. This can be printed or used in tests. Here is an example using the [text file][3] from the previous article: - - -``` -$ awk '{ print $0 " (" NF ")" }' colours.txt -name       color  amount (3) -apple      red    4 (3) -banana     yellow 6 (3) -[...] -``` - -Awk's **print** function takes a series of arguments (which may be variables or strings) and concatenates them together. This is why, at the end of each line in this example, awk prints the number of fields as an integer enclosed by parentheses. - -### The NR variable - -In addition to counting the fields in each record, awk also counts input records. The record number is held in the variable **NR**, and it can be used in the same way as any other variable. For example, to print the record number before each line: - - -``` -$ awk '{ print NR ": " $0 }' colours.txt -1: name       color  amount -2: apple      red    4 -3: banana     yellow 6 -4: raspberry  red    3 -5: grape      purple 10 -[...] -``` - -Note that it's acceptable to write this command with no spaces other than the one after **print**, although it's more difficult for a human to parse: - - -``` -`$ awk '{print NR": "$0}' colours.txt` -``` - -### The printf() function - -For greater flexibility in how the output is formatted, you can use the awk **printf()** function. This is similar to **printf** in C, Lua, Bash, and other languages. It takes a _format_ argument followed by a comma-separated list of items. The argument list may be enclosed in parentheses. - - -``` -`$ printf format, item1, item2, ...` -``` - -The format argument (or _format string_) defines how each of the other arguments will be output. It uses _format specifiers_ to do this, including **%s** to output a string and **%d** to output a decimal number. The following **printf** statement outputs the record followed by the number of fields in parentheses: - - -``` -$ awk 'printf "%s (%d)\n",$0,NF}' colours.txt -name       color  amount (3) -raspberry  red    4 (3) -banana     yellow 6 (3) -[...] -``` - -In this example, **%s (%d)** provides the structure for each line, while **$0,NF** defines the data to be inserted into the **%s** and **%d** positions. Note that, unlike with the **print** function, no newline is generated without explicit instructions. The escape sequence **\n** does this. - -### Awk scripting - -All of the awk code in this article has been written and executed in an interactive Bash prompt. For more complex programs, it's often easier to place your commands into a file or _script_. The option **-f FILE** (not to be confused with **-F**, which denotes the field separator) may be used to invoke a file containing a program. - -For example, here is a simple awk script. Create a file called **example1.awk** with this content: - - -``` -/^a/ {print "A: " $0} -/^b/ {print "B: " $0} -``` - -It's conventional to give such files the extension **.awk** to make it clear that they hold an awk program. This naming is not mandatory, but it gives file managers and editors (and you) a useful clue about what the file is. - -Run the script: - - -``` -$ awk -f example1.awk colours.txt -A: raspberry  red    4 -B: banana     yellow 6 -A: apple      green  8 -``` - -A file containing awk instructions can be made into a script by adding a **#!** line at the top and making it executable. Create a file called **example2.awk** with these contents: - - -``` -#!/usr/bin/awk -f -# -# Print all but line 1 with the line number on the front -# - -NR > 1 { -    printf "%d: %s\n",NR,$0 -} -``` - -Arguably, there's no advantage to having just one line in a script, but sometimes it's easier to execute a script than to remember and type even a single line. A script file also provides a good opportunity to document what a command does. Lines starting with the **#** symbol are comments, which awk ignores. - -Grant the file executable permission: - - -``` -`$ chmod u+x example2.awk` -``` - -Run the script: - - -``` -$ ./example2.awk colours.txt -2: apple      red    4 -2: banana     yellow 6 -4: raspberry red    3 -5: grape      purple 10 -[...] -``` - -An advantage of placing your awk instructions in a script file is that it's easier to format and edit. While you can write awk on a single line in your terminal, it can get overwhelming when it spans several lines. - -### Try it - -You now know enough about how awk processes your instructions to be able to write a complex awk program. Try writing an awk script with more than one rule and at least one conditional pattern. If you want to try more functions than just **print** and **printf**, refer to [the gawk manual][4] online. - -Here's an idea to get you started: - - -``` -#!/usr/bin/awk -f -# -# Print each record EXCEPT -# IF the first record contains "raspberry", -# THEN replace "red" with "pi" - -$1 == "raspberry" { -        gsub(/red/,"pi") -} - -{ print } -``` - -Try this script to see what it does, and then try to write your own. - -The next article in this series will introduce more functions for even more complex (and useful!) scripts. - -* * * - -_This article is adapted from an episode of [Hacker Public Radio][5], a community technology podcast._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/11/fields-records-variables-awk - -作者:[Seth Kenlon][a] -选题:[lujun9972][b] -译者:[译者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/seth -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_laptop_code_programming_mountain_view.jpg?itok=yx5buqkr (Man at laptop on a mountain) -[2]: https://www.gnu.org/software/gawk/manual/html_node/History.html#History -[3]: https://opensource.com/article/19/10/intro-awk -[4]: https://www.gnu.org/software/gawk/manual/ -[5]: http://hackerpublicradio.org/eps.php?id=2129 diff --git a/sources/tech/20191107 Demystifying Kubernetes.md b/sources/tech/20191107 Demystifying Kubernetes.md deleted file mode 100644 index ad3260b0b3..0000000000 --- a/sources/tech/20191107 Demystifying Kubernetes.md +++ /dev/null @@ -1,236 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (Morisun029) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Demystifying Kubernetes) -[#]: via: (https://opensourceforu.com/2019/11/demystifying-kubernetes/) -[#]: author: (Abhinav Nath Gupta https://opensourceforu.com/author/abhinav-gupta/) - -Demystifying Kubernetes -====== - -[![][1]][2] - -_Kubernetes is a production grade open source system for automating deployment, scaling, and the management of containerised applications. This article is about managing containers with Kubernetes._ - -‘Containers’ has become one of the latest buzz words. But what does the term imply? Often associated with Docker, a container is defined as a standardised unit of software. Containers encapsulate the software and the environment required to run the software into a single unit that is easily shippable. -A container is a standard unit of software that packages the code and all its dependencies so that the application runs quickly and reliably from one computing environment to another. The container does this by creating something called an image, which is akin to an ISO image. A container image is a lightweight, standalone, executable package of software that includes everything needed to run an application — code, runtime, system tools, system libraries and settings. - -Container images become containers at runtime and, in the case of Docker containers, images become containers when they run on a Docker engine. Containers isolate software from the environment and ensure that it works uniformly despite differences in instances across environments. - -**What is container management?** -Container management is the process of organising, adding or replacing large numbers of software containers. Container management uses software to automate the process of creating, deploying and scaling containers. This gives rise to the need for container orchestration—a tool that automates the deployment, management, scaling, networking and availability of container based applications. - -**Kubernetes** -Kubernetes is a portable, extensible, open source platform for managing containerised workloads and services, and it facilitates both configuration and automation. It was originally developed by Google. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available. - -Google open sourced the Kubernetes project in 2014. Kubernetes builds upon a decade and a half of experience that Google had with running production workloads at scale, combined with best-of-breed ideas and practices from the community, as well as the usage of declarative syntax. - -Some of the common terminologies associated with the Kubernetes ecosystem are listed below. -_**Pods:**_ A pod is the basic execution unit of a Kubernetes application – the smallest and simplest unit in the Kubernetes object model that you create or deploy. A pod represents processes running on a Kubernetes cluster. - -A pod encapsulates the running container, storage, network IP (unique) and commands that govern how the container should run. It represents the single unit of deployment within the Kubernetes ecosystem, a single instance of an application which might consist of one or many containers running with tight coupling and shared resources. - -Pods in a Kubernetes cluster can be used in two main ways. The first is pods that run a single container. The ‘one-container-per-pod’ model is the most common Kubernetes use case. The second method involves pods that run multiple containers that need to work together. - -A pod might encapsulate an application composed of multiple co-located containers that are tightly coupled and need to share resources. - -_**ReplicaSet:**_ The purpose of a ReplicaSet is to maintain a stable set of replica pods running at any given time. A ReplicaSet contains information about how many copies of a particular pod should be running. To create multiple pods to match the ReplicaSet criteria, Kubernetes uses the pod template. The link a ReplicaSet has to its pods is via the latter’s metadata.ownerReferences field, which specifies which resource owns the current object. - -_**Services:**_ Services are an abstraction to expose the functionality of a set of pods. With Kubernetes, you don’t need to modify your application to use an unfamiliar service discovery mechanism. Kubernetes gives pods their own IP addresses and a single DNS name for a set of pods, and can load-balance across them. - -One major problem that services solve is the integration of the front-end and back-end of a Web application. Since Kubernetes provides IP addresses behind the scenes to pods, when the latter are killed and resurrected, the IP addresses are changed. This creates a big problem on the front-end side to connect a given back-end IP address to the corresponding front-end IP address. Services solve this problem by providing an abstraction over the pods — something akin to a load balancer. - -_**Volumes:**_ A Kubernetes volume has an explicit lifetime — the same as the pod that encloses it. Consequently, a volume outlives any container that runs within the pod and the data is preserved across container restarts. Of course, when a pod ceases to exist, the volume will cease to exist, too. Perhaps more important than this is that Kubernetes supports many types of volumes, and a pod can use any number of them simultaneously. - -At its core, a volume is just a directory, possibly with some data in it, which is accessible to the containers in a pod. How that directory comes to be, the medium that backs it and its contents are determined by the particular volume type used. - -**Why Kubernetes?** -Containers are a good way to bundle and run applications. In a production environment, you need to manage the containers that run the applications and ensure that there is no downtime. For example, if one container goes down, another needs to start. Wouldn’t it be nice if this could be automated by a system? -That’s where Kubernetes comes to the rescue! It provides a framework to run distributed systems resiliently. It takes care of scaling requirements, failover, deployment patterns, and more. For example, Kubernetes can easily manage a canary deployment for your system. - -Kubernetes provides users with: -1\. Service discovery and load balancing -2\. Storage orchestration -3\. Automated roll-outs and roll-backs -4\. Automatic bin packing -5\. Self-healing -6\. Secret and configuration management - -**What can Kubernetes do?** -In this section we will look at some code examples of how to use Kubernetes when building a Web application from scratch. We will create a simple back-end server using Flask in Python. -There are a few prerequisites for those who want to build a Web app from scratch. These are: -1\. Basic understanding of Docker, Docker containers and Docker images. A quick refresher can be found at __. -2\. Docker should be installed in the system. -3\. Kubernetes should be installed in the system. Instructions on how to do so on a local machine can be found at __. -Now, create a simple directory, as shown in the code snippet below: - -``` -mkdir flask-kubernetes/app && cd flask-kubernetes/app -``` - -Next, inside the _flask-kubernetes/app_ directory, create a file called main.py, as shown in the code snippet below: - -``` -touch main.py -``` - -In the newly created _main.py,_ paste the following code: - -``` -from flask import Flask -app = Flask(__name__) - -@app.route("/") -def hello(): -return "Hello from Kubernetes!" - -if __name__ == "__main__": -app.run(host='0.0.0.0') -``` - -Install Flask in your local using the command below: - -``` -pip install Flask==0.10.1 -``` - -After installing Flask, run the following command: - -``` -python app.py -``` - -This should run the Flask server locally on port 5000, which is the default port for the Flask app, and you can see the output ‘Hello from Kubernetes!’ on *. -Once the server is running locally, we will create a Docker image to be used by Kubernetes. -Create a file with the name Dockerfile and paste the following code snippet in it: - -``` -FROM python:3.7 - -RUN mkdir /app -WORKDIR /app -ADD . /app/ -RUN pip install -r requirements.txt - -EXPOSE 5000 -CMD ["python", "/app/main.py"] -``` - -The instructions in _Dockerfile_ are explained below: - -1\. Docker will fetch the Python 3.7 image from the Docker hub. -2\. It will create an app directory in the image. -3\. It will set an app as the working directory. -4\. Copy the contents from the app directory in the host to the image app directory. -5\. Expose Port 5000. -6\. Finally, it will run the command to start the Flask server. -In the next step, we will create the Docker image, using the command given below: - -``` -docker build -f Dockerfile -t flask-kubernetes:latest . -``` - -After creating the Docker image, we can test it by running it locally using the following command: - -``` -docker run -p 5001:5000 flask-kubernetes -``` - -Once we are done testing it locally by running a container, we need to deploy this in Kubernetes. -We will first verify that Kubernetes is running using the _kubectl_ command. If there are no errors, then it is working. If there are errors, do refer to __. - -Next, let’s create a deployment file. This is a yaml file containing the instruction for Kubernetes about how to create pods and services in a very declarative fashion. Since we have a Flask Web application, we will create a _deployment.yaml_ file with both the pods and services declarations inside it. - -Create a file named deployment.yaml and add the following contents to it, before saving it: - -``` -apiVersion: v1 -kind: Service -metadata: -name: flask-kubernetes -service -spec: -selector: -app: flask-kubernetes -ports: -- protocol: "TCP" -port: 6000 -targetPort: 5000 -type: LoadBalancer - - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: -name: flask-kubernetes -spec: -replicas: 4 -template: -metadata: -labels: -app: flask-kubernetes -spec: -containers: -- name: flask-kubernetes -image: flask-kubernetes:latest -imagePullPolicy: Never -ports: -- containerPort: 5000 -``` - -Use _kubectl_ to send the _yaml_ file to Kubernetes by running the following command: - -``` -kubectl apply -f deployment.yaml -``` - -You can see the pods are running if you execute the following command: - -``` -kubectl get pods -``` - -Now navigate to __, and you should see the ‘Hello from Kubernetes!’ message. -That’s it! The application is now running in Kubernetes! - -**What Kubernetes cannot do** -Kubernetes is not a traditional, all-inclusive PaaS (Platform as a Service) system. Since Kubernetes operates at the container level rather than at the hardware level, it provides some generally applicable features common to PaaS offerings, such as deployment, scaling, load balancing, logging, and monitoring. Kubernetes provides the building blocks for developer platforms, but preserves user choice and flexibility where it is important. - - * Kubernetes does not limit the types of applications supported. If an application can run in a container, it should run great on Kubernetes. - * It does not deploy and build source code. - * It does not dictate logging, monitoring, or alerting solutions. - * It does not provide or mandate a configuration language/system. It provides a declarative API for everyone’s use. - * It does not provide or adopt any comprehensive machine configuration, maintenance, management, or self-healing systems. - - - -![Avatar][3] - -[Abhinav Nath Gupta][4] - -The author is a software development engineer at Cleo Software India Pvt Ltd, Bengaluru. He is interested in cryptography, data security, cryptocurrency and cloud computing. He can be reached at [abhi.aec89@gmail.com][5]. - -[![][6]][7] - --------------------------------------------------------------------------------- - -via: https://opensourceforu.com/2019/11/demystifying-kubernetes/ - -作者:[Abhinav Nath Gupta][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensourceforu.com/author/abhinav-gupta/ -[b]: https://github.com/lujun9972 -[1]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Gear-kubernetes.jpg?resize=696%2C457&ssl=1 (Gear kubernetes) -[2]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Gear-kubernetes.jpg?fit=800%2C525&ssl=1 -[3]: https://secure.gravatar.com/avatar/f65917facf5f28936663731fedf545c4?s=100&r=g -[4]: https://opensourceforu.com/author/abhinav-gupta/ -[5]: mailto:abhi.aec89@gmail.com -[6]: http://opensourceforu.com/wp-content/uploads/2013/10/assoc.png -[7]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US diff --git a/sources/tech/20191111 A guide to intermediate awk scripting.md b/sources/tech/20191111 A guide to intermediate awk scripting.md index 7c1000736c..7e788b2adc 100644 --- a/sources/tech/20191111 A guide to intermediate awk scripting.md +++ b/sources/tech/20191111 A guide to intermediate awk scripting.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (lnrCoder) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) @@ -129,7 +129,7 @@ via: https://opensource.com/article/19/11/intermediate-awk-scripting 作者:[Seth Kenlon][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) +译者:[译者ID](https://github.com/lnrCoder) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/tech/20191113 Edit images on Fedora easily with GIMP.md b/sources/tech/20191113 Edit images on Fedora easily with GIMP.md deleted file mode 100644 index c45813d7cb..0000000000 --- a/sources/tech/20191113 Edit images on Fedora easily with GIMP.md +++ /dev/null @@ -1,84 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Edit images on Fedora easily with GIMP) -[#]: via: (https://fedoramagazine.org/edit-images-on-fedora-easily-with-gimp/) -[#]: author: (Mehdi Haghgoo https://fedoramagazine.org/author/powergame/) - -Edit images on Fedora easily with GIMP -====== - -![][1] - -GIMP (short for GNU Image Manipulation Program) is free and open-source image manipulation software. With many capabilities ranging from simple image editing to complex filters, scripting and even animation, it is a good alternative to popular commercial options. - -Read on to learn how to install and use GIMP on Fedora. This article covers basic daily image editing. - -### Installing GIMP - -GIMP is available in the official Fedora repository. To install it run: - -``` -sudo dnf install gimp -``` - -### Single window mode - -Once you open the application, it shows you the dark theme window with toolbox and the main editing area. Note that it has two window modes that you can switch between by selecting _Windows_ -> _Single Window Mode_. By checking this option all components of the UI are displayed in a single window. Otherwise, they will be separate. - -### Loading an image - -![][2] - -To load an image, go to _File_ -> _Open_ and choose your file and choose your image file. - -### Resizing an image - -To resize the image, you have the option to resize based on a couple of parameters, including pixel and percentage — the two parameters which are often handy in editing images. - -Let’s say we need to scale down the Fedora 30 background image to 75% of its current size. To do that, select _Image_ -> _Scale_ and then on the scale dialog, select percentage in the unit drop down. Next, enter _75_ as width or height and press the **Tab** key. By default, the other dimension will automatically resize in correspondence with the changed dimension to preserve aspect ratio. For now, leave other options unchanged and press Scale. - -![][3] - -The image scales to 0.75 percent of its original size. - -### Rotating images - -Rotating is a transform operation, so you find it under _Image_ -> _Transform_ from the main menu, where there are options to rotate the image by 90 or 180 degrees. There are also options for flipping the image vertically or horizontally under the mentioned option. - -Let’s say we need to rotate the image 90 degrees. After applying a 90-degree clockwise rotation and horizontal flip, our image will look like this: - -![Transforming an image with GIMP][4] - -### Adding text - -Adding text is very easy. Just select the A icon from the toolbox, and click on a point on your image where you want to add the text. If the toolbox is not visible, open it from Windows->New Toolbox. - -As you edit the text, you might notice that the text dialog has font customization options including font family, font size, etc. - -![Adding text to image in GIMP][5] - -### Saving and exporting - -You can save your edit as as a GIMP project with the _xcf_ extension from _File_ -> _Save_ or by pressing **Ctrl+S**. Or you can export your image in formats such as PNG or JPEG. To export, go to _File_ -> _Export As_ or hit **Ctrl+Shift+E** and you will be presented with a dialog where you can select the output image and name. - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/edit-images-on-fedora-easily-with-gimp/ - -作者:[Mehdi Haghgoo][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/powergame/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2019/10/gimp-magazine-816x346.jpg -[2]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-00-44-300x165.png -[3]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-17-33-300x262.png -[4]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-41-28-300x243.png -[5]: https://fedoramagazine.org/wp-content/uploads/2019/10/Screenshot-from-2019-10-25-11-47-54-300x237.png diff --git a/sources/tech/20191113 Getting Started With ZFS Filesystem on Ubuntu 19.10.md b/sources/tech/20191113 Getting Started With ZFS Filesystem on Ubuntu 19.10.md deleted file mode 100644 index 1f1665d5fe..0000000000 --- a/sources/tech/20191113 Getting Started With ZFS Filesystem on Ubuntu 19.10.md +++ /dev/null @@ -1,144 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (guevaraya ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Getting Started With ZFS Filesystem on Ubuntu 19.10) -[#]: via: (https://itsfoss.com/zfs-ubuntu/) -[#]: author: (John Paul https://itsfoss.com/author/john/) - -Getting Started With ZFS Filesystem on Ubuntu 19.10 -====== - -One of the main [features of Ubuntu 19.10][1] is support for [ZFS][2]. Now you can easily install Ubuntu with on ZFS without any extra effort. - -Normally, you install Linux with Ext4 filesystem. But if you do a fresh install of Ubuntu 19.10, you’ll see the option to use ZFS on the root. You must not use it on a dual boot system though because it will erase the entire disk. - -![You can choose ZFS while installing Ubuntu 19.10][3] - -Let’s see why ZFS matters and how to take advantage of it on ZFS install of Ubuntu. - -### How ZFS is different than other filesystems? - -ZFS is designed with two major goals in mind: to handle large amounts of storage and prevent data corruption. ZFS can handle up to 256 quadrillion Zettabytes of storage. (Hence the Z in ZFS.) It can also handle files up to 16 exabytes in size. - -If you are limited to a single drive laptop, you can still take advantage of the data protection features in ZFS. The copy-on-write feature ensures that data that is in use is not overwritten. Instead, the new information is written to a new block and the filesystem’s metadata is updated to point to the new block. ZFS can easily create snapshots of the filesystem. These snapshots track changes made to the filesystem and share with the filesystem the data that is the same to save space. - -ZFS assigned a checksum to each file on the drive. It is constantly checking the state of the file against that checksum. If it detects that the file has become corrupt, it will attempt to automatically repair that file. - -I have written a detailed article about [what is ZFS and what its features are][2]. Please read it if you are interested in knowing more on this topic. - -Note - -Keep in mind that the data protection features of ZFS can lead to a reduction in performance. - -### Using ZFS on Ubuntu [For intermediate to advanced users] - -![][4] - -Once you have a clean install of Ubuntu with ZFS on the main disk you can start [taking advantage][5] of the features that this filesystem has. - -Please note that all setup of ZFS requires the command line. I am not aware of any GUI tools for it. - -#### Creating a ZFS pool - -_**The section only applies if you have a system with more than one drive. If you only have one drive, Ubuntu will automatically create the pool during installation.**_ - -Before you create your pool, you need to find out the id of the drives for the pool. You can use the command _**lsblk**_ to show this information. - -To create a basic pool with three drives, use the following command: - -``` -sudo zpool create pool-test /dev/sdb /dev/sdc /dev/sdd. -``` - -Remember to replace _**pool-test**_ with the pool name of your choice. - -This command will set up “a zero redundancy RAID-0 pool”. This means that if one of the drives becomes damaged or corrupt, you will lose data. If you do use this setup, it is recommended that you do regular backups. - -You can alos add another disk to the pool by using this command: - -``` -sudo zpool add pool-name /dev/sdx -``` - -#### Check the status of your ZFS pool - -You can check the status of your new pool using this command: - -``` -sudo zpool status pool-test -``` - -![Zpool Status][6] - -#### Mirror a ZFS pool - -To ensure that your data is safe, you can instead set up mirroring. Mirroring means that each drive contains the same data. With mirroring setup, you could lose two out of three drives and still have all of your information. - -To create a mirror, you can use something like this: - -``` -sudo zpool create pool-test mirror /dev/sdb /dev/sdc /dev/sdd -``` - -#### Create ZFS Snapshots for backup and restore - -Snapshots allow you to create a fall-back position in case a file gets deleted or overwritten. For example, let’s create a snapshot, delete some folder in my home directory and restore them. - -First, you need to find the dataset you want to snapshot. You can do that with the - -``` -zfs list -``` - -![Zfs List][7] - -You can see that my home folder is located in **rpool/USERDATA/johnblood_uwcjk7**. - -Let’s create a snapshot named **1910** using this command: - -``` -sudo zfs snapshot rpool/USERDATA/[email protected] -``` - -The snapshot will be created very quickly. Now, I am going to delete the _Downloads_ and _Documents_ directories. - -Now to restore the snapshot, all you have to do is run this command: - -``` -sudo zfs rollback rpool/USERDATA/[email protected] -``` - -The length of the rollback depends on how much the information changed. Now, you can check the home folder and the deleted folders (and their content) will be returned to their correct place. - -### To ZFS or not? - -This is just a quick glimpse at what you can do with ZFS on Ubuntu. For more information, check out [Ubuntu’s wiki page on ZFS.][5] I also recommend reading this [excellent article on ArsTechnica][8]. - -This is an experimental feature and if you are not aware of ZFS and you want to have a simple stable system, please go with the standard install on Ext4. If you have a spare machine that you want to experiment with, then only try something like this to learn a thing or two about ZFS. If you are an ‘expert’ and you know what you are doing, you are free to experiment ZFS wherever you like. - -Have you ever used ZFS? Please let us know in the comments below. If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][9]. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/zfs-ubuntu/ - -作者:[John Paul][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/john/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/ubuntu-19-04-release-features/ -[2]: https://itsfoss.com/what-is-zfs/ -[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/05/zfs-ubuntu-19-10.jpg?ssl=1 -[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/Using_ZFS_Ubuntu.jpg?resize=800%2C450&ssl=1 -[5]: https://wiki.ubuntu.com/Kernel/Reference/ZFS -[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/zpool-status.png?ssl=1 -[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/10/zfs-list.png?ssl=1 -[8]: https://arstechnica.com/information-technology/2019/10/a-detailed-look-at-ubuntus-new-experimental-zfs-installer/ -[9]: https://reddit.com/r/linuxusersgroup diff --git a/sources/tech/20191114 Cleaning up with apt-get.md b/sources/tech/20191114 Cleaning up with apt-get.md deleted file mode 100644 index b251d10030..0000000000 --- a/sources/tech/20191114 Cleaning up with apt-get.md +++ /dev/null @@ -1,98 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Cleaning up with apt-get) -[#]: via: (https://www.networkworld.com/article/3453032/cleaning-up-with-apt-get.html) -[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) - -Cleaning up with apt-get -====== -Most of us with Debian-based systems use apt-get routinely to install packages and upgrades, but how often do we pull out the cleaning tools? Let's check out some of the tool's options for cleaning up after itself. -[Félix Prado Modified by IDG Comm.][1] [(CC0)][2] - -Running **apt-get** commands on a Debian-based system is routine. Packages are updated fairly frequently and commands like **apt-get update** and **apt-get upgrade** make the process quite easy. On the other hand, how often do you use **apt-get clean**, **apt-get autoclean** or **apt-get autoremove**? - -These commands clean up after apt-get's installation operations and remove files that are still on your system but are no longer needed – often because the application that required them is no longer installed. - -[[Get regularly scheduled insights by signing up for Network World newsletters.]][3] - -### apt-get clean - -The apt-get clean command clears the local repository of retrieved package files that are left in **/var/cache**. The directories it cleans out are **/var/cache/apt/archives/** and **/var/cache/apt/archives/partial/**. The only files it leaves in **/var/cache/apt/archives** are the **lock** file and the **partial** subdirectory. - -[][4] - -BrandPost Sponsored by HPE - -[Take the Intelligent Route with Consumption-Based Storage][4] - -Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency. - -You might have a number of files in the directory prior to running the clean operation: - -``` -/var/cache/apt/archives/db5.3-util_5.3.28+dfsg1-0.6ubuntu1_amd64.deb -/var/cache/apt/archives/db-util_1%3a5.3.21~exp1ubuntu2_all.deb -/var/cache/apt/archives/lock -/var/cache/apt/archives/postfix_3.4.5-1ubuntu1_amd64.deb -/var/cache/apt/archives/sasl2-bin_2.1.27+dfsg-1build3_amd64.deb -``` - -You should only have these afterwards: - -``` -$ sudo ls -lR /var/cache/apt/archives -/var/cache/apt/archives: -total 4 --rw-r----- 1 root root 0 Jan 5 2018 lock -drwx------ 2 _apt root 4096 Nov 12 07:24 partial - -/var/cache/apt/archives/partial: -total 0 <== empty -``` - -The **apt-get clean** command is generally used to clear disk space as needed, generally as part of regularly scheduled maintenance. - -### apt-get autoclean - -The **apt-get** **autoclean** option, like **apt-get clean**, clears the local repository of retrieved package files, but it only removes files that can no longer be downloaded and are virtually useless. It helps to keep your cache from growing too large. - -### apt-get autoremove - -The **autoremove** option removes packages that were automatically installed because some other package required them but, with those other packages removed, they are no longer needed. Sometimes, an upgrade will suggest that you run this command. - -``` -The following packages were automatically installed and are no longer required: - g++-8 gir1.2-mutter-4 libapache2-mod-php7.2 libcrystalhd3 - libdouble-conversion1 libgnome-desktop-3-17 libigdgmm5 libisl19 libllvm8 - liblouisutdml8 libmutter-4-0 libmysqlclient20 libpoppler85 libstdc++-8-dev - libtagc0 libvpx5 libx265-165 php7.2 php7.2-cli php7.2-common php7.2-json - php7.2-opcache php7.2-readline -Use 'sudo apt autoremove' to remove them. <== -``` - -The packages to be removed are often called "unused dependencies". In fact, a good practice to follow is to use **autoremove** after uninstalling a package to be sure that no unneeded files are left behind. - -Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3453032/cleaning-up-with-apt-get.html - -作者:[Sandra Henry-Stocker][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ -[b]: https://github.com/lujun9972 -[1]: https://unsplash.com/photos/nbKaLT4cmRM -[2]: https://creativecommons.org/publicdomain/zero/1.0/ -[3]: https://www.networkworld.com/newsletters/signup.html -[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) -[5]: https://www.facebook.com/NetworkWorld/ -[6]: https://www.linkedin.com/company/network-world diff --git a/sources/tech/20191114 Debugging Software Deployments with strace.md b/sources/tech/20191114 Debugging Software Deployments with strace.md deleted file mode 100644 index 1754792ab5..0000000000 --- a/sources/tech/20191114 Debugging Software Deployments with strace.md +++ /dev/null @@ -1,347 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Debugging Software Deployments with strace) -[#]: via: (https://theartofmachinery.com/2019/11/14/deployment_debugging_strace.html) -[#]: author: (Simon Arneaud https://theartofmachinery.com) - -Debugging Software Deployments with strace -====== - -Most of my paid work involves deploying software systems, which means I spend a lot of time trying to answer the following questions: - - * This software works on the original developer’s machine, so why doesn’t it work on mine? - * This software worked on my machine yesterday, so why doesn’t it work today? - - - -That’s a kind of debugging, but it’s a different kind of debugging from normal software debugging. Normal debugging is usually about the logic of the code, but deployment debugging is usually about the interaction between the code and its environment. Even when the root cause is a logic bug, the fact that the software apparently worked on another machine means that the environment is usually involved somehow. - -So, instead of using normal debugging tools like `gdb`, I have another toolset for debugging deployments. My favourite tool for “Why isn’t this software working on this machine?” is `strace`. - -### What is `strace`? - -[`strace`][1] is a tool for “system call tracing”. It’s primarily a Linux tool, but you can do the same kind of debugging tricks with tools for other systems (such as [DTrace][2] and [ktrace][3]). - -The basic usage is very simple. Just run it against a command and it dumps all the system calls (you’ll probably need to install `strace` first): - -``` -$ strace echo Hello -...Snip lots of stuff... -write(1, "Hello\n", 6) = 6 -close(1) = 0 -close(2) = 0 -exit_group(0) = ? -+++ exited with 0 +++ -``` - -What are these system calls? They’re like the API for the operating system kernel. Once upon a time, software used to have direct access to the hardware it ran on. If it needed to display something on the screen, for example, it could twiddle with ports and/or memory-mapped registers for the video hardware. That got chaotic when multitasking computer systems became popular because different applications would “fight” over hardware, and bugs in one application could crash other applications, or even bring down the whole system. So CPUs started supporting different privilege modes (or “protection rings”). They let an operating system kernel run in the most privileged mode with full hardware access, while spawning less-privileged software applications that must ask the kernel to interact with the hardware for them using system calls. - -At the binary level, making a system call is a bit different from making a simple function call, but most programs use wrappers in a standard library. E.g. the POSIX C standard library contains a `write()` function call that contains all the architecture-dependent code for making the `write` system call. - -![][4] - -In short, an application’s interaction with its environment (the computer system) is all done through system calls. So when software works on one machine but not another, looking at system call traces is a good way to find what’s wrong. More specifically, here are the typical things you can analyse using a system call trace: - - * Console input and output (IO) - * Network IO - * Filesystem access and file IO - * Process/thread lifetime management - * Raw memory management - * Access to special device drivers - - - -### When can `strace` be used? - -In theory, `strace` can be used with any userspace program because all userspace programs have to make system calls. It’s more effective with compiled, lower-level programs, but still works with high-level languages like Python if you can wade through the extra noise from the runtime environment and interpreter. - -`strace` shines with debugging software that works fine on one machine, but on another machine fails with a vague error message about files or permissions or failure to run some command or something. Unfortunately, it’s not so great with higher-level problems, like a certificate verification failure. They usually need a combination of `strace`, sometimes [`ltrace`][5], and higher-level tooling (like the `openssl` command line tool for certificate debugging). - -The examples in this post are based on a standalone server, but system call tracing can often be done on more complicated deployment platforms, too. Just search for appropriate tooling. - -### A simple debugging example - -Let’s say you’re trying to run an awesome server application called foo, but here’s what happens: - -``` -$ foo -Error opening configuration file: No such file or directory -``` - -Obviously it’s not finding the configuration file that you’ve written. This can happen because package managers sometimes customise the expected locations of files when compiling an application, so following an installation guide for one distro leads to files in the wrong place on another distro. You could fix the problem in a few seconds if only the error message told you where the configuration file is expected to be, but it doesn’t. How can you find out? - -If you have access to the source code, you could read it and work it out. That’s a good fallback plan, but not the fastest solution. You also could use a stepping debugger like `gdb` to see what the program does, but it’s more efficient to use a tool that’s specifically designed to show the interaction with the environment: `strace`. - -The output of `strace` can be a bit overwhelming at first, but the good news is that you can ignore most of it. It often helps to use the `-o` switch to save the trace to a separate file: - -``` -$ strace -o /tmp/trace foo -Error opening configuration file: No such file or directory -$ cat /tmp/trace -execve("foo", ["foo"], 0x7ffce98dc010 /* 16 vars */) = 0 -brk(NULL) = 0x56363b3fb000 -access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) -openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 -fstat(3, {st_mode=S_IFREG|0644, st_size=25186, ...}) = 0 -mmap(NULL, 25186, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2f12cf1000 -close(3) = 0 -openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 -read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260A\2\0\0\0\0\0"..., 832) = 832 -fstat(3, {st_mode=S_IFREG|0755, st_size=1824496, ...}) = 0 -mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2f12cef000 -mmap(NULL, 1837056, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f2f12b2e000 -mprotect(0x7f2f12b50000, 1658880, PROT_NONE) = 0 -mmap(0x7f2f12b50000, 1343488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f2f12b50000 -mmap(0x7f2f12c98000, 311296, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16a000) = 0x7f2f12c98000 -mmap(0x7f2f12ce5000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b6000) = 0x7f2f12ce5000 -mmap(0x7f2f12ceb000, 14336, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f2f12ceb000 -close(3) = 0 -arch_prctl(ARCH_SET_FS, 0x7f2f12cf0500) = 0 -mprotect(0x7f2f12ce5000, 16384, PROT_READ) = 0 -mprotect(0x56363b08b000, 4096, PROT_READ) = 0 -mprotect(0x7f2f12d1f000, 4096, PROT_READ) = 0 -munmap(0x7f2f12cf1000, 25186) = 0 -openat(AT_FDCWD, "/etc/foo/config.json", O_RDONLY) = -1 ENOENT (No such file or directory) -dup(2) = 3 -fcntl(3, F_GETFL) = 0x2 (flags O_RDWR) -brk(NULL) = 0x56363b3fb000 -brk(0x56363b41c000) = 0x56363b41c000 -fstat(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x8), ...}) = 0 -write(3, "Error opening configuration file"..., 60) = 60 -close(3) = 0 -exit_group(1) = ? -+++ exited with 1 +++ -``` - -The first page or so of `strace` output is typically low-level process startup. (You can see a lot of `mmap`, `mprotect`, `brk` calls for things like allocating raw memory and mapping dynamic libraries.) Actually, when debugging an error, `strace` output is best read from the bottom up. You can see the `write` call that outputs the error message at the end. If you work up, the first failing system call is the `openat` call that fails with `ENOENT` (“No such file or directory”) trying to open `/etc/foo/config.json`. And now we know where the configuration file is supposed to be. - -That’s a simple example, but I’d say at least 90% of the time I use `strace`, I’m not doing anything more complicated. Here’s the complete debugging formula step-by-step: - - 1. Get frustrated by a vague system-y error message from a program - 2. Run the program again with `strace` - 3. Find the error message in the trace - 4. Work upwards to find the first failing system call - - - -There’s a very good chance the system call in step 4 shows you what went wrong. - -### Some tips - -Before walking through a more complicated example, here are some useful tips for using `strace` effectively: - -#### `man` is your friend - -On many *nix systems, you can get a list of all kernel system calls by running `man syscalls`. You’ll see things like `brk(2)`, which means you can get more information by running `man 2 brk`. - -One little gotcha: `man 2 fork` shows me the man page for the `fork()` wrapper in GNU `libc`, which is actually now implemented using the `clone` system call instead. The semantics of `fork` are the same, but if I write a program using `fork()` and `strace` it, I won’t find any `fork` calls in the trace, just `clone` calls. Gotchas like that are only confusing if you’re comparing source code to `strace` output. - -#### Use `-o` to save output to a file - -`strace` can generate a lot of output so it’s often helpful to store the trace in a separate file (as in the example above). It also avoids mixing up program output with `strace` output in the console. - -#### Use `-s` to see more argument data - -You might have noticed that the second part of the error message doesn’t appear in the example trace above. That’s because `strace` only shows the first 32 bytes of string arguments by default. If you need to capture more, add something like `-s 128` to the `strace` invocation. - -#### `-y` makes it easier to track files/sockets/etc - -“Everything is a file” means *nix systems do all IO using file descriptors, whether it’s to an actual file or over networks or through interprocess pipes. That’s convenient for programming, but makes it harder to follow what’s really going on when you see generic `read` and `write` in the system call trace. - -Adding the `-y` switch makes `strace` annotate every file descriptor in the output with a note about what it points to. - -#### Attach to an already-running process with `-p` - -As we’ll see in the example later, sometimes you want to trace a program that’s already running. If you know it’s running as process 1337 (say, by looking at the output of `ps`), you can trace it like this: - -``` -$ strace -p 1337 -...system call trace output... -``` - -You probably need root. - -#### Use `-f` to follow child processes - -By default, `strace` only traces the one process. If that process spawns a child process, you’ll see the system call for spawning the process (normally `clone` nowadays), but not any of the calls made by the child process. - -If you think the bug is in a child process, you’ll need to use the `-f` switch to enable tracing it. A downside is that the output can be more confusing. When tracing one process and one thread, `strace` can show you a single stream of call events. When tracing multiple processes, you might see the start of a call cut off with ``, then a bunch of calls for other threads of execution, before seeing the end of the original call with `<... foocall resumed>`. Alternatively, you can separate all the traces into different files by using the `-ff` switch as well (see [the `strace` manual][6] for details). - -#### You can filter the trace with `-e` - -As you’ve seen, the default trace output is a firehose of all system calls. You can filter which calls get traced using the `-e` flag (see [the `strace` manual][6]). The main advantage is that it’s faster to run the program under a filtered `strace` than to trace everything and `grep` the results later. Honestly, I don’t bother most of the time. - -#### Not all errors are bad - -A simple and common example is a program searching for a file in multiple places, like a shell searching for which `bin/` directory has an executable: - -``` -$ strace sh -c uname -... -stat("/home/user/bin/uname", 0x7ffceb817820) = -1 ENOENT (No such file or directory) -stat("/usr/local/bin/uname", 0x7ffceb817820) = -1 ENOENT (No such file or directory) -stat("/usr/bin/uname", {st_mode=S_IFREG|0755, st_size=39584, ...}) = 0 -... -``` - -The “last failed call before the error message” heuristic is pretty good at finding relevent errors. In any case, working from the bottom up makes sense. - -#### C programming guides are good for understanding system calls - -Standard C library calls aren’t system calls, but they’re only thin layers on top. So if you understand (even just roughly) how to do something in C, it’s easier to read a system call trace. For example, if you’re having trouble debugging networking system calls, you could try skimming through [Beej’s classic Guide to Network Programming][7]. - -### A more complicated debugging example - -As I said, that simple debugging example is representative of most of my `strace` usage. However, sometimes a little more detective work is required, so here’s a slightly more complicated (and real) example. - -[`bcron`][8] is a job scheduler that’s yet another implementation of the classic *nix `cron` daemon. It’s been installed on a server, but here’s what happens when someone tries to edit a job schedule: - -``` -# crontab -e -u logs -bcrontab: Fatal: Could not create temporary file -``` - -Okay, so bcron tried to write some file, but it couldn’t, and isn’t telling us why. This is a debugging job for `strace`: - -``` -# strace -o /tmp/trace crontab -e -u logs -bcrontab: Fatal: Could not create temporary file -# cat /tmp/trace -... -openat(AT_FDCWD, "bcrontab.14779.1573691864.847933", O_RDONLY) = 3 -mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f82049b4000 -read(3, "#Ansible: logsagg\n20 14 * * * lo"..., 8192) = 150 -read(3, "", 8192) = 0 -munmap(0x7f82049b4000, 8192) = 0 -close(3) = 0 -socket(AF_UNIX, SOCK_STREAM, 0) = 3 -connect(3, {sa_family=AF_UNIX, sun_path="/var/run/bcron-spool"}, 110) = 0 -mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f82049b4000 -write(3, "156:Slogs\0#Ansible: logsagg\n20 1"..., 161) = 161 -read(3, "32:ZCould not create temporary f"..., 8192) = 36 -munmap(0x7f82049b4000, 8192) = 0 -close(3) = 0 -write(2, "bcrontab: Fatal: Could not creat"..., 49) = 49 -unlink("bcrontab.14779.1573691864.847933") = 0 -exit_group(111) = ? -+++ exited with 111 +++ -``` - -There’s the error message `write` near the end, but a couple of things are different this time. First, there’s no relevant system call error that happens before it. Second, we see that the error message has just been `read` from somewhere else. It looks like the real problem is happening somewhere else, and `bcrontab` is just replaying the message. - -If you look at `man 2 read`, you’ll see that the first argument (the 3) is a file descriptor, which is what *nix uses for all IO handles. How do you know what file descriptor 3 represents? In this specific case, you could run `strace` with the `-y` switch (as explained above) and it would tell you automatically, but it’s useful to know how to read and analyse traces to figure things like this out. - -A file descriptor can come from one of many system calls (depending on whether it’s a descriptor for the console, a network socket, an actual file, or something else), but in any case we can search for calls returning 3 (i.e., search for “= 3” in the trace). There are two in this trace: the `openat` at the top, and the `socket` in the middle. `openat` opens a file, but the `close(3)` afterwards shows that it gets closed again. (Gotcha: file descriptors can be reused as they’re opened and closed.) The `socket` call is the relevant one (it’s the last one before the `read`), which tells us `bcrontab` is talking to something over a network socket. The next line, `connect` shows file descriptor 3 being configured as a Unix domain socket connection to `/var/run/bcron-spool`. - -So now we need to figure out what’s listening on the other side of the Unix socket. There are a couple of neat tricks for that, both useful for debugging server deployments. One is to use `netstat` or the newer `ss` (“socket status”). Both commands describe active network sockets on the system, and take the `-l` switch for describing listening (server) sockets, and the `-p` switch to get information about what program is using the socket. (There are many more useful options, but those two are enough to get this job done.) - -``` -# ss -pl | grep /var/run/bcron-spool -u_str LISTEN 0 128 /var/run/bcron-spool 1466637 * 0 users:(("unixserver",pid=20629,fd=3)) -``` - -That tells us that the listener is a command `unixserver` running as process ID 20629. (It’s a coincidence that it’s also using file descriptor 3 for the socket.) - -The second really useful tool for finding the same information is `lsof`. It can list all open files (or file descriptors) on the system. Alternatively, we can get information about a specific file: - -``` -# lsof /var/run/bcron-spool -COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME -unixserve 20629 cron 3u unix 0x000000005ac4bd83 0t0 1466637 /var/run/bcron-spool type=STREAM -``` - -Process 20629 is a long-running server, so we can attach `strace` to it using something like `strace -o /tmp/trace -p 20629`. If we then try to edit the cron schedule in another terminal, we can capture a trace while the error is happening. Here’s the result: - -``` -accept(3, NULL, NULL) = 4 -clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7faa47c44810) = 21181 -close(4) = 0 -accept(3, NULL, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set) ---- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=21181, si_uid=998, si_status=0, si_utime=0, si_stime=0} --- -wait4(0, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG|WSTOPPED, NULL) = 21181 -wait4(0, 0x7ffe6bc36764, WNOHANG|WSTOPPED, NULL) = -1 ECHILD (No child processes) -rt_sigaction(SIGCHLD, {sa_handler=0x55d244bdb690, sa_mask=[CHLD], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7faa47ab9840}, {sa_handler=0x55d244bdb690, sa_mask=[CHLD], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7faa47ab9840}, 8) = 0 -rt_sigreturn({mask=[]}) = 43 -accept(3, NULL, NULL) = 4 -clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7faa47c44810) = 21200 -close(4) = 0 -accept(3, NULL, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set) ---- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=21200, si_uid=998, si_status=111, si_utime=0, si_stime=0} --- -wait4(0, [{WIFEXITED(s) && WEXITSTATUS(s) == 111}], WNOHANG|WSTOPPED, NULL) = 21200 -wait4(0, 0x7ffe6bc36764, WNOHANG|WSTOPPED, NULL) = -1 ECHILD (No child processes) -rt_sigaction(SIGCHLD, {sa_handler=0x55d244bdb690, sa_mask=[CHLD], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7faa47ab9840}, {sa_handler=0x55d244bdb690, sa_mask=[CHLD], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7faa47ab9840}, 8) = 0 -rt_sigreturn({mask=[]}) = 43 -accept(3, NULL, NULL -``` - -(The last `accept` doesn’t complete during the trace period.) Unfortunately, once again, this trace doesn’t contain the error we’re after. We don’t see any of the messages that we saw `bcrontab` sending to and receiving from the socket. Instead, we see a lot of process management (`clone`, `wait4`, `SIGCHLD`, etc.). This process is spawning a child process, which we can guess is doing the real work. If we want to catch a trace of that, we have to add `-f` to the `strace` invocation. Here’s what we find if we search for the error message after getting a new trace with `strace -f -o /tmp/trace -p 20629`: - -``` -21470 openat(AT_FDCWD, "tmp/spool.21470.1573692319.854640", O_RDWR|O_CREAT|O_EXCL, 0600) = -1 EACCES (Permission denied) -21470 write(1, "32:ZCould not create temporary f"..., 36) = 36 -21470 write(2, "bcron-spool[21470]: Fatal: logs:"..., 84) = 84 -21470 unlink("tmp/spool.21470.1573692319.854640") = -1 ENOENT (No such file or directory) -21470 exit_group(111) = ? -21470 +++ exited with 111 +++ -``` - -Now we’re getting somewhere. Process ID 21470 is getting a permission denied error trying to create a file at the path `tmp/spool.21470.1573692319.854640` (relative to the current working directory). If we just knew the current working directory, we would know the full path and could figure out why the process can’t create create its temporary file there. Unfortunately, the process has already exited, so we can’t just use `lsof -p 21470` to find out the current directory, but we can work backwards looking for PID 21470 system calls that change directory. (If there aren’t any, PID 21470 must have inherited it from its parent, and we can `lsof -p` that.) That system call is `chdir` (which is easy to find out using today’s web search engines). Here’s the result of working backwards through the trace, all the way to the server PID 20629: - -``` -20629 clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7faa47c44810) = 21470 -... -21470 execve("/usr/sbin/bcron-spool", ["bcron-spool"], 0x55d2460807e0 /* 27 vars */) = 0 -... -21470 chdir("/var/spool/cron") = 0 -... -21470 openat(AT_FDCWD, "tmp/spool.21470.1573692319.854640", O_RDWR|O_CREAT|O_EXCL, 0600) = -1 EACCES (Permission denied) -21470 write(1, "32:ZCould not create temporary f"..., 36) = 36 -21470 write(2, "bcron-spool[21470]: Fatal: logs:"..., 84) = 84 -21470 unlink("tmp/spool.21470.1573692319.854640") = -1 ENOENT (No such file or directory) -21470 exit_group(111) = ? -21470 +++ exited with 111 +++ -``` - -(If you’re getting lost here, you might want to read [my previous post about *nix process management and shells][9].) Okay, so the server PID 20629 doesn’t have permission to create a file at `/var/spool/cron/tmp/spool.21470.1573692319.854640`. The most likely reason would be classic *nix filesystem permission settings. Let’s check: - -``` -# ls -ld /var/spool/cron/tmp/ -drwxr-xr-x 2 root root 4096 Nov 6 05:33 /var/spool/cron/tmp/ -# ps u -p 20629 -USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND -cron 20629 0.0 0.0 2276 752 ? Ss Nov14 0:00 unixserver -U /var/run/bcron-spool -- bcron-spool -``` - -There’s the problem! The server is running as user `cron`, but only `root` has permissions to write to that `/var/spool/cron/tmp/` directory. A simple `chown cron /var/spool/cron/tmp/` makes `bcron` work properly. (If that weren’t the problem, the next most likely suspect would be a kernel security module like SELinux or AppArmor, so I’d check the kernel logs with `dmesg`.) - -### Summary - -System call traces can be overwhelming at first, but I hope I’ve shown that they’re a fast way to debug a whole class of common deployment problems. Imagine trying to debug that multi-process `bcron` problem using a stepping debugger. - -Working back through a chain of system calls takes practice, but as I said, most of the time I use `strace` I just get a trace and look for errors, working from the bottom up. In any case, `strace` has saved me hours and hours of debugging time. I hope it’s useful for you, too. - --------------------------------------------------------------------------------- - -via: https://theartofmachinery.com/2019/11/14/deployment_debugging_strace.html - -作者:[Simon Arneaud][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://theartofmachinery.com -[b]: https://github.com/lujun9972 -[1]: https://strace.io/ -[2]: http://dtrace.org/blogs/about/ -[3]: https://man.openbsd.org/ktrace -[4]: https://theartofmachinery.com/images/strace/system_calls.svg -[5]: https://linux.die.net/man/1/ltrace -[6]: https://linux.die.net/man/1/strace -[7]: https://beej.us/guide/bgnet/html/index.html -[8]: https://untroubled.org/bcron/ -[9]: https://theartofmachinery.com/2018/11/07/writing_a_nix_shell.html diff --git a/sources/tech/20191115 Developing a Simple Web Application Using Flutter.md b/sources/tech/20191115 Developing a Simple Web Application Using Flutter.md deleted file mode 100644 index 677ed567ee..0000000000 --- a/sources/tech/20191115 Developing a Simple Web Application Using Flutter.md +++ /dev/null @@ -1,150 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Developing a Simple Web Application Using Flutter) -[#]: via: (https://opensourceforu.com/2019/11/developing-a-simple-web-application-using/) -[#]: author: (Jis Joe Mathew https://opensourceforu.com/author/jis-joe/) - -Developing a Simple Web Application Using Flutter -====== - -[![][1]][2] - -_This article guides readers on how to run and deploy their first Web application using Flutter._ - -Flutter has moved to a new stage, the Web, after having travelled a long way in Android and iOS development. Flutter 1.5 has been released by Google, along with support for Web application development. - -**Configuring Flutter for the Web** -In order to use the Web package, enter the _flutter upgrade_ command to update to Flutter version 1.5.4. - - * Open a terminal - * Type flutter upgrade - * Check the version by typing _flutter –version_ - - - -![Figure 1: Upgrading Flutter to the latest version][3] - -![Figure 2: Starting a new Flutter Web project in VSC][4] - -One can also use Android Studio 3.0 or later versions for Flutter Web development, but we will use Visual Studio Code for this tutorial. - -**Creating a new project with Flutter Web** -Open Visual Studio Code and press _Shift+Ctrl+P_ to start a new project. Type flutter and select _New Web Project_. -Now, name the project. I have named it _open_source_for_you_. -Open the terminal window in VSC, and type in the following commands: - -``` -flutter packages pub global activate webdev - -flutter packages upgrade -``` - -Now use the following command to run the website, on localhost, with the IP address 127.0.0.1 - -``` -flutter packages pub global run webdev serve -``` - -Open any browser and type, __ -There is a Web folder inside the project directory which contains an _index.html_ file. The _dart_ file is compiled into a JavaScript file and is included in the HTML file using the following code: - -``` - -``` - -**Coding and making changes to the demo page** -Let’s create a simple application, which will print ‘Welcome to OSFY’ on the Web page. -Let’s now open the Dart file, which is located in the _lib_ folder _main.dart_ (the default name) (see Figure 5). -We can now remove the debug tag using the property of _MaterialApp_, as follows: - -``` -debugShowCheckedModeBanner: false -``` - -![Figure 3: Naming the project][5] - -![Figure 4: The Flutter demo application running on port 8080][6] - -![Figure 5: Location of main.dart file][7] - -Now, adding more into the Dart file is very similar to writing code in Flutter in Dart. For that, we can declare a class titled _MyClass_, which extends the _StatelessWidget_. -We use a _Center_ widget to position elements to the centre. We can also add a _Padding_ widget to add padding. Use the following code to obtain the output shown in Figure 5. Use the Refresh button to view the changes. - -``` -class MyClass extends StatelessWidget { -@override -Widget build(BuildContext context) { -return Scaffold( -body: Center( -child: Column( -mainAxisAlignment: MainAxisAlignment.center, -children: [ -Padding( -padding: EdgeInsets.all(20.0), -child: Text( -'Welcome to OSFY', -style: TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold), -), -), -], -), -), -); -} -} -``` - -![Figure 6: Output of MyClass][8] - -![Figure 7: Final output][9] - -Let’s add an image from the Internet – I’ve chosen the ‘Open Source for You’ logo from the magazine’s website. We use _Image.network_. - -``` -Image.network( -'https://opensourceforu.com/wp-content/uploads/2014/03/OSFY-Logo.jpg', -height: 100, -width: 150 -), -``` - -The final output is shown in Figure 7. - -![Avatar][10] - -[Jis Joe Mathew][11] - -The author is assistant professor of computer science and engineering at Amal Jyoti College, Kanirapally, Kerala. He can be contacted at [jisjoemathew@gmail.com][12]. - -[![][13]][14] - --------------------------------------------------------------------------------- - -via: https://opensourceforu.com/2019/11/developing-a-simple-web-application-using/ - -作者:[Jis Joe Mathew][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensourceforu.com/author/jis-joe/ -[b]: https://github.com/lujun9972 -[1]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Screenshot-from-2019-11-15-16-20-30.png?resize=696%2C495&ssl=1 (Screenshot from 2019-11-15 16-20-30) -[2]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Screenshot-from-2019-11-15-16-20-30.png?fit=900%2C640&ssl=1 -[3]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-1-Upgrading-Flutter-to-the-latest-version.jpg?resize=350%2C230&ssl=1 -[4]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-2-Starting-a-new-Flutter-Web-project-in-VSC.jpg?resize=350%2C93&ssl=1 -[5]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-3-Naming-the-project.jpg?resize=350%2C147&ssl=1 -[6]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-4-The-Flutter-demo-application-running-on-port-8080.jpg?resize=350%2C111&ssl=1 -[7]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-5-Location-of-main.dart-file.jpg?resize=350%2C173&ssl=1 -[8]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-6-Output-of-MyClass.jpg?resize=350%2C173&ssl=1 -[9]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-7-Final-output.jpg?resize=350%2C167&ssl=1 -[10]: https://secure.gravatar.com/avatar/64db0e07799ae14fd1b51d0633db6593?s=100&r=g -[11]: https://opensourceforu.com/author/jis-joe/ -[12]: mailto:jisjoemathew@gmail.com -[13]: https://opensourceforu.com/wp-content/uploads/2019/11/assoc.png -[14]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US diff --git a/sources/tech/20191115 How to port an awk script to Python.md b/sources/tech/20191115 How to port an awk script to Python.md deleted file mode 100644 index 2476fb079d..0000000000 --- a/sources/tech/20191115 How to port an awk script to Python.md +++ /dev/null @@ -1,212 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to port an awk script to Python) -[#]: via: (https://opensource.com/article/19/11/awk-to-python) -[#]: author: (Moshe Zadka https://opensource.com/users/moshez) - -How to port an awk script to Python -====== -Porting an awk script to Python is more about code style than -transliteration. -![Woman sitting in front of her laptop][1] - -Scripts are potent ways to solve a problem repeatedly, and awk is an excellent language for writing them. It excels at easy text processing in particular, and it can bring you through some complicated rewriting of config files or reformatting file names in a directory.  - -### When to move from awk to Python - -At some point, however, awk's limitations start to show. It has no real concept of breaking files into modules, it lacks quality error reporting, and it's missing other things that are now considered fundamentals of how a language works. When these rich features of a programming language are helpful to maintain a critical script, porting becomes a good option. - -My favorite modern programming language that is perfect for porting awk is Python. - -Before porting an awk script to Python, it is often worthwhile to consider its original context. For example, because of awk's limitations, the awk code is commonly called from a Bash script and includes some calls to other command-line favorites like sed, sort, and the gang. It's best to convert all of it into one coherent Python program. Other times, the script makes overly broad assumptions; for example, the code might allow for any number of files, even though it's run with only one in practice. - -After carefully considering the context and determining the thing to substitute with Python, it is time to write code. - -### Standard awk to Python functionality - -The following Python functionality is useful to remember: - - -``` -with open(some_file_name) as fpin: -    for line in fpin: -        pass # do something with line -``` - -This code will loop through a file line-by-line and process the lines. - -If you want to access a line number (equivalent to awk's **NR**), you can use the following code: - - -``` -with open(some_file_name) as fpin: -    for nr, line in enumerate(fpin): -        pass # do something with line -``` - -### awk-like behavior over multiple files in Python - -If you need to be able to iterate through any number of files while keeping a persistent count of the number of lines (like awk's **FNR**), this loop can do it: - - -``` -def awk_like_lines(list_of_file_names): -    def _all_lines(): -        for filename in list_of_file_names: -            with open(filename) as fpin: -                yield from fpin -    yield from enumerate(_all_lines()) -``` - -This syntax uses Python's _generators_ and **yield from** to build an _iterator_ that loops through all lines and keeps a persistent count. - -If you need the equivalent of both **FNR** and **NR**, here is a more sophisticated loop: - - -``` -def awk_like_lines(list_of_file_names): -    def _all_lines(): -        for filename in list_of_file_names: -            with open(filename) as fpin: -                yield from enumerate(fpin) -    for nr, (fnr, line) in _all_lines: -        yield nr, fnr, line -``` - -### More complex awk functionality with FNR, NR, and line - -The question remains if you need all three: **FNR**, **NR**, and **line**. If you really do, using a three-tuple where two of the items are numbers can lead to confusion. Named parameters can make this code easier to read, so it's better to use a **dataclass**: - - -``` -import dataclass - -@dataclass.dataclass(frozen=True) -class AwkLikeLine: -    content: str -    fnr: int -    nr: int - -def awk_like_lines(list_of_file_names): -    def _all_lines(): -        for filename in list_of_file_names: -            with open(filename) as fpin: -                yield from enumerate(fpin) -    for nr, (fnr, line) in _all_lines: -        yield AwkLikeLine(nr=nr, fnr=fnr, line=line) -``` - -You might wonder, why not start with this approach? The reason to start elsewhere is that this is almost always too complicated. If your goal is to make a generic library that makes porting awk to Python easier, then consider doing so. But writing a loop that gets you exactly what you need for a specific case is usually easier to do and easier to understand (and thus maintain). - -### Understanding awk fields - -Once you have a string that corresponds to a line, if you are converting an awk program, you often want to break it up into _fields_. Python has several ways of doing that. This will return a list of strings, splitting the line on any number of consecutive whitespaces: - - -``` -`line.split()` -``` - -If another field separator is needed, something like this will split the line by **:**; the **rstrip** method is needed to remove the last newline: - - -``` -`line.rstrip("\n").split(":")` -``` - -After doing the following, the list **parts** will have the broken-up string: - - -``` -`parts = line.rstrip("\n").split(":")` -``` - -This split is good for choosing what to do with the parameters, but we are in an [off-by-one error][2] scenario. Now **parts[0]** will correspond to awk's **$1**, **parts[1]** will correspond to awk's **$2**, etc. This off-by-one is because awk starts counting the "fields" from 1, while Python counts from 0. In awk's **$0** is the whole line -- equivalent to **line.rstrip("\n") **and awk's **NF** (number of fields) is more easily retrieved as **len(parts)**. - -### Porting awk fields in Python - -As an example, let's convert the one-liner from "[How to remove duplicate lines from files with awk][3]" to Python. - -The original in awk is: - - -``` -`awk '!visited[$0]++' your_file > deduplicated_file` -``` - -An "authentic" Python conversion would be: - - -``` -import collections -import sys - -visited = collections.defaultdict(int) -for line in open("your_file"): -    did_visit = visited[line] -    visited[line] += 1 -    if not did_visit: -        sys.stdout.write(line) -``` - -However, Python has more data structures than awk. Instead of _counting_ visits (which we do not use, except to know whether we saw a line), why not record the visited lines? - - -``` -import sys - -visited = set() -for line in open("your_file"): -    if line in visited: -        continue -    visited.add(line) -    sys.stdout.write(line) -``` - -### Making Pythonic awk code - -The Python community advocates for writing Pythonic code, which means it follows a commonly agreed-upon code style. An even more Pythonic approach will separate the concerns of _uniqueness_ and _input/output_. This change would make it easier to unit test your code: - - -``` -def unique_generator(things): -    visited = set() -    for thing in things: -        if thing in visited: -            continue -        visited.add(things) -        yield thing - -import sys -    -for line in unique_generator(open("your_file")): -    sys.stdout.write(line) -``` - -Putting all logic away from the input/output code leads to better separation of concerns and more usability and testability of code. - -### Conclusion: Python can be a good choice  - -Porting an awk script to Python is often more a matter of reimplementing the core requirements while thinking about proper Pythonic code style than a slavish transliteration of condition/action by condition/action. Take the original context into account and produce a quality Python solution. While there are times when a Bash one-liner with awk can get the job done, Python coding is a path toward more easily maintainable code. - -Also, if you're writing awk scripts, I am confident you can learn Python as well! Let me know if you have any questions in the comments. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/11/awk-to-python - -作者:[Moshe Zadka][a] -选题:[lujun9972][b] -译者:[译者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/moshez -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_women_computing_4.png?itok=VGZO8CxT (Woman sitting in front of her laptop) -[2]: https://en.wikipedia.org/wiki/Off-by-one_error -[3]: https://opensource.com/article/19/10/remove-duplicate-lines-files-awk diff --git a/sources/tech/20191117 How to Install VirtualBox 6.0 on CentOS 8 - RHEL 8.md b/sources/tech/20191117 How to Install VirtualBox 6.0 on CentOS 8 - RHEL 8.md deleted file mode 100644 index 094218c6c4..0000000000 --- a/sources/tech/20191117 How to Install VirtualBox 6.0 on CentOS 8 - RHEL 8.md +++ /dev/null @@ -1,160 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to Install VirtualBox 6.0 on CentOS 8 / RHEL 8) -[#]: via: (https://www.linuxtechi.com/install-virtualbox-6-centos-8-rhel-8/) -[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) - -How to Install VirtualBox 6.0 on CentOS 8 / RHEL 8 -====== - -**VirtualBox** is a free and open source **virtualization tool** which allows techies to run multiple virtual machines of different flavor at the same time. It is generally used at desktop level (Linux and Windows), it becomes very handy when someone try to explore the features of new Linux distribution or want to install software like **OpenStack**, **Ansible** and **Puppet** in one VM, so in such scenarios one can launch a VM using VirtualBox. - -VirtualBox is categorized as **type 2 hypervisor** which means it requires an existing operating system, on top of which VirtualBox software will be installed. VirtualBox provides features to create our own custom host only network and NAT network. In this article we will demonstrate how to install latest version of VirtualBox 6.0 on CentOS 8 and RHEL 8 System and will also demonstrate on how to install VirtualBox Extensions. - -### Installation steps of VirtualBox 6.0 on CentOS 8 / RHEL 8 - -#### Step:1) Enable VirtualBox and EPEL Repository - -Login to your CentOS 8 or RHEL 8 system and open terminal and execute the following commands to enable VirtualBox and EPEL package repository. - -``` -[root@linuxtechi ~]# dnf config-manager --add-repo=https://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo -``` - -Use below rpm command to import Oracle VirtualBox Public Key - -``` -[root@linuxtechi ~]# rpm --import https://www.virtualbox.org/download/oracle_vbox.asc -``` - -Enable EPEL repo using following dnf command, - -``` -[root@linuxtechi ~]# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y -``` - -#### Step:2) Install VirtualBox Build tools and dependencies - -Run the following command to install all VirtualBox build tools and dependencies, - -``` -[root@linuxtechi ~]# dnf install binutils kernel-devel kernel-headers libgomp make patch gcc glibc-headers glibc-devel dkms -y -``` - -Once above dependencies and build tools are installed successfully then proceed with VirtualBox installation using dnf command, - -#### Step:3) Install VirtualBox 6.0 on CentOS 8 / RHEL 8 - -If wish to list available versions of VirtualBox before installing it , then execute the following [dnf command][1], - -``` -[root@linuxtechi ~]# dnf search virtualbox -Last metadata expiration check: 0:14:36 ago on Sun 17 Nov 2019 04:13:16 AM GMT. -=============== Summary & Name Matched: virtualbox ===================== -VirtualBox-5.2.x86_64 : Oracle VM VirtualBox -VirtualBox-6.0.x86_64 : Oracle VM VirtualBox -[root@linuxtechi ~]# -``` - -Let’s install latest version of VirtualBox 6.0 using following dnf command, - -``` -[root@linuxtechi ~]# dnf install VirtualBox-6.0 -y -``` - -If any local user want to attach usb device to VirtualBox VMs then he/she should be part “**vboxuser**s ” group, use the beneath usermod command to add local user to “vboxusers” group. - -``` -[root@linuxtechi ~]# usermod -aG vboxusers pkumar -``` - -#### Step:4) Access VirtualBox on CentOS 8 / RHEL 8 - -There are two ways to access VirtualBox, from the command line type “**virtualbox**” then hit enter - -``` -[root@linuxtechi ~]# virtualbox -``` - -From Desktop environment, Search “VirtualBox” from Search Dash. - -[![Access-VirtualBox-CentOS8][2]][3] - -Click on VirtualBox icon, - -[![VirtualBox-CentOS8][2]][4] - -This confirms that VirtualBox 6.0 has been installed successfully, let’s install its extension pack. - -#### Step:5) Install VirtualBox 6.0 Extension Pack - -As the name suggests, VirtualBox extension pack is used to extend the functionality of VirtualBox. It adds the following features: - - * USB 2.0 & USB 3.0 support - * Virtual RDP (VRDP) - * Disk Image Encryption - * Intel PXE Boot - * Host WebCam - - - -Use below wget command to download virtualbox extension pack under download folder, - -``` -[root@linuxtechi ~]$ cd Downloads/ -[root@linuxtechi Downloads]$ wget https://download.virtualbox.org/virtualbox/6.0.14/Oracle_VM_VirtualBox_Extension_Pack-6.0.14.vbox-extpack -``` - -Once it is downloaded, access VirtualBox and navigate **File** –>**Preferences** –> **Extension** then click on + icon to add downloaded extension pack, - -[![Install-VirtualBox-Extension-Pack-CentOS8][2]][5] - -Click on “Install” to start the installation of extension pack. - -[![Accept-VirtualBox-Extension-Pack-License-CentOS8][2]][6] - -Click on “I Agree” to accept VirtualBox Extension Pack License. - -After successful installation of VirtualBox extension pack, we will get following screen, Click on Ok and start using VirtualBox. - -[![VirtualBox-Extension-Pack-Install-Message-CentOS8][2]][7] - -That’s all from this article, I hope these steps help you install VirtualBox 6.0 on your CentOS 8 and RHEL 8 system. Please do share your valuable feedback and comments. - -**Also Read**: **[How to Manage Oracle VirtualBox Virtual Machines from Command Line][8]** - - * [Facebook][9] - * [Twitter][10] - * [LinkedIn][11] - * [Reddit][12] - - - --------------------------------------------------------------------------------- - -via: https://www.linuxtechi.com/install-virtualbox-6-centos-8-rhel-8/ - -作者:[Pradeep Kumar][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.linuxtechi.com/author/pradeep/ -[b]: https://github.com/lujun9972 -[1]: https://www.linuxtechi.com/dnf-command-examples-rpm-management-fedora-linux/ -[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[3]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Access-VirtualBox-CentOS8.jpg -[4]: https://www.linuxtechi.com/wp-content/uploads/2019/11/VirtualBox-CentOS8.jpg -[5]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Install-VirtualBox-Extension-Pack-CentOS8.jpg -[6]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Accept-VirtualBox-Extension-Pack-License-CentOS8.jpg -[7]: https://www.linuxtechi.com/wp-content/uploads/2019/11/VirtualBox-Extension-Pack-Install-Message-CentOS8.jpg -[8]: https://www.linuxtechi.com/manage-virtualbox-virtual-machines-command-line/ -[9]: http://www.facebook.com/sharer.php?u=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-virtualbox-6-centos-8-rhel-8%2F&t=How%20to%20Install%20VirtualBox%206.0%20on%20CentOS%208%20%2F%20RHEL%208 -[10]: http://twitter.com/share?text=How%20to%20Install%20VirtualBox%206.0%20on%20CentOS%208%20%2F%20RHEL%208&url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-virtualbox-6-centos-8-rhel-8%2F&via=Linuxtechi -[11]: http://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-virtualbox-6-centos-8-rhel-8%2F&title=How%20to%20Install%20VirtualBox%206.0%20on%20CentOS%208%20%2F%20RHEL%208 -[12]: http://www.reddit.com/submit?url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-virtualbox-6-centos-8-rhel-8%2F&title=How%20to%20Install%20VirtualBox%206.0%20on%20CentOS%208%20%2F%20RHEL%208 diff --git a/sources/tech/20191118 How internet security works- TLS, SSL, and CA.md b/sources/tech/20191118 How internet security works- TLS, SSL, and CA.md deleted file mode 100644 index 9746ca39d2..0000000000 --- a/sources/tech/20191118 How internet security works- TLS, SSL, and CA.md +++ /dev/null @@ -1,57 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How internet security works: TLS, SSL, and CA) -[#]: via: (https://opensource.com/article/19/11/internet-security-tls-ssl-certificate-authority) -[#]: author: (Bryant Son https://opensource.com/users/brson) - -How internet security works: TLS, SSL, and CA -====== -What's behind that lock icon in your web browser? -![Lock][1] - -Multiple times every day, you visit websites that ask you to log in with your username or email address and password. Banking websites, social networking sites, email services, e-commerce sites, and news sites are just a handful of the types of sites that use this mechanism. - -Every time you sign into one of these sites, you are, in essence, saying, "yes, I trust this website, so I am willing to share my personal information with it." This data may include your name, gender, physical address, email address, and sometimes even credit card information. - -But how do you know you can trust a particular website? To put this a different way, what is the website doing to secure your transaction so that you can trust it? - -This article aims to demystify the mechanisms that make a website secure. I will start by discussing the web protocols HTTP and HTTPS and the concept of Transport Layer Security (TLS), which is one of the cryptographic protocols in the internet protocol's (IP) layers. Then, I will explain certificate authorities (CAs) and self-signed certificates and how they can help secure a website. Finally, I will introduce some open source tools you can use to create and manage certificates. - -## Securing routes through HTTPS - -The easiest way to understand a secured website is to see it in action. Fortunately, it is far easier to find a secured website than an unsecured website on the internet today. But, since you are already on Opensource.com, I'll use it as an example. No matter what browser you're using, you should see an icon that looks like a lock next to the address bar. Click on the lock icon, and you should see something similar to this. - -![Certificate information][2] - -By default, a website is not secure if it uses the HTTP protocol. Adding a certificate configured through the website host to the route can transform the website from an unsecured HTTP site to a secured HTTPS site. The lock icon usually indicates that the site is secured through HTTPS. - -Click on Certificate to see the site's CA. Depending on your browser, you may need to download the certificate to see it. - -![Certificate information][3] - -Here, you can learn something about Opensource.com's certificate. For example, you can see that the CA is DigiCert, and it is given to Red Hat under the name Opensource.com. - -This certificate information enables the end user to check that the website is safe to visit. - -> WARNING: If you do not see a certificate sign on a website—or if you see a sign that indicates that the website is not secure—please do not log in or do any activity that requires your private data. Doing so is quite dangerous! - -If you see a warning sign, which is rare for most publicly facing websites, it usually means that the certificate is expired or uses a self-signed certificate instead of one issued through a trusted CA. Before we get into those topics, I want to explain the TLS and SSL. - -## Internet protocols with TLS and SSL - -TLS is the current generation of the old Secure Socket Layer (SSL) protocol. The best way to understand this is by examining the different layers of the IP. - -![IP layers][4] - -There are six layers that make up the internet as we know it today: physical, data, network, transport, security, and application. The physical layer is the base foundation, and it is closest to the actual hardware. The application layer is the most abstract layer and the one closest to the end user. The security layer can be considered a part of the application layer, and TLS and SSL, which are the cryptographic protocols designed to provide communications security over a computer network, are in the security layer. - -This process ensures that communication is secure and encrypted when an end user consumes the service. - -## Certificate authorities and self-signed certificates - -A CA is a trusted organization that can issue a digital certificate. - -TLS and SSL can make a connection secure, but the encryption mechanism needs a way to validate it; this is the SSL/TLS certificate. TLS uses a mechanism called asymmetric encryption, which i \ No newline at end of file diff --git a/sources/tech/20191118 How to use regular expressions in awk.md b/sources/tech/20191118 How to use regular expressions in awk.md index cdf1468369..a0be0df4d7 100644 --- a/sources/tech/20191118 How to use regular expressions in awk.md +++ b/sources/tech/20191118 How to use regular expressions in awk.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (lixin555) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) @@ -265,7 +265,7 @@ via: https://opensource.com/article/19/11/how-regular-expressions-awk 作者:[Seth Kenlon][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) +译者:[lixin555](https://github.com/lixin555) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/tech/20191118 Some notes on vector drawing apps.md b/sources/tech/20191118 Some notes on vector drawing apps.md new file mode 100644 index 0000000000..7c57682fc6 --- /dev/null +++ b/sources/tech/20191118 Some notes on vector drawing apps.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Some notes on vector drawing apps) +[#]: via: (https://jvns.ca/blog/2019/11/18/some-notes-on-vector-drawing-apps/) +[#]: author: (Julia Evans https://jvns.ca/) + +Some notes on vector drawing apps +====== + +For the last year and a half I’ve been using the iPad Notability app to draw my [zines][1]. Last week I decided I wanted more features, did a bit of research, and decided to switch to Affinity Designer (a much more complicated program). So here are a few quick notes about it. + +The main difference between them is that Notability is a simple note taking app (aimed at regular people), and Affinity Designer is a vector graphics app (aimed at illustrators / graphic designers), like Adobe Illustrator. + +I’ve never used a serious vector graphics program before, so it’s been cool to learn what kinds of features are available! + +### Notability is super simple + +This is what the Notability UI looks like. There’s a pencil, an eraser, a text tool, and a selection tool. That’s basically it. I LOVED this simplicity when I started using Notability, and I made 4 zines using it (help! i have a manager!, oh shit, git!, bite size networking!, and http: use your browser’s language). + + + +Recently though, I’ve had a couple of problems with it, the main one being that text boxes and things drawn with the pencil tool don’t mix well. (In general Notability has been GREAT though and their support team has always been incredibly helpful when I’ve had questions.) + +### Affinity Designer is really complicated + +Affinity Designer, by comparison, is WAY more complicated. Here’s what the UI looks like: + + + +There are + + * 14 tools on the left + * 14 more panels on the right that alter what the tools do + * a bottom toolbar which has different options for each tool + * 2 menus which together have another 25 things or so that you can do + + + +I still don’t understand what all the tools do (what’s the difference between Pencil and Vector Brush? I don’t know!). But I’m pretty excited about this because (unlike with Notability) there are so many options that if I’m frustrated about something, 90% of the time there’s a way to do the thing I want! + +### switching from Notability to Affinity Designer is really easy + +Switching to Notability wasn’t the best: I [reverse engineered the file format][2] to transfer some files over but the quality was never the best (probably because of problems with my script) and I ended up having to redraw a lot of them in practice. + +With Affinity Designer, I can just + + * export a PDF with Notability (or anything else) + * import the PDF with Affinity Designer + * and then I can easily edit it and that’s it?!? + + + +It’s not perfect – the vector paths it comes up with are kind of weird, probably because of the way the PDF is – but it’s very good! It makes me feel confident that if I need to make a small edit to something I made in the past I can just import the PDF! + +### what can a vector drawing app do? + +here are a few things Affinity Designer can do that Notability can’t: + + * **custom paper sizes**: In Notability every page is 8.5x11, but usually I want something more like 5.5x8.5 which is a different aspect ratio (this is technically sort of possible in Notability by importing a PDF of the correct size but it’s a pain and it means you can’t use a grid) + * **custom colour palettes**: I can have the 10 colours I like to use in my comics all in one place + * **grouping objects together** – I can “group” a bunch of objects together so that I can easily resize and move them all together + * **two kinds of text box**. This is the kind of thing that I wouldn’t have understood 2 years ago but that now I LOVE – you can either have “art text” that acts like an image (no word wrap, gets bigger when you resize it) or “frame text” that has word wrap and doesn’t get bigger when you resize it. + * **really great import** – I can import a PDF or SVG and individually edit / move around parts of the PDF. Notability doesn’t have any import tools that let you edit after importing. + * **custom export options for printing**. I don’t understand what it **does** yet but there are export presets for print PDFs and it fixes some printing problems I was having! + + + +There are also a LOT more features that I’m not interested in but I’m pretty excited about those 6 things and it feels like an app that I won’t grow out of. + +### iPad apps are great + +I’ve been exclusively using Linux for the last 15 years where the image editing/media tools aren’t always great (though I really like Inkscape and I hear good things about Krita!), so it’s really cool to have access to all these great iPad apps. And the prices seem pretty reasonable: + + * Notability is $12 + * Affinity Designer is $20 + * LumaFusion (a nice video editor I’ve been using a little) is $30 + + + +It doesn’t make me want a Mac (I like the Linux desktop experience!), but it’s nice to have access to a bunch of these great tools. And I think a lot of these art tools work better on an iPad than on a computer anyway since you can just draw on the screen :) + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/11/18/some-notes-on-vector-drawing-apps/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://wizardzines.com +[2]: https://jvns.ca/blog/2018/03/31/reverse-engineering-notability-format/ diff --git a/sources/tech/20191119 Container reality checks and more industry trends.md b/sources/tech/20191119 Container reality checks and more industry trends.md new file mode 100644 index 0000000000..5f5477e0aa --- /dev/null +++ b/sources/tech/20191119 Container reality checks and more industry trends.md @@ -0,0 +1,53 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Container reality checks and more industry trends) +[#]: via: (https://opensource.com/article/19/11/container-reality-checks-and-more-industry-trends) +[#]: author: (Tim Hildred https://opensource.com/users/thildred) + +Container reality checks and more industry trends +====== +A weekly look at open source community, market, and industry trends. +![Person standing in front of a giant computer screen with numbers, data][1] + +As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update. + +## [The benefits of gamification in business][2] + +> While its value as an industry is still growing each year, it seems that some organisations are still struggling to implement gamification technology in the first place or engage employees once they have. Early difficulties revolved around a lack of real clarity as to what gamification is and how it can help an organisation. This fed into poor initial results that have dampened enthusiasm among early adopters. There was also a belief that a one-size-fits-all approach could be used, regardless of the circumstances, the demographics of the teams involved or the processes being gamified. For the persistent, these early forays provided valuable lessons that rendered future projects more successful. + +**The impact**: The science fiction fan in me always found the idea of gamification dystopian; a way to trick employees into caring about things they otherwise wouldn't. The summer camp counselor in me recognizes the power of play in learning and teaching. Hopefully, that is the way the pendulum is swinging. + +## [Compare three distinct types of Kubernetes platforms][3] + +> Let's explore the benefits and risks of three types of Kubernetes platforms: the native open source tool, managed cloud services, and integrated ecosystems. We'll examine the technical features each option offers, the extent to which it supports enterprise container and cloud environments, and ease of use. + +**The impact**: This is all the other stuff that you should have been thinking about when you started to get hype on containers, and none of it comes for free. + +## [Deeply understanding the difference between portability, compatibility, and supportability][4] + +> Since the OCI standard governs the images specification, a container image can be created with Podman, pushed to almost any container registry, shared with the world, and consumed by almost any container engine including Docker, RKT, CRI-O, containerd and, of course, other Podman instances. Standardizing on this image format lets us build infrastructure like registry servers which can be used to store any container image, be it RHEL 6, RHEL 7, RHEL8, Fedora, or even Windows container images. + +**The impact**: Another container reality check that also drives home why going through the trouble of standards can be worth it in the long run. + +_I hope you enjoyed this list of what stood out to me from last week and come back next Monday for more open source community, market, and industry trends._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/container-reality-checks-and-more-industry-trends + +作者:[Tim Hildred][a] +选题:[lujun9972][b] +译者:[译者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/thildred +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) +[2]: https://social.hays.com/2019/11/05/benefits-of-gamification-in-business/ +[3]: https://searchitoperations.techtarget.com/feature/Compare-3-distinct-types-of-Kubernetes-platforms +[4]: http://crunchtools.com/deeply-understanding-the-different-between-portability-compatibility-and-supportability/ diff --git a/sources/tech/20191119 Loops in Emacs Lisp.md b/sources/tech/20191119 Loops in Emacs Lisp.md new file mode 100644 index 0000000000..66422100bf --- /dev/null +++ b/sources/tech/20191119 Loops in Emacs Lisp.md @@ -0,0 +1,321 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Loops in Emacs Lisp) +[#]: via: (https://opensourceforu.com/2019/11/loops-in-emacs-lisp/) +[#]: author: (Shakthi Kannan https://opensourceforu.com/author/shakthi-kannan/) + +Loops in Emacs Lisp +====== + +[![][1]][2] + +_This article in the Emacs series explores looping techniques that are available with Emacs Lisp._ + +T here are built-in constructs such as _while_ and _dolist_ that are shipped with the default GNU Emacs. The dash.el library provides functions to iterate over lists, and is written by Magnar Sveen. The latest release of dash.el is v2.16.0, and its source code is available at __ under the GNU General Public License v3.0. +Let us also explore the structures available in loop.el, another library for implementing imperative loops. This has been written by Wilfred Hughes, and has also been released under the GNU General Public License v3.0. + +**Installation** +The dash.el and loop.el packages are available in Milkypostman’s Emacs Lisp Package Archive (MELPA) and in the Marmalede repo. You can install the package using the following commands in GNU Emacs: + +``` +M-x package-install dash +M-x package-install loop +``` + +The other method of installation is to copy the dash.el and loop.el source files to your Emacs load path and load them. In order to get syntax highlighting of dash functions in Emacs buffers, you can add the following command to your Emacs initialisation settings: + +``` +(eval-after-load 'dash '(dash-enable-font-lock)) +``` + +If you are using Cask (__) to manage your Emacs configuration, then you can simply add the following code to your Cask file: + +``` +(depends-on "dash") +(depends-on "loop") +``` + +The usage of various loop construct is as follows. + +**Built-in** +GNU Emacs has built-in loop constructs. The _while_ function, for example, has the following syntax: + +``` +(while TEST BODY...) +``` + +The BODY code segment is evaluated if the result of TEST is not nil. Until TEST returns nil, the BODY will continue to be executed. An example of _while_ function usage is given below: + +``` +(setq alphabets '(a b c d e)) + +(defun print-list-elements (list) +"Print each element of the input LIST" +(while list +(print (car list)) +(setq list (cdr list)))) + +(print-list-elements alphabets) +``` + +The output is as follows: + +``` +a +b +c +d +e +nil +``` + +The ‘dolist’ macro loops over a list and is also built-in with Emacs. Its definition is as follows: + +``` +(dolist (VAR LIST [RESULT]) BODY...) +``` + +The VAR argument represents each element in LIST for every iteration in the BODY segment. The value in RESULT is returned by the function, and is optional. By default, a nil is returned. The ‘alphabet’ list elements can be printed using the _dolist_ macro as shown below: + +``` +(setq alphabets '(a b c d e)) +(dolist (element alphabets) +(print element)) +``` + +The resultant output is the same. + +``` +a +b +c +d +e +nil +``` + +**dash.el** +The dash.el list library provides functions to iterate over lists. The -each function, for example, takes a list and a function, and applies the function to every element in the list. In the following example, a reverse of the input list is created by doubling each element’s value. + +``` +(-each list function) ;; Syntax + +(let (s) (-each '(1 2 3) (lambda (item) (setq s (cons (* item 2) s)))) s) +(6 4 2) +``` + +Another function API from the dash.el library is the -each-while function, which takes three arguments – a list, a predicate and a function. The function is applied to every element in the list that satisfies the predicate. For example: + +``` +(-each-while list predicate function) ;; Syntax + +(defun even? (num) (= 0 (% num 2))) +(let (s) (--each-while '(1 2 3 4) (< it 3) (!cons it s)) s) +(2 1) +``` + +The _-each-r_ function takes a list and a function, and applies the function on every item in the list in the reverse order. An example is given below: + +``` +(-each-r list function) ;; Syntax + +(let (s) (-each-r '(1 2 3) (lambda (item) (setq s (cons (* item 2) s)))) s) + +(2 4 6) +``` + +If you would like to use a predicate function with _-each-r_, you can use the _-each-r-while_ function as illustrated below: + +``` +(-each-r-while list predicate function) ;; Syntax + +(let (s) (-each-r-while '(1 2 3 4 5 6) 'even? (lambda (item) (!cons item s))) s) +(6) +``` + +The _-dotimes_ function will repeatedly call a function from 0 to the input number, minus 1. + +``` +(-dotimes number function) ;; Syntax + +(let (s) (-dotimes 3 (lambda (n) (!cons n s))) s) +(2 1 0) +``` + +You can explore more of the iterative functions available in dash.el under the Side-effects section in the GitHub source repository available at __. + +**loop.el** +We shall now explore the constructs available in the _loop.el_ library. The loop-while construct executes the body of the loop while the condition is true. In the following example, the sum of the numbers from 0 to 5 is computed. + +``` +(require 'loop) + +;; loop-while +loop-while (condition body...) ;; Syntax + +(let ((x 0) +(sum 0)) +;; sum of 0..5 +(loop-while (< x 5) +(setq sum (+ sum x)) +(setq x (1+ x))) +sum) +10 +``` + +If you want to evaluate the body at least once before checking the condition, you can use the _loop-do-while_ construct. In the following example, the value of x is incremented by one and then the condition is satisfied for the loop execution. + +``` +loop-do-while (condition body...) ;; Syntax + +(let ((x 0) +(sum 0)) +;; sum of 1..4 +(loop-do-while (and (> x 0) (< x 5)) +(setq sum (+ sum x)) +(setq x (1+ x))) +sum) +10 +``` + +The _loop-until_ construct repeatedly evaluates the body of the code until the condition becomes true. For example: + +``` +loop-until (condition body...) ;; Syntax + +(let ((x 0) +(sum 0)) +;; sum of 0..4 +(loop-until (= x 5) +(setq sum (+ sum x)) +(setq x (1+ x))) +sum) +10 +``` + +The _loop-for-each_ construct takes three arguments – a var, a list and a body. The var represents an element in the list for the iteration. In the following example, the sum of numbers from 1 to 5 is calculated. + +``` +loop-for-each (var list body...) ;; Syntax + +(let ((sum 0)) +(loop-for-each x (list 1 2 3 4 5) +(setq sum (+ sum x))) +sum) +15 +``` + +A couple of constructs are available to break or continue execution within a loop. The _loop-break_ construct breaks out of the innermost loop. For example: + +``` +loop-break () ;; Syntax + +(let ((sum 0)) +;; sum 1..5 +(loop-for-each x (list 1 2 3 4 5 6) +(setq sum (+ sum x)) +(when (= x 5) +(loop-break))) +sum) +15 +``` + +The _loop-continue_ construct will skip the rest of the current loop-while, loop-do-while or loop-for-each block and will proceed to the next iteration in the loop. In the following example, the list is iterated for elements between 1 and 6, and is skipped when the iteration matches the element 2. + +``` +loop-continue () ;; Syntax + +(let ((sum 0)) +;; sum the numbers 1, 3, 5 +(loop-for-each x (list 1 2 3 4 5 6) +(when (= x 2) +(loop-continue)) +(setq sum (+ sum x))) +sum) +19 +``` + +The loop.el library has unit tests included in the source code, which you can run to validate the defined constructs. In order to run the tests, you need to first clone the source repository using the following commands: + +``` +$ git clone https://github.com/Wilfred/loop.el +Cloning into 'loop.el'... +remote: Enumerating objects: 232, done. +remote: Total 232 (delta 0), reused 0 (delta 0), pack-reused 232 +Receiving objects: 100% (232/232), 31.29 KiB | 801.00 KiB/s, done. +Resolving deltas: 100% (117/117), done. +``` + +If you do not have Cask, install it using the instructions provided in the README file at __. +You can then change the directory into the cloned loop.el folder, and run cask install. This will locally install the required dependencies for running the tests. + +``` +$ cd loop.el/ +$ cask install +Loading package information... Select coding system (default utf-8): +done +Package operations: 3 installs, 0 removals +- Installing [ 1/3] undercover (latest)... done +- Installing [ 2/3] ert-runner (latest)... done +- Installing [ 3/3] f (latest)... already present +``` + +A _Makefile_ exists in the top-level directory, the contents of which are provided below for reference: + +``` +$ cat Makefile +CASK ?= cask +EMACS ?= emacs + +all: test +test: unit + +unit: +${CASK} exec ert-runner + +install: +${CASK} install +``` + +You can now simply run _make_ test at the shell prompt to execute the tests as shown below: + +``` +$ make test +cask exec ert-runner +................. + +Ran 17 tests in 0.001 seconds +``` + +Readers are encouraged to go through the README file at for more information. + +![Avatar][3] + +[Shakthi Kannan][4] + +The author is a free software developer at the Fedora project, and also a blogger. He co-maintains the Fedora Electronic Lab project. + +[![][5]][6] + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/loops-in-emacs-lisp/ + +作者:[Shakthi Kannan][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensourceforu.com/author/shakthi-kannan/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/01/Tips-to-hire-a-web-developer-with-skills-in-2019.jpg?resize=696%2C365&ssl=1 (Tips to hire a web developer with skills in 2019) +[2]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/01/Tips-to-hire-a-web-developer-with-skills-in-2019.jpg?fit=1200%2C630&ssl=1 +[3]: https://secure.gravatar.com/avatar/d6df0aa46ea197a6e5a6b80bba666830?s=100&r=g +[4]: https://opensourceforu.com/author/shakthi-kannan/ +[5]: https://opensourceforu.com/wp-content/uploads/2019/11/assoc.png +[6]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US diff --git a/sources/tech/20191119 What is a community of practice in an open organization.md b/sources/tech/20191119 What is a community of practice in an open organization.md new file mode 100644 index 0000000000..65e9ce464c --- /dev/null +++ b/sources/tech/20191119 What is a community of practice in an open organization.md @@ -0,0 +1,97 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What is a community of practice in an open organization?) +[#]: via: (https://opensource.com/open-organization/19/11/what-is-community-practice) +[#]: author: (Tracy Buckner https://opensource.com/users/tracyb) + +What is a community of practice in an open organization? +====== +If organizational silos are slowing your teams down, consider building +communities of practice to supercharge collaboration. +![Open community, gardeners and food co-op][1] + +Community is a fundamental component of open organizations. The [Open Organization Definition][2] notes that: + +> Shared values and purpose guide participation in open organizations, and these values—more so than arbitrary geographical locations or hierarchical positions—help determine the organization's boundaries and conditions of participation. + +In other words, people in open organizations often define their roles, responsibilities, and affiliations through shared interests and passions—not title, role, or position on an organizational chart. + +That means organizational leaders will find themselves invested in building communities inside their organizations, connecting like-minded people with one another to accelerate business objectives. + +For this reason, communities of practice can be a useful component of open organizations. In this three-part series, I'll explain what communities of practice are, why they are beneficial to an organization, and how you can start a community of practice.  + +### Community at the core + +Community has always been central to organizations built on open principles. In fact, [The Open Source Way][3] explains community as: + +> … the group of people who form intentionally and spontaneously around something important to them. It includes the people who use or benefit from the project, those who participate and share the project to wider audiences, and the contributors who are essential to growth and survival. + +This definition informs our vision for communities of practice (CoPs) at Red Hat. + +In 1991, cognitive anthropologists [Jean Lave][4] and [Etienne Wenger][5] first coined the term "community of practice" while studying group learning. They defined it as “a group of people who share an interest, a craft, and/or a profession.” Communities of practice have been around since the beginning of civilization. Groups of people have come together telling stories, imparting wisdom, and passing on tradition. Any group of people can form a CoP—a group of teachers exploring a new topic, for example, or architects discussing a typical customer problem and identifying a resolution. + +Not all groups are communities of practice. A CoP must have a shared domain of interest, practitioners who share resources (tools, techniques, and ideas), and community members. A CoP forms at the intersection of those factors (see Figure 1). + +![][6] + +### Domain + +A community of practice is defined by a shared _domain_ of interest. It's not merely a group of friends hanging out together; members have a commitment to the success of the domain and a desire to share their knowledge. They value use cases, success stories, feedback, and learning from the other members. + +### Practice  + +A community of practice is not simply a group of people who like the same things (such as certain kinds of music). Members of CoPs are _practitioners_ who engage in shared activities, share resources, tools, techniques, and ideas. Together they develop ways of addressing problems in new ways. Members value interactions and seek knowledge from each other. Many often become thought leaders and experts in the domain. + +### Members + +Not all groups are communities of practice. A CoP must have a shared domain of interest, practitioners who share resources (tools, techniques, and ideas), and community members. + +Community of practice _members_ engage in joint activities and discussions, assist each other, and share their knowledge. They build relationships that enable them to learn from each other; they care about their standing with each other. Members of a community of practice participate regularly but do not necessarily work together on a daily basis.  + +[Wenger][7] suggests several characteristics and potential activities of communities of practice, including: + + * Problem-solving + * Making recommendations + * Sharing experiences + * Hosting community forums + * Developing shared measurement tools + * Building an argument for a policy campaign + * Growing confidence and encouraging representatives to speak out + * Discussing developments in communities and solutions to challenges + * Documenting data needed to move communities forward + * Coordinating visits to participants' sites to learn more about different approaches and perspectives + * Mapping knowledge and identifying gaps + + + +Communities of practice can form inside and across roles and departments in an open organization. When they do, they can help dissolve organizational silos by providing safe spaces for practitioners to come together as a community and work on a domain the members enjoy. + +Together, members can solve current problems—and innovative on new products and solutions. Communities of practice also provide an opportunity to learn from the interaction and open communication in the group. Members mentor and encourage each other to learn more and do more within the community. CoPs provide a place to begin personal branding and to find the confidence to reach out for other thought leadership activities. + +Communities of practice drawn together domain, practice, and members to provide benefits for both the members and the organization. They are a cost-effective way to enhance learning, reduce silos, and promote innovation. And as [Wegner][7] said, “We need others to complement and develop our own expertise.” + +In the next article in this series, we will discuss the benefits of a CoP in an organization. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/19/11/what-is-community-practice + +作者:[Tracy Buckner][a] +选题:[lujun9972][b] +译者:[译者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/tracyb +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/open_community_lead.jpg?itok=F9KKLI7x (Open community, gardeners and food co-op) +[2]: https://opensource.com/open-organization/resources/open-org-definition +[3]: http://www.theopensourceway.org/book/index.html +[4]: http://en.wikipedia.org/wiki/Jean_Lave +[5]: http://en.wikipedia.org/wiki/Etienne_Wenger +[6]: https://opensource.com/sites/default/files/resize/images/open-org/cop_figure1-500x460.png +[7]: https://wenger-trayner.com/wp-content/uploads/2015/04/07-Brief-introduction-to-communities-of-practice.pdf diff --git a/sources/tech/20191120 Set up single sign-on for Fedora Project services.md b/sources/tech/20191120 Set up single sign-on for Fedora Project services.md new file mode 100644 index 0000000000..e580b1dd21 --- /dev/null +++ b/sources/tech/20191120 Set up single sign-on for Fedora Project services.md @@ -0,0 +1,105 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Set up single sign-on for Fedora Project services) +[#]: via: (https://fedoramagazine.org/set-up-single-sign-on-for-fedora-project-services/) +[#]: author: (Stephen Gallagher https://fedoramagazine.org/author/sgallagh/) + +Set up single sign-on for Fedora Project services +====== + +![][1] + +In addition to an operating system, the Fedora Project provides [services][2] for users and developers. Services such as [Ask Fedora][3], the [Fedora Project wiki][4] and the [Fedora Project mailing lists][5] help users [learn][6] how to best take advantage of Fedora. For developers of Fedora, there are many other services such as [dist-git][7], [Pagure][8], [Bodhi][9], [COPR][10] and [Bugzilla][11] for the packaging and release process. + +These services are available with a free account from the [Fedora Accounts System][12] (FAS). This account is the passport to all things Fedora! This article covers how to get set up with an account and configure [Fedora Workstation][13] for browser single sign-on. + +### Signing up for a Fedora account + +To create a FAS account, browse to the [account creation page][14]. Here, you will fill out your basic identity data: + +![Account creation page][15] + +Once you enter your data, the account system sends an email to the address you provided, with a temporary password. Pick a strong password and use it. + +![Password reset page][16] + +Next, the account details page appears. If you want to contribute to the Fedora Project, you should complete the [Contributor Agreement][17] now. Otherwise, you are done and you can use your account to log into the various Fedora services. + +![Account details page][18] + +### Configuring Fedora Workstation for single sign-On + +Now that you have your account, you can sign into any of the Fedora Project services. Most of these services support single sign-on (SSO), so you can sign in without re-entering your username and password. + +Fedora Workstation provides an easy workflow to add your Fedora credentials. The GNOME Online Accounts tool helps you quickly set up your system to access many popular services. To access it, go to the _Settings_ menu. + +![][19] + +Click on the option labeled _Fedora_. A prompt opens for you to provide your username and password for your Fedora Account. + +![][20] + +GNOME Online Accounts stores your password in [GNOME Keyring][21] and automatically acquires your single-sign-on credentials for you when you log in. + +### Single sign-on with a web browser + +Today, Fedora Workstation supports three web browsers out of the box with support for single sign-on with the Fedora Project services. These are [Mozilla Firefox][22], [GNOME Web][23], and [Google Chrome][24]. + +Due to a [bug][25] in Chromium, single sign-on doesn’t work currently if you have more than one set of Kerberos (SSO) credentials active on your session. As a result, Fedora doesn’t enable this function out of the box for Chromium in Fedora. + +To sign on to a service, browse to it and select the _login_ option for that service. For most Fedora services, this is all you need to do; the browser handles the rest. Some services such as the [Fedora mailing lists][26] and [Bugzilla][11] support multiple login types. For them, select the _Fedora_ or _Fedora Account System_ login type. + +That’s it! You can now log into any of the Fedora Project services without re-entering your password. + +##### Special consideration for Google Chrome + +To enable single sign-on out of the box for Google Chrome, Fedora takes advantage of certain features in Chrome that are intended for use in “managed” environments. A managed environment is traditionally a corporate or other organization that sets certain security and/or monitoring requirements on the browser. + +Recently, Google Chrome changed its behavior and it now reports _Managed by your organization_ or possibly _Managed by fedoraproject.org_ under the ⋮ menu in Google Chrome. That [link][27] leads to a page that says, “If your Chrome browser is managed, your administrator can set up or restrict certain features, install extensions, monitor activity, and control how you use Chrome.” However, **[Fedora will never monitor your browser activity or restrict your actions][28].** + +Enter _chrome://policy_ in the address bar to see exactly what settings Fedora has enabled in the browser. The _AuthNegotiateDelegateWhitelist_ and _AuthServerWhitelist_ options will be set to _*.fedoraproject.or_g. These are the only changes Fedora makes. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/set-up-single-sign-on-for-fedora-project-services/ + +作者:[Stephen Gallagher][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/sgallagh/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/05/sso-fedora-web-services-816x345.jpg +[2]: https://apps.fedoraproject.org/ +[3]: https://ask.fedoraproject.org/ +[4]: https://fedoraproject.org/wiki/Fedora_Project_Wiki +[5]: https://lists.fedoraproject.org/archives/ +[6]: https://fedoramagazine.org/check-out-the-new-askfedora/ +[7]: http://src.fedoraproject.org/ +[8]: https://pagure.io +[9]: https://bodhi.fedoraproject.org +[10]: https://copr.fedorainfracloud.org/ +[11]: https://bugzilla.redhat.com +[12]: https://admin.fedoraproject.org/accounts +[13]: https://getfedora.org/ +[14]: https://admin.fedoraproject.org/accounts/user/new +[15]: https://fedoramagazine.org/wp-content/uploads/2019/05/FAS-new.png +[16]: https://fedoramagazine.org/wp-content/uploads/2019/05/changepass-1024x318.png +[17]: https://admin.fedoraproject.org/accounts/fpca/ +[18]: https://fedoramagazine.org/wp-content/uploads/2019/05/account-blurred.png +[19]: https://fedoramagazine.org/wp-content/uploads/2019/09/goa-toplevel.png +[20]: https://fedoramagazine.org/wp-content/uploads/2019/09/goa-fedora-creds.png +[21]: https://wiki.gnome.org/Projects/GnomeKeyring +[22]: https://www.mozilla.org/en-US/firefox +[23]: https://wiki.gnome.org/Apps/Web +[24]: https://www.google.com/chrome/ +[25]: https://bugzilla.redhat.com/show_bug.cgi?id=1640158 +[26]: https://lists.fedoraproject.org +[27]: https://support.google.com/chrome/answer/9281740 +[28]: https://fedoraproject.org/wiki/Legal:PrivacyPolicy diff --git a/sources/tech/20191120 Tools that Accelerate a Newbie-s Understanding of Machine Learning.md b/sources/tech/20191120 Tools that Accelerate a Newbie-s Understanding of Machine Learning.md new file mode 100644 index 0000000000..0b41f3e7f2 --- /dev/null +++ b/sources/tech/20191120 Tools that Accelerate a Newbie-s Understanding of Machine Learning.md @@ -0,0 +1,215 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Tools that Accelerate a Newbie’s Understanding of Machine Learning) +[#]: via: (https://opensourceforu.com/2019/11/tools-that-accelerate-a-newbies-understanding-of-machine-learning/) +[#]: author: (Jatin Karthik Tripathy https://opensourceforu.com/author/jatin-tripathy/) + +Tools that Accelerate a Newbie’s Understanding of Machine Learning +====== + +[![][1]][2] + +_The world of machine learning (ML) and deep learning (DL) is a fascinating one. Many newbies would like to dabble in this field but have some inhibitions. This article introduces readers to some of the best tools to kickstart their journey into the ML/ DL domain._ + +Machine learning is a term that is applied to a broad range of topics which have one thing in common – the use of algorithms and other statistical models to improve the performance of a particular task. All machine learning (ML) models are used to build a mathematical model of the data provided, to help the user predict or make decisions with a very high level of accuracy; thereby considerably reducing the strain of manually sifting through the data. Currently, there are several fields in which ML is used extensively, from filtering out emails and computer vision, to choosing a smart assistant. Readers are urged to spend some time researching only the topics that they are interested in and not get overwhelmed or distracted by the countless other applications of ML. + +Deep learning can be considered a subset of machine learning, though to call it that really does not do it justice. Currently, most applications have moved on from the somewhat old fashioned ML algorithms to employ deep learning (DL) algorithms. The latter provide much more support for the building of more complex mathematical models which cannot be provided by ML. Deep learning algorithms employ multiple ML algorithms in a manner vaguely inspired by how the human brain works, and hence the term‘neural networks’. Deep learning algorithms have been developed to the point where it has been proved that computers can indeed be smarter than humans. + +![Figure 1: Creating a notebook][3] + +This article explores five of the most user-friendly, highly scaleable ML libraries/tools available. These are: + + * Scikit-learn + * OpenCV + * TensorFlow + * Keras + * Google Colaboratory + + + +Some of you may be familiar with a couple of these libraries and even know how to use them. This is not meant to be an in-depth tutorial for any of these tools. The idea is that, hopefully, by the end of this article, readers will discover which of the five libraries featured, interests them enough to read further on the topic. + +**Scikit-learn** +The founders of Scikit-learn started off by trying to find answers to simple problems. I believe that any aspirant must follow the pioneer’s footsteps. Scikit-learn is a free library written for Python which lets users do exactly that. It operates using Python’s NumPy and SciPy libraries to achieve multiple aspects of machine learning with ease, such as various algorithms for classification, regression and clustering. It lets the user easily step into the world of artificial intelligence (AI) without making them feel that they’ve taken too big a leap. With its easy-to-use libraries, you can easily incorporate any of the above ML algorithms into your code. While Scikit-learn is essentially for older ML algorithms, beginners will have their hands full trying to implement various algorithms to see how they affect a particular use case. +This library is largely implemented in Python with some parts of it written in Cython, thus restricting its usage to how much Python you know. Python, incidentally, has a tremendous collection of libraries and third party APIs. + +The advantage of starting off with Scikit-learn is that most programmers with similar aspirations have also started off along the same path. There is huge support for Scikit-learn with the entire code written using the Scikit-learn library, making the learning process fairly simple. It also helps that the official documentation of Scikit-learn is one of the more refined and well written. So, most of your doubts will probably get clarified by just going through the documentation. +To start off with Scikit Learn, just follow the instructions available at the official site, at __. + +![Figure 2: Accessing notebook settings][4] + +**OpenCV** +OpenCV is a cross platform library that lets the user tackle any kind of real-time computer vision. + +**Note:** _Computer vision is a field of computer science that deals with how computers can be made to acquire a high level knowledge from photos or videos. It includes the tasks of acquiring, processing, analysing and understanding the data._ + +OpenCV has a wide range of applications, starting with simple algorithms that deal with 2D images, all the way up to augmented reality, motion tracking, etc. OpenCV is not as user-friendly as Scikit-learn, yet, with a little time anyone can easily understand the flow of things – well enough to use OpenCV to its maximum extent. OpenCV, unlike Scikit-learn, is mostly written in C/C++ and is a cross platform library. This means that the users can truly optimise their code by using lower level and complied languages such as C/C++ or Java. OpenCV also includes a statistical ML library with which it can stand alone to some extent. OpenCV also has integrations with leading DL frameworks such as TensorFlow and Torch/PyTorch, making it a very versatile tool which can be used even if the provided ML library does not meet the user’s demands. + +One of the notable things about OpenCV is that it supports hardware acceleration in three different cases, namely: + + * Intel’s Integrated Performance Primitives + * A CUDA based GPU interface + * An OpenCL based GPU interface + + + +The fact that OpenCV can use hardware acceleration means that the user can easily increase the performance of the code with simple modifications, thereby resulting in smoother real-time applications due to faster code execution. + +**Note:** _It is advisable to use hardware accelerations that are mathematically intensive to perform, else there is a chance of a drop in performance due to the time it takes to shift resources to the GPU from the CPU._ + +Detailed installation instructions for OpenCV are available from the official documentation for the Python programming language at _ py_setup/py_setup_in_windows/py_setup_in_windows.html_. Other installations can also be found in the documentation. + +**TensorFlow** +TensorFlow is an open source library which tackles data flow programming across a range of applications, from a symbolical mathematical library to the core library in neural network programming. Developed by the Google Brain team for the search giant’s internal use, today it is used within the firm for purposes ranging from research to production. + +**Note:** _The TensorFlow library is so named because it operates on multi-dimensional data arrays called tensors, whilst performing calculations for neural networks._ + +Unlike the earlier libraries, TensorFlow has been streamlined to make neural networks and is optimised for DL applications. TensorFlow is best at data crunching at a scale where data can be realistically processed using any other older technique. You can do all this while keeping the usage so simple, that, any devoted Python user will feel right at home with the line-by-line implementation of the neural network, allowing the user to easily implement high level concepts that involve a huge amount of mathematical theory behind them, with the call of a single function. This allows the user to quickly create a neural model and focus on refining it rather than worry about the mathematics behind it, making for faster prototyping. + +Like OpenCV, TensorFlow is not restricted to Python but supports other languages. Support ranges from having direct support to having third party APIs taking care of that. TensorFlow has a very flexible architecture system that allows it to be used in various devices, whether it is CPUs, GPUs or even TPUs (tensor processing units), as well as clustered servers or even handheld devices such as mobile phones. This allows TensorFlow to have a hardware acceleration capability that is unrivalled by most other libraries. + +**Note:** _Keras is a pure Python library unlike TensorFlow_ + +TensorFlow can take code to the browser with the use of TensorFlow.js, making DL projects lightweight and easily scaleable. TensorFlow Lite, which was built for using TensorFlow, specifically for Android development (beginning from Android Oreo) is even lighter. It has a wide reach. There are several applications of this library for different use cases, from being the foundation of some new technologies such as Deep Dream, an automated image captioning software, to being the core in many users’neural network projects. While it can be applied for a great many things, getting started off is not that hard. TensorFlow has huge support online with no lack of example code to go through before you tackle your first project. + +You can begin your TensorFlow journey by getting the Python library at _. org/install/_ and if you have a GPU that meets CUDA requirements, you can even optimise your execution using hardware acceleration. + +![Figure 3: Hardware accelerator][5] + +**Keras** +Keras is an open source Python library which runs on top of other Python libraries such as TensorFlow, Microsoft Cognitive Toolkit, or Theano. Keras focuses on being more user-friendly, modular and extensible compared to the libraries that it runs on top of. +Keras has official support from Google’s TensorFlow team (for the TensorFlow core library), allowing users to quickly build their code using the numerous implementations of commonly used neural networks methods already predefined in the Keras package. Like TensorFlow, Keras also supports hardware acceleration by the use of GPUs or TPUs, allowing the user far easier coding in almost the same execution time. + +Unlike the other tools mentioned in our list, Keras is not a standalone library. Rather, it acts as a high-level API to other libraries that require comparatively more complex ways of coding. This allows users to achieve far more rapid prototyping with their code. As a trade-off for this level of user-friendly Python coding, you lose some level of control over your code. For example, in Keras, while you do have considerable control over your network, any of the lower level packages that implement Keras will control the finer things of the network. + +This might lead you to wonder, why one should even use Keras? The sole reason is that most of the time, while trying out new implementations of neural networks, that high level of control over the hyper parameters isn’t required. The trade-off obtained by dropping that functionality makes far more sense to any programmer who only wants to see how the network performs. You can think of Keras as a way of getting the feel of what you are trying to build before trying to optimise it at a much lower level so that your networks perform the best. Keras has one of the most user-friendly approaches to coding neural networks. For anyone who just wants to try out the latest advances in current technology, Keras will almost always meet such a user’s demands. One small shortcoming is that Keras is a pure Python library unlike TensorFlow. + +**Note:** _As of June 2019, Keras has officially been ported together with Tensorflow to bcome Tensorflow 2.0. This new version of Tensorflow cuts back on a lot of extras previously available, resulting in a more standardised approach of writing code using the Keras API. Tensorflow 2.0 is currently in beta stage, but it already implements a lot of the more commonly used features, so if you feel like foraging into the new and improved library, head over to: _ + +It is possible for one to transform Keras models from Python to lower level languages such as C/C++. +As an example of how easy it is to understand and use Keras as compared to TensorFlow, let us take a look at both these libraries when used for the same application – the classification of handwritten numbers using the Mnist data set. +First let us look at an example of using pure TensorFlow to finish the task, as shown below: + +``` +import tensorflow as tf +mnist = tf.keras.datasets.mnist + +n_nodes = 512 +n_classes = 10 +batch_size = 100 + +x = tf.placeholder('float', [None, 784]) +y = tf.placeholder('float') + +def neural_network_model(data): +layer_1 = {'weights':tf.Variable(tf.random_normal([784, n_nodes])), +'biases':tf.Variable(tf.random_normal([n_nodes]))} +output_layer = {'weights':tf.Variable(tf.random_normal([n_nodes, n_classes])), +'biases':tf.Variable(tf.random_normal([n_classes])),} +l1 = tf.add(tf.matmul(data,layer_1['weights']), layer_1['biases']) +l1 = tf.nn.relu(l1) +output = tf.matmul(l1,output_layer['weights']) + output_layer['biases'] +return output + +def train_neural_network(x): +prediction = neural_network_model(x) +cost = tf.reduce_mean( tf.nn.sparse_softmax_cross_entropy_with_logits(logits=prediction,labels=y) ) +optimizer = tf.train.AdamOptimizer().minimize(cost) +hm_epochs = 5 +with tf.Session() as sess: +sess.run(tf.initialize_all_variables()) +for epoch in range(hm_epochs): +epoch_loss = 0 +for _ in range(int(mnist.train.num_examples/batch_size)): +epoch_x, epoch_y = mnist.train.next_batch(batch_size) +_, c = sess.run([optimizer, cost], feed_dict={x: epoch_x, y: epoch_y}) +epoch_loss += c +print('Epoch', epoch, 'completed out of',hm_epochs,'loss:',epoch_loss) + +correct = tf.equal(tf.argmax(prediction, 1), tf.argmax(y, 1)) +accuracy = tf.reduce_mean(tf.cast(correct, 'float')) +print('Accuracy:',accuracy.eval({x:mnist.test.images, y:mnist.test.labels})) + +train_neural_network(x) +``` + +Now that we have that part done, let us take a look at the same implementation using _tf.keras_ : + +``` +import tensorflow as tf +mnist = tf.keras.datasets.mnist + +(x_train, y_train),(x_test, y_test) = mnist.load_data() +x_train, x_test = x_train / 255.0, x_test / 255.0 + +model = tf.keras.models.Sequential([ +tf.keras.layers.Flatten(), +tf.keras.layers.Dense(512, activation=tf.nn.relu), +tf.keras.layers.Dense(10, activation=tf.nn.softmax) +]) +model.compile(optimizer='adam', +loss='sparse_categorical_crossentropy', +metrics=['accuracy']) +print("running...") +model.fit(x_train, y_train, epochs=5) +model.evaluate(x_test, y_test) +``` + +The Keras code is far simpler and the language is at a higher level than TensorFlow. + +**Colaboratory by Google** +Increased performance in the execution of code is possible through the use of hardware like GPUs or TPUs rather than by running it solely on the CPUs. This is because CPUs, unlike the other two, have a limited number of cores and cannot process the vast mathematical calculations required even for quite a simple neural network. However, what can be done if your GPU is not supported by CUDA or you simply do not have one? + +That is where services such as Colaboratory come into play. Colaboratory is an online service that lets you use an online notebook system called Jupyter to write and execute code which is wholly based on the cloud. This avoids investing in expensive hardware such as a GPU to optimise code. Google Colaboratory gives you access to a Nvidia Tesla K80 GPU at no cost at all. The Colaboratory environment is exactly the same as any offline Python implementation. This means that there is absolutely no learning curve prior to starting off with Colaboratory. The fact that you run you code completely online means that you do not have to install any of the dependencies on your personal computer and this means that you are not restrained from implementing the latest ideas. +Putting your projects completely on the cloud allows you far more freedom and the access to Google TPUs which power the Colaboratory project. Unlike the Nvidia Tesla K80 GPU, the TPU does not come free, but you can use it for a basic fee calculated on TPU usage per second. This allows for the least possible execution time at the cheapest possible price. Like the TPU, Colaboratory also has several plans for other more powerful GPU prices, which are lower than the TPU rates, allowing you to choose what you feel is best for your particular use case. + +As mentioned earlier, Colaboratory is the same as any offline Python development environment that you may already be used to, thus allowing you to use packages that you normally do, such as OpenCV, TensorFlow, Keras, etc. A simple implementation of TensorFlow using Google Colaboratory is given below, starting from the official welcome page, __. + +To start off, first create your Python3 notebook in Colaboratory as shown in Figure 1. +Once you have done that, navigate to the notebook settings (_Edit > Notebook Settings_) as shown in Figure 2. + +Once you have selected the notebook settings, you can now change the runtime type to Python2 or Python3 and you can also change the hardware accelerator. It is here that you will decide on whether you want use the free Nvidia Tesla K80 GPU or the TPU provided by the service (Figure 3). + +![Figure 4: Mnist example][6] + +Now that the environment is set up, we can finally try out some program to test it. The purpose of this article is not to take you through any specific machine learning or deep learning example. For the sake of testing Colaboratory, let’s use the classic Mnist example that has been taken directly from the TensorFlow website __ +Once you have grabbed the code, simply execute it in the notebook and you should see an output as shown in Figure 4. + +Using Colaboratory, you have executed a basic classification example within minutes, without the need for any extra installations of TensorFlow (or even Python) on your computer. Thus, you can fully concentrate only on what you want to achieve and not bother about the dependencies needed for your project. + +We have seen only five of the vast number libraries that are available in the open source world. These five tools will provide the reader with a strong-enough footing to push forward and explore more complex tools that are streamlined for a particular use case. I urge you to also try to learn the mathematics of any new technology that you implement as it gives you a finer understanding of the how and whys of each thing. A nice start to any theory is the Machine Learning Cheatsheet, __ which, while barely scratching the surface of the mathematics behind the implementations, gives a very clear idea about the concepts and code examples to lead you in the right direction + +![Avatar][7] + +[Jatin Karthik Tripathy][8] + +The author takes a keen interest in graphics programming, graphics modelling, artificial intelligence, etc. He can be reached at jatinkarthik (dot) tripathy (at) vitap(dot) ac(dot) in. + +[![][9]][10] + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/11/tools-that-accelerate-a-newbies-understanding-of-machine-learning/ + +作者:[Jatin Karthik Tripathy][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensourceforu.com/author/jatin-tripathy/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Deep-Learning-Machine-learning-Artificial-intelligence.jpg?resize=696%2C502&ssl=1 (Deep Learning Machine learning Artificial intelligence) +[2]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Deep-Learning-Machine-learning-Artificial-intelligence.jpg?fit=700%2C505&ssl=1 +[3]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-1-Creating-a-notebook.jpg?resize=350%2C175&ssl=1 +[4]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-2-Accessing-notebook-settings.jpg?resize=350%2C280&ssl=1 +[5]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-3-Hardware-accelerator.jpg?resize=350%2C256&ssl=1 +[6]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/11/Figure-4-Mnist-example-350x281.jpg?resize=350%2C281&ssl=1 +[7]: https://secure.gravatar.com/avatar/19d277f27f20b7db95dacaff344a6948?s=100&r=g +[8]: https://opensourceforu.com/author/jatin-tripathy/ +[9]: https://opensourceforu.com/wp-content/uploads/2019/11/assoc.png +[10]: https://feedburner.google.com/fb/a/mailverify?uri=LinuxForYou&loc=en_US diff --git a/sources/tech/20191120 Troubleshooting PCIe Bus Error severity Corrected on Ubuntu and Linux Mint.md b/sources/tech/20191120 Troubleshooting PCIe Bus Error severity Corrected on Ubuntu and Linux Mint.md new file mode 100644 index 0000000000..e2051d7401 --- /dev/null +++ b/sources/tech/20191120 Troubleshooting PCIe Bus Error severity Corrected on Ubuntu and Linux Mint.md @@ -0,0 +1,160 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Troubleshooting PCIe Bus Error severity Corrected on Ubuntu and Linux Mint) +[#]: via: (https://itsfoss.com/pcie-bus-error-severity-corrected/) +[#]: author: (Community https://itsfoss.com/author/itsfoss/) + +Troubleshooting PCIe Bus Error severity Corrected on Ubuntu and Linux Mint +====== + +Recently I was trying to install Mint on several nodes in my institute. At times, I was not able to install and got lots of ‘PCIe Bus’ errors on the screen. I have also observed similar issue with Ubuntu 18.04. + +I got stuck into it for more than a month, after using many solution and observations (solution is the same, but observation and treatment may be different), I found something which was helpful for me and I think could be helpful for other Ubuntu and Linux Mint users. + +### Observations about PCIe Bus Error severity Corrected + +![][1] + +It happened with my HP system and it seems that there is some compatibility issues with the HP hardware. The PCIe Bus Error is basically the Linux kernel reporting the hardware issue. + +This error reporting turns into nightmare because of the frequency of error messages generated by the system. I have noticed in various [Linux forums][2] that many HP user have encountered this error, probably HP needs to improve Linux support for their hardware. + +Do note that this doesn’t necessarily mean that you cannot use Linux on your HP system. You might be able to use Linux like everyone else. It’s just that seeing this message flashing on the screen on every boot is annoying and sometimes, it could lead to bigger troubles. + +If the system keeps on reporting, it will increase the log size. If you have limited space for root, it could mean that your system will stuck at the black screen displaying the PCIe error message and your system won’t be able to boot. + +Now that you know a few things, let’s see how to tackle this error. + +### Handling PCIe Bus Error messages if you can boot in to your Linux system + +If you see the PCIe Bus Error message on the screen while booting but you are still able to log in, you could do a workaround for this annoyance. + +You can do little on the hardware compatibility front. I mean you (most probably) cannot go ahead and start coding drivers for your hardware or fix the existing drivers code. If your system works fine, your main concern should be that too much of error reporting doesn’t eat up the disk space. + +In that regard, you can change the Linux kernel parameter and ask it to stop reporting the PCIe errors. To do that, you need to edit the grub configuration. + +Basically, you just have to use a text editor for editing the file. + +First thing first, make a backup of your grub config file so that you can revert in case if you are not sure of things you changed. Open a terminal and use the following command: + +``` +cp /etc/default/grub ~/grub.back +``` + +Now open the file with Gedit for editing: + +``` +sudo gedit /etc/default/grub +``` + +Look for the line that has **GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”** + +Add pci=noaer in this line. AER stands for Advanced Error Reporting and ‘noaer’ asks the kernel to not use/log Advanced Error Reporting. The changed line should look like this: + +``` +GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=noaer" +``` + +Once you have saved the file, you should update the grub using this command: + +``` +sudo update-grub +``` + +[Restart Ubuntu][3] and you shouldn’t see the ‘PCIe Bus Error severity Corrected messages’ anymore. + +If this doesn’t fix the issue for you, you can try to change other kernel parameters. + +#### Further troubleshooting: Disable MSI + +Now you are resorting to hit and trial. You may try disabling [MSI][4]. Though Linux kernel supports MSI for several years now, a wrong implementation of MSI from some hardware manufacturer may lead to the PCIe errors. + +The drill is practically the same as you saw in the previous section. You edit the grub configuration and make the GRUB_CMDLINE_LINUX_DEFAULT line look like this: + +``` +GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=nomsi" +``` + +Update grub and reboot the system: + +``` +sudo update-grub +``` + +#### Even further troubleshooting: Disable mmconf + +I know it’s getting repetitive but if you are still facing the issue, it could be worth to give this a last try. This time, disable the mmconf parameter in Linux kernel. + +mmconf means memory mapped config and if you have an old computer, a buggy BIOS may lead to this issue. + +The steps remain the same. Just change the line GRUB_CMDLINE_LINUX_DEFAULT in your grub config to make it look like: + +``` +GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=nommconf" +``` + +#### Can’t boot! How to edit grub config now? + +In some cases, if you are not even able to boot at all, perhaps your root is out of space. An idea here would be to delete old log files and see if you could boot now and if yes, change the grub config. + +On reboot, if you stuck with logs on the screen and do a hard boot (use power button to turn it off and on again). When you power on, choose to go in to recovery mode from the grub screen. It should be under Advanced options. + +![][5] + +If your system doesn’t show the grub screen, press and hold shift key at boot. In some systems, pressing the Esc key brings the grub screen. + +In the advanced option->recovery mode: + +![][6] + +Drop into root shell: + +![][7] + +If you use the ls command to find large files, you’ll see that sys.log and kern.log take huge space: + +``` +ls -s -S /var/log +``` + +You can [empty the log files in Linux command line][8] this way: + +``` +$ > syslog +$ > kern.log +``` + +Once that is done, reboot your system. You should be able to log in. You should quickly change the grub parameters as discussed above. Adding pci=noaer should help you in this case. + +I know it’s more of a workaround than solution. But this is something that troubled me long and helped me get around the error. Otherwise I had to reinstall the system. + +I just wanted to share what worked for me with the community here. I hope it helps you as well. + +This article is written by Arun Shrimali. Arun is IT Head at Resonance Institute in India and he tries to implement Open Source Software across his organization. + +The article has been edited by Abhishek Prakash. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/pcie-bus-error-severity-corrected/ + +作者:[Community][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/itsfoss/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/troubleshooting_linux.png?ssl=1 +[2]: https://itsfoss.community/ +[3]: https://linuxhandbook.com/restart-ubuntu-server/ +[4]: https://en.wikipedia.org/wiki/Message_Signaled_Interrupts +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2012/07/new-grub-menu-ubuntu.png?ssl=1 +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2012/07/boot-into-recovery-mode-ubuntu-1.jpg?ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2012/07/drop-to-root-prompt-1.png?ssl=1 +[8]: https://linuxhandbook.com/empty-file-linux/ diff --git a/sources/tech/20191121 Simulate gravity in your Python game.md b/sources/tech/20191121 Simulate gravity in your Python game.md new file mode 100644 index 0000000000..977c234d8d --- /dev/null +++ b/sources/tech/20191121 Simulate gravity in your Python game.md @@ -0,0 +1,399 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Simulate gravity in your Python game) +[#]: via: (https://opensource.com/article/19/11/simulate-gravity-python) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Simulate gravity in your Python game +====== +Learn how to program video games with Python's Pygame module and start +manipulating gravity. +![Cosmic stars in outer space][1] + +The real world is full of movement and life. The thing that makes the real world so busy and dynamic is physics. Physics is the way matter moves through space. Since a video game world has no matter, it also has no physics, so game programmers have to _simulate_ physics. + +In terms of most video games, there are basically only two aspects of physics that are important: gravity and collision. + +You implemented some collision detection when you [added an enemy][2] to your game, but this article adds more because gravity requires collision detection. Think about why gravity might involve collisions. If you can't think of any reasons, don't worry—it'll become apparent as you work through the sample code. + +Gravity in the real world is the tendency for objects with mass to be drawn toward one another. The larger the object, the more gravitational influence it exerts. In video game physics, you don't have to create objects with mass great enough to justify a gravitational pull; you can just program a tendency for objects to fall toward the presumed largest object in the video game world: the world itself. + +### Adding a gravity function + +Remember that your player already has a property to determine motion. Use this property to pull the player sprite toward the bottom of the screen. + +In Pygame, higher numbers are closer to the bottom edge of the screen. + +In the real world, gravity affects everything. In platformers, however, gravity is selective—if you add gravity to your entire game world, all of your platforms would fall to the ground. Instead, you add gravity just to your player and enemy sprites. + +First, add a **gravity** function in your **Player** class: + + +``` +    def gravity(self): +        self.movey += 3.2 # how fast player falls +``` + +This is a simple function. First, you set your player in vertical motion, whether your player wants to be in motion or not. In other words, you have programmed your player to always be falling. That's basically gravity. + +For the gravity function to have an effect, you must call it in your main loop. This way, Python applies the falling motion to your player once every clock tick. + +In this code, add the first line to your loop: + + +``` +    player.gravity() # check gravity +    player.update() +``` + +Launch your game to see what happens. Look sharp, because it happens fast: your player falls out of the sky, right off your game screen. + +Your gravity simulation is working, but maybe too well. + +As an experiment, try changing the rate at which your player falls. + +### Adding a floor to gravity + +The problem with your character falling off the world is that there's no way for your game to detect it. In some games, if a player falls off the world, the sprite is deleted and respawned somewhere new. In other games, the player loses points or a life. Whatever you want to happen when a player falls off the world, you have to be able to detect when the player disappears offscreen. + +In Python, to check for a condition, you can use an **if** statement. + +You must check to see **if** your player is falling and how far your player has fallen. If your player falls so far that it reaches the bottom of the screen, then you can do _something_. To keep things simple, set the position of the player sprite to 20 pixels above the bottom edge. + +Make your **gravity** function look like this: + + +``` +    def gravity(self): +        self.movey += 3.2 # how fast player falls +        +        if self.rect.y > worldy and self.movey >= 0: +            self.movey = 0 +            self.rect.y = worldy-ty +``` + +Then launch your game. Your sprite still falls, but it stops at the bottom of the screen. You may not be able to _see_ your sprite behind the ground layer, though. An easy fix is to make your player sprite bounce higher by adding another **-ty** to its new Y position after it hits the bottom of the game world: + + +``` +    def gravity(self): +        self.movey += 3.2 # how fast player falls +        +        if self.rect.y > worldy and self.movey >= 0: +            self.movey = 0 +            self.rect.y = worldy-ty-ty +``` + +Now your player bounces at the bottom of the screen, just behind your ground sprites. + +What your player really needs is a way to fight gravity. The problem with gravity is, you can't fight it unless you have something to push off of. So, in the next article, you'll add ground and platform collision and the ability to jump. In the meantime, try applying gravity to the enemy sprite. + +Here's all the code so far: + + +``` +#!/usr/bin/env python3 +# draw a world +# add a player and player control +# add player movement +# add enemy and basic collision +# add platform +# add gravity + +# GNU All-Permissive License +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved.  This file is offered as-is, +# without any warranty. + +import pygame +import sys +import os + +''' +Objects +''' + +class Platform(pygame.sprite.Sprite): +    # x location, y location, img width, img height, img file     +    def __init__(self,xloc,yloc,imgw,imgh,img): +        pygame.sprite.Sprite.__init__(self) +        self.image = pygame.image.load(os.path.join('images',img)).convert() +        self.image.convert_alpha() +        self.rect = self.image.get_rect() +        self.rect.y = yloc +        self.rect.x = xloc + +class Player(pygame.sprite.Sprite): +    ''' +    Spawn a player +    ''' +    def __init__(self): +        pygame.sprite.Sprite.__init__(self) +        self.movex = 0 +        self.movey = 0 +        self.frame = 0 +        self.health = 10 +        self.score = 1 +        self.images = [] +        for i in range(1,9): +            img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert() +            img.convert_alpha() +            img.set_colorkey(ALPHA) +            self.images.append(img) +            self.image = self.images[0] +            self.rect  = self.image.get_rect() + +    def gravity(self): +        self.movey += 3.2 # how fast player falls +        +        if self.rect.y > worldy and self.movey >= 0: +            self.movey = 0 +            self.rect.y = worldy-ty-ty +        +    def control(self,x,y): +        ''' +        control player movement +        ''' +        self.movex += x +        self.movey += y +        +    def update(self): +        ''' +        Update sprite position +        ''' + +        self.rect.x = self.rect.x + self.movex +        self.rect.y = self.rect.y + self.movey + +        # moving left +        if self.movex < 0: +            self.frame += 1 +            if self.frame > ani*3: +                self.frame = 0 +            self.image = self.images[self.frame//ani] + +        # moving right +        if self.movex > 0: +            self.frame += 1 +            if self.frame > ani*3: +                self.frame = 0 +            self.image = self.images[(self.frame//ani)+4] + +        # collisions +        enemy_hit_list = pygame.sprite.spritecollide(self, enemy_list, False) +        for enemy in enemy_hit_list: +            self.health -= 1 +            print(self.health) + +        ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) +        for g in ground_hit_list: +            self.health -= 1 +            print(self.health) + +class Enemy(pygame.sprite.Sprite): +    ''' +    Spawn an enemy +    ''' +    def __init__(self,x,y,img): +        pygame.sprite.Sprite.__init__(self) +        self.image = pygame.image.load(os.path.join('images',img)) +        #self.image.convert_alpha() +        #self.image.set_colorkey(ALPHA) +        self.rect = self.image.get_rect() +        self.rect.x = x +        self.rect.y = y +        self.counter = 0 +        +    def move(self): +        ''' +        enemy movement +        ''' +        distance = 80 +        speed = 8 + +        if self.counter >= 0 and self.counter <= distance: +            self.rect.x += speed +        elif self.counter >= distance and self.counter <= distance*2: +            self.rect.x -= speed +        else: +            self.counter = 0 + +        self.counter += 1 + +class Level(): +    def bad(lvl,eloc): +        if lvl == 1: +            enemy = Enemy(eloc[0],eloc[1],'yeti.png') # spawn enemy +            enemy_list = pygame.sprite.Group() # create enemy group +            enemy_list.add(enemy)              # add enemy to group +            +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return enemy_list + +    def loot(lvl,lloc): +        print(lvl) + +    def ground(lvl,gloc,tx,ty): +        ground_list = pygame.sprite.Group() +        i=0 +        if lvl == 1: +            while i < len(gloc): +                ground = Platform(gloc[i],worldy-ty,tx,ty,'ground.png') +                ground_list.add(ground) +                i=i+1 + +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return ground_list + +    def platform(lvl,tx,ty): +        plat_list = pygame.sprite.Group() +        ploc = [] +        i=0 +        if lvl == 1: +            ploc.append((0,worldy-ty-128,3)) +            ploc.append((300,worldy-ty-256,3)) +            ploc.append((500,worldy-ty-128,4)) + +            while i < len(ploc): +                j=0 +                while j <= ploc[i][2]: +                    plat = Platform((ploc[i][0]+(j*tx)),ploc[i][1],tx,ty,'ground.png') +                    plat_list.add(plat) +                    j=j+1 +                print('run' + str(i) + str(ploc[i])) +                i=i+1 + +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return plat_list + +''' +Setup +''' +worldx = 960 +worldy = 720 + +fps = 40 # frame rate +ani = 4  # animation cycles +clock = pygame.time.Clock() +pygame.init() +main = True + +BLUE  = (25,25,200) +BLACK = (23,23,23 ) +WHITE = (254,254,254) +ALPHA = (0,255,0) + +world = pygame.display.set_mode([worldx,worldy]) +backdrop = pygame.image.load(os.path.join('images','stage.png')).convert() +backdropbox = world.get_rect() +player = Player() # spawn player +player.rect.x = 0 +player.rect.y = 0 +player_list = pygame.sprite.Group() +player_list.add(player) +steps = 10 # how fast to move + +eloc = [] +eloc = [200,20] +gloc = [] +#gloc = [0,630,64,630,128,630,192,630,256,630,320,630,384,630] +tx = 64 #tile size +ty = 64 #tile size + +i=0 +while i <= (worldx/tx)+tx: +    gloc.append(i*tx) +    i=i+1 + +enemy_list = Level.bad( 1, eloc ) +ground_list = Level.ground( 1,gloc,tx,ty ) +plat_list = Level.platform( 1,tx,ty ) + +''' +Main loop +''' +while main == True: +    for event in pygame.event.get(): +        if event.type == pygame.QUIT: +            pygame.quit(); sys.exit() +            main = False + +        if event.type == pygame.KEYDOWN: +            if event.key == pygame.K_LEFT or event.key == ord('a'): +                print("LEFT") +                player.control(-steps,0) +            if event.key == pygame.K_RIGHT or event.key == ord('d'): +                print("RIGHT") +                player.control(steps,0) +            if event.key == pygame.K_UP or event.key == ord('w'): +                print('jump') + +        if event.type == pygame.KEYUP: +            if event.key == pygame.K_LEFT or event.key == ord('a'): +                player.control(steps,0) +            if event.key == pygame.K_RIGHT or event.key == ord('d'): +                player.control(-steps,0) +            if event.key == pygame.K_UP or event.key == ord('w'): +                print('jump') + +            if event.key == ord('q'): +                pygame.quit() +                sys.exit() +                main = False + +    world.blit(backdrop, backdropbox) +    player.gravity() # check gravity +    player.update() +    player_list.draw(world) +    enemy_list.draw(world) +    ground_list.draw(world) +    plat_list.draw(world) +    for e in enemy_list: +        e.move() +    pygame.display.flip() +    clock.tick(fps) +``` + +* * * + +This is part 6 in an ongoing series about creating video games in [Python 3][3] using the [Pygame][4] module. Previous articles are: + + * [Learn how to program in Python by building a simple dice game][5] + * [Build a game framework with Python using the Pygame module][6] + * [How to add a player to your Python game][7] + * [Using Pygame to move your game character around][8] + * [What's a hero without a villain? How to add one to your Python game][2] + + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/simulate-gravity-python + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者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/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/space_stars_cosmic.jpg?itok=bE94WtN- (Cosmic stars in outer space) +[2]: https://opensource.com/article/18/5/pygame-enemy +[3]: https://www.python.org/ +[4]: https://www.pygame.org +[5]: https://opensource.com/article/17/10/python-101 +[6]: https://opensource.com/article/17/12/game-framework-python +[7]: https://opensource.com/article/17/12/game-python-add-a-player +[8]: https://opensource.com/article/17/12/game-python-moving-player diff --git a/sources/tech/20191122 How to use Bitwarden for password protection on Active Directory.md b/sources/tech/20191122 How to use Bitwarden for password protection on Active Directory.md new file mode 100644 index 0000000000..67b79f1c64 --- /dev/null +++ b/sources/tech/20191122 How to use Bitwarden for password protection on Active Directory.md @@ -0,0 +1,219 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to use Bitwarden for password protection on Active Directory) +[#]: via: (https://opensource.com/article/19/11/bitwarden-password-protection-active-directory) +[#]: author: (Stephen Bancroft https://opensource.com/users/stevereaver) + +How to use Bitwarden for password protection on Active Directory +====== +Integrate your Linux self-hosted Bitwarden instance with AD using +Bitwarden Directory Connector. +![A lock on the side of a building][1] + +[Bitwarden][2] is a fantastic tool for managing passwords. It has applications for every platform, a browser plugin, and a self-hosted version, and it offers some great password management tricks like folders and collections. One of my favorite features is that it will keep a history of your old passwords, which is a great feature for enterprise users. + +If you are an enterprise user, you are probably self-hosting Bitwarden and want to sync your users with a staff directory. My organization uses Active Directory (AD), which is the standard for user directories and integrates seamlessly with Windows desktops. I also need it to work with our open source tools, and herein lies the secret sauce shared in this article. + +The tool that allows you to do this is [Bitwarden Directory Connector][3] (BWDC). If you do a Google search, you will not find much information on using BWDC with AD on Linux. [Bitwarden's blog][4] is a great starting point if you're using the Windows version but it won't help you integrate it into your Linux environment. You can find instructions to do that on Bitwarden's GitHub page, but they aren't very clear. So, here I'll explain how to get your Linux self-hosted version of Bitwarden to integrate with your enterprise Active Directory (and, hopefully, provide more fruitful results for future Google searchers looking for this information). + +In my setup, both Bitwarden and Active Directory are hosted on AWS, the former in an EC2 instance and the latter in AWS Simple Directory. The Bitwarden Docker container is installed in the home directory of a user called **bitwarden**. [Bitwarden's instructions][5] make this easy to set up. But setting up BWDC is not as clear, so I will try to fix that here. + +### Install BWDC + +Start by setting up a directory for BWDC, then download the ZIP file and unzip it: + + +``` +cd /home/bitwarden +mkdir directory-connector +cd directory-connector +wget +unzip bwdc-linux-2.6.2.zip +chmod +x bwdc +``` + +(At the time of this writing, BWDC 2.6.2 was the current version; that may change, so make sure to download the latest release.) + +You will now have a binary file called **bwdc** and a file called **keytar.node**; leave both files right where they are. + +Next, edit the profile of the **bitwarden** user: + + +``` +`vi /home/bitwarden/.profile` +``` + +and add the lines: + + +``` +export BITWARDENCLI_CONNECTOR_PLAINTEXT_SECRETS=true +export PATH=$PATH:/home/bitwarden/directory-connector +``` + +Log out and back in to pick up the new settings, or you can source the profile with: + + +``` +`  . ~/.profile` +``` + +The line **BITWARDENCLI_CONNECTOR_PLAINTEXT_SECRETS=true** tells BWDC not to use any desktop-based keystore. Since this is a server and it's unlikely to have a desktop installed, you will have to keep the password in plain text (but you will take precautions to protect it later). The second line sets up a path to the **bwdc** binary so it can run from any directory you are in. + +### Configure BWDC + +Once BWDC is installed, configure it to connect to your Bitwarden instance: + + +``` +bwdc login +? Email address: <your email for your master account> +? Master password: [hidden] +``` + +After you are logged in, you're ready to work on the **data.json** file. + +If you set up BWDC using the steps above, its configuration information will be stored in **/home/bitwarden/.config/Bitwarden Directory Connector/data.json**. This file contains the **appId** and **access token**; these are the login credentials for your Bitwarden instance. But what about Active Directory, you say? You can add that manually by editing your **data.json** file (I assume you are on a server and are using Vi): + + +``` +`vi '/home/bitwarden/.config/Bitwarden Directory Connector/data.json'` +``` + +Add the following just underneath the **appId** line: + + +``` +"rememberEmail": true, +  "rememberedEmail": "<the email address you logged in with>", +  "organizationId": "<your organization id>", +  "directoryType": 0, +  "directoryConfig_0": { +    "ssl": false, +    "sslAllowUnauthorized": false, +    "port": 389, +    "currentUser": false, +    "ad": true, +    "hostname": "<hostname of your active directory>", +    "rootPath": "<root path of AD, something like; dc=com,dc=au>", +    "username": "<username with privilege to read the AD; DOMAIN\\\Username>", +    "password": "<password for the above account>" +  }, +  "directoryConfig_2": {}, +  "directoryConfig_1": {}, +  "directoryConfig_3": {}, +  "syncConfig": { +    "users": true, +    "groups": true, +    "interval": 5, +    "removeDisabled": true, +    "overwriteExisting": true, +    "useEmailPrefixSuffix": false, +    "creationDateAttribute": "whenCreated", +    "revisionDateAttribute": "whenChanged", +    "emailPrefixAttribute": "sAMAccountName", +    "memberAttribute": "member", +    "userObjectClass": "person", +    "groupObjectClass": "group", +    "userEmailAttribute": "mail", +    "groupNameAttribute": "name", +    "userFilter": "(&(memberOf=CN=bitwarden,OU=groups,DC=work,DC=corp))", +    "groupPath": "OU=Groups", +    "userPath": "CN=Users" +  }, +  "environmentUrls": { +    "base": "<base url of your bitwarden instance; [https://bitwarden.yourdomain\>][6]", +    "api": null, +    "identity": null, +    "webVault": null, +    "icons": null, +    "notifications": null, +    "events": null +  }, +``` + +If you look through this, you'll see that you need to change several values in this entry, including the **userFilter**, **groupPath**, and **userPath**. (I will assume you are familiar with LDAP and AD and know what those values should be for your instance.) Keep the **CN=bitwarden** part for the Bitwarden AD group you will create later. The other value you need to change is **organizationID**, which you can find in your **bwdata** directory as the name of one of the JSON files. List the files: + + +``` +`ls /home/bitwarden/bwdata/core/licenses/organization` +``` + +This should return a directory listing, containing a single filename in the form **<organization id>.json**. The filename itself is your organization's ID. Insert it into the **organizationID** line in the code above. + +Once you get your **data.json** file right, _I **highly** recommend you back up this file_. There seems to be an issue that sets this file back to default settings if BWDC finds a problem with it. This means if you innocently make a change to the file and there is a mistake, you will lose the entire configuration. + +Next, test connectivity to your AD as the **bitwarden** user: + + +``` +`bwdc test` +``` + +This should return a dump of the groups in your AD. To protect your password, set the permissions on that file so that only the **bitwarden** user can read it: + + +``` +`chmod 700 '/home/bitwarden/.config/Bitwarden Directory Connector/data.json'` +``` + +### Set up your group + +Now add a group to your AD (my group is called **bitwarden**), where you will add and remove users as they need access to Bitwarden. This group is necessary because, if you don't filter the users based on this group, BWDC will try to use ALL users in your AD. If the number of users is greater than your Bitwarden license allows, BWDC will fail silently, and you will hate yourself for a long time…. much like I did! + +Once the group is set up and has at least one user, run the test again. You should see your user's email address in the output. + +Now it is time to sync. Once you sync, any users that appear in the **bitwarden** group will be added to Bitwarden, and an email will be sent to them to invite them to sign up. Working as the **bitwarden** user, sync the directories with: + + +``` +`bwdc sync` +``` + +Given that **removeDisabled** is set to **true** in the **data.json** file, you can set up a cron job to keep the members of the **bitwarden** group and the Bitwarden users in constant sync so that any changes you make in your AD are immediately reflected in your Bitwarden instance. Add the following to your **/etc/crontab**: + + +``` +# Sync for Active Directory to Bitwarden +* *     * * *   bitwarden export BITWARDENCLI_CONNECTOR_PLAINTEXT_SECRETS=true ; /home/bitwarden/directory-connector/bwdc sync >/dev/null 2>&1 +``` + +Once you have auto-sync going, you will have a complete list of all your AD groups in Bitwarden. From there, it's just a simple matter of assigning a group to a collection and then adding members to groups in your AD. The users will be automatically assigned to the correct password collections and see the passwords they need. + +### Potential traps + +Finally, I will tell you about a few little traps that I fell into when setting this up. First, be aware of the **AD Primary Group**. You may have set this for a user if any of your Linux or other POSIX systems get login credentials from AD. It seems that AD will not include a user in group search results if that group is set as the primary group; this could remove a user from a group and therefore lose access to a collection. + +Second, when you need to delete a user, you might think that removing an account from the group in AD would remove the user… wrong! It seems that Bitwarden keeps some user information hanging around in its database. This became painfully obvious when I removed my own account and then discovered that I was no longer able to log in after recreating it because the multi-factor authentication (MFA) was still active and the token had expired, effectively locking me out. You must explicitly tell Bitwarden to remove that stuff in the database. To do so, go to the URL: + + +``` +`https:///#/recover-delete` +``` + +Enter the email address the user signed up with. They will get an email instructing them to click a link to confirm to remove the account. Once that is done, the user can be put back in the Bitwarden AD group and go through the sign-on process again. + +Now you know how to get your self-hosted Bitwarden working with your AD. I think you will still experience a few issues, but with a little bit of patience and tinkering with the configuration, it will work. Just don't muck around with it too much once it is working! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/bitwarden-password-protection-active-directory + +作者:[Stephen Bancroft][a] +选题:[lujun9972][b] +译者:[译者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/stevereaver +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_3reasons.png?itok=k6F3-BqA (A lock on the side of a building) +[2]: https://bitwarden.com/ +[3]: https://github.com/bitwarden/directory-connector +[4]: https://blog.bitwarden.com/organization-user-groups-directory-sync-ba674cb78a5c +[5]: https://help.bitwarden.com/article/install-on-premise/ +[6]: https://bitwarden.yourdomain\> diff --git a/sources/tech/20191125 25 Raspberry Pi Project Ideas to Put Your Pi to Some Good Use.md b/sources/tech/20191125 25 Raspberry Pi Project Ideas to Put Your Pi to Some Good Use.md new file mode 100644 index 0000000000..37912e7e20 --- /dev/null +++ b/sources/tech/20191125 25 Raspberry Pi Project Ideas to Put Your Pi to Some Good Use.md @@ -0,0 +1,303 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (25 Raspberry Pi Project Ideas to Put Your Pi to Some Good Use) +[#]: via: (https://itsfoss.com/raspberry-pi-projects/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +25 Raspberry Pi Project Ideas to Put Your Pi to Some Good Use +====== + +It won’t be an exaggeration if I call Raspberry Pi a revolutionary gadget. When it was first launched in the year 2011-12, people just couldn’t believe that a computer can be available in just $25. + +If you bought a Pi and wondering what should do with my Raspberry Pi, I have got your back. I am going to list some cool Raspberry Pi projects that you can start following in your free time. + +These Raspberry Pi project ideas are not limited to Pi. You can use them with other [Raspberry Pi like devices such as Orange Pi, Khadas][1] etc. + +### 25 Cool Raspberry Pi Projects + +I have listed several these project ideas by categorizing them in terms of the level of complexity (beginner, intermediate, and advanced). Some projects need additional equipment and sensors as well. + +Of course, it is worth noting that it will be subjective to what expertise you have. So, let us take a look at the project ideas. + +**Beginner Level Raspberry Pi Projects** + +#### 1\. Media Server + +Building a media server using Rasberry Pi is the most common and probably the easiest project there is. + +You can take a look at some of the [best media server software][2] available for Linux and get started. + +To know more about it, you can refer to the official documentation of [using Kodi with Raspberry Pi][3] (which is one of the media server software available). + +[Using Kodi On Raspberry Pi][3] + +#### 2\. Weather Station + +![][4] + +If you’re good at building projects with electronic components, building a weather station using Raspberry Pi should be fun for you. + +This may not be the easiest one to start with – but it’s quite simple if you carefully look into the project requirements. + +You will be able to collect weather data using a variety of sensors as per your requirements. The project has been listed on the official website to help you build it as easily as possible. + +[Weather Station Project][5] + +#### 3\. The Parent Detector + +![][6] + +Yet another project from Raspberry Pi’s official website, this project uses minimal hardware to set up a motion detector which then triggers a video recording using the Raspberry Pi camera module. + +The use-case for this can be a lot of things. If you are a parent, you can keep an eye on your child when they enter their room. In either case, this can also come in handy to keep an eye on your door as a security measure to check when someone arrives. + +You can find all the necessary details on Raspberry Pi’s official site. + +[The Parent Detector][7] + +#### 4\. FM Radio Station + +Raspberry Pi is an inexpensive device for making an FM radio station. The pre-requisites may not be much but is worth exploring for fun. + +Do note that you may not want to interfere with the local FM frequencies. You can find all the details to set it up by clicking the button below. + +[FM Radio Transmitter][8] + +#### 5\. Minecraft Game Sever + +![][9] + +Minecraft is a quite popular game. However, if you want a personal server, you might have to pay a premium. + +Fret not, you can use your Raspberry Pi to build a local server, create your own world and have fun with your family/friends. + +[Minecraft Game Server][10] + +#### 6\. Temperature Log + +It was something interesting I found on the official website to help you learn a few things like – how to write data to a file etc. + +Here, you will be recording the temperature using the sensor present. + +For this, you will be utilizing the command-line to monitor the temperature of Raspberry Pi. + +[Temperature Log][11] + +#### 7\. Retro Gaming Console + +You can turn your Raspberry Pi into a gaming console by simply installing an OS on an SD card and transfer a few files to it. + +We also have an article on how you can [turn your old PC into a Retrogaming console][12] if you are curious. + +I have linked a resource to help you make this project in the button below: + +[Retro Gaming Console][13] + +#### 8\. Full-Fledged Desktop + +![][14] + +If you do not want to invest a lot to build a PC, you can easily utilize your Raspberry Pi to build one. + +Technically, your Raspberry Pi will be the heart of your PC and you will need to add accessories (monitor, keyboard, mouse, etc) to turn it into a PC. You can also choose to build a custom case for the board if you want – which is totally optional. + +Obviously, the PC won’t be powerful enough for all kinds of tasks – but it will be usable. You can also check out the experience of having [Raspberry Pi 4 as a desktop replacement][15] on their official website as a reference to this project. + +[Full-Fledged Desktop][16] + +**Intermediate Level Raspberry Pi Project Ideas** + +#### 9\. Build a LAMP Web Server with WordPress + +If you are into web development, you can try setting up a LAMP (Linux + Apache + MySQL + PHP) server and install WordPress to create a website. You can also choose to make something else from scratch without installing WordPress. + +You will be able to access the site on any device on the same network as your Raspberry Pi. + +[Build a LAMP Web Server][17] + +#### 10\. Laser Tripwire + +It is a similar concept to the parent detector that uses a motion sensor. In this case, a laser beam is used to detect activity whenever someone breaks the beam. + +You just need a few things to set up the alarm and complete the tripwire. Of course, this is a simple project to start with that has potentially different applications. + +[Laser Tripwire][18] + +#### 11\. Print Server + +What if you can turn your old printer to work on a network of devices even without requiring a built-in WiFi feature? + +Well, that’s what this project is about. You will be able to access your printer from multiple devices using a print server. Check out all the details to help build one by clicking the button below. + +[Raspberry Pi Print Server][19] + +#### 12\. Time Lapse Camera + +Looking for a cheap dedicated time-lapse camera? Well, you can do it yourself with a Raspberry Pi. + +You can use the Pi camera module or explore other options as well. + +[Time-Lapse Camera][20] + +#### 13\. Music Box + +You can build a button-controlled music box using Raspberry Pi to have a great time with your kids or anyone who loves music. + +When you press a button, it will play a sound. You can find the short description of the project in the video above, for more details click on the button below. + +[Music Box][21] + +#### 14\. Google Home On Raspberry Pi + +If you could configure and set up Google Assistant on your Raspberry Pi, you can turn it into an inexpensive Google Home DIY alternative, right? + +Fortunately, you can achieve that with your Raspberry Pi. Find out more about it in the video above. + +#### 15\. Build Smart TV Box + +If you know how to set up a media server on Raspberry Pi (as mentioned in the first project idea of this article), you can make this happen too. + +With the help of the Kodi box (or similar), you can build your own personal smart TV box powered by the media server of your choice. + +[Smart TV Box][22] + +#### 16\. Add Gesture Controls To Raspberry Pi + +You can add the ability to have gesture controls for any of your projects on Raspberry Pi using a [Flick board][23]. + +It may not be the cheapest project but it is an impressive touch for your Raspberry Pi project. + +[Gesture Controls][23] + +**Advanced Level Raspberry Pi Project Ideas** + +#### 17\. Tor Router + +If you are someone who wants to explore ways to enhance your personal digital privacy, you can start by building your own local Tor onion router. + +With this, you can scramble your Internet connection and remain anonymous with your browsing activities. It is just something like a VPN but technically different. + +[Tor Router][24] + +#### 18\. Control LEDs with your voice + +![][25] + +This is quite interesting. I have already mentioned a project where you can set up Google Assistant on your Raspberry Pi. However, in this case, you will be able to control the LEDs with your voice. + +You will not need the assistant this time, all you need is the [Google AIY voice kit][26]. This has been featured on the list of official DIY projects using Raspberry Pi, you can get more information there. + +[Control LEDs With Voice][27] + +#### 19\. WiFi Extender + +If you want to increase the range of your WiFi network, you might have to opt for a premium gadget that can help you do that or you can utilize Raspberry Pi to get the job done. + +Yes, that’s right, you can build a WiFi extender by just using your Raspberry Pi. + +[WiFi Extender][28] + +#### 20\. VPN Server + +You do not need to trust the VPN providers if you can build your own local VPN server. It can be quite challenging to make it happen. + +So, if you are up for some action, you can use your Raspberry Pi to make a private VPN server for your connection. Explore more about it here: + +[VPN Server][29] + +#### 21\. Home Automation Using Raspberry Pi + +A lot of powerful projects can be done using the Raspberry Pi, one of which is – ‘Home Automation’. + +If I want to implement home automation, it will be expensive. But, if I end up using Raspberry Pi to create something similar, it will require less investment. Of course, you will have to explore and improve to make it a reliable system but you can get started with the basics. + +[Home Automation][30] + +#### 22\. Local Cloud Server + +You can also build your own cloud using Raspberry Pi. You can also install Nextcloud on it to protect and store your data. + +A lot of exciting things to explore once you have your own cloud, right? + +[Local Cloud Server][31] + +#### 23\. Portable Hacking Device + +Let me make one thing clear, I am not encouraging you to do something illegal (just like the movies) by building a portable hacking device. + +So, just for educational/testing purposes, feel free to try making your own portable device for hacking using Raspberry Pi. + +[Portable Hacking Device][32] + +#### 24\. Smart Gloves + +Making a pair of smart gloves is really a cool project with Raspberry Pi. In my college days, I witnessed a senior make this thing, it was interesting. + +You can refer to the official resource for this project and get started. + +[Smart Gloves][33] + +#### 25\. Ad Blocker + +With Raspberry Pi, you can easily implement a network-wide Adblocker so that you won’t have to install adblockers separately on devices or browsers. + +You need to utilize Pi-Hole (the ad blocker) to set it up. Check out the video above and the official resource through the button below. + +[Ad Blocker][34] + +**Wrapping Up** + +Here, I listed some of the most interesting projects that I could find that might come in handy for you. + +If you know some other cool ideas, let me know in the comments down below. I might update this list of Raspberry Pi projects with your idea. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/raspberry-pi-projects/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/raspberry-pi-alternatives/ +[2]: https://itsfoss.com/best-linux-media-server/ +[3]: https://www.raspberrypi.org/documentation/usage/kodi/ +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/diy-weather-station.jpg?ssl=1 +[5]: https://projects.raspberrypi.org/en/projects/build-your-own-weather-station +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/parents-detector-pi.png?ssl=1 +[7]: https://projects.raspberrypi.org/en/projects/parent-detector +[8]: https://circuitdigest.com/microcontroller-projects/raspberry-pi-fm-transmitter +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/minecraft-game-server.jpg?ssl=1 +[10]: https://www.makeuseof.com/tag/setup-minecraft-server-raspberry-pi/ +[11]: https://projects.raspberrypi.org/en/projects/temperature-log +[12]: https://itsfoss.com/lakka-retrogaming-linux/ +[13]: https://lifehacker.com/how-to-turn-your-raspberry-pi-into-a-retro-game-console-498561192 +[14]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/raspberry-pi-desktop.jpg?ssl=1 +[15]: https://www.raspberrypi.org/blog/raspberry-pi-4-a-full-desktop-replacement/ +[16]: https://www.makeuseof.com/tag/use-your-raspberry-pi-like-a-desktop-pc/ +[17]: https://projects.raspberrypi.org/en/projects/lamp-web-server-with-wordpress +[18]: https://projects.raspberrypi.org/en/projects/laser-tripwire +[19]: https://circuitdigest.com/microcontroller-projects/raspberry-pi-print-server +[20]: https://projects.raspberrypi.org/en/projects/raspberry-pi-zero-time-lapse-cam +[21]: https://projects.raspberrypi.org/en/projects/gpio-music-box +[22]: https://www.modmy.com/kodi-box-guide +[23]: https://magpi.raspberrypi.org/articles/flick-hat-swipe-gestures-raspberry-pi +[24]: https://magpi.raspberrypi.org/articles/tor-router +[25]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/control-led-voice-raspberry-pi.jpg?fit=800%2C450&ssl=1 +[26]: https://aiyprojects.withgoogle.com/voice +[27]: https://projects.raspberrypi.org/en/projects/google-voice-aiy/ +[28]: https://pimylifeup.com/raspberry-pi-wifi-extender/ +[29]: https://www.comparitech.com/blog/vpn-privacy/raspberry-pi-vpn/ +[30]: https://circuitdigest.com/microcontroller-projects/iot-raspberry-pi-home-automation +[31]: https://opensource.com/article/18/9/host-cloud-nas-raspberry-pi +[32]: https://www.hackster.io/mehedishakeel/portable-hacking-machine-kali-linux-raspberry-pi-touch-18b7c3 +[33]: https://www.raspberrypi.org/blog/raspberry-pi-glove/ +[34]: https://www.raspberrypi.org/blog/pi-hole-raspberry-pi/ diff --git a/sources/tech/20191125 Challenge- Write a bouncy window manager.md b/sources/tech/20191125 Challenge- Write a bouncy window manager.md new file mode 100644 index 0000000000..601e231f53 --- /dev/null +++ b/sources/tech/20191125 Challenge- Write a bouncy window manager.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Challenge: Write a bouncy window manager) +[#]: via: (https://jvns.ca/blog/2019/11/25/challenge--make-a-bouncy-window-manager/) +[#]: author: (Julia Evans https://jvns.ca/) + +Challenge: Write a bouncy window manager +====== + +Hello! I’m writing a short series of programming challenges with [Julian][1], and this is the first one! + +### the challenge + +![][2] + +**requirements** + +The goal here is to make a very silly Linux window manager that bounces its windows around the screen, like in the gif above. + +**anti-requirements** + +The window manager doesn’t need to do anything else! It doesn’t need to support: + + * moving or resizing windows + * switching between windows + * minimizing windows + * literally any of the other things you might normally expect a window manager to do + + + +It turns out implementing this kind of toy window manager is surprisingly approachable! + +### the setup: start with tinywm + +All the instructions here only work on Linux (since this is about writing a Linux window manager). + +**starter kit: tinywm** + +Writing a window manager from scratch seems intimidating (at first I didn’t even know how to start!). But then I found **[tinywm][3]**, which is a tiny window manager written in only **50 lines of C**. This is a GREAT starting point and there’s an annotated version of the source code which explains a lot of the details. There’s a Python version of tinywm too, but I wasn’t able to get it to work. + +I did this challenge by modifying [tinywm][3] and it worked really well. + +**tools** + + * **Xephyr** lets you embed an X session in a window in your regular desktop, so that you can develop your toy window manager without breaking your usual desktop. I ran it like this: `Xephyr -ac -screen 1280x1024 -br -reset -terminate 2> /dev/null :1 &` + * You can start an xterm in the Xephyr desktop with `xterm -display :1` + * I compiled my window manager with `gcc bouncewm.c -g -o bouncewm -lX11` and ran it with `env DISPLAY=:1 ./bouncewm` + * **xtrace** lets you trace all requests to the X windows system that your window manager is making. I found it really helpful when debugging. (run it like `xtrace ./bouncewm`) + + + +**documentation** + +Some useful references: + + * the [dwm source code][4] (dwm is a 2000-line-of-C window manager) + * the [Xlib programming manual][5] + + + +If you’re not comfortable writing C, there are also libraries that let you work with X in other languages. I personally found C easier to use because a lot of the window manager documentation and examples I found were for the Xlib C library. + +### my experience: 5 hours, 50 lines of code + +To give you a very rough idea of the difficulty of this exercise: I did this in 4 or 5 hours this morning and last night, producing the window manager you see in the gif at the top of the blog post (which is 50 lines of code). I’d never looked at the source code for a window manager before yesterday. + +As usual when working with a new library I spent most of that time being confused about various basic things about how X works. (and as a result I learned several new things about X!) + +For me this challenge was a fun way to: + + * learn some basics about the X window system protocol (I’ve been using window managers for 15 years, today I got to write one!) + * research an unfamiliar library (“ooh, what does this function do?”) + * use a C library, since I don’t usually write C + + + +### send me your solution if you do this! + +I’ll post the solution I came up in a week. If you think this window manager challenge sounds fun and end up doing it, I’d love it if you sent me your solution (to [[email protected]][6])! + +I’d be delighted to post any solutions you send me in the solutions blog post. + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/11/25/challenge--make-a-bouncy-window-manager/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: http://www.cipht.net/2017/10/03/are-jump-tables-always-fastest.html +[2]: https://jvns.ca/images/bouncewm.gif +[3]: http://incise.org/tinywm.html +[4]: https://git.suckless.org/dwm/file/dwm.c.html +[5]: https://tronche.com/gui/x/xlib/ +[6]: https://jvns.ca/cdn-cgi/l/email-protection diff --git a/sources/tech/20191125 My top 5 Ansible modules.md b/sources/tech/20191125 My top 5 Ansible modules.md new file mode 100644 index 0000000000..9a76342854 --- /dev/null +++ b/sources/tech/20191125 My top 5 Ansible modules.md @@ -0,0 +1,74 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (My top 5 Ansible modules) +[#]: via: (https://opensource.com/article/19/11/ansible-modules) +[#]: author: (Mark Phillips https://opensource.com/users/markp) + +My top 5 Ansible modules +====== +Learn how to achieve almost anything with these Ansible modules. +![][1] + +When I was growing up, my grandfather had a shed in his garden. He would spend hours in there, making and fixing things. This was way before we had the internet, so I spent a lot of time studying him creating things in that shed. Although the shed was full of many tools, from drills to lathes to electrical gubbins and lots of things I doubt I could identify even today, he made use of only a tiny subset of what he had at hand. Yet there never seemed to be limits to what he could achieve. + +I tell you that story because I feel like my career has been spent in a metaphorical shed. Computers are so many tools, all in a small (virtual?) space. And there are tool sheds within tool sheds—my favourite being Ansible. The recent 2.9 release ships with 3,681 modules! **3,681!** When I first started using Ansible in the summer of 2013, version 1.2.1 had just 113 modules, yet, as [I wrote at the time][2], I could still achieve anything I imagined. + +Modules are the backbone of Ansible, the gears to make light of heavy lifting. They're designed to do one job well, thus realising [the Unix philosophy][3]. This is how we've come to bundle so many of them; Ansible as the conductor of the orchestra now has a lot of instruments at its command. + +Reviewing a Git repository of my Ansible plays and roles over the years reveals that I have used just 35 modules. This small subset was used to build large infrastructures. I wonder what could be achieved with an even smaller subset, though? As I reviewed those 35, I pondered if I could achieve the same results with only five modules at my disposal. So here are my five favourite modules, in a rather tenuous order of precedence. + +### 5. [authorized_key][4] + +Secure shell (SSH) is at the heart of Ansible, at least for almost everything besides Windows. Key (no pun intended) to using SSH efficiently with Ansible is… [keys][5]! Slight aside—there are a lot of very cool things you can do for security with SSH keys. It's worth perusing the **authorized_keys** section of the [sshd manual page][6]. Managing SSH keys can become laborious if you're getting into the realms of granular user access, and although we could do it with either of my next two favourites, I prefer to use the module because it [enables easy management through variables][7]. + +### 4. [file][8] + +Besides the obvious function of placing a file somewhere, the **file** module also sets ownership and permissions. I'd say that's a lot of _bang for your buck_ with one module. I'd proffer a substantial portion of security relates to setting permissions too, so the **file** module plays nicely with **authorized_keys**. + +### 3. [template][9] + +There are so many ways to manipulate the contents of files, and I see lots of folk use **[lineinfile][10]**. I've used it myself for small tasks. However, the **template** module is so much clearer because you maintain the entire file for context. My preference is to write Ansible content in such a way that anyone can understand it _easily_—which to me means not making it hard to understand what is happening. Use of **template** means being able to see the entire file you're putting into place, complete with the variables you are using to change pieces. + +### 2. [uri][11] + +Many modules in the current distribution leverage Ansible as an orchestrator. They talk to another service, rather than doing something specific like putting a file into place. Usually, that talking is over HTTP too. In the days before many of these modules existed, you _could_ program an API directly using the **uri** module. It's a powerful access tool, enabling you to do a lot. I wouldn't be without it in my fictitious Ansible shed. + +### 1. [shell][12] + +The joker card in our pack. The Swiss Army Knife. If you're absolutely stuck for how to control something else, use **shell**. Some will argue we're now talking about making Ansible a Bash script—but, I would say it's still better because with the use of the **name** parameter in your plays and roles, you document every step. To me, that's as big a bonus as anything. Back in the days when I was still consulting, I once helped a database administrator (DBA) migrate to Ansible. The DBA wasn't one for change and pushed back at changing working methods. So, to ease into the Ansible way, we called some existing DB management scripts from Ansible using the **shell** module. With an informative **name** statement to accompany the task. + +You can achieve a lot with these five modules. Yes, modules designed to do a specific task will make your life even easier. But with a smidgen of engineering simplicity, you can achieve a lot with very little. Ansible developer Brian Coca is a master at it, and [his tips and tricks talk][13] is always worth a watch. + +* * * + +What do you think about my top five? What five modules would you pick and why, if you were so limited? Let me know in the comments below! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/ansible-modules + +作者:[Mark Phillips][a] +选题:[lujun9972][b] +译者:[译者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/markp +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/mandelbrot_set.png?itok=bmPc0np5 +[2]: http://probably.co.uk/post/puppet-vs-chef-vs-ansible/ +[3]: https://en.wikipedia.org/wiki/Unix_philosophy#Do_One_Thing_and_Do_It_Well +[4]: https://docs.ansible.com/ansible/latest/modules/authorized_key_module.html +[5]: https://linux.die.net/man/1/ssh-keygen +[6]: https://linux.die.net/man/8/sshd +[7]: https://github.com/phips/ansible-demos/blob/3bf59df1eb2390b31b5c42333197e2fbb7fec93f/roles/ansible-users/tasks/main.yml#L35 +[8]: https://docs.ansible.com/ansible/latest/modules/file_module.html +[9]: https://docs.ansible.com/ansible/latest/modules/template_module.html +[10]: https://docs.ansible.com/ansible/latest/modules/lineinfile_module.html +[11]: https://docs.ansible.com/ansible/latest/modules/uri_module.html +[12]: https://docs.ansible.com/ansible/latest/modules/shell_module.html +[13]: https://www.ansible.com/ansible-tips-and-tricks diff --git a/sources/tech/20191126 App Highlight- Penguin Subtitle Player for Adding Subtitles to Online Videos.md b/sources/tech/20191126 App Highlight- Penguin Subtitle Player for Adding Subtitles to Online Videos.md new file mode 100644 index 0000000000..9907322467 --- /dev/null +++ b/sources/tech/20191126 App Highlight- Penguin Subtitle Player for Adding Subtitles to Online Videos.md @@ -0,0 +1,122 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (App Highlight: Penguin Subtitle Player for Adding Subtitles to Online Videos) +[#]: via: (https://itsfoss.com/penguin-subtitle-player/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +App Highlight: Penguin Subtitle Player for Adding Subtitles to Online Videos +====== + +I must confess. I am addicted to subtitles. It helps me understand the dialogues completely, specially if some dialogues are in a different accent or in a different language. + +This has led to a habit of watching online videos with subtitles. + +While streaming services like Netflix and Amazon Prime provide subtitles for their content, the same is not true for all the websites. + +I often discover interesting content that are on YouTube, Dailymotion or other websites. And that becomes a problem because most of the time, these videos don’t have subtitles. + +The good news is that you have the possibility to watch any online video content with subtitles and I’ll share that neat little trick with you in this article. + +### Watch any online video with subtitles using Penguin subtitle player + +![][1] + +What the heck is a Subtitle player? + +The [open source video players][2] you use allow you to add subtitles. Players like [VLC allow you to download subtitles automatically][3]. + +But they are video player and their main task is to play video. + +A subtitle player on the other hand has only one task and that is to play subtitles. Confused? Let me explain. + +A subtitle player basically provides an interface where you can add subtitle file and play the subtitles with a semi transparent background. The trick here is that this player will be visible all the time on top of any other application. + +So if you are running the subtitle player even while using a website, it will still be visible. That actually is the trick to watch any online video with subtitles. + +![An external subtitle playing on top of YouTube video][4] + +All you have to do is to find appropriate subtitles from an online website like OpenSubtitles and add it to the subtitle player. Now open the website where you want to watch the video. Play it full screen (if that option is available) and it will feel like that the subtitles are part of the video itself. + +![][5] + +#### Install Penguin subtitle player + +[Penguin][6] is a free and open source subtitle player. It is available for Linux, macOS and Windows. + +If you are using Ubuntu-based distribution, you can [use this PPA][7] to easily install Penguin subtitle player. + +``` +sudo add-apt-repository ppa:nilarimogard/webupd8 +sudo apt update +sudo apt install penguin-subtitle-player +``` + +For other Linux distributions, Windows and macOS, you can download the installer files from SourceForge: + +[Download Penguin Subtitle Player][8] + +#### Using Penguin subtitle player + +Once you have installed the application, look for it in the menu and start it. You’ll see an interface like this: + +![Penguin Subtitle Player Interface][9] + +If you have already downloaded the .srt subtitle file, you can add it to the player by clicking the folder icon. + +![Add Subtitle In Penguin Subtitle Player][10] + +You can play/pause the subtitles, skip it to a new time. This helps in adjusting the subtitles with the video. + +![Adjust Subtitle In Penguin Subtitle Player][11] + +You can also tweak the appearance of the subtitles and subtitle player. + +![Configure Penguin Subtitle Player][12] + +You also have the option to change the fonts, font size and color of the subtitle text. You may also increase or decrease the transparency and color of the background. + +![Config Options In Penguin Subtitle Player][13] + +You can also resize the subtitle player interface and move it around anywhere on the screen. + +#### Keep in mind + +There are a few things to keep in mind while using Penguin subtitle player. + +Not all video files and subtitle files are made for each other. Subtitle synchronization is a common problem so you’ll have to make sure that the subtitle you downloaded is best suited for the video you want to play. + +Most video players, even the one embedded on the websites, allow to pause and play the video with the space key. Unfortunately, there is no keyboard shortcut to pause the Penguin subtitle player. In other words, you cannot pause the video and the subtitle player in one keystroke. + +With this much configuration, you should be set for watching online videos with subtitles. + +I hope you enjoy this nifty little open source application. Do let me know whether you find it useful or not. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/penguin-subtitle-player/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/Add_subtitle_online_videos.png?ssl=1 +[2]: https://itsfoss.com/video-players-linux/ +[3]: https://itsfoss.com/download-subtitles-automatically-vlc-media-player-ubuntu/ +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/penguin_subtitle_player.jpg?ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2015/05/Penguin_Subtitle_Player.jpg?ssl=1 +[6]: https://github.com/carsonip/Penguin-Subtitle-Player +[7]: https://itsfoss.com/ppa-guide/ +[8]: https://sourceforge.net/projects/penguinsubtitleplayer/ +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/penguin-subtitle-player-interface.jpg?ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/add_subtitle_in_penguin_subtitle_player.jpg?ssl=1 +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/adjust_subtitle_in_penguin_subtitle_player.jpg?ssl=1 +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/configure_penguin_subtitle_player.jpg?ssl=1 +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/config_options_in_penguin_subtitle_player.jpg?ssl=1 diff --git a/sources/tech/20191126 Calculator N- is an open source scientific calculator for your smartphone.md b/sources/tech/20191126 Calculator N- is an open source scientific calculator for your smartphone.md new file mode 100644 index 0000000000..32d467465a --- /dev/null +++ b/sources/tech/20191126 Calculator N- is an open source scientific calculator for your smartphone.md @@ -0,0 +1,61 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Calculator N+ is an open source scientific calculator for your smartphone) +[#]: via: (https://opensource.com/article/19/11/calculator-n-mobile) +[#]: author: (Ricardo Berlasso https://opensource.com/users/rgb-es) + +Calculator N+ is an open source scientific calculator for your smartphone +====== +The Android app does a wide range of advanced mathematical functions in +the palm of your hand. +![scientific calculator][1] + +Mobile phones are becoming more powerful every day, so it is no surprise that they can beat most computers from the not-so-distant past. This also means the tools available on them are getting more powerful every day. + +Previously, I wrote about [scientific calculators for the Linux desktop][2], and I'm following that up here with information about [Calculator N+][3], an awesome GPL v3.0-licensed computer algebra system (CAS) app for Android devices. + +Calculator N+ is presented as a "powerful calculator for Android," but that's a humble statement; the app not only works with arbitrary precision, displaying results with roots and fractions in all their glory, it does a _lot_ more. + +Finding polynomial roots? Check. Factorization? Check. Symbolic derivatives, integrals, and limits? Check. Number theory (modular arithmetic, combinatorics, prime factorization)? Check. + +You can also solve systems of equations, simplify expressions (including trigonometric ones), convert units… you name it! + +![Calculator N+ graphical interface][4] + +Results are output in LaTeX. The menu in the top-left provides many powerful functions ready to use with a simple touch. Also in that menu, you'll find Help files for all of the app's functions. At the top-right of the screen, you can toggle between exact and decimal representation. Finally, tapping the blue bar at the bottom of the screen gives you access to the whole library of functions available in the app. But be careful! If you are not a mathematician, physicist, or engineer, such a long list may seem overwhelming. + +All of this power comes from the [Symja library][5], another great GPL 3 project. + +Both projects are under active development, and they are getting better with each version. In particular, version 3.4.6 of Calculator N+ gets a major leap in user interface (UI) quality. And yes, there are still some rough corners here and there, but taming this much power in the tiny UI of a smartphone is a difficult task, and I think the app developers are solving its remaining issues quite well. Kudos to them! + +If you are a teacher, a student, or work on a STEM field, check out Calculator N+. It's free, no ads, open source, and covers all your math needs. (Except, of course, during math exams, where smartphones should never be allowed to prevent cheating.) + +Calculator N+ is available in the [Google Play Store][6], or you can [build it from source code][7] using the instructions on the GitHub page. + +If you know any other useful open source apps for science or engineering, let us know in the comments. + +The app makes use of the sensors on your phone and offers a digital science notebook to record your... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/calculator-n-mobile + +作者:[Ricardo Berlasso][a] +选题:[lujun9972][b] +译者:[译者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/rgb-es +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/calculator_money_currency_financial_tool.jpg?itok=2QMa1y8c (scientific calculator) +[2]: https://opensource.com/article/18/1/scientific-calculators-linux +[3]: https://github.com/tranleduy2000/ncalc +[4]: https://opensource.com/sites/default/files/uploads/calculatornplus_sqrt-frac.png (Calculator N+ graphical interface) +[5]: https://github.com/axkr/symja_android_library +[6]: https://play.google.com/store/apps/details?id=com.duy.calculator.free +[7]: https://github.com/tranleduy2000/ncalc/blob/master/README.md diff --git a/sources/tech/20191126 Make Lua development easy with Luarocks.md b/sources/tech/20191126 Make Lua development easy with Luarocks.md new file mode 100644 index 0000000000..23a636b826 --- /dev/null +++ b/sources/tech/20191126 Make Lua development easy with Luarocks.md @@ -0,0 +1,233 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Make Lua development easy with Luarocks) +[#]: via: (https://opensource.com/article/19/11/getting-started-luarocks) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Make Lua development easy with Luarocks +====== +Luarocks makes it easy to get started with Lua, a lightweight, +efficient, and embeddable scripting language. +![Coding on a computer][1] + +Bash too basic? Too much whitespace in Python? Go too corporate? + +You should try Lua, a lightweight, efficient, and embeddable scripting language supporting procedural programming, object-oriented programming, functional programming, data-driven programming, and data description. And best of all, it uses explicit syntax for scoping! + +Lua is also small. Lua's source code is just 24,000 lines of C, the Lua interpreter (on 64-bit Linux) built with all standard Lua libraries is 247K, and the Lua library is 421K. + +You might think that such a small language must be too simplistic to do any real work, but in fact Lua has a vast collection of third-party libraries (including GUI toolkits), it's used extensively in video game and film production for 3D shaders, and is a common scripting language for video game engines. To make it easy to get started with Lua, there's even a package manager called [Luarocks][2]. + +### What is Luarocks? + +Python has PIP, Ruby has Gems, Java has Maven, Node has npm, and Lua has Luarocks. Luarocks is a website and a command. The website is home to open source libraries available for programmers to add to their Lua projects. The command searches the site and installs libraries (defined as "rocks") upon demand. + +### What is a programming library? + +If you're new to programming, you might think of a "library" as just a place where books are stored. Programming libraries ("lib" or "libs" for short) are a little like a book library in the sense that both of these things contain information that someone else has already worked to discover, and which you can borrow so you have to do less work. + +For example, if you were writing code that measures how much stress a special polymer can withstand before breaking, you might think you'd have to be pretty clever with math. But if there was already an open source library specifically designed for exactly that sort of calculation, then you could include that library in your code and let it solve that problem for you (provided you give the library's internal functions the numbers it needs in order to perform an accurate calculation). + +In open source programming, you can install libraries freely and use other people's work at will. Luarocks is the mechanism for Lua that makes it quick and easy to find and use a Lua library. + +### Installing Luarocks + +The **luarocks** command isn't actually _required_ to use packages from the Luarocks website, but it does keep you from having to leave your text editor and venture onto the worldwide web [of potential distractions]. To install Luarocks, you first need to install Lua. + +Lua is available from [lua.org][3] or, on Linux, from your distribution's software repository. For example, on Fedora, CentOS, or RHEL: + + +``` +`$ sudo dnf install lua` +``` + +On Debian and Ubuntu: + + +``` +`$ sudo apt install lua` +``` + +On Windows and Mac, you can download and install Lua from the website. + +Once Lua is installed, install Luarocks. If you're on Linux, the **luarocks** command is available in your distribution's repository. + +On Mac, you can install it with [Brew][4] or compile from source: + + +``` +$ wget +$ tar zxpf luarocks-X.Y.Z.tar.gz +$ cd luarocks-X.Y.Z +$ ./configure; sudo make bootstrap +``` + +On Windows, follow the [install instructions][5] on the Luarocks wiki. + +### Search for a library with Luarocks + +The typical usage of the **luarocks** command, from the perspective of a user rather than a developer, involves searching for a library required by some Lua application you want to run and installing that library. + +To search for the Lua package **luasec** (a library providing HTTPS support for **luarocks**), try this command: + + +``` +$ luarocks search luasec +Warning: falling back to curl - +install luasec to get native HTTPS support + +Search results: +=============== + +Rockspecs and source rocks: +\--------------------------- + +luasec +   0.9-1 (rockspec) - +   0.9-1 (src) - +   0.8.2-1 (rockspec) - +[...] +``` + +### Install a library with Luarocks + +To install the **luasec** library: + + +``` +$ luarocks install --local luasec +[...] +gcc -shared -o ssl.so -L/usr/lib64 +src/config.o src/ec.o src/x509.o [...] +-L/usr/lib -Wl,-rpath,/usr/lib: -lssl -lcrypto + +luasec 0.9-1 is now installed in +/home/seth/.luarocks (license: MIT) +``` + +You can install Lua libraries locally or on a systemwide basis. A _local_ install indicates that the Lua library you install is available to you, but no other user of the computer. If you share your computer with someone else, and you each have your own [login account][6], then you probably want to install a library systemwide. However, if you're the only user of your computer, it's a good habit to install libraries locally, if only because that's the appropriate method when you develop with Lua. + +If you're _developing_ a Lua application, then you probably want to install a library to a project directory instead. In Luarocks terminology, this is a _tree_. Your default tree when installing libraries locally is **$HOME/.luarocks**, but you can redefine it arbitrarily. + + +``` +$ mkdir local +$ luarocks --tree=./local install cmark +Installing +gcc -O2 -fPIC -I/usr/include -c cmark_wrap.c [..] +gcc -O2 -fPIC -I/usr/include -c ext/blocks.c -o ext/blocks.o [..] +[...] +No existing manifest. Attempting to rebuild... +cmark 0.29.0-1 is now installed in +/home/seth/downloads/osdc/example-lua/./local +(license: BSD2) +``` + +The library (in this example, the **cmark** library) is installed to the path specified by the **\--tree** option. You can verify it by listing the contents of the destination: + + +``` +$ find ./local/ -type d -name "cmark" +./local/share/lua/5.1/cmark +./local/lib/luarocks/rocks/cmark +``` + +You can use the library in your Lua code by defining the **package.path** variable to point to your local rocks directory: + + +``` +package.path = package.path .. ';local/share/lua/5.3/?.lua' + +require("cmark") +``` + +### Getting information about an installed rock + +You can see information about an installed rock with the **show** option: + + +``` +$ luarocks show luasec +LuaSec 0.9-1 - A binding for OpenSSL library +to provide TLS/SSL communication over LuaSocket. + +This version delegates to LuaSocket the TCP +connection establishment between +the client and server. Then LuaSec uses this +connection to start a secure TLS/SSL session. + +License:        MIT +Homepage:       +Installed in:   /home/seth/.luarocks +[...] +``` + +This provides you with a summary of what a library provides from a user's perspective, displays the project homepage in case you want to investigate further, and shows you where the library is installed. In this example, it's installed in my home directory in a **.luarocks** folder. This assures me that it's installed locally, which means that if I migrate my home directory to a different computer, I'll retain my Luarocks configuration and installs. + +### Get a list of installed rocks + +You can list all installed rocks on your system with the **list** option: + + +``` +$ luarocks list + +Installed rocks: +\---------------- + +luasec +   0.9-1 (installed) - /home/seth/.luarocks/lib/luarocks/rocks + +luasocket +   3.0rc1-2 (installed) - /home/seth/.luarocks/lib/luarocks/rocks + +luce +   scm-0 (installed) - /home/seth/.luarocks/lib/luarocks/rocks + +tekui +   1.07-1 (installed) - /home/seth/.luarocks/lib/luarocks/rocks +``` + +This displays the rocks you have installed in the default install location. Developers can override this by using the **\--tree** option to redefine the active tree. + +### Remove a rock + +If you want to remove a rock, you can do that with Luarocks using the **remove** option: + + +``` +`$ luarocks remove --local cmark` +``` + +This removes a library (in this example, the **cmark** library) from your local tree. Developers can override this by using the **\--tree** option to redefine the active tree. + +If you want to remove _all_ the rocks you have installed, use the **purge** option instead. + +### Luarocks rocks + +Whether you're a user exploring exciting new Lua applications and need to install some dependencies or you're a developer using Lua to create exciting new applications, Luarocks makes your job easy. Lua is a beautiful and simple language, and Luarocks is perfectly suited to be its package manager. Give both a try today! + +Discussing Tarantool this year at the Percona Live Data Performance Conference. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/getting-started-luarocks + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者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/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: http://luarocks.org +[3]: http://lua.org +[4]: http://brew.sh +[5]: https://github.com/luarocks/luarocks/wiki/Installation-instructions-for-Windows +[6]: https://opensource.com/article/19/11/add-user-gui-linux diff --git a/sources/tech/20191127 Create virtual machines with Cockpit in Fedora.md b/sources/tech/20191127 Create virtual machines with Cockpit in Fedora.md new file mode 100644 index 0000000000..7fd09b985d --- /dev/null +++ b/sources/tech/20191127 Create virtual machines with Cockpit in Fedora.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Create virtual machines with Cockpit in Fedora) +[#]: via: (https://fedoramagazine.org/create-virtual-machines-with-cockpit-in-fedora/) +[#]: author: (Karlis KavacisPaul W. Frields https://fedoramagazine.org/author/karlisk/https://fedoramagazine.org/author/pfrields/) + +Create virtual machines with Cockpit in Fedora +====== + +![][1] + +This article shows you how to install the software you need to use Cockpit to create and manage virtual machines on Fedora 31. Cockpit is [an interactive admin interface][2] that lets you access and manage systems from any supported web browser. With [virt-manager being deprecated][3] users are encouraged to use Cockpit instead, which is meant to replace it. + +Cockpit is an actively developed project, with many plugins available that extend how it works. For example, one such plugin is “Machines,” which interacts with libvirtd and lets users create and manage virtual machines. + +### Installing software + +The required software prerequisites are _libvirt_, _cockpit_ and _cockpit-machines_. To install them on Fedora 31, run the following command from a terminal [using sudo][4]: + +``` +$ sudo dnf install libvirt cockpit cockpit-machines +``` + +Cockpit is also included as part of the “Headless Management” package group. This group is useful for a Fedora based server that you only access through a network. In that case, to install it, use this command: + +``` +$ sudo dnf groupinstall "Headless Management" +``` + +### Setting up Cockpit services + +After installing the necessary packages it’s time to enable the services. The _libvirtd_ service runs the virtual machines, while Cockpit has a socket activated service to let you access the Web GUI: + +``` +$ sudo systemctl enable libvirtd --now +$ sudo systemctl enable cockpit.socket --now +``` + +This should be enough to run virtual machines and manage them through Cockpit. Optionally, if you want to access and manage your machine from another device on your network, you need to expose the service to the network. To do this, add a new rule in your firewall configuration: + +``` +$ sudo firewall-cmd --zone=public --add-service=cockpit --permanent +$ sudo firewall-cmd --reload +``` + +To confirm the services are running and no issues occurred, check the status of the services: + +``` +$ sudo systemctl status libvirtd +$ sudo systemctl status cockpit.socket +``` + +At this point everything should be working. The Cockpit web GUI should be available at or . Or, enter the local network IP in a web browser on any other device connected to the same network. (Without SSL certificates setup, you may need to allow a connection from your browser.) + +### Creating and installing a machine + +Log into the interface using the user name and password for that system. You can also choose whether to allow your password to be used for administrative tasks in this session. + +Select _Virtual Machines_ and then select _Create VM_ to build a new box. The console gives you several options: + + * Download an OS using Cockpit’s built in library + * Use install media already downloaded on the system you’re managing + * Point to a URL for an OS installation tree + * Boot media over the network via the [PXE][5] protocol + + + +Enter all the necessary parameters. Then select _Create_ to power up the new virtual machine. + +At this point, a graphical console appears. Most modern web browsers let you use your keyboard and mouse to interact with the VM console. Now you can complete your installation and use your new VM, just as you would [via virt-manager in the past][6]. + +* * * + +_Photo by [Miguel Teixeira][7] on [Flickr][8] (CC BY-SA 2.0)._ + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/create-virtual-machines-with-cockpit-in-fedora/ + +作者:[Karlis KavacisPaul W. Frields][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/karlisk/https://fedoramagazine.org/author/pfrields/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/11/create-vm-cockpit-816x345.jpg +[2]: https://cockpit-project.org/ +[3]: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/8.0_release_notes/rhel-8_0_0_release#virtualization_4 +[4]: https://fedoramagazine.org/howto-use-sudo/ +[5]: https://en.wikipedia.org/wiki/Preboot_Execution_Environment +[6]: https://fedoramagazine.org/full-virtualization-system-on-fedora-workstation-30/ +[7]: https://flickr.com/photos/miguelteixeira/ +[8]: https://flickr.com/photos/miguelteixeira/2964851828/ diff --git a/sources/tech/20191127 How to Manage Remote Windows Host using Ansible.md b/sources/tech/20191127 How to Manage Remote Windows Host using Ansible.md new file mode 100644 index 0000000000..fa82225b79 --- /dev/null +++ b/sources/tech/20191127 How to Manage Remote Windows Host using Ansible.md @@ -0,0 +1,233 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Manage Remote Windows Host using Ansible) +[#]: via: (https://www.linuxtechi.com/manage-windows-host-using-ansible/) +[#]: author: (James Kiarie https://www.linuxtechi.com/author/james/) + +How to Manage Remote Windows Host using Ansible +====== + +**Ansible** is increasingly becoming the go-to platform for application deployment, and software provisioning among developers owing to its ease of use and flexibility. Furthermore, it is easy to set up and no agent is required to be installed on remote nodes, instead, Ansible uses password less SSH authentication to manage remote Unix/Linux hosts. In this topic, however, we are going to see how you can manage Windows Host using Ansible. + +[![Manage-Windows-Hosts-using-Ansible][1]][2] + +**Lab setup** + +We shall use the setup below to accomplish our objective + + * Ansible Control node   –    CentOS 8          –     IP: 192.168.43.13 + * Windows 10 node         –    Windows 10     –     IP: 192.168.43.147 + + + +### Part 1: Installing Ansible on the Control node (CentOS 8) + +Before anything else, we need to get Ansible installed on the Control node which is the CentOS 8 system. + +#### Step 1: Verify that Python3 is installed on Ansible control node + +Firstly, we need to confirm if Python3 is installed. CentOS 8 ships with Python3 but if it’s missing for any reason, install using the command: + +``` +# sudo dnf install python3 +``` + +Next, make Python3 the default Python version by running: + +``` +# sudo alternatives --set python /usr/bin/python3 +``` + +To verify if python3 is installed, run the command: + +``` +# python --version +``` + +**![check-python-version][1] ** + +**Read Also :** **[How to Install Ansible (Automation Tool) on CentOS 8/RHEL 8][3]** + +#### Step 2: Install a virtual environment for running Ansible + +For this exercise, an isolated environment for running and testing Ansible is preferred. This will keep at bay issues such as dependency problems and package conflicts. The isolated environment we are going to create is called a virtual environment. + +Firstly, let’s begin with the installation of the virtual environment on CentOS 8. + +``` +# sudo dnf install python3-virtualenv +``` + +![install-python3-virtualenv][1] + +After the installation of the virtual environment, create a virtual workspace by running: + +``` +# virtualenv env +``` + +![virtualenv-env-ansible][1] + +``` +# source env/bin/activate +``` + +![source-env-bin-activate-ansible][1] + +Great! Observer that the prompt has now changed to (env). + +#### Step 3: Install Ansible + +After the creation of the virtual environment, proceed and install Ansible automation tool using pip as shown: + +``` +# pip install ansible +``` + +![pip-install-Ansible][1] + +You can later confirm the installation of Ansible using the command: + +``` +# ansible --version +``` + +![check-ansible-version][1] + +To test Ansible and see if it’s working on our Ansible Control server run: + +``` +# ansible localhost -m ping +``` + +![Test-ansible-for-connectivity][1] + +Great! Next, we need to define the Windows host or system on a host file on the Ansible control node. Therefore, open the default hosts file + +``` +# vim /etc/ansible/hosts +``` + +Define the Windows hosts as shown below. + +![Ansible-hosts-file][1] + +**Note:** The username and password point to the user on the Windows host system. + +Next, save and exit the configuration file. + +#### Step 4: Install Pywinrm + +Unlike in Unix systems where Ansible uses SSH to communicate with remote hosts, with Windows it’s a different story altogether. To communicate with Windows hosts, you need to install Winrm. + +To install winrm, once again, use pip tool as shown: + +``` +# pip install pywinrm +``` + +![install-pywinrm][1] + +### Part 2: Configuring Windows Host + +In this section, we are going to configure our Windows 10 remote host system to connect with the Ansible Control node. We are going to install the **WinRM listener-** short for **Windows Remote** – which will allow the connection between the Windows host system and the Ansible server. + +But before we do so, your Windows host system needs to fulfill a few requirements for the installation to succeed: + + * Your Windows host system should be **Windows 7 or later**. For Servers, ensure that you are using **Windows Server 2008** and later versions. + * Ensure your system is running **.NET Framework 4.0** and later. + * Windows **PowerShell** should be Version 3.0 & later + + + +With all the requirements met, now follow the steps stipulated below: + +#### Step 1: Download the WinRM script on Windows 10 host + +WinRM can be installed using a script that you can download from this [link][4]. Copy the entire script and paste it onto the notepad editor. Thereafter, ensure you save the WinRM script at the most convenient location. In our case, we have saved the file on the Desktop under the name  ConfigureRemotingForAnsible.ps1 + +#### Step 2: Run the WinRM script on Windows 10 host + +Next, run PowerShell as the Administrator + +![Run-PowerShell-as-Administrator][1] + +Navigate to the script location and run it. In this case, we have navigated to the Desktop location where we saved the script. Next, proceed and execute the WinRM script on the WIndows host: + +``` +.\ConfigureRemotingForAnsible.ps1 +``` + +This takes about a minute and you should get the output shown below. The output shows that WinRM has successfully been installed. + +![set-up-WinRM-on-Windows10][1] + +### Part 3: Connecting to Windows Host from Ansible Control Node + +To test connectivity to the Windows 10 host, run the command: + +``` +# ansible winhost -m win_ping +``` + +![Ansible-ping-windows-host-machine][1] + +The output shows that we have indeed established a connection to the remote Windows 10 host from the Ansible Control node. This implies that we can now manage the remote Windows host using Ansible Playbooks. Let’s create a sample playbook for the Windows host system. + +### Part 4: Creating and running a playbook for Windows 10 host + +In this final section, we shall create a playbook and create a task that will install Chocolatey on the remote host. Chocolatey is a package manager for Windows system. The play is defined as shown: + +``` +# vim chocolatey.yml +--- +- host: winhost + gather_facts: no + tasks: + - name: Install Chocolatey on Windows10 + win_chocolatey: name=procexp status=present +``` + +![Ansible-Playbook-install-chocolatey][1] + +Save and close the yml file. Next, execute the playbook as shown + +``` +# ansible-playbook chocolatey.yml +``` + +![Ansible-playBook-succeeded][1] + +The output is a pointer that all went well. And this concludes this topic on how you can manage Windows host using Ansible. + + * [Facebook][5] + * [Twitter][6] + * [LinkedIn][7] + * [Reddit][8] + + + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/manage-windows-host-using-ansible/ + +作者:[James Kiarie][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linuxtechi.com/author/james/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: http://www.linuxtechi.com/wp-content/uploads/2019/11/Manage-Windows-Hosts-using-Ansible.jpg +[3]: http://www.linuxtechi.com/install-ansible-centos-8-rhel-8/ +[4]: https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1 +[5]: http://www.facebook.com/sharer.php?u=https%3A%2F%2Fwww.linuxtechi.com%2Fmanage-windows-host-using-ansible%2F&t=How%20to%20Manage%20Remote%20Windows%20Host%20using%20Ansible +[6]: http://twitter.com/share?text=How%20to%20Manage%20Remote%20Windows%20Host%20using%20Ansible&url=https%3A%2F%2Fwww.linuxtechi.com%2Fmanage-windows-host-using-ansible%2F&via=Linuxtechi +[7]: http://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.linuxtechi.com%2Fmanage-windows-host-using-ansible%2F&title=How%20to%20Manage%20Remote%20Windows%20Host%20using%20Ansible +[8]: http://www.reddit.com/submit?url=https%3A%2F%2Fwww.linuxtechi.com%2Fmanage-windows-host-using-ansible%2F&title=How%20to%20Manage%20Remote%20Windows%20Host%20using%20Ansible diff --git a/sources/tech/20191128 Monitoring Linux and Windows hosts with Glances.md b/sources/tech/20191128 Monitoring Linux and Windows hosts with Glances.md new file mode 100644 index 0000000000..0c480bc6ea --- /dev/null +++ b/sources/tech/20191128 Monitoring Linux and Windows hosts with Glances.md @@ -0,0 +1,231 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Monitoring Linux and Windows hosts with Glances) +[#]: via: (https://opensource.com/article/19/11/monitoring-linux-glances) +[#]: author: (David Both https://opensource.com/users/dboth) + +Monitoring Linux and Windows hosts with Glances +====== +The Glances tool offers more information about system performance than +other sysadmin monitoring tools. +![Code going into a computer.][1] + +Sysadmins have many tools to view and manage running processes. For me, these primarily used to be **top**, **atop**, and **htop**. A few years ago, I found [Glances][2], a tool that displays information that none of my other favorites do. All of these tools monitor CPU and memory usage, and most of them list information about running processes (at the very least). However, Glances also monitors filesystem I/O, network I/O, and sensor readouts that can display CPU and other hardware temperatures as well as fan speeds and disk usage by hardware device and logical volume. + +### Glances + +I mentioned Glances in my article [_4 open source tools for Linux system monitoring_][3], but I will delve into it more deeply in this article. If you read my previous article, some of this information may be familiar, but you should also find some new things here. + +Glances is cross-platform because it is written in Python. It can be installed on Windows and other hosts with current versions of Python installed. Most Linux distributions (Fedora in my case) have Glances in their repositories. If not, or if you are using a different operating system (such as Windows), or you just want to get it right from the source, you can find instructions for downloading and installing it in [Glances' GitHub repo][4]. + +I suggest running Glances on a test machine while you try the commands in this article. If you don't have a physical host available for testing, you can explore Glances on a virtual machine (VM), but you won't see the hardware sensors section; after all, a VM has no real hardware. + +To start Glances on a Linux host, open a terminal session and enter the command **glances**. + +Glances has three main sections—Summary, Process, and Alerts—as well as a sidebar. I'll explore them and other details for using Glances now. + +### Summary section + +In its top few lines, Glances' Summary section contains much of the same information as you'll find in other monitors' summary sections. If you have enough horizontal space in your terminal, Glances can show CPU usage with both a bar graph and a numeric indicator; otherwise it will show only the number. + +I like Glances' Summary section better than the ones in other monitors (like **top**); I think it provides the right information in an easily understandable format. + +![Glances display][5] + +The Glances display on a busy Linux host. In the interest of clarity, not all possible displays are shown in the left sidebar. + +The Summary section above provides an overview of the system's status. The first line shows the hostname, the Linux distribution, the kernel version, and the system uptime. + +The next four lines display CPU, memory usage, swap, and load statistics. The left column displays the percentages of CPU, memory, and swap space that are in use. It also shows the combined statistics for all CPUs present in the system. + +Press the **1** key to toggle between the consolidated CPU usage display and the display of the individual CPUs. The following image shows the Glances display with individual CPU statistics. + +![Glances display][6] + +Glances showing the individual CPU statistics. + +This view includes some additional CPU statistics. In either display mode, the descriptions of the CPU usage fields can help you interpret the data displayed in the CPU section. Notice that CPUs are numbered starting at 0 (Zero). + +**CPU** | This is the current CPU usage as a percentage of the total available. +---|--- +**user** | These are the applications and other programs running in user space, i.e., not in the kernel. +**system** | These are kernel-level functions. It does not include CPU time taken by the kernel itself, just the kernel system calls. +**idle** | This is the idle time, i.e., time not used by any running process. +**nice** | This is the time used by processes that are running at a positive, nice level. +**irq** | These are the interrupt requests that take CPU time. +**iowait** | These are CPU cycles that are spent waiting for I/O to occur—this is wasted CPU time. +**steal** | The percentage of CPU cycles that a virtual CPU waits for a real CPU while the hypervisor is servicing another virtual processor. +**ctx-sw** | These are the number of context switches per second; it represents the number of times per second that the CPU switches from running one process to another. +**inter** | This is the number of hardware interrupts per second. A hardware interrupt occurs when a hardware device, such as a hard drive, tells a CPU that it has completed a data transfer or that a network interface card is ready to accept more data. +**sw_int** | Software interrupts tell the CPU that some requested task has completed or that the software is ready for something. These tend to be more common in kernel-level software. + +#### About nice numbers + +Nice numbers are the mechanism used by administrators to affect the priority of a process. It is not possible to change the priority of a process directly, but changing the nice number can modify the results of the kernel scheduler’s priority setting algorithm. Nice numbers run from -20 to +19 where higher numbers are nicer. The default nice number is 0 and the default priority is 20. Setting the nice number higher than zero increases the priority number somewhat, thus making the process nicer and therefore less greedy of CPU cycles. Setting the nice number to a more negative number results in a lower priority number making the process less nice. Nice numbers can be changed using the renice command or from within top, atop, and htop. + +#### Memory + +The Memory portion of the Summary section contains statistics about memory usage. + +**MEM** | This shows the memory usage as a percent of the total amount available. +---|--- +**total** | This is the total amount of RAM memory installed in the host, less any amount assigned to the display adapter. +**used** | This is the total amount of memory in use by the system and application programs but not including cache or buffers. +**free** | This is the amount of free memory. +**active** | This is the amount of actively used memory—inactive memory is subject to swapping to disk should the need arise. +**inactive** | This is memory that is in use but that has not been accessed for some time. +**buffers** | This is memory that is used for buffer space; it is usually used by communications and I/O such as networking. The data is received and stored until the software can retrieve it for use or it can be sent to a storage device or transmitted out to the network. +**cached** | This is the memory used to store data for disk transfer until it can be used by a program or stored to disk. + +The Swap section is self-explanatory if you understand a bit about swap space and how it works. This shows how much total swap space is available, how much is used, and how much is left. + +The Load part of the Summary section displays the one-, five-, and 15-minute load averages. + +You can use the numeric keys **1**, **3**, **4**, and **5** to alter your view of the data in this section. The **2** key toggles the left sidebar on and off. + +#### More about load averages + +Load averages are commonly misunderstood, even though they are a key criterion for measuring CPU usage. But what does it really mean when I say that the one- (or five- or 10-) minute load average is 4.04, for example? Load average can be considered a measure of demand for the CPU; it is a number that represents the average number of instructions waiting for CPU time, so it is a true measure of CPU performance. + +For example, a fully utilized single-processor system CPU would have a load average of 1. This means that the CPU is keeping up exactly with demand; in other words, it has perfect utilization. A load average of less than 1 means the CPU is underutilized, and a load average greater than 1 means the CPU is overutilized and that there is pent-up, unsatisfied demand. For example, a load average of 1.5 in a single-CPU system indicates that one-third of the CPU instructions must wait to be executed until the preceding one has completed. + +This is also true for multiple processors. If a four-CPU system has a load average of 4, then it has perfect utilization. If it has a load average of 3.24, for example, then three of its processors are fully utilized, and one is utilized at about 24%. In the example above, a four-CPU system has a one-minute load average of 4.04, meaning there is no remaining capacity among the four CPUs, and a few instructions are forced to wait. A perfectly utilized four-CPU system would show a load average of 4.00, meaning that the system is fully loaded but not overloaded. + +The optimum load average condition is for the load average to equal the total number of CPUs in a system. That would mean that every CPU is fully utilized, and no instruction must be forced to wait. But reality is messy, and optimum conditions are seldom met. If a host were running at 100% utilization, this would not allow for spikes in CPU load requirements. + +The longer-term load averages indicate overall utilization trends. + +_Linux Journal_ published an excellent article [about load averages][7], the theory, the math behind them, and how to interpret them, in its December 1, 2006, issue. Unfortunately, _Linux Journal_ has ceased publication, and its archives are no longer available directly, so the link is to a third-party archive. + +#### Finding CPU hogs + +One of the reasons for using a tool like Glances is to find processes that are taking up too much CPU time. Open a new terminal session (different from the one running Glances), and enter and start the following CPU-hogging Bash program. + + +``` +`X=0;while [ 1 ];do echo $X;X=$((X+1));done` +``` + +This program is a CPU hog and will use up every available CPU cycle. Allow it to run while you finish this article and experiment with Glances. It will provide you with an idea of what a program that hogs CPU cycles looks like. Be sure to observe the effects on the load averages over time, as well as the cumulative time in the **TIME+** column for this process. + +### Process section + +The Process section displays standard information about each process that is running. Depending upon the viewing mode and the size of the terminal screen, different columns of information will be displayed for the running processes. The default mode with a wide-enough terminal displays the columns listed below. The columns that are displayed change automatically if the terminal screen is resized. The following columns are typically displayed for each process from left to right. + +**CPU%** | This is the amount of CPU time as a percentage of a single core. For example, 98% represents 98% of the available CPU cycles for a single core. Multiple processes can show up to 100% CPU usage. +---|--- +**MEM%** | This is the amount of RAM memory used by the process as a percentage of the total virtual memory in the host. +**VIRT** | This is the amount of virtual memory used by the process in human-readable format, such as 12M for 12 megabytes. +**RES** | This refers to the amount of physical (resident) memory used by the process. Again, this is in human-readable format, with an indicator of **K**, **M**, or **G**, to specify kilobytes, megabytes, or gigabytes. +**PID** | Every process has an identification number, called the PID. This number can be used in commands, such as **renice** and **kill**, to manage the process. Remember that the **kill** utility can send signals to another process besides the “kill” signal. +**USER** | This is the name of the user that owns the process. +**TIME+** | This indicates the cumulative amount of CPU time accrued by the process since it started. +**THR** | This is the total number of threads currently running for this process. +**NI** | This is the nice number of the process. +**S** | This is the current status; it can be (**R**)unning, (**S**)leeping, (**I**)dle, **T** or **t** when the process is stopped during a debugging trace, or (**Z**)ombie. A zombie is a process that has been killed but has not completely died, so it continues to consume some system resources, such as RAM. +**R/s and W/s** | These are the disk reads and writes per second. +**Command** | This is the command used to start the process. + +Glances usually determines the default sort column automatically. Processes can be sorted automatically (**a**), or by CPU (**c**), memory (**m**), name (**p**), user (**u**), I/O rate (**i**), or time (**t**). Processes are automatically sorted by the most-used resource. In the images above, the **TIME+** column is highlighted. + +### Alerts section + +Glances also shows warnings and critical alerts, including the time and duration of the event, at the bottom of the screen. This can be helpful when you're attempting to diagnose problems and cannot stare at the screen for hours at a time. These alert logs can be toggled on or off with the **l** (lower-case L) key, warnings can be cleared with the **w** key, while alerts and warnings can all be cleared with **x**. + +### Sidebar + +Glances has a very nice sidebar on the left that displays information that is not available in **top** or **htop**. While **atop** displays some of this data, Glances is the only monitor that displays data about sensors. After all, sometimes it is nice to see the temperatures inside your computer. + +The individual modules, disk, filesystem, network, and sensors can be toggled on and off using the **d**, **f**, **n**, and **s** keys, respectively. The entire sidebar can be toggled using **2**. Docker stats can be displayed in the sidebar with **D**. + +Note that hardware sensors are not displayed when Glances is running on a virtual machine. + +### Getting help + +You can get help by pressing the **h** key; dismiss the help page by pressing **h** again. The Help page is rather terse, but it does show the available interactive options and how to turn them on and off. The [man page][8] has terse explanations of the options that can be used when launching Glances. + +You can press **q** or **Esc** to exit Glances. + +### Configuration + +Glances does not require a configuration file to work properly. If you choose to have one, the system-wide instance of the configuration file will be located in **/etc/glances/glances.conf**. Individual users can have a local instance at **~/.config/glances/glances.conf**, which will override the global configuration. The primary purpose of these configuration files is to set thresholds for warnings and critical alerts. You can also specify whether certain modules are displayed by default or not. + +The file **/usr/local/share/doc/glances/README.rst** contains additional useful information, including optional Python modules you can install to support some optional Glances features. + +### Command-line options + +Glances provides command-line options that allow it to start up in specific viewing modes. For example, the command **glances -2** starts the program with the left sidebar disabled. + +### Remote and more + +By starting it in server mode, you can use Glances to monitor remote hosts: + + +``` +`[root@testvm1 ~]# glances -s` +``` + +You can then connect to the server from the client with: + + +``` +`[root@testvm2 ~]# glances -c @testvm1` +``` + +Glances can show a list of Glances servers along with a summary of their activity. It also has a web interface so you can monitor remote Glances servers from a browser. Recent versions of Glances can also display Docker statistics. + +There are also pluggable modules for Glances that provide measurement data not available in the base program. + +### Limitations + +Although Glances can monitor many aspects of a host, it cannot manage processes. It cannot change the nice number of a process nor kill one, as **top** and **htop** can. Glances is not an interactive tool. It is used strictly for monitoring. External tools like **kill** and **renice** can be used to manage processes. + +Glances can only show the processes that are taking the majority of the resource specified, such as CPU time, in the available space. If there is room to list just 10 processes, that is all you will be able to see. Glances does not provide scrolling or reverse-sort options that would enable you to see any other than the top X processes. + +### The impact of measurement + +The [observer effect][9] is a physics theory that states, "simply observing a situation or phenomenon necessarily changes that phenomenon." This is also true when measuring Linux system performance. + +Merely using a monitoring tool alters the system's use of resources, including memory and CPU time. The **top** utility and most other monitors use perhaps 2% tor 3% of a system's CPU time. The Glances utility has much more impact than the others; it usually uses between 10% and 20% of CPU time, and I have seen it use as much as 40% of one CPU in a very large and active system with 32 CPUs. That is a lot, so consider its impact when you think about using Glances as your monitor. + +My personal opinion is that this is a small price to pay when you need the capabilities of Glances. + +### Summary + +Despite its lack of interactive capabilities, such as the ability to **renice** or **kill** processes, and its high CPU load, I find Glances to be a very useful tool. The complete [Glances documentation][10] is available on the internet, and the Glances man page has startup options and interactive command information. + +* * * + +_Parts of this article are based on David Both's new book, _[Using and Administering Linux: Volume 2 – Zero to SysAdmin: Advanced Topics][11].__ + +David Both shares his favorite system monitoring tools for understanding what is going on in any... + +David Both explains the importance of keeping hardware cool and shares some Linux tools that can... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/monitoring-linux-glances + +作者:[David Both][a] +选题:[lujun9972][b] +译者:[译者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/dboth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_development_programming.png?itok=4OM29-82 (Code going into a computer.) +[2]: https://nicolargo.github.io/glances/ +[3]: https://opensource.com/life/16/2/open-source-tools-system-monitoring +[4]: https://github.com/nicolargo/glances/blob/master/README.rst#installation +[5]: https://opensource.com/sites/default/files/uploads/glances-figure-1.png (Glances display) +[6]: https://opensource.com/sites/default/files/uploads/glances-figure-2.png (Glances display) +[7]: https://archive.org/details/Linux-Journal-2006-12/page/n81 +[8]: https://linux.die.net/man/1/glances +[9]: https://en.m.wikipedia.org/wiki/Observer_effect_(physics) +[10]: https://glances.readthedocs.io/en/stable/ +[11]: https://www.apress.com/us/book/9781484250488 diff --git a/sources/tech/20191129 Holiday gift guide- Books for the learner, explorer, or tinkerer on your list.md b/sources/tech/20191129 Holiday gift guide- Books for the learner, explorer, or tinkerer on your list.md new file mode 100644 index 0000000000..dd3c603bc4 --- /dev/null +++ b/sources/tech/20191129 Holiday gift guide- Books for the learner, explorer, or tinkerer on your list.md @@ -0,0 +1,130 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Holiday gift guide: Books for the learner, explorer, or tinkerer on your list) +[#]: via: (https://opensource.com/article/19/11/books-wishlist-2019) +[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja) + +Holiday gift guide: Books for the learner, explorer, or tinkerer on your list +====== +Get our list of books to give as gifts or add to your own wishlist this +holiday season. +![4 books that spell out open][1] + +It is my pleasure to introduce Opensource.com's selection of books that would make excellent holiday gift ideas. We hope you find them interesting items to give as gifts this holiday season or to add to your own holiday wishlist. Each book exhibits qualities that make them excellent gifts for open source enthusiasts, as they all encourage learning, exploring, and tinkering. + +### The Big Book of Maker Camp Projects + +![The Big Book of Maker Camp Projects][2] + +**by Sandy Roberts** + +[_The Big Book of Maker Camp Projects_][3] contains dozens of projects that are perfect for maker camps or individuals looking to tinker. Projects cover a wide range of topics ranging from making faux campfires using LEDs and Circuit Playground Express (CPX) boards to tie-dye t-shirts and other wearable crafts. There are plenty of projects to keep maker camp participants engaged and entertained. + +### How Open Source Ate Software + +* * * + +* * * + +* * * + +**![How Open Source Ate Software ][4]** + +**by Gordon Haff** + +Learn more about the history of open source with [_How Open Source Ate Software_][5]. This brief, 180-page book explores how open source became the phenomenon that it is today. This book is an excellent read for anyone interested in where open source came from and how it changed the way software is developed. + +### The Rust Programming Language + +* * * + +* * * + +* * * + +**![The Rust Programming Language ][6]** + +**by Steve Klabnik and Carol Nichols** + +Learn one of the hot, new programming languages with [_The Rust Programming Language_][7]. Yes, this is a print edition of the exact same book that is installed with Rust and can be read in your browser by running **rustup doc --book**, but a physical book offers some benefits by giving the material inside a little more structure than the free HTML version. It is easier to digest material covered over a two-page spread instead of having to scroll through a long web page. Just be sure to get the edition with "Covers Rust 2018" on the cover, so you get a print copy that covers the latest Rust edition. + +### Secret Coders: The Complete Box Set + +* * * + +* * * + +* * * + +**![Secret Coders][8]** + +**by Gene Luen Yang & Mike Holmes** + +[_Secret Coders: The Complete Box Set_][9] collects all six volumes in the Secret Coder series. This series of graphic novels introduces readers to the world of coding by following the exploits of the three protagonists, Hopper, Eni, and Josh, as they explore coding and fight against the schemes of Dr. One-Zero. Each book in the series builds upon the volumes that precede it, and by the time readers have finished the series, they should have an excellent understanding of basic programming concepts. + +### Thing Explainer + +* * * + +* * * + +* * * + +**![Thing Explainer][10]** + +**by Randall Munroe** + +[_Thing Explainer_][11], by the creator of the [xkcd webcomic][12], is a book in the same vein as David Macaulay's [_The Way Things Work_][13] and similar titles. This book, as one would expect from the title, explains things. Using only the 1,000 most common words in the English language and illustrations, Munroe explains airplanes, tectonic plates, and more. + +### Open role-playing games and dice tower + +![Pathfinder][14] | ![Starfinder][15] +---|--- +![Fate Core][16] | ![Fate Accelerated][17] + +If you would like to spend time with your friends and family having exciting adventures, consider one of several pen-and-paper role-playing games with rules books that are released under an open license. + +For example, Paizo's [_Pathfinder_][18] and [_Starfinder_][19] are released under the [Open Game License][20], and [_Fate Core_][21] and [_Fate Accelerated_][22] from Evil Hat are released under the Open Game License and a Creative Commons Attribution license. + +But these are just a few examples, there are plenty of role-playing games that are [released under an open license][23], so there are games out there for a variety of tastes. You can also pair the rule books with a homemade dice tower using these Creative Commons Attribution-NonCommercial licensed [dice tower plans][24]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/books-wishlist-2019 + +作者:[Joshua Allen Holm][a] +选题:[lujun9972][b] +译者:[译者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/holmja +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDU_OSDC_BYU_520x292_FINAL.png?itok=NVY7vR8o (4 books that spell out open) +[2]: https://opensource.com/sites/default/files/uploads/the_big_book_of_maker_camp_projects.jpg (The Big Book of Maker Camp Projects) +[3]: http://www.kaleidoscopeenrichment.com/home/the-big-book-of-maker-camp-projects/ +[4]: https://opensource.com/sites/default/files/uploads/how_open_source_ate_software.jpg (How Open Source Ate Software ) +[5]: https://www.apress.com/us/book/9781484238936 +[6]: https://opensource.com/sites/default/files/uploads/the_rust_programming_language.jpg (The Rust Programming Language ) +[7]: https://nostarch.com/Rust2018 +[8]: https://opensource.com/sites/default/files/uploads/secret_coders_the_complete_boxed_set.jpeg (Secret Coders) +[9]: https://us.macmillan.com/secretcodersthecompleteboxedset/geneluenyang/9781250294685/ +[10]: https://opensource.com/sites/default/files/uploads/thing_explainer.png (Thing Explainer) +[11]: https://xkcd.com/thing-explainer/ +[12]: https://xkcd.com/ +[13]: https://en.wikipedia.org/wiki/The_Way_Things_Work +[14]: https://opensource.com/sites/default/files/uploads/pathfinder_100px.jpg (Pathfinder) +[15]: https://opensource.com/sites/default/files/uploads/starfinder_100px.jpg (Starfinder) +[16]: https://opensource.com/sites/default/files/uploads/fate_core_100px.jpg (Fate Core) +[17]: https://opensource.com/sites/default/files/uploads/fate_accelerated_100px.jpg (Fate Accelerated) +[18]: https://paizo.com/pathfinder +[19]: https://paizo.com/starfinder +[20]: https://en.wikipedia.org/wiki/Open_Game_License +[21]: https://www.evilhat.com/home/fate-core/ +[22]: https://www.evilhat.com/home/fae/ +[23]: https://opensource.com/article/19/5/free-rpg-day +[24]: https://msraynsford.blogspot.com/2016/05/working-dice-tower-with-plans.html diff --git a/sources/tech/20191129 How to write a Python web API with Django.md b/sources/tech/20191129 How to write a Python web API with Django.md new file mode 100644 index 0000000000..ed16fc40f8 --- /dev/null +++ b/sources/tech/20191129 How to write a Python web API with Django.md @@ -0,0 +1,247 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to write a Python web API with Django) +[#]: via: (https://opensource.com/article/19/11/python-web-api-django) +[#]: author: (Rachel Waston https://opensource.com/users/rachelwaston) + +How to write a Python web API with Django +====== +Django is one of the most popular frameworks for Python API development. +Learn how to use it in this quick tutorial. +![Hands on a keyboard with a Python book ][1] + +[Django][2] is the comprehensive web framework by which all other frameworks are measured. One of the most popular names in Python API development, Django has surged in popularity since its start in 2005. + +Django is maintained by the Django Software Foundation and has experienced great community support, with over 11,600 members worldwide. On Stack Overflow, Django has around 191,000 tagged questions. Websites like Spotify, YouTube, and Instagram rely on Django for application and data management. + +This article demonstrates a simple API to fetch data from a server using the GET method of the HTTP protocol. + +### Set up a project + +First, create a structure for your Django application; you can do this at any location on your system: + + +``` +$ mkdir myproject +$ cd myproject +``` + +Then, create a virtual environment to isolate package dependencies locally within the project directory: + + +``` +$ python3 -m venv env +$ source env/bin/activate +``` + +On Windows, use the command **env\Scripts\activate** to activate your Python virtual environment. + +### Install Django and the Django REST framework + +Next, install the Python modules for Django and Django REST: + + +``` +$ pip3 install django +$ pip3 install djangorestframework +``` + +### Instantiate a new Django project + +Now that you have a work environment for your app, you must instantiate a new Django project. Unlike a minimal framework like [Flask][3], Django includes dedicated commands for this process (note the trailing **.** character in the first command): + + +``` +$ django-admin startproject tutorial . +$ cd tutorial +$ django-admin startapp quickstart +``` + +Django uses a database as its backend, so you should sync your database before beginning development. The database can be managed with the **manage.py** script that was created when you ran the **django-admin** command. Because you're currently in the **tutorial** directory, use the **../** notation to run the script, located one directory up: + + +``` +$ python3 ../manage.py makemigrations +No changes detected +$ python4 ../manage.py migrate +Operations to perform: +  Apply all migrations: admin, auth, contenttypes, sessions +Running migrations: +  Applying contenttypes.0001_initial... OK +  Applying auth.0001_initial... OK +  Applying admin.0001_initial... OK +  Applying admin.0002_logentry_remove_auto_add... OK +  Applying admin.0003_logentry_add_action_flag_choices... OK +  Applying contenttypes.0002_remove_content_type_name... OK +  Applying auth.0002_alter_permission_name_max_length... OK +  Applying auth.0003_alter_user_email_max_length... OK +  Applying auth.0004_alter_user_username_opts... OK +  Applying auth.0005_alter_user_last_login_null... OK +  Applying auth.0006_require_contenttypes_0002... OK +  Applying auth.0007_alter_validators_add_error_messages... OK +  Applying auth.0008_alter_user_username_max_length... OK +  Applying auth.0009_alter_user_last_name_max_length... OK +  Applying auth.0010_alter_group_name_max_length... OK +  Applying auth.0011_update_proxy_permissions... OK +  Applying sessions.0001_initial... OK +``` + +### Create users in Django + +Create an initial user named **admin** with the example password of **password123**: + + +``` +$ python3 ../manage.py createsuperuser \ +  --email [admin@example.com][4] \ +  --username admin +``` + +Create a password when you're prompted. + +### Implement serializers and views in Django + +For Django to be able to pass information over to an HTTP GET request, the information object must be translated into valid response data. Django implements **serializers** for this. + +In your project, define some serializers by creating a new module named **quickstart/serializers.py**, which you'll use for data representations: + + +``` +from django.contrib.auth.models import User, Group +from rest_framework import serializers + +class UserSerializer(serializers.HyperlinkedModelSerializer): +    class Meta: +        model = User +        fields = ['url', 'username', 'email', 'groups'] + +class GroupSerializer(serializers.HyperlinkedModelSerializer): +    class Meta: +        model = Group +        fields = ['url', 'name'] +``` + +A [view][5] in Django is a function that takes a web request and returns a web response. The response can be HTML, or an HTTP redirect, or an HTTP error, a JSON or XML document, an image or TAR file, or anything else you can get over the internet. To create a view, open **quickstart/views.py** and enter the following code. This file already exists and has some boilerplate text in it, so keep that and append this text to the file: + + +``` +from django.contrib.auth.models import User, Group +from rest_framework import viewsets +from tutorial.quickstart.serializers import UserSerializer, GroupSerializer + +class UserViewSet(viewsets.ModelViewSet): +    """ +    API endpoint  allows users to be viewed or edited. +    """ +    queryset = User.objects.all().order_by('-date_joined') +    serializer_class = UserSerializer + +class GroupViewSet(viewsets.ModelViewSet): +    """ +    API endpoint  allows groups to be viewed or edited. +    """ +    queryset = Group.objects.all() +    serializer_class = GroupSerializer +``` + +### Generate URLs with Django + +Now you can generate URLs so people can access your fledgling API. Open **urls.py** in a text editor and replace the default sample code with this code: + + +``` +from django.urls import include, path +from rest_framework import routers +from tutorial.quickstart import views + +router = routers.DefaultRouter() +router.register(r'users', views.UserViewSet) +router.register(r'groups', views.GroupViewSet) + +# Use automatic URL routing +# Can also include login URLs for the browsable API +urlpatterns = [ +    path('', include(router.urls)), +    path('api-auth/', include('rest_framework.urls', namespace='rest_framework')) +] +``` + +### Adjust your Django project settings + +The settings module for this example project is stored in **tutorial/settings.py**, so open that in a text editor and add **rest_framework** to the end of the **INSTALLED_APPS** list: + + +``` +INSTALLED_APPS = [ +    ... +    'rest_framework', +] +``` + +### Test your Django API + +You're now ready to test the API you've built. First, start up the built-in server from the command line: + + +``` +`$ python3 manage.py runserver` +``` + +You can access your API by navigating to the URL **** using **curl**: + + +``` +$ curl --get +[{"url":" +``` + +Or use Firefox or the [open source web browser][6] of your choice: + +![A simple Django API][7] + +For more in-depth knowledge about RESTful APIs using Django and Python, see the excellent [Django documentation][8]. + +### Why should I use Django? + +The major benefits of Django: + + 1. The size of the Django community is ever-growing, so you have lots of resources for guidance, even on a complicated project. + 2. Features like templating, routing, forms, authentication, and management tools are included by default. You don't have to hunt for external tools or worry about third-party tools introducing compatibility issues. + 3. Simple constructs for users, loops, and conditions allow you to focus on writing code. + 4. It's a mature and optimized framework that is extremely fast and reliable. + + + +The major drawbacks of Django are: + + 1. Django is complex! From a developer's point of view, Django can be trickier to learn than a simpler framework. + 2. There's a big ecosystem around Django. This is great once you're comfortable with Django, but it can be overwhelming when you're still learning. + + + +Django is a great option for your application or API. Download it, get familiar with it, and start developing an amazing project! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/python-web-api-django + +作者:[Rachel Waston][a] +选题:[lujun9972][b] +译者:[译者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/rachelwaston +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd (Hands on a keyboard with a Python book ) +[2]: https://www.djangoproject.com/ +[3]: https://opensource.com/article/19/11/python-web-api-flask +[4]: mailto:admin@example.com +[5]: https://docs.djangoproject.com/en/2.2/topics/http/views/ +[6]: https://opensource.com/article/19/7/open-source-browsers +[7]: https://opensource.com/sites/default/files/uploads/django-api.png (A simple Django API) +[8]: https://docs.djangoproject.com/en/2.2 diff --git a/sources/tech/20191130 7 maker gifts for kids and teens.md b/sources/tech/20191130 7 maker gifts for kids and teens.md new file mode 100644 index 0000000000..a821b221e3 --- /dev/null +++ b/sources/tech/20191130 7 maker gifts for kids and teens.md @@ -0,0 +1,185 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (7 maker gifts for kids and teens) +[#]: via: (https://opensource.com/article/19/11/maker-gifts-kids) +[#]: author: (Jess Weichler https://opensource.com/users/cyanide-cupcake) + +7 maker gifts for kids and teens +====== +Make your holiday gift shopping easy with this guide to gifts sure to +spark creativity and innovation in babies, kids, tweens, teens, and +beyond. +![Gift box opens with colors coming out][1] + +Struggling with what gifts to give the young person in your life this holiday season? Here are my top picks for open source presents that will spark creativity and inspire for years to come. + +### Hummingbird Robotics Kit + +![Hummingbird Robotics Kit][2] + +**Ages**: 8 to adult + +**What it is:** The [Hummingbird Robotics Kit][3] is a complete robotics kit with a microcontroller, motors, LEDs, and sensors. The robot brain has special ports that little hands can easily attach robot components to. The Hummingbird kits don't come with a body, empowering users to create their own. + +**Why I love it:** The Hummingbird works with multiple programming languages—from visual (BirdBlox, MakeCode, Snap) to text (Python and Java)— making it scalable as users' coding skills increase. All the components are exactly as you'd find them at an electronics store, not obscured by plastic like other robot kits. This demystifies the inner workings of robots and makes it easy to source more parts if needed. + +Because there is no set project, the Hummingbird is the perfect robot for creativity. + +The Hummingbird Bit has open source software and firmware. It works on Linux, Windows, Mac, Chromebook, Android, and iOS. + +**Cost:** Starts at US$ 99. + +### Makey Makey Classic + +![Makey Makey Classic][4] + +**Ages:** 6 to adult + +**What it is:** [Makey Makey Classic][5] turns any conductive object, from marshmallows to a friend, into a computer key. + +You use alligator clips to connect the Makey Makey to the conductive object of your choice. Then, you close the circuit between the ground connection and any trigger key by touching both conductive objects at the same time. The Makey Makey is a good way to safely explore electricity at home while creating interesting ways to interact with your computer. + +**Why I love it:** Makey Makey can be paired with video games made in Scratch to create unique controllers that further immerse users in the game. The possibilities are endless, from instruments made of toilet rolls and foil to interactive art and stories. It works on Linux, Windows, and Mac computers with a USB port. + +**Cost:** US$ 49.95 + +### Arduino Uno + +![Arduino Uno][6] + +**Ages**: 10 to adult + +**What it is:** Arduinos are microcontrollers that can be purchased with or without an electronics kit, and they come in many different flavors, though I like the [Arduino Uno][7] the best. Additional components, such as LEDs, motors, and sensors can be purchased as needed from any electronics shop. + +**Why I love it:** The Arduino Uno is well-documented, so it's easy for makers to find tutorials online. The Arduino can bring a wide variety of electronic projects to life, from simple to complex. The Arduino features open source firmware and hardware. It works on Linux, Mac, and Windows. + +**Cost:** Starts at US$ 22.00 for the board. The overall cost varies depending on projects and skill level. + +### DIY maker kit + +![A maker kit assembled in a quick trip to the hardware store][8] + +**Ages**: 8 to adult + +**What it is:** Many of today's makers, creators, and programmers started out tinkering with objects that happened to be lying around. You can create an awesome maker kit for the young person in your life with a quick trip to the nearest electronics store. Here's what's in my maker kit: + + * Eye goggles + * Hammer + * Nails and screws + * Scraps of wood + * Screwdrivers + * Wire + * LEDs + * Piezo buzzer + * Motors + * AA battery pack with leads + * Wire cutters + * Cardboard + * Masking tape + * Scrap fabric + * Buttons + * Thread + * Needles + * Zippers + * Hooks + * A cool tackle box to store everything in + + + +**Why I love it: **Remember when you were a kid and your parents brought home an empty cardboard box that you turned into a spaceship or a house or a supercomputer? That's what a DIY maker kit can be for older kids. + +Raw components empower kids to experiment and use their imaginations. A DIY maker kit can be completely customized for the recipient. Be sure to throw in some components the giftee may have never thought to create with, like giving an avid sewer some LEDs or a woodworker fabric. + +**Cost:** Variable + +### Heuristic play basket + +![Heuristic play kit][9] + +**Ages:** 8 months to 5 years + +**What it is:** Heuristic play baskets are filled with interesting objects made from natural, non-toxic materials for infants and toddlers to explore using their five senses. It's open-ended, self-directed play at its best. The idea is that an adult will supervise (but not direct) a child's use of the basket and its items for a half-hour, then put the basket away until the next time. + +It's easy to create a lovely play basket with common household objects. Try to include items with varying textures, sounds, smells, shapes, and weights. Here are some ideas to get you started. + + * Colander or ridged wicker basket to hold everything + * Wooden spoon + * Metal whisks and spoons + * Scrubbing brush + * Sponge + * Small egg carton + * Cardboard tubes + * Small rolling pin + * Textured washcloth + * Rocks + * Handbells + * Crochet doily + * Small tin with a lid + + + +Play baskets should not include anything easily breakable or small enough to fit inside a paper towel roll, as these are choking hazards, and all objects should be cleaned thoroughly before being given to a child. + +**Why I love it:** Play baskets are fantastic for sensory development and helping young children ask questions and explore the world around them. This is an important part of developing a maker mindset! + +It's easy to obtain suitable items for a play basket; you probably already have many interesting objects in your home or at your nearest second-hand store. Toddlers will use their play baskets differently than infants. These objects will grow with children as they begin to mimic adult life and tell stories through their play. + +**Cost:** Variable + +### Hello Ruby + +![Hello Ruby book cover][10] + +**Ages**: 5–8 + +**What it is:** _[Hello Ruby][11]: Adventures in Coding_ is an illustrated book by Linda Liukas that introduces children to programming concepts through a fun narrative about a girl who encounters problems and friends, each of which represents code. Liukas' other _Hello Ruby_ books are subtitled _Expedition to the Internet_ and _Journey Inside the Computer_, and _Adventures in Coding_ has been published in more than 20 languages. + +**Why I love it:** The author accompanies the book with a number of free, fun, and unplugged activities that can be downloaded and printed out from the Hello Ruby website. These activities teach coding concepts and also touch on artistic expression, communication, and even time management. + +**Cost:** List price for the hardcover book is US$ 17.99, but you may find it at a lower price through local or online booksellers. + +### Girls Who Code: Learn to Code and Change the World + +![Girls Who Code book cover][12] + +**Ages**: 10 to adult + +**What it is:** Written by Reshma Saujani, the founder of Girls Who Code, _[Girls Who Code: Learn to Code and Change the World][13]_ gives practical information about the tech world for young girls (and boys). It covers a wide variety of topics, including coding languages, use-cases, terminology and vocabulary, career options, and profiles and interviews with people in the tech industry. + +**Why I love it:** This book tells the story of tech in ways even most websites meant for adults miss out on. Technology encompasses so many disciplines, and it's important for young people to understand they can use it to solve real-world problems and make a difference. + +**Cost:** List price for the hardcover book is US$ 17.99 and US$ 10.99 for the paperback, but you may find it at a lower price through local or online booksellers. + +I can see the brightness of curiosity in my six year old niece Shuchi's eyes when she explores a... + +Scratch is a free educational programming language for kids, available in 50 different languages... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/maker-gifts-kids + +作者:[Jess Weichler][a] +选题:[lujun9972][b] +译者:[译者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/cyanide-cupcake +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_gift_giveaway_box_520x292.png?itok=w1YQhNH1 (Gift box opens with colors coming out) +[2]: https://opensource.com/sites/default/files/uploads/hummingbird.png (Hummingbird Robotics Kit) +[3]: https://www.birdbraintechnologies.com/hummingbirdbit/ +[4]: https://opensource.com/sites/default/files/uploads/makeymakey2.jpg (Makey Makey Classic) +[5]: https://makeymakey.com/ +[6]: https://opensource.com/sites/default/files/uploads/arduinouno.jpg (Arduino Uno) +[7]: https://www.arduino.cc/ +[8]: https://opensource.com/sites/default/files/makerbox-makerkit.jpg (A maker kit assembled in a quick trip to the hardware store) +[9]: https://opensource.com/sites/default/files/makerbox-sensorykit.jpg (Heuristic play kit) +[10]: https://opensource.com/sites/default/files/uploads/helloruby2.jpg (Hello Ruby book cover) +[11]: https://www.helloruby.com/ +[12]: https://opensource.com/sites/default/files/uploads/girlswhocodebook.jpg (Girls Who Code book cover) +[13]: https://girlswhocode.com/book/girls-code-learn-code-change-world/ diff --git a/sources/tech/20191201 Modernize your Linux desktop with Enlightenment.md b/sources/tech/20191201 Modernize your Linux desktop with Enlightenment.md new file mode 100644 index 0000000000..b975ca18e7 --- /dev/null +++ b/sources/tech/20191201 Modernize your Linux desktop with Enlightenment.md @@ -0,0 +1,72 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Modernize your Linux desktop with Enlightenment) +[#]: via: (https://opensource.com/article/19/12/linux-enlightenment-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Modernize your Linux desktop with Enlightenment +====== +This article is part of a special series of 24 days of Linux desktops. +Enlightenment offers a smooth, appealing, and modern Linux desktop +experience, even on older hardware. +![Light at the end of the tunnel][1] + +One of Linux's many advantages is its ability to install and run on old computers. What Linux can't _technically_ do is make an old computer's hardware magically perform better. After all, the hardware is the same hardware as ever, and sometimes old hardware feels notably slow when processing modern software that tries to take advantage of new hardware features. This means that an old computer running Linux must run a rather basic desktop, because too many effects or animations might use up precious memory and graphics processing, resulting in sluggish performance. + +The [Enlightenment][2] desktop wasn't designed to solve this exact problem, but in practice, that's exactly what it does. With its finely crafted foundation and custom libraries, Enlightenment provides an attractive and dynamic environment that runs smoothly on old computers and low-powered systems like the [Raspberry Pi][3]. You never have to feel like you're compromising your user experience (UX) just because you're running modest hardware. True to its name, it delivers on the promise of eco-friendly computing and is the first line of defense (or second, if Linux itself is the first) against planned obsolescence. + +Of course, you don't have to run Enlightenment on an old computer. It works just as well on new computers. + +Install Enlightenment from your distribution's software repository. Past versions of Enlightenment are still popular today (and some are still maintained as separate projects), and all of them are good, but the latest versions are the ones above 20. After installing it, log out of your current desktop session so you can log into your new Enlightenment desktop. By default, your session manager (KDM, GDM, LightDM, or XDM, depending on your setup) will continue to log you into your default desktop, so you must override the default when logging in. + +Here's how to override the default and switch to Enlightenment on GNOME Desktop Manager: + +![Selecting the Enlightenment desktop in GDM][4] + +And on KDM: + +![Selecting the Enlightenment desktop in KDM][5] + +The first time you log into Enlightenment, it asks for some basic preferences, such as your desired language setting, size of window title bars, and so on. It's OK to accept the defaults when you're unsure, and it's safe to ignore the warning about ConnMan not being available. Most distributions use [NetworkManager][6] instead of Enlightenment's own network manager, ConnMan. + +### Enlightenment desktop + +By default, the Enlightenment desktop provides desktop icons for common places, such as your home directory, the root directory, and a temporary directory. There's also a "shelf," a docking area at the bottom of the screen where major applications can go when minimized, where launchers can be created for quick access to common applications, and where applets (such as volume control, a clock, keyboard layout, and so on) run. + +Anything configurable in Enlightenment is configurable with a right-click. + +Here's what Enlightenment looks like on Fedora: + +![Enlightenment running on Fedora][7] + +### Features + +To access an application menu, click anywhere on the desktop. Enlightenment is a desktop environment, but it's disguised as a window manager. Its primary task is to help you arrange and manage windows, but it also ships with a file manager (called Fileman) and has options to use a network manager called ConnMan and its own terminal called Terminology. It also has a global settings panel to help manage themes, keyboard shortcuts, screen resolution, and so on. + +Because Enlightenment ships with just a few applications, your default application set can stay the same as what you were using before trying Enlightenment. All of your K apps or GNOME applications and third-party applications like Firefox or Blender or LibreOffice will function as usual. + +Enlightenment is a smooth, appealing, and modern desktop experience. Settle in and become enlightened! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/linux-enlightenment-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者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/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/light_tunnel_death.jpg?itok=ERLZDTfl (Light at the end of the tunnel) +[2]: https://www.enlightenment.org/ +[3]: https://opensource.com/resources/raspberry-pi +[4]: https://opensource.com/sites/default/files/uploads/advent-enlightenment-gdm.jpg (Selecting the Enlightenment desktop in GDM) +[5]: https://opensource.com/sites/default/files/uploads/advent-enlightenment-kdm.jpg (Selecting the Enlightenment desktop in KDM) +[6]: https://en.wikipedia.org/wiki/NetworkManager +[7]: https://opensource.com/sites/default/files/uploads/advent-enlightenment.jpg (Enlightenment running on Fedora) diff --git a/sources/tech/20191202 Holiday gift guide- Linux and open source tech gadgets.md b/sources/tech/20191202 Holiday gift guide- Linux and open source tech gadgets.md new file mode 100644 index 0000000000..abc9c9f3e4 --- /dev/null +++ b/sources/tech/20191202 Holiday gift guide- Linux and open source tech gadgets.md @@ -0,0 +1,109 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Holiday gift guide: Linux and open source tech gadgets) +[#]: via: (https://opensource.com/article/19/12/gadgets-holiday-wishlist) +[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja) + +Holiday gift guide: Linux and open source tech gadgets +====== +Each of these gadgets encourages learning, exploring, and tinkering, +qualities that reflect the values and interests of open source +enthusiasts. +![new techie gadgets representing innovation][1] + +Everything on Opensource.com's annual selection of tech gadgets would make an excellent holiday gift for your friends and family—or even something to add to your own holiday wishlist. Each of these gadgets encourages learning, exploring, and tinkering, qualities that reflect the values and interests of open source enthusiasts. + +### Circuit Playground Express + +![Circuit Playground Express][2] + +The [Circuit Playground Express][3] packs a wide array of interesting tech into a tiny, programmable package, which makes it an excellent choice for wearable projects. It features a motion sensor, temperature sensor, light sensor, sound sensor, speaker, 10 lights that can display any color, and much more. It can be programmed using block-based, drag-and-drop coding or JavaScript using [Microsoft MakeCode for Adafruit][4], or it can be programmed in Python using [CircuitPython][5]. Advanced users can use the [Arduino IDE][6] to program the board. + +### FreedomBox + +![FreedomBox][7] + +[FreedomBox][8] is a self-hosted, privacy-focused alternative to a wide variety of online services. With FreedomBox, you can handle your email with a web-based IMAP client, calendar, online chatting, file storage, and [more][9] without being tied to services outside of your control. The FreedomBox software is built around Debian GNU/Linux, and all the services it can provide are open source. If you want a ready-to-go home server, you can purchase the [Pioneer edition FreedomBox Home Server][10]. If you want to be more "hands-on," you can download the [FreedomBox software][11] and install it on the supported hardware of your choice. + +### Hack laptop + +![Hack computer][12] + +The [Hack][13] laptop is an ASUS E406MA laptop preloaded with a version of [Endless OS][14] that adds learning activities designed to teach children how to program. With only 4GB of RAM and a 64GB eMMC drive for storage, the Hack laptop is not a super-powerful computer, but it is a nice laptop for basic tasks like word processing, web browsing, and email. If the pre-installed Endless OS is not right for the user, the hardware is compatible with recent releases of most other Linux distributions. + +### Kano Computer Kit + +![Kano Computer Kit][15] + +The [Kano Computer Kit][16] is a computer kit based around a custom Raspberry Pi 3 and running the open source [Kano OS][17]. Users follow step-by-step instructions to build their own computer. Once the computer is assembled, there are more than 100 programming activities that provide even more learning and entertainment. The Kano Computer Kit comes with everything needed to get started, except a monitor. The more expensive [Computer Kit Touch][18] comes with a touchscreen display. + +### micro:bit + +![micro:bit][19] + +The [micro:bit][20] is a tiny, programmable circuit board that is great for learning and making. The board features an array of lights on one side of the circuit board, and the board can be programmed to respond to button presses, light, motion, and temperature. It can be programmed using drag-and-drop block or JavaScript using the [MakeCode editor][21], or it can be programmed in Python. + +### pi-top [4] + +![pi-top \[4\]][22] + +The [pi-top [4]][23] is a kit designed to work with the Raspberry Pi 4. This kit includes a case, cables, and a selection of programmable sensors, buttons, and LEDs. The pi-top [4] is designed to work with [pi-topOS][24], but the kit can work reasonably well with other Raspberry Pi [operating systems][25]. + +### Raspberry Pi 4 (and other models) + +![Raspberry Pi 4][26] + +Of all the single-board computers on the market, the Raspberry Pi is probably the most well-known. Part of the reason for the Raspberry Pi's fame is the copious amount of ancillary material available for learning about projects that can be made using a Raspberry Pi. The [_MagPi Magazine_][27] is published monthly, contains tons of interesting projects, and is free to download. So if you give or receive the official [Raspberry Pi 4 Desktop Kit][28], another Raspberry Pi kit from a vendor, or a custom project built around a Raspberry Pi, you are sure to have an excellent gift, one that can keep on giving as _MagPi_ publishes more and more tutorials. + +### Bonus: Tux Super Key Sticker + +![Tux Super Key Keyboard Sticker][29] + +Sure, a sticker is not a tech gadget, but this [Tux sticker][30] from Think Penguin can turn the Windows key on any computer keyboard into a Tux key. This inexpensive sticker can provide a little extra Linux-ness to any computer keyboard. The sticker is also a great item to buy in bulk and give out throughout the year as a Linux advocacy item. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/gadgets-holiday-wishlist + +作者:[Joshua Allen Holm][a] +选题:[lujun9972][b] +译者:[译者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/holmja +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/innovation_virtual_gadgets_device_drone.png?itok=JTAgRb-1 (new techie gadgets representing innovation) +[2]: https://opensource.com/sites/default/files/uploads/circuit_playground_express.jpg (Circuit Playground Express) +[3]: https://learn.adafruit.com/adafruit-circuit-playground-express/overview +[4]: https://learn.adafruit.com/makecode +[5]: https://www.adafruit.com/category/956 +[6]: https://www.arduino.cc/en/Main/Software +[7]: https://opensource.com/sites/default/files/uploads/freedombox_pioneer_edition.jpg (FreedomBox) +[8]: https://freedombox.org +[9]: https://wiki.debian.org/FreedomBox/Features +[10]: https://freedombox.org/buy/ +[11]: https://freedombox.org/download/ +[12]: https://opensource.com/sites/default/files/uploads/endless_hack_laptop.jpg (Hack computer) +[13]: https://hack-computer.com/ +[14]: https://endlessos.com/download/ +[15]: https://opensource.com/sites/default/files/uploads/kano_computer_kit.jpeg (Kano Computer Kit) +[16]: https://kano.me/store/us/products/computer-kit +[17]: https://kano.me/downloadable/us +[18]: https://kano.me/us/store/products/computer-kit-touch +[19]: https://opensource.com/sites/default/files/uploads/microbit.png (micro:bit) +[20]: https://www.microbit.org/ +[21]: https://makecode.microbit.org/ +[22]: https://opensource.com/sites/default/files/uploads/pi-top_4.png (pi-top [4]) +[23]: https://www.pi-top.com/products/pi-top-4 +[24]: https://www.pi-top.com/products/os +[25]: https://www.raspberrypi.org/downloads/ +[26]: https://opensource.com/sites/default/files/uploads/raspberry_pi_4_model_b.jpg (Raspberry Pi 4) +[27]: https://magpi.raspberrypi.org/ +[28]: https://www.raspberrypi.org/blog/whats-inside-the-raspberry-pi-4-desktop-kit/ +[29]: https://opensource.com/sites/default/files/uploads/tux_key_sticker.jpg (Tux Super Key Keyboard Sticker) +[30]: https://www.thinkpenguin.com/gnu-linux/tux-super-key-keyboard-sticker diff --git a/sources/tech/20191203 App Highlight- Caligator is a Beautiful Calculator - Converter.md b/sources/tech/20191203 App Highlight- Caligator is a Beautiful Calculator - Converter.md new file mode 100644 index 0000000000..b177be913e --- /dev/null +++ b/sources/tech/20191203 App Highlight- Caligator is a Beautiful Calculator - Converter.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (App Highlight: Caligator is a Beautiful Calculator & Converter) +[#]: via: (https://itsfoss.com/caligator/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +App Highlight: Caligator is a Beautiful Calculator & Converter +====== + +You will find [lots of useful applications for Linux][1], however, not all of them focus primarily on the user experience. + +Sure, the user interface may end up being something nice and simple but not necessarily pleasing to look at. + +For the very same reason, I wanted to have a calculator and converter app on Linux similar to [Numi][2] (which is available only for macOS). I know we already have a superb calculator app like [Qalculate][3] but I am not a fan of its simple looking (read boring) interface. + +Recently, I came across something very similar – ‘[Caligator][4]‘ made by [Team XenoX][5]. + +### It’s Not Your Typical Calculator + +![][6] + +When compared to traditional calculator apps – this is something different. It lets you calculate or convert by simply typing on it (as you can see in the image above). + +Just like you type in to search for something on Google (or on [privacy-oriented Google alternatives][7]), the user has to just type the instruction naturally to get the output. + +Not just limited to the ability to understand instructions for conversions, it also displays the output as you type. So, you do not have to wait and press another button to get the result. + +![How Caligator Works][8] + +### Feature Overview + +![Caligator Screenshot][9] + +For now, you can perform any kind of arithmetic calculations and convert things like Currency, Length, Weight, and more. + +You can choose between a dark or light theme. However, for now, the app might get stuck when you try to change the theme. Atleast, I’m facing this issue right now on Pop!_OS 19.04. + +They would fix the issue in the next update probably. + +In addition to what’s possible, the developers have planned (as per the [official announcement][10]) the following features for the next update: + + * Font size preferences + * Export options + * Click to copy + * More themes + + + +### Getting Caligator on Linux + +You can directly head on to find its [GitHub releases][11] page and download the asset suitable for you. + +For Linux, they have three file formats available: AppImage, Deb files and source code. + +I suggest downloading the [AppImage][12] file. You just have to give it execute permission and then you can run Caligator on any Linux distribution. + +In addition to Linux, you can also try it on your Mac/Windows machine. + +[Caligator][4] + +**Wrapping Up** + +Caligator is still under development so you may encounter bugs. If you do, please open a bug report for the developers on their GitHub repository. + +While this may be in its early stage of development now, it is definitely an impressive project which should incorporate interesting features in the near future. + +I remember that elementary OS also has a [similar application called NaSC][13]. You may want to check it out as well. + +What do you think about ‘Caligator’? Also, if you know about some interesting new open source projects for desktop Linux, let us know in the comments below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/caligator/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/essential-linux-applications/ +[2]: https://numi.app/ +[3]: https://itsfoss.com/qalculate/ +[4]: https://caligator.now.sh/ +[5]: https://dev.to/teamxenox +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/caligator-screenshot.png?ssl=1 +[7]: https://itsfoss.com/privacy-search-engines/ +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/caligator-works.gif?ssl=1 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/caligator-screenshot-1.jpg?ssl=1 +[10]: https://dev.to/teamxenox/introducing-caligator-a-simple-yet-powerful-open-source-calculator-convertor-5f86 +[11]: https://github.com/sarthology/caligator/releases +[12]: https://itsfoss.com/use-appimage-linux/ +[13]: https://itsfoss.com/math-ubuntu-nasc/ diff --git a/sources/tech/20191203 Bash Script to Check Successful and Failed User Login Attempts on Linux.md b/sources/tech/20191203 Bash Script to Check Successful and Failed User Login Attempts on Linux.md new file mode 100644 index 0000000000..8ae58c08da --- /dev/null +++ b/sources/tech/20191203 Bash Script to Check Successful and Failed User Login Attempts on Linux.md @@ -0,0 +1,182 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Bash Script to Check Successful and Failed User Login Attempts on Linux) +[#]: via: (https://www.2daygeek.com/bash-script-to-check-successful-and-failed-user-login-attempts-on-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +Bash Script to Check Successful and Failed User Login Attempts on Linux +====== + +One of the typical tasks of Linux administrators is to check successful and failed login attempts in the Linux system. + +This ensures that there are no illegal attempts at the environment. + +It is very difficult to manually verify them because the output of the **“/var/log/secure”** file looks awkward. + +To make this easier and more effective, we need to write a bash script. + +Yes, you can achieve this using the following **[Bash script][1]**. + +I’ve included two shell scripts in this tutorial. + +These scripts will show the number of users logged into the system for a given date. Also, it shows successful login attempts and failed login attempts. + +The first **[shell script][2]** allows you to verify user access information for any date available in the **“/var/log/secure”** file. + +The second bash script allows you to send a mail with user access information on a daily basis. + +### Method-1 : Shell Script to Check Successful and Failed User Login Attempts on Linux + +This script allows you to verify user access information for a given date from the terminal. + +``` +# vi /opt/scripts/user-access-details.sh + +#!/bin/bash +echo "" +echo -e "Enter the Date, Use Double Space for date from 1 to 9 (Nov 3) and use Single Space for date from 10 to 31 (Nov 30): \c" +read yday +MYPATH=/var/log/secure* +yday=$(date --date='yesterday' | awk '{print $2,$3}') +yday=$(date | awk '{print $2,$3}') +tuser=$(grep "$yday" $MYPATH | grep "Accepted|Failed" | wc -l) +suser=$(grep "$yday" $MYPATH | grep "Accepted password|Accepted publickey|keyboard-interactive" | wc -l) +fuser=$(grep "$yday" $MYPATH | grep "Failed password" | wc -l) +scount=$(grep "$yday" $MYPATH | grep "Accepted" | awk '{print $9;}' | sort | uniq -c) +fcount=$(grep "$yday" $MYPATH | grep "Failed" | awk '{print $9;}' | sort | uniq -c) +echo "--------------------------------------------" +echo " User Access Report on: $yday" +echo "--------------------------------------------" +echo "Number of Users logged on System: $tuser" +echo "Successful logins attempt: $suser" +echo "Failed logins attempt: $fuser" +echo "--------------------------------------------" +echo -e "Success User Details:\n $scount" +echo "--------------------------------------------" +echo -e "Failed User Details:\n $fcount" +echo "--------------------------------------------" +``` + +Set an executable **[Linux file permission][3]** to **“user-access-details-1.sh”** file. + +``` +# chmod +x /opt/scripts/user-access-details-1.sh +``` + +When you run the script you will receive an alert like the one below. + +``` +# sh /opt/scripts/user-access-details.sh + +Enter the Date, Use Double Space for date from 1 to 9 (Nov 3) and use Single Space for date from 10 to 31 (Nov 30): Nov 6 +------------------------------------------ + User Access Report on: Nov 6 +------------------------------------------ +Number of Users logged on System: 1 +Successful logins attempt: 1 +Failed logins attempt: 0 +------------------------------------------ +Success User Details: + 1 root +------------------------------------------ +Failed User Details: +------------------------------------------ +``` + +When you run the script you will receive an alert like the one below. + +``` +# sh /opt/scripts/user-access-details.sh + +Enter the Date, Use Double Space for date from 1 to 9 (Nov 3) and use Single Space for date from 10 to 31 (Nov 30): Nov 30 +------------------------------------------ + User Access Report on: Nov 30 +------------------------------------------ +Number of Users logged on System: 20 +Successful logins attempt: 14 +Failed logins attempt: 6 +------------------------------------------ +Success User Details: + 1 daygeek + 1 root + 3 u1 + 4 u2 + 1 u3 + 2 u4 + 2 u5 +------------------------------------------ +Failed User Details: + 3 u1 + 3 u4 +------------------------------------------ +``` + +### Method-2 : Bash Script to Check Successful and Failed User Login Attempts With eMail Alert. + +This Bash script allows you to send a mail with user access details on a daily basis via email for yesterday’s date. + +``` +# vi /opt/scripts/user-access-details-2.sh + +#!/bin/bash +/tmp/u-access.txt +SUBJECT="User Access Reports on "date"" +MESSAGE="/tmp/u-access.txt" +TO="[email protected]" +MYPATH=/var/log/secure* +yday=$(date --date='yesterday' | awk '{print $2,$3}') +tuser=$(grep "$yday" $MYPATH | grep "Accepted|Failed" | wc -l) +suser=$(grep "$yday" $MYPATH | grep "Accepted password|Accepted publickey|keyboard-interactive" | wc -l) +fuser=$(grep "$yday" $MYPATH | grep "Failed password" | wc -l) +scount=$(grep "$yday" $MYPATH | grep "Accepted" | awk '{print $9;}' | sort | uniq -c) +fcount=$(grep "$yday" $MYPATH | grep "Failed" | awk '{print $9;}' | sort | uniq -c) +echo "--------------------------------------------" >> $MESSAGE +echo " User Access Report on: $yday" >> $MESSAGE +echo "--------------------------------------------" >> $MESSAGE +echo "Number of Users logged on System: $tuser" >> $MESSAGE +echo "Successful logins attempt: $suser" >> $MESSAGE +echo "Failed logins attempt: $fuser" >> $MESSAGE +echo "--------------------------------------------" >> $MESSAGE +echo -e "Success User Details:\n $scount" >> $MESSAGE +echo "--------------------------------------------" >> $MESSAGE +echo -e "Failed User Details:\n $fcount" >> $MESSAGE +echo "--------------------------------------------" >> $MESSAGE +mail -s "$SUBJECT" "$TO" < $MESSAGE +``` + +Set an executable permission to **“user-access-details-2.sh”** file. + +``` +# chmod +x /opt/scripts/user-access-details-2.sh +``` + +Finally add a **[cronjob][4]** to automate this. It will run everyday at 8’o clock. + +``` +# crontab -e + +0 8 * * * /bin/bash /opt/scripts/user-access-details-2.sh +``` + +**Note:** You will be getting an email alert everyday at 8 o’clock, which is for previous day’s user access information. + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/bash-script-to-check-successful-and-failed-user-login-attempts-on-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/category/bash-script/ +[2]: https://www.2daygeek.com/category/shell-script/ +[3]: https://www.2daygeek.com/understanding-linux-file-permissions/ +[4]: https://www.2daygeek.com/linux-crontab-cron-job-to-schedule-jobs-task/ diff --git a/sources/tech/20191203 How to write a security integration module for Ansible.md b/sources/tech/20191203 How to write a security integration module for Ansible.md new file mode 100644 index 0000000000..550dfd44a6 --- /dev/null +++ b/sources/tech/20191203 How to write a security integration module for Ansible.md @@ -0,0 +1,189 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to write a security integration module for Ansible) +[#]: via: (https://opensource.com/article/19/12/security-ansible-module) +[#]: author: (Adam Miller https://opensource.com/users/maxamillion) + +How to write a security integration module for Ansible +====== +Ansible automation offers a lot of potential for the information +security industry. Learn how to take advantage of it in this summary of +an AnsibleFest 2019 talk. +![Security monster][1] + +[Ansible][2] is a [radically simple IT automation platform][3] that makes your applications and systems easier to deploy. It allows you to avoid writing scripts or custom code to deploy and update your applications, systems, and various classifications of network-attached devices. Ansible allows you to automate in a language that approaches plain English with no agents to install on remote systems and uses native protocols based on device type—such as SSH for Unix-style operating systems, WinRM for Windows systems, REST APIs (**httpapi**) for REST API appliances, and many more. + +### Background + +At [AnsibleFest 2019][4], my colleague [Sumit Jaiswal][5] and I gave a talk, titled "[Ansible development deep dive: How to write a security integration module and collection for Ansible][6]," about something that we have been working on. This article recaps the finer points of our talk; I hope it will highlight the potential of what Ansible is—and can be capable of—in the realm of information security automation. + +A lot of this started with my colleague [Massimo Ferrari's][7] statement that "Ansible automation can be the _lingua franca_ to integrate and orchestrate the many security platforms spread across different domains." We spent a lot of time mulling this over; it may be obvious to DevOps and automation professionals who've discovered the power of Ansible, but infosec doesn't have similar tools that target the industry's problems in the same way. Therefore, Ferrari's statement offers a lot of potential for the infosec industry. + +In this article, I'll summarize two major points we highlighted in our AnsbileFest 2019 talk: + + * Ansible recommended development practices + * Classify what you're integrating with and how you connect to it (API or CLI?) + + + +### Ansible recommended development practices + +The Ansible engineering team likes to never write the words "best practice," because we can't possibly know what's best for you in your specific situation. You are the expert on topics as they apply to your unique environment and requirements. However, we can provide _recommendations_, which I'll outline from the perspective of an Ansible module developer. + +#### Modules + +Modules are user-focused and self-contained. This mostly means that the code contained in your module should be self-contained within your [module][8] or in a **[module_util][9]**. The latter is what allows us to share code between modules, but everything must be as self-contained as possible, as we don't want to introduce too many external dependencies. We also want each module to perform some sort of state management. Each module should be [idempotent][10], which basically means "inflict change if needed, otherwise, do not." A module should not attempt to contain a workflow (that's what [playbooks][11] are for), and we want to leave that up to the user. Modules shouldn't attempt to "do too much," such that you have one massive module that takes 100 arguments and, based on values provided by the user, performs wildly different actions on the target device. + +An example of what we generally want to avoid could go something like this: + + +``` +\- name: Create a virtual machine +  some_module: +    thing_to_do: "create_virtual_machine" +    name: "bobs_awesome_vm" +    storage_size: 100G +    ram: 24G +    vcpus: 4 + +\- name: Create a virtual storage volume +  some_module: +    thing_to_do: "create_virtual_storage_vol" +    name: "bobs_awesome_storage" +    storage_size: 1000G +    lun_id: 12 +``` + +In this example, the fictitious **some_module** is performing completely disjointed actions based on the value of **thing_to_do**. This is not a discrete, self-contained unit of work from the perspective of an Ansible module. These should be two separate modules that could even share code on the backend through a custom module_util (if that makes the developer's life easier). Either way, they should be separate modules so the user can easily define, read, and understand the task as written. As a developer, you want to make the module's interaction user-focused. + +Another aspect of being user-focused is that the user should not need any knowledge of the destination API in order to use the module effectively. The module should provide useful defaults, documentation, and examples that allow users to pick their own automation path. + +#### Collections + +[Ansible collections][12] are a relatively new concept, but they are generally seen as the future for Ansible content of all shapes and sizes. They allow Ansible content, such as modules, module_utils, plugins of all kinds, roles, docs, tests, playbooks, and whatever the community dreams up next, to exist as a cohesive unit to be tested, verified, and distributed as an entity. What's more (and this is its real advantage for developers) is that it decouples the content from the [Ansible Core runtime][13]. This allows Ansible content to be lifecycle-managed separately from Ansible itself, meaning it can be released as often or as infrequently as the content author or maintainer desires. No longer will new features have to wait six months for the next Ansible release. The collection authors can release as often as they desire. + +Collections are meant to be a simple progression into a brave new world where the Ansible Core execution engine is symbolically similar to [CPython][14]. Ansible collections are symbolically similar to Python modules found on [PyPI][15]. [Ansible Galaxy][16] is symbolically similar to PyPI as the de facto distribution mechanism. + +From a developer standpoint, you simply need to drop your files in the correct location and update any custom module_utils Python import paths. From a user perspective, you just need to add the **collection** namespace and name to the [play][11] or [block][17] that intends to use that content. + +### Classify what you're integrating with and how you connect to it + +In the security realm, appliance devices or software that is meant to be used like an appliance (network devices, embedded systems, and so on) sometimes present the administrator both an [application programming interface][18] (API) and a [command-line interface][19] (CLI). As a module developer, you must make some decisions in service of ease of development, maintainability of code, and, ultimately, consistent user experience. + +#### CLI + +If you are potentially going to wrap a CLI, ask yourself whether that CLI offers a consistent interface with output you can reasonably and consistently parse. Beyond that, does the CLI offer the ability to formulate idempotent transactions? While the majority of CLIs offer **get** and **set** types of transactions (especially on Unix/Linux systems), some of them do not, and this is something module authors need to consider. + +When considering CLI implementations with network or embedded devices that have a standard CLI but don't offer a traditional Unix shell, you should look into implementing a [cliconf plugin][20]. This type of plugin enables your users to interact with appliances or embedded devices in a way that's natural to the seasoned Ansible user and beginner alike. Alternatively, should you find yourself with a device that allows you to execute local Python code (_local_ to the device or system itself; a "managed host" in Ansible terminology), then consider the **[run_command][21]** module_util. The latter situation is effectively just a traditional [module development][22] workflow, as it would be for a traditional GNU/Linux distribution. + +#### API + +If the technology you are attempting to integrate with offers an API, determine whether that API is a local on-system API (local to the remote "managed host" system) or a remote API such as a [REST][23] API? + +In the event you find yourself with a local Python API and it's advantageous to use it instead of the REST API (in the event both are available), this situation is effectively the same as a traditional [module development][22] workflow in a GNU/Linux distribution. + +However, if the only option is a REST API, or if the available REST API is determined to be the best option, then writing an [httpapi connection plugin][24] is best for general ease of implementation, maintenance, and handling things like AuthN, AuthZ, sessions, and so on. It also offers an idiomatic pattern for talking to these types of devices, even though they have a considerably different means of communication than most others that Ansible works with. + +An example to illustrate this point is probably common to anyone who has automated a web service with a module that doesn't provide an httpapi connection plugin. Typically in these scenarios, the play, block, or task must be run against **localhost**, and the various information for the connection to the web service must be passed to each invocation of the module for each task. + + +``` +\--- +\- name: talk to foo device +  hosts: localhost +  tasks: +    - name: do something +      foo_device_do_thing: +        url: foo.example.com +        username: "{{ foo_device_username }}" +        passwd: "{{ foo_device_password }}" +        validate_certs: true +        thing_state: present +        some_param: bar +``` + +If this module had been implemented against an httpapi connection plugin instead, then the various connection-specific parameters would be host variables or group variables and wouldn't have to be carried around at the task level in playbooks. + +Here's an inventory entry to handle the AuthN/AuthZ connection for all Ansible modules, written against the httpapi connection plugin. It also performs session handling for increased performance: + + +``` +[foo_devices] +foo.example.com + +[foo_devices:vars] +ansible_network_os=foo_device +ansible_user=foo_device_username +ansible_httpapi_pass=foo_device_password +ansible_httpapi_validate_certs=true +``` + +This playbook would be considerably more idiomatic. The **foo_devices** are a first-class device type and [host pattern][25] for the playbook. + + +``` +\--- +\- name: talk to foo device +  hosts: foo_devices +  tasks: +    - name: do something +      foo_device_do_thing: +        thing_state: present +        some_param: bar +``` + +A playbook has to define information for every task, so imagine one that has 20 or 100 tasks. The overhead would be considerable. This doesn't feel much like directly automating the hosts defined in the host field. However, the httpapi connection plugin negates the need to define the connection information over and over, and it also talks natively to devices over a REST API, just as you would on a Linux system over SSH in a playbook. + +Something to note about httpapi connection plugins is that, even though the user defines hosts, groups, host vars, and group vars, just in like a traditional Unix/Linux or Windows-managed host, these modules actually execute against the localhost (the "control host" in Ansible nomenclature). This is something to keep in mind when you're developing. + +### What the what? + +If you're new to Ansible module development, this might seem like a lot to take in at once. To be fair, it is. However, as you become more seasoned in the finer points of Ansible module development for a wide array of device types and technology solution classifications, the motivation for different development strategies starts to make sense. Some device classifications have idiosyncrasies, and this model helps Ansible developers and users deal with those in a consistent and predictable way. + +### Wrapping up + +If you have questions about Ansible module development models, feel free to reach out through the vibrant [Ansible Community][26], and more specifically, the [Ansible Security Automation Working Group][27]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/security-ansible-module + +作者:[Adam Miller][a] +选题:[lujun9972][b] +译者:[译者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/maxamillion +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security_password_chaos_engineer_monster.png?itok=J31aRccu (Security monster) +[2]: https://www.ansible.com +[3]: https://opensource.com/article/19/2/quickstart-guide-ansible +[4]: https://www.ansible.com/ansiblefest +[5]: https://github.com/justjais +[6]: https://www.ansible.com/development-deep-dive-how-to-write-a-security-integration-module-for-ansible +[7]: https://www.linkedin.com/in/massimoferrari/ +[8]: https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html#developing-modules-general +[9]: https://docs.ansible.com/ansible/latest/dev_guide/developing_module_utilities.html +[10]: https://en.wikipedia.org/wiki/Idempotence +[11]: https://docs.ansible.com/ansible/latest/user_guide/playbooks.html +[12]: https://docs.ansible.com/ansible/latest/dev_guide/developing_collections.html +[13]: https://github.com/ansible/ansible +[14]: https://en.wikipedia.org/wiki/CPython +[15]: https://pypi.org +[16]: https://galaxy.ansible.com +[17]: https://docs.ansible.com/ansible/latest/user_guide/playbooks_blocks.html +[18]: https://en.wikipedia.org/wiki/Application_programming_interface +[19]: https://en.wikipedia.org/wiki/Command-line_interface +[20]: https://docs.ansible.com/ansible/latest/plugins/cliconf.html +[21]: https://docs.ansible.com/ansible/latest/reference_appendices/module_utils.html#ansible.module_utils.basic.AnsibleModule.run_command +[22]: https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html +[23]: https://en.wikipedia.org/wiki/Representational_state_transfer +[24]: https://docs.ansible.com/ansible/latest/network/dev_guide/developing_plugins_network.html#developing-plugins-httpapi +[25]: https://docs.ansible.com/ansible/latest/user_guide/intro_patterns.html +[26]: https://www.ansible.com/community +[27]: https://github.com/ansible/community/wiki/Security-Automation diff --git a/sources/tech/20191203 Solutions to the tiny window manager challenge.md b/sources/tech/20191203 Solutions to the tiny window manager challenge.md new file mode 100644 index 0000000000..54883376cc --- /dev/null +++ b/sources/tech/20191203 Solutions to the tiny window manager challenge.md @@ -0,0 +1,131 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Solutions to the tiny window manager challenge) +[#]: via: (https://jvns.ca/blog/2019/12/03/solutions-to-the-tiny-window-manager-challenge/) +[#]: author: (Julia Evans https://jvns.ca/) + +Solutions to the tiny window manager challenge +====== + +Hello! Last week I posted a small [programming challenge to write a tiny window manager that bounces windows around the screen][1]. + +![][2] + +I’ll write a bit about my experience of solving the challenge, or you can just skip to the end to see the solutions. + +### what’s a window manager? + +An X window manager is a program that sends messages to the X server (which is in charge of drawing your windows) to tell it which windows to display and where. + +I found out that you can trace those events with `xtrace`. Here’s some example output from xtrace (for the toy window manager which is just moving windows about) + +``` +000:<:02d8: 20: Request(12): ConfigureWindow window=0x004158e5 values={x=560 y=8} +000:<:02da: 20: Request(12): ConfigureWindow window=0x004158e5 values={x=554 y=12} +000:<:02dc: 20: Request(12): ConfigureWindow window=0x004158e5 values={x=548 y=16} +000:<:02de: 20: Request(12): ConfigureWindow window=0x004158e5 values={x=542 y=20} +000:<:02e0: 20: Request(12): ConfigureWindow window=0x004158e5 values={x=536 y=24} +000:<:02e2: 20: Request(12): ConfigureWindow window=0x004158e5 values={x=530 y=28} +000:<:02e4: 20: Request(12): ConfigureWindow window=0x004158e5 values={x=524 y=32} +``` + +### you can run programs without a window manager + +You technically don’t _need_ a window manager to run graphical programs – if you want to start an xterm in a window-manager-less X session you can just run + +``` +xterm -display :1 +``` + +and it’ll start the xterm. Here’s a screenshot of an X session with no window manager open. I even have 2 windows open! (chrome and an xterm). It has some major usability problems, for example I don’t think you can resize or move or switch between windows. Which is where the window manager comes in! + + + +### move a window with XMoveWindow + +The challenge was to make the window bounce around the screen. + +In the [tinywm source][3] they use `XMoveResizeWindow` to move and resize windows, but I found in the [docs][4] that there’s also a function called `XMoveWindow`. Perfect! + +Here’s what it looks like. What could be simpler, right? And it works just the way I’d expect! + +``` +XMoveWindow(display, windowID, x, y) +``` + +Except… + +### problem: multiple `XMoveWindow`s don’t work + +I ran into a problem (which I got stuck on for a couple of hours) where when I ran XMoveWindow twice, it would only apply the last move. + +``` +XMoveWindow(display, windowID, 100, 200) +usleep(2000 * 1000); # sleep for 2 seconds +XMoveWindow(display, windowID, 300, 400) +``` + +I’d expect this to move the window once, wait 2 seconds, and them move it again. But that was not what happened! Instead, it would pause for 2 seconds and then move the window once (to the second location). + +### use xtrace to trace window manager events + +I used xtrace to trace the events and found out that my `ConfigureWindow` events that `XMoveWindow` was sending were all being sent at the same time. So it seemed like X was batching the events. But why? + +### XSync forces X to process events + +I didn’t know why this was happening, but I emailed Julian about it and he pointed me in the direction of [XSync][5], which forces X to process all the events you’ve sent it. Sure enough, I used XSync and everything worked beautifully. + +### solutions + +I asked people to email me if they completed the challenge, and 4 people did! Here are their solutions. All the solutions I got implemented more features than I did, so I’d encourage you to look at all the solutions if you’re interested in how to solve this problem! + + * [Kacper Słomiński’s solution][6] (which uses `XQueryTree` to find the windows to bounce, which is nice) + * [@whichxyj’s solution][7] + * [Alexsey Lagoshin’s stressfulwm][8], which allows bouncing multiple windows: + * [Aldrin Martoq Ahumada’s bouncywm-ruby][9], which is the only solution in a language other than C I got! It uses an Xlib Ruby library that looks pretty straightforward to use. + * one really nice one with fancier bouncing effects which I’ll post here later if the person sends me the source + * [my solution][10] + + + +Here’s a gif of Alexsey’s solution. Apparently `XQuartz` on a Mac performs better than Xephyr! + +![][11] + +And Aldrin’s solution, with a great use of `xeyes`: + +![][12] + +### thanks! + +Thanks to everyone who emailed me a solution, and if you write your own implementation I’d love to post it here too, especially if you write one that isn’t in C or Ruby! I’m [[email protected]][13] + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2019/12/03/solutions-to-the-tiny-window-manager-challenge/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://jvns.ca/blog/2019/11/25/challenge--make-a-bouncy-window-manager/ +[2]: https://jvns.ca/images/bouncewm.gif +[3]: http://incise.org/tinywm.html +[4]: https://tronche.com/gui/x/xlib/window/XMoveWindow.html +[5]: https://tronche.com/gui/x/xlib/event-handling/XSync.html +[6]: https://gist.github.com/jvns/d5a0a4daf300f3dd7fa76d13b5aa2d53 +[7]: https://github.com/whichxjy/bounce-wm/blob/master/bounce-wm.c +[8]: https://github.com/ayzenquwe/stressfulwm +[9]: https://github.com/aldrinmartoq/bouncywm-ruby +[10]: https://gist.github.com/jvns/c7a297fc4e17e797fd7b76b68860e55c +[11]: https://raw.githubusercontent.com/ayzenquwe/stressfulwm/d06531d286a5f00424bf12f7c77b18e11437ff20/gif/example.gif +[12]: https://raw.githubusercontent.com/aldrinmartoq/bouncywm-ruby/f6d424b6107c1349c8ee338b6a46c7116c6d1ea7/demo/demo.gif +[13]: https://jvns.ca/cdn-cgi/l/email-protection diff --git a/sources/tech/20191204 --acid -words- Handle Chromium - Firefox sessions with org-mode.md b/sources/tech/20191204 --acid -words- Handle Chromium - Firefox sessions with org-mode.md new file mode 100644 index 0000000000..7b71e21ff3 --- /dev/null +++ b/sources/tech/20191204 --acid -words- Handle Chromium - Firefox sessions with org-mode.md @@ -0,0 +1,145 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (#:acid 'words: Handle Chromium & Firefox sessions with org-mode) +[#]: via: (https://acidwords.com/posts/2019-12-04-handle-chromium-and-firefox-sessions-with-org-mode.html) +[#]: author: (Sanel Z https://acidwords.com/) + +Handle Chromium & Firefox sessions with org-mode +====== + +I was big fan of [Session Manager][1], small addon for Chrome and Chromium that will save all open tabs, assign the name to session and, when is needed, restore it. + +Very useful, especially if you are like me, switching between multiple "mind sessions" during the day - research, development or maybe news reading. Or simply, you'd like to remember workflow (and tabs) you had few days ago. + +After I decided to ditch all extensions from Chromium except [uBlock Origin][2], it was time to look for alternative. My main goal was it to be browser agnostic and session links had to be stored in text file, so I can enjoy all the goodies of plain text file. What would be better for that than good old [org-mode][3] ;) + +Long time ago I found this trick: [Get the currently open tabs in Google Chrome via the command line][4] and with some elisp sugar and coffee, here is the code: + +``` +(require 'cl-lib) + +(defun save-chromium-session () + "Reads chromium current session and generate org-mode heading with items." + (interactive) + (save-excursion + (let* ((cmd "strings ~/'.config/chromium/Default/Current Session' | 'grep' -E '^https?://' | sort | uniq") + (ret (shell-command-to-string cmd))) + (insert + (concat + "* " + (format-time-string "[%Y-%m-%d %H:%M:%S]") + "\n" + (mapconcat 'identity + (cl-reduce (lambda (lst x) + (if (and x (not (string= "" x))) + (cons (concat " - " x) lst) + lst)) + (split-string ret "\n") + :initial-value (list)) + "\n")))))) + +(defun restore-chromium-session () + "Restore session, by openning each link in list with (browse-url). +Make sure to put cursor on date heading that contains list of urls." + (interactive) + (save-excursion + (beginning-of-line) + (when (looking-at "^\\*") + (forward-line 1) + (while (looking-at "^[ ]+-[ ]+\\(http.?+\\)$") + (let* ((ln (thing-at-point 'line t)) + (ln (replace-regexp-in-string "^[ ]+-[ ]+" "" ln)) + (ln (replace-regexp-in-string "\n" "" ln))) + (browse-url ln)) + (forward-line 1))))) +``` + +So, how does it work? + +Evaluate above code, open new org-mode file and call `M-x save-chromium-session`. It will create something like this: + +``` +* [2019-12-04 12:14:02] + - https://www.reddit.com/r/emacs/comments/... + - https://www.reddit.com/r/Clojure + - https://news.ycombinator.com +``` + +or whatever urls are running in Chromium instance. To restore it back, put cursor on desired date and run `M-x restore-chromium-session`. All tabs should be back. + +Here is how I use it, with randomly generated data for the purpose of this text: + +``` +#+TITLE: Browser sessions + +* [2019-12-01 23:15:00]... +* [2019-12-02 18:10:20]... +* [2019-12-03 19:00:12] + - https://www.reddit.com/r/emacs/comments/... + - https://www.reddit.com/r/Clojure + - https://news.ycombinator.com + +* [2019-12-04 12:14:02] + - https://www.reddit.com/r/emacs/comments/... + - https://www.reddit.com/r/Clojure + - https://news.ycombinator.com +``` + +Note that hack for reading Chromium session isn't perfect: `strings` will read whatever looks like string and url from binary database and sometimes that will yield small artifacts in urls. But, you can easily edit those and keep session file lean and clean. + +To actually open tabs, elisp code will use [browse-url][5] and it can be further customized to run Chromium, Firefox or any other browser with `browse-url-browser-function` variable. Make sure to read documentation for this variable. + +Don't forget to put session file in git, mercurial or svn and enjoy the fact that you will never loose your session history again :) + +### What about Firefox? + +If you are using Firefox (recent versions) and would like to pull session urls, here is how to do it. + +First, download and compile [lz4json][6], small tool that will decompress Mozilla lz4json format, where Firefox stores session data. Session data (at the time of writing this post) is stored in `$HOME/.mozilla/firefox//sessionstore-backups/recovery.jsonlz4`. + +If Firefox is not running, `recovery.jsonlz4` will not be present, but use `previous.jsonlz4` instead. + +To extract urls, try this in terminal: + +``` +$ lz4jsoncat recovery.jsonlz4 | grep -oP '"(http.+?)"' | sed 's/"//g' | sort | uniq +``` + +and update `save-chromium-session` with: + +``` +(defun save-chromium-session () + "Reads chromium current session and converts it to org-mode chunk." + (interactive) + (save-excursion + (let* ((path "~/.mozilla/firefox//sessionstore-backups/recovery.jsonlz4") + (cmd (concat "lz4jsoncat " path " | grep -oP '\"(http.+?)\"' | sed 's/\"//g' | sort | uniq")) + (ret (shell-command-to-string cmd))) +... +;; rest of the code is unchanged +``` + +Updating documentation strings, function name and any further refactoring is left for exercise. + +-------------------------------------------------------------------------------- + +via: https://acidwords.com/posts/2019-12-04-handle-chromium-and-firefox-sessions-with-org-mode.html + +作者:[Sanel Z][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://acidwords.com/ +[b]: https://github.com/lujun9972 +[1]: https://chrome.google.com/webstore/detail/session-manager/mghenlmbmjcpehccoangkdpagbcbkdpc?hl=en-US +[2]: https://chrome.google.com/webstore/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm?hl=en +[3]: https://orgmode.org/ +[4]: https://superuser.com/a/1310873 +[5]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Browse_002dURL.html +[6]: https://github.com/andikleen/lz4json diff --git a/sources/tech/20191204 4 ways to control the flow of your awk script.md b/sources/tech/20191204 4 ways to control the flow of your awk script.md new file mode 100644 index 0000000000..df08e99812 --- /dev/null +++ b/sources/tech/20191204 4 ways to control the flow of your awk script.md @@ -0,0 +1,273 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (4 ways to control the flow of your awk script) +[#]: via: (https://opensource.com/article/19/12/control-awk-script) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +4 ways to control the flow of your awk script +====== +Learn to use switch statements and the break, continue, and next +commands to control awk scripts. +![JavaScript in Vim][1] + +There are many ways to control the flow of an awk script, including [loops][2], **switch** statements and the **break**, **continue**, and **next** commands. + +### Sample data + +Create a sample data set called **colours.txt** and copy this content into it: + + +``` +name       color  amount +apple      red    4 +banana     yellow 6 +strawberry red    3 +raspberry  red    99 +grape      purple 10 +apple      green  8 +plum       purple 2 +kiwi       brown  4 +potato     brown  9 +pineapple  yellow 5 +``` + +### Switch statements + +The **switch** statement is a feature specific to GNU awk, so you can only use it with **gawk**. If your system or your target system doesn't have **gawk**, then you should not use a switch statement. + +The **switch** statement in **gawk** is similar to the one in C and many other languages. The syntax is: + + +``` +switch (expression) { +        case VALUE: +                <do something here> +        [...] +        default: +                <do something here> +} +``` + +The **expression** part can be any awk expression that returns a numeric or string result. The **VALUE** part (after the word **case**) is a numeric or string constant or a regular expression. + +When a **switch** statement runs, the _expression_ is evaluated, and the result is matched against each case value. If there's a match, then the code contained within a case definition is executed. If there's no match in any case definition, then the default statement is executed. + +The keyword **break** is at the end of the code in each case definition to break the loop. Without **break**, awk would continue to search for matching case values. + +Here's an example **switch** statement: + + +``` +#!/usr/bin/awk -f +# +# Example of the use of 'switch' in GNU Awk. + +NR > 1 { +    printf "The %s is classified as: ",$1 + +    switch ($1) { +        case "apple": +            print "a fruit, pome" +            break +        case "banana": +        case "grape": +        case "kiwi": +            print "a fruit, berry" +            break +                case "raspberry": +                        print "a computer, pi" +                        break +        case "plum": +            print "a fruit, drupe" +            break +        case "pineapple": +            print "a fruit, fused berries (syncarp)" +            break +        case "potato": +            print "a vegetable, tuber" +            break +        default: +            print "[unclassified]" +    } +} +``` + +This script notably ignores the first line of the file, which in the case of the sample data is just a header. It does this by operating only on records with an index number greater than 1. On all other records, this script compares the contents of the first field (**$1**, as you know from previous articles) to the value of each **case** definition. If there's a match, the **print** function is used to print the botanical classification of the entry. If there are no matches, then the **default** instance prints **"[unclassified]"**. + +The banana, grape, and kiwi are all botanically classified as a berry, so there are three **case** definitions associated with one **print** result. + +Run the script on the **colours.txt** sample file, and you should get this: + + +``` +The apple is classified as: a fruit, pome +The banana is classified as: a fruit, berry +The strawberry is classified as: [unclassified] +The raspberry is classified as: a computer, pi +The grape is classified as: a fruit, berry +The apple is classified as: a fruit, pome +The plum is classified as: a fruit, drupe +The kiwi is classified as: a fruit, berry +The potato is classified as: a vegetable, tuber +The pineapple is classified as: a fruit, fused berries (syncarp) +``` + +### Break + +The **break** statement is mainly used for the early termination of a **for**, **while**, or **do-while** loop or a **switch** statement. In a loop, **break** is often used where it's not possible to determine the number of iterations of the loop beforehand. Invoking **break** terminates the enclosing loop (which is relevant when there are nested loops or loops within loops). + +This example, straight out of the [GNU awk manual][3], shows a method of finding the smallest divisor. Read the additional comments for a clear understanding of how the code works: + + +``` +#!/usr/bin/awk -f + +{ +    num = $1 + +    # Make an infinite FOR loop +    for (divisor = 2; ; divisor++) { + +        # If num is divisible by divisor, then break +        if (num % divisor == 0) { +            printf "Smallest divisor of %d is %d\n", num, divisor +            break +        } + +        # If divisor has gotten too large, the number has no +        # divisor, so is a prime +        if (divisor * divisor > num) { +            printf "%d is prime\n", num +            break +        } +    } +} +``` + +Try running the script to see its results: + + +``` +    $ echo 67 | ./divisor.awk +    67 is prime +    $ echo 69 | ./divisor.awk +    Smallest divisor of 69 is 3 +``` + +As you can see, even though the script starts out with an explicit _infinite_ loop with no end condition, the **break** function ensures that the script eventually terminates. + +### Continue + +The **continue** function is similar to **break**. It can be used in a **for**, **while**, or **do-while** loop (it's not relevant to a **switch** statements, though). Invoking **continue** skips the rest of the enclosing loop and begins the next cycle. + +Here's another good example from the GNU awk manual to demonstrate a possible use of **continue**: + + +``` +#!/usr/bin/awk -f + +# Loop, printing numbers 0-20, except 5 + +BEGIN { +    for (x = 0; x <= 20; x++) { +        if (x == 5) +            continue +        printf "%d ", x +    } +    print "" +} +``` + +This script analyzes the value of **x** before printing anything. If the value is exactly 5, then **continue** is invoked, causing the **printf** line to be skipped, but leaves the loop unbroken. Try the same code but with **break** instead to see the difference. + +### Next + +This statement is not related to loops like **break** and **continue** are. Instead, **next** applies to the main record processing cycle of awk: the functions you place between the BEGIN and END functions. The **next** statement causes awk to stop processing the _current input record_ and to move to the next one. + +As you know from the earlier articles in this series, awk reads records from its input stream and applies rules to them. The **next** statement stops the execution of rules for the current record and moves to the next one. + +Here's an example of **next** being used to "hold" information upon a specific condition: + + +``` +#!/usr/bin/awk -f + +# Ignore the header +NR == 1 { next } + +# If field 2 (colour) is less than 6 +# characters, then save it with its +#  line number and skip it + +length($2) < 6 { +    skip[NR] = $0 +    next +} + +# It's not the header and +# the colour name is > 6 characters, +# so print the line +{ +    print +} + +# At the end, show what was skipped +END { +    printf "\nSkipped:\n" +    for (n in skip) +        print n": "skip[n] +} +``` + +This sample uses **next** in the first rule to avoid the first line of the file, which is a header row. The second rule skips lines when the color name is less than six characters long, but it also saves that line in an array called **skip**, using the line number as the key (also known as the _index_). + +The third rule prints anything it sees, but it is not invoked if either rule 1 or rule 2 causes it to be skipped. + +Finally, at the end of all the processing, the **END** rule prints the contents of the array. + +Run the sample script on the **colours.txt** file from above (and previous articles): + + +``` +$ ./next.awk colours.txt +banana     yellow 6 +grape      purple 10 +plum       purple 2 +pineapple  yellow 5 + +Skipped: +2: apple      red    4 +4: strawberry red    3 +6: apple      green  8 +8: kiwi       brown  4 +9: potato     brown  9 +``` + +### Control freak + +In summary, **switch**, **continue**, **next**, and **break** are important preemptive exceptions to awk rules that provide greater control of your script. You don't have to use them directly; often, you can gain the same logic through other means, but they're great convenience functions that make the coder's life a lot easier. The next article in this series covers the **printf** statement. + +* * * + +Would you rather listen to this article? It was adapted from an episode of [Hacker Public Radio][4], a community technology podcast by hackers, for hackers. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/control-awk-script + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者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/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/javascript_vim.jpg?itok=mqkAeakO (JavaScript in Vim) +[2]: https://opensource.com/article/19/11/loops-awk +[3]: https://www.gnu.org/software/gawk/manual/ +[4]: http://hackerpublicradio.org/eps.php?id=2438 diff --git a/sources/tech/20191204 Complementary engineering indicators.md b/sources/tech/20191204 Complementary engineering indicators.md new file mode 100644 index 0000000000..981720ab11 --- /dev/null +++ b/sources/tech/20191204 Complementary engineering indicators.md @@ -0,0 +1,61 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Complementary engineering indicators) +[#]: via: (https://dave.cheney.net/2019/12/04/complementary-engineering-indicators) +[#]: author: (Dave Cheney https://dave.cheney.net/author/davecheney) + +Complementary engineering indicators +====== + +Last year I had the opportunity to watch Cat Swetel’s presentation _[The Development Metrics You Should Use (but Don’t)][1]_. The information that could be gleaned from just tracking the start and finish date of work items was eye opening. If you’re using an issue tracker this information is probably already (perhaps with some light data munging) available — no need for TPS reports. Additionally, statistics obtained by data mining your project’s issue tracker are, perhaps, less likely to be juked. + +Around the time I saw Cat’s presentation I finished reading Andy Grove’s _High Output Management_. The hidden gem in this book (assuming becoming a meeting powerhouse isn’t your bag) was Grove’s notion of indicator pairs. An example of a paired indicator might be the number of sales deals closed paired with the customer retention rate. The underling principle being optimising for one indicator will have an adverse impact on the other. In the example, overly aggressive or deceptive tactics could superficially raise the number of sales made, but would be reflected in a dip in the retention rate as customers returned the product or terminated their service prematurely. + +These ideas lead me to thinking about indicators you could use for a team delivering a software product. Could those indicators be derived cheaply from the hand to hand combat of software delivery? Could they be structured in a way that aggressively pursuing one metric would be reflected negatively in another? I think so. + +These are the three metrics that I’ve been using to track the health of the project that I lead. + + * Date; was the software done when we said it would be done. If you prefer this indicator as a scalar, how many days difference is there between the ship date agreed on at the start of the sprint/milestone/whatever and what was the actual date that you considered it done. + * Completeness; when the software is done, how many of the things we said we’re going to do actually got delivered in that release. + * Defects reported; once the software is in the field, what is the rate of bugs reported. + + + +It is relatively easy, for example, to hit a delivery date if you aggressively descope anything risky or simply don’t do it. But in doing so this lack of promised functionality would impact the completeness metric. + +Conversely, it’s straight forward to hit your milestone’s completeness target if you let the release date slip and slip. Bringing both the metics into line requires good estimation skills to judge how much can be attempted in milestone and provide direct feedback if your estimation skills needed work. + +The third indicator, defects reported in the field, acts as a check on the other two. It would be easy to consistent hit your delivery date with 100% feature completion if your team does a shoddy job. The high fives and 🎉 emojis will be short lived if each release brings with it a swathe of high priority bug reports. This indicator also tends to have a second order effect, rushed features to meet a deadline tend to generate remedial work in the following milestones, crowding out promised work or blowing later deadlines. + +I consider these to be complementary metrics, they should be considered together, as a group, rather than individually. Ideally your team should be delivering what you promised, when you promised it, with a low defect rate. But more importantly, if that isn’t the case, if one of the indicators is unhealthy, addressing it shouldn’t result in the problem moving to another. + +### Related posts: + + 1. [Never edit a method, always rewrite it][2] + 2. [The Mythical Man-Month selection bias][3] + 3. [The office coffee model of concurrent garbage collection][4] + 4. [Sydney High Performance Go workshop][5] + + + +-------------------------------------------------------------------------------- + +via: https://dave.cheney.net/2019/12/04/complementary-engineering-indicators + +作者:[Dave Cheney][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://dave.cheney.net/author/davecheney +[b]: https://github.com/lujun9972 +[1]: https://www.youtube.com/watch?v=cW3yM-K2M08 +[2]: https://dave.cheney.net/2017/11/30/never-edit-a-method-always-rewrite-it (Never edit a method, always rewrite it) +[3]: https://dave.cheney.net/2013/12/04/the-mythical-man-month-selection-bias (The Mythical Man-Month selection bias) +[4]: https://dave.cheney.net/2018/12/28/the-office-coffee-model-of-concurrent-garbage-collection (The office coffee model of concurrent garbage collection) +[5]: https://dave.cheney.net/2019/07/05/sydney-high-performance-go-workshop (Sydney High Performance Go workshop) diff --git a/sources/tech/20191204 Fedora Desktops - Memory Footprints.md b/sources/tech/20191204 Fedora Desktops - Memory Footprints.md new file mode 100644 index 0000000000..f9a3ea0f3b --- /dev/null +++ b/sources/tech/20191204 Fedora Desktops - Memory Footprints.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Fedora Desktops – Memory Footprints) +[#]: via: (https://fedoramagazine.org/fedora-desktops-memory-footprints/) +[#]: author: (Troy Dawson https://fedoramagazine.org/author/tdawson/) + +Fedora Desktops – Memory Footprints +====== + +![][1] + +There are over 40 desktops in Fedora. Each desktop has it’s own strengths and weaknesses. Usually picking a desktop is a very personal preference based on features, looks, and other qualities. Sometimes, what you pick for a desktop is limited by hardware constraints. + +This article is to help people compare Fedora desktops based on the desktop baseline memory. To narrow the scope, we are only looking at the desktops that have an official Fedora Live image. + +### Installation and Setup + +Each of the desktops was installed on it’s own KVM virtual machine. Each virtual machine had 1 CPU, 4GB of memory, 15 GB virtio solid state disk, and everything else that comes standard on RHEL 8.0 kvm. + +The images for installation were the standard Fedora 31 Live images. For GNOME, that image was the Fedora Workstation. For the other desktops, the corresponding Spin was used. Sugar On A Stick (SOAS) was not tested because it does not install easily onto a local drive. + +The virtual machine booted into the Live CD. “Install to Hard Disk” was selected. During the install, only the defaults were used. A root user, and a regular users were created. After installation and reboot, the Live image was verified to not be in the virtual CDROM. + +The settings for each desktop was not touched. They each ran whatever settings came default from the Live CD installation. Each desktop was logged into via the regular user. A terminal was opened. Using sudo each machine ran “dnf -y update”. After update, in that sudo terminal, each machine ran “/sbin/shutdown -h now” to shut down. + +### Testing + +Each machine was started up. The desktop was logged into via the regular user. Three of the desktop terminals were opened. xterm was never used, it was always the terminal for that desktop, such as konsole. + +In one terminal, top was started and M pressed, showing the processes sorted by memory. In another terminal, a simple while loop showed “free -m” every 30 seconds. The third terminal was idle. + +I then waited 5 minutes. This allowed any startup services to finish. I recorded the final free result, as well as the final top three memory consumers from top. + +### Results + + * Cinnamon + * 624 MB Memory used + * cinnamon 4.8% / Xorg 2.2% / dnfdragora 1.8% + * GNOME + * 612 MB Memory used + * gnome-shell 6.9% / gnome-software 1.8% / ibus-x11 1.5% + * KDE + * 733 MB Memory used + * plasmashell 6.2% / kwin_x11 3.6% / akonadi_mailfil 2.9% + * LXDE + * 318 MB Memory used + * Xorg 1.9% / nm-applet 1.8% / dnfdragora 1.8% + * LXQt + * 391 MB Memory used + * lxqt-panel 2.2% / pcmanfm-qt 2.1% / Xorg 2.1% + * MATE + * 465 MB Memory used + * Xorg 2.5% / dnfdragora 1.8% / caja 1.5% + * XFCE + * 448 MB Memory used + * Xorg 2.3% / xfwm4 2.0% / dnfdragora 1.8% + + + +### Conclusion + +I will let the numbers speak for themselves. + +Remember that these numbers are from a default Live install. If you remove, or add services and features, your memory usage will change. But this is a good baseline to look at if you are determining your desktop based on memory consumption. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/fedora-desktops-memory-footprints/ + +作者:[Troy Dawson][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/tdawson/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/11/desktop-memory-footprint-816x346.jpg diff --git a/sources/tech/20191204 Spice up your Linux desktop with Cinnamon.md b/sources/tech/20191204 Spice up your Linux desktop with Cinnamon.md new file mode 100644 index 0000000000..036f253188 --- /dev/null +++ b/sources/tech/20191204 Spice up your Linux desktop with Cinnamon.md @@ -0,0 +1,68 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Spice up your Linux desktop with Cinnamon) +[#]: via: (https://opensource.com/article/19/12/cinnamon-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Spice up your Linux desktop with Cinnamon +====== +This article is part of a special series of 24 days of Linux desktops. +Just like its namesake, the Cinnamon Linux desktop is warm and inviting +and cozy. +![Cinnamon][1] + +When GNOME 3 was released, some GNOME users were not ready to give up GNOME 2. The [Linux Mint][2] project was so dissatisfied with GNOME 3 that it started its own desktop as an alternative, and thus the [Cinnamon][3] desktop was born. + +Cinnamon originally sought to "remix" GNOME 3 so that it looked and acted like the GNOME 2 so many users knew and loved, but eventually, it diverged enough to be a true fork. Today, Cinnamon uses GTK3 libraries and forked versions of key GNOME 3 applications to create a classic GNOME experience. + +You may find Cinnamon in your distribution's software repository, or you can download and install a distribution that ships with Cinnamon as its default desktop. Before you do, though, be aware that it is meant to provide a full desktop experience, so many Cinnamon apps are installed along with the desktop. If you're already running a different desktop, you may find yourself with redundant applications (two PDF readers, two media players, two file managers, and so on). + +If you just want to try the Cinnamon desktop, you can install a Cinnamon-based distribution in a virtual machine, such as [GNOME Boxes][4]. + +### Cinnamon desktop tour + +The Cinnamon desktop layout has a classic look, although—in spite of being inspired by GNOME 2—that look is not at all like GNOME 2. In fact, it shares more with KDE's Plasma desktop than with GNOME 2, with an application menu in the lower-left corner, a taskbar for pinned and active applications, and a system tray in the lower-right corner. There's no top menu bar with Applications and Places and System menus, and the taskbar uses icons with no text, so if it's a clone of GNOME 2 you're looking for, Cinnamon doesn't provide that. + +![Cinnamon desktop on Linux Mint][5] + +What Cinnamon does provide, however, is the opportunity for Linux Mint developers to control the environment they maintain. The Mint desktop is very much a Linux Mint creation, so much so that it's almost a part of the Mint brand. And yet it's appealing enough for enough users that it's available on [other distributions][6], even ones traditionally seen as "rivals" (at least, insofar as there are rivalries in open source). Here's the Cinnamon desktop environment fitting in nicely with a Fedora install: + +![Cinnamon desktop on Fedora][7] + +The desktop experience, aside from its panel layout, is a simple and classic one. There are icons on the desktop serving as shortcuts to common locations, there's an application for most file-management tasks, and there are applets in the systems tray for common administrative tasks. It's a familiar user experience. Just like its name, it's warm and inviting and cozy. + +### Customizing the desktop + +Cinnamon isn't as flexible as something like Fluxbox or KDE, but it's not as rigid as GNOME 3 or Pantheon. The System Settings application provides customization for all the usual small details, such as keyboard layout, keyboard shortcuts, workspace behavior, a firewall, and so on. A right-click on any element usually brings up a useful contextual menu with settings or information about what you've clicked. + +There are definitely some expectations about what your workflow ought to be when using Cinnamon, but these assumptions are all generic and safe. It may not be the most efficient desktop environment, but it's soundly a generic, all-purpose one. Both power users and new users feel at home in Cinnamon. You can customize the experience within certain parameters, and if you hit the ceiling when you try to make drastic changes, then you can fall back on the fact that this is open source, and you have plenty of other options. + +You may never hit that ceiling, though. Cinnamon's an attractive and responsive interface. It's a pleasure to use because it's simple and intuitive, with no surprises or puzzling user-interface choices to slow you down. With a few custom keyboard shortcuts and a little time to settle into a new environment, you can do amazing things with Cinnamon, and you'll love every moment of it because it's a beautiful thing to witness. Cinnamon is restrained with animations and effects, and the ones it uses are appealing and even informative. + +### Spice of life + +It's fun to try new desktops, and Cinnamon is worth trying. Install or download it today and see what you think. It's one of those desktops that you already know how to use, even if you've never used it before. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/cinnamon-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者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/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cinnamon.jpg?itok=4GV-boum (Cinnamon) +[2]: https://www.linuxmint.com/ +[3]: https://github.com/linuxmint/Cinnamon +[4]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization +[5]: https://opensource.com/sites/default/files/uploads/advent-cinnamon.jpg (Cinnamon desktop on Linux Mint) +[6]: https://en.wikipedia.org/wiki/Cinnamon_(desktop_environment)#Adoption +[7]: https://opensource.com/sites/default/files/uploads/advent-cinnamon-fedora.jpg (Cinnamon desktop on Fedora) diff --git a/sources/tech/20191205 Add jumping to your Python platformer game.md b/sources/tech/20191205 Add jumping to your Python platformer game.md new file mode 100644 index 0000000000..9d64001082 --- /dev/null +++ b/sources/tech/20191205 Add jumping to your Python platformer game.md @@ -0,0 +1,512 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Add jumping to your Python platformer game) +[#]: via: (https://opensource.com/article/19/12/jumping-python-platformer-game) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Add jumping to your Python platformer game +====== +Learn how to fight gravity with jumping in this installment on +programming video games with Python's Pygame module. +![Arcade games][1] + +In the [previous article][2] in this series, you simulated gravity, but now you need to give your player a way to fight against gravity by jumping. + +A jump is a temporary reprieve from gravity. For a few moments, you jump _up_ instead of falling down, the way gravity is pulling you. But once you hit the peak of your jump, gravity kicks in again and pulls you back down to earth. + +In code, this translates to variables. First, you must establish variables for the player sprite so that Python can track whether or not the sprite is jumping. Once the player sprite is jumping, then gravity is applied to the player sprite again, pulling it back down to the nearest object. + +### Setting jump state variables + +You must add two new variables to your Player class: + + * One to track whether your player is jumping or not, determined by whether or not your player sprite is standing on solid ground + * One to bring the player back down to the ground + + + +Add these variables to your **Player** class. In the following code, the lines above the comment are for context, so just add the final two lines: + + +``` +                self.movex = 0 +                self.movey = 0 +                self.frame = 0 +                self.health = 10 +                # gravity variables here +                self.collide_delta = 0 +                self.jump_delta = 6 +``` + +The first variable (**collide_delta**) is set to 0 because, in its natural state, the player sprite is not in a mid-jump. The other variable (**jump_delta**) is set to 6 to prevent the sprite from bouncing (actually, jumping) when it first lands in the game world. When you've finished this article's examples, try setting it to 0 to see what happens. + +### Colliding mid-jump + +If you jump on a trampoline, your jumps are pretty impressive. But what would happen if you jumped into a wall? (Don't try it to find out!) Your jump, no matter how impressively it started, would end very quickly when you collide with something much larger and much more solid than you. + +To mimic this in your video game, you must set the **self.collide_delta** variable to 0 whenever your player sprite collides with something, like the ground. If **self.collide_delta** is anything other than 0, then your player is jumping, and your player can't jump when it hits a wall or the ground. + +In the **update** function of your **Player** class, modify the ground collision block to look like this: + + +``` +        ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) +        for g in ground_hit_list: +            self.movey = 0 +            self.rect.y = worldy-ty-ty +            self.collide_delta = 0 # stop jumping +            if self.rect.y > g.rect.y: +                self.health -=1 +                print(self.health) +``` + +This code block checks for collisions happening between the ground sprites and the player sprite. In the event of a collision, it sets the Y-position of the player to a value equal to the height of the game window (**worldy**) minus the height of a tile minus the height of another tile (so that the player sprite appears to be standing on top of the ground and not in the middle of it). It also sets **self.collide_delta** to 0 so that the program is aware that the player is not in mid-jump. Additionally, it sets **self.movey** to 0 so that the program is aware that the player is not being pulled by gravity (it's a quirk of game physics that you don't need to continue to pull your player toward earth once the player has been grounded). + +The **if** statement detects whether the player has descended _below_ the level of the ground; if so, it deducts health points as a penalty. This assumes that you want your player to lose health points for falling off the world. That's not strictly necessary; it's just a common convention in platformers. More than likely, you want this event to trigger something, though, or else your real-world player will be stuck playing a game with a sprite that's fallen off the screen. An easy recovery is to set **self.rect.y** to 0 again so that when the player sprite falls off the world, it respawns at the top of the world and falls back onto solid ground. + +### Hitting the ground + +Your simulated gravity wants your player's Y-axis movement to be 0 or more. To create a jump, write code that sends your player sprite off solid ground and into the air. + +In the **update** function of your **Player** class, add a temporary reprieve from gravity: + + +``` +        if self.collide_delta < 6 and self.jump_delta < 6: +            self.jump_delta = 6*2 +            self.movey -= 33  # how high to jump +            self.collide_delta += 6 +            self.jump_delta    += 6 +``` + +According to this code, a jump sends the player sprite 33 pixels into the air. It's _negative_ 33 because a lower number in Pygame means it's closer to the top of the screen. + +This event is conditional, though. It only happens if **self.collide_delta** is less than 6 (its default value established in the **init** function of your **Player** sprite) and if **self.jump_delta** is less than 6. This condition prevents the player from triggering another jump until it collides with a platform. In other words, it prevents mid-air jumps. + +You don't have to prevent mid-air jumps, or you can allow for mid-air jumps under special conditions; for instance, if a player obtains a special loot item, then you could grant it the ability to perform mid-air jumps until the next time it is hit by an enemy. + +When you've finished this article's examples, try setting **self.collide_delta** and **self.jump_delta** to 0 for a 100% chance to jump in mid-air. + +### Landing on a platform + +So far, you've defined an anti-gravity condition for when the player sprite hits the ground, but the game code keeps platforms and the ground in separate lists. (As with so many choices made in this article, that's not strictly necessary, and you can experiment with treating the ground as just another platform.) To enable a player sprite to stand on top of a platform, you must detect a collision between the player sprite and a platform sprite and then perform the same actions as you did for a ground collision. Place this code into your **update** function: + + +``` +        plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) +        for p in plat_hit_list: +            self.collide_delta = 0 # stop jumping +            self.movey = 0 +``` + +There's one additional concern, though: platforms hang in the air, meaning the player can interact with them by approaching them from either the top or the bottom. + +It's up to you how you want the platforms to react to your player. It's not uncommon to block a player from accessing a platform from below. Add this code to the above code block to treat platforms as a sort of ceiling or pergola, such that the player sprite can jump onto a platform as long as it jumps higher than the platform's topside, but obstructs the player when it tries to jump from beneath: + + +``` +            if self.rect.y > p.rect.y: +                self.rect.y = p.rect.y+ty +            else: +                self.rect.y = p.rect.y-ty +``` + +The first clause of this **if** statement blocks the player from accessing a platform when the player sprite is directly under the platform. It does this by detecting that the player sprite's position is greater (in Pygame, that means lower on the screen, from top to bottom), and then sets the player sprite's new Y position to its current Y position plus the height of a tile, effectively keeping the player one tile's height away from ever passing through a platform from beneath it. + +The **else** clause does the opposite. If the program is running this code, then the player sprite's Y position is _not_ greater than the platforms, meaning that the player sprite is falling from the sky (either because it has been freshly spawned there or because the player has jumped). In this event, the player sprite's position is set to the position of the platform minus one tile's height (because, remember, in Pygame, lower numbers mean something is higher up on the screen). This keeps the player on top of the platform unless it jumps or walks off of it. + +You can experiment with other ways of dealing with sprite and platform interaction. For instance, maybe the player is assumed to be "in front" of the platforms and can seamlessly jump through them to stand on top of one. Or a platform could slow a player's leap but not block it entirely. You can even mix and match by grouping platforms into different lists. + +### Triggering a jump + +Your code now simulates all the necessary jump conditions, but it still lacks a jump trigger. Your player sprite's **self.jump_delta** is set to 6 initially, and the jump update code is triggered only when it's less than 6. + +To trigger a new setting for the jumping variable, create a **jump** function in your **Player** class that sets the **self.jump_delta** to less than 6, causing gravity to be temporarily reprieved by sending your player sprite 33 pixels into the air: + + +``` +    def jump(self,platform_list): +        self.jump_delta = 0 +``` + +That's all the **jump** function requires, believe it or not. The rest happens in the **update** function, and you've already written that code. + +There's one last thing to do before jumping is functional in your game. If you can't think of what it is, try playing your game to see how jumping works for you. + +The problem is that nothing in your main loop is calling the **jump** function. You made a placeholder keypress for it early on, but right now, all the jump key does is print **jump** to the terminal. + +### Calling the jump function + +In your main loop, change the result of the Up arrow from printing a debug statement to calling the **jump** function. + +Notice that the **jump** function, like the **update** function, needs to know about collisions, so you have to tell it which **plat_list** to use. + + +``` +            if event.key == pygame.K_UP or event.key == ord('w'): +                player.jump(plat_list) +``` + +If you would rather use the Spacebar for jumping, set the key to **pygame.K_SPACE** instead of **pygame.K_UP**. Alternately, you can use both (as separate **if** statements) so that the player has a choice. + +Try your game now. In the next article, you'll make your world scroll. + +![Pygame platformer][3] + +Here's all the code so far: + + +``` +#!/usr/bin/env python3 +# draw a world +# add a player and player control +# add player movement +# add enemy and basic collision +# add platform +# add gravity +# add jumping + +# GNU All-Permissive License +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved.  This file is offered as-is, +# without any warranty. + +import pygame +import sys +import os + +''' +Objects +''' + +class Platform(pygame.sprite.Sprite): +    # x location, y location, img width, img height, img file     +    def __init__(self,xloc,yloc,imgw,imgh,img): +        pygame.sprite.Sprite.__init__(self) +        self.image = pygame.image.load(os.path.join('images',img)).convert() +        self.image.convert_alpha() +        self.rect = self.image.get_rect() +        self.rect.y = yloc +        self.rect.x = xloc + +class Player(pygame.sprite.Sprite): +    ''' +    Spawn a player +    ''' +    def __init__(self): +        pygame.sprite.Sprite.__init__(self) +        self.movex = 0 +        self.movey = 0 +        self.frame = 0 +        self.health = 10 +        self.collide_delta = 0 +        self.jump_delta = 6 +        self.score = 1 +        self.images = [] +        for i in range(1,9): +            img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert() +            img.convert_alpha() +            img.set_colorkey(ALPHA) +            self.images.append(img) +            self.image = self.images[0] +            self.rect  = self.image.get_rect() + +    def jump(self,platform_list): +        self.jump_delta = 0 + +    def gravity(self): +        self.movey += 3.2 # how fast player falls +        +        if self.rect.y > worldy and self.movey >= 0: +            self.movey = 0 +            self.rect.y = worldy-ty +        +    def control(self,x,y): +        ''' +        control player movement +        ''' +        self.movex += x +        self.movey += y +        +    def update(self): +        ''' +        Update sprite position +        ''' +        +        self.rect.x = self.rect.x + self.movex +        self.rect.y = self.rect.y + self.movey + +        # moving left +        if self.movex < 0: +            self.frame += 1 +            if self.frame > ani*3: +                self.frame = 0 +            self.image = self.images[self.frame//ani] + +        # moving right +        if self.movex > 0: +            self.frame += 1 +            if self.frame > ani*3: +                self.frame = 0 +            self.image = self.images[(self.frame//ani)+4] + +        # collisions +        enemy_hit_list = pygame.sprite.spritecollide(self, enemy_list, False) +        for enemy in enemy_hit_list: +            self.health -= 1 +            #print(self.health) + +        plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) +        for p in plat_hit_list: +            self.collide_delta = 0 # stop jumping +            self.movey = 0 +            if self.rect.y > p.rect.y: +                self.rect.y = p.rect.y+ty +            else: +                self.rect.y = p.rect.y-ty +            +        ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) +        for g in ground_hit_list: +            self.movey = 0 +            self.rect.y = worldy-ty-ty +            self.collide_delta = 0 # stop jumping +            if self.rect.y > g.rect.y: +                self.health -=1 +                print(self.health) +                +        if self.collide_delta < 6 and self.jump_delta < 6: +            self.jump_delta = 6*2 +            self.movey -= 33  # how high to jump +            self.collide_delta += 6 +            self.jump_delta    += 6 +            +class Enemy(pygame.sprite.Sprite): +    ''' +    Spawn an enemy +    ''' +    def __init__(self,x,y,img): +        pygame.sprite.Sprite.__init__(self) +        self.image = pygame.image.load(os.path.join('images',img)) +        self.movey = 0 +        #self.image.convert_alpha() +        #self.image.set_colorkey(ALPHA) +        self.rect = self.image.get_rect() +        self.rect.x = x +        self.rect.y = y +        self.counter = 0 + +                +    def move(self): +        ''' +        enemy movement +        ''' +        distance = 80 +        speed = 8 + +        self.movey += 3.2 +        +        if self.counter >= 0 and self.counter <= distance: +            self.rect.x += speed +        elif self.counter >= distance and self.counter <= distance*2: +            self.rect.x -= speed +        else: +            self.counter = 0 +        +        self.counter += 1 + +        if not self.rect.y >= worldy-ty-ty: +            self.rect.y += self.movey + +        plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) +        for p in plat_hit_list: +            self.movey = 0 +            if self.rect.y > p.rect.y: +                self.rect.y = p.rect.y+ty +            else: +                self.rect.y = p.rect.y-ty + +        ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) +        for g in ground_hit_list: +            self.rect.y = worldy-ty-ty + +        +class Level(): +    def bad(lvl,eloc): +        if lvl == 1: +            enemy = Enemy(eloc[0],eloc[1],'yeti.png') # spawn enemy +            enemy_list = pygame.sprite.Group() # create enemy group +            enemy_list.add(enemy)              # add enemy to group +            +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return enemy_list + +    def loot(lvl,lloc): +        print(lvl) + +    def ground(lvl,gloc,tx,ty): +        ground_list = pygame.sprite.Group() +        i=0 +        if lvl == 1: +            while i < len(gloc): +                ground = Platform(gloc[i],worldy-ty,tx,ty,'ground.png') +                ground_list.add(ground) +                i=i+1 + +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return ground_list + +    def platform(lvl,tx,ty): +        plat_list = pygame.sprite.Group() +        ploc = [] +        i=0 +        if lvl == 1: +            ploc.append((0,worldy-ty-128,3)) +            ploc.append((300,worldy-ty-256,3)) +            ploc.append((500,worldy-ty-128,4)) + +            while i < len(ploc): +                j=0 +                while j <= ploc[i][2]: +                    plat = Platform((ploc[i][0]+(j*tx)),ploc[i][1],tx,ty,'ground.png') +                    plat_list.add(plat) +                    j=j+1 +                print('run' + str(i) + str(ploc[i])) +                i=i+1 + +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return plat_list + +''' +Setup +''' +worldx = 960 +worldy = 720 + +fps = 40 # frame rate +ani = 4  # animation cycles +clock = pygame.time.Clock() +pygame.init() +main = True + +BLUE  = (25,25,200) +BLACK = (23,23,23 ) +WHITE = (254,254,254) +ALPHA = (0,255,0) + +world = pygame.display.set_mode([worldx,worldy]) +backdrop = pygame.image.load(os.path.join('images','stage.png')).convert() +backdropbox = world.get_rect() +player = Player() # spawn player +player.rect.x = 0 +player.rect.y = 0 +player_list = pygame.sprite.Group() +player_list.add(player) +steps = 10 # how fast to move +jump = -24 + +eloc = [] +eloc = [200,20] +gloc = [] +#gloc = [0,630,64,630,128,630,192,630,256,630,320,630,384,630] +tx = 64 #tile size +ty = 64 #tile size + +i=0 +while i <= (worldx/tx)+tx: +    gloc.append(i*tx) +    i=i+1 + +enemy_list = Level.bad( 1, eloc ) +ground_list = Level.ground( 1,gloc,tx,ty ) +plat_list = Level.platform( 1,tx,ty ) + +''' +Main loop +''' +while main == True: +    for event in pygame.event.get(): +        if event.type == pygame.QUIT: +            pygame.quit(); sys.exit() +            main = False + +        if event.type == pygame.KEYDOWN: +            if event.key == pygame.K_LEFT or event.key == ord('a'): +                print("LEFT") +                player.control(-steps,0) +            if event.key == pygame.K_RIGHT or event.key == ord('d'): +                print("RIGHT") +                player.control(steps,0) +            if event.key == pygame.K_UP or event.key == ord('w'): +                print('jump') + +        if event.type == pygame.KEYUP: +            if event.key == pygame.K_LEFT or event.key == ord('a'): +                player.control(steps,0) +            if event.key == pygame.K_RIGHT or event.key == ord('d'): +                player.control(-steps,0) +            if event.key == pygame.K_UP or event.key == ord('w'): +                player.jump(plat_list) + +            if event.key == ord('q'): +                pygame.quit() +                sys.exit() +                main = False + +#    world.fill(BLACK) +    world.blit(backdrop, backdropbox) +    player.gravity() # check gravity +    player.update() +    player_list.draw(world) #refresh player position +    enemy_list.draw(world)  # refresh enemies +    ground_list.draw(world)  # refresh enemies +    plat_list.draw(world)   # refresh platforms +    for e in enemy_list: +        e.move() +    pygame.display.flip() +    clock.tick(fps) +``` + +This is the 7th installment in an ongoing series about creating video games in [Python 3][4] using the [Pygame][5] module. Previous articles are: + + * [Learn how to program in Python by building a simple dice game][6] + * [Build a game framework with Python using the Pygame module][7] + * [How to add a player to your Python game][8] + * [Using Pygame to move your game character around][9] + * [What's a hero without a villain? How to add one to your Python game][10] + * [Simulate gravity in your Python game][2] + + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/jumping-python-platformer-game + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者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/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/arcade_game_gaming.jpg?itok=84Rjk_32 (Arcade games) +[2]: https://opensource.com/article/19/11/simulate-gravity-python +[3]: https://opensource.com/sites/default/files/uploads/pygame-jump.jpg (Pygame platformer) +[4]: https://www.python.org/ +[5]: https://www.pygame.org/ +[6]: https://opensource.com/article/17/10/python-101 +[7]: https://opensource.com/article/17/12/game-framework-python +[8]: https://opensource.com/article/17/12/game-python-add-a-player +[9]: https://opensource.com/article/17/12/game-python-moving-player +[10]: https://opensource.com/article/18/5/pygame-enemy diff --git a/sources/tech/20191205 Challenge- find Twitter memes with suffix arrays.md b/sources/tech/20191205 Challenge- find Twitter memes with suffix arrays.md new file mode 100644 index 0000000000..c767c9f1ed --- /dev/null +++ b/sources/tech/20191205 Challenge- find Twitter memes with suffix arrays.md @@ -0,0 +1,220 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Challenge: find Twitter memes with suffix arrays) +[#]: via: (https://jvns.ca/blog/twitter-memes-challenge/) +[#]: author: (Julia Evans https://jvns.ca/) + +Challenge: find Twitter memes with suffix arrays +====== + +This challenge is a mix of data analysis and using fun algorithms! It’s the second challenge in a a short series of programming challenge I’m writing with Julian. (the [first one was to write a tiny fun window manager][1]) + +Twitter has a lot of memes. For example, if you search Twitter for [Flight attendant: is there a doctor on this flight?][2], you’ll find a bunch of tweets making jokes like this: + +``` +Flight Attendant: is there a doctor on board? +Parent: *nudging* That should've been you +Me: Not now, this is serious +Parent: Not asking for a hacker to help, are they? +Me: AAAAAAAA\x00\xd0X?\xfc\x7fBBBBj\x0bX\x99Rfh-p\x89\xe1Rjhh/bash/bin\x89\xe3RQS\x89\xe1\xcd\x80 +Parent:~# +``` + +or if you search [as a kpop fan][3] there are thousands of these: + +``` +me as a kpop fan + +- kpop fan age: 10 years +- first group ever stan: super junior +- current ult groups: iKON, X1, Day6 +- number of albums: >20 +- concerts attended: 6 +- lightsticks owned: 2 +``` + +So! Suppose you have a million tweets from the last 2 days. How do you find the jokes / quizzes / memes people are playing with on Twitter? + +### Challenge: find the twitter memes in 1 million tweets + +This is a pretty open ended challenge and you can do it any way you want. Here’s a [SQLite database with 1.2 million tweets][4], collected from the [twitter streaming api][5] over 2 days. It’s 250MB (70MB compressed), it only has English tweets. It excludes retweets and many tweets that are generated by bots. + +The challenge: find at least 5 Twitter memes using that dataset. + +### memes as common substrings + +The idea here is that memes are substrings like “me as a kpop fan” that many different people are using. The tricky thing is that you don’t really know how long those substrings will be, and maybe you’re interested in phrases of different lengths. + +You can probably do this challenge without using anything fancy (with a hashmap of phrases or something) but I think it’s a nice opportunity to play with a fun data structure: suffix arrays! So let’s talk about what those are. + +### suffix arrays: sort all suffixes + +Suffix arrays sort all suffixes of a string. For example, here’s the suffix array for “plantain” which has the suffixes plantain, lantain, antain, ntain, tain, ain, in, n. + +``` +ain +antain +in +lantain +n +ntain +plantain +tain +``` + +Representing this as a list of strings would be very inefficient (quadratic space), so instead we replace each suffix with the index of its first character in the original string – `[5,2,6,1,7,3,0,4]`. + +``` +5 (ain) +2 (antain) +6 (in) +1 (lantain) +7 (n) +3 (ntain) +0 (plantain) +4 (tain) +``` + +Here’s a real example of what a suffix array of 1 million tweets concatenated looks like. This is an excerpt from the middle of the suffix array, with some of the suffixes that start with `A little`. + +``` +... + A little distracted for a bit ...what do i do w my life hon......... + A little exercise I did this afternoon. #comics #art #clip......... + A little extra Christmas Cash on me! Good Luck to everyone!......... + A little girl in Savannah, Ga., appears to be the 38th huma......... + A little heavy on the smut t… https://t.co/nvoxE7SNjTI wa......... + A little in state battle tonight. #nova vs #penn. two very ......... + A little kiss...” one more time I’m going to vomit. #TT......... + A little late catching up on last nights @GoodDoctorABC. On......... + A little less bling never hurt anyone! Next project...🎄 ......... + A little more intensity to augment their talent and a coupl......... + A little more time, because I have never lived really - Os......... + A little mor… https://t.co/kcq3zf9jgeWe love MX ❤️<9F>......... + A little over 50k! Can We Guess How Much Is In Your Account......... + A little ray of joy & light in the midst of these very ......... + A little refreshment… https://t.co/HgX8PmYwPIThank you @L......... + A little respect goes a long way. ......... + A little salt in d country's troubled legal system“Grant................ + A little snow & people lose all common senseromantic st............... + A little sun for the soul @realfreewebcams https://t.co/3CB............... + A little sunkissed moment for y’all. ............... + .... +``` + +Again, this is actually represented by a bunch of integer indexes into a concatenated string of all the tweets, like `[18238223, 1921812, ...]` so it’s a LOT more memory efficient than actually repeating all those strings. + +### suffix arrays let you find common substrings! + +So what does this have to do with Twitter memes? Well, we can basically + + 1. concatenate all tweets into a big string + 2. make a suffix array of that string + 3. iterate through the suffix array and notice when you see a lot of repeated substrings, like here: + + + +``` +me as a kpop fan ✨kpop fan age: 15 y/o ✨first group ever stan: blackpink ✨current ult groups: btxt ✨number of albu… https://t.co/24diHX9sLm +me as a kpop fan ⭐k-pop fan age: 12 y/o ⭐first group ever stan: bts ⭐current ult gps: bts and txt ⭐number of albu… https://t.co/8R95roQXoE +me as a kpop fan ⭐k-pop fan age: 14 y/o ⭐first group ever stan: girls generation ⭐current ult gp: txt ⭐number of a… https://t.co/010hLuJscF +me as a kpop fan ⭐k-pop fan age: 14-16 y/o ⭐first group ever stan: bts ⭐current ult gps: bts txt ⭐number of albums… https://t.co/0fDcxZGRrh +me as a kpop fan ⭐k-pop fan age: 15 y/o ⭐first group ever stan: blackpink ⭐current ult gps: txt ⭐number of albums… https://t.co/d8zZL83TvV +me as a kpop fan 🌸 k-pop fan age: 12 years old 🌸 first group ever stan: bts 🌸 current ult gps: bts & wanna one 🌸 n… https://t.co/22R1nJpwNX +me as a kpop fan 🌸k-pop fan age: 10 🌸first group ever stan: 2pm 🌸current ult gps: skz,got7,itzy,twice, 🌸number of… https://t.co/mAluaP2yxH +me as a kpop fan 🌸k-pop fan age: 11 yo 🌸first group ever stan: beast 🌸current ult gps: ateez 🌸number of albums: 1… https://t.co/qxtFHG9HDg +me as a kpop fan 🌸k-pop fan age: 11 🌸first group ever stan: bts 🌸current ult gps: bts and ateez 🌸number of albums:… https://t.co/mKXlkrBBtC +me as a kpop fan 🌸k-pop fan age: 13 (now im 19) 🌸first group ever stan: snsd 🌸current ult gps: nct day6 aoa mamam… https://t.co/8XyQ3r5hwz +me as a kpop fan 🌸k-pop fan age: 13 years 🌸first group ever stan: 2pm,suju,bigbang 🌸current ult gps: bts,tbz,ateez… https://t.co/Zs1nQQz6Lt +me as a kpop fan 🌸k-pop fan age: 14 (2005) 🌸first group ever stan: super junior 🌸current ult gps: exo, gfriend, rv… https://t.co/vgmhe2vFMY +me as a kpop fan 🌸k-pop fan age: 14 y/o 🌸first group ever stan: nct dream 🌸current ult gps: svt and,,*insert stan… https://t.co/I38Ui69PvL +me as a kpop fan 🌸k-pop fan age: 15 y/o 🌸first group ever stan: 5sos 🌸current ult gps: bts and 5sos also some ggs… https://t.co/61ZmRkzmdl +me as a kpop fan 🌸k-pop fan age: 15 y/o 🌸first group ever stan: bts 🌸current ult gps: SVT, GOT7, Day6 🌸number of… https://t.co/16SWb3mSPg +me as a kpop fan 🌸k-pop fan age: 18 🌸first group ever stan: suju & soshi 🌸current ult gps: snsd & izone 🌸number of… https://t.co/SmSBFqJnGk +me as a kpop fan 🌸k-pop fan age: 19 y/o marupok 🌸first group ever stan: APINK 🌸current ult gps: SEVENTEEN 🌸number… https://t.co/StYjxr6uq9 +me as a kpop fan 🌸k-pop fan age: 19 🌸first group ever stan: SuJu 🌸current ult gps: SuJu, SF9, SKZ, VIXX, ONEUS, NO… https://t.co/2o2DulCY5b +``` + +### suffix arrays also enable really fast search + +As an aside, the reason I got interested in suffix arrays in the first place was actually not for finding Twitter memes at all but for search. + +I’ve spent a lot of time using Nelson Elhage’s [livegrep][6] at work to search code. It creates a suffix array using the divsufsort library. He has a blog post [Regular Expression Search with Suffix Arrays][7] where he talks about some of the implementation details. + +The reason suffix arrays work for fast search is basically that if you’re looking for the string `A little`, you can do a binary search over the suffix array to find every instance of `A little` in your dataset. Binary searches are extremely fast so every search is guaranteed to run very quickly (in less than a microsecond I believe). What livegrep does is more complicated than that because it does a regular expression search, but that’s the idea to start. + +There’s another blog post [How to use suffix arrays to combat common limitations of full-text search][8] applying suffix arrays to searching through a patent database. In that example, like with code search, the patent officers want to search patents for exact strings. + +### How do you make a suffix array? + +You can use an existing suffix array library, for example [index/suffixarray in Go][9], which is what I used, or [divsufsort][10]. There are [Python bindings for divsufsort][11]. + +If you’re more excited about the data structures/algorithms aspect of suffix arrays you can also implement a suffix array-building algorithm yourself! I did not do this but you can see an implementation of [qsufsort here in Go][12]. That implementation links to a paper. There are lots of algorithms for constructing suffix arrays –`sais` and `divsufsort` are a couple of others. + +### 5 or so hours, 100 lines of Go + +As always with these challenges, I did this one to make sure that it’s both doable in a reasonable amount of time and fun for at least one person (me). + +I did this one in about 5 hours and 100 lines of Go using the suffixarray implementation in the Go standard library, with a bit of bash shell scripting to postprocess the results. This is a messy data analysis challenge – as an example of a messy thing, Spotify released their end-of-2019 results while I was building the dataset and so there are a lot of tweets generated by the Spotify app. + +My results ended up looking something like this: + +``` +5 an Aries and that’s why I gotta +5 an Aries and that’s why I am so +5 an Aquarius and that’s why I +5 AM SO PROUD OF YOU +5 am not a fan of +5 am I the only one who +5 am going to have to +``` + +Then I sifted through them pretty manually to find the Twitter memes. + +### suffix arrays are used in bioinformatics + +This “find twitter memes using suffix arrays” approach is a silly thing but it does have some relationship to reality – DNA sequences are basically really long strings, and biologists need to find patterns in them, and they sometimes use suffix arrays to do it. + +I looked up [packages in Debian that use libdivsufsort][13] and I found [infernal][14]: + +> Infernal (“INFERence of RNA ALignment”) is for searching DNA sequence databases for RNA structure and sequence similarities. It is an implementation of a special case of profile stochastic context-free grammars called covariance models (CMs). A CM is like a sequence profile, but it scores a combination of sequence consensus and RNA secondary structure consensus, so in many cases, it is more capable of identifying RNA homologs that conserve their secondary structure more than their primary sequence. + +### email me the twitter memes you find if you do this! + +If you do this exercise, I’d love it if you emailed me ([[email protected]][15]) with the twitter memes you found and/or your code! I found about 8 but I’m sure there are more. + +I’ll publish any solutions I get (unless you don’t want me to publish your solution – just let me know!). + +Thanks to Julian for discussing suffix arrays and suffix trees and trigram indexes with me at length, and to Kamal who had the idea of using suffix arrays to find Twitter memes. + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/twitter-memes-challenge/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://jvns.ca/blog/2019/11/25/challenge--make-a-bouncy-window-manager/ +[2]: https://twitter.com/search?q=%22attendant%3A%20is%20there%20a%20doctor%20on%20%22&src=typed_query&f=live +[3]: https://twitter.com/search?q=%22as%20a%20kpop%20fan%22&src=typed_query +[4]: https://www.dropbox.com/s/5xnaf1mbdr1424p/twitter.db.gz?dl=0 +[5]: https://developer.twitter.com/en/docs/tutorials/consuming-streaming-data +[6]: https://livegrep.com/search/linux +[7]: https://blog.nelhage.com/2015/02/regular-expression-search-with-suffix-arrays/ +[8]: https://blog.griddynamics.com/using-suffix-arrays-to-fix-limitations-of-full-text-search/ +[9]: https://golang.org/pkg/index/suffixarray/ +[10]: https://github.com/y-256/libdivsufsort +[11]: https://github.com/debatem1/pydivsufsort +[12]: https://github.com/golang/go/blob/release-branch.go1.12/src/index/suffixarray/qsufsort.go +[13]: https://codesearch.debian.net/search?q=divsufsort +[14]: http://eddylab.org/infernal/ +[15]: https://jvns.ca/cdn-cgi/l/email-protection diff --git a/sources/tech/20191206 A beginner-s guide to using Vagrant.md b/sources/tech/20191206 A beginner-s guide to using Vagrant.md new file mode 100644 index 0000000000..a96389215c --- /dev/null +++ b/sources/tech/20191206 A beginner-s guide to using Vagrant.md @@ -0,0 +1,219 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (A beginner's guide to using Vagrant) +[#]: via: (https://opensource.com/article/19/12/beginner-vagrant) +[#]: author: (Jessica Repka https://opensource.com/users/jrepka) + +A beginner's guide to using Vagrant +====== +This easy "hello world" tutorial makes it easy to start using Vagrant +for virtual machine management. +![A person programming][1] + +Vagrant [describes itself][2] as "a tool for building and managing virtual machine environments in a single workflow. With an easy-to-use workflow and focus on automation, Vagrant lowers development environment setup time, increases production parity, and makes the 'works on my machine' excuse a relic of the past." + +Vagrant works with a standard format for documenting an environment, called a Vagrantfile. [According to Vagrant's website][3]: + +> "The primary function of the Vagrantfile is to describe the type of machine required for a project, and how to configure and provision these machines. Vagrantfiles are called Vagrantfiles because the actual literal filename for the file is **Vagrantfile** (casing does not matter unless your file system is running in a strict case sensitive mode)." + +Vagrant is essentially a wrapper to allow for repeatable virtual machine management, but it does not run VMs itself. This tutorial will use [VirtualBox][4] as that environment manager, though Hyper-V and Docker also work by default. Check out Vagrant's documentation to [learn how to use a different provider][5] for this tutorial. + +### Build a Vagrantfile + +This tutorial works through an example application for a simple Hello World page inside a Ruby on Rails (Rails for short) web app. Before you begin, install the following (if you haven't already): + + * [Vagrant][6] + * [VirtualBox][7] + * [Ruby on Rails][8] + * An editing environment, like [Atom][9] or [Notepad++][10] + + + +If you're on Fedora and prefer using the command line, there is an [excellent Fedora tutorial][11], and there's a similarly helpful tutorial for [Windows using Chocolatey][12]. After everything is installed, open your terminal and create a new directory to work in. You can put your directory wherever you like; I prefer to use a folder under my user account: + + +``` +$ mkdir -p ~/Development/Rails_app +$ cd ~/Development/Rails_app +$ vagrant init + +A `Vagrantfile` has been placed in this directory. You are now +ready to `vagrant up` your first virtual environment! Please read +the comments in the Vagrantfile as well as documentation on +`vagrantup.com` for more information on using Vagrant. +``` + +This creates a Vagrantfile with the default configuration information written in Ruby syntax. Look at line 15: + + +``` +`config.vm.box = "base"` +``` + +This indicates that Vagrant will use a default operating system image it hosts called **base**, which you don't have yet. Confirm that by running **box list**: + + +``` +$ vagrant box list + +There are no installed boxes! Use `vagrant box add` to add some. +``` + +If you try to start your environment using the **up** command, it will fail, because Vagrant expects an OS called **base** to exist locally. Switch to the most commonly used environment, **bento/ubuntu-16.04**, then try to spin up your environment. Change the **config.vm.box** line in your Vagrantfile to: + + +``` +`config.vm.box = "centos/7"` +``` + +And now you can run the most satisfying command in virtual machine history: + + +``` +$ vagrant up +Bringing machine 'default' up with 'libvirt' provider... +==> default: Box 'centos/7' could not be found. Attempting to find and install... +    default: Box Provider: libvirt +    default: Box Version: >= 0 +==> default: Loading metadata for box 'centos/7' +    default: URL: +==> default: Adding box 'centos/7' (v1905.1) for provider: libvirt +    default: Downloading: +    default: Download redirected to host: cloud.centos.org +... +``` + +Here is why this is so nice. This tutorial sets up a small website, but if you had a larger website and needed to check whether the frontend looks right, your playbook file and copy-over files would allow you to see your changes. If you have small applications you want to test quickly—without doing an entire Docker image build or logging into a server—this local testing is good for quick checks and repairs. If you're working within hardware, this will make it easy to see if the application will work within your operating system, and it allows you to know which dependencies you need. In the end, it makes for easier deployment and faster testing than doing a from-scratch continuous integration and deployment (CI/CD) to a test server, and it provides quicker access and more control. + +The reason this is so cool can be explained in one simple sentence: You now have local automation. It also allows you to gather a larger breadth of knowledge behind [Ansible][13] and headless server deployments. + +### Verify Vagrant worked correctly + +One way to determine whether this finished properly is seeing a bunch of green text and the words **rails server -h** for startup options. This means the web app has started and is running. + +![Verifying with the vagrant status command][14] + +But you want to use **vagrant global-status** as well as **vagrant status**. + +![Verifying with the vagrant global-status command][15] + +The **vagrant status** command checks the machine states that originate in the current directory. So, if you have a VM up and running, it will show as up and running. If it is broken in any way, it will display a message with an error and some logs when you run **vagrant up**. If some machines are down, they will also show as not running or shut down. + +However, the **vagrant global-status** command can give the status of multiple environments created in Vagrant. So, if you split the environments for different VM types or storage types, this command gives you an option to see everything in all the environments you've created. + +### Customize the Vagrant configuration + +The machine settings have multiple [config.vm][16] options. This tutorial will use the networking option to allow port forwarding. Port forwarding allows you to access a network port in our virtual environment as if it was a local port via a special local network. This means traffic is allowed to see the one thing you allow on this server; in this case, it's a tiny frontend webpage. + +The main reason this matters is for security. Limiting traffic can prevent bad actors and traffic overflow. The way this is built, you can't log into this server unless you configure it as such. This also means no one else can SSH in or see anything except the one little frontend webpage. + +Before moving on, remove the VM so you can start over by running [**vagrant destroy**][17]: + + +``` +$ vagrant destroy +    default: Are you sure you want to destroy the 'default' VM? [y/N] y +==> default: Removing domain... +``` + +To include port forwarding, add this in the next config line: + + +``` + Vagrant.configure("2") do |config| +  config.vm.box = "bento/ubuntu-16.04" +  config.vm.network "forwarded_port", guest: 3000, host: 9090 +  end +``` + +Save the file and run: + + +``` +`vagrant up` +``` + +You now have a VM that forwards port **3000** out to the open world as **9090**. You should now be able to go to **127.0.0.1:9090** on your web browser and see nothing but a plain white page. + +Run **vagrant destroy** again to remove the VM so you can start over. + +### Provision Vagrant with Ansible and scripts + +While base boxes offer a good starting point, it's common to customize a VM during the provisioning process, and you can use multiple provisioning tactics. To follow along, [download the playbook and script][18]. + +This example uses Ansible to set up a basic install of the Ruby on Rails web framework. Then, it adds an extra shell script to configure the web app's welcome page to say: _Hello World, Sorry for the Delay_. (The purpose of this message is because this build takes a long time and people may become frustrated by the delay.) + +The following Vagrantfile reflects Ansible and a playbook running locally on my machine, so it will differ from yours. You can read about [using Ansible with Vagrant][19] in Vagrant's docs. + + +``` +Vagrant.configure("2") do |config| + config.vm.box = "bento/ubuntu-16.04" +  config.vm.network "forwarded_port", guest: 3000, host: 9090 +  ####### Provision ####### +  config.vm.provision "ansible_local" do |ansible| +   ansible.playbook = "prov/playbook.yml" +    ansible.verbose = true +  config.vm.provision "shell", path: "script.sh" +  end +end +``` + +After saving the file, run my favorite command: + + +``` +`vagrant up` +``` + +You now have a VM up and running with Rails, and when you enter **127.0.0.1:9090** in your web browser, you see a webpage that says: _Hello World, Sorry for the Delay_. + +Now that you have all this background, you can try to [build your own script][20]. + +### Final notes + +Vagrant is fairly easy to work with and has abundant [documentation][21] to help you along the way. It's is a great tool if you're looking to work with code in a small staging or development environment; any destruction is a non-issue because the environment itself is disposable. + +Want to give it a try? Take a look at my [repo][18]. + +In this short video, Daniel Farrell tells us about Vagrant, a tool for working with Virtual... + +Learn how Vagrant and Ansible can be used to provision virtual machines for web development. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/beginner-vagrant + +作者:[Jessica Repka][a] +选题:[lujun9972][b] +译者:[译者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/jrepka +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_code_woman.png?itok=vbYz6jjb (A person programming) +[2]: https://www.vagrantup.com/intro/index.html +[3]: https://www.vagrantup.com/docs/vagrantfile/ +[4]: https://www.virtualbox.org/browser/vbox/trunk +[5]: https://www.vagrantup.com/docs/providers/basic_usage.html +[6]: https://www.vagrantup.com/docs/installation/ +[7]: https://www.virtualbox.org/wiki/Downloads +[8]: http://installrails.com/steps/choose_os +[9]: https://atom.io/ +[10]: https://notepad-plus-plus.org/downloads/ +[11]: https://computingforgeeks.com/how-to-install-vagrant-and-virtualbox-on-fedora/ +[12]: https://codingbee.net/vagrant/vagrant-installing-vagrant-on-windows +[13]: https://www.ansible.com/ +[14]: https://opensource.com/sites/default/files/uploads/vagrant1_vagrant-status.png (Verifying with the vagrant status command) +[15]: https://opensource.com/sites/default/files/uploads/vagrant2_vagrant-global-status.png (Verifying with the vagrant global-status command) +[16]: https://www.vagrantup.com/docs/vagrantfile/machine_settings.html +[17]: https://www.vagrantup.com/docs/cli/destroy.html +[18]: https://github.com/Alynder/vagrant_adwx +[19]: https://www.vagrantup.com/docs/provisioning/ansible.html +[20]: https://www.bogotobogo.com/RubyOnRails/RubyOnRails_HelloWorld_Rails.php +[21]: https://www.vagrantup.com/docs/index.html diff --git a/sources/tech/20191208 8 Best Open Source Accounting Software.md b/sources/tech/20191208 8 Best Open Source Accounting Software.md new file mode 100644 index 0000000000..3639504902 --- /dev/null +++ b/sources/tech/20191208 8 Best Open Source Accounting Software.md @@ -0,0 +1,199 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (8 Best Open Source Accounting Software) +[#]: via: (https://itsfoss.com/open-source-accounting-software/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +8 Best Open Source Accounting Software +====== + +Accounting software is a necessity when it comes to managing billings, debts, stocks, invoices and any other kind of financial transactions. You might require something for your personal finances or perhaps for enterprise-focused accounting software. No matter what, it is important to consider open source solutions available (especially being Linux enthusiasts). + +So, in this article, I list out some of the best open source accounting software that I think would come in handy for you. At the end of the list, feel free to suggest your favorite ones in the comments. + +### Best Open Source Accounting Software + +**Note:** _The list is in no particular order of ranking._ + +#### 1\. Skrooge + +![][1] + +Key Highlights: + + * Personal finances manager + * Tailored for Plasma Desktop but compatible with others too + * Cross-platform (Windows, Linux, and macOS) + + + +Skrooge is one of the most useful personal finances manager by KDE. It is originally tailored for the Plasma Desktop but other desktop environments are compatible. + +Supports most of the basic features (reporting, budgeting, etc.) and allows you to work on some pretty big data sets. + +[Skrooge][2] + +#### 2\. Akaunting + +![][3] + +Key Highlights: + + * Online accounting software + * Completely free and open source + * Client portal + * Invoicing + * Expense tracking + * Reporting + * Cashflow + + + +Akaunting is an interesting online accounting software that’s available for free. Yes, surprisingly, there’s no hidden subscription charges or additional upgrade options. It is totally free. If you are looking for a FreshBooks alternative, you should give it a try. + +Ranging from invoicing to managing deposits and transfers. A whole lot of features. You can either utilize their hosting (again, it is free!) or host it yourself. It’s fit for both personal and enterprise needs. Try it out! + +[Akaunting][4] + +#### 3\. Apache OFBiz + +![][5] + +Key Highlights: + + * ERP & CRM + * Developer-friendly + * Powerful Java Web Framework + * Cross-platform (Linux and macOS) + + + +We’ve already mentioned this in our list of [best open source CRM software][6]. Apache OFBiz is an impressive open source solution that incorporates an ERP system and a CRM suite for various types of requirements. + +It’s completely free – however, you will have to host it yourself (or just hire someone to do it). In addition to all the basic features needed for accounting software, it lets a developer extend/enhance features easily while being a Java-based web framework. + +[Apache OFBiz][7] + +#### 4\. iDempiere + +![][8] + +Key Highlights: + + * Community-focused + * Simple and useful + * Cross-platform (Linux and Windows) + + + +Originally based on ADEmpiere ERP. It is a community focused accounting software maintained by an active group of people. iDempiere aims to utilize technologies like [Apache Maven][9] to provide a business suite ERP/CRM/SCM. + +There’s a ready-to-use Virtual machine available to download. In addition, you can utilize it on Windows or Linux. + +[iDempiere][10] + +#### 5\. Openmiracle + +![Openmiracle][11] + +Key Highlights: + + * Plug-ins available + * Completely free + + + +Openmiracle is a quite popular open source and free accounting software. There’s no premium plans to it. So, you can utilize all the power and flexibility for free. + +It features all the necessary options needed in an accounting software. From setting the budget to managing the payroll, there’s a lot of things to explore. + +[Openmiracle][12] + +#### 6\. GnuCash + +![][13] + +Key Highlights: + + * Cross-platform (Linux, Windows, and macOS) + * Fit for personal and small businesses + + + +GNUCash is a great open-source financial accounting software to manage stocks/income/expenses for small business or individuals. + +From reports to quick calculation features, it has a lot to offer. And, the best thing is – it is available across multiple platforms (including Linux), so that’s a plus. + +[GNUCash][14] + +#### 7\. LedgerSMB + +![Ledgersmb Screenshot][15] + +Key Highlights: + + * Dead simple open source ERP + * Optional commercial support available + * Cross-platform (Windows, Linux, and macOS) + + + +A powerful yet simple open source accounting solution. It has been tailored to small and medium sized businesses. Starting from managing invoices to inventory – you also get the ability to translate (up to 45 languages supported). You can try pre-release version or just get the latest stable build to test it out yourself! + +[LedgerSMB][16] + +#### 8\. GNUKhata + +Key Highlights: + + * GST, VAT compliant Invoices if you are based in India (tailored for Indian users) + * Easy to use + * Simple user interface + * Cross-platform (Windows and Linux) + + + +We already covered an article on [GNUKhata][17], if you want to dive into the details. + +However, it is a simple and robust accounting software that is available for free. From the looks of it, the setup is easy and anyone can get used to it. Feel free to try it out and explore. + +[GNUKhata][18] + +**Wrapping Up** + +These are our recommended picks for an open source accounting software. If we missed listing your favorite open-source accounting software, let us in the comments below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/open-source-accounting-software/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/skrooge.jpg?ssl=1 +[2]: https://skrooge.org/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/09/akaunting.jpg?ssl=1 +[4]: https://akaunting.com/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/07/apache-ofbiz.jpg?ssl=1 +[6]: https://itsfoss.com/best-open-source-crm/ +[7]: https://ofbiz.apache.org/ +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/09/idempiere.jpg?ssl=1 +[9]: https://en.wikipedia.org/wiki/Apache_Maven +[10]: https://www.idempiere.org/home +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/openmiracle.jpg?ssl=1 +[12]: http://www.openmiracle.com/ +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/09/gnucash-screenshot.png?ssl=1 +[14]: https://www.gnucash.org/ +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/09/ledgerSMB-screenshot.jpg?ssl=1 +[16]: https://ledgersmb.org/ +[17]: https://itsfoss.com/using-gnu-khata/ +[18]: https://gnukhata.in/ diff --git a/sources/tech/20191208 Dynamically scoped variables in Go.md b/sources/tech/20191208 Dynamically scoped variables in Go.md new file mode 100644 index 0000000000..959799f89e --- /dev/null +++ b/sources/tech/20191208 Dynamically scoped variables in Go.md @@ -0,0 +1,200 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Dynamically scoped variables in Go) +[#]: via: (https://dave.cheney.net/2019/12/08/dynamically-scoped-variables-in-go) +[#]: author: (Dave Cheney https://dave.cheney.net/author/davecheney) + +Dynamically scoped variables in Go +====== + +This is a thought experiment in API design. It starts with the classic Go unit testing idiom: + +``` +func TestOpenFile(t *testing.T) { + f, err := os.Open("notfound") + if err != nil { + t.Fatal(err) + } + + // ... +} +``` + +What’s the problem with this code? The assertion. `if err != nil { ... }` is repetitive and in the case where multiple conditions need to be checked, somewhat error prone if the author of the test uses `t.Error` not `t.Fatal`, eg: + +``` +f, err := os.Open("notfound") +if err != nil { + t.Error(err) +} +f.Close() // boom! +``` + +What’s the solution? DRY it up, of course, by moving the repetitive assertion logic to a helper: + +``` +func TestOpenFile(t *testing.T) { +       f, err := os.Open("notfound") +       check(t, err) + +       // ... +} + +func check(t *testing.T, err error) { +       if err != nil { +                t.Helper() +               t.Fatal(err) +        } +} +``` + +Using the `check` helper the code is a little cleaner, and clearer, _check the error_, and hopefully the indecision between `t.Error` and `t.Fatal` has been solved. The downside of abstracting the assertion to a helper function is now you need to pass a `testing.T` into _each and every invocation_. Worse, you need to pass a `*testing.T` to everything that needs to call `check`, transitively, just in case. + +This is ok, I guess, but I will make the observation that the `t` variable is only needed _when the assertion fails_ — and even in a testing scenario, most of the time, most of the tests pass, so that means reading, and writing, all these `t`‘s is a constant overhead for the relatively rare occasion that a test fails. + +What about if we did something like this instead? + +``` +func TestOpenFile(t *testing.T) { +       f, err := os.Open("notfound") +        check(err) + +       // ... +} + +func check(err error) { +        if err != nil { +                panic(err.Error()) +        } +} +``` + +Yeah, that’ll work, but it has a few problems + +``` +% go test +--- FAIL: TestOpenFile (0.00s) +panic: open notfound: no such file or directory [recovered] +        panic: open notfound: no such file or directory + +goroutine 22 [running]: +testing.tRunner.func1(0xc0000b4400) +        /Users/dfc/go/src/testing/testing.go:874 +0x3a3 +panic(0x111b040, 0xc0000866f0) +        /Users/dfc/go/src/runtime/panic.go:679 +0x1b2 +github.com/pkg/expect_test.check(...) +        /Users/dfc/src/github.com/pkg/expect/expect_test.go:18 +github.com/pkg/expect_test.TestOpenFile(0xc0000b4400) +        /Users/dfc/src/github.com/pkg/expect/expect_test.go:10 +0xa1 +testing.tRunner(0xc0000b4400, 0x115ac90) +        /Users/dfc/go/src/testing/testing.go:909 +0xc9 +created by testing.(*T).Run +        /Users/dfc/go/src/testing/testing.go:960 +0x350 +exit status 2 +``` + +Let’s start with the good; we didn’t have to pass a `testing.T` every place we call `check`, the test fails immediately, and we get a nice message in the panic — albeit twice. But _where_ the assertion failed is hard to see. It occurred on `expect_test.go:11` but you’d be forgiven for not knowing that. + +So `panic` isn’t really a good solution, but there’s something in this stack trace that is — can you see it? Here’s a hint, `github.com/pkg/expect_test.TestOpenFile(0xc0000b4400)`. + +`TestOpenFile` has a `t` value, it was passed to it by `tRunner`, so there’s a `testing.T` in memory at address `0xc0000b4400`. What if we could get access to that `t` inside `check`? Then we could use it to call `t.Helper` and `t.Fatal`. Is that possible? + +### Dynamic scoping + +What we want is to be able to access a variable whose declaration is neither global, or local to the function, but somewhere higher in the call stack. This is called _dynamic scoping_. Go doesn’t support dynamic scoping, but it turns out, for restricted cases, we can fake it. I’ll skip to the chase: + +``` +// getT returns the address of the testing.T passed to testing.tRunner +// which called the function which called getT. If testing.tRunner cannot +// be located in the stack, say if getT is not called from the main test +// goroutine, getT returns nil. +func getT() *testing.T { +        var buf [8192]byte +        n := runtime.Stack(buf[:], false) +        sc := bufio.NewScanner(bytes.NewReader(buf[:n])) +        for sc.Scan() { +                var p uintptr +                n, _ := fmt.Sscanf(sc.Text(), "testing.tRunner(%v", &p) +                if n != 1 { +                        continue +                } +                return (*testing.T)(unsafe.Pointer(p)) +        } +        return nil +} +``` + +We know that each `Test` is called by the `testing` package in its own goroutine (see the stack trace above). The `testing` package launches the test via a function called `tRunner` which takes a `*testing.T` and a `func(*testing.T)` to invoke. Thus we grab a stack trace of the current goroutine, scan through it for the line beginning with `testing.tRunner` — which can only be the `testing` package as `tRunner` is a private function — and parse the address of the first parameter, which is a pointer to a `testing.T`. With a little `unsafe` we convert the raw pointer back to a `*testing.T` and we’re done. + +If the search fails then it is likely that `getT` wasn’t called from a `Test`. This is actually ok because the reason we needed the `*testing.T` was to call `t.Fatal` and the testing package already requires that `t.Fatal` be called from the [main test goroutine][1]. + +``` +import "github.com/pkg/expect" + +func TestOpenFile(t *testing.T) { +        f, err := os.Open("notfound") +        expect.Nil(err) + +        // ... +} +``` + +Putting it all together we’ve eliminated the assertion boilerplate and possibly made the expectation of the test a little clearer to read, _after opening the file `err` is expected to be nil_. + +### Is this fine? + +At this point you should be asking, _is this fine?_ And the answer is, no, this is not fine. You should be screaming internally at this point. But it’s probably worth introspecting those feelings of revulsion. + +Apart from the inherent fragility of scrobbling around in a goroutine’s call stack, there are some serious design issues: + + 1. The `expect.Nil`‘s behaviour now depends on _who called it_. Provided with the same arguments it may have different behaviour depending on where it appears in the call stack — this is unexpected. + 2. Taken to the extreme dynamic scoping effective brings into the scope of a single function all the variables passed into any function that preceded it. It is a side channel for passing data in to and out of functions that is not explicitly documented in function declaration. + + + +Ironically these are precisely the critiques I have of [`context.Context`][2]. I’ll leave it to you to decide if they are justified. + +### A final word + +This is a bad idea, no argument there. This is not a pattern you should ever use in production code. But, this isn’t production code, it’s a test, and perhaps there are different rules that apply to test code. After all, we use mocks, and stubs, and monkey patching, and type assertions, and reflection, and helper functions, and build flags, and global variables, all so we can test our code effectively. None of those, uh, _hacks_ will ever show up in the production code path, so is it really the end of the world? + +If you’ve read this far perhaps you’ll agree with me that as unconventional as this approach is, not having to pass a `*testing.T` into every function that could possibly need to assert something transitively, makes for clearer test code. + +So maybe, in this case, the ends do justify the means. + +* * * + +If you’re interested, I’ve put together a [small assertion library][3] using this pattern. _Caveat emptor_. + +#### Related posts: + + 1. [Go, without package scoped variables][4] + 2. [On declaring variables][5] + 3. [A whirlwind tour of Go’s runtime environment variables][6] + 4. [You shouldn’t name your variables after their types for the same reason you wouldn’t name your pets “dog” or “cat”][7] + + + +-------------------------------------------------------------------------------- + +via: https://dave.cheney.net/2019/12/08/dynamically-scoped-variables-in-go + +作者:[Dave Cheney][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://dave.cheney.net/author/davecheney +[b]: https://github.com/lujun9972 +[1]: https://golang.org/pkg/testing/#T.FailNow +[2]: https://dave.cheney.net/2017/01/26/context-is-for-cancelation +[3]: https://github.com/pkg/expect +[4]: https://dave.cheney.net/2017/06/11/go-without-package-scoped-variables (Go, without package scoped variables) +[5]: https://dave.cheney.net/2014/05/24/on-declaring-variables (On declaring variables) +[6]: https://dave.cheney.net/2015/11/29/a-whirlwind-tour-of-gos-runtime-environment-variables (A whirlwind tour of Go’s runtime environment variables) +[7]: https://dave.cheney.net/2019/01/29/you-shouldnt-name-your-variables-after-their-types-for-the-same-reason-you-wouldnt-name-your-pets-dog-or-cat (You shouldn’t name your variables after their types for the same reason you wouldn’t name your pets “dog” or “cat”) diff --git a/sources/tech/20191208 What-s your favorite terminal emulator.md b/sources/tech/20191208 What-s your favorite terminal emulator.md new file mode 100644 index 0000000000..ff3ed8349d --- /dev/null +++ b/sources/tech/20191208 What-s your favorite terminal emulator.md @@ -0,0 +1,74 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What's your favorite terminal emulator?) +[#]: via: (https://opensource.com/article/19/12/favorite-terminal-emulator) +[#]: author: (Opensource.com https://opensource.com/users/admin) + +What's your favorite terminal emulator? +====== +We asked our community to tell us about their experience with terminal +emulators. Here are a few of the responses we received. Take our poll to +weigh in on your favorite. +![Terminal window with green text][1] + +Preference of a terminal emulator can say a lot about a person's workflow. Is the ability to drive mouseless a must-have? Do you like to navigate between tabs or windows? There's something to be said about how it makes you feel, too. Does it have that cool factor? Tell us about your favorite terminal emulator by taking our poll or leaving us a comment. How many have you tried? + +We asked our community to tell us about their experience with terminal emulators. Here are a few of the responses we received. + +"My favorite terminal emulator is Tilix, customized with Powerline. I love that it supports multiple terminals open in a single window." —Dan Arel + +"urxvt ([rxvt-unicode][2]). It's simple to configure via files, is lightweight, and readily available in most package manager repositories." —Brian Tomlinson + +"gnome-terminal is still my go-to even though I don't use GNOME anymore. :)" —Justin W. Flory + +"Terminator at this point on FC31.  I just started using it but like the split screen feature and it seems light enough for me. Investigating plugins." —Marc Maxwell + +"I switched over to Tilix a while back and it does everything I need terminals to do. :) Multiple panes, notifications, lean and runs my tmux sessions great." —Kevin Fenzi + +"alacritty. It's optimized for speed, implemented in Rust and generally feature packed, but, honestly speaking, I only care about one feature: configurable inter-glyph spacing that allows me to further condense my font. I'm so-o hooked." —Alexander Sosedkin +  + +"I am old and grumpy: KDE Konsole. With tmux in it if session is remote." —Marcin Juszkiewicz + +"iTerm2 for macOS. Yes, it's open source. :-) Terminator on Linux." —Patrick Mullins + + "I've been using alacritty for a year or two now, but recently I started also using cool-retro-term in fullscreen mode whenever I have to run a script that has a lot of output because it looks cool and makes me feel cool. This is important to me." —Nick Childers +  +"I love Tilix, partly because it's good at staying out of the way (I usually just run it full screen with tmux inside), but also for the custom hotlinking support: in my terminal, text like "rhbz#1234" is a hotlink that takes me to bugzilla. Similar for LaunchPad issues, Gerrit change ids for OpenStack, etc." —Lars Kellogg-Stedman +  +"Eterm, also presentations look best in cool-retro-term with Vintage profile." —Ivan Horvath +  +"+1 for Tilix. It’s the best for an option for GNOME users, IMO!"  —Eric Rich +  +"urxvt. Fast. Small. Configurable. Extendable via perl plugins, which can make it mouseless." —Roman Dobosz  +  +"Konsole is the best, the only app I use from KDE project. The highlight of all search result occurrences is a killer feature which afaik does not have any other Linux terminal (glad if you prove me wrong). Best for searching compilation errors and output logs." —Jan Horak +  +"I use Terminator in past a lot. Now I cloned the theme (dark one) in Tilix and I didn't miss a thing. Is easy to move between tabs. That's all." —Alberto Fanjul Alonso +  +"Started my journey in using Terminator, I have since (in the past 3 years or so) completely switched over to Tilix." —Mike Harris +  +"I use Drop Down Terminal X. It's a very simple extension for GNOME 3 that lets me have a terminal always at the stroke of a single key (F12 for me). And it also supports tabs, which is kind of all I need." —Germán Pulido +  +"xfce4-terminal: wayland support, zoom, no borders, no title bar, no scroll bar - that's all I want from terminal emulator, for everything else I have tmux. I want my terminal emulator to use as much screen space as possible as I usually have editor (Vim) and repl side by side in tmux panes." —Martin Kourim + +"Fish! Don’t ask! ;-)" —Eric Schabell + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/favorite-terminal-emulator + +作者:[Opensource.com][a] +选题:[lujun9972][b] +译者:[译者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/admin +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_terminals_0.png?itok=XwIRERsn (Terminal window with green text) +[2]: https://opensource.com/article/19/10/why-use-rxvt-terminal diff --git a/sources/tech/20191208 Why choose Xfce for your lightweight Linux desktop.md b/sources/tech/20191208 Why choose Xfce for your lightweight Linux desktop.md new file mode 100644 index 0000000000..cde1d600d7 --- /dev/null +++ b/sources/tech/20191208 Why choose Xfce for your lightweight Linux desktop.md @@ -0,0 +1,63 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Why choose Xfce for your lightweight Linux desktop) +[#]: via: (https://opensource.com/article/19/12/xfce-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Why choose Xfce for your lightweight Linux desktop +====== +This article is part of a special series of 24 days of Linux desktops. +Looking for for a lightweight Linux distribution with plenty of +features? The Xfce Linux desktop has been the standard for a long time. +![Woman sitting in front of her laptop][1] + +The [Xfce desktop][2] has a specific, self-stated goal: to be fast on a system with low resources while being visually appealing and user-friendly. It's been the de facto choice for lightweight Linux distributions (or remixes) for years and is often cited by its fans as a desktop that provides just enough to be useful, but never so much as to be a burden. + +You may find Xfce included in the software repository of your Linux distribution, or you can download and install a distribution that ships Xfce as an available desktop (like the Xfce [Mageia][3] or [Fedora][4] spins or [Slackware][5]). Before you install it, be aware that, while it's lightweight, it is intended to provide a full desktop experience, so many Xfce apps are installed along with the desktop. If you're already running a different desktop, you may find yourself with redundant applications (two PDF readers, two file managers, and so on). If you just want to try the Xfce desktop, you can install an Xfce-based distribution in a virtual machine, such as [GNOME Boxes][6]. + +### Xfce desktop tour + +True to the Unix philosophy, Xfce keeps its desktop modular. Many different components, such as the xfwm4 window manager, xfce4-panel, xfdesktop, Thunar, Xfconf, and so on, are bundled together to form the Xfce desktop environment. That may seem a pedantic way of defining a bunch of components that are always bundled together as a desktop, but in the case of Xfce, it's significant because these components truly are separate. You can run the Xfce panel over your Openbox or PekWM window manager, or use Xfce applets in your Fluxbox toolbar, and run Thunar as your file manager in Cinnamon or Pantheon. The possibilities are endless, but together they form the Xfce desktop. + +The design of the Xfce desktop is clean, direct, and true to its Unix origins. Xfce began as some desktop widgets written with the XForms framework, even before GNOME existed. It was based conceptually upon the CDE desktop, which was the ubiquitous desktop at the time. Neither CDE nor XForms were open source, but Xfce was distributed freely. Eventually, Xfce was rewritten using the open source GTK toolkit, was included in several distributions, became a popular CDE and GNOME alternative, and eventually became the dominant choice of "lightweight" distributions. + +Here's what it looked like on [Alan Formy-Duval's][7] desktop back in 2003: + +![XFCE in 2003][8] + +Xfce isn't necessarily a simple desktop: its application menu is in the upper-left corner (a tradition familiar to Linux users but probably foreign to newcomers), and it has a place for pinned application launchers, a system tray, virtual desktops, and a taskbar. It's a proper control panel for the GUI side of a Linux computer, with all the essential knobs and switches exposed for easy access. And it does all of that without making much of an impact on your system resources. + +![XFCE in 2019 on Mageia Linux][9] + +Significantly, Xfce uses GTK libraries to accomplish a lightweight desktop, and in doing so, it looks good, it looks familiar, and it can be themed to look really beautiful. The [Xfce screenshot forum][10] affords users the opportunity to show off their themes and configurations. + +### Using the Xfce desktop + +Xfce is an ideal desktop for a server or when you want quick access to important settings on a desktop that you rarely _look_ at. It's also ideal for Linux power users who want to adjust common settings quickly, but otherwise rarely deals with the GUI. Then again, it's a good-looking lightweight desktop, it can be themed easily, and it's got plenty of features. It may be the perfect desktop for you, no matter how you use your Linux computer. The only way to find out is to try! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/xfce-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者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/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_women_computing_4.png?itok=VGZO8CxT (Woman sitting in front of her laptop) +[2]: http://xfce.org +[3]: http://mageia.org +[4]: http://fedoraproject.org +[5]: http://slackware.com +[6]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization +[7]: https://opensource.com/users/alanfdoss +[8]: https://opensource.com/sites/default/files/advent-xfce-2003.jpg (XFCE in 2003) +[9]: https://opensource.com/sites/default/files/advent-xfce.jpg (XFCE on Mageia Linux in 2019) +[10]: https://forum.xfce.org/viewtopic.php?id=12676 diff --git a/sources/tech/20191209 Use the Fluxbox Linux desktop as your window manager.md b/sources/tech/20191209 Use the Fluxbox Linux desktop as your window manager.md new file mode 100644 index 0000000000..8c7ddcb1e5 --- /dev/null +++ b/sources/tech/20191209 Use the Fluxbox Linux desktop as your window manager.md @@ -0,0 +1,164 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Use the Fluxbox Linux desktop as your window manager) +[#]: via: (https://opensource.com/article/19/12/fluxbox-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Use the Fluxbox Linux desktop as your window manager +====== +This article is part of a special series of 24 days of Linux desktops. +Fluxbox is very light on system resources, yet it has vital Linux +desktop features to make your user experience easy, blazingly efficient, +and unduly fast. +![Text editor on a browser, in blue][1] + +The concept of a desktop may differ from one computer user to another. Many people see the desktop as a home base, or a comfy living room, or even a literal desktop where they place frequently used notepads, their best pens and pencils, and their favorite coffee mug. KDE, GNOME, Pantheon (and so on) provide that kind of comfort on Linux. + +But for some users, the desktop is just empty monitor space, a side effect of not yet having any free-floating application windows projected directly onto their retina. For these users, the desktop is a void over which they can run applications—whether big office and graphic suites, or a simple terminal window, or docked applets—to manage services. This model of operating a [POSIX][2] computer has a long history, and one branch of that family tree is the *box window managers: Blackbox, Fluxbox, and Openbox. + +[Fluxbox][3] is a window manager for X11 systems that's based on an older project called Blackbox. Blackbox development was waning when I discovered Linux, so I fell into Fluxbox, and I've used it ever since on at least one of my active systems. It is written in C++ and is licensed under the MIT open source license. + +### Installing Fluxbox + +You are likely to find Fluxbox included in the software repository of your Linux distribution, but you can also find it on [Fluxbox.org][4]. If you're already running a different desktop, it's safe to install Fluxbox on the same system because Fluxbox doesn't predetermine any configuration or accompanying applications. + +After installing Fluxbox, log out of your current desktop session so you can log into your new one. By default, your session manager (KDM, GDM, LightDM, or XDM, depending on your setup) will continue to log you into your previous desktop, so you must override that before logging in. + +To override the desktop with GDM: + +![Select your desktop session in GDM][5] + +Or with KDM: + +![Select your desktop session with KDM][6] + +### Configuring the Fluxbox desktop + +When you first log in, the screen is mostly empty because all Fluxbox provides are panels (for a taskbar, system tray, and so on) and window decoration for application windows. + +![Default Fluxbox configuration on CentOS 7][7] + +If your distribution delivers a plain Fluxbox desktop, you can set a background for your desktop using the **feh** command (you may need to install it from your distribution's repository). This command has a few options for setting the background, including **\--bg-fill** to fill the screen with your wallpaper of choice, **\--bg-scale** to scale it to fit, and so on. + + +``` +`$ feh --bg-fill ~/photo/oamaru/leaf-spiral.jpg` +``` + +![Fluxbox with a theme applied][8] + +By default, Fluxbox auto-generates a menu, available with a right-click anywhere on the desktop, that gives you access to applications. Depending on your distribution, this menu may be very minimal, or it may list all the launchers in your **/usr/share/applications** directory. + +Fluxbox configuration is set in text files, and those text files are contained in the **$HOME/.fluxbox** directory. You can: + + * Set keyboard shortcuts in **keys** + * Set startup services and applications in **startup** + * Set desktop preferences (such as the number of workspaces, locations of panels, and so on) in **init** + * Set menu items in **menu** + + + +The text configuration files are easy to reverse-engineer, but you also can (and should) read the Fluxbox [documentation][9]. + +For example, this is my typical menu (or at least the basic structure of it): + + +``` +# to use your own menu, copy this to ~/.fluxbox/menu, then edit +# ~/.fluxbox/init and change the session.menuFile path to ~/.fluxbox/menu + +[begin] (fluxkbox) + [submenu] (apps) {} +  [submenu] (txt) {} +   [exec] (Emacs 23 (text\\)) { x-terminal-emulator -T "Emacs (text)" -e /usr/bin/emacs -nw} <> +   [exec] (Emacs (X11\\)) {/usr/bin/emacs} <> +   [exec] (LibreOffice) {/usr/bin/libreoffice} +  [end] +  [submenu] (code) {} +   [exec] (qtCreator) {/usr/bin/qtcreator} +   [exec] (eclipse) {/usr/bin/eclipse} +  [end] +  [submenu] (graphics) {} +   [exec] (ksnapshot) {/usr/bin/ksnapshot} +   [exec] (gimp) {/usr/bin/gimp} +   [exec] (blender) {/usr/bin/blender} +  [end] +  [submenu] (files) {} +   [exec] (dolphin) {/usr/bin/dolphin} +   [exec] (konqueror) { /usr/bin/kfmclient openURL $HOME } +  [end] +  [submenu] (network) {} +   [exec] (firefox) {/usr/bin/firefox} +   [exec] (konqueror) {/usr/bin/konqueror} +  [end] + [end] +## change window manager or work env +[submenu] (environments) {} + [restart] (flux)  {/usr/bin/startfluxbox} + [restart] (ratpoison)  {/usr/bin/ratpoison} + [exec] (openIndiana) {/home/kenlon/qemu/startSolaris.sh} +[end] + +[config] (config) + [submenu] (styles) {} +  [stylesdir] (/usr/share/fluxbox/styles) +  [stylesdir] (~/.fluxbox/styles) + [end] +[workspaces] (workspaces) +[reconfig] (reconfigure) +[restart] (restart) +[exit] (exeunt) +[end] +``` + +The menu also provides a few preference settings, such as the ability to pick a theme and restart or log out from your Fluxbox session. + +I launch most applications using keyboard shortcuts, which are entered into the **keys** configuration file. Here are some examples (the **Mod4** key is the Super key, which I use to designate global shortcuts): + + +``` +# open apps +Mod4 t :Exec konsole +Mod4 k :Exec konqueror +Mod4 z :Exec fbrun +Mod4 e :Exec emacs +Mod4 f :Exec firefox +Mod4 x :Exec urxvt +Mod4 d :Exec dolphin +Mod4 q :Exec xscreensaver-command -activate +Mod4 3 :Exec ksnapshot +``` + +Between these shortcuts and an open terminal, I have little use for a mouse during most of my workday, so there's no wasted time switching from one controller to another. And because Fluxbox stays well out of the way, there's little distraction. + +### Why you should use Fluxbox + +Fluxbox is very light on system resources, yet it has vital features to make your user experience easy, blazingly efficient, and unduly fast. It's simple to customize, and it allows you to define your own workflow. You don't have to use Fluxbox's panels, because there are other excellent panels out there. You can even middle-click and drag two separate application windows into one another so that they become one window, each in its own tab. + +The possibilities are endless, so try the steady simplicity that is Fluxbox on your Linux box today! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/fluxbox-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者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/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_blue_text_editor_web.png?itok=lcf-m6N7 (Text editor on a browser, in blue) +[2]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains +[3]: http://fluxbox.org +[4]: http://fluxbox.org/download/ +[5]: https://opensource.com/sites/default/files/advent-gdm_0.jpg (Select your desktop session in GDM) +[6]: https://opensource.com/sites/default/files/advent-kdm.jpg (Select your desktop session with KDM) +[7]: https://opensource.com/sites/default/files/advent-fluxbox-default.jpg (Default Fluxbox configuration on CentOS 7) +[8]: https://opensource.com/sites/default/files/advent-fluxbox-green.jpg (Fluxbox with a theme applied) +[9]: http://fluxbox.org/features/ diff --git a/sources/tech/20191210 App Highlight- Open Source Video Transcoder Handbrake.md b/sources/tech/20191210 App Highlight- Open Source Video Transcoder Handbrake.md new file mode 100644 index 0000000000..d6e239c3eb --- /dev/null +++ b/sources/tech/20191210 App Highlight- Open Source Video Transcoder Handbrake.md @@ -0,0 +1,151 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (App Highlight: Open Source Video Transcoder Handbrake) +[#]: via: (https://itsfoss.com/handbrake/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +App Highlight: Open Source Video Transcoder Handbrake +====== + +_**Brief: HandBrake is a free and open-source video conversion tool that is quite useful. Let’s see what are its main features and how to use them for converting videos from one format to another.**_ + +### HandBrake: An Open Source Video Transcoder + +![][1] + +[HandBrake][2] is a quite useful tool which helps you to convert a video from one format to some of the widely supported codecs (**.mp4/.m4v/.mkv/.webm**) + +It can support any video format and help you convert it. In addition to that, you have several features on board to customize the video attributes while converting. + +If you are looking for a [Format Factory alternative][3], this is your best bet. + +I shall highlight the key features to help you know more. + +![HandBrake][4] + +### Features of HandBrake + +When you start using the video transcoder, you will find a lot of tiny features for video conversion. However, here, I’ll highlight the important things you need to know about HandBrake: + +#### Video Conversion Presets + +![HandBrake Presets][5] + +Suppose you want to convert a full HD video to play on a mobile which was originally tailored for desktop viewing, what do you do? + +Would you test various dimensions and convert them repeatedly to get the perfect mobile port? Or, would you rather prefer to have pre-defined settings for such conversions? + +If you opt for a preset, you just have to select the target device (or type of device) from the list of available presets. + +It even features presets for PS4 Pro (4K) and Discord. So, you can expect a big list of presets available. + +#### Input Sources Support + +Unless the file has some sort of copy protection, HandBrake can help you convert it. You will have no problems whatsoever even if you have an Ultra HD Blu-ray disc as the source with no copyright protection. + +All the available video encoding formats should work fine as an input source file. + +#### Basic Video Manipulation + +![HandBrake Screenshot][6] + +In addition to the ability of video conversion, it also lets you tweak the video to suit your requirements. + +You can change the dimensions, crop it, add a filter, change the frame rate settings, and a lot more things. + +If that wasn’t enough, you also get the ability to add subtitles and chapter markers. + +#### Live Video Preview + +This may not be a big deal to have – but I haven’t seen any video converter tool featuring video previews while being able to convert/tweak the video. It could come in handy for someone specific. + +### Installing HandBrake on Ubuntu and other Linux distributions + +HandBrake is a cross-platform application and you can install it on all different platforms like Linux, macOS and Windows. Just head over to heir website and download it from there. + +[Download HandBrake for any platform][7] + +On It’s FOSS, our focus is on Linux so I am going to show the steps to install it on Linux. + +**Installing HandBrake on Ubuntu** + +HandBrake is available in the [universe repository in Ubuntu][8]. If you have it enabled, you should find it in the software center. Just search for the name and install it from there. + +![HandBrake in Ubuntu Software Center][9] + +You can also use terminal for installing HandBrake with apt or [apt-get command][10]: + +``` +sudo apt-get install handbrake +``` + +However, the software center might feature the older version. If you want to install the latest version of HandBrake on Ubuntu and other Ubuntu-based distributions, you can [use its official PPA][11]. It’s better to uninstall any existing version of HandBrake beforehand. + +``` +sudo apt remove handbrake +sudo add-apt-repository ppa:stebbins/handbrake-releases +sudo apt update +sudo apt install handbrake-gtk +``` + +You can [learn more about using PPA here][12]. It will help you to [remove PPA][13], if you ever need to uninstall HandBrake installed via the PPA. + +If you want to install the CLI version of Handbrake, simply use this command: + +``` +sudo apt install handbrake-cli +``` + +Quite honestly, HandBrake should be used as a GUI application. If you want command line, you can always [use ffmpeg][14] that is more powerful and HandBrake uses it underneath anyways. + +**Installing HandBrake on other Linux distributions** + +HandBrake is one of the [popular Linux software][15] and it should be available in the official repositories of almost all Linux distributions. + +Just use the software center or package manager of your distribution to install HandBrake. + +But again, your distribution might not have the latest version of HandBrale. So, if you want the latest version installed, you can try installing the [Flatpak package][16] available. If you are not sure how to use Flatpak, refer to our guide on [using Flatpak on Linux][17]. + +[HandBrake][2] + +**Wrapping Up** + +A free and open-source video conversion tool that gets the job done. I’m quite satisfied with it personally. + +If you use HandBrake extensively, mention at least one feature that you like the most about it. + +If you use some other application for converting video formats, do share it with us in the comments. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/handbrake/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/12/handbrake_software_logo.png?ssl=1 +[2]: https://handbrake.fr/ +[3]: https://itsfoss.com/format-factory-alternative-linux/ +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/handbrake.png?ssl=1 +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/handbrake-presets.png?ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/handbrake-screenshot.png?ssl=1 +[7]: https://handbrake.fr/downloads.php +[8]: https://itsfoss.com/ubuntu-repositories/ +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/11/handbrake_ubuntu_software_center.png?ssl=1 +[10]: https://itsfoss.com/apt-get-linux-guide/ +[11]: https://launchpad.net/~stebbins/+archive/ubuntu/handbrake-releases +[12]: https://itsfoss.com/ppa-guide/ +[13]: https://itsfoss.com/how-to-remove-or-delete-ppas-quick-tip/ +[14]: https://itsfoss.com/ffmpeg/ +[15]: https://itsfoss.com/essential-linux-applications/ +[16]: https://flathub.org/apps/details/fr.handbrake.ghb +[17]: https://itsfoss.com/flatpak-guide/ diff --git a/sources/tech/20191210 Customize your Linux desktop with FVWM.md b/sources/tech/20191210 Customize your Linux desktop with FVWM.md new file mode 100644 index 0000000000..f238fdc121 --- /dev/null +++ b/sources/tech/20191210 Customize your Linux desktop with FVWM.md @@ -0,0 +1,78 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Customize your Linux desktop with FVWM) +[#]: via: (https://opensource.com/article/19/12/fvwm-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Customize your Linux desktop with FVWM +====== +This article is part of a special series of 24 days of Linux desktops. +If you're looking for a lightweight, fast, and simple Linux window +manager, FVWM qualifies. But if you're looking for something to dig +into, explore, and hack, then FVWM is a must. +![Coding on a computer][1] + +The [FVWM][2] window manager started out as modifications to [TWM][3], back in 1993. After several years of iteration, what emerged is an extremely customizable environment where any behavior, action, or event is configurable. It has support for custom key bindings, mouse gestures, theming, scripting, and much more. + +While FVWM is usable immediately after installation, its default distribution provides only the absolute minimum configuration. It's a great foundation to start your own custom desktop environment, but if you just want to use it as a desktop, then you probably want to install a full configuration distributed by another user. There are a few different distributions of FVWM, including FVWM95, which mimics Windows 95 (at least in appearance and layout). I tried [FVWM-Crystal][4], a modern-looking theme with some common Linux desktop conventions. + +Install the FVWM distribution you want to try from your Linux distribution's software repository. If you can't find a specific FVWM distribution, it's safe to install the base FVWM2 package and then go to [Box-Look.org][5] to download a theme package manually. It's a little more work that way, but not nearly as much as building your own workspace from scratch. + +After installing, log out of your current desktop session so you can log into FVWM. By default, your session manager (KDM, GDM, LightDM, or XDM, depending on your setup) will continue to log you into your previous desktop, so you must override that before logging in. + +To do so with GDM: + +![Select your desktop session in GDM][6] + +And with KDM: + +![Select your desktop session with KDM][7] + +### FVWM desktop + +Regardless of what theme and configuration you're using, FVWM, at minimum, provides a menu when you left-click on the desktop. The contents of this menu vary depending on what you've installed. The menu in the FVWM-Crystal distribution contains quick access to common preferences, such as screen resolution, wallpaper settings, window decorations, and so on. + +As with pretty much everything in FVWM, the menu can be edited to include whatever you want, but FVWM-Crystal favors the application menu bar. The application menu is located at the top-left of the screen, and each icon contains a menu of related application launchers. For example, the GIMP icon reveals image editors, the KDevelop icon reveals integrated development environments (IDEs), the GNU icon reveals text editors, and so on, depending on what you have installed on your system. + +![FVWM-crystal running on Slackware 14.2][8] + +FVWM-Crystal also provides virtual desktops, a taskbar, a clock, and an application bar. + +For your background, you can use the wallpapers bundled with FVWM-Crystal or set your own with the **feh** command (you may need to install it from your repository). This command has a few options for setting the background, including **\--bg-scale** to fill the screen with a scaled version of your wallpaper of choice, **\--bg-fill** to fill the screen without adjusting the size of the image, and so on. + + +``` +`$ feh --bg-scale ~/Pictures/wallpapers/mybackground.jpg` +``` + +Most configuration files are contained in **$HOME/.fvwm-crystal**, with some systemwide defaults located in **/usr/share/fvwm-crystal**. + +### Do it yourself + +FVWM is as much a desktop-building platform as it is a window manager. It doesn't do anything for you, and it expects you to configure anything—and possibly everything. +If you're looking for a lightweight, fast, and simple window manager, FVWM qualifies. But if you're looking for something to dig into, explore, and hack, then FVWM is a must. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/fvwm-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者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/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: http://www.fvwm.org/ +[3]: https://en.wikipedia.org/wiki/Twm +[4]: https://www.box-look.org/p/1018270/ +[5]: http://box-look.org +[6]: https://opensource.com/sites/default/files/advent-gdm_0.jpg (Select your desktop session in GDM) +[7]: https://opensource.com/sites/default/files/advent-kdm.jpg (Select your desktop session with KDM) +[8]: https://opensource.com/sites/default/files/advent-fvwm-crystal.jpg (FVWM-crystal running on Slackware 14.2) diff --git a/sources/tech/20191210 Lessons learned from programming in Go.md b/sources/tech/20191210 Lessons learned from programming in Go.md new file mode 100644 index 0000000000..1702d36c47 --- /dev/null +++ b/sources/tech/20191210 Lessons learned from programming in Go.md @@ -0,0 +1,334 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Lessons learned from programming in Go) +[#]: via: (https://opensource.com/article/19/12/go-common-pitfalls) +[#]: author: (Eduardo Ferreira https://opensource.com/users/edufgf) + +Lessons learned from programming in Go +====== +Prevent future concurrent processing headaches by learning how to +address these common pitfalls. +![Goland gopher illustration][1] + +When you are working with complex distributed systems, you will likely come across the need for concurrent processing. At [Mode.net][2], we deal daily with real-time, fast and resilient software. Building a global private network that dynamically routes packets at the millisecond scale wouldn’t be possible without a highly concurrent system. This dynamic routing is based on the state of the network and, while there are many parameters to consider here, our focus is on link [metrics][3]. In our context, link metrics can be anything related to the status or current properties of a network link (e.g.: link latency). + +### Concurrent probing for link metrics + +[H.A.L.O.][4] (Hop-by-Hop Adaptive Link-State Optimal Routing), our dynamic routing algorithm relies partially on link metrics to compute its routing table. Those metrics are collected by an independent component that sits on each [PoP][5] (Point of Presence). PoPs are machines that represent a single routing entity in our networks, connected by links and spread around multiple locations shaping our network. This component probes neighboring machines using network packets, and those neighbors will bounce back the initial probe. Link latency values can be derived from the received probes. Because each PoP has more than one neighbor, the nature of such a task is intrinsically concurrent: we need to measure latency for each neighboring link in real-time. We can’t afford sequential processing; each probe must be processed as soon as possible in order to compute this metric. + +![latency computation graph][6] + +### Sequence numbers and resets: A reordering situation + +Our probing component exchanges packets and relies on sequence numbers for packet processing. This aims to avoid processing of packet duplication or out-of-order packets. Our first implementation relied on a special sequence number 0 to reset sequence numbers. Such a number was only used during initialization of a component. The main problem was that we were considering an increasing sequence number value that always started at 0. After the component restarts, packet reordering could happen, and a packet could easily replace the sequence number with the value that was being used before the reset. This meant that the following packets would be ignored until it reaches the sequence number that was in use just before the reset. + +### UDP handshake and finite state machine + +The problem here was proper agreement of a sequence number after a component restarts. There are a few ways to handle this and, after discussing our options, we chose to implement a 3-way handshake protocol with a clear definition of states. This handshake establishes sessions over links during initialization. This guarantees that nodes are communicating over the same session and using the appropriate sequence number for it. + +To properly implement this, we have to define a finite state machine with clear states and transitions. This allows us to properly manage all corner cases for the handshake formation. + +![finite state machine diagram][7] + +Session IDs are generated by the handshake initiator. A full exchange sequence is as follows: + + 1. The sender sends out a **SYN (ID)*** *packet. + 2. The receiver stores the received **ID** and sends a **SYN-ACK (ID)**. + 3. The sender receives the **SYN-ACK (ID) *_and sends out an **ACK (ID)**._ *It also starts sending packets starting with sequence number 0. + 4. The receiver checks the last received **ID*** _and accepts the **ACK (ID)**_ *if the ID matches. It also starts accepting packets with sequence number 0. + + + +### Handling state timeouts + +Basically, at each state, you need to handle, at most, three types of events: link events, packet events, and timeout events. And those events show up concurrently, so here you have to handle concurrency properly. + + * Link events are either link up or link down updates. This can either initiate a link session or break an existing session. + * Packet events are control packets **(SYN/SYN-ACK/ACK)** or just probe responses. + * Timeout events are the ones triggered after a scheduled timeout expires for the current session state. + + + +The main challenge here is how to handle concurrent timeout expiration and other events. And this is where one can easily fall into the traps of deadlocks and race conditions. + +### A first approach + +The language used for this project is [Golang][8]. It does provide native synchronization mechanisms such as native channels and locks and is able to spin lightweight threads for concurrent processing. + +![gophers hacking together][9] + +gophers hacking together + +You can start first by designing a structure that represents our **Session** and **Timeout Handlers**. + + +``` +type Session struct {   +  State SessionState   +  Id SessionId   +  RemoteIp string   +} + +type TimeoutHandler struct {   +  callback func(Session)   +  session Session   +  duration int   +  timer *timer.Timer   +} +``` + +**Session** identifies the connection session, with the session ID, neighboring link IP, and the current session state. + +**TimeoutHandler** holds the callback function, the session for which it should run, the duration, and a pointer to the scheduled timer. + +There is a global map that will store, per neighboring link session, the scheduled timeout handler. + + +``` +`SessionTimeout map[Session]*TimeoutHandler` +``` + +Registering and canceling a timeout is achieved by the following methods: + + +``` +// schedules the timeout callback function.   +func (timeout* TimeoutHandler) Register() {   +  timeout.timer = time.AfterFunc(time.Duration(timeout.duration) * time.Second, func() {   +    timeout.callback(timeout.session)   +  })   +} + +func (timeout* TimeoutHandler) Cancel() {   +  if timeout.timer == nil {   +    return   +  }   +  timeout.timer.Stop()   +} +``` + +For the timeouts creation and storage, you can use a method like the following: + + +``` +func CreateTimeoutHandler(callback func(Session), session Session, duration int) *TimeoutHandler {   +  if sessionTimeout[session] == nil {   +    sessionTimeout[session] := new(TimeoutHandler)   +  }   +    +  timeout = sessionTimeout[session]   +  timeout.session = session   +  timeout.callback = callback   +  timeout.duration = duration   +  return timeout   +} +``` + +Once the timeout handler is created and registered, it runs the callback after _duration_ seconds have elapsed. However, some events will require you to reschedule a timeout handler (as it happens at **SYN** state — every 3 seconds). + +For that, you can have the callback rescheduling a new timeout: + + +``` +func synCallback(session Session) {   +  sendSynPacket(session) + +  // reschedules the same callback.   +  newTimeout := NewTimeoutHandler(synCallback, session, SYN_TIMEOUT_DURATION)   +  newTimeout.Register() + +  sessionTimeout[state] = newTimeout   +} +``` + +This callback reschedules itself in a new timeout handler and updates the global **sessionTimeout** map. + +### **Data race and references** + +Your solution is ready. One simple test is to check that a timeout callback is executed after the timer has expired. To do this, register a timeout, sleep for its duration, and then check whether the callback actions were done. After the test is executed, it is a good idea to cancel the scheduled timeout (as it reschedules), so it won’t have side effects between tests. + +Surprisingly, this simple test found a bug in the solution. Canceling timeouts using the cancel method was just not doing its job. The following order of events would cause a data race condition: + + 1. You have one scheduled timeout handler. + 2. Thread 1: +a) You receive a control packet, and you now want to cancel the registered timeout and move on to the next session state. (e.g. received a **SYN-ACK** **after you sent a **SYN**). +b) You call **timeout.Cancel()**, which calls a **timer.Stop()**. (Note that a Golang timer stop doesn’t prevent an already expired timer from running.) + 3. Thread 2: +a) Right before that cancel call, the timer has expired, and the callback was about to execute. +b) The callback is executed, it schedules a new timeout and updates the global map. + 4. Thread 1: +a) Transitions to a new session state and registers a new timeout, updating the global map. + + + +Both threads were updating the timeout map concurrently. The end result is that you failed to cancel the registered timeout, and then you also lost the reference to the rescheduled timeout done by thread 2. This results in a handler that keeps executing and rescheduling for a while, doing unwanted behavior. + +### When locking is not enough + +Using locks also doesn’t fix the issue completely. If you add locks before processing any event and before executing a callback, it still doesn’t prevent an expired callback to run: + + +``` +func (timeout* TimeoutHandler) Register() {   +  timeout.timer = time.AfterFunc(time.Duration(timeout.duration) * time._Second_, func() {   +    stateLock.Lock()   +    defer stateLock.Unlock() + +    timeout.callback(timeout.session)   +  })   +} +``` + +The difference now is that the updates in the global map are synchronized, but this doesn’t prevent the callback from running after you call the **timeout.Cancel() **— This is the case if the scheduled timer expired but didn’t grab the lock yet. You should again lose reference to one of the registered timeouts. + +### Using cancellation channels + +Instead of relying on golang’s **timer.Stop()**, which doesn’t prevent an expired timer to execute, you can use cancellation channels. + +It is a slightly different approach. Now you won’t do a recursive re-scheduling through callbacks; instead, you register an infinite loop that waits for cancellation signals or timeout events. + +The new **Register()** spawns a new go thread that runs your callback after a timeout and schedules a new timeout after the previous one has been executed. A cancellation channel is returned to the caller to control when the loop should stop. + + +``` +func (timeout *TimeoutHandler) Register() chan struct{} {   +  cancelChan := make(chan struct{})   +    +  go func () {   +    select {   +    case _ = <\- cancelChan:   +      return   +    case _ = <\- time.AfterFunc(time.Duration(timeout.duration) * time.Second):   +      func () {   +        stateLock.Lock()   +        defer stateLock.Unlock() + +        timeout.callback(timeout.session)   +      } ()   +    }   +  } () + +  return cancelChan   +} + +func (timeout* TimeoutHandler) Cancel() {   +  if timeout.cancelChan == nil {   +    return   +  }   +  timeout.cancelChan <\- struct{}{}   +} +``` + +This approach gives you a cancellation channel for each timeout you register. A cancel call sends an empty struct to the channel and triggers the cancellation. However, this doesn’t resolve the previous issue; the timeout can expire right before you call cancel over the channel, and before the lock is grabbed by the timeout thread. + +The solution here is to check the cancellation channel inside the timeout scope after you grab the lock. + + +``` +  case _ = <\- time.AfterFunc(time.Duration(timeout.duration) * time.Second):   +    func () {   +      stateLock.Lock()   +      defer stateLock.Unlock()   +      +      select {   +      case _ = <\- handler.cancelChan:   +        return   +      default:   +        timeout.callback(timeout.session)   +      }   +    } ()   +  } +``` + +Finally, this guarantees that the callback is only executed after you grab the lock and no cancellation was triggered. + +### Beware of deadlocks + +This solution seems to work; however, there is one hidden pitfall here: [deadlocks][10]. + +Please read the code above again and try to find it yourself. Think of concurrent calls to any of the methods described. + +The last problem here is with the cancellation channel itself. We made it an unbuffered channel, which means that sending is a blocking call. Once you call cancel in a timeout handler, you only proceed once that handler is canceled. The problem here is when you have multiple calls to the same cancelation channel, where a cancel request is only consumed once. And this can easily happen if concurrent events were to cancel the same timeout handler, like a link down or control packet event. This results in a deadlock situation, possibly bringing the application to a halt. + +![gophers on a wire, talking][11] + +Is anyone listening? + +By Trevor Forrey. Used with permission. + +The solution here is to at least make the channel buffered by one, so sends are not always blocking, and also explicitly make the send non-blocking in case of concurrent calls. This guarantees the cancellation is sent once and won’t block the subsequent cancel calls. + + +``` +func (timeout* TimeoutHandler) Cancel() {   +  if timeout.cancelChan == nil {   +    return   +  }   +    +  select {   +  case timeout.cancelChan <\- struct{}{}:   +  default:   +    // can’t send on the channel, someone has already requested the cancellation.   +  }   +} +``` + +### Conclusion + +You learned in practice how common mistakes can show up while working with concurrent code. Due to their non-deterministic nature, those issues can go easily undetected, even with extensive testing. Here are the three main problems we encountered in the initial implementation. + +#### Updating shared data without synchronization + +This seems like an obvious one, but it’s actually hard to spot if your concurrent updates happen in different locations. The result is data race, where multiple updates to the same data can cause update loss, due to one update overriding another. In our case, we were updating the scheduled timeout reference on the same shared map. (Interestingly, if Go detects a concurrent read/write on the same Map object, it throws a fatal error —you can try to run Go’s [data race detector][12]). This eventually results in losing a timeout reference and making it impossible to cancel that given timeout. Always remember to use locks when they are needed. + +![gopher assembly line][13] + +don’t forget to synchronize gophers’ work + +#### Missing condition checks + +Condition checks are needed in situations where you can’t rely only on the lock exclusivity. Our situation is a bit different, but the core idea is the same as [condition variables][14]. Imagine a classic situation where you have one producer and multiple consumers working with a shared queue. A producer can add one item to the queue and wake up all consumers. The wake-up call means that some data is available at the queue, and because the queue is shared, access must be synchronized through a lock. Every consumer has a chance to grab the lock; however, you still need to check if there are items in the queue. A condition check is needed because you don’t know the queue status by the time you grab the lock. + +In our example, the timeout handler got a ‘wake up’ call from a timer expiration, but it still needed to check if a cancel signal was sent to it before it could proceed with the callback execution. + +![gopher boot camp][15] + +condition checks might be needed if you wake up multiple gophers + +#### Deadlocks + +This happens when one thread is stuck, waiting indefinitely for a signal to wake up, but this signal will never arrive. Those can completely kill your application by halting your entire program execution. + +In our case, this happened due to multiple send calls to a non-buffered and blocking channel. This meant that the send call would only return after a receive is done on the same channel. Our timeout thread loop was promptly receiving signals on the cancellation channel; however, after the first signal is received, it would break off the loop and never read from that channel again. The remaining callers are stuck forever. To avoid this situation, you need to carefully think through your code, handle blocking calls with care, and guarantee that thread starvation doesn’t happen. The fix in our example was to make the cancellation calls non-blocking—we didn’t need a blocking call for our needs. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/go-common-pitfalls + +作者:[Eduardo Ferreira][a] +选题:[lujun9972][b] +译者:[译者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/edufgf +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/go-golang.png?itok=OAW9BXny (Goland gopher illustration) +[2]: http://mode.net +[3]: https://en.wikipedia.org/wiki/Metrics_%28networking%29 +[4]: https://people.ece.cornell.edu/atang/pub/15/HALO_ToN.pdf +[5]: https://en.wikipedia.org/wiki/Point_of_presence +[6]: https://opensource.com/sites/default/files/uploads/image2_0_3.png (latency computation graph) +[7]: https://opensource.com/sites/default/files/uploads/image3_0.png (finite state machine diagram) +[8]: https://golang.org/ +[9]: https://opensource.com/sites/default/files/uploads/image4.png (gophers hacking together) +[10]: https://en.wikipedia.org/wiki/Deadlock +[11]: https://opensource.com/sites/default/files/uploads/image5_0_0.jpg (gophers on a wire, talking) +[12]: https://golang.org/doc/articles/race_detector.html +[13]: https://opensource.com/sites/default/files/uploads/image6.jpeg (gopher assembly line) +[14]: https://en.wikipedia.org/wiki/Monitor_%28synchronization%29#Condition_variables +[15]: https://opensource.com/sites/default/files/uploads/image7.png (gopher boot camp) diff --git a/sources/tech/20191211 Enable your Python game player to run forward and backward.md b/sources/tech/20191211 Enable your Python game player to run forward and backward.md new file mode 100644 index 0000000000..fb9b020278 --- /dev/null +++ b/sources/tech/20191211 Enable your Python game player to run forward and backward.md @@ -0,0 +1,474 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Enable your Python game player to run forward and backward) +[#]: via: (https://opensource.com/article/19/12/python-platformer-game-run) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Enable your Python game player to run forward and backward +====== +Let your player run free by enabling the side-scroller effect in your +Python platformer using the Pygame module. +![Gaming artifacts with joystick, GameBoy, paddle][1] + +This is part 8 in an ongoing series about creating video games in Python 3 using the Pygame module. Previous articles are: + + * [Learn how to program in Python by building a simple dice game][2] + * [Build a game framework with Python using the Pygame module][3] + * [How to add a player to your Python game][4] + * [Using Pygame to move your game character around][5] + * [What's a hero without a villain? How to add one to your Python game][6] + * [Simulate gravity in your Python game][7] + * [Add jumping to your Python platformer game][8] + + + +In previous entries in this series about creating video games in [Python 3][9] using the [Pygame][10] module, you designed your level-design layout, but some portion of your level probably extended past your viewable screen. The ubiquitous solution to that problem in platformer games is, as the term "side-scroller" suggests, scrolling. + +The key to scrolling is to make the platforms around the player sprite move when the player sprite gets close to the edge of the screen. This provides the illusion that the screen is a "camera" panning across the game world. + +This scrolling trick requires two dead zones at either edge of the screen, at which point your avatar stands still while the world scrolls by. + +### Putting the scroll in side-scroller + +You need one trigger point to go forward and another if you want your player to be able to go backward. These two points are simply two variables. Set them each about 100 or 200 pixels from each screen edge. Create the variables in your **setup** section. In the following code, the first two lines are for context, so just add the last two lines: + + +``` +player_list.add(player) +steps = 10 +forwardX  = 600 +backwardX = 230 +``` + +In the main loop, check to see if your player sprite is at the **forwardx** or **backwardx** scroll point. If so, move all platforms either left or right, depending on whether the world is moving forward or backward. In the following code, the final three lines of code are only for your reference: + + +``` +        # scroll the world forward +        if player.rect.x >= forwardx: +                scroll = player.rect.x - forwardx +                player.rect.x = forwardx +                for p in plat_list: +                        p.rect.x -= scroll + +        # scroll the world backward +        if player.rect.x <= backwardx: +                scroll = backwardx - player.rect.x +                player.rect.x = backwardx +                for p in plat_list: +                        p.rect.x += scroll + +        ## scrolling code above +    world.blit(backdrop, backdropbox) +    player.gravity() # check gravity +    player.update() +``` + +Launch your game and try it out. + +![Scrolling the world in Pygame][11] + +Scrolling works as expected, but you may notice a small problem that happens when you scroll the world around your player and non-player sprites: the enemy sprite doesn't scroll along with the world. Unless you want + +your enemy sprite to pursue your player endlessly, you need to modify the enemy code so that when your player makes an expeditious retreat, the enemy is left behind. + +### Enemy scroll + +In your main loop, you must apply the same rules for scrolling platforms to your enemy's position. Because your game world will (presumably) have more than one enemy in it, the rules are applied to your enemy list rather than an individual enemy sprite. That's one of the advantages of grouping similar elements into lists. + +The first two lines are for context, so just add the final two to your main loop: + + +``` +    # scroll the world forward +    if player.rect.x >= forwardx: +        scroll = player.rect.x - forwardx +        player.rect.x = forwardx +        for p in plat_list: +            p.rect.x -= scroll +        for e in enemy_list: +            e.rect.x -= scroll +``` + +To scroll in the other direction: + + +``` +    # scroll the world backward +    if player.rect.x <= backwardx: +        scroll = backwardx - player.rect.x +        player.rect.x = backwardx +        for p in plat_list: +            p.rect.x += scroll +        for e in enemy_list: +            e.rect.x += scroll +``` + +Launch the game again and see what happens. + +Here's all the code you've written for this Python platformer so far: + + +``` +#!/usr/bin/env python3 +# draw a world +# add a player and player control +# add player movement +# add enemy and basic collision +# add platform +# add gravity +# add jumping +# add scrolling + +# GNU All-Permissive License +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved.  This file is offered as-is, +# without any warranty. + +import pygame +import sys +import os + +''' +Objects +''' + +class Platform(pygame.sprite.Sprite): +    # x location, y location, img width, img height, img file     +    def __init__(self,xloc,yloc,imgw,imgh,img): +        pygame.sprite.Sprite.__init__(self) +        self.image = pygame.image.load(os.path.join('images',img)).convert() +        self.image.convert_alpha() +        self.rect = self.image.get_rect() +        self.rect.y = yloc +        self.rect.x = xloc + +class Player(pygame.sprite.Sprite): +    ''' +    Spawn a player +    ''' +    def __init__(self): +        pygame.sprite.Sprite.__init__(self) +        self.movex = 0 +        self.movey = 0 +        self.frame = 0 +        self.health = 10 +        self.collide_delta = 0 +        self.jump_delta = 6 +        self.score = 1 +        self.images = [] +        for i in range(1,9): +            img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert() +            img.convert_alpha() +            img.set_colorkey(ALPHA) +            self.images.append(img) +            self.image = self.images[0] +            self.rect  = self.image.get_rect() + +    def jump(self,platform_list): +        self.jump_delta = 0 + +    def gravity(self): +        self.movey += 3.2 # how fast player falls +        +        if self.rect.y > worldy and self.movey >= 0: +            self.movey = 0 +            self.rect.y = worldy-ty +        +    def control(self,x,y): +        ''' +        control player movement +        ''' +        self.movex += x +        self.movey += y +        +    def update(self): +        ''' +        Update sprite position +        ''' +        +        self.rect.x = self.rect.x + self.movex +        self.rect.y = self.rect.y + self.movey + +        # moving left +        if self.movex < 0: +            self.frame += 1 +            if self.frame > ani*3: +                self.frame = 0 +            self.image = self.images[self.frame//ani] + +        # moving right +        if self.movex > 0: +            self.frame += 1 +            if self.frame > ani*3: +                self.frame = 0 +            self.image = self.images[(self.frame//ani)+4] + +        # collisions +        enemy_hit_list = pygame.sprite.spritecollide(self, enemy_list, False) +        for enemy in enemy_hit_list: +            self.health -= 1 +            #print(self.health) + +        plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) +        for p in plat_hit_list: +            self.collide_delta = 0 # stop jumping +            self.movey = 0 +            if self.rect.y > p.rect.y: +                self.rect.y = p.rect.y+ty +            else: +                self.rect.y = p.rect.y-ty +            +        ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) +        for g in ground_hit_list: +            self.movey = 0 +            self.rect.y = worldy-ty-ty +            self.collide_delta = 0 # stop jumping +            if self.rect.y > g.rect.y: +                self.health -=1 +                print(self.health) +                +        if self.collide_delta < 6 and self.jump_delta < 6: +            self.jump_delta = 6*2 +            self.movey -= 33  # how high to jump +            self.collide_delta += 6 +            self.jump_delta    += 6 +            +class Enemy(pygame.sprite.Sprite): +    ''' +    Spawn an enemy +    ''' +    def __init__(self,x,y,img): +        pygame.sprite.Sprite.__init__(self) +        self.image = pygame.image.load(os.path.join('images',img)) +        self.movey = 0 +        #self.image.convert_alpha() +        #self.image.set_colorkey(ALPHA) +        self.rect = self.image.get_rect() +        self.rect.x = x +        self.rect.y = y +        self.counter = 0 + +                +    def move(self): +        ''' +        enemy movement +        ''' +        distance = 80 +        speed = 8 + +        self.movey += 3.2 +        +        if self.counter >= 0 and self.counter <= distance: +            self.rect.x += speed +        elif self.counter >= distance and self.counter <= distance*2: +            self.rect.x -= speed +        else: +            self.counter = 0 +        +        self.counter += 1 + +        if not self.rect.y >= worldy-ty-ty: +            self.rect.y += self.movey + +        plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) +        for p in plat_hit_list: +            self.movey = 0 +            if self.rect.y > p.rect.y: +                self.rect.y = p.rect.y+ty +            else: +                self.rect.y = p.rect.y-ty + +        ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) +        for g in ground_hit_list: +            self.rect.y = worldy-ty-ty + +        +class Level(): +    def bad(lvl,eloc): +        if lvl == 1: +            enemy = Enemy(eloc[0],eloc[1],'yeti.png') # spawn enemy +            enemy_list = pygame.sprite.Group() # create enemy group +            enemy_list.add(enemy)              # add enemy to group +            +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return enemy_list + +    def loot(lvl,lloc): +        print(lvl) + +    def ground(lvl,gloc,tx,ty): +        ground_list = pygame.sprite.Group() +        i=0 +        if lvl == 1: +            while i < len(gloc): +                ground = Platform(gloc[i],worldy-ty,tx,ty,'ground.png') +                ground_list.add(ground) +                i=i+1 + +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return ground_list + +    def platform(lvl,tx,ty): +        plat_list = pygame.sprite.Group() +        ploc = [] +        i=0 +        if lvl == 1: +            ploc.append((0,worldy-ty-128,3)) +            ploc.append((300,worldy-ty-256,3)) +            ploc.append((500,worldy-ty-128,4)) + +            while i < len(ploc): +                j=0 +                while j <= ploc[i][2]: +                    plat = Platform((ploc[i][0]+(j*tx)),ploc[i][1],tx,ty,'ground.png') +                    plat_list.add(plat) +                    j=j+1 +                print('run' + str(i) + str(ploc[i])) +                i=i+1 + +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return plat_list + +''' +Setup +''' +worldx = 960 +worldy = 720 + +fps = 40 # frame rate +ani = 4  # animation cycles +clock = pygame.time.Clock() +pygame.init() +main = True + +BLUE  = (25,25,200) +BLACK = (23,23,23 ) +WHITE = (254,254,254) +ALPHA = (0,255,0) + +world = pygame.display.set_mode([worldx,worldy]) +backdrop = pygame.image.load(os.path.join('images','stage.png')).convert() +backdropbox = world.get_rect() +player = Player() # spawn player +player.rect.x = 0 +player.rect.y = 0 +player_list = pygame.sprite.Group() +player_list.add(player) +steps = 10 +forwardx = 600 +backwardx = 230 + +eloc = [] +eloc = [200,20] +gloc = [] +#gloc = [0,630,64,630,128,630,192,630,256,630,320,630,384,630] +tx = 64 #tile size +ty = 64 #tile size + +i=0 +while i <= (worldx/tx)+tx: +    gloc.append(i*tx) +    i=i+1 + +enemy_list = Level.bad( 1, eloc ) +ground_list = Level.ground( 1,gloc,tx,ty ) +plat_list = Level.platform( 1,tx,ty ) + +''' +Main loop +''' +while main == True: +    for event in pygame.event.get(): +        if event.type == pygame.QUIT: +            pygame.quit(); sys.exit() +            main = False + +        if event.type == pygame.KEYDOWN: +            if event.key == pygame.K_LEFT or event.key == ord('a'): +                print("LEFT") +                player.control(-steps,0) +            if event.key == pygame.K_RIGHT or event.key == ord('d'): +                print("RIGHT") +                player.control(steps,0) +            if event.key == pygame.K_UP or event.key == ord('w'): +                print('jump') + +        if event.type == pygame.KEYUP: +            if event.key == pygame.K_LEFT or event.key == ord('a'): +                player.control(steps,0) +            if event.key == pygame.K_RIGHT or event.key == ord('d'): +                player.control(-steps,0) +            if event.key == pygame.K_UP or event.key == ord('w'): +                player.jump(plat_list) + +            if event.key == ord('q'): +                pygame.quit() +                sys.exit() +                main = False + +    # scroll the world forward +    if player.rect.x >= forwardx: +        scroll = player.rect.x - forwardx +        player.rect.x = forwardx +        for p in plat_list: +            p.rect.x -= scroll +        for e in enemy_list: +            e.rect.x -= scroll +                +    # scroll the world backward +    if player.rect.x <= backwardx: +        scroll = backwardx - player.rect.x +        player.rect.x = backwardx +        for p in plat_list: +            p.rect.x += scroll +        for e in enemy_list: +            e.rect.x += scroll + +    world.blit(backdrop, backdropbox) +    player.gravity() # check gravity +    player.update() +    player_list.draw(world) #refresh player position +    enemy_list.draw(world)  # refresh enemies +    ground_list.draw(world)  # refresh enemies +    plat_list.draw(world)   # refresh platforms +    for e in enemy_list: +        e.move() +    pygame.display.flip() +    clock.tick(fps) +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/python-platformer-game-run + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者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/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/open_gaming_games_roundup_news.png?itok=KM0ViL0f (Gaming artifacts with joystick, GameBoy, paddle) +[2]: https://opensource.com/article/17/10/python-101 +[3]: https://opensource.com/article/17/12/game-framework-python +[4]: https://opensource.com/article/17/12/game-python-add-a-player +[5]: https://opensource.com/article/17/12/game-python-moving-player +[6]: https://opensource.com/article/18/5/pygame-enemy +[7]: https://opensource.com/article/19/11/simulate-gravity-python +[8]: https://opensource.com/article/19/12/jumping-python-platformer-game +[9]: https://www.python.org/ +[10]: https://www.pygame.org/news +[11]: https://opensource.com/sites/default/files/uploads/pygame-scroll.jpg (Scrolling the world in Pygame) diff --git a/sources/tech/20191211 Revamp your old Linux desktop with Joe-s Window Manager.md b/sources/tech/20191211 Revamp your old Linux desktop with Joe-s Window Manager.md new file mode 100644 index 0000000000..97240d2de9 --- /dev/null +++ b/sources/tech/20191211 Revamp your old Linux desktop with Joe-s Window Manager.md @@ -0,0 +1,78 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Revamp your old Linux desktop with Joe's Window Manager) +[#]: via: (https://opensource.com/article/19/12/joes-window-manager-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Revamp your old Linux desktop with Joe's Window Manager +====== +This article is part of a special series of 24 days of Linux desktops. +JWM's meager weight and simplicity makes it a great window manager for +slow or old Linux computers. +![and old computer and a new computer, representing migration to new software or hardware][1] + +Joe's Window Manager ([JWM][2] for short) is a lightweight window manager for X11. It's written in C, minimally using [Xlib][3]. Because it's so small and simple, JWM makes a great window manager for slow or old computers. The Raspberry Pi barely registers that JWM is running, leaving precious system resources for more important tasks than the desktop. + +JWM follows in the footsteps of environments like FVWM, Window Maker, and Fluxbox. It provides an application menu, window decoration, and a panel with an application menu, taskbar, and clock. + +Install JWM from your distribution's software repository. After installing it, log out of your current desktop session so you can log into JWM. By default, your session manager (KDM, GDM, LightDM, or XDM, depending on your setup) will continue to log you into your previous desktop, so you must override that before logging in. + +To select a new desktop with GDM: + +![Select your desktop session in GDM][4] + +With KDM: + +![Select your desktop session with KDM][5] + +The first time you log into JWM, you may find a black screen with a panel at the bottom. It's normal on most distributions to let you choose the wallpaper for this minimal desktop. You can set a wallpaper with the **feh** command (you may need to install it from your repository). This command has a few options for setting the background, including **\--bg-fill** to fill the screen with your wallpaper of choice, **\--bg-scale** to scale it to fit, and so on. + + +``` +`$ feh --bg-fill ~/Pictures/wallpapers/mybackground.jpg` +``` + +### Application menu + +There are two locations for the application menus in JWM: it appears at your mouse cursor when you left-click on the desktop, and it is also available by clicking the JWM logo in the lower-left corner. + +![JWM running on Debian][6] + +There aren't any applications bundled with JWM, so it's up to you to decide what applications to use. You can get applications from any desktop, like GNOME or KDE, or you can use independent applications. Most of the integration between applications is done by [D-Bus][7] and other backend technology on Linux, so it's safe to mix and match them. I use [PCManFM-Qt][8] as a file manager, [unicode-rxvt][9] as a terminal, and, of course, Firefox as an internet browser. + +### Configuration + +Two configuration files govern JWM. The system-wide configuration file is **/etc/jwm/system.jwmrc**, and the user local file is **$HOME/.jwmrc**. Configuration files are written in XML, but the schema is very basic and easy to reverse-engineer, whether you know XML or not. Configuration options are well-documented on [Joewing.net][10], home of the JWM project. + +### Why you should use JWM + +There's no shortage of lightweight window managers available for Linux, and you might wonder why there seems to be so much redundancy, much less why you should try Joe's. There are a few reasons JWM is as important as any of the others. When looking at software projects, redundancy is a _good thing_. Should one project's implementation of a desktop paradigm fade, you have many others to choose from. And often, the strengths of each project are in the minor details. For example, the quick and easy setup of a taskbar and application menu makes for a quick, sensible default configuration for all the users who want that common setup. For technical users, the XML configuration may be a refreshing change from the custom configuration formats in other environments. + +Joe's Window Manager, in a way, demonstrates the rich diversity of open source and how it's a luxury Linux users enjoy. If you're interested in JWM, try it out today, and see if you can make your own window manager, too. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/joes-window-manager-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者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/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/migration_innovation_computer_software.png?itok=VCFLtd0q (and old computer and a new computer, representing migration to new software or hardware) +[2]: http://joewing.net/projects/jwm/ +[3]: https://en.wikipedia.org/wiki/Xlib +[4]: https://opensource.com/sites/default/files/advent-gdm_0.jpg (Select your desktop session in GDM) +[5]: https://opensource.com/sites/default/files/advent-kdm.jpg (Select your desktop session with KDM) +[6]: https://opensource.com/sites/default/files/uploads/advent-jwm_675px.jpg (JWM running on Debian) +[7]: https://en.wikipedia.org/wiki/D-Bus +[8]: https://blog.lxqt.org/category/pcmanfm-qt/ +[9]: https://opensource.com/article/19/10/why-use-rxvt-terminal +[10]: http://joewing.net/projects/jwm/config-2.3.html diff --git a/sources/tech/20191212 15 Useful Firefox Keyboard Shortcuts You Should Know.md b/sources/tech/20191212 15 Useful Firefox Keyboard Shortcuts You Should Know.md new file mode 100644 index 0000000000..345802439f --- /dev/null +++ b/sources/tech/20191212 15 Useful Firefox Keyboard Shortcuts You Should Know.md @@ -0,0 +1,129 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (15 Useful Firefox Keyboard Shortcuts You Should Know) +[#]: via: (https://itsfoss.com/firefox-keyboard-shortcuts/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +15 Useful Firefox Keyboard Shortcuts You Should Know +====== + +[Firefox][1] is one of the most popular free and open-source browsers for Linux users. Even though you have a lot of [open source chrome alternatives][2], Firefox still is one of the best choices to go with. + +And you don’t even need to [install Firefox on Ubuntu][3] or most other distributions because it is installed by default. + +What if you can make your browsing experience on Firefox even better by using some keyboard shortcuts? + +Hold on, of course, not everyone prefers to use keyboard shortcuts. But, if you’re comfortable with that and want to do perform tasks in a jiffy, you should know some of the most common Firefox keyboard shortcuts. + +It is also worth noting that you could use some of these shortcuts on Chrome/Chromium as well- however, we already have a list of [useful Google Chrome shortcuts][4] to help you out. So, if you’re using Chrome/Chromium, I insist you check out that article. + +### 15 Useful Firefox Keyboard Shortcuts + +![][5] + +You could always refer to the [official documentation][6] of keyboard shortcuts for Firefox. However, that’s a very long list, and you probably do not need to use all of that. + +So, here, I shall be listing the most commonly used (and useful) keyboard shortcuts that you can use on Firefox. To be honest, these are the shortcuts that I use most frequently on Firefox. + +#### 1\. Open A New Tab + +You don’t have to hover your cursor over to the **+** sign in the browser. + +Simply press **CTRL + T** to open a new tab in the same window. + +#### 2\. Open A New Tab In A New Window + +If you want to open up a new window along with a new tab, you just have to press **CTRL + N**. + +#### 3\. Close A Tab + +Lazy to use your mouse to navigate and close the tab? Fret not, just press **CTRL + W** to make your active tab vanish! + +#### 4\. Open A New Private Window + +Don’t want to store the history/cookies for a specific browsing session? You can try the private mode by pressing **CTRL + Shift + P** as the keyboard shortcut for Firefox. + +#### 5\. Open Recently Closed Tabs + +If you closed a tab recently (or a number of tabs), just press **CTRL + Shift + T** till you get all your closed tabs restored. + +#### 6\. Reload Webpage + +You might want to reload a webpage quickly, to do that press **F5**. + +If you want to ignore the cached content and want to fetch a new copy of the webpage, you can try **CTRL + F5**. + +#### 7\. Scroll Up/Down Webpage + +You can also scroll up/down using just your keyboard. + +Simply use **PAGE UP** to scroll up and **PAGE DOWN** key to scroll down. + +#### 8\. Find A Text In Webpage + +You do not need to endlessly look for a word on a webpage just like you would in a physical book. + +Simply press **CTRL + F** and then type in the exact word, it should highlight the matching words if it exists. + +#### 9\. Close Your Browser At Once + +Hit **CTRL + Shift + W** to close all the tabs in one go. However, you might get the prompt to confirm it. + +#### 10\. View The Page Source + +If you’re interested to take peek at the webpage’s source code, you just have to press **CTRL + U** to open view source in a new tab. + +#### 11\. Switch Tabs Quickly + +If you have multiple tabs opened up, you can easily navigate through them by pressing: + +**CTRL + Tab**. + +#### 12\. View Your Downloads + +Do you want to quickly take a look at your download library? All you need to do is press: + +**CTRL + Shift + Y** + +#### 13\. Bookmark A Webpage + +To bookmark a webpage, hit **CTRL + D** and press the **ENTER** key to save it. + +#### 14\. Select the Address/Search Bar + +If you want to search for something through the address bar, hit **CTRL + L** to immediately highlight the search bar for you. + +#### 15\. Check Browsing History + +Usually, it needs a couple of clicks to view your history. But, you can just press **CTRL + H** to launch the sidebar to view your history right away. + +### Wrapping Up + +As I mentioned, you will find a huge list of Firefox keyboard shortcuts if you take a look at their [official documentation][6]. + +If you want to explore more options, feel free to check the documentation. In either case, the mentioned keyboard shortcuts should come pretty handy. + +I’ll be interested to know what Firefox keyboard shortcuts do you use? Let me know your thoughts in the comments below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/firefox-keyboard-shortcuts/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://www.mozilla.org/en-US/firefox/ +[2]: https://itsfoss.com/open-source-browsers-linux/ +[3]: https://itsfoss.com/firefox-quantum-ubuntu/ +[4]: https://itsfoss.com/google-chrome-shortcuts/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/Firefox_Keyboard_Shortcuts.jpg?ssl=1 +[6]: https://developer.mozilla.org/en-US/docs/Tools/Keyboard_shortcuts diff --git a/sources/tech/20191213 How to generate code with Apache Velocity.md b/sources/tech/20191213 How to generate code with Apache Velocity.md new file mode 100644 index 0000000000..ad431b0a55 --- /dev/null +++ b/sources/tech/20191213 How to generate code with Apache Velocity.md @@ -0,0 +1,88 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to generate code with Apache Velocity) +[#]: via: (https://opensource.com/article/19/12/generate-code-apache-velocity) +[#]: author: (Girish Managoli https://opensource.com/users/gammay) + +How to generate code with Apache Velocity +====== +Get started with Velocity, an open source, Java-based template engine +and code generator that converts templates into source code. +![Binary code on a computer screen][1] + +Apache [Velocity][2] is an open source, Java-based template engine and code generator that converts templates into source code. Because it is implemented in Java, it is capable of interpreting varied templates and generating code for any language (web, service, SQL, scripts, etc.), although it seems to be oriented mostly toward web development. + +## Velocity's structure + +Velocity's structure is comprised of an engine and tools. Its core is the Velocity Engine, which uses the defined template, interprets the template language, and generates the code. + +Templates are defined with Velocity Template Language ([VTL][3]), a simple language with effective directives. VTL statements are directives or variables, and variables can be standalone or class methods. + +Examples of VTL expressions include: + + +``` +`package ${packagename};`[/code] | Inserts a package statement in Java where the package name is defined as **packagename** +---|--- +``` +`public ${classname} implements Serializable {`[/code] | Adds a class with name **classname** + +``` + #foreach( $property in $properties ) + public ${property.fieldType} get${property.getField()}() { +     return this.${property.fieldName}; + } +#end [/code] | Creates getter methods for all defined properties + +Velocity tools are collections of basic user-friendly capabilities. There are [GenericTools][4], a "set of classes that provide basic infrastructure for using tools in standard Java SE Velocity projects, as well as a set of tools for use in generic Velocity templates." They include DateTool, MathTool, NumberTool, SortTool, and XmlTool. There are also [VelocityView][5] tools, which include "all of the GenericTools and adds infrastructure and specialized tools for using Velocity in the view layer of web applications (Java EE projects)." VelocityView tools include BrowserTool, CookieTool, and ImportTool + +## Velocity advantages and disadvantages + +Velocity is easy to use and has the capability to generate any language. On the downside, there is a learning curve to understand and apply its template language. Velocity is morphology- and ontology-free. It has no knowledge of the design capability of the module it generates. As a practical example, Velocity may use a template for a controller (e.g., Model-View-Controller or an architecture style) and generate the code, but it has no awareness of the concept of a controller. This is both an advantage and disadvantage, with a generator being simple and easy to use but with no awareness of the design's aptitude. + +## Using Velocity + +Velocity's Java library is available on the [Maven repository][6]. To use the .jar file, define Velocity's latest version in your Maven build config. (Velocity 1.7 is the latest version, as of this writing.) For example, enter the following in your Maven Project Object Model (POM): +``` + + +<dependency> +        <groupId>org.apache.velocity</groupId> +        <artifactId>velocity</artifactId> +        <version>1.7</version> +</dependency> + +``` +### Java Hello World example + +To generate code, you need two things: + + 1. The **Velocity template** to be used for generation, e.g., java_example.vm: [code] public class ${className} { + +    public static void main([String][7][] args) { +        [System][8].out.println("${message}"); +    } + +} +``` + + + + 2. The **Velocity generator** that uses the template to generate code, e.g., VelocityStartGenerator.java: [code] public class VelocityStartGenerator { +  +    static [String][7] inputTemplate = "java_example.vm"; +    static [String][7] className = "VelocityExample"; +    static [String][7] message = "Hello World!"; +    static [String][7] outputFile = className + ".java"; +        +    public static void main([String][7][] args) throws [IOException][9] { +        +        VelocityEngine velocityEngine = new VelocityEngine(); +        velocityEngine.init(); +      +        VelocityContext context = new VelocityContext(); +        context.put("className", className); +  \ No newline at end of file diff --git a/sources/tech/20191213 Why you need to know about Seeed hardware devices.md b/sources/tech/20191213 Why you need to know about Seeed hardware devices.md new file mode 100644 index 0000000000..eec34577da --- /dev/null +++ b/sources/tech/20191213 Why you need to know about Seeed hardware devices.md @@ -0,0 +1,121 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Why you need to know about Seeed hardware devices) +[#]: via: (https://opensource.com/article/19/12/seeeduino-nano-review) +[#]: author: (Alan Smithee https://opensource.com/users/alansmithee) + +Why you need to know about Seeed hardware devices +====== +Learn how Seeed microcontrollers solve the problem of building modular +projects. +![Multi-colored and directional network computer cables][1] + +The microcontroller craze doesn't seem to be dying down—and that's a good thing because these products consistently succeed where the mobile market consistently fails: Users get open software _and hardware_, a portable form factor, and a wide choice of vendors and products that are built to last. + +Among the best of the open hardware and software vendors is [Seeed][2], the self-proclaimed "IoT Hardware Enabler." I recently started seeing the Seeed logo on projects, so I contacted the company to learn about the interesting things they're doing. In response, they generously sent me one of their latest products: the [Seeeduino Nano][3], a compact board that the company says is fully compatible with the Arduino Nano but at half the price and a quarter the size, along with a sample sensor to get me started. + +I spent a few days with it, and I'm already working on a project to improve my home garden and thinking of several others for home automation. Far from just another Arduino-like product, the Seeeduino Nano solves several problems new makers face when they get a microcontroller and want to use it. + +### What do I do with this? + +The most common problem I hear from people underwhelmed by the Raspberry Pi, Arduino, or similar microcontroller is that they excitedly got a board, stepped through its tutorial, and then realized they didn't know what to do with it. As computer users, we're not used to purpose-driven devices. You get a computer-like device and use it for many purposes, so it feels strange to get a computing device and build it into a project. + +It can also be a little overwhelming to get a microcontroller. It's full of potential, but it's also just a microcontroller. It can be intimidating to figure out what kind of project to start when you have a device that apparently is capable of anything. + +Seeed has a line of input and output peripherals (they call it Grove) that are easy to connect and provide an easy way to modularly build projects based on what kind of information you want to process. There's nothing special about the Grove modules compared to sensors or servos you can get for any other device, but Seeed makes what can sometimes seem to be an overwhelming number of choices a lot more navigable. And better yet, Seeed provides libraries for each Grove module, so you'll never buy a part for your project then find that you don't know how to make your controller recognize it. + +Because Seeed sent me a temperature and humidity sensor, my potential projects, at least in the short term, became highly focused. I knew I'd be designing either a thermometer and humidity detector for my home or a moisture monitor for some of my favorite plants. Based on the other Grove modules, I've come up with several more projects, too. + +### Clean connectors + +What makes the Grove modules especially nice is that they're based around I2C connectors. That means you can turn this: + +![Cables and pins and alligator clips][4] + +into this: + +![The Seeeduino Nano with a Grove module connected][5] + +Of course, you can also solve that problem with any number of attachments for a Pi or Arduino or whatever product you happen to own, but the Seeed and Grove are built for one another, so if you're embarking on a new project, this is an easy way to keep things under control from the start. + +### Small footprint + +The Seeeduino Nano is small. It's just 18mm by 43mm (that's about 1.5" by 1"), yet it has eight analog pins, 14 digital pins, and features the ATmega328P 8-bit AVR microcontroller. If your project has space issues, this is a great option. + +![Seeeduino Nano microcontroller][6] + +The sensors tend to be small, too. Size varies depending on what you purchase, but they're generally designed to save space. + +![The Grove temperature and humidity pro \(left\) and a US quarter \(right\)][7] + +### Setup + +Getting started with the Seeeduino Nano was as easy as getting started with an Arduino. That's not always the case with Arduino-like products, because some of them assume you know the components they're built from. You might get a microcontroller, download the Arduino IDE, and discover that the product you purchased isn't an option in the Board menu, leaving you to guess which Arduino board yours is equivalent to. Seeed leaves nothing to chance and provides board definitions for all of its products. You have to import them yourself since they don't ship with the Arduino IDE, but the [Seeed wiki][8] provides instructions on how to do that through the IDE's Board Manager interface. + +After you've imported the board definition, you can either start with the ritual flashing of the Blink code onto your device or just code in the Arduino IDE as usual. There are instructions on the Seeed wiki for that, too. + +### Code + +In addition to board definitions, Seeed provides sample code for each Grove module, so you know how to send data to the module or gather data from it. I was using the Temperature and Humidity Pro sensor, which requires the [DHT library][9]. Seeed provides the library along with a DHTtester [project][10], and instructions on how to install it are on its wiki. + +The only thing Seeed doesn't provide is the name of the correct input pin for the Grove module. The project's example code, written by [LadyAda][11], uses the first analog pin (A0), but, on the Seeeduino Nano, the Grove attaches to what turns out to be A5. This is difficult to tell by looking at it, because the Grove physically attaches to the I2C plug, with no indication of what pin it's connected to. However, the Seeed is open source, so you can either look at the specs for the board, or you can just do what these kinds of gadgets beg you to do: experiment! + +In the end, the basic code to get information from the Grove humidity and temperature sensor is about 20 lines of code (25 if you build in sanity checks, as LadyAda's code does): + + +``` +// public domain code by ladyada +#include "DHT.h" +#define DHTPIN A5 +#define DHTTYPE DHT22 + +DHT dht(DHTPIN, DHTTYPE); + +void setup() { +  Serial.begin(9600); +  dht.begin(); } + +void loop() { +  float h = dht.readHumidity(); +  float t = dht.readTemperature(); +  Serial.print("Humidity: "); +  Serial.print(h); +  Serial.print(" %\t"); +  Serial.print("Temperature: "); +  Serial.print(t); +  Serial.println(" *C"); } +``` + +### Open source everything + +The Seeeduino is open source, from the [downloadable Eagle file][12] to the [software][13] that helps you drive it. It's a dream platform for new users who feel overwhelmed by confusing and disparate choices or for experienced makers who have moved on from a prototype and are ready to build a neatly organized and cleanly wired project. If you've got a budding inventor in your life, let Seeed help seed their projects. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/seeeduino-nano-review + +作者:[Alan Smithee][a] +选题:[lujun9972][b] +译者:[译者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/alansmithee +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/connections_wires_sysadmin_cable.png?itok=d5WqHmnJ (Multi-colored and directional network computer cables) +[2]: http://seeedstudio.com +[3]: http://wiki.seeedstudio.com/Seeeduino-Nano/ +[4]: https://opensource.com/sites/default/files/uploads/rpi-mess.jpg (Cables and pins and alligator clips) +[5]: https://opensource.com/sites/default/files/uploads/seeeduino-grove.jpg (The Seeeduino Nano with a Grove module connected) +[6]: https://opensource.com/sites/default/files/uploads/seeeduino-nano-wiki_0.jpg (Seeeduino Nano microcontroller) +[7]: https://opensource.com/sites/default/files/uploads/tempandhumid.jpg (The Grove temperature and humidity pro (left) and a US quarter (right)) +[8]: http://wiki.seeedstudio.com/ +[9]: https://github.com/Seeed-Studio/Grove_Temperature_And_Humidity_Sensor/releases +[10]: https://project.seeedstudio.com/ +[11]: https://www.adafruit.com +[12]: https://github.com/SeeedDocument/Seeeduino-Nano/raw/master/res/Seeeduino%20nano.zip +[13]: https://github.com/Seeed-Studio diff --git a/sources/tech/20191214 Make VLC More Awesome With These Simple Tips.md b/sources/tech/20191214 Make VLC More Awesome With These Simple Tips.md new file mode 100644 index 0000000000..de91a1105b --- /dev/null +++ b/sources/tech/20191214 Make VLC More Awesome With These Simple Tips.md @@ -0,0 +1,131 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Make VLC More Awesome With These Simple Tips) +[#]: via: (https://itsfoss.com/simple-vlc-tips/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Make VLC More Awesome With These Simple Tips +====== + +[VLC][1] is one of the [best open source video players][2], if not the best. What most people don’t know about it is that it is a lot more than just a video player. + +You can do a lot of complex tasks like broadcasting live videos, capturing devices etc. Just open its menu and you’ll see how many options it has. + +It’s FOSS has a detailed tutorial discussing some of the [pro VLC tricks][3] but those are way too complicated for normal users. + +This is why I am writing another article to show you some of the simple tips that you can use with VLC. + +### Do more with VLC with these simple tips + +Let’s see what can you do with VLC other than just playing a video file. + +#### 1\. Watch YouTube videos with VLC + +![][4] + +If you do not want to watch the annoying advertisements on [YouTube][5] or simply want a distraction-free experience for watching a YouTube video, you can use VLC. + +Yes, it is very easy to stream a YouTube video on VLC. + +Simply launch the VLC player, head to the Media settings and click on “**Open Network Stream**” or **CTRL + N** as a shortcut to that. + +![][6] + +Next, you just have to paste the URL of the video that you want to watch. There are some options to tweak – usually, you should not bother using them. But, if you are curious you can click on the “**Advanced options**” to explore. + +You can also add subtitles to the YouTube videos this way. However, an easier way to [watch YouTube or any online video with subtitles is using Penguin subtitle player][7]. + +#### 2\. Convert videos to different formats + +![][8] + +You can [use ffmpeg to convert videos in Linux command line][9]. You can also use a graphical tool like [HandBrake to convert video formats][10]. + +But if you do not want a separate app to transcode videos, you can use VLC media player to get the job done. + +To do that, just head on to the Media option on VLC and then click on “**Convert/Save**” or press CTRL + R as a shortcut to get there while you have VLC media player active. + +Next, you will need to either import the video from your computer/disk or paste the URL of the video that you want to save/convert. + +Whatever your input source is – just hit the “**Convert/Save**” button after selecting the file. + +Now, you will find another window that gives you the option to change the “**Profile**” from the settings. Click on it and choose a format that you’d like the video to be converted to (and saved). + +You can also change the storage path for the converted file by setting the destination folder at the bottom of the screen before converting it. + +#### 3\. Record Audio/Video From Source + +![Vlc Advanced Controls][11] + +Do you want to record the audio/video you’re playing on VLC Media Player? + +If yes, there’s an easy solution to that. Simply navigate your way through **View->click on “Advanced Controls”**. + +Once you do that, you should observe new buttons (including a red record button in your VLC player). + +#### 4\. Download subtitles automatically + +![][12] + +Yes, you can [automatically download subtitles with VLC][13]. You do not even have to look for it on a separate website. You just have to navigate your way to **View->VLSub**. + +By default, it is deactivated, so when you click on the option it gets activated and lets you search/download the subtitles you wanted. + +[VLC also lets you synchronize the subtitles][14] with simple keyboard shortcuts. + +#### 5\. Take A Snapshot + +![][15] + +With VLC, you can get some screenshots/images of the video while watching it. + +You just need to right-click on the player while the video is playing/paused, you will notice a bunch of options now, navigate through **Video->Take Snapshot**. + +If you have an old version installed, you might observe the snapshot option right after performing a right-click. + +#### Bonus Tip: Add Audio/Video Effects to a video + +From the menu, go to the “**Tools**” option. Now, click on “**Effects and Filters**” or simply press **CTRL + E** from the VLC player window to open up the option. + +Here, you can observe audio effects and video effects that you can add to your video. You may not be able to see all the changes in real-time, so you will have to tweak it and save it in order to see what happens. + +![][16] + +I’ll suggest keeping a backup of the original video before you modify the video. + +#### What’s your favorite VLC tip? + +I shared some of my favourite VLC tips. Do you know some cool tip that you use regularly with VLC? Why not share it with us? I may add it to the list here. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/simple-vlc-tips/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://www.videolan.org/ +[2]: https://itsfoss.com/video-players-linux/ +[3]: https://itsfoss.com/vlc-pro-tricks-linux/ +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/youtube-video-stream.jpg?ssl=1 +[5]: https://www.youtube.com/ +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/youtube-video-play.jpg?ssl=1 +[7]: https://itsfoss.com/penguin-subtitle-player/ +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/vlc-video-convert.jpg?ssl=1 +[9]: https://itsfoss.com/ffmpeg/ +[10]: https://itsfoss.com/handbrake/ +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/vlc-advanced-controls.png?ssl=1 +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/vlc-subtitles-automatic.png?ssl=1 +[13]: https://itsfoss.com/download-subtitles-automatically-vlc-media-player-ubuntu/ +[14]: https://itsfoss.com/how-to-synchronize-subtitles-with-movie-quick-tip/ +[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/vlc-snapshot.png?ssl=1 +[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/vlc-effects-screenshot.jpg?ssl=1 diff --git a/sources/tech/20191215 Customize your Linux desktop with the Trinity Desktop Environment.md b/sources/tech/20191215 Customize your Linux desktop with the Trinity Desktop Environment.md new file mode 100644 index 0000000000..561e90d771 --- /dev/null +++ b/sources/tech/20191215 Customize your Linux desktop with the Trinity Desktop Environment.md @@ -0,0 +1,65 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Customize your Linux desktop with the Trinity Desktop Environment) +[#]: via: (https://opensource.com/article/19/12/linux-trinity-desktop-environment-tde) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Customize your Linux desktop with the Trinity Desktop Environment +====== +This article is part of a special series of 24 days of Linux desktops. +TDE is a fully customizable Linux desktop that will be instantly +recognizable to anyone who knew and loved KDE 3. +![Person standing in front of a giant computer screen with numbers, data][1] + +When KDE 4 was released in 2008, KDE 3 went into support mode until support was dropped entirely. That's the usual lifecycle of software, desktops included, but the KDE 3 fanbase wasn't universally pleased with KDE 4, and some of them decided a fork was in order. + +Some of them formed a new project with the mission of preserving the look and feel of KDE 3, starting from KDE 3.5.10 (the last official release in the 3.x series), and then forking Qt 3 into TQt to keep the underlying technology updated. Today, the [Trinity Desktop Environment][2] (TDE) delivers a traditional desktop environment that looks and feels essentially the same as KDE 3 did 10-plus years ago. + +You may find the Trinity desktop included in the software repository of your distribution. Before you install it, be aware that it is meant to provide a full desktop experience, so many TDE apps are installed along with the desktop. If you're already running another desktop, you may find yourself with redundant applications (two PDF readers, two media players, two file managers, and so on). + +If your software repo doesn't offer Trinity, or you just don't want to install it and all of its applications, you can install a TDE distribution in a virtual machine, such as [GNOME Boxes][3]. I used the [exeGNU][4] distribution for the screenshots below, and there are other distros listed on [TDE's LiveCDs][5] page. + +### TDE desktop tour + +The Trinity Desktop Environment is a very traditional desktop. It's one that's likely to be familiar to you—whether or not you've used KDE at all, in fact. It has one panel at the bottom of the screen that contains an application menu in the left corner, a taskbar in the middle, and a system tray in the right, and there are icons for common locations on the desktop. It behaves exactly as you'd expect a desktop to behave, and you can probably change whatever you want to change because TDE is completely customizable. + +If you were a KDE 3 user in the past, revisiting the Trinity Desktop Environment is a little like stepping back in time. While a side-by-side comparison of the two desktops might reveal significant differences, it would be a real challenge to find a deviation in TDE from the desktop you remember. All the key components are there: the sidebar tabs, the Konqueror file manager, the traditional application menu, the retractable panel, and the classic layout. + +![TDE on exeGNU][6] + +How different this is from KDE 4 or KDE 5 is a matter of perspective. To many users, the TDE default is pretty much the same as the default layout of late KDE 4 or current KDE 5 desktops. As is often the case, however, the biggest differences are in the smallest of details. The absence of Dolphin in favor of [Konqueror][7] is one of the biggest non-changes. Konqueror has quite literally set the standard for both file management and web browsing (KHTML is the code that Apple and Google forked to create the Safari and Chrome browsers), so preserving it as the central desktop application is particularly noteworthy. + +All the "old" applications are still there, and seemingly not a button or widget has moved from the old default 3.5 location. The defaults are always set to what they were in KDE 3.5, but nearly everything can be rearranged, changed, hidden, or disassembled. User experience is supreme, and TDE never assumes that any two users want the same experience. + +![Trinity Control Center][8] + +To a tried and true KDE 3.5.x user, using TDE is just a matter of surrendering to muscle memory. + +### Trinity and open source + +Trinity, along with the Mate fork of GNOME 2, is one of the most direct examples of how open source empowers developers to sustain a beloved software project that's otherwise reached its end. Not all software is kept alive by a fork and a dedicated team of true believers, but sometimes it does happen, and when it does, it results in greater variety and more choice. Whether you choose KDE 5 or TDE, or GNOME 3 or Mate, you get to make those choices because open source empowers developers and users to make technology work better for everyone. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/linux-trinity-desktop-environment-tde + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者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/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) +[2]: https://www.trinitydesktop.org/ +[3]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization +[4]: http://exegnulinux.net +[5]: https://wiki.trinitydesktop.org/LiveCDs +[6]: https://opensource.com/sites/default/files/uploads/advent-trinity.jpg (TDE on exeGNU) +[7]: https://kde.org/applications/internet/org.kde.konqueror +[8]: https://opensource.com/sites/default/files/uploads/advent-trinity-control.jpg (Trinity Control Center) diff --git a/sources/tech/20191215 How to Add Border Around Text in GIMP.md b/sources/tech/20191215 How to Add Border Around Text in GIMP.md new file mode 100644 index 0000000000..d691bafb41 --- /dev/null +++ b/sources/tech/20191215 How to Add Border Around Text in GIMP.md @@ -0,0 +1,139 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Add Border Around Text in GIMP) +[#]: via: (https://itsfoss.com/gimp-text-outline/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +How to Add Border Around Text in GIMP +====== + +This simple tutorial explains the steps to outline text in [GIMP][1]. The text outline helps you highlight text against background of other color. + +![Outlined Text created in GIMP][2] + +Let’s see how can you add a border around your text. + +### Adding text outline in GIMP + +The entire procedure can be described in these easy steps: + + * Create your text and copy its outlined path + * Add a new transparent layer and add the outlined path to this layer + * Change the size of the outline, add a different color to it + + + +That’s all. Don’t worry, I am going to show each steps in detail with proper screenshots. By following this tutorial, you should be able to add outline to text even if you never used GIMP before. + +Just make sure that you have [GIMP installed on Linux][3] or whatever operating system you are using. + +This tutorial has been performed with GIMP 2.10 version. + +#### Step 1: Create your primary text and copy its outline + +Open GIMP and create a new file by going to the top menu->File->New. You can also use Ctrl+N keyboard shortcut. + +![Create New File][4] + +You can select the size of your canvas here. You may also choose if you want white background or a transparent background. It is under the Advanced Options->Color profile. + +I have chosen the default white background. It can be changed later. + +Now select the Text tool from the toolbox in the left sidebar. + +![Adding text in GIMP][5] + +Write the text you want. You can change the font, size and alignment of the text as per your choice. I have kept the default left alignment of the text for this article. + +I have deliberately chose a light color for the text so that it is difficult to read. I’ll add a darker outline to this light text in this tutorial. + +![Text added in GIMP][6] + +When you are done writing your text, right click the text box and select **Path from Text**. + +![Right click on the text box and select ‘Path from Text’][7] + +#### Step 2: Add a transparent layer with the text outline + +Now, go to the top menu, go to Layer and add a new layer. + +![Use Shift+Ctrl+N to add a new layer][8] + +Make sure to add the new layer as transparent. You can give it a suitable name like ‘outline for text’. Click OK to add this transparent layer. + +![Add a transparent layer][9] + +Go to the menu again and this time go to **Select** and click **From path**. You’ll see that your text has been highlighted. + +![Go to Select and choose From Path][10] + +Basically, you just created a transparent layer that has the same text (but transparent) as your original text. What you need to do now is to increase the size of the text on this layer. + +#### Step 3: Adding the text outline by increasing its size and changing its color + +To do that, go to Select in menu once again and this time choose Grow. This will allow you to grow the size of the text on the transparent layer. + +![Grow the selection on the additional layer][11] + +Grow it by 5 or 10 pixel or whatever you prefer. + +![Grow it by 5 or 10 pixel][12] + +What you need to do now is to fill this enlarged selection with a choice of your color. Since my original text is of light color, I am going to use back color for the outline here. + +**Select your main image layer** if it’s not already selected. The layers are visible at the right sidebar. Then go to the toolbox and select the bucket fill tool. Select the desired color you want for the outline. + +Now use the tool to fill black color to your selection. Mind that you fill the outer outline of the text, not the text itself. + +![Fill the outline of the text with a different color][13] + +You are pretty much done here. Use Ctrl+Shift+A to de-select your current selection. + +![Outline added to the text][14] + +So now you have successfully added outline to your text in GIMP. It is on white background and if you want a transparent background, just delete the background layer from the layer menu in the right sidebar. + +![Remove the white background layer if you want a transparent background][15] + +If you are happy with the result, save the file as PNG file (to keep transparent background) or whichever file format you prefer. + +**Did you make it work?** + +That’s it. That’s all you need to do to add a text outline in GIMP. + +I hope you find this GIMP tutorial helpful. You may want to check out another [simple tutorial about adding a watermark in GIMP][16]. + +If you have questions or suggestions, please feel free to leave a comment below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/gimp-text-outline/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.gimp.org/ +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/outlined_text_GIMP.png?ssl=1 +[3]: https://itsfoss.com/gimp-2-10-release/ +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/12/create_outline_text_gimp_1.jpeg?ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_2.jpg?ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp-3.jpg?ssl=1 +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_4.jpg?ssl=1 +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_5.jpg?ssl=1 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_6.jpg?ssl=1 +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_7.jpg?ssl=1 +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_8.jpg?ssl=1 +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_9.jpg?ssl=1 +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_10.jpg?ssl=1 +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_11.jpg?ssl=1 +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_12.jpg?ssl=1 +[16]: https://itsfoss.com/add-watermark-gimp-linux/ diff --git a/sources/tech/20191216 Relive Linux history with the ROX desktop.md b/sources/tech/20191216 Relive Linux history with the ROX desktop.md new file mode 100644 index 0000000000..215006514f --- /dev/null +++ b/sources/tech/20191216 Relive Linux history with the ROX desktop.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Relive Linux history with the ROX desktop) +[#]: via: (https://opensource.com/article/19/12/linux-rox-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Relive Linux history with the ROX desktop +====== +This article is part of a special series of 24 days of Linux desktops. +If you're looking for a fun trip back in time, the ROX desktop is well +worth a go. +![Person typing on a 1980's computer][1] + +The [ROX][2] desktop is no longer being actively developed, but its legacy resounds today, and even when it was active, it was a unique take on what a Linux desktop could be. While other desktops felt roughly similar to old Unix or Windows interfaces, ROX belongs solidly in the BeOS, AmigaOS, and [RISC OS][3] desktop camps. + +It focuses on drag-and-drop actions (which makes its accessibility non-optimal for some users), point-and-click actions, pop-up contextual menus, and a unique system of app directories for running local applications with no installation required. + +### Installing ROX + +Today, ROX is mostly abandoned and left in fragments that the user is left to sort out. Luckily, the puzzle is relatively easy to solve, but don't get confused when you find bits and pieces of the ROX desktop in your distribution's repository—but not _every_ bit of the ROX desktop. The popular parts of ROX—the file manager ([ROX-Filer][4]) and the terminal ([ROXTerm][5])—seem to have endured in most of the popular distribution repositories, and you can install (and use) them as standalone applications. However, to run the ROX desktop, you must also install ROX-Session and the libraries it depends on. + +I installed ROX on Slackware 14.2, but it should work on any Linux or BSD system. + +First, you must install [ROX-lib2][6] from its repository. True to its philosophy of minimal installs, all you have to do to install ROX-lib2 is download the tarball, [unarchive it][7], and move the **ROX-Lib** directory to **/usr/local/lib**. + +Next, you have to install [ROX-Session][8]. This probably needs to be compiled from source code, as it's not likely to be in your software repository. The compile process requires build tools, which ship by default on Slackware but are often omitted in other distributions to save space on the initial download. The names of the packages you must install to build from source code vary depending on your distro, so refer to the documentation for specifics. For example, on Debian-based distributions, you can learn about build requirements in [Debian's wiki][9], and on Fedora-based distributions, refer to [Fedora's docs][10]. Once you have the build tools installed, execute the custom ROX-Session build script: + + +``` +`$ ./AppRun` +``` + +This manages its own build and installation and prompts you for root permissions to add itself as an option on your login screen. + +If you have not installed ROX-Filer from your software repository, do that before continuing. + +Together, these components create a complete ROX desktop. To log into your new desktop, log out of your current desktop session. By default, your session manager (KDM, GDM, LightDM, or XDM, depending on your setup) will continue to log you into your previous desktop, so you must override that before logging in. + +With SDDM: + +![][11] + +With GDM: + +![][12] + +### ROX desktop features + +The ROX desktop is simple by default, with a single panel at the bottom of the screen and a shortcut icon to your home directory on the desktop. The panel contains shortcuts to common locations. That's all there is to the ROX desktop, at least as it's configured out of the box. If you want a clock or a calendar or a system tray, you need to find applications that provide them. + +![Default ROX desktop][13] + +There is no taskbar, as such, but when you minimize a window, it becomes a temporary icon on your desktop. You can click the icon to bring its window back to its former size and placement. + +The panel can be modified some, as well. You can place different shortcuts into it and even create your own applets. + +There's no application menu, either, nor are there shortcuts to applications in a contextual menu. Instead, you can navigate manually to **/usr/share/applications**, or you can add your application directory or directories to the ROX panel. + +![ROX desktop][14] + +The ROX desktop's workflow concentrates on being mouse-driven, reminiscent of Mac OS 7.5 and 8. With ROX-filer, you can manage permissions, file management, introspection, script launching, background setting, and nearly anything else you can think of, provided that you're patient enough for the point-and-click style of interaction. For power users, this seems slow, but ROX manages to make it relatively painless and very intuitive. + +### App directories, AppRun, and AppImage + +The ROX desktop has an elegant convention by which a directory containing a script named **AppRun** is executed as if it were an application. This means that in order to make a ROX app, all you have to do is compile code into a directory, place a script called **AppRun** at the root of that directory to execute the binary you've compiled, and then mark the directory executable. ROX-Filer displays a directory configured in the manner you set with a special icon and color. When you click on an app directory, ROX-Filer automatically runs the **AppRun** script inside. It looks and behaves exactly like an application that has been installed, but it's local to the user's home directory and requires no special permissions. + +This is a convenience feature, but it's one of those small features that feels great when you use it because it's so easy to implement. It's by no means essential, and it's only a few steps ahead of building an application locally, hiding the directory somewhere out of the way, and drumming up a quick **.desktop** file to act as your launcher. However, the concept of an application directory has been [cited][15] as an inspiration for the [AppImage][16] packaging system. + +### Why you should try ROX desktop + +Getting ROX set up and usable is somewhat difficult, and it appears to truly be abandoned. However, its legacy lives on in many ways today, and it's a fascinating and fun bit of Linux history. It may not become your primary desktop, but if you're looking for a fun trip back in time, then ROX is well worth a go. Explore it, customize it, and see what clever ideas it contains. There may yet be hidden gems that the open source community can benefit from. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/linux-rox-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者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/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/1980s-computer-yearbook.png?itok=eGOYEKK- (Person typing on a 1980's computer) +[2]: http://rox.sourceforge.net/desktop/ +[3]: https://www.riscosopen.org/content/ +[4]: http://rox.sourceforge.net/desktop/ROX-Filer +[5]: http://roxterm.sourceforge.net/ +[6]: http://rox.sourceforge.net/desktop/ROX-Lib +[7]: https://opensource.com/article/17/7/how-unzip-targz-file +[8]: http://rox.sourceforge.net/desktop/ROX-Session.html +[9]: https://wiki.debian.org/BuildingTutorial +[10]: https://docs.pagure.org/docs-fedora/installing-software-from-source.html +[11]: https://opensource.com/sites/default/files/advent-kdm_0.jpg +[12]: https://opensource.com/sites/default/files/advent-gdm_1.jpg +[13]: https://opensource.com/sites/default/files/uploads/advent-rox.jpg (Default ROX desktop) +[14]: https://opensource.com/sites/default/files/uploads/advent-rox-custom.jpg (ROX desktop) +[15]: https://github.com/AppImage/AppImageKit/wiki/AppDir +[16]: https://appimage.org/ diff --git a/sources/tech/20191216 Setting up the sway window manager on Fedora.md b/sources/tech/20191216 Setting up the sway window manager on Fedora.md new file mode 100644 index 0000000000..67c1e34f4c --- /dev/null +++ b/sources/tech/20191216 Setting up the sway window manager on Fedora.md @@ -0,0 +1,157 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Setting up the sway window manager on Fedora) +[#]: via: (https://fedoramagazine.org/setting-up-the-sway-window-manager-on-fedora/) +[#]: author: (George Luiz Maluf https://fedoramagazine.org/author/georgelmaluf/) + +Setting up the sway window manager on Fedora +====== + +![][1] + +Sometimes during a critical activity, working with overlapping windows becomes counterproductive. You might find a tiled window manager like sway to be a good alternative. + +Sway is a tiling Wayland compositor. It has the advantage of compatibility with an existing [i3 configuration][2], so you can use it to replace i3 and use Wayland as the display protocol. + +### Installing sway + +To setup sway, open a new terminal and type the following command + +``` +sudo dnf install sway +``` + +Once the installation is completed, log out of your user session. At the login screen, select your user account. Before you enter your password, choose _Sway_ from the menu, as shown in the following image. + +![][3] + +After login, your desktop looks like this: + +![][4] + +### Configuration + +To begin configuration, copy the default config into your user directory. Do that using the following commands. + +``` +mkdir -p .config/sway +cp /etc/sway/config ~/.config/sway/ +``` + +Sway is highly configurable. It’s suggested you read the project’s [wiki page][5] to fine tune your settings. For example, to change the keyboard layout, open a new terminal and run this command: + +``` +$ swaymsg -t get_inputs +[george@mrwhite ~]$ swaymsg -t get_inputs + Input device: VirtualPS/2 VMware VMMouse + Type: Mouse + Identifier: 2:19:VirtualPS/2_VMware_VMMouse + Product ID: 19 + Vendor ID: 2 + Libinput Send Events: enabled + Input device: VirtualPS/2 VMware VMMouse + Type: Mouse + Identifier: 2:19:VirtualPS/2_VMware_VMMouse + Product ID: 19 + Vendor ID: 2 + Libinput Send Events: enabled + Input device: AT Translated Set 2 keyboard + Type: Keyboard + Identifier: 1:1:AT_Translated_Set_2_keyboard + Product ID: 1 + Vendor ID: 1 + Active Keyboard Layout: Portuguese (Brazil) + Libinput Send Events: enabled +``` + +Copy the identifier keyboard code. Open your _~/.config/sway/config file_ with your text editor and edit the configuration accordingly: + +``` +## Input configuration +input "1:1:AT_Translated_Set_2_keyboard" { + xkb_layout br +} +``` + +Save the settings. To reload the configurations, press **Super+Shift+c**. (Typically the **Super** key is mapped to the logo key on a PC.) + +### Waybar + +Sway’s default status bar may not have all the functions you want. Fortunately Waybar is a good replacement. To install, run the follow commands. _(Note, however, that COPR is not an official Fedora repository and not supported by the Fedora Project.)_ + +``` +sudo dnf copr enable alebastr/waybar +sudo dnf install waybar +``` + +Open your _~/.config/sway/config_ file. Edit the bar configuration like this: + +``` +bar { + swaybar_command waybar +} +``` + +Reload the configuration and you’ll now see the waybar in action, as shown below. + +![][6] + +To customize the waybar, you can visit this [wiki page][7] for more details and ideas. + +### Alacritty + +Alacritty is a terminal emulator that uses the GPU for rendering, and a good replacement for _urxvt_. To install run the following lines + +``` +sudo dnf copr enable pschyska/alacritty +sudo dnf install alacritty +``` + +To enable it as default terminal emulator edit your _~/.config/sway/config_. Change this line: + +``` +set $term urxvt256c-ml +``` + +To: + +``` +set $term alacritty +``` + +Reload your configuration. + +When you open a new terminal with **Super+C**, alacritty will be open as seen in the following image: + +![][8] + +* * * + +_Photo by [Ivan Vranić][9] on [Unsplash][10]._ + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/setting-up-the-sway-window-manager-on-fedora/ + +作者:[George Luiz Maluf][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/georgelmaluf/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/12/sway-816x345.jpg +[2]: https://fedoramagazine.org/getting-started-i3-window-manager/ +[3]: https://fedoramagazine.org/wp-content/uploads/2019/11/sway_login_menu-1024x522.png +[4]: https://fedoramagazine.org/wp-content/uploads/2019/11/sway_desktop_default-1024x522.png +[5]: https://github.com/swaywm/sway/wiki +[6]: https://fedoramagazine.org/wp-content/uploads/2019/11/sway_waybar_default-1024x522.png +[7]: https://github.com/Alexays/Waybar/wiki/Configuration +[8]: https://fedoramagazine.org/wp-content/uploads/2019/11/sway_alacritty-1024x522.png +[9]: https://unsplash.com/@hvranic?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[10]: https://unsplash.com/s/photos/sway?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/sources/tech/20191217 App Highlight- Open Source Disk Partitioning Tool GParted.md b/sources/tech/20191217 App Highlight- Open Source Disk Partitioning Tool GParted.md new file mode 100644 index 0000000000..6c78a12ecb --- /dev/null +++ b/sources/tech/20191217 App Highlight- Open Source Disk Partitioning Tool GParted.md @@ -0,0 +1,116 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (App Highlight: Open Source Disk Partitioning Tool GParted) +[#]: via: (https://itsfoss.com/gparted/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +App Highlight: Open Source Disk Partitioning Tool GParted +====== + +_**Brief: GParted is an incredibly popular and free partition editor available for Linux distros. Here, we take a look at what it offers in brief.**_ + +### GParted: A Free & Open-Source GUI-based Partition Manager + +![][1] + +GParted is undoubtedly one of the [best partition managers for Linux][2] out there. The user interface is very simple and gets the job done. + +In some cases, you end up using [GParted][3] to fix or format your USB drive as well. I had a [USB disk which I couldn’t format in Ubuntu][4] using the “Disks” app – this is where GParted came to the rescue. + +So, it is a quite useful tool with a lot of good features. Let me highlight them for you. + +Warning! + +Playing with disk partitioning is a risky task. Don’t do it unless it’s absolutely necessary. Or else, you might just end up wiping the entire disk. + +### Features of GParted + +You can do a lot of things with GParted, ranging from a simple format task to important partitioning tasks. I’ll highlight the key features with some screenshots to help you know more about it before installing it. + +#### Create partition tables + +You can create a new partition table for your new disks or erase the content of your existing disk to modify the partition table. + +![][5] + +You will be able to select msdos, gpt, atari, and a lot more types of partition tables. + +#### Create, move, label, delete & modify partitions + +You can easily create, label, delete or modify the partitions with a bunch of options available within GParted. + +![][6] + +Of course, you will have to be careful about what you want to do. + +The good thing is that GParted makes sure that you do not directly apply any changes – it queues up your selected operations/tasks and asks for another final confirmation before you hit it. + +The tick mark symbol ✓on the top allows you to confirm the changes and then only your changes take into effect. + +Here’s another screenshot for the options you have available for the partitions: + +![][7] + +#### Attempt data rescue + +Apart from editing partitions, you can also try to [recover your lost data in Linux][8] using the “**Attempt Data Rescue**” feature as shown in the screenshot below. + +![][9] + +It is worth noting that you do not have this feature installed by default – you only see the option visible. So, for the data recovery feature to work, you have to install gpart separately using the following command (on Ubuntu/Debian-based distributions): + +``` +sudo apt install gpart +``` + +In addition to all the key features, it supports a wide range of storage devices and filesystems. You can learn more about it from the [list of features][10] on their official website. + +### Installing GParted on Ubuntu and other Linux distributions + +You might have GParted pre-installed. So, make sure to verify that. If you do not have it installed, you can head into the software center to get it installed. + +In case you want to use the terminal, simply type in the following command: + +``` +sudo apt install gparted +``` + +As I mentioned above, if you want the data recovery option, you should install gpart package in addition to gparted package. + +If you’re using any other Linux distribution, you can either find it in the respective software manager or simply check out the [official download instructions][11]. + +[Download GParted][11] + +**Wrapping Up** + +GParted is a very useful and important tool when it comes to dealing with disk management and partitions. However, you will have to be careful while using it for the obvious reasons. + +Have you tried GParted? Which other partitioning tool you use on Linux? Feel free to share your experiences in the comments below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/gparted/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-screenshot.png?ssl=1 +[2]: https://itsfoss.com/partition-managers-linux/ +[3]: https://gparted.org/ +[4]: https://itsfoss.com/format-usb-drive-sd-card-ubuntu/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-create-partition-table.png?ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-modify-partitions.png?ssl=1 +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-partition-options.png?ssl=1 +[8]: https://itsfoss.com/recover-deleted-files-linux/ +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-attempt-data-rescue-feature.png?ssl=1 +[10]: https://gparted.org/features.php +[11]: https://gparted.org/download.php diff --git a/translated/talk/20181018 Think global- How to overcome cultural communication challenges.md b/translated/talk/20181018 Think global- How to overcome cultural communication challenges.md new file mode 100644 index 0000000000..2e6ef612b5 --- /dev/null +++ b/translated/talk/20181018 Think global- How to overcome cultural communication challenges.md @@ -0,0 +1,93 @@ +全球化思考:怎样克服交流中的文化差异 +====== +这有一些建议帮助你的全球化开发团队能够更好地理解你们的讨论并能参与其中。 +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/people_remote_teams_world.png?itok=_9DCHEel) + +几周前,我见证了两位同事之间一次有趣的互动,他们分别是 Jason,我们的一位美国员工,和 Raj,一位来自印度的访问工作人员。 + +Raj 在印度时,他一般会通过电话参加美国中部时间上午 9 点的每日立会,现在他到美国工作了,就可以和组员们坐在同一间会议室里开会了。Jason 拦下了 Raj,说:“ Raj 你要去哪?你不是一直和我们开电话会议吗?你突然出现在会议室里我还不太适应。” Raj 听了说,“是这样吗?没问题。”就回到自己工位前准备和以前一样参加电话会议了。 + +我去找 Raj,问他为什么不去参加每日立会,Raj 说 Jason 让自己给组员们打电话参会,而与此同时,Jason 也在会议室等着 Raj 来参加立会。 + +到底是哪里出的问题?Jason 明显只是调侃 Raj 终于能来一起开会了,为什么 Raj 没能听懂呢? + +Jason 明显是在开玩笑,但 Raj 把它当真了。这就是在两人互相不了解对方文化语境时发生的一个典型误会。 + +我经常会遇到有人在电子邮件的末尾写“请复原”,最开始我很迷惑,“这有什么需要我复原的内容?”后来我才搞懂,“请复原”其实是“请回复”的意思。 + +在 Ricardo Fernandez 的TED 演讲“[如何管理跨文化团队][1]” 中,他提到了自己与一位南非同事发生的小故事。那位同事用一句“我一会给你打电话。”结束了两人的 IM 会话,Ricardo 回到办公室后就开始等这位同事的电话,十五分钟后他忍不住主动给这位同事打了电话,问他:“你不是说要给我打电话吗?”,这位同事答到:“是啊,我是说以后有机会给你打电话。”这时 Ricardo 才理解那位同事说的“一会”是“以后”的意思。 + +现在是全球化时代,我们的同事很可能不跟我们面对面接触,甚至不在同一座城市,来自不同的国家。越来越多的技术公司拥有全球化的工作场所,和来自世界各地的员工,他们有着不同的背景和经历。这种多样性使得技术公司能够在这个快速发展的科技大环境下拥有更强的竞争力。 + +但是这种地域的多样性也会给团队带来挑战。管理和维持团高性能的团队发展对于同地协作的团队来说就有着很大难度,对于有着多样背景成员的全球化团队来说,无疑更加困难。成员之间的交流会发生延迟,误解时有发生,成员之间甚至会互相怀疑,这些都会影响着公司的成功。 + +到底是什么因素让全球化交流间发生误解呢?我们可以参照 Erin Meyer 的书《[文化地图][2]》,她在书中将全球文化分为八个类型,其中美国文化被分为低语境文化,与之相对的,日本为高语境文化。 + +看到这里你可能会问,高、低语境文化到底是什么意思?美国人从小就教育孩子们简洁表达,“直言不讳”是他们的表达准则;另一边,日本人从小学习在高效处理社交线索的同时进行交流,“察言观色”是他们的交流习惯。 + +大部分亚洲国家的文化都属于高语境文化。作为一个年轻的移民国家,美国毫不意外地拥有着低语境文化。移民来自于世界各地,拥有着不同的文化背景,他们不得不选择简洁而直接的交流方式,这或许就是其拥有低语境文化的原因。 + +### 从文化语境的角度与异国同事交流的三个步骤: + +怎样面临跨文化交流中遇到的挑战?比如说一位美国人与他的日本同事交流,他更应该注重日本同事的非语言线索,同样的日本同事应当更关注美国人直接表达出的信息。如果你也面临类似的挑战,按照下面这三个步骤做,可以帮助你更有效地和异国同事交流,增进与他们的感情。 + +#### 认识到文化语境的差异 + +跨文化交流的第一步是认识到文化差异,跨文化交流从认识其他文化开始。 + +#### 尊重文化语境的差异 + +一旦你意识到了文化语境的差异会影响跨文化交流,你要做的就是尊重这些差异。在你遇到一种不同的交流方式时,学会接受差异,学会积极听取他人意见。 + +#### 调和文化语境的差异 + +只是认识和尊重差异还远远不够,你还需要学会如何调和这些差异。互相理解和换位思考可以增进差异的调和,你还要学着用它们去提高同事间的交流效率,推动生产力。 + +### 五种促进不同文化语境间交流的方法 + +为了加强组员们之间关系,这么多年来我一直在收集各种各样的方法和建议。这些方法帮助我解决了与外国组员间产生的很多交流问题,下面有其中一些例子: + +#### 与外国组员交流时尽量使用视频会议的形式 + +研究表明,交流中约 55% 的内容不是靠语言传递的。肢体语言传达着一种十分微妙的信息,你可以根据它们理解对方的意思,而视频会议中处于异地的组员们能够看到对方的肢体语言。因此,组织远程会议时我一般都会采用视频会议的形式。 + +#### 确保每位成员都有机会分享他们的想法 + +我虽然喜欢开视频会议,但不是每次都能开的成。如果视频会议对你的团队来说并不常用,大家可能要一些时间去适应,你需要积极鼓励大家参与到其中,先从进行语音会议开始。 + +我们有一个外地的组员,每次都和我们进行语音会议,和我们提到她经常会有些想法想要分享,或者想做些贡献,但是我们互相看不到,她不知道该怎样开口。如果你一直在进行语音会议,注意要给组员们足够的时间和机会分享他们的想法。 + +#### 互相学习 + +通过你身边一两名外国朋友来学习他们的文化,你可以把从一位同事身上学到的应用于所有来自这个国家的同事。我有几位南亚和南美的同事,他们帮助我理解他们的文化,而这些也使得我更加专业。 + +对编程人员来说,我建议请你全世界的同行们检查你的代码,这个过程能让你观察到其他文化中人们怎样进行反馈、劝说他人,和最终进行技术决策。 + +#### 学会感同身受 + +同理心是一段牢固关系的核心。你越能换位思考,就越容易获得信任,来建立长久的关系。你可以在每次会议开始之前和大家闲聊几句,这样大家更容易处于一个放松的状态,如果团队中有很多外国人,要确保大家都能参与进来。 + +#### 和你的外国同事们单独见面 + +保持长久关系最好的方法是和你的组员们单独见面。如果你的公司可以报销这些费用,那么努力去和组员们见面吧。和一起工作了很长时间的组员们见面能够使你们的关系更加坚固。我所在的公司就有着周期性交换员工的传统,每隔一段时间,世界各地的员工就会来到美国工作,美国员工再到其他分部工作。 + +另一种聚齐组员们的机会的研讨会。研讨会创造的不仅是学习和培训的机会,你还可以挤出一些时间和组员们培养感情。 + +在如今,全球化经济不断发展,拥有来自不同国家和地区的员工对维持一个公司的竞争力来说越来越重要。即使组员们来自世界各地,团队中会出现一些交流问题,但拥有一支国际化的高绩效团队不是问题。如果你在工作中有什么促进团队交流的小窍门,请在评论中告诉我们吧。 + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/think-global-communication-challenges + +作者:[Avindra Fernando][a] +选题:[lujun9972][b] +译者:[Valoniakim](https://github.com/Valoniakim) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/avindrafernando +[b]: https://github.com/lujun9972 +[1]: https://www.youtube.com/watch?v=QIoAkFpN8wQ +[2]: https://www.amazon.com/The-Culture-Map-Invisible-Boundaries/dp/1610392507 diff --git a/translated/tech/20181231 Easily Upload Text Snippets To Pastebin-like Services From Commandline.md b/translated/tech/20181231 Easily Upload Text Snippets To Pastebin-like Services From Commandline.md new file mode 100644 index 0000000000..1c60f5abfb --- /dev/null +++ b/translated/tech/20181231 Easily Upload Text Snippets To Pastebin-like Services From Commandline.md @@ -0,0 +1,247 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Easily Upload Text Snippets To Pastebin-like Services From Commandline) +[#]: via: (https://www.ostechnix.com/how-to-easily-upload-text-snippets-to-pastebin-like-services-from-commandline/) +[#]: author: (SK https://www.ostechnix.com/author/sk/) + +从命令行轻松将文本片段上传到类似 Pastebin 的服务中 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/12/wgetpaste-720x340.png) + +每当需要在线共享代码片段时,我们想到的第一个便是 Pastebin.com,这是 Paul Dixon 于 2002 年推出的在线文本共享网站。现在,有几种可供选择的文本共享服务可以上传和共享文本片段、错误日志、配置文件、命令输出或任何类型的文本文件。如果你碰巧经常使用各种类似于 Pastebin 的服务来共享代码,那么这对你来说确实是个好消息。向 Wgetpaste 打个招呼吧,它是一个命令行 BASH 实用程序,可轻松地将文本摘要上传到类似 pastebin 的服务中。使用 Wgetpaste 脚本,任何人都可以与自己的朋友、同事或想在类似 Unix 的系统中的命令行中查看/使用/查看代码的人快速共享文本片段。 + +### 安装 Wgetpaste + +Wgetpaste 在 Arch Linux [Community] 存储库中可用。要将其安装在 Arch Linux 及其变体(如 Antergos 和 Manjaro Linux)上,只需运行以下命令: + +``` +$ sudo pacman -S wgetpaste +``` + +对于其他发行版,请从 [Wgetpaste 网站][1] 获取源代码,并按如下所述手动安装。 + +首先下载最新的 Wgetpaste tar 文件: + +``` +$ wget http://wgetpaste.zlin.dk/wgetpaste-2.28.tar.bz2 +``` + +提取它: + +``` +$ tar -xvjf wgetpaste-2.28.tar.bz2 +``` + +它将 tar 文件的内容提取到名为 `wgetpaste-2.28` 的文件夹中。 + +转到该目录: + +``` +$ cd wgetpaste-2.28/ +``` + +将 `wgetpaste` 二进制文件复制到 `$PATH` 中,例如 `/usr/local/bin/`。 + +``` +$ sudo cp wgetpaste /usr/local/bin/ +``` + +最后,使用命令使其可执行: + +``` +$ sudo chmod +x /usr/local/bin/wgetpaste +``` + +### 将文本片段上传到类似 Pastebin 的服务中 + +使用 Wgetpaste 上传文本片段很简单。让我向你展示一些示例。 + +#### 1、上传文本文件 + +要使用 Wgetpaste 上传任何文本文件,只需运行: + +``` +$ wgetpaste mytext.txt +``` + +此命令将上传 `mytext.txt` 文件的内容。 + +示例输出: + +``` +Your paste can be seen here: https://paste.pound-python.org/show/eO0aQjTgExP0wT5uWyX7/ +``` + +![](https://www.ostechnix.com/wp-content/uploads/2018/12/wgetpaste-1.png) + +你可以通过邮件、短信、whatsapp 或 IRC 等任何媒体共享 pastebin 的 URL。拥有此 URL 的人都可以访问它,并在他们选择的 Web 浏览器中查看文本文件的内容。 + +这是 Web 浏览器中 `mytext.txt` 文件的内容: + +![](https://www.ostechnix.com/wp-content/uploads/2018/12/wgetpaste-2.png) + +你也可以使用 `tee` 命令显示粘贴的内容,而不是盲目地上传它们。 + +为此,请使用如下的 `-t` 选项。 + +``` +$ wgetpaste -t mytext.txt +``` + +![][3] + +#### 2、将文字片段上传到其他服务 + +默认情况下,Wgetpaste 会将文本片段上传到 poundpython()服务。 + +要查看支持的服务列表,请运行: + +``` +$ wgetpaste -S +``` + +示例输出: + +``` +Services supported: (case sensitive): +Name: | Url: +=============|================= +bpaste | https://bpaste.net/ +codepad | http://codepad.org/ +dpaste | http://dpaste.com/ +gists | https://api.github.com/gists +*poundpython | https://paste.pound-python.org/ +``` + +在这里,`*` 表示默认服务。 + +如你所见,Wgetpaste 当前支持五种文本共享服务。我并没有全部尝试,但是我相信所有服务都可以使用。 + +要将内容上传到其他服务,例如 bpaste.net,请使用如下所示的 `-s` 选项。 + +``` +$ wgetpaste -s bpaste mytext.txt +Your paste can be seen here: https://bpaste.net/show/5199e127e733 +``` + +#### 3、从标准输入读取输入 + +Wgetpaste 也可以从标准输入读取。 + +``` +$ uname -a | wgetpaste +``` + +此命令将上传 `uname -a` 命令的输出。 + +#### 4、上传命令及命令的输出 + +有时,你可能需要粘贴命令及其输出。为此,请在如下所示的引号内指定命令的内容。 + +``` +$ wgetpaste -c 'ls -l' +``` + +这会将命令 `ls -l` 及其输出上传到 pastebin 服务。 + +当你想让其他人清楚地知道你刚运行的确切命令及其输出时,此功能很有用。 + +![][4] + +如你在输出中看到的,我运行了 `ls -l` 命令。 + +#### 5、上载系统日志文件、配置文件 + +就像我已经说过的,我们可以上载你的系统中任何类型的文本文件,而不仅仅是普通的文本文件,例如日志文件、特定命令的输出等。例如,你刚刚更新了 Arch Linux 机器,最后系统损坏了。你问你的同事该如何解决此问题,他(她)想阅读 `pacman.log` 文件。 这是上传 `pacman.log` 文件内容的命令: + +``` +$ wgetpaste /var/log/pacman.log +``` + +与你的同事共享 pastebin URL,以便他/她可以查看 `pacman.log`,并通过查看日志文件来帮助你解决问题。 + +通常,日志文件的内容可能太长,你不希望全部共享它们。在这种情况下,只需使用 `cat` 命令读取输出,然后使用 `tail -n` 命令定义要共享的行数,最后将输出通过管道传递到 Wgetpaste,如下所示。 + +``` +$ cat /var/log/pacman.log | tail -n 50 | wgetpaste +``` + +上面的命令将仅上传 `pacman.log` 文件的“最后 50 行”。 + +#### 6、将输入网址转换为短链接 + +默认情况下,Wgetpaste 将在输出中显示完整的 pastebin URL。如果要将输入 URL 转换为短链接,只需使用 `-u` 选项。 + +``` +$ wgetpaste -u mytext.txt +Your paste can be seen here: http://tinyurl.com/y85d8gtz +``` + +#### 7、设定语言 + +默认情况下,Wgetpaste 将上传“纯文本”中的文本片段。 + +要列出指定服务支持的语言,请使用 `-L` 选项。 + +``` +$ wgetpaste -L +``` + +该命令将列出默认服务(poundpython )支持的所有语言。 + +我们可以使用 `-l` 选项来改变它。 + +``` +$ wgetpaste -l Bash mytext.txt +``` + +#### 8、在输出中禁用语法突出显示或 html + +如上所述,文本片段将以特定的语言格式(纯文本、Bash 等)显示。 + +但是,你可以更改此行为,以使用 `-r` 选项显示原始文本摘要。 + +``` +$ wgetpaste -r mytext.txt +Your raw paste can be seen here: https://paste.pound-python.org/raw/CUJhQ3jEmr2UvfmD2xCL/ +``` + +![](https://www.ostechnix.com/wp-content/uploads/2018/12/wgetpaste-5.png) + +如你在上面的输出中看到的,没有语法突出显示,没有 html 格式。只是原始输出。 + +#### 9、更改 Wgetpaste 默认值 + +所有默认值(`DEFAULT_{NICK,LANGUAGE,EXPIRATION}[_${SERVICE}]` 和 `DEFAULT_SERVICE`)都可以在 `/etc/wgetpaste.conf` 中全局更改,也可以在 `~/.wgetpaste.conf` 文件中针对每个用户更改。但是,这些文件在我的系统中默认情况下并不存在。我想我们需要手动创建它们。开发人员已经在[这里][5]和[这里][6]为这两个文件提供了示例内容。只需使用给定的样本内容手动创建这些文件,并相应地修改参数即可更改 Wgetpaste 的默认设置。 + +#### 10、获得帮助 + +要显示帮助部分,请运行: + +``` +$ wgetpaste -h +``` + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-easily-upload-text-snippets-to-pastebin-like-services-from-commandline/ + +作者:[SK][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: http://wgetpaste.zlin.dk/ +[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]: http://www.ostechnix.com/wp-content/uploads/2018/12/wgetpaste-3.png +[4]: http://www.ostechnix.com/wp-content/uploads/2018/12/wgetpaste-4.png +[5]: http://wgetpaste.zlin.dk/zlin.conf +[6]: http://wgetpaste.zlin.dk/wgetpaste.example diff --git a/sources/tech/20190225 Netboot a Fedora Live CD.md b/translated/tech/20190225 Netboot a Fedora Live CD.md similarity index 53% rename from sources/tech/20190225 Netboot a Fedora Live CD.md rename to translated/tech/20190225 Netboot a Fedora Live CD.md index 2767719b8c..6cae3ce9d4 100644 --- a/sources/tech/20190225 Netboot a Fedora Live CD.md +++ b/translated/tech/20190225 Netboot a Fedora Live CD.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (robsean) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) @@ -7,23 +7,23 @@ [#]: via: (https://fedoramagazine.org/netboot-a-fedora-live-cd/) [#]: author: (Gregory Bartholomew https://fedoramagazine.org/author/glb/) -Netboot a Fedora Live CD +网络启动一个 Fedora Live CD ====== ![](https://fedoramagazine.org/wp-content/uploads/2019/02/netboot-livecd-816x345.jpg) -[Live CDs][1] are useful for many tasks such as: +[Live CD][1] 对于很多任务是很有用的,例如: - * installing the operating system to a hard drive - * repairing a boot loader or performing other rescue-mode operations - * providing a consistent and minimal environment for web browsing - * …and [much more][2]. + * 将操作系统安装到一个硬盘驱动器 + * 修复一个启动加载程序或执行其它救援模式操作 + * 为网络浏览提供一个相适应的最小环境 + * …以及[更多的东西][2]。 -As an alternative to using DVDs and USB drives to store your Live CD images, you can upload them to an [iSCSI][3] server where they will be less likely to get lost or damaged. This guide shows you how to load your Live CD images onto an iSCSI server and access them with the [iPXE][4] boot loader. +因为使用 DVD 和 USB 驱动器来存储你的 Live CD 镜像是一个替代方案,你可以上传它们到一个不太可能丢失或损坏的 [iSCSI][3] 服务器中。这个指南向你展示如何加载你的 Live CD 镜像到一个 ISCSI 服务器上,并使用 [iPXE][4] 启动加载程序来访问它们。 -### Download a Live CD Image +### 下载一个 Live CD 镜像 ``` $ MY_RLSE=27 @@ -32,11 +32,11 @@ $ MY_NAME=fc$MY_RLSE $ wget -O $MY_NAME.iso https://dl.fedoraproject.org/pub/archive/fedora/linux/releases/$MY_RLSE/Workstation/x86_64/iso/$MY_LIVE ``` -The above commands download the Fedora-Workstation-Live-x86_64-27-1.6.iso Fedora Live image and save it as fc27.iso. Change the value of MY_RLSE to download other archived versions. Or you can browse to to download the latest Fedora live image. Versions prior to 21 used different naming conventions, and must be [downloaded manually here][5]. If you download a Live CD image manually, set the MY_NAME variable to the basename of the file without the extension. That way the commands in the following sections will reference the correct file. +上面的命令下载 Fedora-Workstation-Live-x86_64-27-1.6.iso Fedora Live 镜像,并保存为 fc27.iso 。更改 MY_RLSE 的值来下载其它档案版本。或者,你可以浏览 来下载最新的 Fedora live 镜像。在21之前的版本使用不同的命名约定,必需[在这里手动下载][5]。如果你手动下载一个 Live CD 镜像,设置 MY_NAME 变量为不带有扩展名的文件的基本名称。用此方法,下面部分中命令将引用正确的文件。 -### Convert the Live CD Image +### 转换 Live CD 镜像 -Use the livecd-iso-to-disk tool to convert the ISO file to a disk image and add the netroot parameter to the embedded kernel command line: +使用 livecd-iso-to-disk 工具来转换 ISO 文件为一个磁盘镜像,并添加 netroot 参数到嵌入的内核命令行: ``` $ sudo dnf install -y livecd-tools @@ -49,18 +49,18 @@ $ sudo livecd-iso-to-disk --format --extra-kernel-args netroot=iscsi:$MY_SRVR::: $ sudo losetup -d $MY_LOOP ``` -### Upload the Live Image to your Server +### 上传 Live 镜像到你的服务器 -Create a directory on your iSCSI server to store your live images and then upload your modified image to it. +在你的 ISCSI 服务器上创建一个目录来存储你的 live 镜像,随后上传你修改的镜像到其中。 -**For releases 21 and greater:** +**对于 21 及更高发布版本:** ``` $ MY_FLDR=/images $ scp $MY_NAME.img $MY_SRVR:$MY_FLDR/ ``` -**For releases prior to 21:** +**对于 21 以前发布版本:** ``` $ MY_FLDR=/images @@ -71,9 +71,9 @@ $ sudo dd status=none if=${MY_LOOP}p1 | ssh $MY_SRVR "dd of=$MY_FLDR/$MY_NAME.im $ sudo losetup -d $MY_LOOP ``` -### Define the iSCSI Target +### 定义 iSCSI 目标 -Run the following commands on your iSCSI server: +在你的 iSCSI 服务器上运行下面的命令: ``` $ sudo -i @@ -91,11 +91,11 @@ END # tgt-admin --update ALL ``` -### Create a Bootable USB Drive +### 创建一个可启动 USB 驱动器 -The [iPXE][4] boot loader has a [sanboot][6] command you can use to connect to and start the live images hosted on your iSCSI server. It can be compiled in many different [formats][7]. The format that works best depends on the type of hardware you’re running. As an example, the following instructions show how to [chain load][8] iPXE from [syslinux][9] on a USB drive. +[iPXE][4] 启动加载程序有一个 [sanboot][6] 命令,你可以使用它来连接,并启动你 ISCSI 服务器上运行的live 镜像。它可以用很多不同的[格式][7]编译。最好的工作格式依赖于你正在运行的硬件。例如,下面的说明向你展示如何在一个 USB 驱动器上从 [syslinux][9] 中 [链式加载][8] iPXE。 -First, download iPXE and build it in its lkrn format. This should be done as a normal user on a workstation: +首先,下载 iPXE ,并以它的 lkrn 格式构建。这应该作为一个工作站上的普通用户完成: ``` $ sudo dnf install -y git @@ -107,7 +107,7 @@ $ make bin/ipxe.lkrn $ cp bin/ipxe.lkrn /tmp ``` -Next, prepare a USB drive with a MSDOS partition table and a FAT32 file system. The below commands assume that you have already connected the USB drive to be formatted. **Be careful that you do not format the wrong drive!** +接下来,准备一个带有一个 MSDOS 分区表和一个 FAT32 文件系统的 USB 驱动器。下面的命令假设你已经连接将要格式化的 USB 驱动器。**注意:你要格式正确的驱动器!** ``` $ sudo -i @@ -119,7 +119,7 @@ $ sudo -i # mkfs -t vfat -F 32 ${MY_USB}1 ``` -Finally, install syslinux on the USB drive and configure it to chain load iPXE: +最后,在 USB 驱动器上安装并配置 syslinux ,来链式加载 iPXE : ``` # dnf install -y syslinux-nonlinux @@ -146,16 +146,16 @@ END # umount ${MY_USB}1 ``` -You should be able to use this same USB drive to netboot additional iSCSI targets simply by editing the syslinux.cfg file and adding additional menu entries. +通过简单地编辑 syslinux.cfg 文件,并添加附加的菜单入口,你应该能够使用这同一个 USB 驱动器来网络启动附加的 ISCSI 目标。 -This is just one method of loading iPXE. You could install syslinux directly on your workstation. Another option is to compile iPXE as an EFI executable and place it directly in your [ESP][10]. Yet another is to compile iPXE as a PXE loader and place it on your TFTP server to be referenced by DHCP. The best option depends on your environment. +这仅是加载 IPXE 的一种方法。你可以直接在你的工作站上安装 syslinux 。再一种选项是编译 iPXE 为一个 EFI 可执行文件,并直接放置它到你的 [ESP][10]中。又一种选项是编译 iPXE 为一个 PXE 加载器,并放置它到你的能够被 DHCP 引用的 TFTP 服务器。最佳的选项依赖于的环境 -### Final Notes +### 最后说明 - * You may want to add the –filename \EFI\BOOT\grubx64.efi parameter to the sanboot command if you compile iPXE in its EFI format. - * It is possible to create custom live images. Refer to [Creating and using live CD][11] for more information. - * It is possible to add the –overlay-size-mb and –home-size-mb parameters to the livecd-iso-to-disk command to create live images with persistent storage. However, if you have multiple concurrent users, you’ll need to set up your iSCSI server to manage separate per-user writeable overlays. This is similar to what was shown in the “[How to Build a Netboot Server, Part 4][12]” article. - * The live images support a persistenthome option on their kernel command line (e.g. persistenthome=LABEL=HOME). Used together with CHAP-authenticated iSCSI targets, the persistenthome option provides an interesting alternative to NFS for centralized home directories. + * 如果你以 IPXE 的 EFI 格式编译 IPXE ,你可能想添加 –filename \EFI\BOOT\grubx64.efi 参数到 sanboot 命令。 + * 能够创建自定义 live 镜像。更多信息参考[创建和使用 live CD][11] 。 + * 有可能添加 –overlay-size-mb 和 –home-size-mb 参数到 livecd-iso-to-disk 命令来创建永久存储的 live 镜像。然而,如果你有多个并发用户,你将需要设置你的 ISCSI 服务器来管理独立的每个用户可写覆盖。这与 “[如何构建一个网络启动服务器,部分 4][12]” 一文所示类似。 + * Live 镜像在它们的内核命令行中支持一个 persistenthome 选项(例如, persistenthome=LABEL=HOME)。与经过 CHAP 身份验证的 iSCSI 目标一起使用,对于集权控制主目录,persistenthome 选项为 NFS 提供一个有趣的替代方案。 @@ -166,7 +166,7 @@ via: https://fedoramagazine.org/netboot-a-fedora-live-cd/ 作者:[Gregory Bartholomew][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) +译者:[robsean](https://github.com/robsean) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -185,3 +185,4 @@ via: https://fedoramagazine.org/netboot-a-fedora-live-cd/ [10]: https://en.wikipedia.org/wiki/EFI_system_partition [11]: https://docs.fedoraproject.org/en-US/quick-docs/creating-and-using-a-live-installation-image/#proc_creating-and-using-live-cd [12]: https://fedoramagazine.org/how-to-build-a-netboot-server-part-4/ + diff --git a/translated/tech/20190322 Easy means easy to debug.md b/translated/tech/20190322 Easy means easy to debug.md new file mode 100644 index 0000000000..58ac5ffcf6 --- /dev/null +++ b/translated/tech/20190322 Easy means easy to debug.md @@ -0,0 +1,74 @@ +[#]: collector: (lujun9972) +[#]: translator: ( luming) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Easy means easy to debug) +[#]: via: (https://arp242.net/weblog/easy.html) +[#]: author: (Martin Tournoij https://arp242.net/) + +简单就是易于调试 +====== +对于框架、库或者工具来说,怎样做才算是“简单”?也许有很多的定义,但我的理解通常是易于调试。我经常见到人们宣传某个特定的程序、框架、库、文件格式是简单的,因为它们会说“看,我只需要这么一点工作量就能够完成某项工作,这太简单了”。非常好,但并不完善。 + +你可能只编写一次软件,但几乎总要经历好几个调试周期。注意我说的调试周期并不意味着“代码里面有 bug 你需要修复”,而是说“我需要再看一下这份代码来修复 bug”。为了调试代码,你需要理解它,因此“易于调试”延伸来讲就是“易于理解”。 + +抽象使得程序易于编写,但往往是以难以理解为代价。有时候这是一个很好的折中,但通常不是。大体上,如果能使程序在日后易于理解和调试,我很乐意花更多的时间来写一些东西,因为这样可以省时间。 + +简洁并不是让程序易于调试的唯一方法,但它也许是最重要的。良好的文档也是,但不幸的是它太少了。(注意,质量并不取决于字数!) + +这种影响是真是存在的。难以调试的程序会有更多的 bug,即使最初的 bug 数量与易于调试的程序完全相同,这简简单单是因为修复 bug 更加困难、更花时间。 + +在公司的环境中,把时间花在难以修复的 bug 上通常被认为是不划算的投资。而在开源的环境下,人们花的时间会更少。(大多数项目都有一个或多个定期的维护者,但成百上千的贡献者提交的仅只是几个补丁) + +这并不全是 1974 年由 Brian W. Kernighan 和 P. J. Plauger 合著的小说《编程风格的元素》中的观点: + +> 每个人都知道调试比起编写程序困难两倍。当你写程序的时候耍小聪明,那么将来应该怎么去调试? + +我见过许多写起来精妙,但却导致难以调试的代码。我会在下面列出几种样例。争论这些东西本身有多坏并不是我的本意,我仅想强调对于“易于使用”和“易于调试”之间的折中。 + * ORM对象关系映射 库可以让数据库查询变得简单,代价是一旦你想解决某个问题,事情就变得难以理解。 + +* 许多测试框架让调试变得困难。Ruby 的 rspec 就是一个很好的例子。有一次我不小心使用错了,结果花了很长时间搞清楚哪里出了问题(因为它给出错误提示非常含糊)。 + +我在《[测试并非万能][1]》这篇文章中写了更多关于以上的例子。 + +* 我用过的许多 JavaScript 框架都很难完全理解。Clever(LCTT 译注:一种 JS 框架)的声明语句一向很有逻辑,直到某条语句和你的预期不符,这时你就只能指望 Stack Overflow 上的某篇文章或 GitHub 上的某个回帖来帮助你了。 + +这些函数库确实让任务变得非常简单,使用它们也没有什么错。但通常人们都过于关注“易于使用”而忽视了“易于调试”这一点。 + +* Docker 非常棒,并且让许多事情变得非常简单,直到你看到了这条提示: +``` + ERROR: for elasticsearch Cannot start service elasticsearch: +oci runtime error: container_linux.go:247: starting container process caused "process_linux.go:258: +applying cgroup configuration for process caused \"failed to write 898 to cgroup.procs: write +/sys/fs/cgroup/cpu,cpuacct/docker/b13312efc203e518e3864fc3f9d00b4561168ebd4d9aad590cc56da610b8dd0e/cgroup.procs: +invalid argument\"" +``` +或者这条: +``` +ERROR: for elasticsearch Cannot start service elasticsearch: EOF +``` +那么...现在看起来呢? +* `Systemd` 比起 `SysV`、`init.d` 脚本更加简单,因为编写 `systemd` 单元文件比起编写 `shell` 脚本更加方便。这也是 Lennart Poetterin 在他的 [systemd 神话][2] 中解释 `systemd` 为何简单时使用的论点。 + +我非常赞同 Poettering 的观点——也可以看 [shell 脚本陷阱][3] 这篇文章。但是这种角度并不全面。单元文件简单的背后意味着 `systemd` 作为一个整体要复杂的多,并且用户确实会受到它的影响。看看我遇到的这个[问题][4]和为它所做的[修复][5]。看起来很简单吗? + + +-------------------------------------------------------------------------------- + +via: https://arp242.net/weblog/easy.html + +作者:[Martin Tournoij][a] +选题:[lujun9972][b] +译者:[LuuMing](https://github.com/LuuMing) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://arp242.net/ +[b]: https://github.com/lujun9972 +[1]: https://www.arp242.net/testing.html +[2]: http://0pointer.de/blog/projects/the-biggest-myths.html +[3]:https://www.arp242.net/shell-scripting-trap.html +[4]:https://unix.stackexchange.com/q/185495/33645 +[5]:https://cgit.freedesktop.org/systemd/systemd/commit/?id=6e392c9c45643d106673c6643ac8bf4e65da13c1 \ No newline at end of file diff --git a/translated/tech/20190513 How To Set Password Complexity On Linux.md b/translated/tech/20190513 How To Set Password Complexity On Linux.md new file mode 100644 index 0000000000..9e70171824 --- /dev/null +++ b/translated/tech/20190513 How To Set Password Complexity On Linux.md @@ -0,0 +1,189 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How To Set Password Complexity On Linux?) +[#]: via: (https://www.2daygeek.com/how-to-set-password-complexity-policy-on-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +Linux 如何设置密码复杂度? +====== + +对于 Linux 系统管理员来说,用户管理是最重要的事之一。这涉及到很多因素,实现强密码策略是用户管理的其中一个方面。移步后面的 URL 查看如何 [在 Linux 上生成一个强密码][1]。它会限制系统未授权的用户的访问。 + +所有人都知道 Linux 的默认策略很安全,然而我们还是要做一些微调,这样才更安全。弱密码有安全隐患,因此,请特别注意。移步后面的 URL 查看生成的强密码的 [密码长度和分值][2]。本文将教你在 Linux 中如何实现最安全的策略。 + +在大多数 Linux 系统中,我们可以用 PAM(pluggable authentication module,译注:可插拔认证模块)来加强密码策略。在下面的路径可以找到这个文件。 + +在红帽系列的系统中,路径:`/etc/pam.d/system-auth`。 + +Debian 系列的系统中,路径:`/etc/pam.d/common-password`。 + +关于默认的密码过期时间,可以在 `/etc/login.defs` 文件中查看详细信息。 + +为了更好理解,我摘取了文件的部分内容: + +``` +# vi /etc/login.defs + +PASS_MAX_DAYS 99999 +PASS_MIN_DAYS 0 +PASS_MIN_LEN 5 +PASS_WARN_AGE 7 +``` + +**详细解释:** + + * **`PASS_MAX_DAYS:`**` ` 一个密码可使用的最大天数。 + * **`PASS_MIN_DAYS:`**` ` 两次密码修改之间最小的间隔天数。 + * **`PASS_MIN_LEN:`**` ` 密码最小长度。 + * **`PASS_WARN_AGE:`**` ` 密码过期前给出警告的天数。 + + + +我们将会展示在 Linux 中如何实现下面的 11 个密码策略。 + + * 一个密码可使用的最大天数 + * 两次密码修改之间最小的间隔天数 + * 密码过期前给出警告的天数 + * 密码历史记录/拒绝重复使用密码 + * 密码最小长度 + * 最少的大写字母个数 + * 最少的小写字母个数 + * 最少的数字个数 + * 最少的其他字符(符号)个数 + * 账号锁定 — 重试 + * 账号解锁时间 + +### 密码可使用的最大天数是什么? + +这一参数限制一个密码可使用的最大天数。它强制用户在过期前修改他/她的密码。如果他们忘记修改,那么他们会登录不了系统。他们需要联系管理员才能正常登录。这个参数可以在 `/etc/login.defs` 文件中设置。我把这个参数设置为 `90 天`。 + +``` +# vi /etc/login.defs + +PASS_MAX_DAYS 90 +``` + +### 密码最小天数是什么? + +这个参数限制两次修改之间的最少天数。举例来说,如果这个参数被设置为 15 天,用户今天修改了密码,那么在 15 天之内他都不能修改密码。这个参数可以在 `/etc/login.defs` 文件中设置。我设置为 `15 天`。 + +``` +# vi /etc/login.defs + +PASS_MIN_DAYS 15 +``` + +### 密码警告天数是什么? + +这个参数控制密码警告的前置天数,在密码即将过期时会给用户警告提示。在警告天数结束前,用户会收到日常警告提示。这可以提醒用户在密码过期前修改他们的密码,否则我们就需要联系管理员来解锁密码。这个参数可以在 `/etc/login.defs` 文件中设置。我设置为 `10 天`。 + +``` +# vi /etc/login.defs + +PASS_WARN_AGE 10 +``` + +**注意:** 上面的所有参数仅对新账号有效,对已存在的账号无效。 + +### 密码历史或拒绝重复使用密码是什么? + +这个参数控制密码历史。它记录曾经使用过的密码(禁止使用的曾用密码的个数)。当用户设置新的密码时,它会检查密码历史,如果他们要设置的密码是一个曾经使用过的旧密码,将会发出警告提示。这个参数可以在 `/etc/pam.d/system-auth` 文件中设置。我设置密码历史为 `5`。 + +``` +# vi /etc/pam.d/system-auth + +password sufficient pam_unix.so md5 shadow nullok try_first_pass use_authtok remember=5 +``` + +### 密码最小长度是什么? + +这个参数表示密码的最小长度。当用户设置新密码时,系统会检查这个参数,如果新设的密码长度小于这个参数设置的值,会收到警告提示。这个参数可以在 `/etc/pam.d/system-auth` 文件中设置。我设置最小密码长度为 `12`。 + +``` +# vi /etc/pam.d/system-auth + +password requisite pam_cracklib.so try_first_pass retry=3 minlen=12 +``` + +**try_first_pass retry=3** : 在密码设置交互界面,用户有 3 次机会重设密码。 + +### 设置最少的大写字母个数? + +这个参数表示密码中至少需要的大写字母的个数。这些是密码长度增长参数,可以让密码更长。当用户设置新密码时,系统会检查这个参数,如果密码中没有大写字母,会收到警告提示。这个参数可以在 `/etc/pam.d/system-auth` 文件中设置。我设置密码(中大写字母)的最小长度为 `1` 个字母。 + +``` +# vi /etc/pam.d/system-auth + +password requisite pam_cracklib.so try_first_pass retry=3 minlen=12 ucredit=-1 +``` + +### 设置最少的小写字母个数? + +这个参数表示密码中至少需要的小写字母的个数。这些是密码长度增长参数,可以让密码更长。当用户设置新密码时,系统会检查这个参数,如果密码中没有小写字母,会收到警告提示。这个参数可以在 `/etc/pam.d/system-auth` 文件中设置。我设置为 `1` 个字母。 + +``` +# vi /etc/pam.d/system-auth + +password requisite pam_cracklib.so try_first_pass retry=3 minlen=12 lcredit=-1 +``` + +### 设置密码中最少的数字个数? + +这个参数表示密码中至少需要的数字的个数。这些是密码长度增长参数,可以让密码更长。当用户设置新密码时,系统会检查这个参数,如果密码中没有数字,会收到警告提示。这个参数可以在 `/etc/pam.d/system-auth` 文件中设置。我设置为 `1`。 + +``` +# vi /etc/pam.d/system-auth + +password requisite pam_cracklib.so try_first_pass retry=3 minlen=12 dcredit=-1 +``` + +### 设置密码中最少的其他字符(符号)个数? + +这个参数表示密码中至少需要的特殊符号的个数。这些是密码长度增长参数,可以让密码更长。当用户设置新密码时,系统会检查这个参数,如果密码中没有特殊符号,会收到警告提示。这个参数可以在 `/etc/pam.d/system-auth` 文件中设置。我设置为 `1` 个字符。 + +``` +# vi /etc/pam.d/system-auth + +password requisite pam_cracklib.so try_first_pass retry=3 minlen=12 ocredit=-1 +``` + +### 设置账号锁定? + +这个参数控制用户连续登录失败的最大次数。当达到设定的连续失败登录次数阈值时,锁定账号。这个参数可以在 `/etc/pam.d/system-auth` 文件中设置。 + +``` +# vi /etc/pam.d/system-auth + +auth required pam_tally2.so onerr=fail audit silent deny=5 +account required pam_tally2.so +``` + +### 设定账号解锁时间? + +这个参数表示用户解锁时间。如果一个用户账号在连续认证失败后被锁定了,当过了设定的解锁时间后,就会解锁。设置被锁定中的账号的解锁时间(900 秒 = 15分钟)。这个参数可以在 `/etc/pam.d/system-auth` 文件中设置。 + +``` +# vi /etc/pam.d/system-auth + +auth required pam_tally2.so onerr=fail audit silent deny=5 unlock_time=900 +account required pam_tally2.so +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/how-to-set-password-complexity-policy-on-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/5-ways-to-generate-a-random-strong-password-in-linux-terminal/ +[2]: https://www.2daygeek.com/how-to-check-password-complexity-strength-and-score-in-linux/ diff --git a/translated/tech/20191023 How to program with Bash- Loops.md b/translated/tech/20191023 How to program with Bash- Loops.md new file mode 100644 index 0000000000..5d051aafcd --- /dev/null +++ b/translated/tech/20191023 How to program with Bash- Loops.md @@ -0,0 +1,337 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to program with Bash: Loops) +[#]: via: (https://opensource.com/article/19/10/programming-bash-loops) +[#]: author: (David Both https://opensource.com/users/dboth) + +Bash 编程教程之循环 +====== +本文是 bash 编程系列(3 部分)的最后一篇,来学习使用循环执行迭代的操作。 +![arrows cycle symbol for failing faster][1] + +Bash 是一种强大的用于命令行和 shell 脚本里的编程语言。本系列的三部分都是基于我的 [Linux 自学课程三卷][2] 写的,探索怎么用 CLI(command-line interface)进行 bash 编程。本系列的 [第一篇文章][3] 讨论了 bash 编程的一些简单命令行操作,如使用变量和控制操作符。[第二篇文章][4] 探讨了文件、字符串、数字等类型和各种各样在执行流中提供控制逻辑的的逻辑运算符,还有 bash 中不同种类的扩展。本文是第三篇(也是最后一篇),意在考察在各种迭代的操作中使用循环以及怎么合理控制循环。 + +### 循环 + +我使用过的所有编程语言都有很多种循环结构来用来执行重复的操作。我经常使用 for 循环,然而我发现 while 和 until 循环也很有用处。 + +#### for 循环 + +我的理解是,**for** 命令在 bash 中的实现比大部分语言灵活,因为它可以处理非数字的值;与之形成对比的是,诸如标准 C 语言的 **for** 循环只能处理数字类型的值。 + +Bash 版的 **for** 命令基本的结构很简单: + + +``` +`for Var in list1 ; do list2 ; done` +``` + +解释一下:“对于 list1 中的每一个值,把 **$Var** 设置为那个值,使用该值执行 list2 中的程序语句;list1 中的值都执行完后,整个循环结束,退出循环。” list1 中的值可以是一个简单的显式字符串值,也可以是一个命令执行后的结果(译注:**\` \`** 包含的命令执行的结果,本系列第二篇文章中有描述)。我经常使用这种结构。 + +确认 **~/testdir** 仍然是当前的工作目录(PWD)。删除目录下所有东西,来看下这个显式写出值列表的 **for** 循环的简单的示例。这个列表中的值是字母值 — 但是不要忘了,在 bash 中所有的变量都是 string 或者可以被当成 string 来处理。 + + +``` +[student@studentvm1 testdir]$ rm * +[student@studentvm1 testdir]$ for I in a b c d 1 2 3 4 ; do echo $I ; done +a +b +c +d +1 +2 +3 +4 +``` + +给变量赋予更有意义的名字,变成前面版本的进阶版: + + +``` +[student@studentvm1 testdir]$ for Dept in "Human Resources" Sales Finance "Information Technology" Engineering Administration Research ; do echo "Department $Dept" ; done +Department Human Resources +Department Sales +Department Finance +Department Information Technology +Department Engineering +Department Administration +Department Research +``` + +创建几个目录(创建时显示一些处理信息): + + +``` +[student@studentvm1 testdir]$ for Dept in "Human Resources" Sales Finance "Information Technology" Engineering Administration Research ; do echo "Working on Department $Dept" ; mkdir "$Dept"  ; done +Working on Department Human Resources +Working on Department Sales +Working on Department Finance +Working on Department Information Technology +Working on Department Engineering +Working on Department Administration +Working on Department Research +[student@studentvm1 testdir]$ ll +total 28 +drwxrwxr-x 2 student student 4096 Apr  8 15:45  Administration +drwxrwxr-x 2 student student 4096 Apr  8 15:45  Engineering +drwxrwxr-x 2 student student 4096 Apr  8 15:45  Finance +drwxrwxr-x 2 student student 4096 Apr  8 15:45 'Human Resources' +drwxrwxr-x 2 student student 4096 Apr  8 15:45 'Information Technology' +drwxrwxr-x 2 student student 4096 Apr  8 15:45  Research +drwxrwxr-x 2 student student 4096 Apr  8 15:45  Sales +``` + +在 **mkdir** 语句中 **$Dept** 变量必须用引号包裹起来;否则名字中间有空格(如 `Information Technology`)会被当做两个独立的目录处理。我一直信奉的一条实践规则:所有的文件和目录都应该为一个单词(中间没有空格)。虽然大部分现代的操作系统可以处理名字中间有空格的情况,但是系统管理员需要花费额外的精力去确保脚本和 CLI 程序能正确处理这些特例。(尽管你因为不知道将要处理什么样的文件而烦恼,但是脚本和 CLI 应该已经把这些特例考虑在内了。) + +再次删除 **~/testdir** 下的所有东西 — 再运行一次下面的命令: + + +``` +[student@studentvm1 testdir]$ rm -rf * ; ll +total 0 +[student@studentvm1 testdir]$ for Dept in Human-Resources Sales Finance Information-Technology Engineering Administration Research ; do echo "Working on Department $Dept" ; mkdir "$Dept"  ; done +Working on Department Human-Resources +Working on Department Sales +Working on Department Finance +Working on Department Information-Technology +Working on Department Engineering +Working on Department Administration +Working on Department Research +[student@studentvm1 testdir]$ ll +total 28 +drwxrwxr-x 2 student student 4096 Apr  8 15:52 Administration +drwxrwxr-x 2 student student 4096 Apr  8 15:52 Engineering +drwxrwxr-x 2 student student 4096 Apr  8 15:52 Finance +drwxrwxr-x 2 student student 4096 Apr  8 15:52 Human-Resources +drwxrwxr-x 2 student student 4096 Apr  8 15:52 Information-Technology +drwxrwxr-x 2 student student 4096 Apr  8 15:52 Research +drwxrwxr-x 2 student student 4096 Apr  8 15:52 Sales +``` + +假设现在有个需求,需要列出一台 Linux 机器上所有的 RPM 包并对每个包附上简短的描述。我为North Carolina 州工作的时候,曾经遇到过这种需求。由于当时州代理处不允许使用开源的工具,而且我对 Linux 不够熟悉,对技术一窍不通的老板(PHB)需要我列出我计算机上安装的所有软件,这样他们就可以“查看“计算机上有没有安装异常的软件了。 + +你怎么实现它?有一种方法是,已知 **rpm –qa** 命令提供了 RPM 包的完整描述,包括 PHB 想要的东西:软件名称和概要描述。一步步执行出最后的结果。首先,列出所有的 RPM 包: + + +``` +[student@studentvm1 testdir]$ rpm -qa +perl-HTTP-Message-6.18-3.fc29.noarch +perl-IO-1.39-427.fc29.x86_64 +perl-Math-Complex-1.59-429.fc29.noarch +lua-5.3.5-2.fc29.x86_64 +java-11-openjdk-headless-11.0.ea.28-2.fc29.x86_64 +util-linux-2.32.1-1.fc29.x86_64 +libreport-fedora-2.9.7-1.fc29.x86_64 +rpcbind-1.2.5-0.fc29.x86_64 +libsss_sudo-2.0.0-5.fc29.x86_64 +libfontenc-1.1.3-9.fc29.x86_64 +<snip> +``` + +用 **sort** 和 **uniq** 命令对列表进行排序和打印去重后的结果(有些已安装的 RPM 包具有相同的名字:) + + +``` +[student@studentvm1 testdir]$ rpm -qa | sort | uniq +a2ps-4.14-39.fc29.x86_64 +aajohan-comfortaa-fonts-3.001-3.fc29.noarch +abattis-cantarell-fonts-0.111-1.fc29.noarch +abiword-3.0.2-13.fc29.x86_64 +abrt-2.11.0-1.fc29.x86_64 +abrt-addon-ccpp-2.11.0-1.fc29.x86_64 +abrt-addon-coredump-helper-2.11.0-1.fc29.x86_64 +abrt-addon-kerneloops-2.11.0-1.fc29.x86_64 +abrt-addon-pstoreoops-2.11.0-1.fc29.x86_64 +abrt-addon-vmcore-2.11.0-1.fc29.x86_64 +<snip> +``` + +以上命令得到了想要的 RPM 列表,因此你可以把这个列表作为一个循环的输入信息,循环最终会打印每个 RPM 包的详细信息: + + +``` +[student@studentvm1 testdir]$ for RPM in `rpm -qa | sort | uniq` ; do rpm -qi $RPM ; done +``` + +这段代码产出了多余的信息。当循环结束后, 下一步就是提取出 PHB 需要的信息。因此,添加一个 **egrep** 命令用来搜索匹配 **^Name** 或 **^Summary** 的行。脱字符(^)表示行首,整个命令表示显示所有以 Name 或 Summary 开头的行。 + + +``` +[student@studentvm1 testdir]$ for RPM in `rpm -qa | sort | uniq` ; do rpm -qi $RPM ; done | egrep -i "^Name|^Summary" +Name        : a2ps +Summary     : Converts text and other types of files to PostScript +Name        : aajohan-comfortaa-fonts +Summary     : Modern style true type font +Name        : abattis-cantarell-fonts +Summary     : Humanist sans serif font +Name        : abiword +Summary     : Word processing program +Name        : abrt +Summary     : Automatic bug detection and reporting tool +<snip> +``` + +在上面的命令中你可以试试用 **grep** 代替 **egrep** ,你会发现用 **grep** 不能得到正确的结果。你可以通过管道把命令结果用 **less** 过滤下。最终命令像这样: + + +``` +[student@studentvm1 testdir]$ for RPM in `rpm -qa | sort | uniq` ; do rpm -qi $RPM ; done | egrep -i "^Name|^Summary" > RPM-summary.txt +``` + +这个命令行程序在同一行中用到了管道、重定向和 **for** 循环。它把你 CLI 程序的结果重定向到了一个文件,这个文件可以在邮件中使用或在其他地方作为输入使用。这个一次一步构建程序的过程让你能看到每步的结果,以此来确保整个程序以你期望的流程进行且输出你想要的结果。 + +PHB 最终收到了超过 1900 个独立 RPM 包的清单,我严重怀疑根本就没人去读它。我给了他们想要的东西,没有从他们嘴里听到过任何关于 RPM 包的信息。 + +### 其他循环 + +Bash 中还有两种其他类型的循环结构:**while** 和 **until** 结构,两者在语法和功能上都类似。这些循环结构的基础语法很简单: + + +``` +while [ expression ] ; do list ; done +``` + +逻辑解释:表达式(expression)结果为 true 时,执行程序语句 `list`。表达式结果为 false 时,退出循环。 + + +``` +until [ expression ] ; do list ; done +``` + +逻辑解释:直到表达式的结果为 true,执行程序语句 `list`。当表达式结果为 true 时,退出循环。 + +#### While 循环 + +**while** 循环用于当逻辑表达式结果为 true 时执行一系列程序语句。假设你的 PWD 仍是 **~/testdir** 。最简单的 **while** 循环会一直运行下去。下面格式的条件语句永远以 `true` 作为返回。你也可以用简单的 `1` 代替 `true` — 结果一样 — 但是这解释了 true 表达式的用法。 + + +``` +[student@studentvm1 testdir]$ X=0 ; while [ true ] ; do echo $X ; X=$((X+1)) ; done | head +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +[student@studentvm1 testdir]$ +``` + +既然你已经学了 CLI 的各部分知识,那就让它变得更有用处。首先,为了防止变量 **$X** 在前面的程序或 CLI 命令执行后有遗留的值,设置 **$X** 的值为 0。然后,因为逻辑表达式 **[ true ]** 的结果永远是 1,即 true,在 **do** 和 **done** 中间的程序指令列表会一直执行 — 或者直到你按下 **Ctrl+C** 抑或发送一个 `signal 2` 给程序。那些程序指令是算法扩展,用来打印变量 **$X** 当前的值并加 1. + +[系统管理员的 Linux 哲学][5] 的信条之一是追求优雅,实现优雅的一种方式就是简化。你可以用操作符 **++** 来简化这个程序。在第一个例子中,变量当前的值被打印出来,然后变量的值增加了。可以在变量后加一个 **++** 来表示这个逻辑: + + +``` +[student@studentvm1 ~]$ X=0 ; while [ true ] ; do echo $((X++)) ; done | head +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +``` + +现在删掉程序最后的 **| head** 再运行一次。在这个版本中,变量在值被打印之前就自增了。这是通过在变量之前添加 **++** 操作符实现的。你能看出区别吗? + + +``` +[student@studentvm1 ~]$ X=0 ; while [ true ] ; do echo $((++X)) ; done | head +1 +2 +3 +4 +5 +6 +7 +8 +9 +``` + +你已经把打印变量的值和自增简化到了一条语句。类似 **++** 操作符, 也有 **--** 操作符。你需要一个在循环到某个特定数字时终止循环的方法。把 true 表达式换成一个数字比较表达式来实现它。写一个循环到 5 终止的程序。在下面的示例代码中,你可以看到 **-le** 是 ”小于或等于“ 的数字逻辑操作符。整个语句的意思:只要 **$X** 的值小于或等于 5,循环就一直运行。当 **$X** 增加到 6时,循环终止。 + + +``` +[student@studentvm1 ~]$ X=0 ; while [ $X -le 5 ] ; do echo $((X++)) ; done +0 +1 +2 +3 +4 +5 +[student@studentvm1 ~]$ +``` + +#### Until 循环 + + + +*until** 命令非常像 **while** 命令。不同之处是,它直到逻辑表达式的值是 `true` 之前,会一直循环。看一下这种结构最简单的格式: + + +``` +[student@studentvm1 ~]$ X=0 ; until false  ; do echo $((X++)) ; done | head +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +[student@studentvm1 ~]$ +``` + +它用一个逻辑比较表达式来数到一个特定的值: + + +``` +[student@studentvm1 ~]$ X=0 ; until [ $X -eq 5 ]  ; do echo $((X++)) ; done +0 +1 +2 +3 +4 +[student@studentvm1 ~]$ X=0 ; until [ $X -eq 5 ]  ; do echo $((++X)) ; done +1 +2 +3 +4 +5 +[student@studentvm1 ~]$ +``` + +### 总结: + +本系列探讨了构建 bash 命令行程序和 shell 脚本的很多强大的工具。但是这仅仅是你能用 Bash 做的很多有意思的事中的冰山一角,接下来就看你的了。我发现学习 Bash 编程最好的方法就是实践。找一个需要多个 Bash 命令的简单项目然后写一个 CLI 程序。系统管理员们做了很多工作让任务变成 CLI 编程,因此我确信你很容易能找到自动化的任务。很多年前,尽管我对其他的 Shell 语言和 Perl 很熟悉,但还是决定用 Bash 做所有系统管理员的自动化任务。我发现 — 有时稍微搜索一下 — 我可以用 Bash 实现我需要的所有事情。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/programming-bash-loops + +作者:[David Both][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dboth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fail_progress_cycle_momentum_arrow.png?itok=q-ZFa_Eh (arrows cycle symbol for failing faster) +[2]: http://www.both.org/?page_id=1183 +[3]: https://opensource.com/article/19/10/programming-bash-part-1 +[4]: https://opensource.com/article/19/10/programming-bash-part-2 +[5]: https://www.apress.com/us/book/9781484237298 diff --git a/translated/tech/20191112 Getting started with PostgreSQL.md b/translated/tech/20191112 Getting started with PostgreSQL.md deleted file mode 100644 index 9fe988c3f9..0000000000 --- a/translated/tech/20191112 Getting started with PostgreSQL.md +++ /dev/null @@ -1,213 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Getting started with PostgreSQL) -[#]: via: (https://opensource.com/article/19/11/getting-started-postgresql) -[#]: author: (Greg Pittman https://opensource.com/users/greg-p) - -PostgreSQL 入门 -====== -安装,设置,创建和开始使用 PostgreSQL 数据库。 -![Guy on a laptop on a building][1] - -每人或许都有需要在数据库中保存的东西。即使你沉迷于使用文书或电子文件,它们也会变得很麻烦。纸质文档可能会丢失或混乱,你需要访问的电子信息可能会隐藏在段落和页面的深处。 - -在我从事医学工作的时候,我使用 [PostgreSQL][2] 来跟踪我的住院患者名单并提交有关住院患者的信息。我将我的每日患者名单打印在口袋里,以便快速了解并就患者房间、诊断或其他细节的任何变化做出快速记录。 - -我以为一切没问题,直到去年我妻子决定买一辆新车,我“继承”了她以前的那辆车。她保留了汽车维修和保养服务收据的文件夹,但随着时间的流逝,它变得杂乱。花时间筛选所有纸条以弄清楚什么时候做了什么,我认为 PostgreSQL 将是更好的跟踪此信息的方法。 - -### 安装 PostgreSQL - -自上次使用 PostgreSQ L以来已经有一段时间了,我忘记了如何使用它。实际上,我甚至没有在计算机上安装它。安装它是第一步。我使用 Fedora,因此在控制台中运行: - - -``` -`dnf list postgresql*` -``` - -请注意,你无需使用 sudo 即可使用 **list** 选项。该命令返回了很长的软件包列表。看了眼后,我决定只需要三个:postgresql、postgresql-server 和 postgresql-docs。 - -为了了解下一步需要做什么,我决定查看 [PostgreSQL 文档][3]。文档参考内容非常广泛,实际上,广泛到令人生畏。幸运的是,我发现我在升级 Fedora 时曾经做过的一些笔记,希望有效地导出数据库,在新版本上重新启动 PostgreSQL,以及导入旧数据库。 - -### 设置 PostgreSQL - -与大多数其他软件不同,你不能只是安装 PostgreSQL 并开始使用它。你必须预先执行两个基本步骤:首先,你需要设置 PostgreSQL,第二,你需要启动它。你必须以 **root** 用户身份执行这些操作(sudo 在这里不起作用)。 - -要设置它,请输入: - - -``` -`postgresql-setup –initdb` -``` - -这将确定 PostgreSQL 数据库在计算机上的位置。然后(仍为 **root**)输入以下两个命令: - - -``` -systemctl start postgresql.service -systemctl enable postgresql.service -``` - -第一个命令为当前会话启动 PostgreSQL(如果你关闭它,那么 PostgreSQL 就将关闭)。第二个命令使 PostgreSQL 在随后的重启中自动启动。 - -### 创建用户 - -PostgreSQL 正在运行,但是你仍然不能使用它,因为你还没有用户。为此,你需要切换到特殊用户 **postgres**。当你仍以 **root** 身份运行时,输入: - - -``` -`su postgres` -``` - -由于你是以 **root** 的身份执行此操作的,因此无需输入密码。root 用户可以在不知道密码的情况下以任何用户身份操作;这就是使其强大而危险的原因之一。 - -现在你就是 **postgres** 了,请运行下面两个命令,如下所示创建用户(创建用户 **gregp**): - - -``` -createuser gregp -createdb gregp -``` - -你可能会看到错误消息,如:**Could not switch to /home/gregp**。这只是意味着用户 **postgres**不能访问该目录。尽管如此,你的用户和数据库已创建。接下来,输入 **Exit** 和 **Enter** 两次,这样就回到了原来的状态。 - -### 设置数据库 - -要开始使用 PostgreSQL,请在命令行输入 **psql**。你应该在每行左侧看到类似 **gregp=>** 的内容,以显示你使用的是 PostgreSQL,并且只能使用它理解的命令。你自动获得一个数据库(我的名为 **gregp**),它里面完全没有内容。对 PostgreSQL 来说,数据库只是一个工作空间。在空间内,你创建_表_。表包含变量列表,每个变量的下面是构成数据库的数据。 - -以下是我设置汽车服务数据库的方式: - - -``` -CREATE TABLE autorepairs ( -        date            date, -        repairs         varchar(80), -        location        varchar(80), -        cost            numeric(6,2) -); -``` - -我本可以在一行内输入入,但为了更好地说明结构,并表明 PostgreSQL 不会解释制表符和换行的空白,我分成了多行。字段包含在括号中,每个变量名和数据类型与下一个变量用逗号分隔(最后一个逗号除外),命令以分号结尾。所有命令都必须以分号结尾! - -第一个变量名是 **date**,它的数据类型也是 **date**,这在 PostgreSQL 中没关系。第二个和第三个变量 **repairs** 和 **location** 都是 **varchar(80)** 类型,这意味着它们可以是最多 80 个任意字符(字母、数字等)。最后一个变量 **cost** 使用 **numeric** 类型。括号中的数字表示最多有六位数字,其中两位是小数。最初,我尝试了 **real** 类型,这将是一个浮点数。**real** 作为数据类型在使用时,在遇到 **WHERE** 子句,类似 **WHERE cost = 0** 或其他任何特定数字。由于 **real** 值有些不精确,因此特定数字将永远不会匹配。 - -### 输入数据 - -接下来,你可以使用 **INSERT INTO** 命令添加一些数据(在 PostgreSQL 中称为**行**): - - -``` -`INSERT INTO autorepairs VALUES ('2017-08-11', 'airbag recall', 'dealer', 0);` -``` - -请注意,括号为值构成一个容器,它必须以正确的顺序,用逗号分隔,并在命令末尾加上分号。 **date** 和 **varchar(80)** 类型的值必须包含在单引号中,但数字值(如 **numeric**)不用。作为反馈,你应该会看到: - - -``` -`INSERT 0 1` -``` - -与常规终端会话一样,你将有输入命令的历史记录,因此,在输入后续行时,通常可以按向上箭头键来显示最后一个命令并根据需要编辑数据,从而节省大量时间。 - -如果出了什么问题怎么办?使用 **UPDATE** 更改值: - - -``` -`UPDATE autorepairs SET date = '2017-11-08' WHERE repairs = 'airbag recall';` -``` - -或者,也许你不再需要表中的行。使用 **DELETE**: - - -``` -`DELETE FROM autorepairs WHERE repairs = 'airbag recall';` -``` - -这将删除整行。 - -最后一件事:即使我在 PostgreSQL 命令中一直使用大写字母(在大多数文档中也这么做),你也可以用小写字母输入,这是我常做的。 - -### 输出数据 - -如果你想展示数据,使用 **SELECT**: - - -``` -`SELECT * FROM autorepairs ORDER BY date;` -``` - -没有 **ORDER BY** 的话,行将不管你输入的内容来显示。例如,以下就是我终端中输出的我的汽车服务数据: - - -``` -SELECT date, repairs FROM autorepairs ORDER BY date; - -    date   |                             repairs                              -\-----------+----------------------------------------------------------------- -2008-08-08 | oil change, air filter, spark plugs -2011-09-30 | 35000 service, oil change, rotate tires/balance wheels -2012-03-07 | repl battery -2012-11-14 | 45000 maint, oil/filter -2014-04-09 | 55000 maint, oil/filter, spark plugs, air/dust filters -2014-04-21 | replace 4 tires -2014-04-21 | wheel alignment -2016-06-01 | 65000 mile service, oil change -2017-05-16 | oil change, replce oil filt housing -2017-05-26 | rotate tires -2017-06-05 | air filter, cabin filter,spark plugs -2017-06-05 | brake pads and rotors, flush brakes -2017-08-11 | airbag recall -2018-07-06 | oil/filter change, fuel filter, battery svc -2018-07-06 | transmission fl, p steering fl, rear diff fl -2019-07-22 | oil & filter change, brake fluid flush, front differential flush -2019-08-20 | replace 4 tires -2019-10-09 | replace passenger taillight bulb -2019-10-25 | replace passenger taillight assembly -(19 rows) -``` - -要将此发送到文件,将输出更改为: - - -``` -`\o autorepairs.txt` -``` - -然后再次运行 **SELECT** 命令。 - -### 退出 PostgreSQL - -最后,在终端中退出 PostgreSQL,输入: - - -``` -`quit` -``` - -或者它的缩写版: - - -``` -`\q` -``` - -虽然这只是 PostgreSQL 的简要介绍,但我希望它展示了将数据库用于这样的简单任务既不困难也不费时。 - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/11/getting-started-postgresql - -作者:[Greg Pittman][a] -选题:[lujun9972][b] -译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/greg-p -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_code_programming_laptop.jpg?itok=ormv35tV (Guy on a laptop on a building) -[2]: https://www.postgresql.org/ -[3]: http://www.postgresql.org/docs diff --git a/translated/tech/20191118 How internet security works- TLS, SSL, and CA.md b/translated/tech/20191118 How internet security works- TLS, SSL, and CA.md new file mode 100644 index 0000000000..6850c03e2d --- /dev/null +++ b/translated/tech/20191118 How internet security works- TLS, SSL, and CA.md @@ -0,0 +1,128 @@ +[#]: collector: (lujun9972) +[#]: translator: (hopefully2333) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How internet security works: TLS, SSL, and CA) +[#]: via: (https://opensource.com/article/19/11/internet-security-tls-ssl-certificate-authority) +[#]: author: (Bryant Son https://opensource.com/users/brson) + +互联网的安全是如何保证的:TLS,SSL,和 CA +====== +你的浏览器里的锁的图标的后面是什么? +![Lock][1] + +每天你都会重复这件事很多次,你访问网站,这个网站需要你用用户名或者电子邮件地址,和你的密码来进行登录。银行网站,社交网站,电子邮件服务,电子商务网站,和新闻网站。这里只在使用了这种机制的网站中列举了其中一小部分。 + +每次你登陆进一个这种类型的网站时,你实际上是在说:“是的,我信任这个网站,所以我愿意把我的个人信息共享给它。”这些数据可能包含你的姓名,性别,实际地址,电子邮箱地址,有时候甚至会包括你的信用卡信息。 + +但是你怎么知道你可以信任这个网站?换个方式问,为了让你可以信任它,网站应该如何保护你的交易? + +本文旨在阐述使网站变得安全的机制。我会首先论述 web 协议 http 和 https,以及传输层安全(TLS)的概念,后者是互联网协议(IP)层中的加密协议之一。然后,我会解释证书颁发机构和自签名证书,以及它们如何帮助保护一个网站。最后,我会介绍一些开源的工具,你可以使用它们来创建和管理你的证书。 + +### 通过 https 保护路由 + +了解一个受保护的网站的最简单的方式就是在交互中观察它,幸运的是,在今天的互联网上,发现一个安全的网站远远比找到一个不安全的网站要简单。但是,因为你已经在 Opensource.com 这个网站上了,我会使用它来作为案例,无论你使用的是哪个浏览器,你应该在你的地址栏旁边看到一个像锁一样的图标。点击这个锁图标,你应该会看见一些和下面这个类似的东西。 + +![Certificate information][2] + +默认情况下,如果一个网站使用的是 http 协议,那么它是不安全的。通过网站主机配置一个证书并添加到路由,可以把这个网站从一个不安全的 http 网站变为一个安全的 https 网站。那个锁图标通常表示这个网站是受 https 保护的。 + +点击证书来查看网站的 CA,根据你的浏览器,你可能需要下载证书来查看它。 + +![Certificate information][3] + +点击证书来查看网站的 CA,根据你的浏览器,你可能需要下载证书来查看它。 + +这个证书信息可以让终端用户检查该网站是否可以安全访问。 + +> 警告:如果你没有在网站上看到证书标志,或者如果你看见的标志显示这个网站不安全——请不要登录或者做任何需要你个人数据的操作。这种情况非常危险! + +如果你看到的是警告标志,对于大多数面向公众开放的网站来说,这很少见,它通常意味着该证书已经过期或者是该证书是自签名的,而非通过一个受信任的第三方来颁发。在我们进入这些主题之前,我想解释一下 TLS 和 SSL。 + +### 带有 TLS 和 SSL 的互联网协议 + +TLS 是旧版安全套接字层协议(SSL)的最新版本。理解这一点的最好方法就是仔细理解 IP 的不同协议层。 + +![IP layers][4] + +我们知道当今的互联网是由6个层面组成的:物理层,数据链路层,网络层,传输层,安全层,应用层。物理层是基础,这一层是最接近实际的硬件设备的。应用层是最抽象的一层,是最接近终端用户的一层。安全层可以被认为是应用层的一部分,TLS 和 SSL,是被设计用来在一个计算机网络中提供通信安全的加密协议,它们位于安全层中。 + +这个过程可以确保终端用户使用网络服务时,通信的安全性和保密性。 + +### 证书颁发机构和自签名证书 + +CA 是受信任的组织,它可以颁发数字证书。 + +TLS 和 SSL 可以使连接更安全,但是这个加密机制需要一种方式来验证它;这就是 SSL/TLS 证书。TLS 使用了一种叫做非对称加密的加密机制,这个机制有一对称为私钥和公钥的安全密钥。(这是一个非常复杂的主题,超出了本文的讨论范围,但是如果你想去了解这方面的东西,你可以阅读“密码学和公钥密码基础体系简介”)你要知道的基础内容是,证书颁发机构们,比如 GlobalSign, DigiCert,和 GoDaddy,它们是受人们信任的可以颁发证书的供应商,它们颁发的证书可以用于验证网站使用的 TLS/SSL 证书。网站使用的证书是导入到主机服务器里的,用于保护网站。 + +然而,如果你只是要测试一下正在开发中的网站或服务,CA 证书可能对你而言太昂贵或者是太复杂了。你必须有一个用于生产目的的受信任的证书,但是开发者和网站管理员需要有一种更简单的方式来测试网站,然后他们才能将其部署到生产环境中;这就是自签名证书的来源。 + +自签名证书是一种 TLS/SSL 证书,是由创建它的人而非受信任的 CA 机构颁发的。用电脑生成一个自签名证书很简单,它可以让你在无需购买昂贵的 CA 颁发的证书的情况下测试一个安全网站。虽然自签名证书肯定不能拿到生产环境中去使用,但对于开发和测试阶段来说,这是一种简单灵活的方法。 + +### 生成证书的开源工具 + +有几种开源工具可以用来管理 TLS/SSL 证书。其中最著名的就是 openssl,这个工具包含在很多 Linux 发行版中和 macos 中。当然,你也可以使用其他开源工具。 + +| Tool Name | Description | License | +| --------- | ------------------------------------------------------------------------------ | --------------------------------- | +| OpenSSL | 实现 TLS 和加密库的最著名的开源工具 | Apache License 2.0 | +| EasyRSA | 用于构建 PKI CA 的命令行实用工具 | GPL v2 | +| CFSSL | 来自 cloudflare 的 PKI/TLS 瑞士军刀 | BSD 2-Clause "Simplified" License | +| Lemur | 来自网飞的 TLS创建工具 | Apache License 2.0 | + +如果你的目的是扩展和对用户友好,网飞的 Lemur 是一个很有趣的选择。你在网飞的技术博客上可以查看更多有关它的信息。 + +### 如何创建一个 Openssl 证书 + +你可以靠自己来创建证书,下面这个案例就是使用 Openssl 生成一个自签名证书。 + +1. 使用 openssl 命令行生成一个私钥: +``` +openssl genrsa -out example.key 2048 +``` +![](https://opensource.com/sites/default/files/uploads/4_openssl_generatekey.jpg) + +2. 使用在第一步中生成的私钥来创建一个证书签名请求(CSR): +``` +openssl req -new -key example.key -out example.csr \ +-subj "/C=US/ST=TX/L=Dallas/O=Red Hat/OU=IT/CN=test.example.com" +``` + +![](https://opensource.com/sites/default/files/uploads/5_openssl_generatecsr.jpg) + +3. 使用你的 CSR 和私钥创建一个证书: + +``` +openssl x509 -req -days 366 -in example.csr \ +-signkey example.key -out example.crt +``` + +![](https://opensource.com/sites/default/files/uploads/6_openssl_generatecert.jpg) + +### 了解更多关于互联网安全的知识 +如果你想要了解更多关于互联网安全和网站安全的知识,请看我为这篇文章一起制作的 Youtube 视频。 + + + +你有什么问题?发在评论里让我们知道。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/internet-security-tls-ssl-certificate-authority + +作者:[Bryant Son][a] +选题:[lujun9972][b] +译者:[hopefully2333](https://github.com/hopefully2333) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/brson +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security-lock-password.jpg?itok=KJMdkKum +[2]: https://opensource.com/sites/default/files/uploads/1_certificatecheckwebsite.jpg +[3]: https://opensource.com/sites/default/files/uploads/2_certificatedisplaywebsite.jpg +[4]: https://opensource.com/sites/default/files/uploads/3_internetprotocol.jpg +[5]: https://opensource.com/article/18/5/cryptography-pki +[6]: https://medium.com/netflix-techblog/introducing-lemur-ceae8830f621 diff --git a/translated/tech/20191127 How to write a Python web API with Flask.md b/translated/tech/20191127 How to write a Python web API with Flask.md new file mode 100644 index 0000000000..763b7200dd --- /dev/null +++ b/translated/tech/20191127 How to write a Python web API with Flask.md @@ -0,0 +1,147 @@ +[#]: collector: (lujun9972) +[#]: translator: (hj24) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to write a Python web API with Flask) +[#]: via: (https://opensource.com/article/19/11/python-web-api-flask) +[#]: author: (Rachel Waston https://opensource.com/users/rachelwaston) + +如何使用Flask编写Python Web API +====== + +这是一个快速教程,用来展示如何通过Flask(目前发展最迅速的Python框架之一)来从服务器获取数据。 +![spiderweb diagram][1] + +[Python][2]是一个以语法简洁著称的高级的,面向对象的程序语言。它一直都是一个用来构建RESTful API的顶级编程语言。 + +[Flask][3]是一个高度可定制化的Python框架,可以为开发人员提供用户访问数据方式的完全控制。Flask是一个基于Werkzeug的[WSGI][4]工具包和Jinja 2模板引擎的”微框架“。它是一个被设计来开发RESTful API的web框架。 + +Flask是Python发展最迅速的框架之一,很多知名网站如:Netflix, Pinterest, 和LinkedIn都将Flask纳入了它们的开发技术栈。下面是一个简单的示例,展示了Flask是如何允许用户通过HTTP GET请求来从服务器获取数据的。 + +### 初始化一个Flask应用 + +首先,创建一个你的Flask项目的目录结构。你可以在你系统的任何地方来做这件事。 + + +``` +$ mkdir tutorial +$ cd tutorial +$ touch main.py +$ python3 -m venv env +$ source env/bin/activate +(env) $ pip3 install flask-restful +Collecting flask-restful +Downloading +Collecting Flask>=0.8 (from flask-restful) +[...] +``` + +### 导入Flask模块 + +Next, import the **flask** module and its **flask_restful** library into your **main.py** code: + +然后,在你的**main.py**代码中导入**flask**模块和它的**flask_restful**库: + + +``` +from flask import Flask +from flask_restful import Resource, Api + +app = Flask(__name__) +api = Api(app) + +class Quotes(Resource): +    def get(self): +        return { +            'William Shakespeare': { +                'quote': ['Love all,trust a few,do wrong to none', +                'Some are born great, some achieve greatness, and some greatness thrust upon them.'] +        }, +        'Linus': { +            'quote': ['Talk is cheap. Show me the code.'] +            } +        } + +api.add_resource(Quotes, '/') + +if __name__ == '__main__': +    app.run(debug=True) +``` + +### 运行app + +Flask includes a built-in HTTP server for testing. Test the simple API you built: + +Flask包含一个内建的用于测试的HTTP服务器。来测试一下这个你创建的简单的API: + + +``` +(env) $ python main.py + * Serving Flask app "main" (lazy loading) + * Environment: production +   WARNING: This is a development server. Do not use it in a production deployment. +   Use a production WSGI server instead. + * Debug mode: on + * Running on (Press CTRL+C to quit) +``` + +启动开发服务器时将启动Flask应用程序,该应用程序包含一个名为 **get** 的方法来响应简单的HTTP GET请求。你可以通过 **wget**、**curl** 命令或者任意的web浏览器来测试它。 + + +``` +$ curl +{ +    "William Shakespeare": { +        "quote": [ +            "Love all,trust a few,do wrong to none", +            "Some are born great, some achieve greatness, and some greatness thrust upon them." +        ] +    }, +    "Linus": { +        "quote": [ +            "Talk is cheap. Show me the code." +        ] +    } +} +``` + +要查看使用Python和Flask的类似Web API的更复杂版本,请导航至美国国会图书馆的[Chronicling America] [5]网站,该网站可提供有关这些信息的历史报纸和数字化报纸。 + +### 为什么使用 Flask? + +Flask有以下几个主要的优点: + + 1. Python很流行并且广泛被应用,所以任何熟悉Python的人都可以使用Flask来开发。 + 2. 它轻巧而简约。 + 3. 考虑安全性而构建。 + 4. 出色的文档,其中包含大量清晰,有效的示例代码。 + +还有一些潜在的缺点: + + 1. 它轻巧而简约。但如果您正在寻找具有大量捆绑库和预制组件的框架,那么这可能不是最佳选择。 + 2. 如果必须围绕Flask构建自己的框架,则你可能会发现维护自定义项的成本可能会抵消使用Flask的好处。 + + +如果您要构建Web程序或API,可以考虑选择Flask。它功能强大且健壮,并且其优秀的项目文档使入门变得容易。试用一下,评估一下,看看它是否适合您的项目。 + +在本课中了解更多信息关于Python异常处理以及如何以安全的方式进行操作。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/python-web-api-flask + +作者:[Rachel Waston][a] +选题:[lujun9972][b] +译者:[hj24](https://github.com/hj24) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/rachelwaston +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web-cms-build-howto-tutorial.png?itok=bRbCJt1U (spiderweb diagram) +[2]: https://www.python.org/ +[3]: https://palletsprojects.com/p/flask/ +[4]: https://en.wikipedia.org/wiki/Web_Server_Gateway_Interface +[5]: https://chroniclingamerica.loc.gov/about/api diff --git a/translated/tech/20191210 3 easy steps to update your apps to Python 3.md b/translated/tech/20191210 3 easy steps to update your apps to Python 3.md new file mode 100644 index 0000000000..566eb735c8 --- /dev/null +++ b/translated/tech/20191210 3 easy steps to update your apps to Python 3.md @@ -0,0 +1,163 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (3 easy steps to update your apps to Python 3) +[#]: via: (https://opensource.com/article/19/12/update-apps-python-3) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +将你的应用迁移到 Python 3 的三个步骤 +====== +Python 2 气数将尽,是时候将你的项目从 Python 2 迁移到 Python 3 了。 + +![Hands on a keyboard with a Python book ][1] + +Python 2.x 很快就要[失去官方支持][2]了,尽管如此,从 Python 2 迁移到 Python 3 却并没有想象中那么难。我在上周用了一个晚上的时间将一个 3D 渲染器及其对应的 [PySide][3] 迁移到 Python 3,回想起来,尽管在迁移过程中无可避免地会遇到一些牵一发而动全身的修改,但整个过程相比起痛苦的重构来说简直是出奇地简单。 + +每个人都别无选择地有各种必须迁移的原因:或许是觉得已经拖延太久了,或许是依赖了某个在 Python 2 下不再维护的模块。但如果你仅仅是想通过做一些事情来对开源做贡献,那么把一个 Python 2 应用迁移到 Python 3 就是一个简单而又有意义的做法。 + +无论你从 Python 2 迁移到 Python 3 的原因是什么,这都是一项重要的任务。按照以下三个步骤,可以让你把任务完成得更加清晰。 + +### 1\. 使用 2to3 + +从几年前开始,Python 在你或许还不知道的情况下就已经自带了一个名叫 [2to3][4] 的脚本,它可以帮助你实现大部分代码从 Python 2 到 Python 3 的自动转换。 + +下面是一段使用 Python 2.6 编写的代码: + + +``` +#!/usr/bin/env python +# -*- coding: utf-8 -*- +mystring = u'abcdé' +print ord(mystring[-1]) +``` + +对其执行 2to3 脚本: + + +``` +$ 2to3 example.py +RefactoringTool: Refactored example.py +\--- example.py     (original) ++++ example.py     (refactored) +@@ -1,5 +1,5 @@ + #!/usr/bin/env python + # -*- coding: utf-8 -*- +  +-mystring = u'abcdé' +-print ord(mystring[-1]) ++mystring = 'abcdé' ++print(ord(mystring[-1])) +RefactoringTool: Files that need to be modified: +RefactoringTool: example.py +``` + +在默认情况下,2to3 只会对迁移到 Python 3 时必须作出修改的代码进行标示,在输出结果中显示的 Python 3 代码是直接可用的,但你可以在 2to3 加上 `-w` 或者 `--write` 参数,这样它就可以直接按照给出的方案修改你的 Python 2 代码文件了。 + + +``` +$ 2to3 -w example.py +[...] +RefactoringTool: Files that were modified: +RefactoringTool: example.py +``` + +2to3 脚本不仅仅对单个文件有效,你还可以把它用于一个目录下的所有 Python 文件,同时它也会递归地对所有子目录下的 Python 文件都生效。 + +### 2\. 使用 Pylint 或 Pyflakes + +有一些不良的代码习惯在 Python 2 下运行是没有异常的,在 Python 3 下运行则会或多或少报出错误,并且这些代码无法通过语法转换来修复,所以 2to3 对它们没有效果,但一旦使用 Python 3 来运行就会产生报错。 + +对于这种情况,你需要使用 [Pylint][5]、[Pyflakes][6](或封装好的 [flake8][7])这类工具。其中我更喜欢 Pyflakes,它会忽略代码风格上的差异,在这一点上它和 Pylint 不同。尽管代码优美是 Python 的一大特点,但在代码迁移的层面上,“让代码功能保持一致”无疑比“让代码风格保持一致”重要得多/ + +以下是 Pyflakes 的输出样例: + + +``` +$ pyflakes example/maths +example/maths/enum.py:19: undefined name 'cmp' +example/maths/enum.py:105: local variable 'e' is assigned to but never used +example/maths/enum.py:109: undefined name 'basestring' +example/maths/enum.py:208: undefined name 'EnumValueCompareError' +example/maths/enum.py:208: local variable 'e' is assigned to but never used +``` + +上面这些由 Pyflakes 输出的内容清晰地给出了代码中需要修改的问题。相比之下,Pylint 会输出多达 143 行的内容,而且多数是诸如代码缩进这样无关紧要的问题。 + +值得注意的是第 19 行这个容易产生误导的错误。从输出来看你可能会以为 `cmp` 是一个在使用前未定义的变量,实际上 `cmp` 是 Python 2 的一个内置函数,而它在 Python 3 中被移除了。而且这段代码被放在了 `try` 语句块中,除非认真检查这段代码的输出值,否则这个问题很容易被忽略掉。 + + +``` +    try: +        result = cmp(self.index, other.index) +    except: +        result = 42 +        +    return result +``` + +在代码迁移过程中,你会发现很多原本在 Python 2 中能正常运行的函数都发生了变化,甚至直接在 Python 3 中被移除了。例如 PySide 的绑定方式发生了变化、`importlib` 取代了 `imp` 等等。这样的问题只能见到一个解决一个,而涉及到的功能需要重构还是直接放弃,则需要你自己权衡。但目前来说,大多数问题都是已知的,并且有[完善的文档记录][8]。所以难的不是修复问题,而是找到问题,从这个角度来说,使用 Pyflake 是很有必要的。 + +### 3\. 修复被破坏的 Python 2 代码 + +尽管 2to3 脚本能够帮助你把代码修改成兼容 Python 3 的形式,但对于一个完整的代码库,它就显得有点无能为力了,因为一些老旧的代码在 Python 3 中可能需要不同的结构来表示。在这样的情况下,只能人工进行修改。 + +例如以下代码在 Python 2.6 中可以正常运行: + + +``` +class CLOCK_SPEED: +        TICKS_PER_SECOND = 16 +        TICK_RATES = [int(i * TICKS_PER_SECOND) +                      for i in (0.5, 1, 2, 3, 4, 6, 8, 11, 20)] + +class FPS: +        STATS_UPDATE_FREQUENCY = CLOCK_SPEED.TICKS_PER_SECOND +``` + +类似 2to3 和 Pyflakes 这些自动化工具并不能发现其中的问题,但如果上述代码使用 Python 3 来运行,解释器会认为 `CLOCK_SPEED.TICKS_PER_SECOND` 是未被明确定义的。因此就需要把代码改成面向对象的结构: + + +``` +class CLOCK_SPEED: +        def TICKS_PER_SECOND(): +                TICKS_PER_SECOND = 16 +                TICK_RATES = [int(i * TICKS_PER_SECOND) +                        for i in (0.5, 1, 2, 3, 4, 6, 8, 11, 20)] +                return TICKS_PER_SECOND + +class FPS: +        STATS_UPDATE_FREQUENCY = CLOCK_SPEED.TICKS_PER_SECOND() +``` + +你也许会认为如果把 `TICKS_PER_SECOND()` 改写为一个构造函数能让代码看起来更加简洁,但这样就需要把这个方法的调用形式从 `CLOCK_SPEED.TICKS_PER_SECOND()` 改为 `CLOCK_SPEED()` 了,这样的改动或多或少会对整个库造成一些未知的影响。如果你对整个代码库的结构烂熟于心,那么你确实可以随心所欲地作出这样的修改。但我通常认为,只要我做出了修改,都可能会影响到其它代码中的至少三处地方,因此我更倾向于不使代码的结构发生改变。 + +### 坚持信念 + +如果你正在尝试将一个大项目从 Python 2 迁移到 Python 3,也许你会觉得这是一个漫长的过程。你可能会费尽心思也找不到一条有用的报错信息,这种情况下甚至会有将代码推倒重建的冲动。但从另一个角度想,代码原本在 Python 2 中就可以运行,要让它能在 Python 3 中继续运行,你需要做的只是对它稍加转换而已。 + +但只要你完成了迁移,你就得到了这个模块或者整个应用程序的 Python 3 版本,外加 Python 官方的长期支持。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/update-apps-python-3 + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd "Hands on a keyboard with a Python book " +[2]: https://opensource.com/article/19/11/end-of-life-python-2 +[3]: https://pypi.org/project/PySide/ +[4]: https://docs.python.org/3.1/library/2to3.html +[5]: https://opensource.com/article/19/10/python-pylint-introduction +[6]: https://pypi.org/project/pyflakes/ +[7]: https://opensource.com/article/19/5/python-flake8 +[8]: https://docs.python.org/3.0/whatsnew/3.0.html + diff --git a/translated/tech/20191211 Annotate screenshots on Linux with Ksnip.md b/translated/tech/20191211 Annotate screenshots on Linux with Ksnip.md new file mode 100644 index 0000000000..be9e674b41 --- /dev/null +++ b/translated/tech/20191211 Annotate screenshots on Linux with Ksnip.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Annotate screenshots on Linux with Ksnip) +[#]: via: (https://opensource.com/article/19/12/annotate-screenshots-linux-ksnip) +[#]: author: (Clayton Dewey https://opensource.com/users/cedewey) + +在 Linux 上使用 Ksnip 注释截图 +====== +Ksnip 让你能轻松地在 Linux 中创建和标记截图。 +![a checklist for a team][1] + +我最近从 MacOS 切换到了 [Elementary OS][2],这是一个专注于易用性和隐私性的 Linux 发行版。作为用户体验设计师和免费软件支持者,我会经常截图并进行注释。在尝试了几种不同的工具之后,到目前为止,我最喜欢的工具是 [Ksnip][3],它是 GPLv2 许可下的一种开源工具。 + +![Ksnip screenshot][4] + +### 安装 + +使用你首选的包管理器安装 Ksnip。我通过 Apt 安装了它: + + +``` +`sudo apt-get install ksnip` +``` + +### 配置 + +Ksnip 有许多配置选项,包括: + + * 保存截图的地方 +  * 默认截图的文件名 +  * 图像采集器行为 +  * 光标颜色和宽度 +  * 文字字体 + + + +你也可以将其与你的 Imgur 帐户集成。 + +![Ksnip configuration options][5] + +### 用法 + +Ksnip 提供了大量的[功能][6]。我最喜欢的 Ksnip 部分是它拥有我需要的所有注释工具(还有一个我没想到的工具!)。 + +您可以使用以下注释: + + * 钢笔 + * 记号笔 + * 矩形 + * 椭圆 + * 文字 + + + +你还可以模糊区域来移除敏感信息。还有使用我最喜欢的新工具:用于在界面上表示步骤的带数字的点。 + +### 关于作者 + +我非常喜欢 Ksnip,因此我联系了作者 [Damir Porobic][7] 来了解有关该项目的更多信息。 + +当我问到是什么启发了他编写 Ksnip 时,他说: + +>“几年前我从 Windows 切换到 Linux,却没有了在 Windows 中常用的 Windows Snipping Tool。当时的所有其他截图工具要么很大(很多按钮和复杂功能),要么缺少诸如注释等关键功能,所以我决定编写一个简单的 Windows Snipping Tool 克隆版,但是随着时间的流逝,它开始有越来越多的功能。“ + +这正是我在评估截图工具时发现的。他花时间构建解决方案并免费共享给他人使用,这真是太好了。 + +至于 Ksnip 的未来,Damir 希望添加全局快捷方式(至少对于 Windows 是这样)和用于新截图的选项卡,并允许该应用在后台运行。GitHub 上的功能请求列表也越来越多。 + +### 帮助的方式 + +Damir 最需要的是帮助开发 Ksnip。他和他的妻子很快就会有孩子了,所以他将没有太多的时间放在这个项目上。不过,他可以检查和接受拉取请求。 + +此外,此项目还可以通过 Snap 、Flatpak 以及 MacOS 安装包、Windows 安装包等其他安装方式安装。如果你想提供帮助,请查看 Ksnip 的 README 的 [Contribution][8] 部分。 + +* * * + +_此文章最初发表在 [Agaric Tech Cooperative 的博客][9]上,并经允许重新发布。_ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/annotate-screenshots-linux-ksnip + +作者:[Clayton Dewey][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/cedewey +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/checklist_hands_team_collaboration.png?itok=u82QepPk (a checklist for a team) +[2]: https://elementary.io/ +[3]: https://github.com/damirporobic/ksnip +[4]: https://opensource.com/sites/default/files/uploads/ksnip.png (Ksnip screenshot) +[5]: https://opensource.com/sites/default/files/uploads/ksnip-configuration.png (Ksnip configuration options) +[6]: https://github.com/DamirPorobic/ksnip#features +[7]: https://github.com/damirporobic/ +[8]: https://github.com/DamirPorobic/ksnip/blob/master/README.md#contribution +[9]: https://agaric.coop/blog/annotate-screenshots-linux-ksnip diff --git a/translated/tech/20191212 How to configure Openbox for your Linux desktop.md b/translated/tech/20191212 How to configure Openbox for your Linux desktop.md new file mode 100644 index 0000000000..5c6879119f --- /dev/null +++ b/translated/tech/20191212 How to configure Openbox for your Linux desktop.md @@ -0,0 +1,67 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to configure Openbox for your Linux desktop) +[#]: via: (https://opensource.com/article/19/12/openbox-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +如何为 Linux 桌面配置 Openbox +====== +本文是 24 天 Linux 桌面特别系列的一部分。Openbox 窗口管理器占用很小的系统资源、易于配置、使用愉快。 +![open with sky and grass][1] + +你可能不知道使用过 [Openbox][2] 桌面:尽管 Openbox 本身是一个出色的窗口管理器,但它还是 LXDE 和 LXQT 等桌面环境的窗口管理器“引擎”,它甚至可以管理 KDE 和 GNOME。除了作为多个桌面的基础之外,Openbox 可以说是最简单的窗口管理器之一,可以为那些不想学习所有配置选项的人配置。通过使用基于菜单的 **obconf** 的配置应用,可以像在 GNOME 或 KDE 这样的完整桌面中一样轻松地设置所有常用首选项。 + +### 安装 Openbox + +你可能会在 Linux 发行版的软件仓库中找到 Openbox,但也可以在 [Openbox.org][3] 中找到它。如果你已经在运行其他桌面,那么可以安全地在同一系统上安装 Openbox,因为 Openbox 除了几个配置面板之外,不包括任何捆绑的应用。 + +安装后,退出当前桌面会话,以便你可以登录 Openbox 桌面。默认情况下,会话管理器(KDM、GDM、LightDM 或 XDM,这取决于你的设置)将继续登录到以前的桌面,因此你必须在登录之前覆盖该桌面。 + +要使用 GDM 覆盖它: + +![Select your desktop session in GDM][4] + +要使用 SDDM 覆盖它: + +![Select your desktop session with KDM][5] + +### 配置 Openbox 桌面 + +默认情况下,Openbox 包含 **obconf** 应用,你可以使用它来选择和安装主题,修改鼠标行为,设置桌面首选项等。你可能会在仓库中发现其他配置应用,如 **obmenu** ,用于配置窗口管理器的其他部分。 + +![Openbox Obconf configuration application][6] + +建立你自己的桌面体验相对容易。它有一些所有常见的桌面组件,例如系统托盘 [stalonetray][7]、任务栏 [Tint2][8] 或 [Xfce4-panel][9] 等几乎你能想到的。任意组合应用,直到拥有梦想的开源桌面为止。 + +![Openbox][10] + +### 为何使用 Openbox + +Openbox 占用很小的系统资源、易于配置、使用愉快。它基本不会弹出,因此会是一个容易熟悉的系统。你永远不会知道你面前的桌面秘密使用了 Openbox 作为窗口管理器(知道如何自定义它会不会很高兴?)。如果开源吸引你,那么试试看 Openbox。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/openbox-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_general_openfield.png?itok=MeVN97oy (open with sky and grass) +[2]: http://openbox.org +[3]: http://openbox.org/wiki/Openbox:Download +[4]: https://opensource.com/sites/default/files/advent-gdm_0.jpg (Select your desktop session in GDM) +[5]: https://opensource.com/sites/default/files/advent-kdm.jpg (Select your desktop session with KDM) +[6]: https://opensource.com/sites/default/files/uploads/advent-openbox-obconf_675px.jpg (Openbox Obconf configuration application) +[7]: https://sourceforge.net/projects/stalonetray/ +[8]: https://opensource.com/article/19/1/productivity-tool-tint2 +[9]: http://xfce.org +[10]: https://opensource.com/sites/default/files/uploads/advent-openbox_675px.jpg (Openbox) diff --git a/translated/tech/20191213 What GNOME 2 fans love about the Mate Linux desktop.md b/translated/tech/20191213 What GNOME 2 fans love about the Mate Linux desktop.md new file mode 100644 index 0000000000..505c16110e --- /dev/null +++ b/translated/tech/20191213 What GNOME 2 fans love about the Mate Linux desktop.md @@ -0,0 +1,56 @@ +[#]: collector: (lujun9972) +[#]: translator: (mayunmeiyouming) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What GNOME 2 fans love about the Mate Linux desktop) +[#]: via: (https://opensource.com/article/19/12/mate-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +GNOME 2粉丝喜欢Mate Linux桌面的什么 +====== +本文是24天Linux桌面特别系列的一部分。如果您还记得GNOME 2,那么Mate Linux桌面将满足您的怀旧的情怀。 +![Linux keys on the keyboard for a desktop computer][1] + +如果你以前听过这个:当GNOME3第一次发布时,很多GNOME用户还没有准备好放弃GNOME2。[Mate] [2](以yerba mate_ plant命名)项目的开始是为了延续GNOME 2桌面,刚开始时使用GTK 2(GNOME 2所基于的工具包),然后又合并了GTK 3。由于Linux Mint的简单易用,使得桌面变得非常流行,并且从那时起,它已经普遍用于Fedora、Ubuntu、Slackware、Arch和许多其他Linux发行版上。今天,Mate继续提供一个传统的桌面环境,它的外观和感觉与GNOME 2完全一样,使用GTK 3工具包。 + +您可以在Linux发行版的软件仓库中找到Mate,也可以下载并[安装][3]把Mate作为默认桌面的发行版。不过,在你这样做之前,请注意它是为了提供完整的桌面体验,所以许多Mate应用程序都是随桌面一起安装的。如果您运行的是不同的桌面,您可能会发现自己有多余的应用程序(两个PDF阅读器、两个媒体播放器、两个文件管理器,等等)。如果您只想尝试Mate桌面,可以在虚拟机中安装基于Mate的发行版,例如[GNOME box][4]。 + +### Mate桌面之旅 + +Mate项目不仅仅唤起了GNOME 2;它是gnome2。如果你是00年代中期Linux桌面的粉丝,至少,你会发现Mate的怀旧情怀。我不是GNOME2的粉丝,我倾向于使用KDE,但是有一个地方我无法想象没有GNOME2:[OpenSolaris][5]。OpenSolaris项目并没有持续太久,当Ian Murdock在被Oracle并入Sun Microsystems之前加入Sun Microsystems时,它变得非常突出,但我当时是一个低级的Solaris管理员,并使用OpenSolaris来教自己更多关于Unix的那种风格。这是我使用GNOME2的唯一平台(因为我一开始不知道如何更改桌面,后来才习惯),而今天的[OpenIndiana project][6]是OpenSolaris的社区延续,它通过Mate桌面使用GNOME2。 + +![Mate on OpenIndiana][7] + +Mate的布局由左上角的三个菜单组成:应用程序、位置和系统。应用程序菜单提供对系统上安装的所有的应用程序的启动程序的快速访问。Places菜单提供对常用位置(如主目录、网络文件夹等)的快速访问。系统菜单包含全局选项,如关级和睡眠。右上角是一个系统托盘,屏幕底部有一个任务栏和一个虚拟桌面切换栏。 + +就桌面设计而言,它是一种稍微有点奇怪的配置。它从早期的Linux桌面、MacFinder和Windows中借用了相同的部分,但是又创建了一个独特的配置,这种配置很直观,而且很熟悉。Mate故意抵制与这个模型的偏差,这正是它的用户喜欢的地方。 + +### Mate和开源 + +Mate是一个最直接的例子,展示了开源如何使开发人员能够对抗项目生命的终结。从理论上讲,GNOME2会被GNOME3所取代,但它依然存在,因为一个开发人员建立代码的一个分支并继续进行下去。势头越来越大,更多的开发人员加入进来,并且用户喜爱的桌面比以往任何时候都更好。并不是所有的软件都有第二次机会,但是开源永远是一个机会,否则就永远没有机会。 + +使用和支持开源意味着支持用户和开发人员的自由。而且Mate桌面是它们的努力的有力证明。 + +探索不同的桌面是一件好事。我最近将开始使用为GNOME 3 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/mate-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[mayunmeiyouming](https://github.com/mayunmeiyouming) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux_keyboard_desktop.png?itok=I2nGw78_ (Linux keys on the keyboard for a desktop computer) +[2]: https://mate-desktop.org/ +[3]: https://mate-desktop.org/install/ +[4]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization +[5]: https://en.wikipedia.org/wiki/OpenSolaris +[6]: https://www.openindiana.org/documentation/faq/#what-is-openindiana +[7]: https://opensource.com/sites/default/files/uploads/advent-mate-openindiana_675px.jpg (Mate on OpenIndiana) diff --git a/translated/tech/20191214 Get started with Lumina for your Linux desktop.md b/translated/tech/20191214 Get started with Lumina for your Linux desktop.md new file mode 100644 index 0000000000..d1520e3b5c --- /dev/null +++ b/translated/tech/20191214 Get started with Lumina for your Linux desktop.md @@ -0,0 +1,67 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Get started with Lumina for your Linux desktop) +[#]: via: (https://opensource.com/article/19/12/linux-lumina-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +在 Linux 桌面中开始使用 Lumina +====== +本文是 24 天 Linux 桌面特别系列的一部分。Lumina 是快速、合理的基于 Fluxbox 的快捷方式桌面,它具有你无法缺少的所有功能。 +![Lightbulb][1] + +多年来,有一个基于 FreeBSD 的桌面操作系统(OS),称为 PC-BSD。它旨在作为一般使用的系统,因此值得注意,因为 BSD 主要用于服务器。大多数时候,PC-BSD 默认带 KDE 桌面,但是 KDE 越来越依赖于 Linux 特定的技术,因此有越来越多的 PC-BSD 从中迁移出来。PC-BSD 变成了 [Trident][2],它的默认桌面是 [Lumina][3],它是一组小部件,它们使用与 KDE 相同的基于 Qt 的工具箱,运行在 Fluxbox 窗口管理器中。 + +你可以在 Linux 发行版的软件仓库或 BSD 的 port 树中找到 Lumina 桌面。如果你安装了 Lumina 并且已经在运行另一个桌面,那么你可能会发现有冗余的应用(两个 PDF 阅读器、两个文件管理器,等等),因为 Lumina 包含一些集成的应用。如果你只想尝试 Lumina 桌面,那么可以在虚拟机如 [GNOME Boxes][4] 中安装基于 Lumina 的 BSD 发行版。 + +如果在当前的操作系统上安装 Lumina,那么必须注销当前的桌面会话,才能登录到新的会话。默认情况下,会话管理器(SDDM、GDM、LightDM 或 XDM,取决于你的设置)将继续登录到以前的桌面,因此你必须在登录之前覆盖该桌面。 + +在 GDM 中: + +![Selecting your desktop in GDM][5] + +在 SDDM 中: + +![Selecting your desktop in KDM][6] + +### Lumina 桌面 + +Lumina 提供了一个简单而轻巧的桌面环境。屏幕底部有一个面板,它的左侧是应用菜单,中间是任务栏,右边是系统托盘。桌面上有图标,可以快速访问常见的应用和路径。 + +除了这个基本的桌面结构外,Lumina 还有自定义文件管理器、PDF 查看器,截图工具、媒体播放器、文本编辑器和存档工具。还有一个配置程序可以帮助你自定义 Lumina 桌面,并且右键单击桌面可以找到更多配置选项。 + +![Lumina desktop running on Project Trident][7] + +Lumina 与几个 Linux 轻量级桌面非常相似,尤其是 LXQT,不同之处在于 Lumina 完全不依赖于基于 Linux 的桌面框架,例如 ConsoleKit、PolicyKit、D-Bus 或 systemd。对于你而言,这是否具有优势取决于所运行的操作系统。毕竟,如果你运行的是可以访问这些功能的 Linux,那么使用不使用这些特性的桌面可能就没有多大意义,还会减少功能。如果你运行的是 BSD,那么在 Fluxbox 中运行 Lumina 部件意味着你不必从 port 安装 Linux 兼容库。 + +### 为什么要使用 Lumina + +Lumina 设计简单,没有很多功能,你无法通过安装 Fluxbox 以及自己喜欢的组件来实现([PCManFM][8] 用于文件管理、各种 [LXQt 应用][9 ]、[Tint2][10] 面板等)。但它是开源的,开源用户喜欢寻找避免重复发明轮子的方法(几乎与我们喜欢重新发明轮子一样多)。 + +Lumina 桌面是快速而合理的基于 Fluxbox 的桌面快捷方式,它具有你无法缺少的所有功能,并且你很少需要调整细节。试一试 Lumina 桌面,看看它是否适合你。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/linux-lumina-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lightbulb-idea-think-yearbook-lead.png?itok=5ZpCm0Jh (Lightbulb) +[2]: https://project-trident.org/ +[3]: https://lumina-desktop.org/ +[4]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization +[5]: https://opensource.com/sites/default/files/uploads/advent-gdm_400x400_1.jpg (Selecting your desktop in GDM) +[6]: https://opensource.com/sites/default/files/uploads/advent-kdm_400x400_1.jpg (Selecting your desktop in KDM) +[7]: https://opensource.com/sites/default/files/uploads/advent-lumina.jpg (Lumina desktop running on Project Trident) +[8]: https://wiki.lxde.org/en/PCManFM +[9]: http://lxqt.org +[10]: https://opensource.com/article/19/1/productivity-tool-tint2