diff --git a/translated/tech/20171103 3 ways robotics affects the CIO role.md b/published/20171103 3 ways robotics affects the CIO role.md similarity index 91% rename from translated/tech/20171103 3 ways robotics affects the CIO role.md rename to published/20171103 3 ways robotics affects the CIO role.md index ae4f3e4f9c..6b43a229b3 100644 --- a/translated/tech/20171103 3 ways robotics affects the CIO role.md +++ b/published/20171103 3 ways robotics affects the CIO role.md @@ -1,7 +1,11 @@ 机器人学影响 CIO 角色的 3 种方式 ====== + +> 机器人流程自动化如何影响 CIO ?考虑这些可能。 +  -随着 2017 即将结束,许多 CIO 们的 2018 年目标也将确定。或许你们将参与到机器人流程自动化(RPA)中。多年以来,RPA 对许多公司来说只是一个可望不可及的概念。但是随着组织被迫变得越来越敏捷高效,RPA 所具有的潜在优势开始受到重视。 + +随着 2017 的结束,许多 CIO 们的 2018 年目标也将确定。或许你们将参与到机器人流程自动化(RPA)中。多年以来,RPA 对许多公司来说只是一个可望不可及的概念。但是随着组织被迫变得越来越敏捷高效,RPA 所具有的潜在优势开始受到重视。 根据 Redwood Sofeware 和 Sapio Research 的最新 [研究报告][1],IT 决策者们相信,未来 5 年有 59% 的业务可以被自动化处理,从而产生新的速度和效率,并且消减相应的重复性的人工工作量的岗位。但是,目前在相应岗位上没有实施 RPA 的公司中,有 20% 的公司员工超过 1000 人。 @@ -43,7 +47,7 @@ via: https://enterprisersproject.com/article/2017/11/3-ways-robotics-affects-cio 作者:[Dennis Walsh][a] 译者:[qhwdw](https://github.com/qhwdw) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20180418 Passwordless Auth Server.md b/published/20180418 Passwordless Auth Server.md index 38ed4e206f..ae5973e43b 100644 --- a/published/20180418 Passwordless Auth Server.md +++ b/published/20180418 Passwordless Auth Server.md @@ -160,7 +160,7 @@ func main() { router.Handle("GET", "/api/auth_user", authRequired(getAuthUser)) addr := fmt.Sprintf(":%d", config.port) - log.Printf("starting server at %s 🚀\n", config.appURL) + log.Printf("starting server at %s \n", config.appURL) log.Fatalf("could not start server: %v\n", http.ListenAndServe(addr, router)) } @@ -220,7 +220,7 @@ go build ``` -我们在目录中有了一个 “passwordless-demo”,但是你的目录中可能与示例不一样,`go build` 将创建一个同名的可执行文件。如果你没有关闭前面的 cockroach 节点,并且你正确配置了 `SMTP_USERNAME` 和 `SMTP_PASSWORD` 变量,你将看到命令 `starting server at http://localhost/ 🚀` 没有错误输出。 +我们在目录中有了一个 “passwordless-demo”,但是你的目录中可能与示例不一样,`go build` 将创建一个同名的可执行文件。如果你没有关闭前面的 cockroach 节点,并且你正确配置了 `SMTP_USERNAME` 和 `SMTP_PASSWORD` 变量,你将看到命令 `starting server at http://localhost/ ` 没有错误输出。 #### 请求 JSON 的中间件 @@ -764,7 +764,7 @@ func fetchUser(ctx context.Context, id string) (User, error) { 如果你在 mailtrap 上点击之后出现有关 `脚本运行被拦截,因为文档的框架是沙箱化的,并且没有设置 'allow-scripts' 权限` 的问题,你可以尝试右键点击 “在新标签中打开链接“。这样做是安全的,因为邮件内容是 [沙箱化的][10]。我在 `localhost` 上有时也会出现这个问题,但是我认为你一旦以 `https://` 方式部署到服务器上应该不会出现这个问题了。 -如果有任何问题,请在我的 [GitHub repo][11] 留言或者提交 PRs 👍 +如果有任何问题,请在我的 [GitHub repo][11] 留言或者提交 PRs 以后,我为这个 API 写了一个客户端作为这篇文章的[第二部分][13]。 diff --git a/published/20180530 How to load or unload a Linux kernel module.md b/published/20180530 How to load or unload a Linux kernel module.md new file mode 100644 index 0000000000..b63c1ccf43 --- /dev/null +++ b/published/20180530 How to load or unload a Linux kernel module.md @@ -0,0 +1,163 @@ +如何装载/卸载 Linux 内核模块 +=============== + +> 找到并装载内核模块以解决外设问题。 + + + +本文来自 Manning 出版的 [Linux in Action][1] 的第 15 章。 + +Linux 使用内核模块管理硬件外设。 我们来看看它是如何工作的。 + +运行中的 Linux 内核是您不希望被破坏的东西之一。毕竟,内核是驱动计算机所做的一切工作的软件。考虑到在一个运行的系统上必须同时管理诸多细节,最好能让内核尽可能的减少分心,专心的完成它的工作。但是,如果对计算环境进行任何微小的更改都需要重启整个系统,那么插入一个新的网络摄像头或打印机就可能会严重影响您的工作流程。每次添加设备时都必须重新启动,以使系统识别它,这效率很低。 + +为了在稳定性和可用性之间达成有效的平衡,Linux 将内核隔离,但是允许您通过可加载内核模块 (LKM) 实时添加特定的功能。如下图所示,您可以将模块视为软件的一部分,它告诉内核在哪里找到一个设备以及如何使用它。反过来,内核使设备对用户和进程可用,并监视其操作。 + +![Kernel modules][3] + +*内核模块充当设备和 Linux 内核之间的转换器。* + +虽然你可以自己编写模块来完全按照你喜欢的方式来支持一个设备,但是为什么要这样做呢?Linux 模块库已经非常强大,通常不需要自己去实现一个模块。 而绝大多数时候,Linux 会自动加载新设备的模块,而您甚至不知道它。 + +不过,有时候,出于某种原因,它本身并不会自动进行。(你肯定不想让那个招聘经理不耐烦地一直等待你的笑脸加入视频面试。)为了帮助你解决问题,你需要更多地了解内核模块,特别是,如何找到运行你的外设的实际模块,然后如何手动激活它。 + +### 查找内核模块 + +按照公认的约定,内核模块是位于 `/lib/modules/` 目录下的具有 .ko(内核对象)扩展名的文件。 然而,在你找到这些文件之前,你还需要选择一下。因为在引导时你需要从版本列表中选择其一加载,所以支持您选择的特定软件(包括内核模块)必须存在某处。 那么,`/lib/modules/` 就是其中之一。 你会发现目录里充满了每个可用的 Linux 内核版本的模块; 例如: + +``` +$ ls /lib/modules +4.4.0-101-generic +4.4.0-103-generic +4.4.0-104-generic +``` + +在我的电脑上,运行的内核是版本号最高的版本(4.4.0-104-generic),但不能保证这对你来说是一样的(内核经常更新)。 如果您将要在一个运行的系统上使用模块完成一些工作的话,你需要确保您找到正确的目录树。 + +好消息:有一个可靠的窍门。相对于通过名称来识别目录,并希望能够找到正确的目录,你可以使用始终指向使用的内核名称的系统变量。 您可以使用 `uname -r`( `-r` 从系统信息中指定通常显示的内核版本号)来调用该变量: + + +``` +$ uname -r +4.4.0-104-generic +``` + +通过这些信息,您可以使用称为命令替换的过程将 `uname` 并入您的文件系统引用中。 例如,要导航到正确的目录,您需要将其添加到 `/lib/modules` 。 要告诉 Linux “uname” 不是一个文件系统中的位置,请将 `uname` 部分用反引号括起来,如下所示: + +``` +$ ls /lib/modules/`uname -r` +build modules.alias modules.dep modules.softdep +initrd modules.alias.bin modules.dep.bin modules.symbols +kernel modules.builtin modules.devname modules.symbols.bin +misc modules.builtin.bin modules.order vdso + +``` + +你可以在 `kernel/` 目录下的子目录中找到大部分模块。 花几分钟时间浏览这些目录,了解事物的排列方式和可用内容。 这些文件名通常会让你知道它们是什么。 + +``` +$ ls /lib/modules/`uname -r`/kernel +arch crypto drivers fs kernel lib mm +net sound ubuntu virt zfs +``` + +这是查找内核模块的一种方法;实际上,这是一种快速的方式。 但这不是唯一的方法。 如果你想获得完整的集合,你可以使用 `lsmod` 列出所有当前加载的模块以及一些基本信息。 这个截断输出的第一列(在这里列出的太多了)是模块名称,后面是文件大小和数量,然后是每个模块的名称: + +``` +$ lsmod +[...] +vboxdrv 454656 3 vboxnetadp,vboxnetflt,vboxpci +rt2x00usb 24576 1 rt2800usb +rt2800lib 94208 1 rt2800usb +[...] +``` + +到底有多少?好吧,我们再运行一次 `lsmod ` ,但是这一次将输出管道输送到 `wc -l` 看一下一共多少行: + +``` +$ lsmod | wc -l +113 +``` + +这是已加载的模块。 总共有多少个? 运行 `modprobe -c` 并计算这些行将给我们这个数字: + +``` +$ modprobe -c | wc -l +33350 +``` + +有 33,350 个可用模块!? 看起来好像有人多年来一直在努力为我们提供软件来驱动我们的物理设备。 + +注意:在某些系统中,您可能会遇到自定义的模块,这些模块要么在 `/etc/modules` 文件中使用独特的条目进行引用,要么在 `/etc/modules-load.d/` 下的配置文件中。这些模块很可能是本地开发项目的产物,可能涉及前沿实验。不管怎样,知道你看到的是什么总是好的。 + +这就是如何找到模块的方法。 如果出于某种原因,它不会自行加载,您的下一个工作就是弄清楚如何手动加载未激活的模块。 + +### 手动加载内核模块 + +在加载内核模块之前,逻辑上您必须确认它存在。在这之前,你需要知道它叫什么。要做到这一点,有时需要兼有魔法和运气以及在线文档作者的辛勤工作的帮助。 + +我将通过描述一段时间前遇到的问题来说明这个过程。在一个晴朗的日子里,出于某种原因,笔记本电脑上的 WiFi 接口停止工作了。就这样。也许是软件升级把它搞砸了。谁知道呢?我运行了 `lshw -c network` ,得到了这个非常奇怪的信息: + +``` +network UNCLAIMED + AR9485 Wireless Network Adapter +``` + +Linux 识别到了接口(Atheros AR9485),但将其列为未声明。 那么,正如他们所说的那样,“当情况变得严峻时,就会在互联网上进行艰难的搜索。” 我搜索了一下 atheros ar9 linux 模块,在浏览了一页又一页五年前甚至是十年前的页面后,它们建议我自己写个模块或者放弃吧,然后我终于发现(最起码 Ubuntu 16.04)有一个可以工作的模块。 它的名字是 ath9k 。 + +是的! 这场战斗胜券在握!向内核添加模块比听起来容易得多。 要仔细检查它是否可用,可以针对模块的目录树运行 `find`,指定 `-type f` 来告诉 Linux 您正在查找文件,然后将字符串 `ath9k` 和星号一起添加以包含所有以你的字符串打头的文件: + +``` +$ find /lib/modules/$(uname -r) -type f -name ath9k* +/lib/modules/4.4.0-97-generic/kernel/drivers/net/wireless/ath/ath9k/ath9k_common.ko +/lib/modules/4.4.0-97-generic/kernel/drivers/net/wireless/ath/ath9k/ath9k.ko +/lib/modules/4.4.0-97-generic/kernel/drivers/net/wireless/ath/ath9k/ath9k_htc.ko +/lib/modules/4.4.0-97-generic/kernel/drivers/net/wireless/ath/ath9k/ath9k_hw.ko +``` + +再一步,加载模块: + +``` +# modprobe ath9k +``` + +就是这样。无启动,没烦恼。 + +这里还有一个示例,向您展示如何使用已经崩溃的运行模块。曾经有一段时间,我使用罗技网络摄像头和一个特定的软件会使摄像头在下次系统启动前无法被任何其他程序访问。有时我需要在不同的应用程序中打开相机,但没有时间关机重新启动。(我运行了很多应用程序,在引导之后将它们全部准备好需要一些时间。) + +由于这个模块可能是运行的,所以使用 `lsmod` 来搜索 video 这个词应该给我一个关于相关模块名称的提示。 实际上,它比提示更好:用 video 这个词描述的唯一模块是 uvcvideo(如下所示): + +``` +$ lsmod | grep video +uvcvideo 90112 0 +videobuf2_vmalloc 16384 1 uvcvideo +videobuf2_v4l2 28672 1 uvcvideo +videobuf2_core 36864 2 uvcvideo,videobuf2_v4l2 +videodev 176128 4 uvcvideo,v4l2_common,videobuf2_core,videobuf2_v4l2 +media 24576 2 uvcvideo,videodev +``` + +有可能是我自己的操作导致了崩溃,我想我可以挖掘更深一点,看看我能否以正确的方式解决问题。但结果你知道的;有时你不关心理论,只想让设备工作。 所以我用 `rmmod` 杀死了 `uvcvideo` 模块,然后用 `modprobe` 重新启动它,一切都好: + +``` +# rmmod uvcvideo +# modprobe uvcvideo +``` + +再一次:不重新启动。没有其他的后续影响。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/how-load-or-unload-linux-kernel-module + +作者:[David Clinton][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[amwps290](https://github.com/amwps290) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/dbclinton +[1]:https://www.manning.com/books/linux-in-action?a_aid=bootstrap-it&a_bid=4ca15fc9&chan=opensource +[2]:/file/397906 +[3]:https://opensource.com/sites/default/files/uploads/kernels.png "Kernel modules" diff --git a/published/20180601 Vim-plug - A Minimalist Vim Plugin Manager.md b/published/20180601 Vim-plug - A Minimalist Vim Plugin Manager.md new file mode 100644 index 0000000000..ee22f26366 --- /dev/null +++ b/published/20180601 Vim-plug - A Minimalist Vim Plugin Manager.md @@ -0,0 +1,116 @@ +Vim-plug:极简 Vim 插件管理器 +====== + + + +当没有插件管理器时,Vim 用户必须手动下载 tarball 包形式的插件,并将它们解压到 `~/.vim` 目录中。在少量插件的时候可以。但当他们安装更多的插件时,就会变得一团糟。所有插件文件分散在单个目录中,用户无法找到哪个文件属于哪个插件。此外,他们无法找到他们应该删除哪个文件来卸载插件。这时 Vim 插件管理器就可以派上用场。插件管理器将安装插件的文件保存在单独的目录中,因此管理所有插件变得非常容易。我们几个月前已经写了关于 [Vundle][1] 的文章。今天,我们将看到又一个名为 “Vim-plug” 的 Vim 插件管理器。 + +Vim-plug 是一个自由、开源、速度非常快的、极简的 vim 插件管理器。它可以并行地安装或更新插件。你还可以回滚更新。它创建浅层克隆最小化磁盘空间使用和下载时间。它支持按需加载插件以加快启动时间。其他值得注意的特性是支持分支/标签/提交、post-update 钩子、支持外部管理的插件等。 + +### 安装 + +安装和使用起来非常容易。你只需打开终端并运行以下命令: + +``` +$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +``` + +Neovim 用户可以使用以下命令安装 Vim-plug: + +``` +$ curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +``` + +### 用法 + +#### 安装插件 + +要安装插件,你必须如下所示首先在 Vim 配置文件中声明它们。一般 Vim 的配置文件是 `~/.vimrc`,Neovim 的配置文件是 `~/.config/nvim/init.vim`。请记住,当你在配置文件中声明插件时,列表应该以 `call plug#begin(PLUGIN_DIRECTORY)` 开始,并以 `plug#end()` 结束。 + +例如,我们安装 “lightline.vim” 插件。为此,请在 `~/.vimrc` 的顶部添加以下行。 + +``` +call plug#begin('~/.vim/plugged') +Plug 'itchyny/lightline.vim' +call plug#end() + +``` + +在 vim 配置文件中添加上面的行后,通过输入以下命令重新加载: + +``` +:source ~/.vimrc +``` + +或者,只需重新加载 Vim 编辑器。 + +现在,打开 vim 编辑器: + +``` +$ vim +``` + +使用以下命令检查状态: + +``` +:PlugStatus + +``` + +然后输入下面的命令,然后按回车键安装之前在配置文件中声明的插件。 + +``` +:PlugInstall +``` + +#### 更新插件 + +要更新插件,请运行: + +``` +:PlugUpdate +``` + +更新插件后,按下 `d` 查看更改。或者,你可以之后输入 `:PlugDiff`。 + +#### 审查插件 + +有时,更新的插件可能有新的 bug 或无法正常工作。要解决这个问题,你可以简单地回滚有问题的插件。输入 `:PlugDiff` 命令,然后按回车键查看上次 `:PlugUpdate`的更改,并在每个段落上按 `X` 将每个插件回滚到更新前的前一个状态。 + +#### 删除插件 + +删除一个插件删除或注释掉你以前在你的 vim 配置文件中添加的 `plug` 命令。然后,运行 `:source ~/.vimrc` 或重启 Vim 编辑器。最后,运行以下命令卸载插件: + +``` +:PlugClean +``` + +该命令将删除 vim 配置文件中所有未声明的插件。 + +#### 升级 Vim-plug + +要升级vim-plug本身,请输入: + +``` +:PlugUpgrade +``` + +如你所见,使用 Vim-plug 管理插件并不难。它简化了插件管理。现在去找出你最喜欢的插件并使用 Vim-plug 来安装它们。 + +就是这些了。我将很快在这里发布另一个有趣的话题。在此之前,请继续关注我们。 + +干杯! + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/vim-plug-a-minimalist-vim-plugin-manager/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:https://linux.cn/article-9416-1.html \ No newline at end of file diff --git a/sources/tech/20180108 How to Install Docker CE on Your Desktop.md b/sources/tech/20180108 How to Install Docker CE on Your Desktop.md deleted file mode 100644 index 9bd67736c2..0000000000 --- a/sources/tech/20180108 How to Install Docker CE on Your Desktop.md +++ /dev/null @@ -1,205 +0,0 @@ -Translating by MjSeven - - -How to Install Docker CE on Your Desktop -====== - - - -[In the previous article,][1] we learned some of the basic terminologies of the container world. That background information will come in handy when we run commands and use some of those terms in follow-up articles, including this one. This article will cover the installation of Docker on desktop Linux, macOS, and Windows, and it is intended for beginners who want to get started with Docker containers. The only prerequisite is that you are comfortable with command-line interface. - -### Why do I need Docker CE on my local machine? - -As a new user, you many wonder why you need containers on your local systems. Aren’t they meant to run in cloud and servers as microservices? While containers have been part of the Linux world for a very long time, it was Docker that made them really consumable with its tools and technologies. - -The greatest thing about Docker containers is that you can use your local machine for development and testing. The container images that you create on your local system can then run “anywhere.” There is no conflict between developers and operators about apps running fine on development systems but not in production. - -The point is that in order to create containerized applications, you must be able to run and create containers on your local systems. - -You can use any of the three platforms -- desktop Linux, Windows, or macOS as the development platform for containers. Once Docker is successfully running on these systems, you will be using the same commands across platforms so it really doesn’t matter which OS you are running underneath. - -That’s the beauty of Docker. - -### Let’s get started - -There are two editions of Docker. Docker Enterprise Edition (EE) and Docker Community Edition (CE). We will be using the Docker Community Edition, which is a free of cost version of Docker intended for developers and enthusiasts who want to get started with Docker. - -There are two channels of Docker CE: stable and edge. As the name implies, the stable version gives you well-tested quarterly updates, whereas the edge version offers new updates every month. After further testing, these edge features are added to the stable release. I recommend the stable version for new users. -Docker CE is supported on macOS, Windows 10, Ubuntu 14.04, 16.04, 17.04 and 17.10; Debian 7.7,8,9 and 10; Fedora 25, 26, 27; and centOS. While you can download Docker CE binaries and install on your Desktop Linux systems, I recommend adding repositories so you continue to receive patches and updates. - -### Install Docker CE on Desktop Linux - -You don’t need a full blown desktop Linux to run Docker, you can install it on a bare minimal Linux server as well, that you can run in a VM. In this tutorial, I am running it on Fedora 27 and Ubuntu 17.04 running on my main systems. - -### Ubuntu Installation - -First things first. Run a system update so your Ubuntu packages are fully updated: -``` -$ sudo apt-get update - -``` - -Now run system upgrade: -``` -$ sudo apt-get dist-upgrade - -``` - -Then install Docker PGP keys: -``` -sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - -Update the repository info again: -$ sudo apt-get update - -``` - -Now install Docker CE: -``` -$ sudo apt-get install docker-ce - -``` - -Once it's installed, Docker CE runs automatically on Ubuntu based systems. Let’s check if it’s running: -``` -$ sudo systemctl status docker - -``` - -You should get the following output: -``` -docker.service - Docker Application Container Engine - Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) - Active: active (running) since Thu 2017-12-28 15:06:35 EST; 19min ago - Docs: https://docs.docker.com -Main PID: 30539 (dockerd) - -``` - -Since Docker is installed on your system, you can now use Docker CLI (Command Line Interface) to run Docker commands. Living up to the tradition, let’s run the ‘Hello World’ command: -``` -$ sudo docker run hello-world - -``` - -![YMChR_7xglpYBT91rtXnqQc6R1Hx9qMX_iO99vL8][2] -Congrats! You have Docker running on your Ubuntu system. - -### Installing Docker CE on Fedora - -Things are a bit different on Fedora 27. On Fedora, you first need to install def-plugins-core packages that will allow you to manage your DNF packages from CLI. -``` -$ sudo dnf -y install dnf-plugins-core - -``` - -Now install the Docker repo on your system: -``` -$ sudo dnf config-manager \ - --add-repo \ - https://download.docker.com/linux/fedora/docker-ce.repo -It’s time to install Docker CE: - -$ sudo dnf install docker-ce - -``` - -Unlike Ubuntu, Docker doesn’t start automatically on Fedora. So let’s start it: -``` -$ sudo systemctl start docker - -``` - -You will have to start Docker manually after each reboot, so let’s configure it to start automatically after reboots. $ systemctl enable docker Well, it’s time to run the Hello World command: -``` -$ sudo docker run hello-world - -``` - -Congrats, Docker is running on your Fedora 27 system. - -### Cutting your roots - -You may have noticed that you have to use sudo to run Docker commands. That’s because of Docker daemon’s binding with the UNIX socket, instead of a TCP port and that socket is owned by the root user. So, you need sudo privileges to run the docker command. You can add system user to the docker group so it won’t require sudo: -``` -$ sudo groupadd docker - -``` - -In most cases, the docker user group is automatically created when you install Docker CE, so all you need to do is add your user to that group: -``` -$ sudo usermod -aG docker $USER - -``` - -To test if the group has been added successfully, run the groups command against the name of the user: -``` -$ groups swapnil - -``` - -(Here, Swapnil is the user.) - -This is the output on my system: -``` -$ swapnil : swapnil adm cdrom sudo dip plugdev lpadmin sambashare docker - -``` - -You can see that the user also belongs to the docker group. Log out of your system, so that group changes take effect. Once you log back in, try the Hello World command without sudo: -``` -$ docker run hello-world - -``` - -You can check system wide info about the installed version of Docker and more by running this command: -``` -$ docker info - -``` - -### Install Docker CE on macOS and Windows - -You can easily install Docker CE (and EE) on macOS and Windows. Download the official Docker for Mac and install it the way you install applications on macOS, by simply dragging them into the Applications directory. Once the file is copied, open Docker from spotlight to start the installation process. Once installed, Docker will start automatically and you can see it in the top bar of macOS. - -![IEX23j65zYlF8mZ1c-T_vFw_i1B1T1hibw_AuhEA][3] - -macOS is UNIX, so you can simply open the terminal app and start using Docker commands natively. Test the hello world app: -``` -$ docker run hello-world - -``` - -Congrats, you have Docker running on your macOS. - -### Docker on Windows 10 - -You need the latest version of Windows 10 Pro or Server in order to run/install Docker on it. If you are not fully updated, Windows won’t install Docker. I got an error on my Windows 10 system and had to run system updates. My version was still behind, and I hit [this][4] bug. So, if you fail to install Docker on Windows, just know you are not alone. Keep an eye on that bug to find a solution. - -Once you install Docker on Windows, you can either use bash shell via WSL or use PowerShell to run docker commands. Let’s test the “Hello World” command in PowerShell: -``` -PS C:\Users\swapnil> docker run hello-world - -``` - -Congrats, you have Docker running on Windows. - -In the next article, we will talk about pulling images from DockerHub and running containers on our systems. We will also talk about pushing our own containers to Docker Hub. - - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/learn/intro-to-linux/how-install-docker-ce-your-desktop - -作者:[SWAPNIL BHARTIYA][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) -选题:[lujun9972](https://github.com/lujun9972) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/arnieswap -[1]:https://www.linux.com/blog/intro-to-linux/2017/12/container-basics-terms-you-need-know -[2]:https://lh5.googleusercontent.com/YMChR_7xglpYBT91rtXnqQc6R1Hx9qMX_iO99vL8Z8C0-BlynDcL5B5pG-zzH0fKU0Qvnzd89v0KDEbZiO0gTfGNGfDtO-FkTt0bmzIQ-TKbNmv18S9RXdkSeXqgKDFRewnaHPj2 -[3]:https://lh3.googleusercontent.com/IEX23j65zYlF8mZ1c-T_vFw_i1B1T1hibw_AuhEAfwv9oFpMfcAqkgEk7K5o58iDAAfGozSpIvY_qEsTOHRlSbesMKwTnG9rRkWba1KPSmnuH1LyoccDGNO3Clbz8du0gSByZxNj -[4]:https://github.com/docker/for-win/issues/1263 diff --git a/sources/tech/20180429 Passwordless Auth- Client.md b/sources/tech/20180429 Passwordless Auth- Client.md new file mode 100644 index 0000000000..06e4464709 --- /dev/null +++ b/sources/tech/20180429 Passwordless Auth- Client.md @@ -0,0 +1,338 @@ +Passwordless Auth: Client +====== +Time to continue with the [passwordless auth][1] posts. Previously, we wrote an HTTP service in Go that provided with a passwordless authentication API. Now, we are gonna code a JavaScript client for it. + +We’ll go with a single page application (SPA) using the technique I showed [here][2]. Read it first if you haven’t yet. + +For the root URL (`/`) we’ll show two different pages depending on the auth state: a page with an access form or a page greeting the authenticated user. Another page is for the auth callback redirect. + +### Serving + +I’ll serve the client with the same Go server, so let’s add some routes to the previous `main.go`: +``` +router.Handle("GET", "/js/", http.FileServer(http.Dir("static"))) +router.HandleFunc("GET", "/...", serveFile("static/index.html")) + +``` + +This serves files under `static/js`, and `static/index.html` is served for everything else. + +You can use your own server apart, but you’ll have to enable [CORS][3] on the server. + +### HTML + +Let’s see that `static/index.html`. +``` + + +
+ + +Welcome back, ${authUser.username} 👋
+ + ` + + const page = template.content + + page.getElementById('logout-button') + .addEventListener('click', logout) + + return page +} + +function logout() { + localStorage.clear() + location.reload() +} + +``` + +This page greets the authenticated user and also has a logout button. The `logout()` function just clears `localStorage` and reloads the page. + +There is it. I bet you already saw the [demo][4] before. Also, the source code is in the same [repository][5]. + +👋👋👋 + +-------------------------------------------------------------------------------- + +via: https://nicolasparada.netlify.com/posts/passwordless-auth-client/ + +作者:[Nicolás Parada][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://nicolasparada.netlify.com/ +[1]:https://nicolasparada.netlify.com/posts/passwordless-auth-server/ +[2]:https://nicolasparada.netlify.com/posts/javascript-client-router/ +[3]:https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS +[4]:https://go-passwordless-demo.herokuapp.com/ +[5]:https://github.com/nicolasparada/go-passwordless-demo diff --git a/sources/tech/20180516 How to Read Outlook Emails by Python.md b/sources/tech/20180516 How to Read Outlook Emails by Python.md new file mode 100644 index 0000000000..36a000d010 --- /dev/null +++ b/sources/tech/20180516 How to Read Outlook Emails by Python.md @@ -0,0 +1,156 @@ +translating by lujun9972 +How to Read Outlook Emails by Python +====== + + + +when you start e-mail marketing , You need opt-in email address list. You have opt-in list. You are using email client software and If you can export your list from your email client, You will have good list. + +Now I am trying to explain my codes to write all emails into test file from your outlook profile. + +First you should import win32com.client, You need to install pywin32 +``` +pip install pywin32 + +``` + +We should connect to Outlook by MAPI +``` +outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") + +``` + +Then we should get all accounts in your outlook profile. +``` +accounts= win32com.client.Dispatch("Outlook.Application").Session.Accounts; + +``` + +Then You need to get emails from inbox folder that is named emailleri_al. +``` +def emailleri_al(folder): + messages = folder.Items + a=len(messages) + if a>0: + for message2 in messages: + try: + sender = message2.SenderEmailAddress + if sender != "": + print(sender, file=f) + except: + print("Ben hatayım") + print(account.DeliveryStore.DisplayName) + pass + + try: + message2.Save + message2.Close(0) + except: + pass +``` + +You should go to all account and get inbox folder and get emails +``` +for account in accounts: + global inbox + inbox = outlook.Folders(account.DeliveryStore.DisplayName) + print("****Account Name**********************************",file=f) + print(account.DisplayName,file=f) + print(account.DisplayName) + print("***************************************************",file=f) + folders = inbox.Folders + + for folder in folders: + print("****Folder Name**********************************", file=f) + print(folder, file=f) + print("*************************************************", file=f) + emailleri_al(folder) + a = len(folder.folders) + + if a>0 : + global z + z = outlook.Folders(account.DeliveryStore.DisplayName).Folders(folder.name) + x = z.Folders + for y in x: + emailleri_al(y) + print("****Folder Name**********************************", file=f) + print("..."+y.name,file=f) + print("*************************************************", file= +``` + +All Code is as the following +``` +import win32com.client +import win32com +import os +import sys + +f = open("testfile.txt","w+") + +outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") +accounts= win32com.client.Dispatch("Outlook.Application").Session.Accounts; + +def emailleri_al(folder): + messages = folder.Items + a=len(messages) + if a>0: + for message2 in messages: + try: + sender = message2.SenderEmailAddress + if sender != "": + print(sender, file=f) + except: + print("Error") + print(account.DeliveryStore.DisplayName) + pass + + try: + message2.Save + message2.Close(0) + except: + pass + + + +for account in accounts: + global inbox + inbox = outlook.Folders(account.DeliveryStore.DisplayName) + print("****Account Name**********************************",file=f) + print(account.DisplayName,file=f) + print(account.DisplayName) + print("***************************************************",file=f) + folders = inbox.Folders + + for folder in folders: + print("****Folder Name**********************************", file=f) + print(folder, file=f) + print("*************************************************", file=f) + emailleri_al(folder) + a = len(folder.folders) + + if a>0 : + global z + z = outlook.Folders(account.DeliveryStore.DisplayName).Folders(folder.name) + x = z.Folders + for y in x: + emailleri_al(y) + print("****Folder Name**********************************", file=f) + print("..."+y.name,file=f) + print("*************************************************", file=f) + + + +print("Finished Succesfully") +``` +-------------------------------------------------------------------------------- + +via: https://www.codementor.io/aliacetrefli/how-to-read-outlook-emails-by-python-jkp2ksk95 + +作者:[A.A. Cetrefli][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.codementor.io/aliacetrefli diff --git a/sources/tech/20180519 Python Debugging Tips.md b/sources/tech/20180519 Python Debugging Tips.md new file mode 100644 index 0000000000..0db53aa810 --- /dev/null +++ b/sources/tech/20180519 Python Debugging Tips.md @@ -0,0 +1,70 @@ +Python Debugging Tips +====== +When it comes to debugging, there’s a lot of choices that you can make. It is hard to give generic advice that always works (other than “Have you tried turning it off and back on?”). + +Here are a few of my favorite Python Debugging tips. + +### Make a branch + +Trust me on this. Even if you never intend to commit the changes back upstream, you will be glad your experiments are contained within their own branch. + +If nothing else, it makes cleanup a lot easier! + +### Install pdb++ + +Seriously. It makes you life easier if you are on the command line. + +All that pdb++ does is replace the standard pdb module with 100% PURE AWESOMENESS. Here’s what you get when you `pip install pdbpp`: + + * A Colorized prompt! + * tab completion! (perfect for poking around!) + * It slices! It dices! + + + +Ok, maybe the last one is a little bit much… But in all seriousness, installing pdb++ is well worth your time. + +### Poke around + +Sometimes the best approach is to just mess around and see what happens. Put a break point in an “obvious” spot and make sure it gets hit. Pepper the code with `print()` and/or `logging.debug()` statements and see where the code execution goes. + +Examine the arguments being passed into your functions. Check the versions of the libraries (if things are getting really desperate). + +### Only change one thing at a time + +Once you are poking around a bit you are going to get ideas on things you could do. But before you start slinging code, take a step back and think about what you could change, and then only change 1 thing. + +Once you’ve made the change, then test and see if you are closer to resolving the issue. If not, change the thing back, and try something else. + +Changing only one thing allows you to know what does and doesn’t work. Plus once you do get it working, your new commit is going to be much smaller (because there will be less changes). + +This is pretty much what one does in the Scientific Process: only change one variable at a time. By allowing yourself to see and measure the results of one change you will save your sanity and arrive at a working solution faster. + +### Assume nothing, ask questions + +Occasionally a developer (not you of course!) will be in a hurry and whip out some questionable code. When you go through to debug this code you need to stop and make sure you understand what it is trying to accomplish. + +Make no assumptions. Just because the code is in the `model.py` file doesn’t mean it won’t try to render some HTML. + +Likewise, double check all of your external connections before you do anything destructive! Going to delete some configuration data? MAKE SURE YOU ARE NOT CONNECTED TO YOUR PRODUCTION SYSTEM. + +### Be clever, but not too clever + +Sometimes we write code that is so amazingly awesome it is not obvious how it does what it does. + +While we might feel smart when we publish that code, more often than not we will wind up feeling dumb later on when the code breaks and we have to remember how it works to figure out why it isn’t working. + +Keep an eye out for any sections of code that look either overly complicated and long, or extremely short. These could be places where complexity is hiding and causing your bugs. + +-------------------------------------------------------------------------------- + +via: https://pythondebugging.com/articles/python-debugging-tips + +作者:[PythonDebugging.com][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://pythondebugging.com diff --git a/sources/tech/20180611 3 open source alternatives to Adobe Lightroom.md b/sources/tech/20180611 3 open source alternatives to Adobe Lightroom.md new file mode 100644 index 0000000000..664c054913 --- /dev/null +++ b/sources/tech/20180611 3 open source alternatives to Adobe Lightroom.md @@ -0,0 +1,84 @@ +3 open source alternatives to Adobe Lightroom +====== + + + +You wouldn't be wrong to wonder whether the smartphone, that modern jack-of-all-trades, is taking over photography. While that might be valid in the point-and-shoot camera market, there are a sizeable number of photography professionals and hobbyists who recognize that a camera that fits in your pocket can never replace a high-end DSLR camera and the depth, clarity, and realism of its photos. + +All of that power comes with a small price in terms of convenience; like negatives from traditional film cameras, the [raw image][1] files produced by DSLRs must be processed before they can be edited or printed. For this, a digital image processing application is indispensable, and the go-to application has been Adobe Lightroom. But for many reasons—including its expensive, subscription-based pricing model and its proprietary license—there's a lot of interest in open source and other alternatives. + +Lightroom has two main functions: processing raw image files and digital asset management (DAM)—organizing images with tags, ratings, and other metadata to make it easier to keep track of them. + +In this article, we'll look at three open source image processing applications: Darktable, LightZone, and RawTherapee. All of them have DAM capabilities, but none has Lightroom's machine learning-based image categorization and tagging features. If you're looking for more information about open source DAM software, check out Terry Hancock's article "[Digital asset management for an open movie project][2]," where he shares his research on software to organize multimedia files for his [_Lunatics!_][3] open movie project. + +### Darktable + +![Darktable][4] + +Like the other applications on our list, [darktable][5] processes raw images into usable file formats—it exports into JPEG, PNG, TIFF, PPM, PFM, and EXR, and it also supports Google and Facebook web albums, Flickr uploads, email attachments, and web gallery creation. + +Its 61 image operation modules allow you to adjust contrast, tone, exposure, color, noise, etc.; add watermarks; crop and rotate; and much more. As with the other applications described in this article, those edits are "non-destructive"—that is, your original raw image is preserved no matter how many tweaks and modifications you make. + +Darktable imports raw images from more than 400 cameras plus JPEG, CR2, DNG, OpenEXR, and PFM; images are managed in a database so you can filter and search using metadata including tags, ratings, and color. It's also available in 21 languages and is supported on Linux, MacOS, BSD, Solaris 11/GNOME, and Windows. (The [Windows port][6] is new, and darktable warns it may have "rough edges or missing functionality" compared to other versions.) + +Darktable is licensed under [GPLv3][7]; you can learn more by perusing its [features][8], viewing the [user manual][9], or accessing its [source code][10] on GitHub. + +### LightZone + +![LightZone's tool stack][11] + +As a non-destructive raw image processing tool, [LightZone][12] is similar to the other two applications on this list: it's cross-platform, operating on Windows, MacOS, and Linux, and it supports JPG and TIFF images in addition to raw. But it's also unique in several ways. + +For one thing, it started out in 2005 as a proprietary image processing tool and later became an open source project under a BSD license. Also, before you can download the application, you must register for a free account; this is so the LightZone development community can track downloads and build the community. (Approval is quick and automated, so it's not a large barrier.) + +Another difference is that image modifications are done using stackable tools, rather than filters (like most image-editing applications); tool stacks can be rearranged or removed, as well as saved and copied to a batch of images. You can also edit certain parts of an image using a vector-based tool or by selecting pixels based on color or brightness. + +You can get more information on LightZone by searching its [forums][13] or accessing its [source code][14] on GitHub. + +### RawTherapee + +![RawTherapee][15] + +[RawTherapee][16] is another popular open source ([GPL][17]) raw image processor worth your attention. Like darktable and LightZone, it is cross-platform (Windows, MacOS, and Linux) and implements edits in a non-destructive fashion, so you maintain access to your original raw image file no matter what filters or changes you make. + +RawTherapee uses a panel-based interface, including a history panel to keep track of your changes and revert to a previous point; a snapshot panel that allows you to work with multiple versions of a photo; and scrollable tool panels to easily select a tool without worrying about accidentally using the wrong one. Its tools offer a wide variety of exposure, color, detail, transformation, and demosaicing features. + +The application imports raw files from most cameras and is localized to more than 25 languages, making it widely usable. Features like batch processing and [SSE][18] optimizations improve speed and CPU performance. + +RawTherapee offers many other [features][19]; check out its [documentation][20] and [source code][21] for details. + +Do you use another open source raw image processing tool in your photography? Do you have any related tips or suggestions for other photographers? If so, please share your recommendations in the comments. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/alternatives/adobe-lightroom + +作者:[Opensource.com][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com +[1]:https://en.wikipedia.org/wiki/Raw_image_format +[2]:https://opensource.com/article/18/3/movie-open-source-software +[3]:http://lunatics.tv/ +[4]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/uploads/raw-image-processors_darkroom1.jpg?itok=0fjk37tC (Darktable) +[5]:http://www.darktable.org/ +[6]:https://www.darktable.org/about/faq/#faq-windows +[7]:https://github.com/darktable-org/darktable/blob/master/LICENSE +[8]:https://www.darktable.org/about/features/ +[9]:https://www.darktable.org/resources/ +[10]:https://github.com/darktable-org/darktable +[11]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/uploads/raw-image-processors_lightzone1tookstack.jpg?itok=1e3s85CZ (LightZone's tool stack) +[12]:http://www.lightzoneproject.org/ +[13]:http://www.lightzoneproject.org/Forum +[14]:https://github.com/ktgw0316/LightZone +[15]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/uploads/raw-image-processors_rawtherapee.jpg?itok=meiuLxPw (RawTherapee) +[16]:http://rawtherapee.com/ +[17]:https://github.com/Beep6581/RawTherapee/blob/dev/LICENSE.txt +[18]:https://en.wikipedia.org/wiki/Streaming_SIMD_Extensions +[19]:http://rawpedia.rawtherapee.com/Features +[20]:http://rawpedia.rawtherapee.com/Main_Page +[21]:https://github.com/Beep6581/RawTherapee diff --git a/sources/tech/20180611 How to partition a disk in Linux.md b/sources/tech/20180611 How to partition a disk in Linux.md new file mode 100644 index 0000000000..8ed451d114 --- /dev/null +++ b/sources/tech/20180611 How to partition a disk in Linux.md @@ -0,0 +1,185 @@ +How to partition a disk in Linux +====== + + +Creating and deleting partitions in Linux is a regular practice because storage devices (such as hard drives and USB drives) must be structured in some way before they can be used. In most cases, large storage devices are divided into separate sections called partitions. Partitioning also allows you to divide your hard drive into isolated sections, where each section behaves as its own hard drive. Partitioning is particularly useful if you run multiple operating systems. + +There are lots of powerful tools for creating, removing, and otherwise manipulating disk partitions in Linux. In this article, I'll explain how to use the `parted` command, which is particularly useful with large disk devices and many disk partitions. Differences between `parted` and the more common `fdisk` and `cfdisk` commands include: + + * **GPT format:** The `parted` command can create a Globally Unique Identifiers Partition Table [GPT][1]), while `fdisk` and `cfdisk` are limited to DOS partition tables. + * **Larger disks:** A DOS partition table can format up to 2TB of disk space, although up to 16TB is possible in some cases. However, a GPT partition table can address up to 8ZiB of space. + * **More partitions:** Using primary and extended partitions, DOS partition tables allow only 16 partitions. With GPT, you get up to 128 partitions by default and can choose to have many more. + * **Reliability:** Only one copy of the partition table is stored in a DOS partition. GPT keeps two copies of the partition table (at the beginning and the end of the disk). The GPT also uses a [CRC][2] checksum to check the partition table integrity, which is not done with DOS partitions. + + + +With today's larger disks and the need for more flexibility in working with them, using `parted` to work with disk partitions is recommended. Most of the time, disk partition tables are created as part of the operating system installation process. Direct use of the `parted` command is most useful when adding a storage device to an existing system. + +### Give 'parted' a try + +`parted` command. To try these steps, I strongly recommend using a brand new storage device or one where you don't mind wiping out the contents. + +The following explains the process of partitioning a storage device with thecommand. To try these steps, I strongly recommend using a brand new storage device or one where you don't mind wiping out the contents. + +**1\. List the partitions:** Use `parted -l` to identify the storage device you want to partition. Typically, the first hard disk (`/dev/sda` or `/dev/vda`) will contain the operating system, so look for another disk to find the one you want (e.g., `/dev/sdb`, `/dev/sdc`, `/dev/vdb`, `/dev/vdc`, etc.). +``` +$ sudo parted -l + +[sudo] password for daniel: + +Model: ATA RevuAhn_850X1TU5 (scsi) + +Disk /dev/vdc: 512GB + +Sector size (logical/physical): 512B/512B + +Partition Table: msdos + +Disk Flags: + + + +Number Start End Size Type File system Flags + + 1 1049kB 525MB 524MB primary ext4 boot + + 2 525MB 512GB 512GB primary lvm + +``` + +**2\. Open the storage device:** Use `parted` to begin working with the selected storage device. In this example, the device is the third disk on a virtual system (`/dev/vdc`). It is important to indicate the specific device you want to use. If you just type `parted` with no device name, it will randomly select a storage device to modify. +``` +$ sudo parted /dev/vdc + +GNU Parted 3.2 + +Using /dev/vdc + +Welcome to GNU Parted! Type 'help' to view a list of commands. + +(parted) + +``` + +**3\. Set the partition table:** Set the partition table type to GPT, then type "Yes" to accept it. +``` +(parted) mklabel gpt + +Warning: the existing disk label on /dev/vdc will be destroyed + +and all data on this disk will be lost. Do you want to continue? + +Yes/No? Yes + +``` + +The `mklabel` and `mktable` commands are used for the same purpose (making a partition table on a storage device). The supported partition tables are: aix, amiga, bsd, dvh, gpt, mac, ms-dos, pc98, sun, and loop. Remember `mklabel` will not make a partition, rather it will make a partition table. + +**4\. Review the partition table:** Show information about the storage device. +``` +(parted) print + +Model: Virtio Block Device (virtblk) + +Disk /dev/vdc: 1396MB + +Sector size (logical/physical): 512B/512B + +Partition Table: gpt + +Disk Flags: + +Number Start End Size File system Name Flags + +``` + +**5\. Get help:** To find out how to make a new partition, type: `(parted) help mkpart`. +``` +(parted) help mkpart + + mkpart PART-TYPE [FS-TYPE] START END make a partition + + + + PART-TYPE is one of: primary, logical, extended + + FS-TYPE is one of: btrfs, nilfs2, ext4, ext3, ext2, fat32, fat16, hfsx, hfs+, hfs, jfs, swsusp, + + linux-swap(v1), linux-swap(v0), ntfs, reiserfs, hp-ufs, sun-ufs, xfs, apfs2, apfs1, asfs, amufs5, + + amufs4, amufs3, amufs2, amufs1, amufs0, amufs, affs7, affs6, affs5, affs4, affs3, affs2, affs1, + + affs0, linux-swap, linux-swap(new), linux-swap(old) + + START and END are disk locations, such as 4GB or 10%. Negative values count from the end of the + + disk. For example, -1s specifies exactly the last sector. + + + + 'mkpart' makes a partition without creating a new file system on the partition. FS-TYPE may be + + specified to set an appropriate partition ID. + +``` + +**6\. Make a partition:** To make a new partition (in this example, 1,396MB on partition 0), type the following: +``` +(parted) mkpart primary 0 1396MB + + + +Warning: The resulting partition is not properly aligned for best performance + +Ignore/Cancel? I + + + +(parted) print + +Model: Virtio Block Device (virtblk) + +Disk /dev/vdc: 1396MB + +Sector size (logical/physical): 512B/512B + +Partition Table: gpt + +Disk Flags: + +Number Start End Size File system Name Flags + +1 17.4kB 1396MB 1396MB primary + +``` + +Filesystem type (fstype) will not create an ext4 filesystem on `/dev/vdc1`. A DOS partition table's partition types are primary, logical, and extended. In a GPT partition table, the partition type is used as the partition name. Providing a partition name under GPT is a must; in the above example, primary is the name, not the partition type. + +**7\. Save and quit:** Changes are automatically saved when you quit `parted`. To quit, type the following: +``` +(parted) quit + +Information: You may need to update /etc/fstab. + +$ + +``` + +### Words to the wise + +Make sure to identify the correct disk before you begin changing its partition table when you add a new storage device. If you mistakenly change the disk partition that contains your computer's operating system, you could make your system unbootable. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/6/how-partition-disk-linux + +作者:[Daniel Oh][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者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/daniel-oh +[1]:https://en.wikipedia.org/wiki/GUID_Partition_Table +[2]:https://en.wikipedia.org/wiki/Cyclic_redundancy_check diff --git a/sources/tech/20180611 Turn Your Raspberry Pi into a Tor Relay Node.md b/sources/tech/20180611 Turn Your Raspberry Pi into a Tor Relay Node.md new file mode 100644 index 0000000000..4ca5834bd8 --- /dev/null +++ b/sources/tech/20180611 Turn Your Raspberry Pi into a Tor Relay Node.md @@ -0,0 +1,133 @@ +Turn Your Raspberry Pi into a Tor Relay Node +====== + + + +If you’re anything like me, you probably got yourself a first- or second-generation Raspberry Pi board when they first came out, played with it for a while, but then shelved it and mostly forgot about it. After all, unless you’re a robotics enthusiast, you probably don’t have that much use for a computer with a pretty slow processor and 256 megabytes of RAM. This is not to say that there aren’t cool things you can do with one of these, but between work and other commitments, I just never seem to find the right time for some good old nerding out. + +However, if you would like to put it to good use without sacrificing too much of your time or resources, you can turn your old Raspberry Pi into a perfectly functioning Tor relay node. + +### What is a Tor Relay node + +You have probably heard about the [Tor project][1] before, but just in case you haven’t, here’s a very quick summary. The name “Tor” stands for “The Onion Router” and it is a technology created to combat online tracking and other privacy violations. + +Everything you do on the Internet leaves a set of digital footprints in every piece of equipment that your IP packets traverse: all of the switches, routers, load balancers and destination websites log the IP address from which your session originated and the IP address of the internet resource you are accessing (and often its hostname, [even when using HTTPS][2]). If you’re browsing from home, then your IP can be directly mapped to your household. If you’re using a VPN service ([as you should be][3]), then your IP can be mapped to your VPN provider, and then they are the ones who can map it to your household. In any case, odds are that someone somewhere is assembling an online profile on you based on the sites you visit and how much time you spend on each of them. Such profiles are then sold, aggregated with matching profiles collected from other services, and then monetized by ad networks. At least, that’s the optimist’s view of how that data is used -- I’m sure you can think of many examples of how your online usage profiles can be used against you in much more nefarious ways. + +The Tor project attempts to provide a solution to this problem by making it impossible (or, at least, unreasonably difficult) to trace the endpoints of your IP session. Tor achieves this by bouncing your connection through a chain of anonymizing relays, consisting of an entry node, relay node, and exit node: + + 1. The **entry node** only knows your IP address, and the IP address of the relay node, but not the final destination of the request; + + 2. The **relay node** only knows the IP address of the entry node and the IP address of the exit node, and neither the origin nor the final destination + + 3. The **exit node** **** only knows the IP address of the relay node and the final destination of the request; it is also the only node that can decrypt the traffic before sending it over to its final destination + + + + +Relay nodes play a crucial role in this exchange because they create a cryptographic barrier between the source of the request and the destination. Even if exit nodes are controlled by adversaries intent on stealing your data, they will not be able to know the source of the request without controlling the entire Tor relay chain. + +As long as there are plenty of relay nodes, your privacy when using the Tor network remains protected -- which is why I heartily recommend that you set up and run a relay node if you have some home bandwidth to spare. + +#### Things to keep in mind regarding Tor relays + +A Tor relay node only receives encrypted traffic and sends encrypted traffic -- it never accesses any other sites or resources online, so you do not need to worry that someone will browse any worrisome sites directly from your home IP address. Having said that, if you reside in a jurisdiction where offering anonymity-enhancing services is against the law, then, obviously, do not operate your own Tor relay. You may also want to check if operating a Tor relay is against the terms and conditions of your internet access provider. + +### What you will need + + * A Raspberry Pi (any model/generation) with some kind of enclosure + + * An SD card with [Raspbian Stretch Lite][4] + + * An ethernet cable + + * A micro-USB cable for power + + * A keyboard and an HDMI-capable monitor (to use during the setup) + + + + +This guide will assume that you are setting this up on your home connection behind a generic cable or ADSL modem router that performs NAT translation (and it almost certainly does). Most of them have a USB port you can use to power up your Raspberry Pi, and if you’re only using the wifi functionality of the router, then it should have a free ethernet port for you to plug into. However, before we get to the point where we can set-and-forget your Raspberry Pi, we’ll need to set it up as a Tor relay node, for which you’ll need a keyboard and a monitor. + +### The bootstrap script + +I’ve adapted a popular Tor relay node bootstrap script for use with Raspbian Stretch -- you can find it in my GitHub repository here: