Merge pull request #5 from LCTT/master

update
This commit is contained in:
MjSeven 2018-04-14 17:38:39 +08:00 committed by GitHub
commit 3f7a564f20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 2791 additions and 948 deletions

View File

@ -0,0 +1,121 @@
我的冒险旅程之迁移回 Windows
======
我已经主要使用 Linux 大约 10 年了,而且主要是 Ubuntu。但在最新发布的版本中我决定重新回到我通常不喜欢的操作系统 Windows 10。
![Ubuntu On Windows][1]
我一直是 Linux 的粉丝,我最喜欢的两个发行版是 Debian 和 Ubuntu。现今作为一个服务器操作系统Linux 是完美无暇的,但在桌面上一直存在不同程度的问题。
最近一系列的问题让我意识到,我不需要使用 Linux 作为我的桌面操作系统,我仍然是一个 Linux 粉丝,但基于我安装 Ubuntu 17.10 的经验,我已经决定回到 Windows。
### 什么使我选择了回归
问题是,当 Ubuntu 17.10 出来后,我像往常一样进行全新安装,但遇到了一些非常奇怪的新问题。
* Dell D3100 Dock 不再工作(包括临时规避方案也没用)
* Ubuntu 意外死机(随机)
* 双击桌面上的图标没反应
* 使用 HUD 搜索诸如“tweaks”之类的程序会尝试安装 META 桌面版本
* GUI 比标准的 GNOME 感觉更糟糕
现在我确实考虑回到使用 Ubuntu 16.04 或另一个发行版,但是我觉得 Unity 7 是最精致的桌面环境,而另外唯一一个优雅且稳定的是 Windows 10。
除此之外,使用 Linux 而不是使用 Windows 也有一些固有的问题,如:
* 大多数商用软件不可用E.G Maya、 PhotoShop、 Microsoft Office大多数情况下替代品并不相同等等。
* 大多数游戏都没有移植到 Linux 上,包括来自 EA、 Rockstar Ect. 等主要工作室的游戏。
* 对于大多数硬件来说,其 Linux 驱动程序是厂商的次要考虑。
在决定使用 Windows 之前,我确实考虑过其他发行版和操作系统。
与此同时,我看到了更多的“微软爱 Linux ”的行动,并且了解了 WSL。他们的新开发者的关注角度对我来说很有意思于是我试了一下。
### 我在 Windows 找到了什么
我使用计算机主要是为了编程我也使用虚拟机、git 和 ssh并且大部分工作依赖于 bash。我偶尔也会玩游戏观看 netflix 和一些轻松的办公室工作。
总之,我期待在 Ubuntu 中保留当前的工作流程并将其移植到 Windows 上。我也想利用 Windows 的优点。
* 所有的 PC 游戏支持 Windows
* 大多数程序是原生的
* 微软办公软件
虽然使用 Windows 有很多坑,但是我打算正确对待它,所以我不担心一般的 Windows 故障,例如病毒和恶意软件。
### Windows 的子系统 LinuxWindows 上的 Ubuntu 中的 Bash
微软与 Canonical 的密切合作将 Ubuntu 带到了 Windows 上。在经过快速设置和启动程序之后,你将拥有非常熟悉的 bash 界面。
我一直在研究其局限性,但是在写这篇文章时我碰到的唯一真正的限制是它从硬件中抽象了出来。例如,`lsblk` 不会显示你有什么分区,因为子系统里的 Ubuntu 没有提供这些信息。
但是除了访问底层工具之外,我发现其体验非常熟悉,也很棒。
我在下面的工作流程中使用了它。
* 生成 SSH 密钥对
* 使用 Git 和 Github 来管理我的仓库
* SSH 到几个服务器,包括不用密码
* 为本地数据库运行 MySQL
* 监视系统资源
* 使用 Vim 编辑配置文件
* 运行 Bash 脚本
* 运行本地 Web 服务器
* 运行 PHP、NodeJS
到目前为止,它已经被证明是非常强大的工具。除了是在 Windows 10 用户界面之中,我的工作流程感觉和我在 Ubuntu 上几乎一样。尽管我的多数工作可以在 WSL 中处理,但我仍然打算通过虚拟机进行更深入的工作,这可能超出了 WSL 的范围。
### 不需要用 Wine
我遇到的另一个主要问题是兼容性问题。我很少使用 Wine 来使用 Windows 软件。LCTT 译注Wine 是可以使 Linux 上运行 Windows 应用的软件)但是有时它是必需的,尽管通常体验不是很好。
#### HeidiSQL
我首先安装的程序之一是 HeidiSQL它是我最喜欢的数据库客户端之一。它可以在 Wine 下工作,但是感觉很不好,所以我在 Linux 下丢掉它而使用了 MySQL Workbench。回到了 Windows 中,就像一个可靠的老朋友回来了。
#### 游戏平台 / Steam
没有游戏的 Windows 电脑是无法想象的。我从 Steam 的网站上安装了它,我的 Linux 游戏,加上我的 Windows 游戏就变大了 5 倍,并且包括 GTA V LCTT 译注: GTA V 是一款名叫侠盗飞车的游戏) 等 AAA 级游戏。而这些我在 Ubuntu 中只能梦想。
我对 SteamOS 有很大的期望,并且一直会持续如此。但是我认为在可预见的将来,它不会在任何地方的游戏市场中崭露头角。所以如果你想在 PC 上玩游戏,你确实需要 Windows。
还有一点需要注意的是, 你的 nvidia 显卡的驱动程序会得到很好的支持,这使得像 TF2 LCTT 译注: 这是一款名叫军团要塞 2 的游戏)这样的一些 Linux 原生游戏运行的稍好一些。
**Windows 在游戏方面总是优越的,所以这并不令人感到意外。**
### 从 USB 硬盘运行,为什么
我在我的主固态硬盘上运行 Linux但在过去我是从 usb 棒和 usb 硬盘运行它的。我习惯了 Linux 的这种持久性,这让我可以在不丢失主要操作系统的情况下长期尝试多个版本。现在我尝试将 Windows 安装到 USB 连接的硬盘上时,它无法工作也不可能工作。所以当我将 Windows 硬盘分区的克隆作为备份时,我很惊讶我可以通过 USB 启动它。
这对我来说已经成为一个方便的选择,因为我打算将我的工作笔记本电脑迁移回 Windows但如果不想冒险那就把它扔在那里吧。
所以我在过去的几天里,我使用 USB 来运行它,除了一些错误的消息外,我没有通过 USB 运行发现它真正的缺点。
这样做主要的问题是:
* 较慢的启动速度
* 恼人的信息:不要拔掉你的 USB
* 无法激活它
**我可能会写一篇关于 USB 驱动器上的 Windows 的文章,这样我们可以有更详细的了解。**
### 那么结论是什么?
我使用 Windows 10 大约两周了,并没有注意到它对我的工作流程有任何的负面影响。尽管过程会有一些小问题,但我需要的所以工具都在手边,并且操作系统一般都在运行。
### 我会留在 Windows吗
虽然现在还为时尚早,但我想在可见的未来我会坚持使用 Windows。
--------------------------------------------------------------------------------
via: [https://www.chris-shaw.com/blog/my-adventure-migrating-back-to-windows](https://www.chris-shaw.com/blog/my-adventure-migrating-back-to-windows)
作者:[Christopher Shaw][a]
译者:[MjSeven](https://github.com/MjSeven)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.chris-shaw.com
[1]:https://winaero.com/blog/wp-content/uploads/2016/07/Ubutntu-on-Windows-10-logo-banner.jpg

View File

@ -1,11 +1,12 @@
为初学者提供的 Uniq 命令教程及示例
为初学者提供的 uniq 命令教程及示例
=====
如果你主要是在命令行上工作,并且每天处理大量的文本文件,那么你应该了解下 **Uniq** 命令。该命令会帮助你轻松地从文件中找到重复的行。它不仅用于查找重复项,而且我们还可以使用它来删除重复项,显示重复项的出现次数,只显示重复的行,只显示唯一的行等。由于 uniq 命令是 GNU coreutils 包的一部分,所以它预装在大多数 Linux 发行版中,让我们不需要费心安装。来看一些实际的例子。
如果你主要是在命令行上工作,并且每天处理大量的文本文件,那么你应该了解下 `uniq` 命令。该命令会帮助你轻松地从文件中找到重复的行。它不仅用于查找重复项,而且我们还可以使用它来删除重复项,显示重复项的出现次数,只显示重复的行,只显示唯一的行等。由于 `uniq` 命令是 GNU coreutils 包的一部分,所以它预装在大多数 Linux 发行版中,让我们不需要费心安装。来看一些实际的例子。
请注意,除非重复行是相邻的,否则 'uniq' 不会删除它们。因此,你可能需要先对它们进行排序,或将排序命令与 uniq 组合以获得结果。让我给你看一些例子。
请注意,除非重复行是相邻的,否则 `uniq` 不会删除它们。因此,你可能需要先对它们进行排序,或将排序命令与 `uniq` 组合以获得结果。让我给你看一些例子。
首先,让我们创建一个带有一些重复行的文件:
```
vi ostechnix.txt
```
@ -20,9 +21,10 @@ Top 500 super computers are powered by Linux
正如你在上面的文件中看到的,我们有一些重复的行(第一行和第二行,第三行和第五行是重复的)。
### **1\. 使用 Uniq 命令删除文件中的连续重复行**
### 1、 使用 uniq 命令删除文件中的连续重复行
如果你在不使用任何参数的情况下使用 `uniq` 命令,它将删除所有连续的重复行,只显示唯一的行。
如果你在不使用任何参数的情况下使用 'uniq' 命令,它将删除所有连续的重复行,只显示唯一的行。
```
uniq ostechnix.txt
```
@ -31,9 +33,10 @@ uniq ostechnix.txt
![][2]
如你所见, uniq 命令删除了给定文件中的所有连续重复行。你可能还注意到,上面的输出仍然有第二行和第四行重复了。这是因为 uniq 命令只有在相邻的情况下才会删除重复的行,当然,我们也可以删除非连续的重复行。请看下面的第二个例子。
如你所见, `uniq` 命令删除了给定文件中的所有连续重复行。你可能还注意到,上面的输出仍然有第二行和第四行重复了。这是因为 `uniq` 命令只有在相邻的情况下才会删除重复的行,当然,我们也可以删除非连续的重复行。请看下面的第二个例子。
### 2、 删除所有重复的行
### **2\. 删除所有重复的行**
```
sort ostechnix.txt | uniq
```
@ -42,16 +45,18 @@ sort ostechnix.txt | uniq
![][3]
看到了吗?没有重复的行。换句话说,上面的命令将显示在 ostechnix.txt 中只出现一次的行。我们使用 sort 命令与 uniq 命令结合,因为,就像我提到的,除非重复行是相邻的,否则 uniq 不会删除它们。
看到了吗?没有重复的行。换句话说,上面的命令将显示在 `ostechnix.txt` 中只出现一次的行。我们使用 `sort` 命令与 `uniq` 命令结合,因为,就像我提到的,除非重复行是相邻的,否则 `uniq` 不会删除它们。
### **3\. 只显示文件中唯一的一行**
### 3、 只显示文件中唯一的一行
为了只显示文件中唯一的一行,可以这样做:
```
sort ostechnix.txt | uniq -u
```
示例输出:
```
Linux is secure by default
Top 500 super computers are powered by Linux
@ -59,20 +64,23 @@ Top 500 super computers are powered by Linux
如你所见,在给定的文件中只有两行是唯一的。
### **4\. 只显示重复的行**
### 4、 只显示重复的行
同样的,我们也可以显示文件中重复的行,就像下面这样:
同样的,我们也可以显示文件中重复的行就像下面这样:
```
sort ostechnix.txt | uniq -d
```
示例输出:
```
Linus is the creator of Linux.
welcome to ostechnix
```
这两行在 ostechnix.txt 文件中是重复的行。请注意 -d(小写 d) 将会**只打印重复的行****每组有一个**。打印**所有重复的行**,使用 -D(大写 D),如下所示:
这两行在 `ostechnix.txt` 文件中是重复的行。请注意 `-d`(小写 `d` 将会只打印重复的行,每组显示一个。打印所有重复的行,使用 `-D`(大写 `D`),如下所示:
```
sort ostechnix.txt | uniq -D
```
@ -81,14 +89,16 @@ sort ostechnix.txt | uniq -D
![][4]
### **5\. 显示文件中每一行的出现次数**
### 5、 显示文件中每一行的出现次数
由于某种原因,你可能想要检查给定文件中每一行重复出现的次数。要做到这一点,使用 `-c` 选项,如下所示:
由于某种原因,你可能想要检查给定文件中每一行重复出现的次数。要做到这一点,使用 **-c** 选项,如下所示:
```
sort ostechnix.txt | uniq -c
```
**示例输出:**
示例输出:
```
2 Linus is the creator of Linux.
1 Linux is secure by default
@ -97,11 +107,13 @@ sort ostechnix.txt | uniq -c
```
我们还可以按照每一行的出现次数进行排序,然后显示,如下所示:
```
sort ostechnix.txt | uniq -c | sort -nr
```
示例输出:
```
2 welcome to ostechnix
2 Linus is the creator of Linux.
@ -109,35 +121,39 @@ sort ostechnix.txt | uniq -c | sort -nr
1 Linux is secure by default
```
### 6\. 将比较限制为 'N' 个字符
### 6、 将比较限制为 N 个字符
我们可以使用 `-w` 选项来限制对文件中特定数量字符的比较。例如,让我们比较文件中的前四个字符,并显示重复行,如下所示:
我们可以使用 -w 选项来限制对文件中特定数量字符的比较。例如,让我们比较文件中的前四个字符,并显示重复行,如下所示:
```
uniq -d -w 4 ostechnix.txt
```
### 7\. 忽略比较指定的 'N' 个字符
### 7、 忽略比较指定的 N 个字符
像对文件中行的 N 个字符进行限制比较一样,我们也可以使用 -s 选项来忽略比较前 N 个字符。
像对文件中行的 N 个字符进行限制比较一样,我们也可以使用 `-s` 选项来忽略比较前 N 个字符。
下面的命令将忽略在文件中每行的前四个字符进行比较:
```
uniq -d -s 4 ostechnix.txt
```
为了忽略比较前 N 字段(译注:即前几列)而不是字符,在上面的命令中使用 '-f' 选项。
为了忽略比较前 N 字段(LCTT 译注:即前几列)而不是字符,在上面的命令中使用 `-f` 选项。
欲了解更多详情,请参考帮助部分:
```
uniq --help
```
也可以使用 man 命令查看:
也可以使用 `man` 命令查看:
```
man uniq
```
今天就到这里!我希望你现在对 uniq 命令及其目的有一个基本的了解。如果你发现我们的指南有用,请在你的社交网络上分享,并继续支持 OSTechNix。更多好东西要来了,请继续关注!
今天就到这里!我希望你现在对 `uniq` 命令及其目的有一个基本的了解。如果你发现我们的指南有用,请在你的社交网络上分享,并继续支持我们。更多好东西要来了,请继续关注!
干杯!
@ -145,9 +161,9 @@ man uniq
via: https://www.ostechnix.com/uniq-command-tutorial-examples-beginners/
作者:[][a]
作者:[SK][a]
译者:[MjSeven](https://github.com/MjSeven)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -3,181 +3,160 @@
![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/container-image_0.jpg?itok=G_Gz80R9)
在 [前面的文章][1] 中,我们学习了在 Linux、macOS、以及 Windows 上如何使用 Docker 的基础知识。在这篇文章中,我们将学习创建 Docker 镜像的基本知识。我们可以在 DockerHub 上得到用于你自己的项目的预构建镜像,并且也可以将你自己的镜像发布到这里。
在 [前面的文章][1] 中,我们学习了在 Linux、macOS、以及 Windows 上如何使用 Docker 的基础知识。在这篇文章中,我们将学习创建 Docker 镜像的基本知识。我们可以在 DockerHub 上得到可用于你自己的项目的预构建镜像,并且也可以将你自己的镜像发布到这里。
我们使用预构建镜像得到一个基本的 Linux 子系统,因为,从头开始构建需要大量的工作。你可以得到 Alpine Docker 版使用的官方版本、Ubuntu、BusyBox、或者 scratch。在我们的示例中我将使用 Ubuntu。
我们使用预构建镜像得到一个基本的 Linux 子系统,因为,从头开始构建需要大量的工作。你可以使用 Alpine Docker 版使用的官方版本、Ubuntu、BusyBox、或者 scratch。在我们的示例中我将使用 Ubuntu。
在我们开始构建镜像之前,让我们先“容器化”它们!我的意思是,为你的所有 Docker 镜像创建目录,这样你就可以维护不同的项目和阶段,并保持它们彼此隔离。
```
$ mkdir dockerprojects
cd dockerprojects
```
现在,在 `dockerprojects` 目录中,你可以使用自己喜欢的文本编辑器去创建一个 `Dockerfile` 文件;我喜欢使用 nano它对新手来说很容易上手。
```
$ nano Dockerfile
```
然后添加这样的一行内容:
```
FROM Ubuntu
```
![m7_f7No0pmZr2iQmEOH5_ID6MDG2oEnODpQZkUL7][2]
![][2]
使用 Ctrl+Exit 然后选择 Y 去保存它。
使用 `Ctrl+Exit` 然后选择 `Y` 去保存它。
现在开始创建你的新镜像,然后给它起一个名字(在刚才的目录中运行如下的命令):
```
$ docker build -t dockp .
```
(注意命令后面的圆点)这样就创建成功了,因此,你将看到如下内容:
```
Sending build context to Docker daemon 2.048kB
Sending build context to Docker daemon 2.048kB
Step 1/1 : FROM ubuntu
---> 2a4cca5ac898
Successfully built 2a4cca5ac898
Successfully tagged dockp:latest
```
现在去运行和测试一下你的镜像:
```
$ docker run -it Ubuntu
```
你将看到 root 提示符:
```
root@c06fcd6af0e8:/#
```
这意味着在 Linux、Windows、或者 macOS 中你可以运行一个最小的 Ubuntu 了。你可以运行所有的 Ubuntu 原生命令或者 CLI 实用程序。
![vpZ8ts9oq3uk--z4n6KP3DD3uD_P4EpG7fX06MC3][3]
![][3]
我们来查看一下在你的目录下你拥有的所有 Docker 镜像:
```
$docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
dockp latest 2a4cca5ac898 1 hour ago 111MB
ubuntu latest 2a4cca5ac898 1 hour ago 111MB
hello-world latest f2a91732366c 8 weeks ago 1.85kB
```
你可以看到共有三个镜像dockp、Ubuntu、和 hello-world hello-world 是我在几周前创建的,这一系列的前面的文章就是在它下面工作的。构建一个完整的 LAMP 栈可能是一个挑战,因此,我们使用 Dockerfile 去创建一个简单的 Apache 服务器镜像。
你可以看到共有三个镜像:`dockp``Ubuntu`、和 `hello-world` `hello-world` 是我在几周前创建的,这一系列的前面的文章就是在它下面工作的。构建一个完整的 LAMP 栈可能是一个挑战,因此,我们使用 Dockerfile 去创建一个简单的 Apache 服务器镜像。
从本质上说Dockerfile 是安装所有需要的包、配置、以及拷贝文件的一套指令。在这个案例中,它是安装配置 Apache 和 Nginx。
你也可以在 DockerHub 上去创建一个帐户,然后在构建镜像之前登入到你的帐户,在这个案例中,你需要从 DockerHub 上拉取一些东西。从命令行中登入 DockerHub运行如下所求的命令
```
$ docker login
```
在登入时输入你的用户名和密码。
接下来,为这个 Docker 项目,在目录中创建一个 Apache 目录:
```
$ mkdir apache
```
在 Apache 目录中创建 Dockerfile 文件:
```
$ nano Dockerfile
```
然后,粘贴下列内容:
```
FROM ubuntu
MAINTAINER Kimbro Staken version: 0.1
RUN apt-get update && apt-get install -y apache2 && apt-get clean && rm -rf /var/lib/apt/lists/*
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
EXPOSE 80
CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]
```
然后,构建镜像:
```
docker build -t apache .
```
(注意命令尾部的空格和圆点)
这将花费一些时间,然后你将看到如下的构建成功的消息:
```
Successfully built e7083fd898c7
Successfully tagged ng:latest
Swapnil:apache swapnil$
```
现在,我们来运行一下这个服务器:
```
$ docker run -d apache
a189a4db0f7c245dd6c934ef7164f3ddde09e1f3018b5b90350df8be85c8dc98
```
发现了吗,你的容器镜像已经运行了。可以运行如下的命令来检查所有运行的容器:
```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED
a189a4db0f7 apache "/usr/sbin/apache2ctl" 10 seconds ago
```
你可以使用 docker kill 命令来杀死容器:
你可以使用 `docker kill` 命令来杀死容器:
```
$docker kill a189a4db0f7
```
正如你所见,这个 "镜像" 它已经永久存在于你的目录中了,而不论运行与否。现在你可以根据你的需要创建很多的镜像,并且可以从这些镜像中繁衍出来更多的镜像。
正如你所见,这个 “镜像” 它已经永久存在于你的目录中了,而不论运行与否。现在你可以根据你的需要创建很多的镜像,并且可以从这些镜像中繁衍出来更多的镜像。
这就是如何去创建镜像和运行容器。
想学习更多内容,你可以打开你的浏览器,然后找到更多的关于如何构建像 LAMP 栈这样的完整的 Docker 镜像的文档。这里有一个帮你实现它的 [ Dockerfile][4] 文件。在下一篇文章中,我将演示如何推送一个镜像到 DockerHub。
想学习更多内容,你可以打开你的浏览器,然后找到更多的关于如何构建像 LAMP 栈这样的完整的 Docker 镜像的文档。这里有一个帮你实现它的 [Dockerfile][4] 文件。在下一篇文章中,我将演示如何推送一个镜像到 DockerHub。
你可以通过来自 Linux 基金会和 edX 的 ["介绍 Linux" ][5] 免费课程来学习更多的知识。
你可以通过来自 Linux 基金会和 edX 的 [“介绍 Linux”][5] 免费课程来学习更多的知识。
--------------------------------------------------------------------------------
@ -185,7 +164,7 @@ via: https://www.linux.com/blog/learn/intro-to-linux/2018/1/how-create-docker-im
作者:[SWAPNIL BHARTIYA][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/) 荣誉推出

View File

@ -1,12 +1,11 @@
Linux 中如何打印和管理打印机
完全指南:在 Linux 中如何打印和管理打印机
======
### Linux 中的打印
虽然现在大量的沟通都是电子化和无纸化的,但是在我们的公司中还有大量的材料需要打印。银行结算单、公用事业帐单、财务和其它报告、以及收益结算单等一些东西还是需要打印的。本教程将介绍在 Linux 中如何使用 CUPS 去打印。
CUPS通用 Unix 打印系统Common UNIX Printing System的首字母缩写,它是 Linux 中的打印机和打印任务的管理者。早期计算机上的打印机一般是在特定的字符集和字体大小下打印文本文件行。现在的图形打印机可以打印各种字体和大小的文本和图形。尽管如此,现在你所使用的一些命令,在它们以前的历史上仍旧使用的是古老的行打印守护进程LPD技术。
CUPS<ruby>通用 Unix 打印系统<rt>Common UNIX Printing System</rt></ruby>的首字母缩写,它是 Linux 中的打印机和打印任务的管理者。早期计算机上的打印机一般是在特定的字符集和字体大小下打印文本文件行。现在的图形打印机可以打印各种字体和大小的文本和图形。尽管如此,现在你所使用的一些命令,在古老的行打印守护进程LPD技术的历史中仍能找到它们
本教程将帮你了解 Linux 服务器专业考试LPIC-1的第 108 号主题的 108.4 目标。这个目标的权重为 2。
@ -20,38 +19,39 @@ CUPS是通用 Unix 打印系统Common UNIX Printing System的首字母
这一小部分历史并不是 LPI 目标的,但它有助于你理解这个目标的相关环境。
早期的计算机大都使用行打印机。这些都是击打式打印机,一段时间以来,它们使用固定间距的字符和单一的字体来打印文本行。为提升整个系统性能,早期的主机都对慢速的外围设备如读卡器、卡片穿孔机、和运行其它工作的行打印进行交叉工作。因此就产生了在行上或者假脱机上的同步外围操作,这一术语目前在谈到计算机打印时仍然在使用。
早期的计算机大都使用行式打印机。这些都是击打式打印机,那时,它们使用固定间距的字符和单一的字体来打印文本行。为提升整个系统性能,早期的主机要与慢速的外围设备(如读卡器、卡片穿孔机、和运行其它工作的行式打印机)交叉进行工作。因此就产生了在线的或者假脱机的同步外围操作,这一术语目前在谈到计算机打印时仍然在使用。
在 UNIX 和 Linux 系统上,打印初始化使用的是 BSDBerkeley Software Distribution打印子系统它是由一个作为服务器运行的行打印守护程序LPD组成而客户端命令如 `lpr` 是用于提交打印作业。这个协议后来被 IETF 标准化为 RFC 1179 —— **行打印机守护协议**。
在 UNIX 和 Linux 系统上,打印初始化使用的是 BSD<ruby>伯克利软件分发版<rt>Berkeley Software Distribution</rt></ruby>)打印子系统,它是由一个作为服务器运行的行打印守护程序LPD组成而客户端命令如 `lpr` 是用于提交打印作业。这个协议后来被 IETF 标准化为 RFC 1179 —— **行打印机守护进程协议**。
系统也有一个打印守护程序。它的功能与BSD 的 LPD 守护程序类似,但是它们的命令集不一样。你在后面会经常看到完成相同的任务使用不同选项的两个命令。例如,对于打印文件的命令,`lpr` 是伯克利实现的,而 `lp` 是 System V 实现的
System V 也有一个打印守护程序。它的功能与BSD 的 LPD 守护程序类似,但是它们的命令集不一样。你在后面会经常看到完成相同的任务使用不同选项的两个命令。例如,对于打印文件的命令,伯克利实现版本是 `lpr`,而 System V 实现版本是 `lp`
随着打印机技术的进步,在一个页面上混合出现不同字体成为可能,并且可以将图片像文字一样打印。可变间距字体,以及更多先进的打印技术,比如 kerning 和 ligatures现在都已经标准化。它们对基本的 lpd/lpr 方法进行了改进设计,比如 LPRng下一代的 LPR、以及 CUPS。
随着打印机技术的进步,在一个页面上混合出现不同字体成为可能,并且可以将图片像文字一样打印。可变间距字体,以及更多先进的打印技术,比如间距和连字符,现在都已经标准化。出现了几种对基本的 lpd/lpr 方法等改进设计,比如 LPRng下一代的 LPR以及 CUPS。
许多可以打印图形的打印机,使用 Adobe PostScript 语言进行初始化。一个 PostScript 打印机有一个解释器引擎它可以解释打印任务中的命令并从这些命令中生成最终的页面。PostScript 经常被用做原始文件和打印机之间的中间层,比如一个文本文件或者一个图像文件,以及没有适合 PostScript 功能的特定打印机的最终格式。转换这些特定的打印任务,比如一个 ASCII 文本文件或者一个 JPEG 图像转换为 PostScript然后再使用过滤器转换 PostScript 到非 PostScript 打印机所需要的最终光栅格式。
许多可以打印图形的打印机,使用 Adobe PostScript 语言进行初始化。一个 PostScript 打印机有一个解释器引擎它可以解释打印任务中的命令并从这些命令中生成最终的页面。PostScript 经常被用做原始文件(比如一个文本文件或者一个图像文件)和最终格式没有适合的 PostScript 功能的特定打印机之间的中间层。转换这些特定的打印任务,比如将一个 ASCII 文本文件或者一个 JPEG 图像转换为 PostScript然后再使用过滤器转换 PostScript 到非 PostScript 打印机所需要的最终光栅格式。
现在的便携式文档格式PDF它就是基于 PostScript 的,已经替换了传统的原始 PostScript。PDF 设计为与硬件和软件无关,它封装了要打印的页面的完整描述。你可以查看 PDF 文件,同时也可以打印它们
现在的<ruby>便携式文档格式<rt>Portable Document Format</rt></ruby>PDF它就是基于 PostScript 的,已经替换了传统的原始 PostScript。PDF 设计为与硬件和软件无关,它封装了要打印的页面的完整描述。你可以查看 以及打印 PDF 文件。
### 管理打印队列
用户直接打印作业到一个名为打印队列的逻辑实体。在单用户系统中,一个打印队列和一个打印机通常是几乎相同的意思。但是CUPS 允许系统对最终在一个远程系统上的打印,并不附属打印机到一个队列打印作业上,而是通过使用类,允许将打印作业重定向到该类第一个可用的打印机上
用户直接打印作业到一个名为<ruby>打印队列<rt>print queue</rt></ruby>的逻辑实体。在单用户系统中打印队列和打印机通常是几乎相同的意思。但是CUPS 允许系统不用连接到一个打印机上,而最终在一个远程系统上的排队打印作业,并且通过使用分类,允许将定向到一个分类的打印作业在该分类第一个可用的打印机上打印
你可以检查和管理打印队列。对于 CUPS 来说,其中一些命令还是很新的。另外的一些是源于 LPD 的兼容命令,不过现在的一些选项通常是原始 LPD 打印系统选项的有限子集。
你可以检查和管理打印队列。对于 CUPS 来说,其中一些命令实现了一些新操作。另外的一些是源于 LPD 的兼容命令,不过现在的一些选项通常是最初的 LPD 打印系统选项的有限子集。
你可以使用 CUPS 的 `lpstat` 命令去检查队列,以了解打印系统。一些常见命令如下表 1。
###### 表 1. lpstat 命令的选项
| 选项 | 作用 |
| -a | 显示打印机状态 |
| -c | 显示打印类 |
| -p | 显示打印状态enabled 或者 disabled. |
| -s | 显示默认打印机、打印机和类。相当于 -d -c -v。**注意:为指定多个选项,这些选项必须像值一样分隔开。**|
| -s | 显示打印机和它们的设备。 |
你可以使用 CUPS 的 `lpstat` 命令去检查队列,以了解打印系统。一些常见选项如下表 1。
你也可以使用 LPD 的 `lpc` 命令,它可以在 /usr/sbin 中找到,使用它的 `status` 选项。如果你不想指定打印机名字,将列出所有的队列。列表 1 展示了命令的一些示例。
| 选项 | 作用 |
| --- | --- |
| `-a` | 显示打印机状态 |
| `-c` | 显示打印分类 |
| `-p` | 显示打印状态:`enabled` 或者 `disabled` |
| `-s` | 显示默认打印机、打印机和类。相当于 `-d -c -v`。**注意:要指定多个选项,这些选项必须像值一样分隔开。**|
| `-v` | 显示打印机和它们的设备。|
*表 1. lpstat 命令的选项*
你也可以使用 LPD 的 `lpc` 命令(它可以在 `/usr/sbin` 中找到)使用它的 `status` 选项。如果你不想指定打印机名字,将列出所有的队列。列表 1 展示了命令的一些示例。
###### 列表 1. 显示可用打印队列
```
[ian@atticf27 ~]$ lpstat -d
system default destination: HL-2280DW
@ -77,11 +77,12 @@ HL-2280DW:
```
这个示例展示了两台打印机 —— HL-2280DW 和 XP-610和一个类 `anyprint`,它允许打印作业定向到这两台打印机中的第一个可用打印机。
*列表 1. 显示可用打印队列*
在这个示例中,已经禁用了打印到 HL-2280DW 队列,但是打印是启用的,这样便于打印机脱机维护之前可以完成打印队列中的任务。无论队列是启用还是禁用,都可以使用 `cupsaccept``cupsreject` 命令来管理它们。你或许可能在 /usr/sbin 中找到这些命令,它们现在都是链接到新的命令上。同样,无论打印是启用还是禁用,你都可以使用 `cupsenable``cupsdisable` 命令来管理它们。在早期版本的 CUPS 中,这些被称为 `enable``disable`,它也许会与 bash shell 内置的 `enable` 混淆。列表 2 展示了如何去启用打印机 HL-2280DW 上的队列不过它的打印还是禁止的。CUPS 的几个命令支持使用一个 `-r` 选项去提供一个动作的理由。这个理由会在你使用 `lpstat` 时显示,但是如果你使用的是 `lpc` 命令则不会显示它。
这个示例展示了两台打印机 —— HL-2280DW 和 XP-610和一个分类 `anyprint`,它允许打印作业定向到这两台打印机中的第一个可用打印机。
在这个示例中,已经禁用了打印到 HL-2280DW 队列,但是打印功能是启用的,这样便于将打印机脱机维护之前可以完成打印队列中的任务。启用还是禁用队列,可以使用 `cupsaccept``cupsreject` 命令来管理。以前它们叫做 `accept``reject`,你或许可能在 `/usr/sbin` 中找到这些命令,但它们现在都是符号链接到新的命令上了。同样,启用还是禁用打印,你可以使用 `cupsenable``cupsdisable` 命令来管理。在早期版本的 CUPS 中,这些被称为 `enable``disable`,它也许会与 bash shell 内置的 `enable` 混淆。列表 2 展示了如何去启用打印机 HL-2280DW 上的队列而禁止它的打印。CUPS 的几个命令支持使用 `-r` 选项去提供一个该操作的理由。这个理由会在你使用 `lpstat` 时显示,但是如果你使用的是 `lpc` 命令则不会显示它。
###### 列表 2. 启用队列和禁用打印
```
[ian@atticf27 ~]$ lpstat -a -p HL-2280DW
anyprint accepting requests since Mon 29 Jan 2018 01:17:09 PM EST
@ -100,16 +101,16 @@ printer XP-610 is idle. enabled since Thu 27 Apr 2017 05:53:59 PM EDT
anyprint accepting requests since Mon 29 Jan 2018 01:17:09 PM EST
HL-2280DW accepting requests since Mon 29 Jan 2018 04:03:50 PM EST
XP-610 accepting requests since Thu 27 Apr 2017 05:53:59 PM EDT
```
注意:用户执行这些任务必须经过授权。它可能要求是 root 用户或者其它的授权用户。在 /etc/cups/cups-files.conf 中可以看到 SystemGroup 的条目cups-files.conf 的 man 页面有更多授权用户组的信息。
*列表 2. 启用队列和禁用打印*
注意:用户执行这些任务必须经过授权。它可能要求是 root 用户或者其它的授权用户。在 `/etc/cups/cups-files.conf` 中可以看到 `SystemGroup` 的条目,`cups-files.conf` 的 man 页面有更多授权用户组的信息。
### 管理用户打印作业
现在,你已经知道了一些如何去检查打印队列和类的方法,我将给你展示如何管理打印队列上的作业。你要做的第一件事是,如何找到一个特定打印机或者全部打印机上排队的任意作业。完成上述工作要使用 `lpq` 命令。如果没有指定任何选项,`lpq` 将显示默认打印机上的队列。使用 `-P` 选项和一个打印机名字将指定打印机,或者使用 `-a` 选项去指定所有的打印机,如下面的列表 3 所示。
###### 列表 3. 使用 lpq 检查打印队列
```
[pat@atticf27 ~]$ # As user pat (non-administrator)
[pat@atticf27 ~]$ lpq
@ -132,16 +133,16 @@ Rank Owner Job File(s) Total Size
3rd pat 7 bitlib.C 6144 bytes
4th ian 8 .bashrc 1024 bytes
5th ian 9 .bashrc 1024 bytes
```
在这个示例中,共有五个作业,它们是 4、6、7、8、和 9并且它是名为 HL-2280DW 的打印机的队列,而不是 XP-610 的。在这个示例中使用 `-P` 选项可简单地显示那个打印机已经准备好但是没有队列任务。注意CUPS 的打印机命名,大小写是不敏感的。还要注意的是,用户 ian 提交了同样的作业两次,当一个作业第一次没有打印时,经常能看到用户的这种动作。
*列表 3. 使用 lpq 检查打印队列*
一般情况下你可能查看或者维护你自己的打印作业但是root 用户或者其它授权的用户通常会去管理其它打印作业。大多数 CUPS 命令都可以使用一个 `-E` 选项,对 CUPS 服务器与客户端之间的通讯进行加密
在这个示例中,共有五个作业,它们是 4、6、7、8、和 9并且它是名为 HL-2280DW 的打印机的队列,而不是 XP-610 的。在这个示例中使用 `-P` 选项可简单地显示哪个打印机已经准备好但是没有队列任务。注意CUPS 的打印机命名,是大小写不敏感的。还要注意的是,用户 ian 提交了同样的作业两次,当一个作业没有第一时间打印时,经常能看到用户的这种动作
使用 `lprm` 命令从队列中去删除 .bashrc 作业。如果不使用选项,将删除当前的作业。使用 `-` 选项,将删除全部的作业。要么就如列表 4 那样,指定一个要删除的作业列表。
一般情况下你可能会查看或者维护你自己的打印作业但是root 用户或者其它授权的用户通常会去管理其它打印作业。大多数 CUPS 命令都可以使用一个 `-E` 选项,对 CUPS 服务器与客户端之间的通讯进行加密。
使用 `lprm` 命令从队列中去删除一个 `.bashrc` 作业。如果不使用选项,将删除当前的作业。使用 `-` 选项,将删除全部的作业。要么就如列表 4 那样,指定一个要删除的作业列表。
###### 列表 4. 使用 lprm 删除打印作业
```
[[pat@atticf27 ~]$ # As user pat (non-administrator)
[pat@atticf27 ~]$ lprm
@ -156,14 +157,14 @@ Rank Owner Job File(s) Total Size
2nd pat 6 bitlib.h 6144 bytes
3rd pat 7 bitlib.C 6144 bytes
4th ian 9 .bashrc 1024 bytes
```
*列表 4. 使用 lprm 删除打印作业*
注意,用户 pat 不能删除队列中的第一个作业,因为它是用户 ian 的。但是ian 可以删除他自己的 8 号作业。
另外的可以帮你操作打印队列中的作业的命令是 `lp`。使用它可以去修改作业属性,比如打印数量或者优先级。我们假设用户 ian 希望他的作业 9 在用户 pat 的作业之前打印,并且希望打印两份。作业优先级的默认值是 50它的优先级范围从最低的 1 到最高的 100 之间。用户 ian 可以使用 `-i`、`-n`、以及 `-q` 选项去指定一个要修改的作业,而新的打印数量和优先级可以如下面的列表 5 所示的那样去修改。注意,使用 `-l` 选项的 `lpq` 命令可以提供更详细的输出。
###### 列表 5. 使用 lp 去改变打印数量和优先级
```
[ian@atticf27 ~]$ lpq
HL-2280DW is not ready
@ -180,12 +181,12 @@ Rank Owner Job File(s) Total Size
2nd ian 4 permutation.C 6144 bytes
3rd pat 6 bitlib.h 6144 bytes
4th pat 7 bitlib.C 6144 bytes
```
最后,`lpmove` 命令可以允许一个作业从一个队列移动到另一个队列。例如,我们可能因为打印机 HL-2280DW 现在不能使用,而想去移动一个作业到另外的队列上。你可以指定一个作业编号,比如 9或者你可以用一个队列名加一个连字符去限定它比如HL-2280DW-0。`lpmove` 命令的操作要求一个授权用户。列表 6 展示了如何去从一个队列移动作业到另外的队列,通过打印机和作业 ID 指定第一个,然后指定打印机的所有作业都移动到第二个队列。稍后我们可以去再次检查队列,其中一个作业已经在打印中了。
*列表 5. 使用 lp 去改变打印数量和优先级*
最后,`lpmove` 命令可以允许一个作业从一个队列移动到另一个队列。例如,我们可能因为打印机 HL-2280DW 现在不能使用,而想去移动一个作业到另外的队列上。你可以指定一个作业编号,比如 9或者你可以用一个队列名加一个连字符去限定它比如HL-2280DW-0。`lpmove` 命令的操作要求是授权用户。列表 6 展示了如何去从一个队列移动作业到另外的队列,先是指定打印机和作业 ID 移动,然后是移动指定打印机的所有作业。稍后我们可以去再次检查队列,其中一个作业已经在打印中了。
###### 列表 6. 使用 lpmove 移动作业到另外一个打印队列
```
[ian@atticf27 ~]$ lpmove HL-2280DW-9 anyprint
[ian@atticf27 ~]$ lpmove HL-2280DW xp-610
@ -200,44 +201,46 @@ active ian 9 .bashrc 1024 bytes
Rank Owner Job File(s) Total Size
active pat 6 bitlib.h 6144 bytes
1st pat 7 bitlib.C 6144 bytes
```
如果你使用的是打印服务器而不是 CUPS比如 LPD 或者 LPRng大多数的队列管理功能是由 `lpc` 命令的子命令来处理的。例如,你可以使用 `lpc topq` 去移动一个作业到队列的顶端。其它的 `lpc` 子命令包括 `disable`、`down`、`enable`、`hold`、`move`、`redirect`、`release`、和 `start`。这些子命令在 CUPS 的兼容命令中没有实现。
*列表 6. 使用 lpmove 移动作业到另外一个打印队列*
如果你使用的是 CUPS 之外的打印服务器,比如 LPD 或者 LPRng大多数的队列管理功能是由 `lpc` 命令的子命令来处理的。例如,你可以使用 `lpc topq` 去移动一个作业到队列的顶端。其它的 `lpc` 子命令包括 `disable`、`down`、`enable`、`hold`、`move`、`redirect`、`release`、和 `start`。这些子命令在 CUPS 的兼容命令中没有实现。
#### 打印文件
如何去打印创建的作业?大多数图形界面程序都提供了一个打印方法,通常是 **文件** 菜单下面的选项。这些程序为选择打印机、设置页边距、彩色或者黑白打印、打印数量、选择每张纸打印的页面数(每张纸打印两个页面,通常用于讲义)等等,都提供了图形化的工具。现在,我将为你展示如何使用命令行工具去管理这些功能,然后和图形化实现进行比较。
打印文件最简单的方法是使用 `lpr` 命令,然后提供一个文件名字。这将在默认打印机上打印这个文件。`lp` 命令不仅可以打印文件,也可以修改打印作业。列表 7 展示了使用这个命令的一个简单示例。注意,`lpr` 会静默处理这个作业,但是 `lp` 会显示处理后的作业的 ID。
打印文件最简单的方法是使用 `lpr` 命令,然后提供一个文件名字。这将在默认打印机上打印这个文件。`lp` 命令不仅可以打印文件,也可以修改打印作业。列表 7 展示了使用这个命令的一个简单示例。注意,`lpr` 会静默处理这个作业,但是 `lp` 会显示处理后的作业的 ID。
###### 列表 7. 使用 lpr 和 lp 打印
```
[ian@atticf27 ~]$ echo "Print this text" > printexample.txt
[ian@atticf27 ~]$ lpr printexample.txt
[ian@atticf27 ~]$ lp printexample.txt
request id is HL-2280DW-12 (1 file(s))
```
*列表 7. 使用 lpr 和 lp 打印*
表 2 展示了 `lpr` 上你可以使用的一些选项。注意, `lp` 的选项和 `lpr` 的很类似,但是名字可能不一样;例如,`-#` 在 `lpr` 上是相当于 `lp``-n` 选项。查看 man 页面了解更多的信息。
###### 表 2. lpr 的选项
| 选项 | 作用 |
| -C, -J, or -T | 设置一个作业名字。 |
| -P | 选择一个指定的打印机。 |
| -# | 指定打印数量。注意它与 lp 命令的 -n 有点差别。|
| -m | 在作业完成时发送电子邮件。 |
| -l | 表示打印文件已经为打印做好格式准备。相当于 -o raw。 |
| -o | 设置一个作业选项。 |
| -p | 格式化一个带有阴影标题的文本文件。相关于 -o prettyprint。 |
| -q | 暂缓(或排队)最后的打印作业。 |
| -r | 在文件进入打印池之后,删除文件。 |
| 选项 | 作用 |
|---|---|
| `-C` `-J``-T` | 设置一个作业名字。 |
| `-P` | 选择一个指定的打印机。|
| `-#` | 指定打印数量。注意这不同于 `lp` 命令的 `-n` 选项。|
| `-m` | 在作业完成时发送电子邮件。|
| `-l` | 表示打印文件已经为打印做好格式准备。相当于 `-o raw`。 |
| `-o` | 设置一个作业选项。|
| `-p` | 格式化一个带有阴影标题的文本文件。相关于 `-o prettyprint`。|
| `-q` | 暂缓(或排队)后面的打印作业。|
| `-r` | 在文件进入打印池之后,删除文件。 |
*表 2. lpr 的选项*
列表 8 展示了一些选项。我要求打印之后给我发确认电子邮件,那个作业被暂缓执行,并且在打印之后删除文件。
###### 列表 8. 使用 lpr 打印
```
[ian@atticf27 ~]$ lpr -P HL-2280DW -J "Ian's text file" -#2 -m -p -q -r printexample.txt
[[ian@atticf27 ~]$ lpq -l
@ -248,20 +251,20 @@ ian: 1st [job 13 localhost]
2 copies of Ian's text file 1024 bytes
[ian@atticf27 ~]$ ls printexample.txt
ls: cannot access 'printexample.txt': No such file or directory
```
我现在有一个在 HL-2280DW 打印队列上暂缓执行的作业。怎么做到这样?`lp` 命令有一个选项可以暂缓或者投放作业,使用 `-H` 选项是使用各种值。列表 9 展示了如何投放被暂缓的作业。检查 `lp` 命令的 man 页面了解其它选项的信息。
*列表 8. 使用 lpr 打印*
我现在有一个在 HL-2280DW 打印队列上暂缓执行的作业。然后怎么做?`lp` 命令可以通过使用 `-H` 的各种选项来暂缓或者投放作业。列表 9 展示了如何投放被暂缓的作业。查看 `lp` 命令的 man 页面了解其它选项的信息。
###### 列表 9. 重启一个暂缓的打印作业
```
[ian@atticf27 ~]$ lp -i 13 -H resume
```
*列表 9. 重启一个暂缓的打印作业*
并不是所有的可用打印机都支持相同的选项集。使用 `lpoptions` 命令去查看一个打印机的常用选项。添加 `-l` 选项去显示打印机专用的选项。列表 10 展示了两个示例。许多常见的选项涉及到人像/风景打印、页面大小和输出在纸张上的布局。详细信息查看 man 页面。
###### 列表 10. 检查打印机选项
```
[ian@atticf27 ~]$ lpoptions -p HL-2280DW
copies=1 device-uri=dnssd://Brother%20HL-2280DW._pdl-datastream._tcp.local/
@ -296,21 +299,22 @@ StpImageType/Image Type: None Text Graphics *TextGraphics Photo LineArt
```
大多数的 GUI 应用程序有一个打印对话框,通常你可以使用 **文件 >打印** 菜单去选择它。图 1 展示了在 GIMP 中的一个示例GIMP 是一个图像处理程序。
*列表 10. 检查打印机选项*
###### 图 1. 在 GIMP 中打印
大多数的 GUI 应用程序有一个打印对话框,通常你可以使用 **文件 >打印** 菜单去选择它。图 1 展示了在 GIMP 中的一个示例GIMP 是一个图像处理程序。
![Printing from the GIMP][3]
到目前为止,我们所有的命令都是隐式指向到本地的 CUPS 打印服务器上。你也可以通过指定 `-h` 选项和一个端口号(如果不是 CUPS 的默认端口号 631的话将打印转向到另外一个系统上的服务器。
*图 1. 在 GIMP 中打印*
到目前为止,我们所有的命令都是隐式指向到本地的 CUPS 打印服务器上。你也可以通过指定 `-h` 选项和一个端口号(如果不是 CUPS 的默认端口号 631 的话)将打印转向到另外一个系统上的服务器。
### CUPS 和 CUPS 服务器
CUPS 打印系统的核心是 `cupsd` 打印服务器它是一个运行的守护进程。CUPS 配置文件一般位于 /etc/cups/cupsd.conf。/etc/cups 目录也有与 CUPS 相关的其它的配置文件。CUPS 一般在系统初始化期间启动,根据你的发行版不同,它也可能通过位于 /etc/rc.d/init.d 或者 /etc/init.d 目录中的 CUPS 脚本来控制。对于 最新使用 systemd 来初始化的系统CUPS 服务脚本可能在 /usr/lib/systemd/system/cups.service 中。和大多数使用脚本的服务一样,你可以停止、启动、或者重启守护程序。查看我们的教程:[学习 Linux101运行级别、引导目标、关闭、和重启动][4],了解使用初始化脚本的更多信息。
CUPS 打印系统的核心是 `cupsd` 打印服务器它是一个运行的守护进程。CUPS 配置文件一般位于 `/etc/cups/cupsd.conf``/etc/cups` 目录也有与 CUPS 相关的其它的配置文件。CUPS 一般在系统初始化期间启动,根据你的发行版不同,它也可能通过位于 `/etc/rc.d/init.d` 或者 `/etc/init.d` 目录中的 CUPS 脚本来控制。对于 最新使用 systemd 来初始化的系统CUPS 服务脚本可能在 `/usr/lib/systemd/system/cups.service` 中。和大多数使用脚本的服务一样,你可以停止、启动、或者重启守护程序。查看我们的教程:[学习 Linux101运行级别、引导目标、关闭、和重启动][4],了解使用初始化脚本的更多信息。
配置文件 /etc/cups/cupsd.conf 包含管理一些事情的参数,比如访问打印系统、是否允许远程打印、本地打印池文件等等。在一些系统上,一个辅助的部分单独描述打印队列,它一般是由配置工具自动生成的。列表 11 展示了一个默认的 cupsd.conf 文件中的一些条目。注意,注释是以 # 字符开头的。默认值通常以注释的方式显示,并且可以通过删除前面的 # 字符去改变默认值。
配置文件 `/etc/cups/cupsd.conf` 包含一些管理参数,比如访问打印系统、是否允许远程打印、本地打印池文件等等。在一些系统上,第二部分单独描述了打印队列,它一般是由配置工具自动生成的。列表 11 展示了一个默认的 `cupsd.conf` 文件中的一些条目。注意,注释是以 `#` 字符开头的。默认值通常以注释的方式显示,并且可以通过删除前面的 `#` 字符去改变默认值。
###### Listing 11. 默认的 /etc/cups/cupsd.conf 文件的部分内容
```
# Only listen for connections from the local machine.
Listen localhost:631
@ -338,12 +342,12 @@ WebInterface Yes
<Limit Create-Job Print-Job Print-URI Validate-Job>
Order deny,allow
</Limit>
```
能够允许在 cupsd.conf 中使用的文件、目录、和用户配置命令,现在都存储在作为替代的 cups-files.conf 中。这是为了防范某些类型的提权攻击。列表 12 展示了 cups-files.conf 文件中的一些条目。注意正如在文件层次结构标准FHS中所期望的那样打印池文件默认保存在文件系统的 /var/spool 目录中。查看 man 页面了解 cupsd.conf 和 cups-files.conf 配置文件的更多信息。
*列表 11. 默认的 /etc/cups/cupsd.conf 文件的部分内容*
可以用在 `cupsd.conf` 中使用的文件、目录、和用户配置命令,现在都存储在作为替代的 `cups-files.conf` 中。这是为了防范某些类型的提权攻击。列表 12 展示了 `cups-files.conf` 文件中的一些条目。注意正如在文件层次结构标准FHS中所期望的那样打印池文件默认保存在文件系统的 `/var/spool` 目录中。查看 man 页面了解 `cupsd.conf``cups-files.conf` 配置文件的更多信息。
###### 列表 12. 默认的 /etc/cups/cups-files.conf 配置文件的部分内容
```
# Location of the file listing all of the local printers...
#Printcap /etc/printcap
@ -364,12 +368,13 @@ WebInterface Yes
# Location of other configuration files...
#ServerRoot /etc/cups
```
列表 12 引用了 /etc/printcap 文件。这是 LPD 打印服务器的配置文件的名字,并且一些应用程序仍然使用它去确定可用的打印机和它们的属性。它通常是在 CUPS 系统上自动生成的,因此,你可能没有必要去修改它。但是,如果你在诊断用户打印问题,你可能需要去检查它。列表 13 展示了一个示例。
*列表 12. 默认的 /etc/cups/cups-files.conf 配置文件的部分内容*
列表 12 提及了 `/etc/printcap` 文件。这是 LPD 打印服务器的配置文件的名字,并且一些应用程序仍然使用它去确定可用的打印机和它们的属性。它通常是在 CUPS 系统上自动生成的,因此,你可能没有必要去修改它。但是,如果你在诊断用户打印问题,你可能需要去检查它。列表 13 展示了一个示例。
###### 列表 13. 自动生成的 /etc/printcap
```
# This file was automatically generated by cupsd(8) from the
# /etc/cups/printers.conf file. All changes to this file
@ -377,18 +382,19 @@ WebInterface Yes
HL-2280DW|Brother HL-2280DW:rm=atticf27:rp=HL-2280DW:
anyprint|Any available printer:rm=atticf27:rp=anyprint:
XP-610|EPSON XP-610 Series:rm=atticf27:rp=XP-610:
```
这个文件中的每一行都有一个打印机名字、打印机描述远程机器rm的名字、以及那个远程机器上的远程打印机rp。老的 /etc/printcap 文件也描述了打印机的能力。
*列表 13. 自动生成的 /etc/printcap*
这个文件中的每一行都有一个打印机名字、打印机描述,远程机器(`rm`)的名字、以及那个远程机器上的远程打印机(`rp`)。老的 `/etc/printcap` 文件也描述了打印机的能力。
#### 文件转换过滤器
你可以使用 CUPS 打印许多类型的文件包括明文的文本文件、PDF、PostScript、和各种格式的图像文件你只需要提供要打印的文件名除此之外你再无需向 `lpr``lp` 命令提供更多的信息。这个神奇的壮举是通过使用过滤器来实现的。实际上,这些年来最流行的过滤器就命名为 magicfilter
你可以使用 CUPS 打印许多类型的文件包括明文的文本文件、PDF、PostScript、和各种格式的图像文件你只需要提供要打印的文件名除此之外你再无需向 `lpr``lp` 命令提供更多的信息。这个神奇的壮举是通过使用过滤器来实现的。实际上,这些年来最流行的过滤器就就叫做 magicfilter神奇的过滤器
当打印一个文件时CUPS 使用多用途因特网邮件扩展MIME类型去决定合适的转换过滤器。其它的打印包可能使用由 `file` 命令使用的神奇数字机制。关于 `file` 或者 `magic` 的更多信息可以查看它们的 man 页面。
当打印一个文件时CUPS 使用多用途因特网邮件扩展MIME类型去决定合适的转换过滤器。其它的打印数据包可能使用由 `file` 命令使用的神奇数字机制。关于 `file` 或者神奇数的更多信息可以查看它们的 man 页面。
输入文件被过滤器转换成中间层的光栅格式或者 PostScript 格式。一些作业信息,比如打印数量也会被添加进去。数据最终通过一个 bechend 发送到目标打印机。还有一些可以用手动过滤的输入文件的过滤器。你可以通过这些过滤器获得特殊格式的结果,或者去处理一些 CUPS 原生并不支持的文件格式。
输入文件被过滤器转换成中间层的光栅格式或者 PostScript 格式。一些作业信息,比如打印数量也会被添加进去。数据最终通过一个后端发送到目标打印机。还有一些可以用手动过滤的输入文件的过滤器(如 a2ps 或 dvips。你可以通过这些过滤器获得特殊格式的结果,或者去处理一些 CUPS 原生并不支持的文件格式。
#### 添加打印机
@ -401,25 +407,22 @@ CUPS 支持多种打印机,包括:
* 使用 NCP 的 Novell 打印机
* HP Jetdirect 打印机
当系统启动或者设备连接时,现在的大多数系统都会尝试自动检测和自动配置本地硬件。同样,许多网络打印机也可以被自动检测到。使用 CUPS 的 web 管理工具(<http://localhost:631> 或者 <http://127.0.0.1:631>)去搜索或添加打印机。许多发行版都包含它们自己的配置工具,比如,在 SUSE 系统上的 YaST。图 2 展示了使用 localhost:631 的 CUPS 界面,图 3 展示了 Fedora 27 上的 GNOME 打印机设置对话框。
###### 图 2. 使用 CUPS 的 web 界面
![Using the CUPS web interface][5]
###### 图 3. Fedora 27 上的打印机设置
*图 2. 使用 CUPS 的 web 界面*
![Using printer settings on Fedora 27][6]
*图 3. Fedora 27 上的打印机设置*
你也可以从命令行配置打印机。在配置打印机之前,你需要一些关于打印机和它的连接方式的基本信息。如果是一个远程系统,你还需要一个用户 ID 和密码。
你需要去知道你的打印机使用什么样的驱动程序。不是所有的打印机都支持 Linux有些打印机在 Linux 上压根就不能使用,或者功能受限。你可以去 OpenPrinting.org(查看相关主题)去查看是否有你的特定的打印机的驱动程序。`lpinfo` 命令也可以帮你识别有效的设备类型和驱动程序。使用 `-v` 选项去列出支持的设备,使用 `-m` 选项去列出驱动程序,如列表 14 所示。
你需要去知道你的打印机使用什么样的驱动程序。不是所有的打印机都支持 Linux有些打印机在 Linux 上压根就不能使用,或者功能受限。你可以去 OpenPrinting.org 去查看是否有你的特定的打印机的驱动程序。`lpinfo` 命令也可以帮你识别有效的设备类型和驱动程序。使用 `-v` 选项去列出支持的设备,使用 `-m` 选项去列出驱动程序,如列表 14 所示。
###### 列表 14. 可用的打印机驱动程序
```
[ian@atticf27 ~]$ lpinfo -m | grep -i xp-610
lsb/usr/Epson/epson-inkjet-printer-escpr/Epson-XP-610_Series-epson-escpr-en.ppd.gz
@ -443,16 +446,16 @@ network dnssd://Brother%20HL-2280DW._pdl-datastream._tcp.local/
network dnssd://EPSON%20XP-610%20Series._ipp._tcp.local/?uuid=cfe92100-67c4-11d4-a45f-ac18266c48aa
network lpd://BRN001BA98A1891/BINARY_P1
network lpd://192.168.1.38:515/PASSTHRU
```
Epson-XP-610_Series-epson-escpr-en.ppd.gz 驱动程序在我的系统上位于 /usr/share/ppd/Epson/epson-inkjet-printer-escpr/ 目录中。
*列表 14. 可用的打印机驱动程序*
如果你找不到驱动程序你可以到打印机生产商的网站看看说不上会有专用的驱动程序。例如在写这篇文章的时候Brother 就有一个我的 HL-2280DW 打印机的驱动程序,但是,这个驱动程序在 OpenPrinting.org 上还没有列出来。
这个 Epson-XP-610_Series-epson-escpr-en.ppd.gz 驱动程序在我的系统上位于 `/usr/share/ppd/Epson/epson-inkjet-printer-escpr/` 目录中。
如果你找不到驱动程序你可以到打印机生产商的网站看看说不定会有专用的驱动程序。例如在写这篇文章的时候Brother 就有一个我的 HL-2280DW 打印机的驱动程序,但是,这个驱动程序在 OpenPrinting.org 上还没有列出来。
如果你收集齐了基本信息,你可以如列表 15 所示的那样,使用 `lpadmin` 命令去配置打印机。为此,我将为我的 HL-2280DW 打印机创建另外一个实例,以便于双面打印。
###### 列表 15. 配置一台打印机
```
[ian@atticf27 ~]$ lpinfo -m | grep -i "hl.*2280"
HL2280DW.ppd Brother HL2280DW for CUPS
@ -465,16 +468,16 @@ anyprint accepting requests since Mon 29 Jan 2018 01:17:09 PM EST
HL-2280DW accepting requests since Tue 30 Jan 2018 10:56:10 AM EST
HL-2280DW-duplex accepting requests since Wed 31 Jan 2018 11:41:16 AM EST
HXP-610 accepting requests since Mon 29 Jan 2018 10:34:49 PM EST
```
你可以使用带 `-c` 选项的 `lpadmin` 命令去创建一个仅用于双面打印的新类,而不用为了双面打印去创建一个打印机的副本。
*列表 15. 配置一台打印机*
你可以使用带 `-c` 选项的 `lpadmin` 命令去创建一个仅用于双面打印的新分类,而不用为了双面打印去创建一个打印机的副本。
如果你需要删除一台打印机,使用带 `-x` 选项的 `lpadmin` 命令。
列表 16 展示了如何去删除打印机和创建一个替代类。
###### 列表 16. 删除一个打印机和创建一个类
```
[ian@atticf27 ~]$ lpadmin -x HL-2280DW-duplex
[ian@atticf27 ~]$ lpadmin -p HL-2280DW -c duplex -E -D "Duplex printing" -o sides=two-sided-long-edge
@ -485,34 +488,33 @@ anyprint accepting requests since Mon 29 Jan 2018 01:17:09 PM EST
duplex accepting requests since Wed 31 Jan 2018 12:12:05 PM EST
HL-2280DW accepting requests since Wed 31 Jan 2018 11:51:16 AM EST
XP-610 accepting requests since Mon 29 Jan 2018 10:34:49 PM EST
```
*列表 16. 删除一个打印机和创建一个类*
你也可以使用 `lpadmin` 或者 `lpoptions` 命令去设置各种打印机选项。详细信息请查看 man 页面。
### 排错
如果你有一个打印问题,尝试下列的提示:
如果你有打印问题,尝试下列的提示:
* 确保 CUPS 服务器正在运行。你可以使用 `lpstat` 命令,如果它不能连接到 cupsd 守护程序,它将会报告一个错误。或者,你可以使用 `ps -ef` 命令在输出中去检查是否有 cupsd。
* 如果你尝试为打印去排队一个作业,而得到一个错误信息,指示打印机不接受这个作业,你可以使用 `lpstat -a` 或者 `lpc status` 去检查那个打印机可接受的作业。
* 如果你试着排队一个打印作业而得到一个错误信息,指示打印机不接受这个作业,你可以使用 `lpstat -a` 或者 `lpc status` 去检查那个打印机是否接受作业。
* 如果一个队列中的作业没有打印,使用 `lpstat -p``lpc status` 去检查那个打印机是否接受作业。如前面所讨论的那样,你可能需要将这个作业移动到其它的打印机。
* 如果这个打印机是远程的,检查它在远程系统上是否存在,并且是可操作的。
* 检查配置文件,确保特定的用户或者远程系统允许在这个打印机上打印。
* 确保防火墙允许远程打印请求,是否允许从其它系统到你的系统,或者从你的系统到其它系统的数据包通讯。
* 验证是否有正确的驱动程序。
正如你所见,打印涉及到你的系统中的几个组件,甚至还有网络。在本教程中,基于篇幅的考虑,我们仅为诊断给你提供了几个着手点。大多数的 CUPS 系统也有实现我们所讨论的命令行功能的图形界面。一般情况下,这个界面是从本地主机使用浏览器指向 631 端口(<http://localhost:631><http://127.0.0.1:631>)来访问的,如前面的图 2 所示。
正如你所见,打印涉及到你的系统中的几个组件,甚至还有网络。在本教程中,基于篇幅的考虑,我们仅能给你的诊断提供了几个着手点。大多数的 CUPS 系统也有实现我们所讨论的命令行功能的图形界面。一般情况下,这个界面是从本地主机使用浏览器指向 631 端口(<http://localhost:631><http://127.0.0.1:631>)来访问的,如前面的图 2 所示。
你可以通过将 CUPS 运行在前台而不是做为一个守护进程来诊断它的问题。如果有需要,你也可以通过这种方式去测试替代的配置文件。运行 `cupsd -h` 获得更多信息,或者查看 man 页面。
CUPS 也管理一个访问日志和错误日志。你可以在 cupsd.conf 中使用 LogLevel 语句来改变日志级别。默认情况下,日志是保存在 /var/log/cups 目录。它们可以在浏览器界面(<http://localhost:631>)下,从 **Administration** 选项卡中查看。使用不带任何选项的 `cupsctl` 命令可以显示日志选项。也可以编辑 cupsd.conf 或者使用 `cupsctl` 去调整各种日志参数。查看 `cupsctl` 命令的 man 页面了解更多信息。
CUPS 也带有一个访问日志和错误日志。你可以在 `cupsd.conf` 中使用 `LogLevel` 语句来改变日志级别。默认情况下,日志是保存在 `/var/log/cups` 目录。它们可以在浏览器界面(<http://localhost:631>)下,从 **Administration** 选项卡中查看。使用不带任何选项的 `cupsctl` 命令可以显示日志选项。也可以编辑 `cupsd.conf` 或者使用 `cupsctl` 去调整各种日志参数。查看 `cupsctl` 命令的 man 页面了解更多信息。
在 Ubuntu 的 Wiki 页面上的 [调试打印问题][7] 页面也是一个非常好的学习的地方。
它包含了打印和 CUPS 的介绍。
这就是关于打印和 CUPS 的介绍。
--------------------------------------------------------------------------------
@ -520,7 +522,7 @@ via: https://www.ibm.com/developerworks/library/l-lpic1-108-4/index.html
作者:[Ian Shields][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/) 荣誉推出

View File

@ -1,11 +1,13 @@
开始使用 SQL
SQL 入门
======
> 使用 SQL 构建一个关系数据库比你想的更容易。
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brain_data.png?itok=RH6NA32X)
使用 SQL 构建数据库比大多数人想象得要简单。实际上,你甚至不需要成为一个有经验的程序员使用 SQL 创建数据库。在本文中,我将解释如何使用 MySQL 5.6 来创建简单的关系型数据库管理系统RDMS。在开始之前我想快速地感谢 [SQL Fiddle][1],这是我用来运行脚本的工具。它提供了一个用于测试简单脚本的有用的沙箱。
使用 SQL 构建数据库比大多数人想象得要简单。实际上,你甚至不需要成为一个有经验的程序员就可以使用 SQL 创建数据库。在本文中,我将解释如何使用 MySQL 5.6 来创建简单的关系型数据库管理系统RDMS。在开始之前我想顺便感谢一下 [SQL Fiddle][1],这是我用来运行脚本的工具。它提供了一个用于测试简单脚本的有用的沙箱。
在本教程中,我将构建一个使用下实体关系图ERD中显示的简单架构的数据库。数据库列出了学生和正在学习的课程。为了保持简单我使用了两个实体即表只有一种关系和依赖关系。这两个实体称为 `dbo_students``dbo_courses`
在本教程中,我将构建一个使用下实体关系图ERD中显示的简单架构的数据库。数据库列出了学生和正在学习的课程。为了保持简单我使用了两个实体即表只有一种关系和依赖。这两个实体称为 `dbo_students``dbo_courses`
![](https://opensource.com/sites/default/files/u128651/erd.png)
@ -20,87 +22,62 @@
### 构建架构
要构建数据库,使用 `CREATE TABLE <表名>` 命令,然后定义每个字段的名称和数据类型。数据库使用 `VARCHAR(n)` (字符串)和 `INT(n)` (整数),其中 n 表示可以存储的值的长度。例如 `INT(2)`能是 01
要构建数据库,使用 `CREATE TABLE <表名>` 命令,然后定义每个字段的名称和数据类型。数据库使用 `VARCHAR(n)` (字符串)和 `INT(n)` (整数),其中 `n` 表示可以存储的值的长度。例如 `INT(2)`以是 `01`
这是用于创建两个表的代码:
```
CREATE TABLE dbo_students
(
  student_id INT(2) AUTO_INCREMENT NOT NULL,
  student_name VARCHAR(50),
  course_studied INT(2),
  PRIMARY KEY (student_id)
student_id INT(2) AUTO_INCREMENT NOT NULL,
student_name VARCHAR(50),
course_studied INT(2),
PRIMARY KEY (student_id)
);
CREATE TABLE dbo_courses
(
  course_id INT(2) AUTO_INCREMENT NOT NULL,
  course_name VARCHAR(30),
  PRIMARY KEY (course_id)
course_id INT(2) AUTO_INCREMENT NOT NULL,
course_name VARCHAR(30),
PRIMARY KEY (course_id)
);
```
`NOT NULL` 意味着字段不能为空,`AUTO_INCREMENT` 意味着当一个新的元组被添加时ID 号将自动生成,并将 1 添加到先前存储的 ID 号,来强化各实体之间的完整参照性。 `PRIMARY KEY` 是每个表的惟一标识符属性。这意味着每个元组都有自己的不同的标识。
`NOT NULL` 意味着字段不能为空,`AUTO_INCREMENT` 意味着当一个新的元组被添加时ID 号将自动生成,是对先前存储的 ID 号加 1以强化各实体之间的完整参照性。 `PRIMARY KEY` 是每个表的惟一标识符属性。这意味着每个元组都有自己的不同的标识。
### 关系作为一种约束
就目前来看,这两张表格是独立存在的,没有任何联系或关系。要连接它们,必须标识一个外键。在 `dbo_students` 中,外键是 `course_studied`,其来源在 `dbo_courses`意味着该字段被引用。SQL 中的特定命令为 `CONSTRAINT`,并且将使用另一个名为 `ALTER TABLE` 的命令添加这种关系,这样即使在架构构建完毕后,也可以编辑表。
以下代码将关系添加到数据库构造脚本中:
```
ALTER TABLE dbo_students
ADD CONSTRAINT FK_course_studied
FOREIGN KEY (course_studied) REFERENCES dbo_courses(course_id);
```
使用 `CONSTRAINT` 命令实际上并不是必要的,但这是一个好习惯,因为它意味着约束可以被命名并且使维护更容易。现在数据库已经完成了,是时候添加一些数据了。
### 将数据添加到数据库
`INSERT INTO <表名>`是用于直接选择将数据添加到哪些属性(即字段)的命令。首先声明实体名称,然后声明属性。命令下边是添加到实体的数据,从而创建一个元组。如果指定了 `NOT NULL`,这表示该属性不能留空。以下代码将展示如何向表中添加记录:
`INSERT INTO <表名>` 是用于直接选择要添加哪些属性(即字段)数据的命令。首先声明实体名称,然后声明属性,下边是添加到实体的数据,从而创建一个元组。如果指定了 `NOT NULL`,这表示该属性不能留空。以下代码将展示如何向表中添加记录:
```
INSERT INTO dbo_courses(course_id,course_name)
VALUES(001,'Software Engineering');
INSERT INTO dbo_courses(course_id,course_name)
VALUES(002,'Computer Science');
INSERT INTO dbo_courses(course_id,course_name)
VALUES(003,'Computing');
INSERT INTO dbo_students(student_id,student_name,course_studied)
VALUES(001,'student1',001);
INSERT INTO dbo_students(student_id,student_name,course_studied)
VALUES(002,'student2',002);
INSERT INTO dbo_students(student_id,student_name,course_studied)
VALUES(003,'student3',002);
INSERT INTO dbo_students(student_id,student_name,course_studied)
VALUES(004,'student4',003);
```
@ -109,128 +86,89 @@ VALUES(004,'student4',003);
### 查询
查询遵循使用以下命令的集合结构:
```
SELECT <attributes>
FROM <entity>
WHERE <condition>
```
要显示 `dbo_courses` 实体内的所有记录并显示课程代码和课程名称,请使用 * 。 这是一个通配符,它消除了键入所有属性名称的需要。(在生产数据库中不建议使用它。)此处查询的代码是:
要显示 `dbo_courses` 实体内的所有记录并显示课程代码和课程名称,请使用 `*` 。 这是一个通配符,它消除了键入所有属性名称的需要。(在生产数据库中不建议使用它。)此处查询的代码是:
```
SELECT *
FROM dbo_courses
```
此处查询的输出显示表中的所有元组,因此可显示所有可用课程:
```
| course_id |          course_name |
|-----------|----------------------|
|         1 | Software Engineering |
|         2 |     Computer Science |
|         3 |            Computing |
```
后的文章中,我将使用三种类型的连接之一来解释更复杂的查询:Inner,Outer 或 Cross
在后的文章中,我将使用三种类型的连接之一来解释更复杂的查询:内连接、外连接和交叉连接
这是完整的脚本:
```
CREATE TABLE dbo_students
(
  student_id INT(2) AUTO_INCREMENT NOT NULL,
  student_name VARCHAR(50),
  course_studied INT(2),
  PRIMARY KEY (student_id)
student_id INT(2) AUTO_INCREMENT NOT NULL,
student_name VARCHAR(50),
course_studied INT(2),
PRIMARY KEY (student_id)
);
CREATE TABLE dbo_courses
(
  course_id INT(2) AUTO_INCREMENT NOT NULL,
  course_name VARCHAR(30),
  PRIMARY KEY (course_id)
course_id INT(2) AUTO_INCREMENT NOT NULL,
course_name VARCHAR(30),
PRIMARY KEY (course_id)
);
ALTER TABLE dbo_students
ADD CONSTRAINT FK_course_studied
FOREIGN KEY (course_studied) REFERENCES dbo_courses(course_id);
INSERT INTO dbo_courses(course_id,course_name)
VALUES(001,'Software Engineering');
INSERT INTO dbo_courses(course_id,course_name)
VALUES(002,'Computer Science');
INSERT INTO dbo_courses(course_id,course_name)
VALUES(003,'Computing');
INSERT INTO dbo_students(student_id,student_name,course_studied)
VALUES(001,'student1',001);
INSERT INTO dbo_students(student_id,student_name,course_studied)
VALUES(002,'student2',002);
INSERT INTO dbo_students(student_id,student_name,course_studied)
VALUES(003,'student3',002);
INSERT INTO dbo_students(student_id,student_name,course_studied)
VALUES(004,'student4',003);
SELECT *
FROM dbo_courses
```
### 学习更多
SQL 并不困难;我认为它比编程简单,并且该语言对于不同的数据库系统是通用的。 请注意,`dbo.<实体>` (译者注:文章中使用的是 `dbo_<实体>`) 不是必需的实体命名约定;我之所以使用,仅仅是因为它是 Microsoft SQL Server 中的标准。
SQL 并不困难;我认为它比编程简单,并且该语言对于不同的数据库系统是通用的。 请注意,实体关系图中 `dbo.<实体>` LCTT 译注:文章中使用的是 `dbo_<实体>`不是必需的实体命名约定;我之所以使用,仅仅是因为它是 Microsoft SQL Server 中的标准。
如果你想了解更多,在网络上这方面的最佳指南是 [W3Schools.com][2] 中对所有数据库平台的 SQL 综合指南。
请随意使用我的数据库。另外,如果你有任何建议或疑问,请在评论中回复。(译注:请点击原文地址进行评论回应)
请随意使用我的数据库。另外,如果你有任何建议或疑问,请在评论中回复。
--------------------------------------------------------------------------------
via: [https://opensource.com/article/18/2/getting-started-sql](https://opensource.com/article/18/2/getting-started-sql)
via: https://opensource.com/article/18/2/getting-started-sql
作者:[Aaron Cocker][a]
译者:[MjSeven](https://github.com/MjSeven)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -0,0 +1,91 @@
高级 SSH 速查表
===========================
所有人都知道 SSH 是一种远程登录工具,然而它也有许多其他用途。
创建一个 SOCKS 代理来浏览网页(也就是翻墙啦):
> ```
ssh -D <port> <remote_host>
```
> 设置 `localhost:<port>` 作为你浏览器的代理
连接一个堡垒机后的 Windows RDP 主机:
> ```
ssh -L <port>:<target_host>:3389 <bastion_server>
```
> 让你的 RDP 客户端连接到 `localhost:<port>`
在不使用 VNC 端口的情况下,连接远程 VNC 主机:
> ```
ssh -L 5901:localhost:5901 <remote_host>
```
> 让你的 VNC 客户端连接到 `localhost:5901`
按照这个思路你可以映射任意端口LDAP (389)、631 (CUPS)、8080 (替代的 HTTP),等等。
产生一个新的 SSH 密钥对:
> ```
ssh-keygen
```
更新密钥对的密码:
> ```
ssh-keygen -p
```
把公钥复制到远程主机上:
> ```
ssh-copy-id -i <identity file> <remote_host>
```
SSH 有一堆命令行选项,但是如果有一些是你经常使用的,你可以为它们在 SSH 配置文件 (${HOME}/.ssh/config) 里创建一个入口。比如:
>```
host myhouse
User itsme
   HostName house.example.com
```
那么你就可以输入 `ssh myhouse` 来代替 `ssh itsme@house.example.com`
以下是常用的命令行选项和他们的配置文件写法。一些是常用的简化写法。请查看 `ssh(1)``ssh_config(5)` 的手册页来获取详尽信息。
|命令行|配置文件|描述
|:--|:--|:--|
| `-l <login name>` | `User <login name>` | 远程主机的登录用户名。|
| `-i <identity file>` | `IdentityFile <identity file>` |指定要使用的鉴权文件SSH 密码对)。 |
| `-p <remote port>` | `Port <remote port>` | 远程 SSH 守护进程监听的端口号。 (默认为 22) |
| `-C` | `Compression <yes,no>` | 压缩往来信息。 (默认为 no) |
| `-D <port>` | `DynamicForward <port>` | 把本地端口的报文转发到远程主机。 |
| `-X` | `ForwardX11 <yes,no>` | 把 X11 的图像数据转发到远程主机的端口. (默认为 no) |
| `-A` | `ForwardAgent <yes,no>` | 把授权代理的报文转发给远程主机。如果你使用第三方主机登录,这个功能将很有用。 (默认为 no) |
| `-4`(仅使用 IPv4 `-6` (仅使用 IPv6| `AddressFamily <any,inet4,inet6>` | 指定仅使用 IPv4 或者 IPv6。 |
| `-L <local port>:<target host>:<target port>` | `LocalForward <local port>:<target host>:<target port>` | 把本地主机指定端口的报文转发到远程主机的某个端口。|
opensource.com Twitter @opensourceway | facebook.com/opensourceway | IRC: #opensource.com on Freenode
--------------------------------------------------------------------------------
作者简介:
Ben Cotton 是业余的气象学家和职业的高性能计算工程师。Ben 是微软 Azure 的产品营销经理,专注于高性能计算。他是一个 Fedora 用户和贡献者,共同创立了一个当地的开放源码群,并且是开源促进会的成员和保护自由软件的支持者。通过以下方式联系他 Twitter (@FunnelFiasco) 或者 FunnelFiasco.com.
-------------
via: https://opensource.com/sites/default/files/gated-content/cheat_sheet_ssh_v03.pdf
作者:[BEN COTTON][a]
译者:[kennethXia](https://github.com/kennethXia)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/bcotton
[1]:https://web.kamihq.com/web/upgrade.html

View File

@ -0,0 +1,106 @@
5 steps to building a cloud that meets your users' needs
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003601_05_mech_osyearbook2016_cloud_cc.png?itok=XSV7yR9e)
This article was co-written with [Ian Tewksbury][1].
However you define it, a cloud is simply another tool for your users to perform their part of your organization's value stream. It can be easy when talking about any new paradigm or technology (the cloud is arguably both) to get distracted by the shiny newness of it. Conversations can quickly devolve into feature wish lists set off by a series of never-ending questions, all of which you probably have already considered:
* Will it be public, private, or hybrid?
* Will it use virtual machines or containers, or both?
* Will it be self-service?
* Will it be fully automated from development to production, or will it have manual gates?
* How fast can we make it?
* What about tool X, Y, or Z?
The list goes on.
The usual approach to beginning IT modernization, or digital transformation, or whatever you call it is to start answering high-level questions in the higher-level echelons of management. The outcome of this approach is predictable: failure. After extensively researching and spending months, if not years, deploying the fanciest new technology, the new cloud is never used and falls into disrepair until it is eventually scrapped or forgotten in the dustier corners of the datacenter and budget.
That's because whatever was delivered was not the tool the users wanted or needed. Worse yet, it likely was a single tool when users really needed a collection of tools that could be swapped out over time as newer, shinier, upgraded tools come along that better meet their needs.
### Focus on what matters
The problem is focus, which has traditionally been on the tools. But the tools are not what add to your organization's value stream; end users making use of tools are what do that. You need to shift your focus from building your cloud—for example, the technology and the tools, to your people, your users.
Beyond the fact that users using tools (not the tools themselves) are what drive value, there are other reasons to focus attention on the users. The tools are for the users to use to solve their problems and allow them to create value, so it follows that if those tools don't meet those users' needs, then those tools won't be used. If you deliver tools that your users don't like, they won't use them. This is natural human behavior.
The IT industry got away with providing a single solution to users for decades because there were only one or two options, and the users had no power to change that. That is no longer the case. We now live in the world of technological choice. It is no longer acceptable to users to not be given a choice; they have choices in their personal technological lives, and they expect it in the workplace, too. Today's users are educated and know there are better options than the ones you've been providing.
As a result, outside the most physically secure locations, there is no way to stop them from just doing what they want, which we call "shadow IT." If your organization has such strict security and compliance polices that shadow IT is impossible, many of your best people will grow frustrated and leave for other organizations that offer them choices.
For all of these reasons, you must design your expensive and time-consuming cloud project with your end user foremost in mind.
### Five-step process to build a cloud for users' needs
Now that we know the why, let's talk about the how. How do you build a cloud for the end user? How do you start refocusing your attention from the technology to the people using that technology?
Through experience, we've learned that the best approach involves two things: getting constant feedback from your users, and building things iteratively.
Your cloud environment will continually evolve with your organization. The following five-step process will help you create a cloud that meets your users' needs.
#### 1\. Identify who your users will be.
Before you can start asking users questions, you first must identify who the users of your new cloud will be. They will likely include developers who build applications on the cloud; the operations team who will operate, maintain, and likely build the cloud; and the security team who protects your organization. For the first iteration, scope down your users to a smaller group so you're less overwhelmed by feedback. Ask each of your identified user groups to appoint two liaisons (a primary and a secondary) who will represent their team on this journey. This will also keep your first delivery small in both size and time.
#### 2\. Talk to your users face-to-face to get valuable input.
The best way to get users' feedback is through direct communication. Mass emails asking for input will self-select respondents—if you even get a response. Group discussions can be helpful, but people tend to be more candid when they have a private, attentive audience.
Schedule in-person, individual meetings with your first set of users to ask them questions like the following:
* What do you need in order to accomplish your tasks?
* What do you want in order to accomplish your tasks?
* What is your current, most annoying technological pain?
* What is your current, most annoying policy or procedural pain?
* What ideas do you have to address any of your needs, wants, or pains?
These questions are guidelines and not ideal for every organization. They should not be the only questions you ask, and they should lead to further discussion. Be sure to tell people that anything said or asked is taken as feedback, and all feedback is helpful, whether positive or negative. The outcome of these conversations will help set your development priorities.
Gathering this level of personalized feedback is another reason to keep your initial group of users small: It takes a lot of time to sit down with each user, but we have found it is absolutely worth the investment.
#### 3\. Design and deliver your first iteration of the solution.
Once you've collected feedback from your initial users, it is time to design and deliver a piece of functionality. We do not recommend trying to deliver the entire solution. The design and delivery phase should be short; this is to avoid making the huge mistake of spending a year building what you think is the correct solution, only to have your users reject it because it isn't beneficial to them. The specific tools you choose for building your cloud will depend on your organization and its specific needs. Just make sure that the solution you build is based on your users' feedback and that you deliver it in small chunks to solicit feedback from them as often as possible.
#### 4\. Ask users for feedback on the first iteration.
Great, now you've designed and delivered the first iteration of your fancy new cloud to your end users! You didn't spend a year doing it but instead tackled it in small pieces. Why is it important to do things in small chunks? It's because you're going back to your user groups and collecting feedback about your design and delivery. What do they like? What don't they like? Did you properly address their concerns? Is the technology great, but the process or policy side of the system still lacking?
Again, the questions you'll ask depend on your organization; the key here is to continue the discussions from the earlier phases. You're building this cloud for users after all, so make sure it's useful for them and a productive use of everyone's time.
#### 5\. Return to step 1.
This is an iterative process. Your first delivery should have been quick and small, and all future iterations should be, too. Don't expect to be able to follow this process once, twice, or even three times and be done. As you iterate, you will introduce more users and get better at the process. You will get more buy-in from users. You will be able to iterate faster and more reliably. And, finally, you will change your process to meet your users' needs.
Users are the most important part of this process, but the iteration is the second most important part because it allows you to keep going back to the users and getting more information. Throughout each phase, take note of what worked and what didn't. Be introspective and honest with yourself. Are we providing the most value possible for the time we spent? If not, try something different in the next phase. The great part about not spending too much time in each cycle is that, if something doesn't work this time, you can easily tweak it for next time, until you find an approach that works for your organization.
### This is just the beginning
Through many customer engagements, feedback gathered from users, and experiences from peers in the field, we've found time and time again that the most important thing you can do when building a cloud is to talk to your users. It seems obvious, but it is surprising how many organizations will go off and build something for months or years, then find out it isn't even useful to end users.
Now you know why you should keep your focus on the end users and have a process for building a cloud with them at the center. The remaining piece is the part that we all enjoy, the part where you go out and do it.
This article is based on "[Design your hybrid cloud for the end user—or fail][2]," a talk the authors will be giving at [Red Hat Summit 2018][3], which will be held May 8-10 in San Francisco.
[Register by May 7][3] to save US$ 500 off of registration. Use discount code **OPEN18** on the payment page to apply the discount.
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/4/5-steps-building-your-cloud-correctly
作者:[Cameron Wyatt][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://opensource.com/users/cameronmwyatt
[1]:https://opensource.com/users/itewk
[2]:https://agenda.summit.redhat.com/SessionDetail.aspx?id=154225
[3]:https://www.redhat.com/en/summit/2018

View File

@ -0,0 +1,61 @@
Microservices Explained
======
![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/cloud-microservices.jpg?itok=GpoWiDeG)
Microservices is not a new term. Like containers, the concept been around for a while, but its become a buzzword recently as many companies embark on their cloud native journey. But, what exactly does the term microservices mean? Who should care about it? In this article, well take a deep dive into the microservices architecture.
### Evolution of microservices
Patrick Chanezon, Chief Developer Advocate for Docker provided a brief history lesson during our conversation: In the late 1990s, developers started to structure their applications into monoliths where massive apps hadall features and functionalities baked into them. Monoliths were easy to write and manage. Companies could have a team of developers who built their applications based on customer feedback through sales and marketing teams. The entire developer team would work together to build tightly glued pieces as an app that can be run on their own app servers. It was a popular way of writing and delivering web applications.
There is a flip side to the monolithic coin. Monoliths slow everything and everyone down. Its not easy to update one service or feature of the application. The entire app needs to be updated and a new version released. It takes time. There is a direct impact on businesses. Organizations could not respond quickly to keep up with new trends and changing market dynamics. Additionally, scalability was challenging.
Around 2011, SOA (Service Oriented Architecture) became popular where developers could cram multi-tier web applications as software services inside a VM (virtual machine). It did allow them to add or update services independent of each other. However, scalability still remained a problem.
“The scale out strategy then was to deploy multiple copies of the virtual machine behind a load balancer. The problems with this model are several. Your services can not scale or be upgraded independently as the VM is your lowest granularity for scale. VMs are bulky as they carry extra weight of an operating system, so you need to be careful about simply deploying multiple copies of VMs for scaling,” said Madhura Maskasky, co-founder and VP of Product at Platform9.
Some five years ago when Docker hit the scene and containers became popular, SOA faded out in favor of “microservices” architecture. “Containers and microservices fix a lot of these problems. Containers enable deployment of microservices that are focused and independent, as containers are lightweight. The Microservices paradigm, combined with a powerful framework with native support for the paradigm, enables easy deployment of independent services as one or more containers as well as easy scale out and upgrade of these,” said Maskasky.
### Whats are microservices?
Basically, a microservice architecture is a way of structuring applications. With the rise of containers, people have started to break monoliths into microservices. “The idea is that you are building your application as a set of loosely coupled services that can be updated and scaled separately under the container infrastructure,” said Chanezon.
“Microservices seem to have evolved from the more strictly defined service-oriented architecture (SOA), which in turn can be seen as an expression object oriented programming concepts for networked applications. Some would call it just a rebranding of SOA, but the term “microservices” often implies the use of even smaller functional components than SOA, RESTful APIs exchanging JSON, lighter-weight servers (often containerized, and modern web technologies and protocols,” said Troy Topnik, SUSE Senior Product Manager, Cloud Application Platform.
Microservices provides a way to scale development and delivery of large, complex applications by breaking them down that allows the individual components to evolve independently from each other.
“Microservices architecture brings more flexibility through the independence of services, enabling organizations to become more agile in how they deliver new business capabilities or respond to changing market conditions. Microservices allows for using the right tool for the right task, meaning that apps can be developed and delivered by the technology that will be best for the task, rather than being locked into a single technology, runtime or framework,” said Christian Posta, senior principal application platform specialist, Red Hat.
### Who consumes microservices?
“The main consumers of microservices architecture patterns are developers and application architects,” said Topnik. As far as admins and DevOps engineers are concerned their role is to build and maintain the infrastructure and processes that support microservices.
“Developers have been building their applications traditionally using various design patterns for efficient scale out, high availability and lifecycle management of their applications. Microservices done along with the right orchestration framework help simplify their lives by providing a lot of these features out of the box. A well-designed application built using microservices will showcase its benefits to the customers by being easy to scale, upgrade, debug, but without exposing the end customer to complex details of the microservices architecture,” said Maskasky.
### Who needs microservices?
Everyone. Microservices is the modern approach to writing and deploying applications more efficiently. If an organization cares about being able to write and deploy its services at a faster rate they should care about it. If you want to stay ahead of your competitors, microservices is the fastest route. Security is another major benefit of the microservices architecture, as this approach allows developers to keep up with security and bug fixes, without having to worry about downtime.
“Application developers have always known that they should build their applications in a modular and flexible way, but now that enough of them are actually doing this, those that dont risk being left behind by their competitors,” said Topnik.
If you are building a new application, you should design it as microservices. You never have to hold up a release if one team is late. New functionalities are available when they're ready, and the overall system never breaks.
“We see customers using this as an opportunity to also fix other problems around their application deployment -- such as end-to-end security, better observability, deployment and upgrade issues,” said Maskasky.
Failing to do so means you would be stuck in the traditional stack, which means microservices wont be able to add any value to it. If you are building new applications, microservices is the way to go.
Learn more about cloud-native at [KubeCon + CloudNativeCon Europe][1], coming up May 2-4 in Copenhagen, Denmark.
--------------------------------------------------------------------------------
via: https://www.linux.com/blog/2018/4/microservices-explained
作者:[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://events.linuxfoundation.org/events/kubecon-cloudnativecon-europe-2018/attend/register/

View File

@ -1,102 +0,0 @@
translating by Auk7F7
How to set GNOME to display a custom slideshow
======
A very cool, yet lesser known, feature in GNOME is its ability to display a slideshow as your wallpaper. You can select a wallpaper slideshow from the background settings panel in the [GNOME Control Center][1]. Wallpaper slideshows can be distinguished from static wallpapers by a small clock emblem displayed in the lower-right corner of the preview.
Some distributions come with pre-installed slideshow wallpapers. For example, Ubuntu includes the stock GNOME timed wallpaper slideshow, as well as one of Ubuntu wallpaper contest winners.
What if you want to create your own custom slideshow to use as a wallpaper? While GNOME doesn't provide a user interface for this, it's quite simple to create one using some simple XML files in your home directory. Fortunately, the background selection in the GNOME Control Center honors some common directory paths, which makes it easy to create a slideshow without having to edit anything provided by your distribution.
### Getting started
Using your favorite text editor, create an XML file in `$HOME/.local/share/gnome-background-properties/`. Although the filename isn't important, the directory name matters (and you'll probably have to create the directory). For my example, I created `/home/ken/.local/share/gnome-background-properties/osdc-wallpapers.xml `with the following content:
```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd">
<wallpapers>
<wallpaper deleted="false">
<name>Opensource.com Wallpapers</name>
<filename>/home/ken/Pictures/Wallpapers/osdc/osdc.xml</filename>
<options>zoom</options>
</wallpaper>
</wallpapers>
```
The above XML file needs a `<wallpaper>` stanza for each slideshow or static wallpaper you want to include in the `backgrounds` panel of the GNOME Control Center.
In this example, my `osdc.xml` file looks like this:
```
<?xml version="1.0" ?>
<background>
<static>
<!-- Duration in seconds to display the background -->
<duration>30.0</duration>
<file>/home/ken/Pictures/Wallpapers/osdc/osdc_2.png</file>
</static>
<transition>
<!-- Duration of the transition in seconds, default is 2 seconds -->
<duration>0.5</duration>
<from>/home/ken/Pictures/Wallpapers/osdc/osdc_2.png</from>
<to>/home/ken/Pictures/Wallpapers/osdc/osdc_1.png</to>
</transition>
<static>
<duration>30.0</duration>
<file>/home/ken/Pictures/Wallpapers/osdc/osdc_1.png</file>
</static>
<transition>
<duration>0.5</duration>
<from>/home/ken/Pictures/Wallpapers/osdc/osdc_1.png</from>
<to>/home/ken/Pictures/Wallpapers/osdc/osdc_2.png</to>
</transition>
</background>
```
There are a few important pieces in the above XML. The `<background>` node in the XML is your outer node. Each background supports multiple `<static>` and `<transition>` nodes.
The `<static>` node defines an image to be displayed and the duration to display it with `<duration>` and `<file>` nodes, respectively.
The `<transition>` node defines the `<duration>`, the `<from>` image, and the `<to>` image for each transition.
### Changing wallpaper throughout the day
Another cool GNOME feature is time-based slideshows. You can define the start time for the slideshow and GNOME will calculate times based on it. This is useful for setting different wallpapers based on the time of day. For example, you could set the start time to 06:00 and display one wallpaper until 12:00, then change it for the afternoon, and again at 18:00.
This is accomplished by defining the `<starttime>` in your XML like this:
```
<starttime>
<!-- A start time in the past is fine -->
<year>2017</year>
<month>11</month>
<day>21</day>
<hour>6</hour>
<minute>00</minute>
<second>00</second>
</starttime>
```
The above XML started the animation at 06:00 on November 21, 2017, with a duration of 21,600.00, equal to six hours. This displays your morning wallpaper until 12:00, at which time it changes to your next wallpaper. You can continue in this manner to change the wallpaper at any intervals you'd like throughout the day, but ensure the total of all your durations is 86,400 seconds (equal to 24 hours).
GNOME will calculate the delta between the start time and the current time and display the correct wallpaper for the current time. For example, if you select your new wallpaper at 16:00, GNOME will display the proper wallpaper for 36,000 seconds past the start time of 06:00.
For a complete example, see the adwaita-timed slideshow provided by the gnome-backgrounds package in most distributions. It's usually found in `/usr/share/backgrounds/gnome/adwaita-timed.xml`.
### For more information
Hopefully this encourages you to take a dive into creating your own slideshow wallpapers. If you would like to download complete versions of the files referenced in this article, they can be found on [GitHub][2].
If you're interested in utility scripts for generating the XML files, you can do an internet search for gnome-background-generator.
--------------------------------------------------------------------------------
via: https://opensource.com/article/17/12/create-your-own-wallpaper-slideshow-gnome
作者:[Ken Vandine][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/kenvandine
[1]:http://manpages.ubuntu.com/manpages/xenial/man1/gnome-control-center.1.html
[2]:https://github.com/kenvandine/misc/tree/master/articles/osdc/gnome/slide-show-backgrounds/osdc

View File

@ -1,3 +1,5 @@
pinewall translating
Containers without Docker at Red Hat
======

View File

@ -1,3 +1,5 @@
translating---geekpi
How to Create, Revert and Delete KVM Virtual machine snapshot with virsh command
======
[![KVM-VirtualMachine-Snapshot][1]![KVM-VirtualMachine-Snapshot][2]][2]

View File

@ -1,3 +1,5 @@
translating---geekpi
How to Use WSL Like a Linux Pro
============================================================

View File

@ -1,60 +0,0 @@
translating---geekpi
How to add fonts to Fedora
===================
![](https://fedoramagazine.org/wp-content/uploads/2017/11/install-fonts-1024x433.jpg)
Fonts help you express your thoughts in creative ways through design. Whether youre captioning an image, building a presentation, or designing a greeting or advertisement, fonts can boost your idea to the next level. Its easy to fall in love with them just for their own aesthetic qualities. Fortunately, Fedora makes installation easy. Heres how to do it.
### System-wide installation
If you install a font system-wide, it becomes available to all users. The best way to take advantage of this method is by using RPM packages from the official software repositories.
To get started, open the  _Software_  tool in your Fedora Workstation, or other tool that uses the official repositories. Choose the  _Add-ons_  category in the group of banners shown. Then in the add-on categories, select  _Fonts._  Youll see a list of available fonts similar to this screenshot:
[![](https://fedoramagazine.org/wp-content/uploads/2017/11/Software-fonts-1024x768.png)][1]
When you select a font, some details appear. Depending on several conditions, you may be able to preview how the font looks with some example text. Select the  _Install_ button to add it to your system. It may take a few moments for the process to complete, based on your system speed and network bandwidth.
You can also remove previously installed font packages, shown with a check mark, with the  _Remove_  button shown in the font details.
### Personal installation
This method works better if you have a font youve downloaded in a compatible format:  _.ttf_ ,  _otf_ ,  _.ttc_ ,  _.pfa_ ,  _.pfb_  or . _pcf._  These font extensions shouldnt be installed system-wide by dropping them into a system folder. Non-packaged fonts of this type cant be updated automatically. They also can potentially interfere with some software operations later. The best way to install these fonts is in your own personal data directory.
Open the  _Files_  application in your Fedora Workstation, or a similar file manager app of your choice. If youre using  _Files_ , you may need to use the  _Ctrl+H_  key combination to show hidden files and folders. Look for the  _.fonts_  folder and open it. If you dont have a  _.fonts_  folder, create it. (Remember the leading dot and to use all lowercase.)
Copy the font file youve downloaded to your  _.fonts_  folder. You can close the file manager at this point. Open a terminal and type the following command:
```
fc-cache
```
This will rebuild font caches that help Fedora locate and reference the fonts it can use. You may also need to restart an application such as Inkscape or LibreOffice in which you want to use the new font. Once you restart, the new font should be available.
* * *
Photo by [Raphael Schaller][2] on [Unsplash][3].
--------------------------------------------------------------------------------
作者简介:
Paul W. Frields
Paul W. Frields has been a Linux user and enthusiast since 1997, and joined the Fedora Project in 2003, shortly after launch. He was a founding member of the Fedora Project Board, and has worked on documentation, website publishing, advocacy, toolchain development, and maintaining software. He joined Red Hat as Fedora Project Leader from February 2008 to July 2010, and remains with Red Hat as an engineering manager. He currently lives with his wife and two children in Virginia.
-----------------------------
via: https://fedoramagazine.org/add-fonts-fedora/
作者:[ Paul W. Frields ][a]
译者:[译者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/pfrields/
[1]:https://fedoramagazine.org/wp-content/uploads/2017/11/Software-fonts.png
[2]:https://unsplash.com/photos/GkinCd2enIY?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
[3]:https://unsplash.com/search/photos/fonts?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText

View File

@ -0,0 +1,108 @@
How To Quickly Monitor Multiple Hosts In Linux
======
![](https://www.ostechnix.com/wp-content/uploads/2018/03/rwho-1-720x340.png)
There are plenty of monitoring tools out there to monitor local and remote Linux systems. One fine example is [**Cockpit**][1]. Those tools, however, are either bit complicated to install and use, at least for the newbie admins. The newbie admin might need to spend some time to figure out how to configure those tools to monitor the systems. If you want a quick and dirty way to monitor multiple hosts at a time in your local area network, you might need to check **“rwho”** tool. It will instantly and quickly will monitor the local and remote systems as soon as you install rwho utility. You configure nothing! All you have to do is to install “rwho” tool on the systems that you want to monitor.
Please dont think of rwho as a feature-rich, and complete monitoring tool. This is just a simple tool that monitors only the **uptime** , **load** and **logged in users** of a remote system. Using “rwho” utility, we can find who is logged in on which computer, a list of monitored computers with uptime (time since last reboot), how many users are logged in and the load averages for the past 1, 5, and 15 minutes. Nothing more! Nothing less! Also, it will only monitor the systems that are in the same subnet. hence, it is ideal for small and home office network.
### Monitor Multiple Hosts In Linux
Let me explain how rwho works. Every system that uses rwho on the network will broadcast information about itself. The other computers can access these information using rwhod-daemon. So, every computer on the network must have rwho installed. Also, the rwhod-port (e.g. Port 513/UDP) must be allowed through your firewall/router in-order to distribute or access the information of other hosts.
Alright, let us install it.
I tested in on Ubuntu 16.04 LTS server. rwho is available in the default repositories, so we can install it using the APT package manager like below.
```
$ sudo apt-get install rwho
```
On RPM based systems such as CentOS, Fedora, RHEL, use this command to install it:
```
$ sudo yum install rwho
```
Make sure you have allowed the rwhod-port 513 if you are behind a firewall/router. Also, verify if the rwhod-daemon is running or not using command:
$ sudo systemctl status rwhod
If it is not started already, run the following commands to enable and start rwhod service:
```
$ sudo systemctl enable rwhod
$ sudo systemctl start rwhod
```
Now, it is time to monitor the systems. Run the following command to find out who is logged on which computer:
```
$ rwho
ostechni ostechnix:pts/5 Mar 12 17:41
root server:pts/0 Mar 12 17:42
```
As you can see, currently there are two systems on my local area network. The local system user is **ostechnix** (Ubuntu 16.04 LTS) and remote systems user is **root** (CentOS 7). As you might guessed already, rwho is similar to “who” command, but it will monitor the remote systems too.
And, we can find the uptime of all running systems on the network, using command:
```
$ ruptime
ostechnix up 2:17, 1 user, load 0.09, 0.03, 0.01
server up 1:54, 1 user, load 0.00, 0.01, 0.05
```
Here, ruptime (similar to “uptime” command) displays the total uptime of my Ubuntu (local) and CentOS (remote) systems. Got it? Great! Here is the sample screenshot from my Ubuntu 16.04 LTS system:
![][3]
You can find the information about all other machines in the local area network in the following location:
```
$ ls /var/spool/rwho/
whod.ostechnix whod.server
```
This is a small, yet very useful to find out who is logged in on which computer and the uptime along with system load details.
**Suggested read:**
Please be mindful that this method has one serious loophole. Since information about every computer is broadcasted over the net, everyone in the subnet could potentially get this information. It is okay normally but on the other side this can be a unwanted side-effect when information about the network is distributed to non-authorized users. So, It is strongly recommended to use it in a trusted and protected local area network.
For more details, refer man pages.
```
$ man rwho
```
And, thats all for now. More good stuffs to come. Stay tuned!
Cheers!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/
作者:[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/cockpit-monitor-administer-linux-servers-via-web-browser/
[2]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
[3]:http://www.ostechnix.com/wp-content/uploads/2018/03/rwho.png
[4]:https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/?share=reddit (Click to share on Reddit)
[5]:https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/?share=twitter (Click to share on Twitter)
[6]:https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/?share=facebook (Click to share on Facebook)
[7]:https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/?share=google-plus-1 (Click to share on Google+)
[8]:https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/?share=linkedin (Click to share on LinkedIn)
[9]:https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/?share=pocket (Click to share on Pocket)
[10]:https://api.whatsapp.com/send?text=How%20To%20Quickly%20Monitor%20Multiple%20Hosts%20In%20Linux%20https%3A%2F%2Fwww.ostechnix.com%2Fhow-to-quickly-monitor-multiple-hosts-in-linux%2F (Click to share on WhatsApp)
[11]:https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/?share=telegram (Click to share on Telegram)
[12]:https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/?share=email (Click to email this to a friend)
[13]:https://www.ostechnix.com/how-to-quickly-monitor-multiple-hosts-in-linux/#print (Click to print)

View File

@ -1,135 +0,0 @@
translating---geekpi
Transfer Files From Computer To Mobile Devices By Scanning QR Codes
======
![](https://www.ostechnix.com/wp-content/uploads/2018/03/qr-filetransfer-720x340.png)
Transferring files from a Computer to a smartphone is not a big deal. You can do this by mounting the mobile phone on your system using an USB cable, then transfer files from the file manager. Also, some third party applications, such as [**KDE Connect**][1] and [**AirDroid**][2], can help you to easily manage and transfer files from your system to Android devices. Today, I stumbled upon a super cool utility named **“Qr-filetransfer”**. It allows you to transfer files over WiFi from computer to mobile devices by scanning QR codes without leaving your Terminal. Yes, you read that right! The qr-filetransfer is a free, open source command line utility written using Go programming language. In this brief tutorial, we are going to learn to transfer files from Linux to any mobile devices using qr-transfer.
### Installing Qr-filetransfer
First, install Go language on your system.
On Arch Linux and derivatives:
```
$ sudo pacman -S go
```
On RPM based systems like RHEL, CentOS, Fedora, run:
```
$ sudo yum install golang
```
Or,
```
$ sudo dnf install golang
```
On DEB based systems such as Debian, Ubuntu, Linux Mint, you can install it using command:
```
$ sudo apt-get install golang
```
On SUSE/openSUSE:
```
$ sudo zypper install golang
```
After installing Go language, run the following command to download qr-filetransfer application.
```
$ go get github.com/claudiodangelis/qr-filetransfer
```
The above command will download the contents of a qr-filetrnasfer GitHub repository in a directory named **“go”** in your current working directory.
Copy the qt-filetransfer binary file to your PATH, for example /usr/local/bin/.
```
$ sudo cp go/bin/qr-filetransfer /usr/local/bin/
```
Finally, make it executable as shown below.
```
$ sudo chmod +x /usr/local/bin/qr-filetransfer
```
### Transfer Files From Computer To Mobile Devices By Scanning QR Codes
Make sure that your smartphone is connected to the same WiFi network as your computer.
Then, launch qt-filetransfer tool along the with the file or folder path you want to transfer to your smartphone.
For example, I am going to transfer a mp3 file.
```
$ qr-filetransfer Chill\ Study\ Beats.mp3
```
At first launch, qr-filetransfer will ask you to choose the network interface to use like below.
```
Choose the network interface to use (type the number):
[0] enp5s0
[1] wlp9s0
```
I was going to transfer file using **wlp9s0** interface, so I typed “1”. Qr-filetransfer will remember this choice and you will never be prompted again, unless you pass the **-force** argument, or delete the **.qr-filetransfer.json** file that the program stores in the home directory of current user.
Then, you will see the QR code as shown in the below picture.
![][4]
Open the QR code app (if it is not installed already, install any QR code reader app from play store) and scan the QR code displayed in your terminal.
Once the QR code is read, you will be asked whether you want to copy the link or open the link. You can either copy the link and paste it manually on your mobile web browser or choose “Open link” to automatically open it in your mobile browser.
![][5]
Once the share link has been opened, the file will be downloaded in your smartphone.
![][6]
If the file is too big, zip the file, then transfer it
```
$ qr-filetransfer -zip /path/to/file.txt
```
To transfer a full directory, run:
```
$ qr-filetransfer /path/to/directory
```
Please note that the directory gets zipped before being transferred.
Qr-filetransfer utility will only transfer the stuffs from your system to mobile and not vice versa. This project is very new, so there will be bugs. If you encountered any bugs, report them in the GitHub page given at the end of this guide.
Cheers!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/transfer-files-from-computer-to-mobile-devices-by-scanning-qr-codes/
作者:[SK][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.ostechnix.com/author/sk/
[1]:https://www.ostechnix.com/kde-connect-access-files-notifications-android-devices/
[2]:https://www.ostechnix.com/airdroid-share-files-and-folders-between-linux-and-android/
[4]:http://www.ostechnix.com/wp-content/uploads/2018/03/qr-filetransfer-5.png
[5]:http://www.ostechnix.com/wp-content/uploads/2018/03/qr-filetransfer-6-4.png
[6]:http://www.ostechnix.com/wp-content/uploads/2018/03/qr-filetransfer-4.png

View File

@ -1,82 +0,0 @@
Translating by qhwdw
Reliable IoT event logging with syslog-ng
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openwires_fromRHT_520_0612LL.png?itok=PqZi55Ab)
For any device connected to the internet or a network, it's essential that you log events so you know what the device is doing and can address any potential problems. Increasingly those devices include Internet of Things (IoT) devices and embedded systems.
One monitoring tool to consider is the open source [syslog-ng][1] application, an enhanced logging daemon with a focus on portability and central log collection. It collects logs from many different sources, processes and filters them, and stores or routes them for further analysis. Most of syslog-ng is written in efficient and highly portable C code. It's suitable for a wide range of scenarios, whether you need something simple enough to run with a really small footprint on underpowered devices or a solution powerful enough to reside in your data center and collect logs from tens of thousands of devices.
You probably noticed the abundance of buzzwords I wrote in that single paragraph. To clarify what this all means, let's go over them, but this time slower and in more depth.
### Logging
First things first. Logging is the recording of events on a computer. On a typical Linux machine, you can find these log messages in the `/var/log` directory. For example, if you log into your machine through SSH, you will find a message similar to this in one of the files:
`Jan 14 11:38:48 ``linux``-0jbu sshd[7716]: Accepted ``publickey`` for root from 127.0.0.1 port 48806 ssh2`
It could be about your CPU running too hot, a document downloaded through HTTP, or just about anything one of your applications considers important.
### syslog-ng
As I wrote above, the syslog-ng application is an enhanced logging daemon with a focus on portability and central log collection. Daemon means syslog-ng is an application running continuously in the background; in this case, it's collecting log messages.
While Linux testing for many of today's applications is limited to x86_64 machines, syslog-ng also works on many BSD and commercial UNIX variants. What is even more important from the embedded/IoT standpoint is that it runs on many different CPU architectures, including 32- and 64-bit ARM, PowerPC, MIPS, and more. (Sometimes I learn about new architectures just by reading about how syslog-ng is used.)
Why is central collection of logs such a big deal? One reason is ease of use, as it creates a single place to check instead of tens or thousands of devices. Another reason is availability—you can check a device's log messages even if the device is unavailable for any reason. A third reason is security; when your device is hacked, checking the logs can uncover traces of the hack.
### Four roles of syslog-ng
Syslog-ng has four major roles: collecting, processing, filtering, and storing log messages.
**Collecting messages:** syslog-ng can collect from a wide variety of [platform-specific sources][2], like `/dev/log`, `journal`, or `sun-streams`. As a central log collector, it speaks both the legacy (`rfc3164`) and the new (`rfc5424`) syslog protocols and all their variants over User Datagram Protocol (UDP), TCP, and encrypted connections. You can also collect log messages (or any kind of text data) from pipes, sockets, files, and even application output.
**Processing log messages:** The possibilities here are almost endless. You can classify, normalize, and structure log messages with built-in parsers. You can even write your own parser in Python if none of the available parsers suits your needs. You can also enrich messages with geolocation data or additional fields based on the message content. Log messages can be reformatted to suit the requirements of the application processing the logs. You can also rewrite log messages—not to falsify messages, of course—for things such as anonymizing log messages as required by many compliance regulations.
**Filtering logs:** There are two main uses for filtering logs: To discard surplus log messages—like debug-level messages—to save on storage, and for log routing—making sure the right logs reach the right destinations. An example of the latter is forwarding all authentication-related messages to a security information and event management (SIEM) system.
**Storing messages:** Traditionally, files were saved locally or sent to a central syslog server; either way, they'd be sent to [flat files][3]. Over the years, syslog-ng began supporting SQL databases, and in the past few years Big Data destinations, including HDFS, Kafka, MongoDB, and Elasticsearch, were added to syslog-ng.
### Message formats
When you look at your log messages under the `/var/log` directory, you will see (like in the SSH message above) most are in the form:
`date + host name + application name + an almost complete English sentence`
Where each application event is described by a different sentence, creating a report based on this data is quite a painful job.
The solution to this mess is to use structured logging. In this case, events are represented as name-value pairs instead of freeform log messages. For example, an SSH login can be described by the application name, source IP address, username, authentication method, and so on.
You can take a structured approach for your log messages right from the beginning. When working with legacy log messages, you can use the different parsers in syslog-ng to turn unstructured (and some of the structured) message formats into name-value pairs. Once you have your logs available as name-value pairs, reporting, alerting, and simply finding the information you are looking for becomes a lot easier.
### Logging IoT
Let's start with a tricky question: Which version of syslog-ng is the most popular? Before you answer, consider these facts: The project started 20 years ago, Red Hat Enterprise Linux EPEL has version 3.5, and the current version is 3.14. When I ask this question during my presentations, the audience members usually suggest the one in their favorite Linux distribution. Surprisingly, the correct answer is version 1.6, almost 15 years old. That's because it is the version included in the Amazon Kindle e-book readers, so it's running on over 100 million devices worldwide. Another example of a consumer device running syslog-ng is the BMW i3 all-electric car.
The Kindle uses syslog-ng to collect all possible information about what the user is doing on the device. On the BMW, syslog-ng does very complex, content-based filtering of log messages, and most it likely records only the most important logs.
Networking and storage are other categories of devices that often use syslog-ng. Networking and storage are other categories of devices that often use syslog-ng. Some better known examples are the Turris Omnia open source Linux router and Synology NAS devices. In most cases, syslog-ng started out as a logging client on these devices, but in some cases it's evolved into a central logging server with a rich web interface.
You can find syslog-ng in industrial devices, as well. It runs on all real-time Linux devices from National Instruments doing measurements and automation. It is also used to collect logs from customer-developed applications. Configuration is done from the command line, but a nice GUI is available to browse the logs.
Finally, there are some large-scale projects, such as cars and airplanes, where syslog-ng runs on both the client and server side. The common theme here is that syslog-ng collects all log and metrics data, sends it to a central cluster of servers where logs are processed, and saves it to one of the supported Big Data destinations where it waits for further analysis.
### Overall benefits for IoT
There are several benefits of using syslog-ng in an IoT environment. First, it delivers high performance and reliable log collection. It also simplifies the architecture, as system and application logs and metrics data can be collected together. Third, it makes it easier to use data, as data is parsed and presented in a ready-to-use format. Finally, efficient routing and filtering by syslog-ng can significantly decrease processing load.
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/3/logging-iot-events-syslog-ng
作者:[Peter Czanik][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://opensource.com/users/czanik
[1]:https://syslog-ng.com/open-source-log-management
[2]:https://syslog-ng.com/documents/html/syslog-ng-ose-latest-guides/en/syslog-ng-ose-guide-admin/html/sources.html
[3]:https://en.wikipedia.org/wiki/Flat_file_database

View File

@ -1,105 +0,0 @@
Translating by qhwdw
Build a baby monitor with a Raspberry Pi
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/baby-chick-egg.png?itok=RcFfqdbA)
Hong Kong can be hot and humid, even at night, and many people use air conditioning to make their homes more bearable. When my oldest son was a baby, the air conditioning unit in his bedroom had manual controls and no thermostat functionality. It was either on or off, and allowing it to run continuously overnight caused the room to get cold and wasted energy and money.
I decided to fix this problem with an [Internet of Things][1] solution based on a [Raspberry Pi][2]. Later I took it a step further with a [baby monitor][3] add-on. In this article, I'll explain how I did it, and the code is [available on my GitHub][4] page.
### Setting up the air conditioner controller
I solved the first part of my problem with an Orvibo S20 [WiFi-connected smart plug][5] and smartphone application. Although this allowed me to control the air conditioning unit remotely, it was still a manual process, and I wanted to try and automate it. I found a project on [Instructables][6] that seemed to match my requirements: It used a Raspberry Pi to measure local temperature and humidity readings from an [AM2302 sensor][7] and record them to a MySQL database.
Using crimp terminal contacts with crimp housings made it a pinch to connect the temperature/humidity sensor to the correct GPIO pins on the Raspberry Pi. Fortunately, the AM2302 sensor has [open source software][8] for taking readings, with helpful [Python][9] examples.
The software for [interfacing with the AM2302 sensor][10] has been updated since I put my project together, and the original code I used is now considered legacy and unmaintained. The code is made up of a small binary object to connect to the sensor and some Python scripts to interpret the readings and return the correct values.
![Raspberry Pi, sensor, and Python code][12]
Raspberry Pi, sensor, and Python code used to build the temperature/humidity monitor.
With the sensor connected to the Raspberry Pi, the Python code can correctly return temperature and humidity readings. Connecting Python to a MySQL database is straightforward, and there are plenty of code examples that use the `python-``mysql` bindings. Because I needed to monitor the temperature and humidity continuously, I wrote software to do this.
In fact, I ended up with two solutions, one that would run continuously as a process and periodically poll the sensor (typically at one-minute intervals), and another Python script that ran once and exited. I decided to use the run-once-and-exit approach coupled with cron to call this script every minute. The main reason was that the continuous (looped) script occasionally would not return a reading, which could lead to a buildup of processes trying to read the sensor, and that would eventually cause a system to hang due to lack of available resources.
I also found a convenient [Perl script][13] to programmatically control my smart plug. This was an essential piece of the jigsaw, as it meant I could trigger the Perl script if certain temperature and/or humidity conditions were met. After some testing, I decided to create a separate `checking` script that would pull the latest values from the MySQL database and set the smart plug on or off depending upon the values returned. Separating the logic to run the plug control script from the sensor-reading script also meant that it operated independently and would continue to run, even if the sensor-reading script developed problems.
It made sense to make the temperature at which the air conditioner would switch on/off configurable, so I moved these values to a configuration file that the control script read. I also found that, although the sensor was generally accurate, occasionally it would return incorrect readings. The sensor script was modified to not write temperature or humidity values to the MySQL database that were significantly different from the previous values. Likewise the allowed variance of temperature or humidity between consecutive readings was set in a general configuration file, and if the reading was outside these limits the values would not be committed to the database.
Although this seemed like quite a lot of effort to make a thermostat, recording the data to a MySQL database meant it was available for further analysis to identify usage patterns. There are many graphing options available to present data from a MySQL database, and I decided to use [Google Chart][14]to display the data on a web page.
![Temperature and humidity chart][16]
Temperature and humidity measured over the previous six hours.
### Adding a baby monitor camera
The open nature of the Raspberry Pi meant I could continue to add functionality—and I had plenty of open GPIO pins available. My next idea was to add a camera module to set it up as a baby monitor, given that the device was already in the baby's bedroom.
I needed a camera that works in the dark, and the [Pi Noir][17] camera module is perfect for this. The Pi Noir is the same as the Raspberry Pi's regular camera module, except it doesn't have an infrared (IR) filter. This means daytime images may have a slightly purple tint, but it will display images lit with IR light in the dark.
Now I needed a source of IR light. Due to the Pi's popularity and low barrier of entry, there are a huge number of peripherals and add-ons for it. Of the many IR sources available, the one that caught my attention was the [Bright Pi][18]. It draws power from the Raspberry Pi and fits around the camera Pi module to provide a source of IR and normal light. The only drawback was I needed to dust off my rusty soldering skills.
It might have taken me longer than most, but my soldering skills were up to it, and I was able to successfully attach all the IR LEDs to the housing and connect the IR light source to the Pi's GPIO pins. This also meant that the Pi could programmatically control when the IR LEDs were lit, as well as their light intensity.
It also made sense to have the video capture exposed via a web stream so I could watch it from the web page with the temperature and humidity readings chart. After further research, I chose to use a [streaming software][19] that used M-JPEG captures. Exposing the JPG source via the web page also allowed me to connect camera viewer applications on my smartphone to view the camera output there, as well.
### Putting on the finishing touches
No Raspberry Pi project is complete without selecting an appropriate case for the Pi and its various components. After a lot of searching and comparing, there was one clear [winner][20]: SmartPi's Lego-style case. The Lego compatibility allowed me to build mounts for the temperature/humidity sensor and camera. Here's the final outcome:
![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pibabymonitor_case.png?itok=_ofyN73a)
Since then, I've made other changes and updates to my setup:
* I upgraded from a Raspberry Pi 2 Model B to a [Raspberry Pi 3][21], which meant I could do away with the USB WiFi module.
* I replaced the Orvibo S20 with a [TP-Link HS110][22] smart plug.
* I also plugged the Pi into a smart plug so I can do remote reboots/resets.
* I migrated the MySQL database off the Raspberry Pi, and it now runs in a container on a NAS device.
* I added a [flexible tripod][23] to allow for the best camera angle.
* I recompiled the USB WiFi module to disable the onboard flashing LED, which was one of the main advantages to upgrading to a Raspberry Pi 3.
* I've since built another monitor for my second child.
* I bought a bespoke night camera for my third child … due to lack of time.
Want to learn more? All the code is [available on my GitHub][4] page.
Do you have a Raspberry Pi project to share? [Send us your story idea][24].
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/3/build-baby-monitor-raspberry-pi
作者:[Jonathan Ervine][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/jervine
[1]:https://opensource.com/tags/internet-things
[2]:https://opensource.com/tags/raspberry-pi
[3]:https://opensource.com/article/17/9/gonimo
[4]:https://github.com/jervine/rpi-temp-humid-monitor
[5]:https://www.amazon.co.uk/marsboy-S20-Automation-Control-Smartphone/dp/B01LXKPUDK/ref=sr_1_1/258-6082934-2585109?ie=UTF8&qid=1520578769&sr=8-1&keywords=orvibo+s20
[6]:http://www.instructables.com/id/Raspberry-Pi-Temperature-Humidity-Network-Monitor/
[7]:https://www.adafruit.com/product/393
[8]:https://github.com/adafruit/Adafruit_Python_DHT
[9]:https://opensource.com/tags/python
[10]:https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/tree/legacy/Adafruit_DHT_Driver_Python
[11]:/file/390916
[12]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pibabymonitor_materials.png?itok=2w03CdKM (Raspberry Pi, sensor, and Python code)
[13]:https://github.com/franc-carter/bauhn-wifi
[14]:https://developers.google.com/chart/
[15]:/file/390876
[16]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pibabymonitor_temp-humidity.png?itok=2jqtQU0x (Temperature and humidity chart)
[17]:https://www.raspberrypi.org/products/pi-noir-camera-v2/
[18]:https://www.pi-supply.com/product/bright-pi-bright-white-ir-camera-light-raspberry-pi/
[19]:https://elinux.org/RPi-Cam-Web-Interface
[20]:https://smarticase.com/collections/all/products/smartipi-kit-3
[21]:https://opensource.com/article/18/3/raspberry-pi-3b-model-news
[22]:https://www.tp-link.com/uk/products/details/cat-5258_HS110.html
[23]:https://www.amazon.com/Flexpod-Flexible-Tripod-Discontinued-Manufacturer/dp/B000JC8WYA
[24]:http://opensource.com/story

View File

@ -0,0 +1,114 @@
What NASA Has Been Doing About Open Science
======
![][1]
We have recently started a new [Science category][2] on Its FOSS. We covered [how open source approach is impacting Science][3] in the last article. In this open science article, we discuss [NASA][4]s actively growing efforts that involve their dynamic role in boosting scientific research by encouraging open source practices.
### How NASA is using Open Source approach to improve science
It was a great [initiative][5] by NASA that they made their entire research library freely available on the public domain.
Yes! Entire research library for everyone to access and get benefit from it in their research.
Their open science resources can now be mainly classified into these three categories as follows:
* Open Source NASA
* Open API
* Open Data
#### 1\. Open Source NASA
Heres an interesting interview of [Chris Wanstrath][6], co-founder and CEO of [GitHub][7], about how it all began to form many years ago:
Uniquely named “[code.nasa.gov][8]“, NASA now has precisely 365 scientific software available as [open source via GitHub][9] as of the time of this post. So if you are a developer who loves coding, you can study each one of them every day for a years time!
Even if you are not a developer, you can still browse through the fantastic collection of open source packages enlisted on the portal!
One of the interesting open source packages listed here is the source code of [Apollo 11][10]s guidance computer. The Apollo 11 spaceflight took [the first two humans to the Moon][11], namely, [Neil Armstrong][12] and [Edwin Aldrin][13] ! If you want to know more about Edwin Aldrin, you might want to pay a visit [here][14].
##### Licenses being used by NASAs Open Source Initiative:
Here are the different [open source licenses][15] categorized as under:
#### 2\. Open API
An Open [Application Programming Interface][16] or API plays a significant role in practicing Open Science. Just like [The Open Source Initiative][17], there is also one for API, called [The Open API Initiative][18]. Here is a simple illustration of how an API bridges an application with its developer:
![][19]
Do check out the link in the caption in the image above. The API has been explained in a straightforward manner. It concludes with five exciting takeaways in the end.
![][20]
Makes one wonder how different [an open vs a proprietary API][21] would be.
![][22]
Targeted towards application developers, [NASAs open API][23] is an initiative to significantly improve the accessibility of data that could also contain image content. The site has a live editor, allowing you check out the [API][16] behind [Astronomy Picture of the Day (APOD)][24].
#### 3\. Open Data
![][25]
In [our first science article][3], we shared with you the various open data models of three countries mentioned under the “Open Science” section, namely, France, India and the U.S. NASA also has a similar approach towards the same idea. This is a very important ideology that is being adopted by [many countries][26].
[NASAs Open Data Portal][27] focuses on openness by having an ever-growing catalog of data, available for anyone to access freely. The inclusion of datasets within this collection is an essential and radical step towards the development of research of any kind. NASA have even taken a fantastic initiative to ask for dataset suggestions for submission on their portal and thats really very innovative, considering the growing trends of [data science][28], [AI and deep learning][29].
The following video shows students and scientists coming up with their own definitions of Data Science based on their personal experience and research. That is really encouraging! [Dr. Murtaza Haider][30], Ted Rogers School of Management, Ryerson University, mentions the difference Open Source is making in the field of Data Science before the video ends. He explains in very simple terms, how development models transitioned from a closed source approach to an open one. The vision has proved to be sufficiently true enough in todays time.
![][31]
Now anyone can suggest a dataset of any kind on NASA. Coming back to the video above, NASAs initiative can be related so much with submitting datasets and working on analyzing them for better Data Science!
![][32]
You just need to signup for free. This initiative will have a very positive effect in the future, considering open discussions on the public forum and the significance of datasets in every type of analytical field that could exist. Statistical studies will also significantly improve for sure. We will talk about these concepts in detail in a future article and also about their relativeness to an open source model.
So thus concludes an exploration into NASAs open science model. See you soon in another open science article!
--------------------------------------------------------------------------------
via: https://itsfoss.com/nasa-open-science/
作者:[Avimanyu Bandyopadhyay][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://itsfoss.com/author/avimanyu/
[1]:https://itsfoss.com/wp-content/uploads/2018/03/tux-in-space.jpg
[2]:https://itsfoss.com/category/science/
[3]:https://itsfoss.com/open-source-impact-on-science/
[4]:https://www.nasa.gov/
[5]:https://futurism.com/free-science-nasa-just-opened-its-entire-research-library-to-the-public/
[6]:http://chriswanstrath.com/
[7]:https://github.com/
[8]:http://code.nasa.gov
[9]:https://github.com/open-source
[10]:https://www.nasa.gov/mission_pages/apollo/missions/apollo11.html
[11]:https://www.space.com/16758-apollo-11-first-moon-landing.html
[12]:https://www.jsc.nasa.gov/Bios/htmlbios/armstrong-na.html
[13]:https://www.jsc.nasa.gov/Bios/htmlbios/aldrin-b.html
[14]:https://buzzaldrin.com/the-man/
[15]:https://itsfoss.com/open-source-licenses-explained/
[16]:https://en.wikipedia.org/wiki/Application_programming_interface
[17]:https://opensource.org/
[18]:https://www.openapis.org/
[19]:https://itsfoss.com/wp-content/uploads/2018/03/api-bridge.jpeg
[20]:https://itsfoss.com/wp-content/uploads/2018/03/open-api-diagram.jpg
[21]:http://www.apiacademy.co/resources/api-strategy-lesson-201-private-apis-vs-open-apis/
[22]:https://itsfoss.com/wp-content/uploads/2018/03/nasa-open-api-live-example.jpg
[23]:https://api.nasa.gov/
[24]:https://apod.nasa.gov/apod/astropix.html
[25]:https://itsfoss.com/wp-content/uploads/2018/03/nasa-open-data-portal.jpg
[26]:https://www.xbrl.org/the-standard/why/ten-countries-with-open-data/
[27]:https://data.nasa.gov/
[28]:https://en.wikipedia.org/wiki/Data_science
[29]:https://www.kdnuggets.com/2017/07/ai-deep-learning-explained-simply.html
[30]:https://www.ryerson.ca/tedrogersschool/bm/programs/real-estate-management/murtaza-haider/
[31]:https://itsfoss.com/wp-content/uploads/2018/03/suggest-dataset-nasa-1.jpg
[32]:https://itsfoss.com/wp-content/uploads/2018/03/suggest-dataset-nasa-2-1.jpg

View File

@ -1,3 +1,6 @@
Translating by MjSeven
Getting started with Vagrant
======

View File

@ -0,0 +1,172 @@
12 Best GTK Themes for Ubuntu and other Linux Distributions
======
**Brief: Lets have a look at some of the beautiful GTK themes that you can use not only in Ubuntu but other Linux distributions that use GNOME.**
For those of us that use Ubuntu proper, the move from Unity to Gnome as the default desktop environment has made theming and customizing easier than ever. Gnome has a fairly large tweaking community, and there is no shortage of fantastic GTK themes for users to choose from. With that in mind, I went ahead and found some of my favorite themes that I have come across in recent months. These are what I believe offer some of the best experiences that you can find.
### Best themes for Ubuntu and other Linux distributions
This is not an exhaustive list and may exclude some of the themes you already use and love, but hopefully, you find at least one theme that you enjoy that you did not already know about. All themes present should work on any Gnome 3 setup, Ubuntu or not. I lost some screenshots so I have taken images from the official websites.
The themes listed here are in no particular order.
But before you see the best GNOME themes, you should learn [how to install themes in Ubuntu GNOME][1].
#### 1\. Arc-Ambiance
![][2]
Arc and Arc variant themes have been around for quite some time now, and are widely regarded as some of the best themes you can find. In this example, I have selected Arc-Ambiance because of its modern take on the default Ambiance theme in Ubuntu.
I am a fan of both the Arc theme and the default Ambiance theme, so needless to say, I was pumped when I came across a theme that merged the best of both worlds. If you are a fan of the arc themes but not a fan of this one in particular, Gnome look has plenty of other options that will most certainly suit your taste.
[Arc-Ambiance Theme][3]
#### 2\. Adapta Colorpack
![][4]
The Adapta theme has been one of my favorite flat themes I have ever found. Like Arc, Adapata is widely adopted by many-a-linux user. I have selected this color pack because in one download you have several options to choose from. In fact, there are 19 to choose from. Yep. You read that correctly. 19!
So, if you are a fan of the flat/material design language that we see a lot of today, then there is most likely a variant in this theme pack that will satisfy you.
[Adapta Colorpack Theme][5]
#### 3\. Numix Collection
![][6]
Ah, Numix! Oh, the years we have spent together! For those of us that have been theming our DE for the last couple of years, you must have come across the Numix themes or icon packs at some point in time. Numix was probably the first modern theme for Linux that I fell in love with, and I am still in love with it today. And after all these years, it still hasnt lost its charm.
The gray tone throughout the theme, especially with the default pinkish-red highlight color, makes for a genuinely clean and complete experience. You would be hard pressed to find a theme pack as polished as Numix. And in this offering, you have plenty of options to choose from, so go crazy!
[Numix Collection Theme][7]
#### 4\. Hooli
![][8]
Hooli is a theme that has been out for some time now, but only recently came across my radar. I am a fan of most flat themes but have usually strayed away from themes that come to close to the material design language. Hooli, like Adapta, takes notes from that design language, but does it in a way that I think sets it apart from the rest. The green highlight color is one of my favorite parts about the theme, and it does a good job at not overpowering the entire theme.
[Hooli Theme][9]
#### 5\. Arrongin/Telinkrin
![][10]
Bonus: Two themes in one! And they are relatively new contenders in the theming realm. They both take notes from Ubuntus soon to be finished “[communitheme][11]” and bring it to your desktop today. The only real difference I can find between the offerings are the colors. Arrongin is centered around an Ubuntu-esq orange color, while Telinkrin uses a slightly more KDE Breeze-esq blue. I personally prefer the blue, but both are great options!
[Arrongin/Telinkrin Themes][12]
#### 6\. Gnome-osx
![][13]
I have to admit, usually, when I see that a theme has “osx” or something similar in the title, I dont expect much. Most Apple inspired themes seem to have so much in common that I cant really find a reason to use them. There are two themes I can think of that break this mold: the Arc-osc them and the Gnome-osx theme that we have here.
The reason I like the Gnome-osx theme is because it truly does look at home on the Gnome desktop. It does a great job at blending into the DE without being too flat. So for those of you that enjoy a slightly less flat theme, and you like the red, yellow, and green button scheme for the close, minimize, and maximize buttons, than this theme is perfect for you.
[Gnome-osx Theme][14]
#### 7\. Ultimate Maia
![][15]
There was a time when I used Manjaro Gnome. Since then I have reverted back to Ubuntu, but one thing I wish I could have brought with me was the Manjaro theme. If you feel the same about the Manjaro theme as I do, then you are in luck because you can bring it to ANY distro you want that is running Gnome!
The rich green color, the Breeze-esq close, minimize, maximize buttons, and the over-all polish of the theme makes for one compelling option. It even offers some other color variants of you are not a fan of the green. But lets be honest…who isnt a fan of that Manjaro green color?
[Ultimate Maia Theme][16]
#### 8\. Vimix
![][17]
This was a theme I easily got excited about. It is modern, pulls from the macOS red, yellow, green buttons without directly copying them, and tones down the vibrancy of the theme, making for one unique alternative to most other themes. It comes with three dark variants and several colors to choose from so most of us will find something we like.
[Vimix Theme][18]
#### 9\. Ant
![][19]
Like Vimix, Ant pulls inspiration from macOS for the button colors without directly copying the style. Where Vimix tones down the color options, Ant adds a richness to the colors that looks fantastic on my System 76 Galago Pro screen. The variation between the three theme options is pretty dramatic, and though it may not be to everyones taste, it is most certainly to mine.
[Ant Theme][20]
#### 10\. Flat Remix
![][21]
If you havent noticed by this point, I am a sucker for someone who pays attention to the details in the close, minimize, maximize buttons. The color theme that Flat Remix uses is one I have not seen anywhere else, with a red, blue, and orange color way. Add that on top of a theme that looks almost like a mix between Arc and Adapta, and you have Flat Remix.
I am personally a fan of the dark option, but the light alternative is very nice as well. So if you like subtle transparencies, a cohesive dark theme, and a touch of color here and there, Flat Remix is for you.
[Flat Remix Theme][22]
#### 11\. Paper
![][23]
[Paper][24] has been around for some time now. I remember using it for the first back in 2014. I would say, at this point, Paper is more known for its icon pack than for its GTK theme, but that doesnt mean that the theme isnt a wonderful option in and of its self. Even though I adored the Paper icons from the beginning, I cant say that I was a huge fan of the Paper theme when I first tried it out.
I felt like the bright colors and fun approach to a theme made for an “immature” experience. Now, years later, Paper has grown on me, to say the least, and the light hearted approach that the theme takes is one I greatly appreciate.
[Paper Theme][25]
#### 12\. Pop
![][26]
Pop is one of the newer offerings on this list. Created by the folks over at [System 76][27], the Pop GTK theme is a fork of the Adapta theme listed earlier and comes with a matching icon pack, which is a fork of the previously mentioned Paper icon pack.
The theme was released soon after System 76 announced that they were releasing [their own distribution,][28] Pop!_OS. You can read my [Pop!_OS review][29] to know more about it. Needless to say, I think Pop is a fantastic theme with a superb amount of polish and offers a fresh feel to any Gnome desktop.
[Pop Theme][30]
#### Conclusion
Obviously, there way more themes to choose from than we could feature in one article, but these are some of the most complete and polished themes I have used in recent months. If you think we missed any that you really like or you just really dislike one that I featured above, then feel free to let me know in the comment section below and share why you think your favorite themes are better!
--------------------------------------------------------------------------------
via: https://itsfoss.com/best-gtk-themes/
作者:[Phillip Prado][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://itsfoss.com/author/phillip/
[1]:https://itsfoss.com/install-themes-ubuntu/
[2]:https://itsfoss.com/wp-content/uploads/2018/03/arcambaince-300x225.png
[3]:https://www.gnome-look.org/p/1193861/
[4]:https://itsfoss.com/wp-content/uploads/2018/03/adapta-300x169.jpg
[5]:https://www.gnome-look.org/p/1190851/
[6]:https://itsfoss.com/wp-content/uploads/2018/03/numix-300x169.png
[7]:https://www.gnome-look.org/p/1170667/
[8]:https://itsfoss.com/wp-content/uploads/2018/03/hooli2-800x500.jpg
[9]:https://www.gnome-look.org/p/1102901/
[10]:https://itsfoss.com/wp-content/uploads/2018/03/AT-800x590.jpg
[11]:https://itsfoss.com/ubuntu-community-theme/
[12]:https://www.gnome-look.org/p/1215199/
[13]:https://itsfoss.com/wp-content/uploads/2018/03/gosx-800x473.jpg
[14]:https://www.opendesktop.org/s/Gnome/p/1171688/
[15]:https://itsfoss.com/wp-content/uploads/2018/03/ultimatemaia-800x450.jpg
[16]:https://www.opendesktop.org/s/Gnome/p/1193879/
[17]:https://itsfoss.com/wp-content/uploads/2018/03/vimix-800x450.jpg
[18]:https://www.gnome-look.org/p/1013698/
[19]:https://itsfoss.com/wp-content/uploads/2018/03/ant-800x533.png
[20]:https://www.opendesktop.org/p/1099856/
[21]:https://itsfoss.com/wp-content/uploads/2018/03/flatremix-800x450.png
[22]:https://www.opendesktop.org/p/1214931/
[23]:https://itsfoss.com/wp-content/uploads/2018/04/paper-800x450.jpg
[24]:https://itsfoss.com/install-paper-theme-linux/
[25]:https://snwh.org/paper/download
[26]:https://itsfoss.com/wp-content/uploads/2018/04/pop-800x449.jpg
[27]:https://system76.com/
[28]:https://itsfoss.com/system76-popos-linux/
[29]:https://itsfoss.com/pop-os-linux-review/
[30]:https://github.com/pop-os/gtk-theme/blob/master/README.md

View File

@ -0,0 +1,166 @@
The Shuf Command Tutorial With Examples For Beginners
======
![](https://www.ostechnix.com/wp-content/uploads/2018/04/shuf-command-720x340.png)
The Shuf command is used to generate random permutations in Unix-like operating systems. Using shuf command, we can shuffle the lines of a given input file randomly. Shuf command is part of GNU Coreutils, so you dont have bother with installation. In this brief tutorial, let me show you some examples of shuf command.
### The Shuf Command Tutorial With Examples
I have a file named **ostechnix.txt** with the following contents.
```
$ cat ostechnix.txt
line1
line2
line3
line4
line5
line6
line7
line8
line9
line10
```
Now let us display the above lines in a random order. To do so, run:
```
$ shuf ostechnix.txt
line2
line8
line5
line10
line7
line1
line4
line6
line9
line3
```
See? The above command randomized the order of lines in the file named “ostechnix.txt” and output the result.
You might want to write the output to another file. For example, I want to save the output in a file named **output.txt**. To do so, first create output.txt file:
```
$ touch output.txt
```
Then, write the output to that file using **-o** flag like below.
```
$ shuf ostechnix.txt -o output.txt
```
The above command will shuffle the contents of ostechnix.txt file randomly and write the output to output.txt file. You can view the output.txt file contents using command:
```
$ cat output.txt
line2
line8
line9
line10
line1
line3
line7
line6
line4
line5
```
I just want to display any one of the random line from the file. How do I do it? Simple!
```
$ shuf -n 1 ostechnix.txt
line6
```
Similarly, we can pick the first “n” random entries. The following command will display the only the first five random entries.
```
$ shuf -n 5 ostechnix.txt
line10
line4
line5
line9
line3
```
Instead of reading the lines from a file, we can directly pass the inputs using **-e** flag like below.
```
$ shuf -e line1 line2 line3 line4 line5
line1
line3
line5
line4
line2
```
You can pass shuffle the numbers too:
```
$ shuf -e 1 2 3 4 5
3
5
1
4
2
```
To quickly pick any one from the given range, use this command instead.
```
$ shuf -n 1 -e 1 2 3 4 5
```
Or, pick any three random numbers like below.
```
$ shuf -n 3 -e 1 2 3 4 5
3
5
1
```
We can also generate random numbers within a particular range. For example, to display random numbers between 1 to 10, simply use:
```
$ shuf -i 1-10
1
9
8
2
4
7
6
3
10
5
```
For more details, refer man pages.
```
$ man shuf
```
And, thats all for today. More good stuffs to come. Stay tuned!
Cheers!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/the-shuf-command-tutorial-with-examples-for-beginners/
作者:[SK][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.ostechnix.com/author/sk/

View File

@ -0,0 +1,102 @@
translating---geekpi
A Kernel Module That Forcibly Shutdown Your System
======
![](https://www.ostechnix.com/wp-content/uploads/2018/04/kgotobed-720x340.png)
I know that staying up late is bad for the health. But, who cares? I have been a night owl for years. I usually go to bed after 12 am, sometimes after 1 am. The next morning, I snooze my alarm at least three times, wake up tired and grumpy. Everyday, I promise myself I will go to bed earlier, but ended up going to bed very late as usual. And, this cycle continues! If youre anything like me, here is a good news. A fellow late nighter has developed a Kernel module named **“Kgotobed”** that forces you to go to bed at a specific time. That said it will forcibly shutdown your system.
Why should I use this? I have plenty of other options. I can set a cron job to schedule system shutdown at a specific time. I can set up a reminder or alarm clock. I can use a browser plugin or a software. You might ask! However, they all are can easily be ignored or bypassed. Kgotobed is something that you cant ignore. Something that **cant be disabled even if youre a root user**. Yes, it will forcibly power off your system at the specified time. There is no snooze option. You cant postpone the power off process or you cant cancel it either. Your system will go down at the specified time no matter what. You have been warned!!
### Install Kgotobed
Make sure you have installed **dkms**. It is available in the default repositories of most Linux distributions.
For example on Fedora, you can install it using the following command:
```
$ sudo dnf install kernel-devel-$(uname -r) dkms
```
On Debian, Ubuntu, linux Mint:
```
$ sudo apt install dkms
```
Once installed the prerequisites, git clone Kgotobed project.
```
$ git clone https://github.com/nikital/kgotobed.git
```
This command will clone all contents of Kgotobed repository in a folder named “kgotobed” in your current working directory. Cd to that directory:
```
$ cd kgotobed/
```
And, install Kgotobed driver using command:
```
$ sudo make install
```
The above command will register **kgotobed.ko** module with **DKMS** (so that it will be rebuilt for every kernel you run) and Install **gotobed** utility in **/usr/local/bin/** location and then register, enable and start kgotobed service.
### How it works
By default, Kgotobed sets bedtime to **1:00 AM**. That said, your computer will shutdown at 1:00 AM no matter what youre doing.
To view the current bed time, run:
```
$ gotobed
Current bedtime is 2018-04-10 01:00:00
```
To move the bed time earlier, for example 22:00 (10 PM), run:
```
$ sudo gotobed 22:00
[sudo] password for sk:
Current bedtime is 2018-04-10 00:58:00
Setting bedtime to 2018-04-09 22:00:00
Bedtime will be in 2 hours 16 minutes
```
This can be helpful when you want to sleep earlier!
However, you cant move the bed time later i.e after 1:00 AM. You cant unload the module, and adjusting system clock wont help either. The only way out is a reboot!!
To set different default time, you need to customize **kgotobed.service** (by editing it or by using systemd drop-in).
### Uninstall Kgotobed
Not happy with Kgotobed? No worries! Go to the “kgotobed” folder which we cloned earlier and run the following command to uninstall it.
```
$ sudo make uninstall
```
Again, I warn you there is no way to snooze, postpone, or cancel the power off process, even if youre a root user. Your system will go down forcibly at the specified time. This is not for everyone! It may drive you nuts when youre working on an important task. In such cases, make sure you have saved the work from time to time or use some advanced utilities that help you to auto shutdown, reboot, suspend, and hibernate your system at a specific time as described in the following link.
And, thats for now. Hope you find this guide useful. More good stuffs to come. Stay tuned!
Cheers!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/kgotobed-a-kernel-module-that-forcibly-shutdown-your-system/
作者:[SK][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.ostechnix.com/author/sk/

View File

@ -0,0 +1,281 @@
How to create LaTeX documents with Emacs
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/email_paper_envelope_document.png?itok=uPj_kouJ)
In his excellent article, [An introduction to creating documents in LaTeX][1], author [Aaron Cocker][2] introduces the [LaTeX typesetting system][3] and explains how to create a LaTeX document using [TeXstudio][4]. He also lists a few LaTeX editors that many users find helpful in creating LaTeX documents.
This comment on the article by [Greg Pittman][5] caught my attention: "LaTeX seems like an awful lot of typing when you first start...". This is true. LaTeX involves a lot of typing and debugging, if you missed a special character like an exclamation mark, which can discourage many users, especially beginners. In this article, I will introduce you to [GNU Emacs][6] and describe how to use it to create LaTeX documents.
### Creating your first document
Launch Emacs by typing:
```
emacs -q --no-splash helloworld.org
```
The `-q` flag ensures that no Emacs initializations will load. The `--no-splash-screen` flag prevents splash screens to ensure that only one window is open, with the file `helloworld.org`.
![Emacs startup screen][8]
GNU Emacs with the helloworld.org file opened in a buffer window
Let's add some LaTeX headers the Emacs way: Go to **Org** in the menu bar and select **Export/Publish**.
![template_flow.png][10]
Inserting a default template
In the next window, Emacs offers options to either export or insert a template. Insert the template by entering **#** ([#] Insert template). This will move a cursor to a mini-buffer, where the prompt reads **Options category:**. At this time you may not know the category names; press Tab to see possible completions. Type "default" and press Enter. The following content will be inserted:
```
#+TITLE: helloworld
#+DATE: <2018-03-12 Mon>
#+AUTHOR:
#+EMAIL: makerpm@nubia
#+OPTIONS: ':nil *:t -:t ::t <:t H:3 \n:nil ^:t arch:headline
#+OPTIONS: author:t c:nil creator:comment d:(not "LOGBOOK") date:t
#+OPTIONS: e:t email:nil f:t inline:t num:t p:nil pri:nil stat:t
#+OPTIONS: tags:t tasks:t tex:t timestamp:t toc:t todo:t |:t
#+CREATOR: Emacs 25.3.1 (Org mode 8.2.10)
#+DESCRIPTION:
#+EXCLUDE_TAGS: noexport
#+KEYWORDS:
#+LANGUAGE: en
#+SELECT_TAGS: export
```
Change the title, date, author, and email as you wish. Mine looks like this:
```
#+TITLE: Hello World! My first LaTeX document
#+DATE: \today
#+AUTHOR: Sachin Patil
#+EMAIL: psachin@redhat.com
```
We don't want to create a Table of Contents yet, so change the value of `toc` from `t` to `nil` inline, as shown below:
```
#+OPTIONS: tags:t tasks:t tex:t timestamp:t toc:nil todo:t |:t
```
Let's add a section and paragraphs. A section starts with an asterisk (*). We'll copy the content of some paragraphs from Aaron's post (from the [Lipsum Lorem Ipsum generator][11]):
```
* Introduction
  \paragraph{}
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras lorem
  nisi, tincidunt tempus sem nec, elementum feugiat ipsum. Nulla in
  diam libero. Nunc tristique ex a nibh egestas sollicitudin.
  \paragraph{}
  Mauris efficitur vitae ex id egestas. Vestibulum ligula felis,
  pulvinar a posuere id, luctus vitae leo. Sed ac imperdiet orci, non
  elementum leo. Nullam molestie congue placerat. Phasellus tempor et
  libero maximus commodo.
```
![helloworld_file.png][13]
The helloworld.org file
With the content in place, we'll export the content as a PDF. Select **Export/Publish** from the **Org** menu again, but this time, type **l** (export to LaTeX), followed by **o** (as PDF file and open). This not only opens PDF file for you to view, but also saves the file as `helloworld.pdf` in the same path as `helloworld.org`.
![org_to_pdf.png][15]
Exporting helloworld.org to helloworld.pdf
![org_and_pdf_file.png][17]
Opening the helloworld.pdf file
You can also export org to PDF by pressing `Alt + x`, then typing "org-latex-export-to-pdf". Use Tab to auto-complete.
Emacs also creates the `helloworld.tex` file to give you control over the content.
![org_tex_pdf.png][19]
Emacs with LaTeX, org, and PDF files open in three different windows
You can compile the `.tex` file to `.pdf` using the command:
```
pdflatex helloworld.tex
```
You can also export the `.org` file to HTML or as a simple text file. What I like about .org files is they can be pushed to [GitHub][20], where they are rendered just like any other markdown formats.
### Creating a LaTeX Beamer presentation
Let's go a step further and create a LaTeX [Beamer][21] presentation using the same file with some modifications as shown below:
```
#+TITLE: LaTeX Beamer presentation
#+DATE: \today
#+AUTHOR: Sachin Patil
#+EMAIL: psachin@redhat.com
#+OPTIONS: ':nil *:t -:t ::t <:t H:3 \n:nil ^:t arch:headline
#+OPTIONS: author:t c:nil creator:comment d:(not "LOGBOOK") date:t
#+OPTIONS: e:t email:nil f:t inline:t num:t p:nil pri:nil stat:t
#+OPTIONS: tags:t tasks:t tex:t timestamp:t toc:nil todo:t |:t
#+CREATOR: Emacs 25.3.1 (Org mode 8.2.10)
#+DESCRIPTION:
#+EXCLUDE_TAGS: noexport
#+KEYWORDS:
#+LANGUAGE: en
#+SELECT_TAGS: export
#+LATEX_CLASS: beamer
#+BEAMER_THEME: Frankfurt
#+BEAMER_INNER_THEME: rounded
* Introduction
*** Programming
    - Python
    - Ruby
*** Paragraph one
    Lorem ipsum dolor sit amet, consectetur adipiscing
    elit. Cras lorem nisi, tincidunt tempus sem nec, elementum feugiat
    ipsum. Nulla in diam libero. Nunc tristique ex a nibh egestas
    sollicitudin.
*** Paragraph two
    Mauris efficitur vitae ex id egestas. Vestibulum
    ligula felis, pulvinar a posuere id, luctus vitae leo. Sed ac
    imperdiet orci, non elementum leo. Nullam molestie congue
    placerat. Phasellus tempor et libero maximus commodo.
* Thanks
*** Links
    - Link one
    - Link two
```
We have added three more lines to the header:
```
#+LATEX_CLASS: beamer
#+BEAMER_THEME: Frankfurt
#+BEAMER_INNER_THEME: rounded
```
To export to PDF, press `Alt + x` and type "org-beamer-export-to-pdf".
![latex_beamer_presentation.png][23]
The Latex Beamer presentation, created using Emacs and Org mode
I hope you enjoyed creating this LaTeX and Beamer document using Emacs (note that it's faster to use keyboard shortcuts than a mouse). Emacs Org-mode offers much more than I can cover in this post; you can learn more at [orgmode.org][24].
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/4/how-create-latex-documents-emacs
作者:[Sachin Patil][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://opensource.com/users/psachin
[1]:https://opensource.com/article/17/6/introduction-latex
[2]:https://opensource.com/users/aaroncocker
[3]:https://www.latex-project.org
[4]:http://www.texstudio.org/
[5]:https://opensource.com/users/greg-p
[6]:https://www.gnu.org/software/emacs/
[7]:/file/392261
[8]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/emacs_startup.png?itok=UnT4PgK5 (Emacs startup screen)
[9]:/file/392266
[10]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/insert_template_flow.png?itok=V_c2KipO (template_flow.png)
[11]:https://www.lipsum.com/feed/html
[12]:/file/392271
[13]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/helloworld_file.png?itok=o8IX0TsJ (helloworld_file.png)
[14]:/file/392276
[15]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/org_to_pdf.png?itok=fNnC1Y-L (org_to_pdf.png)
[16]:/file/392281
[17]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/org_and_pdf_file.png?itok=HEhtw-cu (org_and_pdf_file.png)
[18]:/file/392286
[19]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/org_tex_pdf.png?itok=poZZV_tj (org_tex_pdf.png)
[20]:https://github.com
[21]:https://www.sharelatex.com/learn/Beamer
[22]:/file/392291
[23]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/latex_beamer_presentation.png?itok=rsPSeIuM (latex_beamer_presentation.png)
[24]:https://orgmode.org/worg/org-tutorials/org-latex-export.html

View File

@ -0,0 +1,136 @@
Yet Another TUI Graphical Activity Monitor, Written In Go
======
![](https://www.ostechnix.com/wp-content/uploads/2018/04/Gotop-720x340.png)
You already know about “top” command, dont you? Yes, It provides dynamic real-time information about running processes in any Unix-like operating systems. A few developers have built graphical front-ends for top command, so the users can easily find out their systems activity in a graphical window. One of them is **Gotop**. As the name implies, Gotop is a TUI graphical activity monitor, written in **Go** language. It is completely free, open source and inspired by [gtop][1] and [vtop][2] programs.
In this brief guide, we are going to discuss how to install and use Gotop program to monitor a Linux systems activity.
### Installing Gotop
Gotop is written using Go, so we need to install it first. To install Go programming language in Linux, refer the following guide.
After installing Go, download the latest Gotop binary using the following command.
```
$ sh -c "$(curl https://raw.githubusercontent.com/cjbassi/gotop/master/download.sh)"
```
And, then move the downloaded binary to your $PATH, for example **/usr/local/bin/**.
```
$ cp gotop /usr/local/bin
```
Finally, make it executable using command:
```
$ chmod +x /usr/local/bin/gotop
```
If youre using Arch-based systems, Gotop is available in **AUR** , so you can install it using any AUR helper programs.
Using [**Cower**][3]:
```
$ cower -S gotop
```
Using [**Pacaur**][4]:
```
$ pacaur -S gotop
```
Using [**Packer**][5]:
```
$ packer -S gotop
```
Using [**Trizen**][6]:
```
$ trizen -S gotop
```
Using [**Yay**][7]:
```
$ yay -S gotop
```
Using [yaourt][8]:
```
$ yaourt -S gotop
```
### Usage
Gotop usage is easy! All you have to do is to run the following command from the Terminal.
```
$ gotop
```
There you go! You will see the usage of your systems CPU, disk, memory, network, cpu temperature and process list in a simple TUI window.
![][10]
To show only CPU, Mem and Process widgets, use **-m** flag like below.
```
$ gotop -m
```
![][11]
You can sort the process table by using the following keyboard shortcuts.
* **c** CPU
* **m** Mem
* **p** PID
For process navigation, use the following keys.
* **UP/DOWN** arrows or **j/k** keys to go up and down.
* **Ctrl-d** and **Ctrl-u** up and down half a page.
* **Ctrl-f** and **Ctrl-b** up and down a full page.
* **gg** and **G** iump to top and bottom.
Press **< TAB>** to toggle process grouping. To kill the selected process or process group, type **dd**. To select a process, just click on it. To scroll down/up, use the mouse scroll button. To zoom in and zoom out CPU and memory graphs, use **h** and **l**. To display the help menu at anytime, just press **?**.
**Recommended read:**
And, thats all for now. Hope this helps. More good stuffs to come. Stay tuned!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/gotop-yet-another-tui-graphical-activity-monitor-written-in-go/
作者:[SK][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.ostechnix.com/author/sk/
[1]:https://github.com/aksakalli/gtop
[2]:https://github.com/MrRio/vtop
[3]:https://www.ostechnix.com/cower-simple-aur-helper-arch-linux/
[4]:https://www.ostechnix.com/install-pacaur-arch-linux/
[5]:https://www.ostechnix.com/install-packer-arch-linux-2/
[6]:https://www.ostechnix.com/trizen-lightweight-aur-package-manager-arch-based-systems/
[7]:https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/
[8]:https://www.ostechnix.com/install-yaourt-arch-linux/
[9]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
[10]:http://www.ostechnix.com/wp-content/uploads/2018/04/Gotop-1.png
[11]:http://www.ostechnix.com/wp-content/uploads/2018/04/Gotop-2.png

View File

@ -0,0 +1,174 @@
Bootiso Lets You Safely Create Bootable USB Drive
======
![](https://www.ostechnix.com/wp-content/uploads/2018/04/USB-drive-720x340.png)
Howdy newbies! Some of you may often use **dd command** to do various things, like creating a USB drive or cloning disk partitions. Please be mindful that dd command is one of the dangerous and destructive command. If youre Linux beginner, mostly avoid using dd command to do stuffs. If you dont know what you are doing, you may wipe your hard drive in minutes. The dd command literally just takes bytes from **if** and writes them to **of**. It doesnt care what its overwriting, it doesnt care if theres a partition table in the way, or a boot sector, or a home folder, or anything important. It will simply do what it is told to do. Instead, use some user-friendly apps like [**Etcher**][1]. So you will know which device youre going to format before actually start creating bootable USB devices.
Today, I stumbled upon yet another utility named **“Bootiso”** , which is also used to safely create bootable USB drive. It is actually a BASH script, and is brilliant! It has some extra features that helps us to safely create bootable USB devices. If you want to be sure youre targeting a USB device (and not internal drive), or if you want autodetection of a USB device, you can use bootiso. Here is the significant advantages of using this script:
* If there is only one USB drive, Bootiso will automatically select it.
* If there are more than one USB drives present, it lets you to choose one of them from the list.
* Just in case you mistakenly choose one of Internal hard drive, it will exit without doing anything.
* It checks the selected ISO has the correct mime-type. If it has wrong mime-type, it will exit.
* It asserts that the selected item is not a partition and exit if it doesnt.
* It will prompt the user confirmation before erasing and partitioning the USB drive.
* Lists available USB drives.
* Installs syslinux bootloader (optional).
* Free and Open Source.
### Safely Create Bootable USB Drive Using Bootiso
Installing Bootiso is very easy. Download the latest version using command:
```
$ curl -L https://rawgit.com/jsamr/bootiso/latest/bootiso -O
```
Move the downloaded file to your **$PATH** , for example /usr/local/bin/.
```
$ sudo cp bootiso /usr/local/bin/
```
Finally, make it executable:
```
$ sudo chmod +x /usr/local/bin/bootiso
```
Done! Now, it is time to create bootable USB drives. First, let us see how many USB drives are present using command:
```
$ bootiso -l
```
Sample output:
```
Listing USB drives available in your system:
NAME HOTPLUG SIZE STATE TYPE
sdb 1 7.5G running disk
```
As you can see, I have only one USB drive. Let us go ahead and create the USB bootable from an ISO file using command:
```
$ bootiso bionic-desktop-amd64.iso
```
This command will prompt you to enter the sudo password. Type the password and hit ENTER key to install the missing dependencies (if there are any) and then create USB bootable device.
Sample output:
```
[...]
Listing USB drives available in your system:
NAME HOTPLUG SIZE STATE TYPE
sdb 1 7.5G running disk
Autoselecting `sdb' (only USB device candidate)
The selected device `/dev/sdb' is connected through USB.
Created ISO mount point at `/tmp/iso.c5m'
`bootiso' is about to wipe out the content of device `/dev/sdb'.
Are you sure you want to proceed? (y/n)>y
Erasing contents of /dev/sdb...
Creating FAT32 partition on `/dev/sdb1'...
Created USB device mount point at `/tmp/usb.QgV'
Copying files from ISO to USB device with `rsync'
Synchronizing writes on device `/dev/sdb'
`bootiso' took 303 seconds to write ISO to USB device with `rsync' method.
ISO succesfully unmounted.
USB device succesfully unmounted.
USB device succesfully ejected.
You can safely remove it !
```
If the your ISO file has the wrong mime-type, you will see the following error message:
```
Provided file `bionic-desktop-amd64.iso' doesn't seem to be an iso file (wrong mime type: `application/octet-stream').
Exiting bootiso...
```
You can, however, skip the mime-type check using **no-mime-check** option like below.
```
$ bootiso --no-mime-check bionic-desktop-amd64.iso
```
Like I already mentioned, Bootiso will automatically choose the USB drive if there is only one USB drive present in your system. So, we dont need to mention the usb disk path. If you have more than one devices connected, you can explicitly specify the USB device using **-d** flag like below.
```
$ bootiso -d /dev/sdb bionic-desktop-amd64.iso
```
Replace “/dev/sdb” with your own path.
If you dont specify **-d** flag when using more than one USB devices, Bootiso will prompt you to select from available USB drives.
Bootiso will ask the user confirmation before erasing and partitioning the USB devices. To auto-confirm this, use **-y** or **assume-yes** flag.
```
$ bootiso -y bionic-desktop-amd64.iso
```
You can also enable autoselecting USB devices in conjunction with **-y** option as shown below.
```
$ bootiso -y -a bionic-desktop-amd64.iso
```
Or,
```
$ bootiso --assume-yes --autoselect bionic-desktop-amd64.iso
```
Please remember it will work only if you have only one connected USB drive.
By default, Bootiso will create a **FAT 32** partition and then mount and copy the ISO contents using **“rsync”** program to your USB drive. You can also use “dd” instead of “rsync” if you want.
```
$ bootiso --dd -d /dev/sdb bionic-desktop-amd64.iso
```
If you want to increase the odds your USB will be bootable, use **“-b”** or **bootloader”** like below.
```
$ bootiso -b bionic-desktop-amd64.iso
```
The above command will install a bootloader with **syslinux** (safe mode). Please note that it doesnt work if you use “dd” option.
After creating the bootable device, Bootiso will automatically eject the USB drive. If you dont want it to automatically eject it, use **-J** or **no-eject** flag.
```
$ bootiso -J bionic-desktop-amd64.iso
```
Now, the USb device will remain connected. You can unmount it at anytime using “umount” command.
To display help section, run:
```
$ bootiso -h
```
And, thats all for now. Hope this script helps. More good stuffs to come. Stay tuned!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/bootiso-lets-you-safely-create-bootable-usb-drive/
作者:[SK][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.ostechnix.com/author/sk/
[1]:https://www.ostechnix.com/etcher-beauitiful-app-create-bootable-sd-cards-usb-drives/

View File

@ -0,0 +1,156 @@
Top 9 open source ERP systems to consider | Opensource.com
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_orgchart1.png?itok=tukiFj89)
Businesses with more than a handful of employees have a lot to balance including pricing, product planning, accounting and finance, managing payroll, dealing with inventory, and more. Stitching together a set of disparate tools to handle those jobs is a quick, cheap, and dirty way to get things done.
That approach isn't scalable. It's difficult to efficiently move data between the various pieces of such an ad-hoc system. As well, it can be difficult to maintain.
Instead, most growing businesses turn to an [enterprise resource planning][1] (ERP) system.
The big guns in that space are Oracle, SAP, and Microsoft Dynamics. Their offerings are comprehensive, but also expensive. What happens if your business can't afford one of those big implementations or if your needs are simple? You turn to the open source alternatives.
### What to look for in an ERP system
Obviously, you want a system that suits your needs. Depending on those needs, more features doesn't always mean better. However, your needs might change as your business grows, so you'll want to find an ERP system that can expand to meet your new needs. That could mean the system has additional modules or just supports plugins and add-ons.
Most open source ERP systems are web applications. You can download and install them on your server. But if you don't want (or don't have the skills or staff) to maintain a system yourself, then make sure there's a hosted version of the application available.
Finally, you'll want to make sure the application has good documentation and good support—either in the form of paid support or an active user community.
There are a number of flexible, feature-rich, and cost-effective open source ERP systems out there. Here are nine to check out if you're in the market for such a system.
### ADempiere
Like most other open source ERP solutions, [ADempiere][2] is targeted at small and midsized businesses. It's been around awhile—the project was formed in 2006 as a fork from the Compiere ERP software.
Its Italian name means to achieve or satisfy, and its "multidimensional" ERP features aim to help businesses satisfy a wide range of needs. It adds supply chain management (SCM) and customer relationship management (CRM) features to its ERP suite to help manage sales, purchasing, inventory, and accounting processes in one piece of software. Its latest release, v.3.9.0, updated its user interface, point-of-sale, HR, payroll, and other features.
As a multiplatform, Java-based cloud solution, ADempiere is accessible on Linux, Unix, Windows, MacOS, smartphones, and tablets. It is licensed under [GPLv2][3]. If you'd like to learn more, take its [demo][4] for a test run or access its [source code][5] on GitHub.
### Apache OFBiz
[Apache OFBiz][6]'s suite of related business tools is built on a common architecture that enables organizations to customize the ERP to their needs. As a result, it's best suited for midsize or large enterprises that have the internal development resources to adapt and integrate it within their existing IT and business processes.
OFBiz is a mature open source ERP system; its website says it's been a top-level Apache project for a decade. [Modules][7] are available for accounting, manufacturing, HR, inventory management, catalog management, CRM, and e-commerce. You can also try out its e-commerce web store and backend ERP applications on its [demo page][8].
Apache OFBiz's source code can be found in the [project's repository][9]. It is written in Java and licensed under an [Apache 2.0 license][10].
### Dolibarr
[Dolibarr][11] offers end-to-end management for small and midsize businesses—from keeping track of invoices, contracts, inventory, orders, and payments to managing documents and supporting electronic point-of-sale system. It's all wrapped in a fairly clean interface.
If you're wondering what Dolibarr can't do, [here's some documentation about that][12].
In addition to an [online demo][13], Dolibarr also has an [add-ons store][14] where you can buy software that extends its features. You can check out its [source code][15] on GitHub; it's licensed under [GPLv3][16] or any later version.
### ERPNext
[ERPNext][17] is one of those classic open source projects; in fact, it was [featured on Opensource.com][18] way back in 2014. It was designed to scratch a particular itch, in this case replacing a creaky and expensive proprietary ERP implementation.
ERPNext was built for small and midsized businesses. It includes modules for accounting, managing inventory, sales, purchase, and project management. The applications that make up ERPNext are form-driven—you fill information in a set of fields and let the application do the rest. The whole suite is easy to use.
If you're interested, you can request a [demo][19] before taking the plunge and [downloading it][20] or [buying a subscription][21] to the hosted service.
### Metasfresh
[Metasfresh][22]'s name reflects its commitment to keeping its code "fresh." It's released weekly updates since late 2015, when its founders forked the code from the ADempiere project. Like ADempiere, it's an open source ERP based on Java targeted at the small and midsize business market.
While it's a younger project than most of the other software described here, it's attracted some early, positive attention, such as being named a finalist for the Initiative Mittelstand "best of open source" IT innovation award.
Metasfresh is free when self-hosted or for one user via the cloud, or on a monthly subscription fee basis as a cloud-hosted solution for 1-100 users. Its [source code][23] is available under the [GPLv2][24] license at GitHub and its cloud version is licensed under GPLv3.
### Odoo
[Odoo][25] is an integrated suite of applications that includes modules for project management, billing, accounting, inventory management, manufacturing, and purchasing. Those modules can communicate with each other to efficiently and seamlessly exchange information.
While ERP can be complex, Odoo makes it friendlier with a simple, almost spartan interface. The interface is reminiscent of Google Drive, with just the functions you need visible. You can [give Odoo a try][26] before you decide to sign up.
Odoo is a web-based tool. Subscriptions to individual modules will set you back $20 (USD) a month for each one. You can also [download it][27] or grab the [source code][28] from GitHub. It's licensed under [LGPLv3][29].
### Opentaps
[Opentaps][30], one of the few open source ERP solutions designed for larger businesses, packs a lot of power and flexibility. This is no surprise because it's built on top of Apache OFBiz.
You get the expected set of modules that help you manage inventory, manufacturing, financials, and purchasing. You also get an analytics feature that helps you analyze all aspects of your business. You can use that information to better plan into the future. Opentaps also packs a powerful reporting function.
On top of that, you can [buy add-ons and additional modules][31] to enhance Opentaps' capabilities. They include integration with Amazon Marketplace Services and FedEx. Before you [download Opentaps][32], give the [online demo][33] a try. It's licensed under [GPLv3][34].
### WebERP
[WebERP][35] is exactly as it sounds: An ERP system that operates through a web browser. The only other software you need is a PDF reader to view reports.
Specifically, its an accounting and business management solution geared toward wholesale, distribution, and manufacturing businesses. It also integrates with [third-party business software][36], including a point-of-sale system for multi-branch retail management, an e-commerce module, and wiki software for building a business knowledge base. It's written in PHP and aims to be a low-footprint, efficient, fast, and platform-independent system that's easy for general business users.
WebERP is actively being developed and has an active [forum][37], where you can ask questions or learn more about using the application. You can also try a [demo][38] or download the [source code][39] (licensed under [GPLv2][40]) on GitHub.
### xTuple PostBooks
If your manufacturing, distribution, or e-commerce business has outgrown its small business roots and is looking for an ERP to grow with you, you may want to check out [xTuple PostBooks][41]. It's a comprehensive solution built around its core ERP, accounting, and CRM features that adds inventory, distribution, purchasing, and vendor reporting capabilities.
xTuple is available under the Common Public Attribution License ([CPAL][42]), and the project welcomes developers to fork it to create other business software for inventory-based manufacturers. Its web app core is written in JavaScript, and its [source code][43] can be found on GitHub. To see if it's right for you, register for a free [demo][44] on xTuple's website.
There are many other open source ERP options you can choose from—others you might want to check out include [Tryton][45], which is written in Python and uses the PostgreSQL database engine, or the Java-based [Axelor][46], which touts users' ability to create or modify business apps with a drag-and-drop interface. And, if your favorite open source ERP solution isn't on the list, please share it with us in the comments. You might also check out our list of top [supply chain management tools][47].
This article is updated from a [previous version][48] authored by Opensource.com moderator [Scott Nesbitt][49].
--------------------------------------------------------------------------------
via: https://opensource.com/tools/enterprise-resource-planning
作者:[Opensource.com][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://opensource.com
[1]:http://en.wikipedia.org/wiki/Enterprise_resource_planning
[2]:http://www.adempiere.net/welcome
[3]:http://wiki.adempiere.net/License
[4]:http://www.adempiere.net/web/guest/demo
[5]:https://github.com/adempiere/adempiere
[6]:http://ofbiz.apache.org/
[7]:https://ofbiz.apache.org/business-users.html#UsrModules
[8]:http://ofbiz.apache.org/ofbiz-demos.html
[9]:http://ofbiz.apache.org/source-repositories.html
[10]:http://www.apache.org/licenses/LICENSE-2.0
[11]:http://www.dolibarr.org/
[12]:http://wiki.dolibarr.org/index.php/What_Dolibarr_can%27t_do
[13]:http://www.dolibarr.org/onlinedemo
[14]:http://www.dolistore.com/
[15]:https://github.com/Dolibarr/dolibarr
[16]:https://github.com/Dolibarr/dolibarr/blob/develop/COPYING
[17]:https://erpnext.com/
[18]:https://opensource.com/business/14/11/building-open-source-erp
[19]:https://frappe.erpnext.com/request-a-demo
[20]:https://erpnext.com/download
[21]:https://erpnext.com/pricing
[22]:http://metasfresh.com/en/
[23]:https://github.com/metasfresh/metasfresh
[24]:https://github.com/metasfresh/metasfresh/blob/master/LICENSE.md
[25]:https://www.odoo.com/
[26]:https://www.odoo.com/page/start
[27]:https://www.odoo.com/page/download
[28]:https://github.com/odoo
[29]:https://github.com/odoo/odoo/blob/11.0/LICENSE
[30]:http://www.opentaps.org/
[31]:http://shop.opentaps.org/
[32]:http://www.opentaps.org/products/download
[33]:http://www.opentaps.org/products/online-demo
[34]:https://www.gnu.org/licenses/agpl-3.0.html
[35]:http://www.weberp.org/
[36]:http://www.weberp.org/Links.html
[37]:http://www.weberp.org/forum/
[38]:http://www.weberp.org/weberp/
[39]:https://github.com/webERP-team/webERP
[40]:https://github.com/webERP-team/webERP#legal
[41]:https://xtuple.com/
[42]:https://xtuple.com/products/license-options#cpal
[43]:http://xtuple.github.io/
[44]:https://xtuple.com/free-demo
[45]:http://www.tryton.org/
[46]:https://www.axelor.com/
[47]:https://opensource.com/tools/supply-chain-management
[48]:https://opensource.com/article/16/3/top-4-open-source-erp-systems
[49]:https://opensource.com/users/scottnesbitt

View File

@ -0,0 +1,125 @@
Awesome GNOME extensions for developers
======
![](https://fedoramagazine.org/wp-content/uploads/2018/04/gnome-extensions-for-developers-816x345.jpg)
Extensions add immense flexibility to the GNOME 3 desktop environment. They give users the advantage of customizing their desktop while adding ease and efficiency to their workflow. The Fedora Magazine has already covered some great desktop extensions such as [EasyScreenCast][1], [gTile][2], and [OpenWeather][3]. This article continues that coverage by focusing on extensions tailored for developers.
If you need assistance installing GNOME extensions, refer to the article [How to install a GNOME Shell extension][4].
### ![Docker Integration extension icon][5] Docker Integration
![Docker Integration extension status menu][6]
The [Docker Integration][7] extension is a must for developers using Docker for their apps. The status menu provides a list of Docker containers with the option to start, stop, pause and even remove them. The list updates automatically as new containers are added to the system.
After installing this extension, Fedora users may get the message: “Error occurred when fetching containers.” This is because Docker commands require sudo or root permissions by default. To configure your user account to run Docker, refer to the [Docker Installation page on the Fedora Developer Portal][8].
You can find more information on the [extensions website][9].
### ![Jenkins CI Server Indicator icon][10] Jenkins CI Server Indicator
![Jenkins CI Server Indicator extension status menu][11]
The [Jenkins CI Server Indicator][12] extension makes it easy for developers to build their apps on a Jenkins CI Server. It displays a menu with a list of jobs and the state of those jobs. It also includes features such as easy access to the Jenkins web front-end, notifications for completed jobs, and the ability to trigger and filter jobs.
For more information, visit the [developers site][13].
### ![android-tool extension icon][14] android-tool
![android-tool extension status menu][15][android-tool][16] can be a valuable extension for Android developers. Features include capturing bug reports, device screenshots and screen-recording. It can also connect to the Android device via USB or TCP.
This extension does require the adb package. To install adb from the official Fedora repository [run this command][17]:
```
sudo dnf install android-tools
```
You can find more information at [the extension Github site][18].
### ![GnomeHub extension icon][19] GnomeHub
![GnomeHub extension status menu][20][GnomeHub][21] is a great extension for GNOME users using Github for their projects. It displays Github repositories and notifies the user of opened pull requests. In addition, users can add their favorite repositories in the extensions settings.
For more information, refer to [the projects Github page][22].
### ![gistnotes extension icon][23] gistnotes
Quite simply, [gistnotes][24] provides easy access for gist users to create, store and manage notes or code snippets. For more information refer to [the projects website][25].
![gistnotes window][26]
### ![Arduino Control extension icon][27] Arduino Control
The [Arduino Control][28] extension allows users to connect to, and control, their Arduino boards. It also lets users add sliders and switches in the status menu. In addition, the developer includes scripts in the extensions directory to connect to the board via Ethernet or USB.
Most importantly, this extension can be customized to fit your project. An example provided in the README file is the ability to “Control your Room Lights from any Computer on the Network.”
You can read more about the features and setup of this extension on [the projects Github page][29].
### ![Hotel Manager extension icon][30] Hotel Manager
![Hotel Manager extension status menu.][31]
Developers using the Hotel process manager for their web apps should explore the [Hotel Manager][32] extension. It displays a list of web apps added to Hotel, and gives users the ability to start, stop and restart those apps. Furthermore, the computers icon to the right gives quick access to open, or view, that web app. The extension can also start, stop, or restart the Hotel daemon.
As of the publication of this article, Hotel Manager version 4 for GNOME 3.26 does not list the web apps in the extensions drop-down menu. Version 4 also gives errors when installing on Fedora 28 (GNOME 3.28). However, version 3 works with Fedora 27 and Fedora 28.
For more details, see [the projects Github page][33].
### VSCode Search Provider
[VSCode Search Provider][34] is a simple extension that displays Visual Studio Code projects in the GNOME overview search results. For heavy VSCode users, this extension saves time by giving developers quick access to their projects. You can find more information on [the projects Github page][35].
![GNOME Overview search results showing VSCode projects.][36]
Do you have a favourite extension you use for development? Let us know in the comments.
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/awesome-gnome-extensions-developers/
作者:[Shaun Assam][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://fedoramagazine.org/author/sassam/
[1]:https://fedoramagazine.org/screencast-gnome-extension/
[2]:https://fedoramagazine.org/must-have-gnome-extension-gtile/
[3]:https://fedoramagazine.org/weather-updates-openweather-gnome-shell-extension/
[4]:https://fedoramagazine.org/install-gnome-shell-extension/
[5]:https://fedoramagazine.org/wp-content/uploads/2017/08/dockericon.png
[6]:https://fedoramagazine.org/wp-content/uploads/2017/08/docker-extension-menu.png
[7]:https://extensions.gnome.org/extension/1065/docker-status/
[8]:https://developer.fedoraproject.org/tools/docker/docker-installation.html
[9]:https://github.com/gpouilloux/gnome-shell-extension-docker
[10]:https://fedoramagazine.org/wp-content/uploads/2017/08/jenkinsicon.png
[11]:https://fedoramagazine.org/wp-content/uploads/2017/08/jenkins-extension-menu.png
[12]:https://extensions.gnome.org/extension/399/jenkins-ci-server-indicator/
[13]:https://www.philipphoffmann.de/gnome-3-shell-extension-jenkins-ci-server-indicator/
[14]:https://fedoramagazine.org/wp-content/uploads/2017/08/androidtoolicon.png
[15]:https://fedoramagazine.org/wp-content/uploads/2017/08/android-tool-extension-menu.png
[16]:https://extensions.gnome.org/extension/1232/android-tool/
[17]:https://fedoramagazine.org/howto-use-sudo/
[18]:https://github.com/naman14/gnome-android-tool
[19]:https://fedoramagazine.org/wp-content/uploads/2017/08/gnomehubicon.png
[20]:https://fedoramagazine.org/wp-content/uploads/2017/08/gnomehub-extension-menu.png
[21]:https://extensions.gnome.org/extension/1263/gnomehub/
[22]:https://github.com/lagartoflojo/gnomehub
[23]:https://fedoramagazine.org/wp-content/uploads/2017/08/gistnotesicon.png
[24]:https://extensions.gnome.org/extension/917/gistnotes/
[25]:https://github.com/mohan43u/gistnotes
[26]:https://fedoramagazine.org/wp-content/uploads/2018/04/gistnoteswindow.png
[27]:https://fedoramagazine.org/wp-content/uploads/2017/08/arduinoicon.png
[28]:https://extensions.gnome.org/extension/894/arduino-control/
[29]:https://github.com/simonthechipmunk/arduinocontrol
[30]:https://fedoramagazine.org/wp-content/uploads/2017/08/hotelicon.png
[31]:https://fedoramagazine.org/wp-content/uploads/2017/08/hotelmanager-extension-menu.png
[32]:https://extensions.gnome.org/extension/1285/hotel-manager/
[33]:https://github.com/hardpixel/hotel-manager
[34]:https://extensions.gnome.org/extension/1207/vscode-search-provider/
[35]:https://github.com/jomik/vscode-search-provider
[36]:https://fedoramagazine.org/wp-content/uploads/2018/04/vscodesearch.png

View File

@ -0,0 +1,108 @@
Replicate your custom Linux settings with DistroTweaks
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_code_woman.png?itok=vbYz6jjb)
Currently, there are more than 300 different Linux operating system distributions available. Each distro serves a slightly different purpose with slightly different bundles of programs for different communities of users.
Even though there are hundreds of different versions of Linux, it hasn't been very easy for individual customizers to share them with the community. [DistroTweaks][1], a process that allows users to customize and share Linux, is a better option than what's come before.
A DistroTweak is a process that allows anyone to quickly and easily add dozens of customizations and programs to an existing Linux distro with just the click of a button. It replaces the tedious process of making changes and manually (and individually) adding dozens of programs. The term "tweak" is a nod to what computer enthusiasts call a slight modification of an operating system or application. A tweak generally doesn't change the core of the operating system or program; it merely adds to it.
### Why DistroTweaks?
In the past, there were two options for widely sharing a custom distribution. The first was to clone the distribution with a cloning tool after customizing your settings and programs, but cloning is a complex process. Often, folks didn't find out their clone didn't work until they tried to install it and got the black screen of death.
The other option was to make your own distribution. You would fork an existing distribution, delete programs you didn't like, and add the programs you wanted. You also had to create new graphics to replace the ones in the parent distribution, as well as build a website to host the download page and a community forum for answering questions. This is very time-consuming.
DistroTweaks offers a third option for sharing Linux that is more reliable than cloning and less work than starting your own distribution. It leverages the [Aptik][2] tool that simplifies re-installing software after a Linux distro re-installation.
### How DistroTweaks solves problems
I teach courses in writing books and creating complex, interactive websites, and I want my students to have access to the same custom computer system and programs I use. This is an issue because I have made several dozen minor modifications to the Linux Mint operating system, added a couple of dozen programs to the default Mint programs, and made more than 50 modifications to LibreOffice (one of Mint's default programs).
Previously, my students had to follow dozens of steps in my books and websites to get a computer that looked exactly like mine. While this is a good learning exercise that teaches students why I made these modifications, this "learning by doing" process is a long ordeal that may be too intimidating or time-consuming for a lot of students.
To make this faster and easier, I developed a simple process that exactly copies all my custom settings and programs into a special DistroTweaks file. My students can install Linux Mint in the normal way, add the DistroTweaks file, and, in a matter of minutes, have an exact copy of my computer with all my customized Mint settings and programs (including the LibreOffice customizations). Because it doesn't alter Linux Mint itself, the result is highly stable. The DistroTweaks process even works inside a virtual machine, so it can be tested before installing it on a computer. In addition, the process is so easy that anyone can create their own custom DistroTweak and share it with any group.
### How to create a DistroTweak
1. To avoid accidentally sharing your personal settings, start with a completely clean computer.
2. Download and install your favorite Linux distribution (we have only tested DistroTweaks with Ubuntu-based Linux, but Debian-based distros may also work).
3. Create a list of all the tweaks you will make to your distro settings, the programs you will add, and the customizations you will make. For example, we customized LibreOffice Writer menu and added several extensions to it.
4. Complete all the steps on your list of tweaks on your clean computer. Practice installing everything, just to make sure everything works and you are aware of all dependencies ahead of time. Be as organized as possible.
5. Next, use a personal package archive ([PPA][3]) software repository to install the Aptik tool. To install Aptik, open a terminal and enter the following commands:
```
sudo apt-add-repository -y ppa:teejee2008/ppa
sudo apt-get update
sudo apt-get install aptik
```
1. Start Aptik from the Linux menu and enter your password.
2. Create a backup folder in your computer's **Filesystem** folder: First, right-click on the screen and select **Open as root**. Then, right-click again and select **Add a new folder**. Name the folder **Backup**.
3. In Aptik, click **Select** , which opens in the **Filesystem** folder, and click on your new **Backup** folder.
4. Click on **One-click settings** to review your default settings (which you can change if you want). Click OK to close this window.
5. Click on the **Backup** icon to the right of **Installed software**. This will bring up a (long) list of programs that will be backed up by clicking on **Downloaded packages**. You can uncheck any programs you don't want copied to your new installation.
6. It's finally time to use Aptik to copy all your programs and system settings into your new **Backup** folder. Click on the **One-click backup** button. It will take about 10 minutes to copy all your programs, software sources, and settings to your **Backup** folder; when it's finished, you'll see the notification **Backup completed**. Click **Close**.
7. Copy everything in the **Backup** folder to an external USB drive or a cloud storage.
8. Change the name of your backup archive to whatever you want to call your special DistroTweak.
### How to add a DistroTweak to your computer
1. Back up your documents and other files by coping them to an external USB.
2. Use a [live USB][4] containing your favorite Linux distro to reformat your computer and install the operating system. Just plug in the USB live stick, restart your computer, and go through the normal installation process.
3. Remove the live USB stick and install Aptik on your computer by entering the following commands in your terminal:
```
sudo apt-add-repository -y ppa:teejee2008/ppa
sudo apt-get update
sudo apt-get install aptik
```
1. Copy and paste your DistroTweaks folder from your USB or cloud storage to the filesystem folder on your computer with the new distro installed.
2. Point Aptik to your DistroTweaks folder.
3. Enter your admin password, then click on **One-click restore**. Watch as dozens of programs are installed in minutes.
4. Recopy your documents and other files from your USB drive to your computer.
### DistroTweaks limitations
* DistroTweaks has only been tested on Ubuntu-based distributions.
* After installing dozens of programs through DistroTweaks, several may not work correctly (even if they're listed in the menu). If this happens, you will have to uninstall and reinstall them.
* For DistroTweaks to work, the target computer must use the same desktop environment used to create the DistroTweak. For example, a Mint Cinnamon DistroTweak should only be used on a Mint Cinnamon installation.
While DistroTweaks is a new option for existing distributions, it offers even more benefits to people who have wanted to create and share their own custom set of programs but were impeded by the difficulties of starting and maintaining their own distributions. Whether you are a teacher (like me) or a corporate executive of a Fortune 500 company, DistroTweaks makes creating and sharing your own version of Linux a lot easier.
David will be speaking at LinuxFest NW this year. See [program highlights or register][5] to attend.
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/4/distrotweaks
作者:[David Spring][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://opensource.com/users/davidspring
[1]:https://distrotweaks.org/
[2]:https://github.com/teejee2008/aptik
[3]:https://en.wikipedia.org/wiki/Ubuntu_(operating_system)#Package_Archives
[4]:https://en.wikipedia.org/wiki/Live_USB
[5]:https://www.linuxfestnorthwest.org/conferences/lfnw18

View File

@ -0,0 +1,73 @@
3 password managers for the Linux command line
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/password.jpg?itok=ec6z6YgZ)
We all want our passwords to be safe and secure. To do that, many people turn to password management applications like [KeePassX][1] or [Bitwarden][2].
If you spend a lot of time in a terminal window and are looking for a simpler solution, you'll want to check out one of the many password managers for the Linux command line. They're quick, easy to use, and secure.
Let's take a look at three of them.
### Titan
[Titan][3] is a password manager that doubles as a file-encryption tool. I'm not sure how well Titan works at encrypting files; I only looked at it as a password manager. In that capacity, it does a solid job.
![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/titan.png?itok=5QoQ1aY7)
Titan stores your passwords in an encrypted [SQLite database][4], which you create and add a master passphrase to when you first fire up the application. Tell Titan to add a password and it asks for a name to identify it, a username, the password itself, a URL, and a comment about the password.
You can get Titan to generate a password for you, and you can search your database by an entry's name or numeric ID, by the name or comment, or using regular expressions. Viewing a specific password, however, can be a bit clunky. You either have to list all passwords and scroll through them to find the one you want to use, or you can view the password by listing the details of an entry using its numeric ID (if you know it).
### Gopass
[Gopass][5] is billed as "the team password manager." Don't let that put you off. It's also great for personal use.
![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gopass.png?itok=1Uodlute)
Gopass is an update of the venerable Unix and Linux [Pass][6] password manager written in the Go programming language. In true Linux fashion, you can either [compile the source code][7] or [use an installer][8] to get gopass on your computer.
Before you start using gopass, make sure you have [GNU Privacy Guard (GPG)][9] and [Git][10] on your system. The former encrypts and decrypts your password store, and the latter signs commits to a [Git repository][11]. If gopass is for personal use, you still need Git. You just don't need to worry about signing commits. If you're interested, you can learn about those dependencies [in the documentation][12].
When you first start gopass, you need to create a password store and generate a [secret key][13] to secure that store. When you want to add a password (which gopass refers to as a secret), gopass asks you for information such as a URL, a username, and a note about the secret. You can have gopass generate the password for the secret you're adding, or you can enter one yourself.
As you need to, you can edit, view, or delete passwords. You can also view a specific password or copy it to your clipboard to paste it into a login form or window.
### Kpcli
The open source password manager of choice for many people is either [KeePass][14] or [KeePassX][15]. [Kpcli][16] brings the features of KeePass and KeePassX to your nearest terminal window.
![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/kpcli.png?itok=kMmOHTJz)
Kpcli is a keyboard-driven shell that does most of what its graphical cousins can do. That includes opening a password database; adding and editing passwords and groups (which help you organize your passwords); or even renaming or deleting passwords and groups.
When you need to, you can copy a username and password to your clipboard to paste into a login form. To keep that information safe, kpcli also has a command to clear the clipboard. Not bad for a little terminal app.
Do you have a favorite command-line password manager? Why not share it by leaving a comment?
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/4/3-password-managers-linux-command-line
作者:[Scott Nesbitt][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://opensource.com/users/scottnesbitt
[1]:https://www.keepassx.org/
[2]:https://opensource.com/article/18/3/managing-passwords-bitwarden
[3]:https://www.titanpasswordmanager.org/
[4]:https://en.wikipedia.org/wiki/SQLite
[5]:https://www.justwatch.com/gopass/
[6]:https://www.passwordstore.org/
[7]:https://github.com/justwatchcom/gopass
[8]:https://justwatch.com/gopass/#install
[9]:https://www.gnupg.org
[10]:https://git-scm.com/
[11]:https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository
[12]:https://github.com/justwatchcom/gopass/blob/master/docs/setup.md
[13]:http://searchsecurity.techtarget.com/definition/private-key
[14]:https://keepass.info/
[15]:https://www.keepassx.org
[16]:http://kpcli.sourceforge.net/

View File

@ -1,119 +0,0 @@
我的冒险之旅之迁移回 Windows
======
我已经使用 Linux 作为我的主要操作系统大约 10 年了,并且主要使用 Ubuntu。但在最新发布的版本中我决定重新回到我通常不喜欢的操作系统 Windows 10。
![Ubuntu On Windows][1]
我一直是 Linux 的粉丝,我最喜欢的两个发行版是 debian 和 ubuntu。现今作为一个服务器操作系统linux 是完美无暇的,但在桌面上一直存在不同程度的问题。
最近一系列的问题让我意识到,我不需要使用 linux 作为我的桌面操作系统,我仍然是一个粉丝。所以基于我安装 Ubuntu 17.10 的经验,我已经决定回到 windows。
### 什么使我选择了回归
问题是,当 Ubuntu 17.10 出来后,我像往常一样进行全新安装,但遇到了一些非常奇怪的新问题。
* Dell D3100 Dock 不再工作(包括 Work Arounds
* Ubuntu 意外死机(随机)
* 双击桌面上的图标没反应
* 使用 HUD 搜索诸如“调整”之类的程序将尝试安装 META 版本
* GUI 比标准的 GNOME 感觉更糟糕
现在我确实考虑回到使用 Ubuntu 16.04 或另一个发行版本,但是我觉得 Unity 7 是最精致的桌面环境,另外唯一一个优雅且稳定的是 Windows 10。
除此之外,在 Windows 上使用 Linux 也有特定的支持,如:
* 大多数装有商用软件不可用E.G Maya, PhotoShop, Microsoft Office大多数情况下替代品并不相同
* 大多数游戏都没有移植到 Linux 上,包括来自 EA, Rockstar Ect. 等主要工作室的游戏。
* 对于大多数硬件来说,驱动程序是选择 Linux 的第二个考虑因素。‘
在决定使用 Windows 之前,我确实看过其他发行版和操作系统。
与此同时,我看到更多的是“微软热爱 Linux ”的活动,并且了解了 WSL。他们新开发者的聚焦角度对我来说很有意思于是我试了一下。
### 我在 Windows 找到了什么
我使用计算机主要是为了编程我也使用虚拟机git 和 ssh并且大部分工作依赖于 bash。我偶尔也会玩游戏观看 netflix 和一些轻松的办公室工作。
总之,我期待在 Ubuntu 中保留当前的工作流程并将其移植到 Windows 上。我也想利用 Windows 的优点。
* 所有 PC 游戏支持 Windows
* 大多数程序受本地支持
* 微软办公软件
现在,使用 Windows 有很多警告,但是我打算正确对待它,所以我不担心一般的 windows 故障,例如病毒和恶意软件。
### Windows 的子系统 LinuxWindows 上存在 Ubuntu 的 Bash
微软与 Canonical 密切合作将 Ubuntu 带到了 Windows 上。在快速设置和启动程序之后,你将拥有非常熟悉的 bash 界面。
现在我一直在研究这个问题的局限性但是在写这篇文章时我碰到的唯一真正的限制是它从硬件中抽象了出来。例如lsblk 不会显示你有什么分区,因为子系统 Ubuntu 没有提供这些信息。
但是除了访问底层工具之外,我发现这种体验非常熟悉,也很棒。
我在下面的工作流程中使用了它。
* 生成 SSH 密钥对
* 使用 Git 和 Github 来管理我的仓库
* SSH 到几个服务器,包括没有密码的
* 为本地数据库运行 MySQL
* 监视系统资源
* 使用 VIM 配置文件
* 运行 Bash 脚本
* 运行本地 Web 服务器
* 运行 PHP, NodeJS
到目前为止,它已经被证明是非常强大的工具,除了在 Windows 10 UI 中。我的工作流程感觉和我在 Ubuntu 上几乎一样。尽管我的多数工作可以在 WSL 中处理,但我仍然打算让虚拟机进行更深入的工作,这可能超出了 WSL 的范围。
### 没有 Wine
我遇到的另一个主要问题是兼容性问题。现在,我很少使用 WINE译注 wine 是可以使 Linux 上运行 Windows 下的软件)来使用 Windows 软件。尽管通常不是很好,但是有时它是必需的。
### HeidiSQL
我安装的第一个程序之一是 HeidiSQL它是我最喜欢的数据库客户端之一。它在 wine 下工作,但是感觉很可怕,所以我放弃了 MySQL Workbench。让它回到 Windows 中,就像回来了一个可靠的老朋友。
### 游戏平台 / Steam
没有游戏的 Windows 电脑无法想象。我从 steam 的网站上安装了它,并且使用我的 Linux 目录,以及我的 Windows 目录,这个目录是 Linux 目录的 5 倍大,并且包括 GTA V (译注: GTA V 是一款名叫侠盗飞车的游戏) 等 AAA 级配置。这些是我只能在 Ubuntu 中梦想的东西。
现在,我对 SteamOS 有很大的期望,并且一直会持续如此。但是我认为在不久的将来它不会在任何地方的游戏市场中崭露头角。所以如果你想在 PC 上玩游戏,你确实需要 Windows。
还有一点需要注意的是, ny nvidia 显卡的驱动程序有很好的支持,这使得像 TF2 (译注: 这是一款名叫军团要塞2的游戏) 这样的一些 Linux 本机游戏运行的稍好一些。
** Windows 在游戏方面总是优越的,所以这并不令人感到意外。**
### 从 USB 硬盘运行,为什么
我在我的主要 sss 驱动器上运行 Linux但在过去我从 usb 密钥和 usb 硬盘运行(译注:这句话不知道怎么翻译,希望校正者注意。)。我习惯了 Linux 的这种持久性,这让我可以在不丢失主要操作系统的情况下长期尝试多个版本。现在我尝试将 Windows 安装到 USB 连接的硬盘上时,它无法工作并且是无法实现的。所以当我将 Windows HDD 的克隆作为备份时,我很惊讶我可以通过 USB 启动它。
这对我来说已经成为一个方便的选择,因为我打算将我的工作笔记本电脑迁移回 Windows但如果不想冒险那就把它扔在那里吧。
所以我在过去的几天里,我使用 USB 来运行它,除了一些错误的消息外,我没有通过 USB 运行发现它真正的缺点。
这样做的显著问题是:
* 较慢的启动速度
* 恼人的信息:不要拔掉你的 USB
* 无法激活它
**我可能会写一篇关于 USB 驱动器上的 Windows 的文章,这样我们可以有更详细的了解。**
### 那么结论是什么?
我使用 Windows 10 大约两周了,并没有注意到它对我的工作流程有任何的负面影响。尽管过程会有一些小问题,但我需要的所以工具都在手边,并且操作系统一般都在运行。
## 我会留在 Windows吗
虽然现在还为时尚早,但我想在可见的未来我会坚持使用 Windows。
--------------------------------------------------------------------------------
via: [https://www.chris-shaw.com/blog/my-adventure-migrating-back-to-windows](https://www.chris-shaw.com/blog/my-adventure-migrating-back-to-windows)
作者:[Christopher Shaw][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.chris-shaw.com
[1]:https://winaero.com/blog/wp-content/uploads/2016/07/Ubutntu-on-Windows-10-logo-banner.jpg

View File

@ -0,0 +1,105 @@
如何设置 GNOME 显示自定义幻灯片
======
在 GNOME 中, 一个非常酷, 但却鲜为人知的特性是它能够将幻灯片显示为墙纸。你可以从 [GNOME 控制中心][1]的 "背景设置" 面板中选择墙纸幻灯片。在预览的右下角显示一个小时钟标志, 可以将幻灯片的墙纸与静态墙纸区别开来。
一些发行版带有预装的幻灯片壁纸。 例如, Ubuntu 包含了库存的 GNOME 定时壁纸幻灯片, 以及 Ubuntu 壁纸大赛优胜者之一。
如果你想创建自己的自定义幻灯片用作壁纸怎么办? 虽然 GNOME 没有为此提供一个用户界面, 但是在你的主目录中使用一些简单的 XML 文件来创建一个是非常容易的。 幸运的是, GNOME 控制中心的背景选择支持一些常见的目录路径,这样就可以轻松创建幻灯片, 而不必编辑分发所提供的任何内容。
### 开始
使用你最喜欢的文本编辑器在 `$HOME/.local/share/gnome-background-properties/` 创建一个 XML 文件。 虽然文件名不重要, 但目录名称很重要(你可能需要创建目录)。 举个例子, 我创建了带有以下内容的 `/home/ken/.local/share/gnome-background-properties/osdc-wallpapers.xml `
```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd">
<wallpapers>
<wallpaper deleted="false">
<name>Opensource.com Wallpapers</name>
<filename>/home/ken/Pictures/Wallpapers/osdc/osdc.xml</filename>
<options>zoom</options>
</wallpaper>
</wallpapers>
```
上面的 XML 文件需要为每个幻灯片或静态壁纸设计一 `<wallpaper>` 节点, 你需要将它们包含在 GNOME 控制中心的 `背景面板`中。
在这个例子中, 我的 `osdc.xml` 文件看起来是这样的:
```
<?xml version="1.0" ?>
<background>
<static>
<!-- Duration in seconds to display the background -->
<duration>30.0</duration>
<file>/home/ken/Pictures/Wallpapers/osdc/osdc_2.png</file>
</static>
<transition>
<!-- Duration of the transition in seconds, default is 2 seconds -->
<duration>0.5</duration>
<from>/home/ken/Pictures/Wallpapers/osdc/osdc_2.png</from>
<to>/home/ken/Pictures/Wallpapers/osdc/osdc_1.png</to>
</transition>
<static>
<duration>30.0</duration>
<file>/home/ken/Pictures/Wallpapers/osdc/osdc_1.png</file>
</static>
<transition>
<duration>0.5</duration>
<from>/home/ken/Pictures/Wallpapers/osdc/osdc_1.png</from>
<to>/home/ken/Pictures/Wallpapers/osdc/osdc_2.png</to>
</transition>
</background>
```
上面的XML中有几个重要的部分。 XML中的 `<background>` 节点是你的外部节点。 每个背景都支持多个 `<static>``<transition>` 节点。
`<static>` 节点定义要显示的图像以及分别用 `<duration>``<file>` 节点显示它的持续时间。
`<transition>` 节点为每个转换定义`<duration>` `<from>` 图像和 `<to>` 图像。
### 全天更换壁纸
另一个很酷的GNOME功能是基于时间的幻灯片。 你可以定义幻灯片的开始时间GNOME将根据它计算时间。 这对于根据一天中的时间设置不同的壁纸很有用。 例如你可以将开始时间设置为06:00并在12:00之前显示一张墙纸然后在下午和18:00再次更改。
这是通过在XML中定义 `<starttime>` 来完成的,如下所示:
```
<starttime>
<!-- A start time in the past is fine -->
<year>2017</year>
<month>11</month>
<day>21</day>
<hour>6</hour>
<minute>00</minute>
<second>00</second>
</starttime>
```
上述XML文件于2017年11月21日06:00开始动画时长为21,600.00,相当于六个小时。 这段时间将显示你的早晨壁纸直到12:0012:00时它会更改为你的下一张壁纸。 你可以继续以这种方式每隔一段时间更换一次壁纸但确保所有持续时间的总计为86,400秒等于24小时
GNOME将计算开始时间和当前时间之间的增量并显示当前时间的正确墙纸。 例如如果你在16:00选择新壁纸则GNOME将在06:00开始时间之后显示36,000秒的适当壁纸。
有关完整示例请参阅大多数发行版中由gnome-backgrounds包提供的adwaita-timed幻灯片。 它通常位于 `/usr/share/backgrounds/gnome/adwaita-timed.xml` 中。
### 了解更多信息
希望这可以鼓励你深入了解创建自己的幻灯片壁纸。 如果你想下载本文中引用的文件的完整版本,那么你可以在 [GitHub][2] 上找到它们。
如果你对用于生成XML文件的实用程序脚本感兴趣你可以在互联网上搜索gnome- backearth -generator。
--------------------------------------------------------------------------------
via: https://opensource.com/article/17/12/create-your-own-wallpaper-slideshow-gnome
作者:[Ken Vandine][a]
译者:[Auk7F7](https://github.com/Auk7F7)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/kenvandine
[1]:http://manpages.ubuntu.com/manpages/xenial/man1/gnome-control-center.1.html
[2]:https://github.com/kenvandine/misc/tree/master/articles/osdc/gnome/slide-show-backgrounds/osdc

View File

@ -0,0 +1,58 @@
如何将字体添加到 Fedora
===================
![](https://fedoramagazine.org/wp-content/uploads/2017/11/install-fonts-1024x433.jpg)
字体可帮助你通过设计以创意的方式表达你的想法。无论给图片加标题、编写演示文稿还是设计问候语或广告字体都可以将你的想法提升到更高水平。很容易仅仅为了它们的审美品质而爱上它们。幸运的是Fedora 使安装变得简单。以下是如何做的。
### 全系统安装
如果你在系统范围内安装字体,那么它可以让所有用户使用。此方式的最佳方法是使用官方软件库中的 RPM 软件包。
开始前打开 Fedora Workstation 中的 _Software_ 工具,或者其他使用官方仓库的工具。选择横栏中选择 _Add-ons_ 类别。接着在 add-on 类别中选择 _Fonts_。你会看到类似于下面截图中的可用字体:
[![](https://fedoramagazine.org/wp-content/uploads/2017/11/Software-fonts-1024x768.png)][1]
当你选择一种字体时,会出现一些细节。根据几种情况,你可能能够预览字体的一些示例文本。点击 _Install_ 按钮将其添加到你的系统。根据系统速度和网络带宽,完成此过程可能需要一些时间。
你还可以在字体细节中通过 _Remove_ 按钮删除前面带有勾的已经安装的字体。
### 个人安装
如果你以兼容格式_.ttf_、 _otf_ 、_.ttc_、_.pfa_ 、_.pfb_ 或者 . _pcf_ 下载了字体,则此方法效果更好。这些字体扩展名不应通过将它们放入系统文件夹来安装在系统范围内。这种类型的非打包字体不能自动更新。他们也可能会在稍后干扰一些软件操作。安装这些字体的最佳方法是在你自己的个人数据目录中。
打开 Fedora Workstation 中的 _Files_ 应用或你选择的类似文件管理器应用。如果你使用 _Files_,那么可能需要使用 _Ctrl+H_ 组合键来显示隐藏的文件和文件夹。查找 _.fonts_ 文件夹并将其打开。如果你没有 _.fonts_ 文件夹,请创建它。 (记住最前面的点并全部使用小写。)
将已下载的字体文件复制到 _.fonts_ 文件夹中。此时你可以关闭文件管理器。打开一个终端并输入以下命令:
```
fc-cache
```
这将重建字体缓存,帮助 Fedora 可以找到并引用它。你可能还需要重新启动需要使用新字体的应用程序,例如 Inkscape 或 LibreOffice。你重新启动后新的字体应该就可以使用了。
* * *
照片由 [Raphael Schaller][2] 发布在 [Unsplash][3] 中。
--------------------------------------------------------------------------------
作者简介:
Paul W. Frields
Paul W. Frields 自 1997 年以来一直是 Linux 用户和爱好者,并于 2003 年 Fedora 发布不久后加入项目。他是 Fedora 项目委员会的创始成员之一,并从事文档、网站发布、倡导、工具链开发和维护软件工作。他于 2008 年 2 月至 2010 年 7 月在红帽担任 Fedora 项目负责人,现任红帽公司工程部经理。他目前和他的妻子和两个孩子一起住在弗吉尼亚州。
-----------------------------
via: https://fedoramagazine.org/add-fonts-fedora/
作者:[ Paul W. Frields ][a]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://fedoramagazine.org/author/pfrields/
[1]:https://fedoramagazine.org/wp-content/uploads/2017/11/Software-fonts.png
[2]:https://unsplash.com/photos/GkinCd2enIY?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
[3]:https://unsplash.com/search/photos/fonts?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText

View File

@ -0,0 +1,133 @@
通过扫描二维码将文件从计算机传输到移动设备
======
![](https://www.ostechnix.com/wp-content/uploads/2018/03/qr-filetransfer-720x340.png)
将文件从计算机传输到智能手机并不是什么大问题。你可以使用 USB 线将手机挂载到系统上,然后从文件管理器传输文件。此外,某些第三方应用程序(例如 [**KDE Connect**][1] 和 [**AirDroid**] [2])可帮助你轻松管理和传输系统中的文件至 Android 设备。今天,我偶然发现了一个名为 **“Qr-filetransfer”** 的超酷工具。它允许你通过扫描二维码通过 WiFi 将文件从计算机传输到移动设备而无须离开终端。是的,你没有看错! qr-filetransfer 是一个使用 Go 语言编写的免费的开源命令行工具。在这个简短的教程中,我们将学习如何使用 qr-transfer 将文件从 Linux 传输到任何移动设备。
### 安装 Qr-filetransfer
首先,在你的系统上安装 Go 语言。
在 Arch Linux 及其衍生版上:
```
$ sudo pacman -S go
```
在基于 RPM 的系统(如 RHEL、CentOS、Fedora上运行
```
$ sudo yum install golang
```
或者:
```
$ sudo dnf install golang
```
在基于 DEB 的系统上,例如 Debian、Ubuntu、Linux Mint你可以使用命令安装它
```
$ sudo apt-get install golang
```
在 SUSE/openSUSE 上:
```
$ sudo zypper install golang
```
安装 Go 语言后,运行以下命令下载 qr-filetransfer 应用。
```
$ go get github.com/claudiodangelis/qr-filetransfer
```
上述命令将在当前工作目录下的一个名为 **“go”** 的目录中下载 qr-filetrnasfer GitHub 仓库的内容。
将 qt-filetransfer 的二进制文件复制到 PATH 中,例如 /usr/local/bin/。
```
$ sudo cp go/bin/qr-filetransfer /usr/local/bin/
```
最后,如下使其可执行:
```
$ sudo chmod +x /usr/local/bin/qr-filetransfer
```
### 通过扫描二维码将文件从计算机传输到移动设备
确保你的智能手机已连接到与计算机相同的 WiFi 网络。
然后,使用要传输的文件的完整路径启动 qt-filetransfer。
比如,我要传输一个 mp3 文件。
```
$ qr-filetransfer Chill\ Study\ Beats.mp3
```
首次启动时qr-filetransfer 会要求你选择使用的网络接口,如下所示。
```
Choose the network interface to use (type the number):
[0] enp5s0
[1] wlp9s0
```
我打算使用 **wlp9s0** 接口传输文件,因此我输入 “1”。qr-filetransfer 会记住这个选择,除非你通过 **-force** 参数或删除程序存储在当前用户的家目录中的 **.qr-filetransfer.json** 文件,否则永远不会再提示你。
然后,你将看到二维码,如下图所示。
![][4]
打开二维码应用(如果它尚未安装,请从 Play 商店安装任何一个二维码读取程序)并扫描终端中显示的二维码。
读取二维码后,系统会询问你是要复制链接还是打开链接。你可以复制链接并手动将其粘贴到移动网络浏览器上,或者选择“打开链接”以在移动浏览器中自动打开它。
![][5]
共享链接打开后,该文件将下载到智能手机中。
![][6]
如果文件太大,请压缩文件,然后传输它
```
$ qr-filetransfer -zip /path/to/file.txt
```
要传输整个目录,请运行:
```
$ qr-filetransfer /path/to/directory
```
请注意,目录在传输之前会被压缩。
qr-filetransfer 只能将系统中的内容传输到移动设备,反之不能。这个项目非常新,所以会有 bug。如果你遇到了任何 bug请在本指南最后给出的 GitHub 页面上报告。
干杯!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/transfer-files-from-computer-to-mobile-devices-by-scanning-qr-codes/
作者:[SK][a]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
选题:[lujun9972](https://github.com/lujun9972)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.ostechnix.com/author/sk/
[1]:https://www.ostechnix.com/kde-connect-access-files-notifications-android-devices/
[2]:https://www.ostechnix.com/airdroid-share-files-and-folders-between-linux-and-android/
[4]:http://www.ostechnix.com/wp-content/uploads/2018/03/qr-filetransfer-5.png
[5]:http://www.ostechnix.com/wp-content/uploads/2018/03/qr-filetransfer-6-4.png
[6]:http://www.ostechnix.com/wp-content/uploads/2018/03/qr-filetransfer-4.png

View File

@ -0,0 +1,81 @@
使用 syslog-ng 可靠地记录物联网事件
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openwires_fromRHT_520_0612LL.png?itok=PqZi55Ab)
现在,物联网设备和嵌入式系统越来越多。对于许多连接到因特网或者一个网络的设备来说,记录事件很有必要,因为你需要知道这些设备都做了些什么事情,这样你才能够解决可能出现的问题。
可以考虑去使用的一个监视工具是开源的 [syslog-ng][1] 应用程序它是一个强化的、致力于可移植的、中心化的日志收集守护程序。它可以从许多不同种类的源、进程来收集日志并且可以对这些日志进行过滤、存储、或者路由以便于做进一步的分析。syslog-ng 的大多数代码是用高效率的、高可移植的 C 代码写成的。它能够适用于各种场景,无论你是将它运行在一个处理能力很弱的设备上做一些简单的事情,还是运行在数据中心从成千上万的机器中收集日志的强大应用,它都能够胜任。
你可能注意到在这个段落中,我使用了大量的溢美词汇。为了让你更清晰地了解它,我们来复习一下,但这将花费更多的时间,也了解的更深入一些。
### 日志
首先解释一下日志。日志是记录一台计算机上事件的东西。在一个典型的 Linux 机器上,你可以在 `/var/log` 目录中找到这些信息。例如,如果你通过 SSH 登陆到机器中,你将可以在其中一个日志文件中找到类似于如下内容的信息:
`Jan 14 11:38:48 ``linux``-0jbu sshd[7716]: Accepted ``publickey`` for root from 127.0.0.1 port 48806 ssh2`
它的内容可能是关于你的 CPU 过热,通过 HTTP 下载了一个文档,或者你的应用程序认为重要的任何东西。
### syslog-ng
正如我在上面所写的那样syslog-ng 应用程序是一个强化的、致力于可移植性、和中心化的日志收集守护程序。守护程序的意思是syslog-ng 是一个持续运行在后台的应用程序,用于收集日志信息。
虽然现在大多数应用程序的 Linux 测试是限制在 x86_64 的机器上但是syslog-ng 也可以运行在大多数 BSD 和商业 UNIX 变种版本上的。从嵌入式/物联网的角度来看,这种能够运行在不同的 CPU 架构(包括 32 位和 64 位的 ARM、PowerPC、MIPS 等等)的能力甚至更为重要。(有时候,我通过阅读关于 syslog-ng 如何使用它们来学习新架构)
为什么中心化的日志收集如此重要?其中一个很重要的原因是易于使用,因为它放在一个地方,不用到成百上千的机器上挨个去检查它们的日志。另一个原因是可用性 —— 如果一个设备不论是什么原因导致了它不可用,你可以检查这个设备的日志信息。第三个原因是安全性;当你的设备被黑,检查设备日志可以发现攻击的踪迹。
### syslog-ng 的四种用法
Syslog-ng 有四种主要的用法:收集、处理、过滤、和保存日志信息。
**收集信息:** syslog-ng 能够从各种各样的 [特定平台源][2] 上收集信息,比如 `/dev/log``journal`,或者 `sun-streams`。作为一个中心化的日志收集器,传统的(`rfc3164`)和最新的(`rfc5424`)系统日志协议、以及它们 基于 UDP、TCP、和加密连接的各种变种它都是支持的。你也可以从管道、套接字、文件、甚至应用程序输出来收集日志信息或者各种文本数据
**处理日志信息:** 它的处理能力几乎是无限的。你可以用它内置的解析器来分类、规范、以及结构化日志信息。如果它没有为你提供在你的应用场景中所需要的解析器,你甚至可以用 Python 来自己写一个解析器。你也可以使用地理数据来丰富信息,或者基于信息内容来附加一些字段。日志信息可以按处理它的应用程序所要求的格式进行重新格式化。你也可以重写日志信息 —— 当然了,你不能篡改日志内容 —— 比如在某些情况下,需要满足匿名要求的信息。
**过滤日志:** 过滤日志的用法主要有两种:丢弃不需要保存的日志信息 —— 像调试级别的信息;和路由日志信息—— 确保正确的日志到达正确的目的地。后一种用法的一个例子是转发所有的认证相关的信息到一个安全信息与事件管理系统SIEM
**保存信息:** 传统的做法是,将文件保存在本地或者发送到中心化日志服务器;不论是哪种方式,它们都被发送到一个[平面文件][3]。经过这些年的改进syslog-ng 已经开始支持 SQL 数据库,并且在过去的几年里,大数据目的地,包括 HDFS、Kafka、MongoDB、和 Elasticsearch都被加入到 syslog-ng 的支持中。
### 消息格式
当在你的 `/var/log` 目录中查看消息时,你将看到(如上面的 SSH 信息)大量的消息都是如下格式的内容:
`date + host name + application name + an almost complete English sentence`
在这里的每个应用程序事件都是用不同的语法描述的,基于这些数据去创建一个报告是个痛苦的任务。
解决这种混乱信息的一个方案是使用结构化日志。在这种情况下,事件被表示为键-值对,而不是随意的日志信息。比如,一个 SSH 日志能够按应用程序名字、源 IP 地址、用户名、认证方法等等来描述。
你可以从一开始就对你的日志信息按合适的格式进行结构化处理。当处理传统的日志信息时,你可以在 syslog-ng 中使用不同的解析器,转换非结构化(和部分结构化)的信息为键-值对格式。一旦你的日志信息表示为键-值对,那么,报告、报警、以及简单查找信息将变得很容易。
### 物联网日志
我们从一个棘手的问题开始:哪个版本的 syslog-ng 最流行?在你回答之前,想想如下这些事实:这个项目启动于 20 年以前Red Hat 企业版 Linux EPEL 已经有了 3.5 版,并且当前版本是 3.14。当我在我的演讲中问到这个问题时,观众通常回答他们喜欢的 Linux 发行版。你们绝对想不到的是,正确答案竟然是 1.6 版最流行,这个版本已经有 15 年的历史的。这什么这个版本是最为流行的,因为它是包含在亚马逊 Kindle 阅读器中的版本,它是电子书阅读器,因为它运行在全球范围内超过 1 亿台的设备上。另外一个在消费类设备上运行 syslog-ng 的例子是 BMW i3 电动汽车。
Kindle 使用 syslog-ng 去收集关于用户在这台设备上都做了些什么事情的所有可能的信息。在 BMW 电动汽车上syslog-ng 所做的事情更复杂,基于内容过滤日志信息,并且在大多数情况下,只记录最重要的日志。
使用 syslog-ng 的其它类别设备还有网络和存储。一些比较知名的例子有Turris Omnia 开源 Linux 路由器和群晖 NAS 设备。在大多数案例中syslog-ng 是在设备上作为一个日志客户端来运行,但是在有些案例中,它运行为一个有富 Web 界面的中心日志服务器。
你还可以在一些行业服务中找到 syslog-ng 的身影。它运行在来自美国国家仪器有限公司NI的实时 Linux 设备上,执行测量和自动化任务。它也被用于从定制开发的应用程序中收集日志。从命令行就可以做配置,但是一个漂亮的 GUI 可用于浏览日志。
最后这里还有大量的项目比如汽车和飞机syslog-ng 在它们上面既可以运行为客户端也可以运行为服务端。在这种使用案例中syslog-ng 一般用来收集所有的日志和测量数据,然后发送它们到处理这些日志的中心化服务器集群上,然后保存它们到支持大数据的目的地,以备进一步分析。
### 对物联网的整体益处
在物联网环境中使用 syslog-ng 有几个好处。第一,它的分发性能很高,并且是一个可靠的日志收集器。第二,它的架构也很简单,因此,系统、应用程序日志、以及测量数据可以被一起收集。第三,它使数据易于使用,因为,数据可以被解析和表示为易于使用的格式。最后,通过 syslog-ng 的高效路由和过滤功能,可以显著降低处理程序的负载水平。
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/3/logging-iot-events-syslog-ng
作者:[Peter Czanik][a]
译者:[译者ID](https://github.com/译者ID)
校对:[qhwdw](https://github.com/qhwdw)
选题:[lujun9972](https://github.com/lujun9972)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/czanik
[1]:https://syslog-ng.com/open-source-log-management
[2]:https://syslog-ng.com/documents/html/syslog-ng-ose-latest-guides/en/syslog-ng-ose-guide-admin/html/sources.html
[3]:https://en.wikipedia.org/wiki/Flat_file_database

View File

@ -0,0 +1,104 @@
使用树莓派构建一个婴儿监视器
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/baby-chick-egg.png?itok=RcFfqdbA)
香港很湿热,即便是晚上,许多人为了更舒适,在家里也使用空调。当我的大儿子还是一个小婴儿的时候,他卧室的空调还是需要手动控制的,没有温度自动调节的功能。它的控制器只有开或者关,让空调整个晚上持续运行会导致房间过冷,并且也浪费能源和钱。
我决定使用一个基于 [树莓派][2] 的 [物联网][1] 解决方案去修复这个问题。后来我进一步为它添加了一个[婴儿监视器][3]插件。在这篇文章中,我将解释我是如何做的,它的代码在 [我的 GitHub][4] 页面上。
### 设计空调控制器
解决我的问题的第一个部分是使用了一个 Orvibo S20 [可通过 WiFi 连接的智能插头][5]和智能手机应用程序。虽然这样可以让我通过远程来控制空调,但是它还是手动处理的,而我希望尝试让它自动化。我在 [Instructables][6] 上找到了一个满足我的需求的项目:他使用树莓派从一个 [AM2302 传感器][7] 上测量附近的温度和湿度,并将它们记录到一个 MySQL 数据库中。
使用圧接头将温度/湿度传感器连接到树莓派的相应 GPIO 针脚上。幸运的是AM2302 传感器有一个用于读取的 [开源软件][8],并且同时提供了 [Python][9] 示例。
与我的项目放在一起的用于 [AM2302 传感器][10] 接口的软件已经更新了,并且我使用的原始代码现在已经被认为是过时的而停止维护了。这个代码是由一个小的二进制组成,用于连接到传感器以及解释阅读和返回正确值的 Python 脚本。
![Raspberry Pi, sensor, and Python code][12]
树莓派、传感器、以及用于构建温度/湿度监视器的 Python 代码。
将传感器连接到树莓派,这些 Python 代码能够正确地返回温度和湿度读数。将 Python 连接到 MySQL 数据库很简单,并且也有大量的使用 `python-``mysql` 绑定的代码示例。因为我需要持续地监视温度和湿度,所以我写软件来实现这些。
事实上,最终我用了两个解决方案,一是作为一个持续运行的进程,周期性(一般是间隔一分钟)地获取传感器数据,另一种是让 Python 脚本运行一次然后退出。我决定使用第二种方法,并使用 cron 去每分钟调用一次这个脚本。之所以选择这种方法的主要原因是,(通过循环实现的)持续的脚本偶尔会不返回读数,这将导致尝试读取传感器的进程出现聚集,最终可能会导致系统挂起而缺乏可用资源。
我也找到了可以用程序来控制我的智能插头的一个 [Perl 脚本][13]。它是解决这种问题所需的一部分,因此当某些温度/湿度达到触发条件,将触发这个 Perl 脚本。在做了一些测试之后,我决定去设计一个独立的 `checking` 脚本,从 MySQL 去拉取最新的数据,然后根据返回的值去设置智能开关为开或关。将插头控制逻辑与传感器读取脚本分开,意味着它们是各自独立运行的,就算是传感器读取脚本写的有问题也没事。
配置一个打开/关闭空调的温度值是很有意义的,因此,我将这些值转移到控制脚本读取的配置文件中。我也发现,虽然传感器的值一般都很准确,但是,偶尔也会出现返回不正确读数的情况。这个传感器脚本被修改为不向 MySQL 数据库中写入与前值差异非常大的值。同样也在配置文件中写入了连续读取的温度/湿度之间允许的最大差异值,如果读取的值处于这些限制值以外,这些值写不会提交到数据库中。
虽然,做这个自动调节器似乎花费了很多努力,但是,这意味着,记录到 MySQL 数据库的数据是有效的、可用于进一步去分析识别用户使用模式的有用数据。可以用多种图形方式去展示来自 MySQL 数据库中的数据,而我决定使用 [Google Chart][14] 在一个 Web 页面上显示数据。
![Temperature and humidity chart][16]
过去六小时内测量到的温度和湿度
### 添加一个婴儿监视摄像头
树莓派开放的性能意味着我可以不断地为它增加功能 —— 并且我有大量的未使用的可用 GPIO 针脚。我的下一个创意是去添加一个摄像头模块,将它放在孩子的卧室中,配置它去监视婴儿。
我需要一个能够在黑暗环境中工作的摄像头,而 [Pi Noir][17] 摄像头模块是非常适合这种条件的。Pi Noir 除了没有红外过滤之外,同样也是树莓派常用的摄像头模块。这意味着它在白天时的图像可能有点偏紫色,但是它可以在黑暗中借助红外灯来显示图像。
现在我需要一个红外光源。由于树莓派非常流行,并且进入门槛很低,因此它有大量的外围配件和插件。也有适合它的各种红外光源,我注意到的其中一个是 [Bright Pi][18]。它可以从树莓派上供电,并且它很适合为树莓派的摄像头模块提供红外光和普通光。它唯一的缺点是太考验我的焊接技能了。
我的焊接技能还是不错的,但是可能花费的时间比其他人更长。我成功地连接了外壳上所有的红外 LEDs并将它们连接到树莓派的 GPIO 针脚上。这意味着树莓派能够编程控制红外 LED 是否点亮,以及它的亮度。
通过一个 Web 流去公开捕获的视频也很有意义,因为这样我就可以从 Web 页面上查看温度和湿度的读数图表。进一步研究之后,我选择了一个使用 M-JPEG 捕获器的 [流软件][19]。通过 Web 页面公开 JPG 源,我可以在我的智能手机上去连接摄像头查看程序,去查看摄像头的输出。
### 做最后的修饰
没有哪个树莓派项目都已经完成了还没有为它选择一个合适的外壳,并且它有各种零件。在大量搜索和比较之后,有了一个明确的 [赢家][20]SmartPi 的乐高积木式外壳。乐高的兼容性可以让我去安装温度/湿度传感器和摄像头。下面是最终的成果图:
![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pibabymonitor_case.png?itok=_ofyN73a)
在这以后,我对我的这个作品作了一些改变和更新:
* 我将它从树莓派 2 Model B 升级到了 [树莓派 3][21],这意味着我可以使用 USB WiFi 模块。
* 我用一个 [TP-Link HS110][22] 智能插头替换了 Orvibo S20。
* 我也将树莓派插到了一个智能插头上,这样我就可以远程重启/重置它了。
* 我从树莓派上将 MySQL 数据库移走了,它现在运行在一个 NAS 设备上的容器中。
* 我增加了一个非常 [灵活的三角夹][23],这样我就可以调整到最佳角度。
* 我重新编译了 USB WiFi 模块,禁用了板载 LED 指示灯,这就是升级到树莓派 3 的其中一个好处。
* 我因此为我的第二个孩子设计了另外一个监视器。
* 因为没有时间去折腾,我为我的第三个孩子购买了夜用摄像头。
想学习更多的东西吗?所有的代码都在 [我的 GitHub][4] 页面上。
想分享你的树莓派项目吗?[将你的故事和创意发送给我们][24]。
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/3/build-baby-monitor-raspberry-pi
作者:[Jonathan Ervine][a]
译者:[qhwdw](https://github.com/qhwdw)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/jervine
[1]:https://opensource.com/tags/internet-things
[2]:https://opensource.com/tags/raspberry-pi
[3]:https://opensource.com/article/17/9/gonimo
[4]:https://github.com/jervine/rpi-temp-humid-monitor
[5]:https://www.amazon.co.uk/marsboy-S20-Automation-Control-Smartphone/dp/B01LXKPUDK/ref=sr_1_1/258-6082934-2585109?ie=UTF8&amp;qid=1520578769&amp;sr=8-1&amp;keywords=orvibo+s20
[6]:http://www.instructables.com/id/Raspberry-Pi-Temperature-Humidity-Network-Monitor/
[7]:https://www.adafruit.com/product/393
[8]:https://github.com/adafruit/Adafruit_Python_DHT
[9]:https://opensource.com/tags/python
[10]:https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/tree/legacy/Adafruit_DHT_Driver_Python
[11]:/file/390916
[12]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pibabymonitor_materials.png?itok=2w03CdKM "Raspberry Pi, sensor, and Python code"
[13]:https://github.com/franc-carter/bauhn-wifi
[14]:https://developers.google.com/chart/
[15]:/file/390876
[16]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pibabymonitor_temp-humidity.png?itok=2jqtQU0x "Temperature and humidity chart"
[17]:https://www.raspberrypi.org/products/pi-noir-camera-v2/
[18]:https://www.pi-supply.com/product/bright-pi-bright-white-ir-camera-light-raspberry-pi/
[19]:https://elinux.org/RPi-Cam-Web-Interface
[20]:https://smarticase.com/collections/all/products/smartipi-kit-3
[21]:https://opensource.com/article/18/3/raspberry-pi-3b-model-news
[22]:https://www.tp-link.com/uk/products/details/cat-5258_HS110.html
[23]:https://www.amazon.com/Flexpod-Flexible-Tripod-Discontinued-Manufacturer/dp/B000JC8WYA
[24]:http://opensource.com/story

View File

@ -1,73 +0,0 @@
Opensource.com: 高级 SSH 用法表
===========================
所有人都知道 SSH 是一种远程登录工具,然而它也有许多其他用途。
```
创建一个 SOCKS 代理来浏览网页(也就是翻墙啦):
ssh -D <port> <remote_host>
设置 localhost:<port> 作为你浏览器的代理
连接一个躲在防御服务器背后的 Windows RDP 主机:
ssh -L <port>:<target_host>:3389 <bastion_server>
让你的 RDP 客户端连接到 localhost:<port>
在不使用 VNC 端口的情况下,连接远程 VNC 主机:
ssh -L 5901:localhost:5901 <remote_host>
让你的 VNC 客户端连接到 localhost:5901
按照这个思路,你可以映射任意端口: LDAP (389), 631 (CUPS), 8080 (alternate HTTP),等等。
产生一个新的 SSH 密钥对:
ssh-keygen
更新密钥对的密码:
ssh-keygen -p
把公钥复制到远程主机上:
ssh-copy-id -i <identity file> <remote_host>
SSH 有一堆命令行选项,但是如果有一些是你经常使用的,你可以为他们在 SSH 配置文件 (${HOME}/.ssh/config) 里创建一个入口。比如:
host myhouse
User itsme
   HostName house.example.com
那么你就可以输入 'ssh myhouse' 来代替 'ssh itsme@house.example.com'.
```
以下是常用的命令行选项和他们的配置文件写法。一些是常用的简化写法。请查看 ssh(1) 和 ssh_config(5) 的手册页来获取详尽信息。
|命令行|配置文件|描述
|:--|:--|:--|
|-l \<login name\>| User \<login name\>|远程主机的登录用户名。|
|-i \<identity file\> |IdentityFile \<identity file\> |指定要使用的鉴权文件SSH 密码对)。 |
|-p \<remote port\>| Port \<remote port\>|远程 SSH 守护进程监听的端口号。 (默认为 22) |
|-C|Compression \<yes\|no\>|压缩往来信息。 (默认为 no) |
|-D \<port\>|DynamicForward \<port\>|把本地端口的报文转发到远程主机。 |
|-X|ForwardX11 \<yes\|no\>|把 X11 的图像数据转发到远程主机的端口. (默认为 no) |
|-A|ForwardAgent \<yes\|no\>|把授权代理的报文转发给远程主机。如果你使用第三方主机登录,这个功能将很有用。 (默认为 no) |
|-4 (use IPv4 only) -6 (use IPv6 only)|AddressFamily \<any\|inet4\|inet6\> |指定仅使用 IPv4 或者 IPv6. |
|-L \<local port\>:\<target host\>:\<target port\> |LocalForward \<local port\>:\<target host\>:\<target port\> |把本地主机指定端口的报文转发到远程主机的某个端口。|
opensource.com
Twitter @opensourceway | facebook.com/opensourceway | IRC: #opensource.com on Freenode
--------------------------------------------------------------------------------
作者简介:
Ben Cotton是业余的气象学家和职业的高性能计算工程师。Ben 是微软 Azure 的产品营销经理,专注于高性能计算。他是一个 Fedora 用户和贡献者,共同创立了一个当地的开放源码群,并且是开源促进会的成员和保护自由软件的支持者。通过以下方式联系他 Twitter (@FunnelFiasco) 或者 FunnelFiasco.com.
-------------
via: https://opensource.com/sites/default/files/gated-content/cheat_sheet_ssh_v03.pdf
作者:[ BEN COTTON ][a]
译者:[kennethXia](https://github.com/kennethXia)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/bcotton
[1]:https://web.kamihq.com/web/upgrade.html