mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
commit
39f9fb1400
158
published/20180206 Power(Shell) to the people.md
Normal file
158
published/20180206 Power(Shell) to the people.md
Normal file
@ -0,0 +1,158 @@
|
||||
给大家安利一下 PowerShell
|
||||
======
|
||||
|
||||
> 代码更简洁、脚本更清晰、跨平台一致性等好处是让 Linux 和 OS X 用户喜爱 PowerShell 的原因。
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_lightbulbs.png?itok=pwp22hTw)
|
||||
|
||||
今年(2018)早些时候,[Powershell Core][1] 以 [MIT][3] 开源协议发布了[正式可用版(GA)][2]。PowerShell 算不上是新技术。自 2006 年为 Windows 发布了第一版 PowerShell 以来,PowerShell 的创建者在[结合了][4] Unⅸ shell 的强大和灵活的同时也在弥补他们所意识到的缺点,特别是从组合命令中获取值时所要进行的文本操作。
|
||||
|
||||
在发布了 5 个主要版本之后,PowerShell 已经可以在所有主流操作系统上(包括 OS X 和 Linux)本地运行同样创新的 shell 和命令行环境。一些人(应该说是大多数人)可能依旧在嘲弄这位诞生于 Windows 的闯入者的大胆和冒失:为那些远古以来(从千禧年开始算不算?)便存在着强大的 shell 环境的平台引荐自己。在本帖中,我希望可以将 PowerShell 的优势介绍给大家,甚至是那些经验老道的用户。
|
||||
|
||||
### 跨平台一致性
|
||||
|
||||
如果你计划将脚本从一个执行环境迁移到另一个平台时,你需要确保只使用了那些在两个平台下都起作用的命令和语法。比如在 GNU 系统中,你可以通过以下方式获取昨天的日期:
|
||||
|
||||
```
|
||||
date --date="1 day ago"
|
||||
```
|
||||
|
||||
在 BSD 系统中(比如 OS X),上述语法将没办法工作,因为 BSD 的 date 工具需要以下语法:
|
||||
|
||||
```
|
||||
date -v -1d
|
||||
```
|
||||
|
||||
因为 PowerShell 具有宽松的许可证,并且在所有的平台都有构建,所以你可以把 PowerShell 和你的应用一起打包。因此,当你的脚本运行在目标系统中时,它们会运行在一样的 shell 环境中,使用与你的测试环境中同样的命令实现。
|
||||
|
||||
### 对象和结构化数据
|
||||
|
||||
*nix 命令和工具依赖于你使用和操控非结构化数据的能力。对于那些长期活在 `sed`、 `grep` 和 `awk` 环境下的人们来说,这可能是小菜一碟,但现在有更好的选择。
|
||||
|
||||
让我们使用 PowerShell 重写那个获取昨天日期的实例。为了获取当前日期,使用 `Get-Date` cmdlet(读作 “commandlet”):
|
||||
|
||||
```
|
||||
> Get-Date
|
||||
|
||||
Sunday, January 21, 2018 8:12:41 PM
|
||||
```
|
||||
|
||||
你所看到的输出实际上并不是一个文本字符串。不如说,这是 .Net Core 对象的一个字符串表现形式。就像任何 OOP 环境中的对象一样,它具有类型以及你可以调用的方法。
|
||||
|
||||
让我们来证明这一点:
|
||||
|
||||
```
|
||||
> $(Get-Date).GetType().FullName
|
||||
System.DateTime
|
||||
```
|
||||
|
||||
`$(...)` 语法就像你所期望的 POSIX shell 中那样,计算括弧中的命令然后替换整个表达式。但是在 PowerShell 中,这种表达式中的 `$` 是可选的。并且,最重要的是,结果是一个 .Net 对象,而不是文本。因此我们可以调用该对象中的 `GetType()` 方法来获取该对象类型(类似于 Java 中的 `Class` 对象),`FullName` [属性][5] 则用来获取该类型的全称。
|
||||
|
||||
那么,这种对象导向的 shell 是如何让你的工作变得更加简单呢?
|
||||
|
||||
首先,你可将任何对象排进 `Get-Member` cmdlet 来查看它提供的所有方法和属性。
|
||||
|
||||
```
|
||||
> (Get-Date) | Get-Member
|
||||
PS /home/yevster/Documents/ArticlesInProgress> $(Get-Date) | Get-Member
|
||||
|
||||
|
||||
TypeName: System.DateTime
|
||||
|
||||
Name MemberType Definition
|
||||
---- ---------- ----------
|
||||
Add Method datetime Add(timespan value)
|
||||
AddDays Method datetime AddDays(double value)
|
||||
AddHours Method datetime AddHours(double value)
|
||||
AddMilliseconds Method datetime AddMilliseconds(double value)
|
||||
AddMinutes Method datetime AddMinutes(double value)
|
||||
AddMonths Method datetime AddMonths(int months)
|
||||
AddSeconds Method datetime AddSeconds(double value)
|
||||
AddTicks Method datetime AddTicks(long value)
|
||||
AddYears Method datetime AddYears(int value)
|
||||
CompareTo Method int CompareTo(System.Object value), int ...
|
||||
```
|
||||
|
||||
你可以很快的看到 DateTime 对象具有一个 `AddDays` 方法,从而可以使用它来快速的获取昨天的日期:
|
||||
|
||||
```
|
||||
> (Get-Date).AddDays(-1)
|
||||
|
||||
Saturday, January 20, 2018 8:24:42 PM
|
||||
```
|
||||
|
||||
为了做一些更刺激的事,让我们调用 Yahoo 的天气服务(因为它不需要 API 令牌)然后获取你的本地天气。
|
||||
|
||||
```
|
||||
$city="Boston"
|
||||
$state="MA"
|
||||
$url="https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22${city}%2C%20${state}%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"
|
||||
```
|
||||
|
||||
现在,我们可以使用老派的方法然后直接运行 `curl $url` 来获取 JSON 二进制对象,或者……
|
||||
|
||||
```
|
||||
$weather=(Invoke-RestMethod $url)
|
||||
```
|
||||
|
||||
如果你查看了 `$weather` 类型(运行 `echo $weather.GetType().FullName`),你将会发现它是一个 `PSCustomObject`。这是一个用来反射 JSON 结构的动态对象。
|
||||
|
||||
然后 PowerShell 可以通过 tab 补齐来帮助你完成命令输入。只需要输入 `$weather.`(确报包含了 `.`)然后按下 `Tab` 键。你将看到所有根级别的 JSON 键。输入其中的一个,然后跟上 `.` ,再一次按下 `Tab` 键,你将看到它所有的子键(如果有的话)。
|
||||
|
||||
因此,你可以轻易的导航到你所想要的数据:
|
||||
|
||||
```
|
||||
> echo $weather.query.results.channel.atmosphere.pressure
|
||||
1019.0
|
||||
|
||||
> echo $weather.query.results.channel.wind.chill 41
|
||||
```
|
||||
|
||||
并且如果你有非结构化的 JSON 或 CSV 数据(通过外部命令返回的),只需要将它相应的排进 `ConverFrom-Json` 或 `ConvertFrom-CSV` cmdlet,然后你可以得到一个漂亮干净的对象。
|
||||
|
||||
### 计算 vs. 自动化
|
||||
|
||||
我们使用 shell 用于两种目的。一个是用于计算,运行独立的命令然后手动响应它们的输出。另一个是自动化,通过写脚本执行多个命令,然后以编程的方式相应它们的输出。
|
||||
|
||||
我们大多数人都能发现这两种目的在 shell 上的不同且互相冲突的要求。计算任务要求 shell 简洁明了。用户输入的越少越好。但如果用户输入对其他用户来说几乎难以理解,那这一点就不重要了。脚本,从另一个角度来讲是代码。可读性和可维护性是关键。这一方面,POSIX 工具通常是失败的。虽然一些命令通常会为它们的参数提供简洁明了的语法(如:`-f` 和 `--force`),但是命令名字本身就不简洁明了。
|
||||
|
||||
PowerShell 提供了几个机制来消除这种浮士德式的平衡。
|
||||
|
||||
首先,tab 补齐可以消除键入参数名的需要。比如:键入 `Get-Random -Mi`,按下 `Tab` 然后 PowerShell 将会为你完成参数:`Get-Random -Minimum`。但是如果你想更简洁一些,你甚至不需要按下 `Tab`。如下所示,PowerShell 可以理解:
|
||||
|
||||
```
|
||||
Get-Random -Mi 1 -Ma 10
|
||||
```
|
||||
|
||||
因为 `Mi` 和 `Ma` 每一个都具有独立不同的补齐。
|
||||
|
||||
你可能已经留意到所有的 PowerShell cmdlet 名称具有动名词结构。这有助于脚本的可读性,但是你可能不想一而再、再而三的键入 `Get-`。所以并不需要!如果你之间键入了一个名词而没有动词的话,PowerShell 将查找带有该名词的 `Get-` 命令。
|
||||
|
||||
> 小心:尽管 PowerShell 不区分大小写,但在使用 PowerShell 命令是时,名词首字母大写是一个好习惯。比如,键入 `date` 将会调用系统中的 `date` 工具。键入 `Date` 将会调用 PowerShell 的 `Get-Date` cmdlet。
|
||||
|
||||
如果这还不够,PowerShell 还提供了别名,用来创建简单的名字。比如,如果键入 `alias -name cd`,你将会发现 `cd` 在 PowerShell 实际上时 `Set-Location` 命令的别名。
|
||||
|
||||
所以回顾以下 —— 你可以使用强大的 tab 补全、别名,和名词补全来保持命令名词简洁、自动化和一致性参数名截断,与此同时还可以享受丰富、可读的语法格式。
|
||||
|
||||
### 那么……你看呢?
|
||||
|
||||
这些只是 PowerShell 的一部分优势。还有更多特性和 cmdlet,我还没讨论(如果你想弄哭 `grep` 的话,可以查看 [Where-Object][6] 或其别称 `?`)。如果你有点怀旧的话,PowerShell 可以为你加载原来的本地工具。但是给自己足够的时间来适应 PowerShell 面向对象 cmdlet 的世界,然后你将发现自己会选择忘记回去的路。
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/2/powershell-people
|
||||
|
||||
作者:[Yev Bronshteyn][a]
|
||||
译者:[sanfusu](https://github.com/sanfusu)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/yevster
|
||||
[1]:https://github.com/PowerShell/PowerShell/blob/master/README.md
|
||||
[2]:https://blogs.msdn.microsoft.com/powershell/2018/01/10/powershell-core-6-0-generally-available-ga-and-supported/
|
||||
[3]:https://spdx.org/licenses/MIT
|
||||
[4]:http://www.jsnover.com/Docs/MonadManifesto.pdf
|
||||
[5]:https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties
|
||||
[6]:https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/where-object?view=powershell-6
|
@ -1,28 +1,30 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (MjSeven)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-10627-1.html)
|
||||
[#]: subject: (Emoji-Log: A new way to write Git commit messages)
|
||||
[#]: via: (https://opensource.com/article/19/2/emoji-log-git-commit-messages)
|
||||
[#]: author: (Ahmad Awais https://opensource.com/users/mrahmadawais)
|
||||
|
||||
Emoji-Log:编写 Git 提交信息的新方法
|
||||
======
|
||||
使用 Emoji-Log 为你的提交添加上下文。
|
||||
|
||||
> 使用 Emoji-Log 为你的提交添加上下文。
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/emoji_tech_keyboard.jpg?itok=ncBNKZFl)
|
||||
|
||||
我是一名全职开源开发人员,我喜欢称自己为“开源者”。我从事开源软件工作已经超过十年,并[构建了数百个][1]开源软件应用程序。
|
||||
我是一名全职的开源开发人员,我喜欢称自己为“开源者”。我从事开源软件工作已经超过十年,并[构建了数以百计的][1]开源软件应用程序。
|
||||
|
||||
同时我也是不要重复自己 Don't Repeat Yourself(DRY)哲学的忠实粉丝,并且相信编写更好的 Git 提交消息是 DRY 的一个重要组成部分。它们具有足够的上下文关联可以作为你开源软件的变更日志。我编写的众多工作流之一是 [Emoji-Log][2],它是一个简单易用的开源 Git 提交日志标准。它通过使用表情符号来创建更好的 Git 提交消息,从而改善了开发人员的体验(DX)。
|
||||
同时我也是“<ruby>避免重复工作<rt>Don't Repeat Yourself</rt></ruby>”(DRY)哲学的忠实粉丝,并且我相信编写更好的 Git 提交消息是 DRY 的一个重要组成部分。它们具有足够的上下文关联,可以作为你开源软件的变更日志。我编写的众多工作流之一是 [Emoji-Log][2],它是一个简单易用的开源 Git 提交日志标准。它通过使用表情符号来创建更好的 Git 提交消息,从而改善了开发人员的体验(DX)。
|
||||
|
||||
我使用 Emoji-Log 构建了 [VSCode Tips & Tricks 仓库][3] 和我的 🦄 [紫色 VSCode 主题仓库][4],以及一个看起来很漂亮的[自动变更日志][5]。
|
||||
|
||||
### Emoji-Log 的哲学
|
||||
|
||||
我喜欢表情符号,我很喜欢它们。编程,代码,极客/书呆子,开源...所有这一切本质上都很枯燥,有时甚至很无聊。表情符号帮助我添加颜色和情感。想要将感受添加到 2D、平面和基于文本的代码世界并没有错。
|
||||
我喜欢(很多)表情符号,我很喜欢它们。编程、代码、极客/书呆子、开源……所有这一切本质上都很枯燥,有时甚至很无聊。表情符号帮助我添加颜色和情感。想要将感受添加到这个 2D 的、平板的、基于文本的代码世界并没有错。
|
||||
|
||||
相比于[数百个表情符号][6],我学会了更好的办法是保持小类别和普遍性。以下是指导使用 Emoji-Log 编写提交信息的原则:
|
||||
相比于[数百个表情符号][6],我学会的更好办法是让类别较小和普遍性。以下是指导使用 Emoji-Log 编写提交信息的原则:
|
||||
|
||||
1. **必要的**
|
||||
* Git 提交信息是必要的。
|
||||
@ -31,10 +33,10 @@ Emoji-Log:编写 Git 提交信息的新方法
|
||||
* 例如,使用 ✅ **Create** 而不是 ❌ **Creating**
|
||||
2. **规则**
|
||||
* 少数类别易于记忆。
|
||||
* 不多不也少
|
||||
* 例如 **📦 NEW** , **👌 IMPROVE** , **🐛 FIX** , **📖 DOC** , **🚀 RELEASE**, **✅ TEST**
|
||||
* 不多也不少
|
||||
* 例如 **📦 NEW** 、 **👌 IMPROVE** 、 **🐛 FIX** 、 **📖 DOC** 、 **🚀 RELEASE** 、 **✅ TEST**
|
||||
3. **行为**
|
||||
* 让 Git 基于你所采取的操作提交
|
||||
* 让 Git 的提交基于你所采取的操作
|
||||
* 使用像 [VSCode][7] 这样的编辑器来提交带有提交信息的正确文件。
|
||||
|
||||
### 编写提交信息
|
||||
@ -63,7 +65,7 @@ Emoji-Log:编写 Git 提交信息的新方法
|
||||
|
||||
### Emoji-Log 函数
|
||||
|
||||
为了快速构建原型,我写了以下函数,你可以将它们添加到 **.bashrc** 或者 **.zshrc** 文件中以快速使用 Emoji-Log。
|
||||
为了快速构建原型,我写了以下函数,你可以将它们添加到 `.bashrc` 或者 `.zshrc` 文件中以快速使用 Emoji-Log。
|
||||
|
||||
```
|
||||
#.# Better Git Logs.
|
||||
@ -126,7 +128,8 @@ funcsave gdoc
|
||||
funcsave gtst
|
||||
```
|
||||
|
||||
如果你愿意,可以将这些别名直接粘贴到 **~/.gitconfig** 文件:
|
||||
如果你愿意,可以将这些别名直接粘贴到 `~/.gitconfig` 文件:
|
||||
|
||||
```
|
||||
# Git Commit, Add all and Push — in one step.
|
||||
cap = "!f() { git add .; git commit -m \"$@\"; git push; }; f"
|
||||
@ -145,6 +148,17 @@ doc = "!f() { git cap \"📖 DOC: $@\"; }; f"
|
||||
tst = "!f() { git cap \"✅ TEST: $@\"; }; f"
|
||||
```
|
||||
|
||||
### Emoji-Log 例子
|
||||
|
||||
这里列出了一些使用 Emoji-Log 的仓库:
|
||||
|
||||
- [Create-guten-block toolkit](https://github.com/ahmadawais/create-guten-block/commits/)
|
||||
- [VSCode Shades of Purple theme](https://github.com/ahmadawais/shades-of-purple-vscode/commits/)
|
||||
- [Ahmad Awais' GitHub repos](https://github.com/ahmadawais) (我的最新的仓库)
|
||||
- [CaptainCore CLI](https://github.com/CaptainCore/captaincore-cli/commits/) (WordPress 管理工具)
|
||||
- [CaptainCore GUI](https://github.com/CaptainCore/captaincore-gui/commits/) (WordPress 插件)
|
||||
|
||||
你呢?如果你的仓库使用 Emoji-Log,请将这个 [Emoji-Log 徽章](https://on.ahmda.ws/rOMZ/c)放到你的 README 中,并给我发送一个[拉取请求](https://github.com/ahmadawais/Emoji-Log/pulls),以让我可以将你的仓库列在这里。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -153,7 +167,7 @@ via: https://opensource.com/article/19/2/emoji-log-git-commit-messages
|
||||
作者:[Ahmad Awais][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[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/) 荣誉推出
|
||||
|
@ -1,47 +1,46 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (MjSeven)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-10629-1.html)
|
||||
[#]: subject: (How To Fix “Network Protocol Error” On Mozilla Firefox)
|
||||
[#]: via: (https://www.ostechnix.com/how-to-fix-network-protocol-error-on-mozilla-firefox/)
|
||||
[#]: author: (SK https://www.ostechnix.com/author/sk/)
|
||||
|
||||
如何修复 Mozilla Firefox 中出现的 “Network Protocol Error”
|
||||
======
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2019/03/firefox-logo-1-720x340.png)
|
||||
|
||||
Mozilla Firefox 多年来一直是我的默认 Web 浏览器,我每天用它来进行日常网络活动,例如访问邮件,浏览喜欢的网站等。今天,我在使用 Firefox 时遇到了一个奇怪的错误。我试图在 Reddit 平台上分享我们的一个指南时,在 Firefox 上出现了以下错误消息:
|
||||
|
||||
```
|
||||
Network Protocol Error
|
||||
> Network Protocol Error
|
||||
|
||||
Firefox has experienced a network protocol violation that cannot be repaired.
|
||||
> Firefox has experienced a network protocol violation that cannot be repaired.
|
||||
|
||||
The page you are trying to view cannot be shown because an error in the network protocol was detected.
|
||||
> The page you are trying to view cannot be shown because an error in the network protocol was detected.
|
||||
|
||||
Please contact the website owners to inform them of this problem.
|
||||
```
|
||||
> Please contact the website owners to inform them of this problem.
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2019/03/firefox.png)
|
||||
|
||||
老实说,我有点慌,我以为可能是我的系统受到了某种恶意软件的影响。哈哈!但是我发现我错了。我在 Arch Linux 桌面上使用的是最新的 Firefox 版本,我在 Chromium 浏览器中打开了相同的链接,它正确显示了,我猜这是 Firefox 相关的错误。在谷歌上搜索后,我解决了这个问题,如下所述。
|
||||
|
||||
出现这种问题主要是因为“**浏览器缓存**”,如果你遇到此类错误,例如 "Network Protocol Error" 或 "Corrupted Content Error",遵循以下任何一种方法。
|
||||
出现这种问题主要是因为“浏览器缓存”,如果你遇到此类错误,例如 “Network Protocol Error” 或 “Corrupted Content Error”,遵循以下任何一种方法。
|
||||
|
||||
**方法 1:**
|
||||
**方法 1:**
|
||||
|
||||
要修复 "Network Protocol Error" 或 "Corrupted Content Error",你需要在绕过缓存时重新加载网页。为此,按下 **Ctrl + F5** 或 **Ctrl + Shift + R** 快捷键,它将从服务器重新加载页面,而不是从 Firefox 缓存加载。这样网页就应该可以正常工作了。
|
||||
要修复 “Network Protocol Error” 或 “Corrupted Content Error”,你需要在重新加载网页时绕过缓存。为此,按下 `Ctrl + F5` 或 `Ctrl + Shift + R` 快捷键,它将从服务器重新加载页面,而不是从 Firefox 缓存加载。这样网页就应该可以正常工作了。
|
||||
|
||||
**方法 2:**
|
||||
**方法 2:**
|
||||
|
||||
如果方法 1 不起作用,尝试以下方法。
|
||||
|
||||
打开 **Edit - > Preferences**,在 "Preferences" 窗口中,打开左窗格中的 **Privacy & Security** 选项卡,单击 **“Clear Data”** 选项清除 Firefox 缓存。
|
||||
打开 “Edit - > Preferences”,在 “Preferences” 窗口中,打开左窗格中的 “Privacy & Security” 选项卡,单击 “Clear Data” 选项清除 Firefox 缓存。
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2019/03/firefox-1.png)
|
||||
|
||||
确保你选中了 Cookies and Site Data” 和 "Cached Web Content" 选项,然后单击 **"Clear"**。
|
||||
确保你选中了 “Cookies and Site Data” 和 “Cached Web Content” 选项,然后单击 “Clear”。
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2019/03/firefox-2.png)
|
||||
|
||||
@ -58,7 +57,7 @@ via: https://www.ostechnix.com/how-to-fix-network-protocol-error-on-mozilla-fire
|
||||
作者:[SK][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[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/) 荣誉推出
|
||||
|
@ -0,0 +1,84 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Why feedback, not metrics, is critical to DevOps)
|
||||
[#]: via: (https://opensource.com/article/19/3/devops-feedback-not-metrics)
|
||||
[#]: author: (Ranjith Varakantam (Red Hat) https://opensource.com/users/ranjith)
|
||||
|
||||
Why feedback, not metrics, is critical to DevOps
|
||||
======
|
||||
|
||||
Metrics can tell you some things, but not the most important things about how your products and teams are doing.
|
||||
|
||||
![CICD with gears][1]
|
||||
|
||||
Most managers and agile coaches depend on metrics over feedback from their teams, users, and even customers. In fact, quite a few use feedback and metrics synonymously, where they present feedback from teams or customers as a bunch of numbers or a graphical representation of those numbers. This is not only unfortunate, but it can be misleading as it presents only part of the story and not the entire truth.
|
||||
|
||||
When it comes to two critical factors—how we manage or guide our teams and how we operate and influence the product that our teams are developing—few exceptional leaders and teams get it right. For one thing, it has become very easy to get your hands on data and metrics. Furthermore, it's still hard to get real feedback from teams and users. It requires significant investments and energy, and unless everyone understands the critical need for it, getting and giving feedback tends to be a low priority and keeps getting pushed to the back burner.
|
||||
|
||||
### How to manage and guide teams
|
||||
|
||||
With the acceptance of agile, a lot of teams have put a ridiculously high value on metrics, such as velocity, burndown charts, cumulative flow diagram (CFD), etc., instead of the value delivered by the team in each iteration or deployment. The focus is on the delivery or output produced without a clear understanding of how this relates to personal performance or implications for the project, product, or service.
|
||||
|
||||
A few managers and agile coaches even abuse the true spirit of agile by misusing metrics to chastise or even penalize their teams. Instead of creating an environment of empowerment, they are slipping back into the command-and-control method where metrics are used to bully teams into submission.
|
||||
|
||||
In our group, the best managers have weekly one-on-one meetings with every team member. These meetings not only give them a real pulse on team morale but also a profound understanding of the project and the decisions being made to move it forward. This weekly feedback loop also helps the team members communicate technical, functional, and even personal issues better. As a result, the team is much more cohesive in understanding the overall project needs and able to make decisions promptly.
|
||||
|
||||
These leaders also skip levels—reaching out to team members two or three levels below them—and have frequent conversations with other group members who interact with their teams on a regular basis. These actions give the managers a holistic picture, which they couldn't get if they relied on feedback from one manager or lead, and help them identify any blind spots the leads and managers may have.
|
||||
|
||||
These one-on-one meetings effectively transform a manager into a coach who has a close understanding of every team member. Like a good coach, these managers both give and receive feedback from the team members regarding the product, decision-making transparency, places where the team feels management is lagging, and areas that are being ignored. This empowers the teams by giving them a voice, not once in a while in an annual meeting or an annual survey, but every week. This is the level where DevOps teams should be in order to deliver their commitments successfully.
|
||||
|
||||
This demands significant investments of time and energy, but the results more than justify it. The alternative is to rely on metrics and annual reviews and surveys, which has failed miserably. Unless we begin valuing feedback over metrics, we will keep seeing the metrics we want to see but failed projects and miserable team morale.
|
||||
|
||||
### Influencing projects and product development
|
||||
|
||||
We see similar behavior on the project or product side, with too few conversations with the users and developers and too much focus on metrics. Let's take the example of a piece of software that was released to the community or market, and the primary success metric is the number of downloads or installs. This can be deceiving for several reasons:
|
||||
|
||||
1. This product was packaged into another piece of software that users installed; even though the users are not even aware of your product's existence or purpose, it is still counted as a win and something the user needs.
|
||||
|
||||
2. The marketing team spent a huge budget promoting the product—and even offered an incentive to developers to download it. The _incentive_ drives the downloads, not user need or desire, but the metric is still considered a measure of success.
|
||||
|
||||
3. Software updates are counted as downloads, even when they are involuntary updates pushed rather than initiated by the user. This keeps bumping up the number, even though the user might have used it once, a year ago, for a specific task.
|
||||
|
||||
|
||||
|
||||
|
||||
In these cases, the user automatically becomes a metric that's used to report how well the product is doing, just based on the fact it was downloaded and it's accepting updates, regardless of whether the user likes or uses the software. Instead, we should be focusing on actual usage of the product and the feedback these users have to offer us, rather than stopping short at the download numbers.
|
||||
|
||||
The same holds true for SaaS products—instead of counting the number of signups, we should look at how often users use the product or service. Signups by themselves have little meaning, especially to the DevOps team where the focus is on getting constant feedback and striving for continuous improvements.
|
||||
|
||||
### Gathering feedback
|
||||
|
||||
So, why do we rely on metrics so much? My guess is they are easy to collect, and the marketing team is more interested in getting the product into the users' hands than evaluating how it is fairing. Unless the engineering team invests quite a bit of time in collecting feedback with tracing, which captures how often the program is executed and which components are used most often, it can be difficult to collect feedback.
|
||||
|
||||
A big advantage of working in an open source community is that we first release the piece of software into a community where we can get feedback. Most open source enthusiasts take the time to log issues and bugs based on their experience with the product. If we can supplement this data with tracing, the team has an accurate record of how the product is used.
|
||||
|
||||
Open as many channels of communication as possible–chat, email, Twitter, etc.—and allow users to choose their feedback channel.
|
||||
|
||||
A few DevOps teams have integrated blue-green deployments, A/B testing, and canary releases to shorten the feedback loop. Setting up these frameworks it is not a trivial matter and calls for a huge upfront investment and constant updates to make them seamlessly work. But once everything is set up and data begins to flow, the team can act upon real feedback based on real user interactions with every new bit of software released.
|
||||
|
||||
Most agile practitioners and lean movement activists push for a build-deploy-measure-learn cycle, and for this to happen, we need to collect feedback in addition to metrics. It might seem expensive and time consuming in the short term, but in the long run, it is a foolproof way of learning.
|
||||
|
||||
### Proof that feedback pays off
|
||||
|
||||
Whether it pertains to people or projects, it pays to rely on first-hand feedback rather than metrics, which are seldom interpreted in impartial ways. We have ample proof of this in other industries, where companies such as Zappos and the Virgin Group have done wonders for their business simply by listening to their customers. There is no reason we cannot follow suit, especially those of us working in open source communities.
|
||||
|
||||
Feedback is the only effective way we can uncover our blind spots. Metrics are not of much help in this regard, as we can't find out what's wrong when we are dealing with unknowns. Blind spots can create serious gaps between reality and what we think we know. Feedback not only encourages continuous improvement, whether it's on a personal or a product level, but the simple act of listening and acting on it increases trust and loyalty.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/3/devops-feedback-not-metrics
|
||||
|
||||
作者:[Ranjith Varakantam (Red Hat)][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/ranjith
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cicd_continuous_delivery_deployment_gears.png?itok=kVlhiEkc (CICD with gears)
|
146
sources/tech/20170414 5 projects for Raspberry Pi at home.md
Normal file
146
sources/tech/20170414 5 projects for Raspberry Pi at home.md
Normal file
@ -0,0 +1,146 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (5 projects for Raspberry Pi at home)
|
||||
[#]: via: (https://opensource.com/article/17/4/5-projects-raspberry-pi-home)
|
||||
[#]: author: (Ben Nuttall (Community Moderator) )
|
||||
|
||||
5 projects for Raspberry Pi at home
|
||||
======
|
||||
|
||||
![5 projects for Raspberry Pi at home][1]
|
||||
|
||||
The [Raspberry Pi][2] computer can be used in all kinds of settings and for a variety of purposes. It obviously has a place in education for helping students with learning programming and maker skills in the classroom and the hackspace, and it has plenty of industrial applications in the workplace and in factories. I'm going to introduce five projects you might want to build in your own home.
|
||||
|
||||
### Media center
|
||||
|
||||
One of the most common uses for Raspberry Pi in people's homes is behind the TV running media center software serving multimedia files. It's easy to set this up, and the Raspberry Pi provides plenty of GPU (Graphics Processing Unit) power to render HD TV shows and movies to your big screen TV. [Kodi][3] (formerly XBMC) on a Raspberry Pi is a great way to playback any media you have on a hard drive or network-attached storage. You can also install a plugin to play YouTube videos.
|
||||
|
||||
There are a few different options available, most prominently [OSMC][4] (Open Source Media Center) and [LibreELEC][5], both based on Kodi. They both perform well at playing media content, but OSMC has a more visually appearing user interface, while LibreElec is much more lightweight. All you have to do is choose a distribution, download the image and install on an SD card (or just use [NOOBS][6]), boot it up, and you're ready to go.
|
||||
|
||||
![LibreElec ][7]
|
||||
|
||||
LibreElec; Raspberry Pi Foundation, CC BY-SA
|
||||
|
||||
![OSMC][8]
|
||||
|
||||
OSMC.tv, Copyright, Used with permission
|
||||
|
||||
Before proceeding you'll need to decide [w][9][hich Raspberry Pi model to use][9]. These distributions will work on any Pi (1, 2, 3, or Zero), and video playback will essentially be matched on each of these. Apart from the Pi 3 (and Zero W) having built-in Wi-Fi, the only noticeable difference is the reaction speed of the user interface, which will be much faster on a Pi 3. A Pi 2 will not be much slower, so that's fine if you don't need Wi-Fi, but the Pi 3 will noticeably outperform the Pi 1 and Zero when it comes to flicking through the menus.
|
||||
|
||||
### SSH gateway
|
||||
|
||||
If you want to be able to access computers and devices on your home network from outside over the internet, you have to open up ports on those devices to allow outside traffic. Opening ports to the internet is a security risk, meaning you're always at risk of attack, misuse, or any kind of unauthorized access. However, if you install a Raspberry Pi on your network and set up port forwarding to allow only SSH access to that Pi, you can use that as a secure gateway to hop onto other Pis and PCs on the network.
|
||||
|
||||
Most routers allow you to configure port-forwarding rules. You'll need to give your Pi a fixed internal IP address and set up port 22 on your router to map to port 22 on your Raspberry Pi. If your ISP provides you with a static IP address, you'll be able to SSH into it with this as the host address (for example, **ssh pi@123.45.56.78** ). If you have a domain name, you can configure a subdomain to point to this IP address, so you don't have to remember it (for example, **ssh[pi@home.mydomain.com][10]** ).
|
||||
|
||||
![][11]
|
||||
|
||||
However, if you're going to expose a Raspberry Pi to the internet, you should be very careful not to put your network at risk. There are a few simple procedures you can follow to make it sufficiently secure:
|
||||
|
||||
1\. Most people suggest you change your login password (which makes sense, seeing as the default password “raspberry” is well known), but this does not protect against brute-force attacks. You could change your password and add a two-factor authentication (so you need your password _and_ a time-dependent passcode generated by your phone), which is more secure. However, I believe the best way to secure your Raspberry Pi from intruders is to [disable][12] [“password authentication”][12] in your SSH configuration, so you allow only SSH key access. This means that anyone trying to SSH in by guessing your password will never succeed. Only with your private SSH key can anyone gain access. Similarly, most people suggest changing the SSH port from the default 22 to something unexpected, but a simple [Nmap][13] of your IP address will reveal your true SSH port.
|
||||
|
||||
2\. Ideally, you would not run much in the way of other software on this Pi, so you don't end up accidentally exposing anything else. If you want to run other software, you might be better running it on another Pi on the network that is not exposed to the internet. Ensure that you keep your packages up to date by upgrading regularly, particularly the **openssh-server** package, so that any security vulnerabilities are patched.
|
||||
|
||||
3\. Install [sshblack][14] or [fail2ban][15] to blacklist any users who seem to be acting maliciously, such as attempting to brute force your SSH password.
|
||||
|
||||
Once you've secured your Raspberry Pi and put it online, you'll be able to log in to your network from anywhere in the world. Once you're on your Raspberry Pi, you can SSH into other devices on the network using their local IP address (for example, 192.168.1.31). If you have passwords on these devices, just use the password. If they're also SSH-key-only, you'll need to ensure your key is forwarded over SSH by using the **-A** flag: **ssh -A pi@123.45.67.89**.
|
||||
|
||||
### CCTV / pet camera
|
||||
|
||||
Another great home project is to set up a camera module to take photos or stream video, capture and save files, or streamed internally or to the internet. There are many reasons you might want to do this, but two common use cases are for a homemade security camera or to monitor a pet.
|
||||
|
||||
The [Raspberry Pi camera module][16] is a brilliant accessory. It provides full HD photo and video, lots of advanced configuration, and is [easy to][17] [program][17]. The [infrared camera][18] is ideal for this kind of use, and with an infrared LED (which the Pi can control) you can see in the dark!
|
||||
|
||||
If you want to take still images on a regular basis to keep an eye on things, you can just write a short [Python][19] script or use the command line tool [raspistill][20], and schedule it to recur in [Cron][21]. You might want to have it save them to [Dropbox][22] or another web service, upload them to a web server, or you can even create a [web app][23] to display them.
|
||||
|
||||
If you want to stream video, internally or externally, that's really easy, too. A simple MJPEG (Motion JPEG) example is provided in the [picamera documentation][24] (under “web streaming”). Just download or copy that code into a file, run it and visit the Pi's IP address at port 8000, and you'll see your camera's output live.
|
||||
|
||||
A more advanced streaming project, [pistreaming][25], is available, which uses [JSMpeg][26] (a JavaScript video player) with the web server and a websocket for the camera stream running separately. This method is more performant and is just as easy to get running as the previous example, but there is more code involved and if set up to stream on the internet, requires you to open two ports.
|
||||
|
||||
Once you have web streaming set up, you can position the camera where you want it. I have one set up to keep an eye on my pet tortoise:
|
||||
|
||||
![Tortoise ][27]
|
||||
|
||||
Ben Nuttall, CC BY-SA
|
||||
|
||||
If you want to be able to control where the camera actually points, you can do so using servos. A neat solution is to use Pimoroni's [Pan-Tilt HAT][28], which allows you to move the camera easily in two dimensions. To integrate this with pistreaming, see the project's [pantilthat branch][29].
|
||||
|
||||
![Pan-tilt][30]
|
||||
|
||||
Pimoroni.com, Copyright, Used with permission
|
||||
|
||||
If you want to position your Pi outside, you'll need a waterproof enclosure and some way of getting power to the Pi. PoE (Power-over-Ethernet) cables can be a good way of achieving this.
|
||||
|
||||
### Home automation and IoT
|
||||
|
||||
It's 2017 and there are internet-connected devices everywhere, especially in the home. Our lightbulbs have Wi-Fi, our toasters are smarter than they used to be, and our tea kettles are at risk of attack from Russia. As long as you keep your devices secure, or don't connect them to the internet if they don't need to be, then you can make great use of IoT devices to automate tasks around the home.
|
||||
|
||||
There are plenty of services you can buy or subscribe to, like Nest Thermostat or Philips Hue lightbulbs, which allow you to control your heating or your lighting from your phone, respectively—whether you're inside or away from home. You can use a Raspberry Pi to boost the power of these kinds of devices by automating interactions with them according to a set of rules involving timing or even sensors. One thing you can't do with Philips Hue is have the lights come on when you enter the room, but with a Raspberry Pi and a motion sensor, you can use a Python API to turn on the lights. Similarly, you can configure your Nest to turn on the heating when you're at home, but what if you only want it to turn on if there's at least two people home? Write some Python code to check which phones are on the network and if there are at least two, tell the Nest to turn on the heat.
|
||||
|
||||
You can do a great deal more without integrating with existing IoT devices and with only using simple components. A homemade burglar alarm, an automated chicken coop door opener, a night light, a music box, a timed heat lamp, an automated backup server, a print server, or whatever you can imagine.
|
||||
|
||||
### Tor proxy and blocking ads
|
||||
|
||||
Adafruit's [Onion Pi][31] is a [Tor][32] proxy that makes your web traffic anonymous, allowing you to use the internet free of snoopers and any kind of surveillance. Follow Adafruit's tutorial on setting up Onion Pi and you're on your way to a peaceful anonymous browsing experience.
|
||||
|
||||
![Onion-Pi][33]
|
||||
|
||||
Onion-pi from Adafruit, Copyright, Used with permission
|
||||
|
||||
![Pi-hole][34]You can install a Raspberry Pi on your network that intercepts all web traffic and filters out any advertising. Simply download the [Pi-hole][35] software onto the Pi, and all devices on your network will be ad-free (it even blocks in-app ads on your mobile devices).
|
||||
|
||||
There are plenty more uses for the Raspberry Pi at home. What do you use Raspberry Pi for at home? What do you want to use it for?
|
||||
|
||||
Let us know in the comments.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/17/4/5-projects-raspberry-pi-home
|
||||
|
||||
作者:[Ben Nuttall (Community Moderator)][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/raspberry_pi_home_automation.png?itok=2TnmJpD8 (5 projects for Raspberry Pi at home)
|
||||
[2]: https://www.raspberrypi.org/
|
||||
[3]: https://kodi.tv/
|
||||
[4]: https://osmc.tv/
|
||||
[5]: https://libreelec.tv/
|
||||
[6]: https://www.raspberrypi.org/downloads/noobs/
|
||||
[7]: https://opensource.com/sites/default/files/libreelec_0.png (LibreElec )
|
||||
[8]: https://opensource.com/sites/default/files/osmc.png (OSMC)
|
||||
[9]: https://opensource.com/life/16/10/which-raspberry-pi-should-you-choose-your-project
|
||||
[10]: mailto:pi@home.mydomain.com
|
||||
[11]: https://opensource.com/sites/default/files/resize/screenshot_from_2017-04-07_15-13-01-700x380.png
|
||||
[12]: http://stackoverflow.com/questions/20898384/ssh-disable-password-authentication
|
||||
[13]: https://nmap.org/
|
||||
[14]: http://www.pettingers.org/code/sshblack.html
|
||||
[15]: https://www.fail2ban.org/wiki/index.php/Main_Page
|
||||
[16]: https://www.raspberrypi.org/products/camera-module-v2/
|
||||
[17]: https://opensource.com/life/15/6/raspberry-pi-camera-projects
|
||||
[18]: https://www.raspberrypi.org/products/pi-noir-camera-v2/
|
||||
[19]: http://picamera.readthedocs.io/
|
||||
[20]: https://www.raspberrypi.org/documentation/usage/camera/raspicam/raspistill.md
|
||||
[21]: https://www.raspberrypi.org/documentation/linux/usage/cron.md
|
||||
[22]: https://github.com/RZRZR/plant-cam
|
||||
[23]: https://github.com/bennuttall/bett-bot
|
||||
[24]: http://picamera.readthedocs.io/en/release-1.13/recipes2.html#web-streaming
|
||||
[25]: https://github.com/waveform80/pistreaming
|
||||
[26]: http://jsmpeg.com/
|
||||
[27]: https://opensource.com/sites/default/files/tortoise.jpg (Tortoise)
|
||||
[28]: https://shop.pimoroni.com/products/pan-tilt-hat
|
||||
[29]: https://github.com/waveform80/pistreaming/tree/pantilthat
|
||||
[30]: https://opensource.com/sites/default/files/pan-tilt.gif (Pan-tilt)
|
||||
[31]: https://learn.adafruit.com/onion-pi/overview
|
||||
[32]: https://www.torproject.org/
|
||||
[33]: https://opensource.com/sites/default/files/onion-pi.jpg (Onion-Pi)
|
||||
[34]: https://opensource.com/sites/default/files/resize/pi-hole-250x250.png (Pi-hole)
|
||||
[35]: https://pi-hole.net/
|
@ -1,3 +1,4 @@
|
||||
tomjlw is translating
|
||||
Python ChatOps libraries: Opsdroid and Errbot
|
||||
======
|
||||
|
||||
@ -211,7 +212,7 @@ Have you used Errbot or Opsdroid? If so, please leave a comment with your impres
|
||||
via: https://opensource.com/article/18/3/python-chatops-libraries-opsdroid-and-errbot
|
||||
|
||||
作者:[Jeff Triplett][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[tomjlw](https://github.com/tomjlw)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,3 +1,4 @@
|
||||
DaivdMax2006 is translating
|
||||
100 Best Ubuntu Apps
|
||||
======
|
||||
|
||||
|
@ -0,0 +1,128 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Host your own cloud with Raspberry Pi NAS)
|
||||
[#]: via: (https://opensource.com/article/18/9/host-cloud-nas-raspberry-pi?extIdCarryOver=true)
|
||||
[#]: author: (Manuel Dewald https://opensource.com/users/ntlx)
|
||||
|
||||
Host your own cloud with Raspberry Pi NAS
|
||||
======
|
||||
|
||||
Protect and secure your data with a self-hosted cloud powered by your Raspberry Pi.
|
||||
|
||||
![Tree clouds][1]
|
||||
|
||||
In the first two parts of this series, we discussed the [hardware and software fundamentals][2] for building network-attached storage (NAS) on a Raspberry Pi. We also put a proper [backup strategy][3] in place to secure the data on the NAS. In this third part, we will talk about a convenient way to store, access, and share your data with [Nextcloud][4].
|
||||
|
||||
![Raspberry Pi NAS infrastructure with Nextcloud][6]
|
||||
|
||||
### Prerequisites
|
||||
|
||||
To use Nextcloud conveniently, you have to meet a few prerequisites. First, you should have a domain you can use for the Nextcloud instance. For the sake of simplicity in this how-to, we'll use **nextcloud.pi-nas.com**. This domain should be directed to your Raspberry Pi. If you want to run it on your home network, you probably need to set up dynamic DNS for this domain and enable port forwarding of ports 80 and 443 (if you go for an SSL setup, which is highly recommended; otherwise port 80 should be sufficient) from your router to the Raspberry Pi.
|
||||
|
||||
You can automate dynamic DNS updates from the Raspberry Pi using [ddclient][7].
|
||||
|
||||
### Install Nextcloud
|
||||
|
||||
To run Nextcloud on your Raspberry Pi (using the setup described in the [first part][2] of this series), install the following packages as dependencies to Nextcloud using **apt**.
|
||||
|
||||
```
|
||||
sudo apt install unzip wget php apache2 mysql-server php-zip php-mysql php-dom php-mbstring php-gd php-curl
|
||||
```
|
||||
|
||||
The next step is to download Nextcloud. [Get the latest release's URL][8] and copy it to download via **wget** on the Raspberry Pi. In the first article in this series, we attached two disk drives to the Raspberry Pi, one for current data and one for backups. Install Nextcloud on the data drive to make sure data is backed up automatically every night.
|
||||
```
|
||||
sudo mkdir -p /nas/data/nextcloud
|
||||
sudo chown pi /nas/data/nextcloud
|
||||
cd /nas/data/
|
||||
wget <https://download.nextcloud.com/server/releases/nextcloud-14.0.0.zip> -O /nas/data/nextcloud.zip
|
||||
unzip nextcloud.zip
|
||||
sudo ln -s /nas/data/nextcloud /var/www/nextcloud
|
||||
sudo chown -R www-data:www-data /nas/data/nextcloud
|
||||
```
|
||||
|
||||
When I wrote this, the latest release (as you see in the code above) was 14. Nextcloud is under heavy development, so you may find a newer version when installing your copy of Nextcloud onto your Raspberry Pi.
|
||||
|
||||
### Database setup
|
||||
|
||||
When we installed Nextcloud above, we also installed MySQL as a dependency to use it for all the metadata Nextcloud generates (for example, the users you create to access Nextcloud). If you would rather use a Postgres database, you'll need to adjust some of the modules installed above.
|
||||
|
||||
To access the MySQL database as root, start the MySQL client as root:
|
||||
|
||||
```
|
||||
sudo mysql
|
||||
```
|
||||
|
||||
This will open a SQL prompt where you can insert the following commands—substituting the placeholder with the password you want to use for the database connection—to create a database for Nextcloud.
|
||||
```
|
||||
CREATE USER nextcloud IDENTIFIED BY '<insert-password-here>';
|
||||
CREATE DATABASE nextcloud;
|
||||
GRANT ALL ON nextcloud.* TO nextcloud;
|
||||
```
|
||||
|
||||
|
||||
You can exit the SQL prompt by pressing **Ctrl+D** or entering **quit**.
|
||||
|
||||
### Web server configuration
|
||||
|
||||
Nextcloud can be configured to run using Nginx or other web servers, but for this how-to, I decided to go with the Apache web server on my Raspberry Pi NAS. (Feel free to try out another alternative and let me know if you think it performs better.)
|
||||
|
||||
To set it up, configure a virtual host for the domain you created for your Nextcloud instance **nextcloud.pi-nas.com**. To create a virtual host, create the file **/etc/apache2/sites-available/001-nextcloud.conf** with content similar to the following. Make sure to adjust the ServerName to your domain and paths, if you didn't use the ones suggested earlier in this series.
|
||||
```
|
||||
<VirtualHost *:80>
|
||||
ServerName nextcloud.pi-nas.com
|
||||
ServerAdmin [admin@pi-nas.com][9]
|
||||
DocumentRoot /var/www/nextcloud/
|
||||
|
||||
<Directory /var/www/nextcloud/>
|
||||
AllowOverride None
|
||||
</Directory>
|
||||
</VirtualHost>
|
||||
```
|
||||
|
||||
|
||||
To enable this virtual host, run the following two commands.
|
||||
```
|
||||
a2ensite 001-nextcloud
|
||||
sudo systemctl reload apache2
|
||||
```
|
||||
|
||||
|
||||
With this configuration, you should now be able to reach the web server with your domain via the web browser. To secure your data, I recommend using HTTPS instead of HTTP to access Nextcloud. A very easy (and free) way is to obtain a [Let's Encrypt][10] certificate with [Certbot][11] and have a cron job automatically refresh it. That way you don't have to mess around with self-signed or expiring certificates. Follow Certbot's simple how-to [instructions to install it on your Raspberry Pi][12]. During Certbot configuration, you can even decide to automatically forward HTTP to HTTPS, so visitors to **<http://nextcloud.pi-nas.com>** will be redirected to **<https://nextcloud.pi-nas.com>**. Please note, if your Raspberry Pi is running behind your home router, you must have port forwarding enabled for ports 443 and 80 to obtain Let's Encrypt certificates.
|
||||
|
||||
### Configure Nextcloud
|
||||
|
||||
The final step is to visit your fresh Nextcloud instance in a web browser to finish the configuration. To do so, open your domain in a browser and insert the database details from above. You can also set up your first Nextcloud user here, the one you can use for admin tasks. By default, the data directory should be inside the Nextcloud folder, so you don't need to change anything for the backup mechanisms from the [second part of this series][3] to pick up the data stored by users in Nextcloud.
|
||||
|
||||
Afterward, you will be directed to your Nextcloud and can log in with the admin user you created previously. To see a list of recommended steps to ensure a performant and secure Nextcloud installation, visit the Basic Settings tab in the Settings page (in our example: <https://nextcloud.pi-nas.com/>settings/admin) and see the Security & Setup Warnings section.
|
||||
|
||||
Congratulations! You've set up your own Nextcloud powered by a Raspberry Pi. Go ahead and [download a Nextcloud client][13] from the Nextcloud page to sync data with your client devices and access it offline. Mobile clients even provide features like instant upload of pictures you take, so they'll automatically sync to your desktop PC without wondering how to get them there.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/9/host-cloud-nas-raspberry-pi?extIdCarryOver=true
|
||||
|
||||
作者:[Manuel Dewald][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/ntlx
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/life_tree_clouds.png?itok=b_ftihhP (Tree clouds)
|
||||
[2]: https://opensource.com/article/18/7/network-attached-storage-Raspberry-Pi
|
||||
[3]: https://opensource.com/article/18/8/automate-backups-raspberry-pi
|
||||
[4]: https://nextcloud.com/
|
||||
[5]: /file/409336
|
||||
[6]: https://opensource.com/sites/default/files/uploads/nas_part3.png (Raspberry Pi NAS infrastructure with Nextcloud)
|
||||
[7]: https://sourceforge.net/p/ddclient/wiki/Home/
|
||||
[8]: https://nextcloud.com/install/#instructions-server
|
||||
[9]: mailto:admin@pi-nas.com
|
||||
[10]: https://letsencrypt.org/
|
||||
[11]: https://certbot.eff.org/
|
||||
[12]: https://certbot.eff.org/lets-encrypt/debianother-apache
|
||||
[13]: https://nextcloud.com/install/#install-clients
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -1,86 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Linux security: Cmd provides visibility, control over user activity)
|
||||
[#]: via: (https://www.networkworld.com/article/3342454/linux-security-cmd-provides-visibility-control-over-user-activity.html)
|
||||
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
|
||||
|
||||
Linux security: Cmd provides visibility, control over user activity
|
||||
======
|
||||
|
||||
![](https://images.techhive.com/images/article/2017/01/background-1900329_1920-100705659-large.jpg)
|
||||
|
||||
There's a new Linux security tool you should be aware of — Cmd (pronounced "see em dee") dramatically modifies the kind of control that can be exercised over Linux users. It reaches way beyond the traditional configuration of user privileges and takes an active role in monitoring and controlling the commands that users are able to run on Linux systems.
|
||||
|
||||
Provided by a company of the same name, Cmd focuses on cloud usage. Given the increasing number of applications being migrated into cloud environments that rely on Linux, gaps in the available tools make it difficult to adequately enforce required security. However, Cmd can also be used to manage and protect on-premises systems.
|
||||
|
||||
### How Cmd differs from traditional Linux security controls
|
||||
|
||||
The leaders at Cmd — Milun Tesovic and Jake King — say organizations cannot confidently predict or control user behavior until they understand how users work routinely and what is considered “normal.” They seek to provide a tool that will granularly control, monitor, and authenticate user activity.
|
||||
|
||||
Cmd monitors user activity by forming user activity profiles (characterizing the activities these users generally perform), noticing abnormalities in their online behavior (login times, commands used, user locations, etc.), and preventing and reporting certain activities (e.g., downloading or modifying files and running privileged commands) that suggest some kind of system compromise might be underway. The product's behaviors are configurable and changes can be made rapidly.
|
||||
|
||||
The kind of tools most of us are using today to detect threats, identify vulnerabilities, and control user privileges have taken us a long way, but we are still fighting the battle to keep our systems and data safe. Cmd brings us a lot closer to identifying the intentions of hostile users whether those users are people who have managed to break into accounts or represent insider threats.
|
||||
|
||||
![1 sources live sessions][1]
|
||||
|
||||
View live Linux sessions
|
||||
|
||||
### How does Cmd work?
|
||||
|
||||
In monitoring and managing user activity, Cmd:
|
||||
|
||||
* Collects information that profiles user activity
|
||||
* Uses the baseline to determine what is considered normal
|
||||
* Detects and proactively prevents threats using specific indicators
|
||||
* Sends alerts to responsible people
|
||||
|
||||
|
||||
|
||||
![2 triggers][3]
|
||||
|
||||
Building custom policies in Cmd
|
||||
|
||||
Cmd goes beyond defining what sysadmins can control through traditional methods, such as configuring sudo privileges, providing much more granular and situation-specific controls.
|
||||
|
||||
Administrators can select escalation policies that can be managed separately from the user privilege controls managed by Linux sysadmins.
|
||||
|
||||
The Cmd agent provides real-time visibility (not after-the-fact log analysis) and can block actions, require additional authentication, or negotiate authorization as needed.
|
||||
|
||||
Also, Cmd supports custom rules based on geolocation if user locations are available. And new policies can be pushed to agents deployed on hosts within minutes.
|
||||
|
||||
![3 command blocked][4]
|
||||
|
||||
Building a trigger query in Cmd
|
||||
|
||||
### Funding news for Cmd
|
||||
|
||||
[Cmd][2] recently got a financial boost, having [completed of a $15 million round of funding][5] led by [GV][6] (formerly Google Ventures) with participation from Expa, Amplify Partners, and additional strategic investors. This brings the company's raised funding to $21.6 million and will help it continue to add new defensive capabilities to the product and grow its engineering teams.
|
||||
|
||||
In addition, the company appointed Karim Faris, general partner at GV, to its board of directors.
|
||||
|
||||
Join the Network World communities on [Facebook][7] and [LinkedIn][8] to comment on topics that are top of mind.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3342454/linux-security-cmd-provides-visibility-control-over-user-activity.html
|
||||
|
||||
作者:[Sandra Henry-Stocker][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://images.idgesg.net/images/article/2019/02/1-sources-live-sessions-100789431-large.jpg
|
||||
[2]: https://cmd.com
|
||||
[3]: https://images.idgesg.net/images/article/2019/02/2-triggers-100789432-large.jpg
|
||||
[4]: https://images.idgesg.net/images/article/2019/02/3-command-blocked-100789433-large.jpg
|
||||
[5]: https://www.linkedin.com/pulse/changing-cybersecurity-announcing-cmds-15-million-funding-jake-king/
|
||||
[6]: https://www.gv.com/
|
||||
[7]: https://www.facebook.com/NetworkWorld/
|
||||
[8]: https://www.linkedin.com/company/network-world
|
@ -1,61 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (sanfusu )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Blockchain 2.0: An Introduction [Part 1])
|
||||
[#]: via: (https://www.ostechnix.com/blockchain-2-0-an-introduction/)
|
||||
[#]: author: (EDITOR https://www.ostechnix.com/author/editor/)
|
||||
|
||||
Blockchain 2.0: An Introduction [Part 1]
|
||||
======
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2019/03/blockchain-introduction-720x340.png)
|
||||
|
||||
### Blockchain 2.0 – The next paradigm of computing
|
||||
|
||||
The **Blockchain** is now easily distinguishable as a transformational technology poised to bring in revolutionary changes in the way people use the internet. The present series of posts will explore the upcoming wave of Blockchain 2.0 based technologies and applications. The Blockchain is here to stay as evidenced by the tremendous interest in it shown by different stakeholders.
|
||||
|
||||
Staying on top of what it is and how it works is paramount to anyone who plans on using the internet for literally anything. Even if all you do is just stare at your friends’ morning breakfast pics on Instagram or looking for the next best clip to watch, you need to know what this technology can do to all of that.
|
||||
|
||||
Even though the basic concept behind the Blockchain was first talked about in academia in the **1990s** , its prominence to being a trending buzzword among netizens is owed to the rise of payment platforms such as **Bitcoins** and **Ethers**.
|
||||
|
||||
Bitcoin started off as a decentralized digital currency. Its advent meant that you could basically pay people over the internet being totally anonymous, safe and secure. What lay beneath the simple financial token system that was bitcoin though was the BLOCKCHAIN. You can think of Bitcoin technology or any cryptocurrency for that matter as being built up from 3 layers. There’s the foundational Blockchain tech that verifies, records and confirms transactions, on top of the foundation rests the protocol, basically, a rule or an online etiquette to honor, record and confirm transactions and of course, on top of it all is the cryptocurrency token commonly called Bitcoin. A token is generated by the Blockchain once a transaction respecting the protocol is recorded on it.
|
||||
|
||||
While most people only saw the top layer, the coins or tokens being representative of what bitcoin really was, few ventured deep enough to understand that financial transactions were just one of many such possibilities that could be accomplished with the help of the Blockchain foundation. These possibilities are now being explored to generate and develop new standards for decentralizing all manners of transactions.
|
||||
|
||||
At its very basic level, the Blockchain can be thought of as an all-encompassing ledger of records and transactions. This in effect means that all kinds of records can theoretically be handled by the Blockchain. Developments in this area will possibly in the future result in all kinds of hard (Such as real estate deeds, physical keys, etc.) and soft intangible assets (Such as identity records, patents, trademarks, reservations etc.) can be encoded as digital assets to be protected and transferred via the blockchain.
|
||||
|
||||
For the uninitiated, transactions on the Blockchain are inherently thought of and designed to be unbiased, permanent records. This is possible because of a **“consensus system”** that is built into the protocol. All transactions are confirmed, vetted and recorded by the participants of the system, in the case of the Bitcoin cryptocurrency platform, this role is taken care of by **miners** and exchanges. This can vary from platform to platform or from blockchain to blockchain. The protocol stack on which the platform is built is by definition supposed to be open-source and free for anyone with the technical know-how to verify. Transparency is woven into the system unlike much of the other platforms that the internet currently runs on.
|
||||
|
||||
Once transactions are recorded and coded into the Blockchain, they will be seen through. Participants are bound to honor their transactions and contracts the way they were originally intended to be executed. The execution itself will be automatically taken care of by the platform since it’s hardcoded into it, unless of course if the original terms forbid it. This resilience of the Blockchain platform toward attempts of tampering with records, permanency of the records etc., are hitherto unheard of for something working over the internet. This is the added layer of trust that is often talked about while supporters of the technology claim its rising significance.
|
||||
|
||||
These features are not recently discovered hidden potentials of the platform, these were envisioned from the start. In a communique, **Satoshi Nakamoto** , the fabled creator(s) of Bitcoin mentioned, **“the design supports a tremendous variety of possible transaction types that I designed years ago… If Bitcoin catches on in a big way, these are things we’ll want to explore in the future… but they all had to be designed at the beginning to make sure they would be possible later.”**. Cementing the fact that these features are designed and baked into the already existing protocols. The key idea being that the decentralized transaction ledger like the functionality of the Blockchain could be used to transfer, deploy and execute all manner of contracts.
|
||||
|
||||
Leading institutions are currently exploring the possibility of re-inventing financial instruments such as stocks, pensions, and derivatives, while governments all over the world are concerned more with the tamper-proof permanent record keeping potential of the Blockchain. Supporters of the platform claim that once development reaches a critical threshold, everything from your hotel key cards to copyrights and patents will from then on be recorded and implemented via the use of Blockchains.
|
||||
|
||||
An almost full list of items and particulars that could theoretically be implemented via a Blockchain model is compiled and maintained on [**this**][1] page by **Ledra Capital**. A thought experiment to actually realize how much of our lives the Blockchain might effect is a daunting task, but a look at that list will reiterate the importance of doing so.
|
||||
|
||||
Now, all of the bureaucratic and commercial uses mentioned above might lead you to believe that a technology such as this will be solely in the domain of Governments and Large private corporations. However, the truth is far from that. Given the fact that the vast potentials of the system make it attractive for such uses, there are other possibilities and features harbored by Blockchains. There are other more intricate concepts related to the technology such as **DApps** , **DAOs** , **DACs** , **DASs** etc., more of which will be covered in depth in this series of articles.
|
||||
|
||||
Basically, development is going on in full swing and its early for anyone to comment on definitions, standards, and capabilities of such Blockchain based systems for a wider roll-out, but the possibilities and its imminent effects are doubtless. There are even talks about Blockchain based smartphones and polling during elections.
|
||||
|
||||
This was just a brief birds-eye view of what the platform is capable of. We’ll look at the distinct possibilities through a series of such detailed posts and articles. Keep an eye out for the [**next post of the series**][2], which will explore how the Blockchain is revolutionizing transactions and contracts.
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/blockchain-2-0-an-introduction/
|
||||
|
||||
作者:[EDITOR][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.ostechnix.com/author/editor/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: http://ledracapital.com/blog/2014/3/11/bitcoin-series-24-the-mega-master-blockchain-list
|
||||
[2]: https://www.ostechnix.com/blockchain-2-0-revolutionizing-the-financial-system/
|
@ -0,0 +1,77 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (14 days of celebrating the Raspberry Pi)
|
||||
[#]: via: (https://opensource.com/article/19/3/happy-pi-day)
|
||||
[#]: author: (Anderson Silva (Red Hat) https://opensource.com/users/ansilva)
|
||||
|
||||
14 days of celebrating the Raspberry Pi
|
||||
======
|
||||
|
||||
In the 14th and final article in our series on getting started with the Raspberry Pi, take a look back at all the things we've learned.
|
||||
|
||||
![][1]
|
||||
|
||||
**Happy Pi Day!**
|
||||
|
||||
Every year on March 14th, we geeks celebrate Pi Day. In the way we abbreviate dates—MMDD—March 14 is written 03/14, which numerically reminds us of 3.14, or the first three numbers of [pi][2]. What many Americans don't realize is that virtually no other country in the world uses this [date format][3], so Pi Day pretty much only works in the US, though it is celebrated globally.
|
||||
|
||||
Wherever you are in the world, let's celebrate the Raspberry Pi and wrap up this series by reviewing the topics we've covered in the past two weeks:
|
||||
|
||||
* Day 1: [Which Raspberry Pi should you choose?][4]
|
||||
* Day 2: [How to buy a Raspberry Pi][5]
|
||||
* Day 3: [How to boot up a new Raspberry Pi][6]
|
||||
* Day 4: [Learn Linux with the Raspberry Pi][7]
|
||||
* Day 5: [5 ways to teach kids to program with Raspberry Pi][8]
|
||||
* Day 6: [3 popular programming languages you can learn with Raspberry Pi][9]
|
||||
* Day 7: [How to keep your Raspberry Pi updated][10]
|
||||
* Day 8: [How to use your Raspberry Pi for entertainment][11]
|
||||
* Day 9: [Play games on the Raspberry Pi][12]
|
||||
* Day 10: [Let's get physical: How to use GPIO pins on the Raspberry Pi][13]
|
||||
* Day 11: [Learn about computer security with the Raspberry Pi][14]
|
||||
* Day 12: [Do advanced math with Mathematica on the Raspberry Pi][15]
|
||||
* Day 13: [Contribute to the Raspberry Pi community][16]
|
||||
|
||||
|
||||
|
||||
![Pi Day illustration][18]
|
||||
|
||||
I'll end this series by thanking everyone who was brave enough to follow along and especially those who learned something from it during these past 14 days! I also want to encourage everyone to keep expanding their knowledge about the Raspberry Pi and all of the open (and closed) source technology that has been built around it.
|
||||
|
||||
I also encourage you to learn about other cultures, philosophies, religions, and worldviews. What makes us human is this amazing (and sometimes amusing) ability that we have to adapt not only to external environmental circumstances—but also intellectual ones.
|
||||
|
||||
No matter what you do, keep learning!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/3/happy-pi-day
|
||||
|
||||
作者:[Anderson Silva (Red Hat)][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/raspberry-pi-juggle.png?itok=oTgGGSRA
|
||||
[2]: https://www.piday.org/million/
|
||||
[3]: https://en.wikipedia.org/wiki/Date_format_by_country
|
||||
[4]: https://opensource.com/article/19/3/which-raspberry-pi-choose
|
||||
[5]: https://opensource.com/article/19/3/how-buy-raspberry-pi
|
||||
[6]: https://opensource.com/article/19/3/how-boot-new-raspberry-pi
|
||||
[7]: https://opensource.com/article/19/3/learn-linux-raspberry-pi
|
||||
[8]: https://opensource.com/article/19/3/teach-kids-program-raspberry-pi
|
||||
[9]: https://opensource.com/article/19/3/programming-languages-raspberry-pi
|
||||
[10]: https://opensource.com/article/19/3/how-raspberry-pi-update
|
||||
[11]: https://opensource.com/article/19/3/raspberry-pi-entertainment
|
||||
[12]: https://opensource.com/article/19/3/play-games-raspberry-pi
|
||||
[13]: https://opensource.com/article/19/3/gpio-pins-raspberry-pi
|
||||
[14]: https://opensource.com/article/19/3/learn-about-computer-security-raspberry-pi
|
||||
[15]: https://opensource.com/article/19/3/do-math-raspberry-pi
|
||||
[16]: https://opensource.com/article/19/3/contribute-raspberry-pi-community
|
||||
[17]: /file/426561
|
||||
[18]: https://opensource.com/sites/default/files/uploads/raspberrypi_14_piday.jpg (Pi Day illustration)
|
@ -0,0 +1,169 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How To Navigate Inside A Directory/Folder In Linux Without CD Command?)
|
||||
[#]: via: (https://www.2daygeek.com/navigate-switch-directory-without-using-cd-command-in-linux/)
|
||||
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
|
||||
|
||||
How To Navigate Inside A Directory/Folder In Linux Without CD Command?
|
||||
======
|
||||
|
||||
As everybody know that we can’t navigate inside a directory in Linux without CD command.
|
||||
|
||||
Yes that’s true but we have the Linux built-in command called `shopt` that help us to solve this issue.
|
||||
|
||||
[shopt][1] is a shell builtin command to set and unset various bash shell options, which is installed so, we no need to install it again.
|
||||
|
||||
Yes we can navigate inside a directory without CD command after enabling this option.
|
||||
|
||||
We will show you, how to do this in this article. This is a small tweak but it’s very useful for newbies who all are moving from Windows to Linux.
|
||||
|
||||
This is not useful for Linux administrator because we won’t navigate to the directory without CD command, as we had a good practices on this.
|
||||
|
||||
If you are trying to navigate a directory/folder in Linux without cd command, you will be getting the following error message. This is common in Linux.
|
||||
|
||||
```
|
||||
$ Documents/
|
||||
bash: Documents/: Is a directory
|
||||
```
|
||||
|
||||
To achieve this, we need to append the following values in a user `.bashrc` file.
|
||||
|
||||
### What Is the .bashrc File?
|
||||
|
||||
The “.bashrc” file is a shell script which is run every time a user opens a new shell in interactive mode.
|
||||
|
||||
You can add any command in that file that you want to type at the command prompt.
|
||||
|
||||
The .bashrc file itself contains a series of configurations for the terminal session. This includes setting up or enabling: colouring, completion, the shell history, command aliases and more.
|
||||
|
||||
```
|
||||
$ vi ~/.bashrc
|
||||
|
||||
shopt -s autocd
|
||||
```
|
||||
|
||||
Run the following command to make the changes to take effect.
|
||||
|
||||
```
|
||||
$ source ~/.bashrc
|
||||
```
|
||||
|
||||
We have done all the configuration. Simple do the testing on this to confirm whether this working or not.
|
||||
|
||||
```
|
||||
$ Documents/
|
||||
cd -- Documents/
|
||||
|
||||
$ daygeek/
|
||||
cd -- daygeek/
|
||||
|
||||
$ /home/daygeek/Documents/daygeek
|
||||
cd -- /home/daygeek/Documents/daygeek
|
||||
|
||||
$ pwd
|
||||
/home/daygeek/Documents/daygeek
|
||||
```
|
||||
|
||||
![][3]
|
||||
Yes, it’s working fine as expected.
|
||||
|
||||
However, it’s working fine in `fish shell` without making any changes in the `.bashrc` file.
|
||||
![][4]
|
||||
|
||||
If you would like to perform this action for temporarily then use the following commands (set/unset). This will go away when you reboot the system.
|
||||
|
||||
```
|
||||
# shopt -s autocd
|
||||
|
||||
# shopt | grep autocd
|
||||
autocd on
|
||||
|
||||
# shopt -u autocd
|
||||
|
||||
# shopt | grep autocd
|
||||
autocd off
|
||||
```
|
||||
|
||||
shopt command is offering so many other options and if you want to verify those, run the following command.
|
||||
|
||||
```
|
||||
$ shopt
|
||||
autocd on
|
||||
assoc_expand_once off
|
||||
cdable_vars off
|
||||
cdspell on
|
||||
checkhash off
|
||||
checkjobs off
|
||||
checkwinsize on
|
||||
cmdhist on
|
||||
compat31 off
|
||||
compat32 off
|
||||
compat40 off
|
||||
compat41 off
|
||||
compat42 off
|
||||
compat43 off
|
||||
compat44 off
|
||||
complete_fullquote on
|
||||
direxpand off
|
||||
dirspell off
|
||||
dotglob off
|
||||
execfail off
|
||||
expand_aliases on
|
||||
extdebug off
|
||||
extglob off
|
||||
extquote on
|
||||
failglob off
|
||||
force_fignore on
|
||||
globasciiranges on
|
||||
globstar off
|
||||
gnu_errfmt off
|
||||
histappend on
|
||||
histreedit off
|
||||
histverify off
|
||||
hostcomplete on
|
||||
huponexit off
|
||||
inherit_errexit off
|
||||
interactive_comments on
|
||||
lastpipe off
|
||||
lithist off
|
||||
localvar_inherit off
|
||||
localvar_unset off
|
||||
login_shell off
|
||||
mailwarn off
|
||||
no_empty_cmd_completion off
|
||||
nocaseglob off
|
||||
nocasematch off
|
||||
nullglob off
|
||||
progcomp on
|
||||
progcomp_alias off
|
||||
promptvars on
|
||||
restricted_shell off
|
||||
shift_verbose off
|
||||
sourcepath on
|
||||
xpg_echo off
|
||||
```
|
||||
|
||||
I had found few other utilities, that are help us to navigate a directory faster in Linux compared with cd command.
|
||||
|
||||
Those are pushd, popd, up shell script and bd utility. We will cover these topics in the upcoming articles.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.2daygeek.com/navigate-switch-directory-without-using-cd-command-in-linux/
|
||||
|
||||
作者:[Magesh Maruthamuthu][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.2daygeek.com/author/magesh/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html
|
||||
[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
|
||||
[3]: https://www.2daygeek.com/wp-content/uploads/2019/03/navigate-switch-directory-without-using-cd-command-in-linux-1.jpg
|
||||
[4]: https://www.2daygeek.com/wp-content/uploads/2019/03/navigate-switch-directory-without-using-cd-command-in-linux-2.jpg
|
@ -0,0 +1,264 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How To Parse And Pretty Print JSON With Linux Commandline Tools)
|
||||
[#]: via: (https://www.ostechnix.com/how-to-parse-and-pretty-print-json-with-linux-commandline-tools/)
|
||||
[#]: author: (EDITOR https://www.ostechnix.com/author/editor/)
|
||||
|
||||
How To Parse And Pretty Print JSON With Linux Commandline Tools
|
||||
======
|
||||
|
||||
**JSON** is a lightweight and language independent data storage format, easy to integrate with most programming languages and also easy to understand by humans, of course when properly formatted. The word JSON stands for **J** ava **S** cript **O** bject **N** otation, though it starts with JavaScript, and primarily used to exchange data between server and browser, but now being used in many fields including embedded systems. Here we’re going to parse and pretty print JSON with command line tools on Linux. It’s extremely useful for handling large JSON data in a shell scripts, or manipulating JSON data in a shell script.
|
||||
|
||||
### What is pretty printing?
|
||||
|
||||
The JSON data is structured to be somewhat more human readable. However in most cases, JSON data is stored in a single line, even without a line ending character.
|
||||
|
||||
Obviously that’s not very convenient for reading and editing manually.
|
||||
|
||||
That’s when pretty print is useful. The name is quite self explanatory, re-formatting the JSON text to be more legible by humans. This is known as **JSON pretty printing**.
|
||||
|
||||
### Parse And Pretty Print JSON With Linux Commandline Tools
|
||||
|
||||
JSON data could be parsed with command line text processors like **awk** , **sed** and **gerp**. In fact JSON.awk is an awk script to do that. However there are some dedicated tools for the same purpose.
|
||||
|
||||
1. **jq** or **jshon** , JSON parser for shell, both of them are quite useful.
|
||||
|
||||
2. Shell scripts like **JSON.sh** or **jsonv.sh** to parse JSON in bash, zsh or dash shell.
|
||||
|
||||
3. **JSON.awk** , JSON parser awk script.
|
||||
|
||||
4. Python modules like **json.tool**.
|
||||
|
||||
5. **underscore-cli** , Node.js and javascript based.
|
||||
|
||||
|
||||
|
||||
|
||||
In this tutorial I’m focusing only on **jq** , which is quite powerful JSON parser for shells with advanced filtering and scripting capability.
|
||||
|
||||
### JSON pretty printing
|
||||
|
||||
JSON data could be in one and nearly illegible for humans, so to make it somewhat readable, JSON pretty printing is here.
|
||||
|
||||
**Example:** A data from **jsonip.com** , to get external IP address in JSON format, use **curl** or **wget** tools like below.
|
||||
|
||||
```
|
||||
$ wget -cq http://jsonip.com/ -O -
|
||||
```
|
||||
|
||||
The actual data looks like this:
|
||||
|
||||
```
|
||||
{"ip":"111.222.333.444","about":"/about","Pro!":"http://getjsonip.com"}
|
||||
```
|
||||
|
||||
Now pretty print it with jq:
|
||||
|
||||
```
|
||||
$ wget -cq http://jsonip.com/ -O - | jq '.'
|
||||
```
|
||||
|
||||
This should look like below, after filtering the result with jq.
|
||||
|
||||
```
|
||||
{
|
||||
|
||||
"ip": "111.222.333.444",
|
||||
|
||||
"about": "/about",
|
||||
|
||||
"Pro!": "http://getjsonip.com"
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
The Same thing could be done with python **json.tool** module. Here is an example:
|
||||
|
||||
```
|
||||
$ cat anything.json | python -m json.tool
|
||||
```
|
||||
|
||||
This Python based solution should be fine for most users, but it’s not that useful where Python is not pre-installed or could not be installed, like on embedded systems.
|
||||
|
||||
However the json.tool python module has a distinct advantage, it’s cross platform. So, you can use it seamlessly on Windows, Linux or mac OS.
|
||||
|
||||
|
||||
### How to parse JSON with jq
|
||||
|
||||
First, you need to install jq, it’s already picked up by most GNU/Linux distributions, install it with their respective package installer commands.
|
||||
|
||||
On Arch Linux:
|
||||
|
||||
```
|
||||
$ sudo pacman -S jq
|
||||
```
|
||||
|
||||
On Debian, Ubuntu, Linux Mint:
|
||||
|
||||
```
|
||||
$ sudo apt-get install jq
|
||||
```
|
||||
|
||||
On Fedora:
|
||||
|
||||
```
|
||||
$ sudo dnf install jq
|
||||
```
|
||||
|
||||
On openSUSE:
|
||||
|
||||
```
|
||||
$ sudo zypper install jq
|
||||
```
|
||||
|
||||
For other OS or platforms, see the [official installation instructions][1].
|
||||
|
||||
**Basic filters and identifiers of jq**
|
||||
|
||||
jq could read the JSON data either from **stdin** or a **file**. You’ve to use both depending on the situation.
|
||||
|
||||
The single symbol of **.** is the most basic filter. These filters are also called as **object identifier-index**. Using a single **.** along with jq basically pretty prints the input JSON file.
|
||||
|
||||
**Single quotes** – You don’t have to use the single quote always. But if you’re combining several filters in a single line, then you must use them.
|
||||
|
||||
**Double quotes** – You’ve to enclose any special character like **@** , **#** , **$** within two double quotes, like this example, **jq .foo.”@bar”**
|
||||
|
||||
**Raw data print** – For any reason, if you need only the final parsed data, not enclosed within a double quote, use the -r flag with the jq command, like this. **– jq -r .foo.bar**.
|
||||
|
||||
**Parsing specific data**
|
||||
|
||||
To filter out a specific part of JSON, you’ve to look into the pretty printed JSON file’s data hierarchy.
|
||||
|
||||
An example of JSON data, from Wikipedia:
|
||||
|
||||
```
|
||||
{
|
||||
|
||||
"firstName": "John",
|
||||
|
||||
"lastName": "Smith",
|
||||
|
||||
"age": 25,
|
||||
|
||||
"address": {
|
||||
|
||||
"streetAddress": "21 2nd Street",
|
||||
|
||||
"city": "New York",
|
||||
|
||||
"state": "NY",
|
||||
|
||||
"postalCode": "10021"
|
||||
|
||||
},
|
||||
|
||||
"phoneNumber": [
|
||||
|
||||
{
|
||||
|
||||
"type": "home",
|
||||
|
||||
"number": "212 555-1234"
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
|
||||
"type": "fax",
|
||||
|
||||
"number": "646 555-4567"
|
||||
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
"gender": {
|
||||
|
||||
"type": "male"
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
I’m going to use this JSON data as an example in this tutorial, saved this as **sample.json**.
|
||||
|
||||
Let’s say I want to filter out the address from sample.json file. So the command should be like:
|
||||
|
||||
```
|
||||
$ jq .address sample.json
|
||||
```
|
||||
|
||||
**Sample output:**
|
||||
|
||||
```
|
||||
{
|
||||
|
||||
"streetAddress": "21 2nd Street",
|
||||
|
||||
"city": "New York",
|
||||
|
||||
"state": "NY",
|
||||
|
||||
"postalCode": "10021"
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
Again let’s say I want the postal code, then I’ve to add another **object identifier-index** , i.e. another filter.
|
||||
|
||||
```
|
||||
$ cat sample.json | jq .address.postalCode
|
||||
```
|
||||
|
||||
Also note that the **filters are case sensitive** and you’ve to use the exact same string to get something meaningful output instead of null.
|
||||
|
||||
**Parsing elements from JSON array**
|
||||
|
||||
Elements of JSON array are enclosed within square brackets, undoubtedly quite versatile to use.
|
||||
|
||||
To parse elements from a array, you’ve to use the **[]identifier** along with other object identifier-index.
|
||||
|
||||
In this sample JSON data, the phone numbers are stored inside an array, to get all the contents from this array, you’ve to use only the brackets, like this example.
|
||||
|
||||
```
|
||||
$ jq .phoneNumber[] sample.json
|
||||
```
|
||||
|
||||
Let’s say you just want the first element of the array, then use the array object numbers starting for 0, for the first item, use **[0]** , for the next items, it should be incremented by one each step.
|
||||
|
||||
```
|
||||
$ jq .phoneNumber[0] sample.json
|
||||
```
|
||||
|
||||
**Scripting examples**
|
||||
|
||||
Let’s say I want only the the number for home, not entire JSON array data. Here’s when scripting within jq command comes handy.
|
||||
|
||||
```
|
||||
$ cat sample.json | jq -r '.phoneNumber[] | select(.type == "home") | .number'
|
||||
```
|
||||
|
||||
Here first I’m piping the results of one filer to another, then using the select attribute to select a particular type of data, again piping the result to another filter.
|
||||
|
||||
Explaining every type of jq filters and scripting is beyond the scope and purpose of this tutorial. It’s highly suggested to read the JQ manual for better understanding given below.
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/how-to-parse-and-pretty-print-json-with-linux-commandline-tools/
|
||||
|
||||
作者:[EDITOR][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.ostechnix.com/author/editor/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://stedolan.github.io/jq/download/
|
@ -0,0 +1,317 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to create portable documents with CBZ and DjVu)
|
||||
[#]: via: (https://opensource.com/article/19/3/comic-book-archive-djvu)
|
||||
[#]: author: (Seth Kenlon (Red Hat, Community Moderator) https://opensource.com/users/seth)
|
||||
|
||||
How to create portable documents with CBZ and DjVu
|
||||
======
|
||||
|
||||
Stop using PDFs with these two smart digital archive formats.
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/books_stack_library_reading.jpg?itok=uulcS8Sw)
|
||||
|
||||
Recently, I discovered that my great-great-grandfather wrote two books near the turn of the 20th century: one about sailing and the other about his career as [New York City's fire chief][1]. The books have a niche audience, but since they are part of my family history, I wanted to preserve a digital copy of each. But, I wondered, what portable document format is best suited for such an endeavor?
|
||||
|
||||
I decided early on that PDF was not an option. The format, while good for printing preflight, seems condemned to nonstop feature bloat, and it produces documents that are difficult to introspect and edit. I wanted a smarter format with similar features. Two came to mind: comic book archive and DjVu.
|
||||
|
||||
### Comic book archive
|
||||
|
||||
[Comic book archive][2] is a simple format most often used, as the name suggests, for comic books. You can see examples of comic book archives on sites like [Comic Book Plus][3] and [The Digital Comic Museum][4].
|
||||
|
||||
The greatest feature of a comic book archive is also its weakest: it's so simple, it's almost more of a convention than a format. In fact, a comic book archive is just a ZIP, TAR, 7Z, or RAR archive given the extension .cbz, .cbt, .cb7, or .cbr, respectively. It has no standard for storing metadata.
|
||||
|
||||
They are, however, very easy to create.
|
||||
|
||||
#### Creating comic book archives
|
||||
|
||||
1. Create a directory full of image files, and rename the images so that they have an inherent order:
|
||||
|
||||
```
|
||||
$ n=0 && for i in *.png ; do mv $i `printf %04d $n`.png ; done
|
||||
```
|
||||
|
||||
|
||||
|
||||
2. Archive the files using your favorite archive tool. In my experience, CBZ is best supported.
|
||||
|
||||
```
|
||||
$ zip comicbook.zip -r *.png
|
||||
```
|
||||
|
||||
|
||||
|
||||
3. Finally, rename the file with the appropriate extension.
|
||||
|
||||
```
|
||||
$ mv comicbook.zip comicbook.cbz
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
The resulting file should open on most of your devices. On Linux, both [Evince][5] and [Okular][6] can open CBZ files. On Android, [Document Viewer][7] and [Bubble][8] can open them.
|
||||
|
||||
#### Uncompressing comic book archives
|
||||
|
||||
Getting your data back out of a comic book archive is also easy: just unarchive the CBZ file.
|
||||
|
||||
Since your favorite archive tool may not recognize the .cbz extension as a valid archive, it's best to rename it back to its native extension:
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
$ mv comicbook.cbz comicbook.zip
|
||||
$ unzip comicbook.zip
|
||||
|
||||
### DjVu
|
||||
|
||||
A more advanced format, developed more than 20 years ago by AT&T, is [DjVu][9] (pronounced "déjà vu"). It's a digital document format with advanced compression technology and is viewable in more applications than you probably realize, including [Evince][5], [Okular][6], [DjVu.js][10] online, the [DjVu.js viewer][11] Firefox extension, [GNU Emacs][12], [Document Viewer][7] on Android, and the open source, cross-platform [DjView][13] viewer on Sourceforge.
|
||||
|
||||
You can read more about DjVu and find sample .djvu files, at [djvu.org][14].
|
||||
|
||||
DjVu has several appealing features, including image compression, outline (bookmark) structure, and support for embedded text. It's easy to introspect and edit using free and open source tools.
|
||||
|
||||
#### Installing DjVu
|
||||
|
||||
The open source toolchain is [DjVuLibre][15], which you can find in your distribution's software repository. For example, on Fedora:
|
||||
|
||||
```
|
||||
$ sudo dnf install dvjulibre
|
||||
```
|
||||
|
||||
#### Creating a DjVu file
|
||||
|
||||
A .djvu is an image that has been encoded as a DjVu file. A .djvu can contain one or more images (stored as "pages").
|
||||
|
||||
To manually produce a DjVu, you can use one of two encoders: **c44** for high-quality images or **cjb2** for simple bi-tonal images. Each encoder accepts a different image format: c44 can process .pnm or .jpeg files, while cjb2 can process .pbm or .tiff images.
|
||||
|
||||
If you need to preprocess an image, you can do that in a terminal with [Image Magick][16], using the **-density** option to define your desired resolution:
|
||||
|
||||
```
|
||||
$ convert -density 200 foo.png foo.pnm
|
||||
```
|
||||
|
||||
Then you can convert it to DjVu:
|
||||
|
||||
```
|
||||
$ c44 -dpi 200 foo.pnm foo.djvu
|
||||
```
|
||||
|
||||
If your image is simple, like black text on a white page, you can try to convert it using the simpler encoder. If necessary, use Image Magick first to convert it to a compatible intermediate format:
|
||||
|
||||
```
|
||||
$ convert -density 200 foo.png foo.pbm
|
||||
```
|
||||
|
||||
And then convert it to DjVu:
|
||||
|
||||
```
|
||||
$ cjb2 -dpi 200 foo.pbm foo.djvu
|
||||
```
|
||||
|
||||
You now have a simple, single-page .djvu document.
|
||||
|
||||
#### Creating a multi-page DjVu file
|
||||
|
||||
While a single-page DjVu can be useful, given DjVu's sometimes excellent compression, it's most commonly used as a multi-page format.
|
||||
|
||||
Assuming you have a directory of many .djvu files, you can bundle them together with the **djvm** command:
|
||||
|
||||
```
|
||||
$ djvm -c pg_1.djvu two.djvu 003.djvu mybook.djvu
|
||||
```
|
||||
|
||||
Unlike a CBZ archive, the names of the bundled images have no effect on their order in the DjVu document, rather it preserves the order you provide in the command. If you had the foresight to name them in a natural sorting order (001.djvu, 002.djvu, 003.djvu, 004.djvu, and so on), you can use a wildcard:
|
||||
|
||||
```
|
||||
$ djvm -c *.djvu mybook.djvu
|
||||
```
|
||||
|
||||
#### Manipulating a DjVu document
|
||||
|
||||
It's easy to edit DjVu documents with **djvm**. For instance, you can insert a page into an existing DjVu document:
|
||||
|
||||
```
|
||||
$ djvm -i mybook.djvu newpage.djvu 2
|
||||
```
|
||||
|
||||
In this example, the page _newpage.djvu_ becomes the new page 2 in the file _mybook.djvu_.
|
||||
|
||||
You can also delete a page. For example, to delete page 4 from _mybook.djvu_ :
|
||||
|
||||
```
|
||||
$ djvm -d mybook.djvu 4
|
||||
```
|
||||
|
||||
#### Setting an outline
|
||||
|
||||
You can add metadata to a DjVu file, such as an outline (commonly called "bookmarks"). To do this manually, create a plaintext file with the document's outline. A DjVu outline is expressed in a [Lisp][17]-like structure, with an opening **bookmarks** element followed by bookmark names and page numbers:
|
||||
```
|
||||
(bookmarks
|
||||
("Front cover" "#1")
|
||||
("Chapter 1" "#3")
|
||||
("Chapter 2" "#18")
|
||||
("Chapter 3" "#26")
|
||||
)
|
||||
```
|
||||
|
||||
The parentheses define levels in the outline. The outline currently has only top-level bookmarks, but any section can have a subsection by delaying its closing parenthesis. For example, to add a subsection to Chapter 1:
|
||||
```
|
||||
(bookmarks
|
||||
("Front cover" "#1")
|
||||
("Chapter 1" "#3"
|
||||
("Section 1" "#6"))
|
||||
("Chapter 2" "#18")
|
||||
("Chapter 3" "#26")
|
||||
)
|
||||
```
|
||||
|
||||
Once the outline is complete, save the file and apply it to your DjVu file using the **djvused** command:
|
||||
|
||||
```
|
||||
$ djvused -e 'set-outline outline.txt' -s mybook.djvu
|
||||
```
|
||||
|
||||
Open the DjVu file to see the outline.
|
||||
|
||||
![A DjVu with an outline as viewed in Okular][19]
|
||||
|
||||
#### Embedding text
|
||||
|
||||
If you want to store the text of a document you're creating, you can embed text elements ("hidden text" in **djvused** terminology) in your DjVu file so that applications like Okular or DjView can select and copy the text to a user's clipboard.
|
||||
|
||||
This is a complex operation because, in order to embed text, you must first have text. If you have access to a good OCR application (or the time and dedication to transcribe the printed page), you may have that data, but then you must map the text to the bitmap image.
|
||||
|
||||
Once you have the text and the coordinates for each line (or, if you prefer, for each word), you can write a **djvused** script with blocks for each page:
|
||||
```
|
||||
select; remove-ant; remove-txt
|
||||
# -------------------------
|
||||
select "p0004.djvu" # page 4
|
||||
set-txt
|
||||
(page 0 0 2550 3300
|
||||
(line 1661 2337 2235 2369 "Fires and Fire-fighters")
|
||||
(line 1761 2337 2235 2369 "by John Kenlon"))
|
||||
|
||||
.
|
||||
# -------------------------
|
||||
select "p0005.djvu" # page 5
|
||||
set-txt
|
||||
(page 0 0 2550 3300
|
||||
(line 294 2602 1206 2642 "Some more text here, blah blah blah."))
|
||||
```
|
||||
|
||||
The integers for each line represent the minimum and maximum locations for the X and Y coordinates of each line ( **xmin** , **ymin** , **xmax** , **ymax** ). Each line is a rectangle measured in pixels, with an origin at the _bottom-left_ corner of the page.
|
||||
|
||||
You can define embedded text elements as words, lines, and hyperlinks, and you can map complex regions with shapes other than just rectangles. You can also embed specially defined metadata, such as BibTex keys, which are expressed in lowercase (year, booktitle, editor, author, and so on), and DocInfo keys, borrowed from the PDF spec, always starting with an uppercase letter (Title, Author, Subject, Creator, Produced, CreationDate, ModDate, and so on).
|
||||
|
||||
#### Automating DjVu creation
|
||||
|
||||
While it's nice to be able to handcraft a finely detailed DjVu document, if you adopt DjVu as an everyday format, you'll notice that your applications lack some of the conveniences available in the more ubiquitous PDF. For instance, few (if any) applications offer a convenient _Print to DjVu_ or _Export to DjVu_ option, as they do for PDF.
|
||||
|
||||
However, you can still use DjVu by leveraging PDF as an intermediate format.
|
||||
|
||||
Unfortunately, the library required for easy, automated DjVu conversion is licensed under the CPL, which has requirements that cannot be satisfied by the GPL code in the toolchain. For this reason, it can't be distributed as a compiled library, but you're free to compile it yourself.
|
||||
|
||||
The process is relatively simple due to an excellent build script provided by the DjVuLibre team.
|
||||
|
||||
1. First, prepare your system with software development tools. On Fedora, the quick-and-easy way is with a DNF group:
|
||||
|
||||
```
|
||||
$ sudo dnf group install @c-development
|
||||
```
|
||||
|
||||
On Ubuntu:
|
||||
|
||||
```
|
||||
$ sudo apt-get install build-essential
|
||||
```
|
||||
|
||||
|
||||
|
||||
2. Next, download the [**GSDjVu** source code][20] from Sourceforge. Be sure to download **GSDjVu** , not **DjVuLibre** (in other words, don't click on the big green button at the top of the file listing, but on the latest file instead).
|
||||
|
||||
|
||||
3. Unarchive the file you just downloaded, and change directory into it:
|
||||
```
|
||||
$ cd ~/Downloads
|
||||
$ tar xvf gsdjvu-X.YY.tar.gz
|
||||
$ cd gsdjvu-X.YY
|
||||
```
|
||||
|
||||
|
||||
|
||||
4. Create a directory called **BUILD**. It must be called **BUILD** , so quell your creativity:
|
||||
```
|
||||
$ mkdir BUILD
|
||||
$ cd BUILD
|
||||
```
|
||||
|
||||
|
||||
|
||||
5. Download the additional source packages required to build the **GSDjVu **application. Specifically, you must download the source for **Ghostscript** (you almost certainly already have this installed, but you need its source to build against). Additionally, your system must have source packages for **jpeg** , **libpng** , **openjpeg** , and **zlib**. If you think your system already has the source packages for these projects, you can run the build script; if the sources are not found, the script will fail and let you correct the error before trying again.
|
||||
|
||||
|
||||
6. Run the interactive **build-gsdjvu** build script included in the download. This script unpacks the source files, patches Ghostscript with the **gdevdjvu** driver, compiles Ghostscript, and prunes unnecessary files from the build results.
|
||||
|
||||
|
||||
7. You can install **GSDjVu **anywhere in your path. If you don't know what your **PATH** variable is, you can see it with **echo $PATH**. For example, to install it to the **/usr/local** prefix:
|
||||
```
|
||||
$ sudo cp -r BUILD/INST/gsdjvu /usr/local/lib64
|
||||
$ cd /usr/local/bin
|
||||
$ sudo ln -s ../lib64/gsdjvu/gsdjvu gsdjvu
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
#### Converting a PDF to DjVu
|
||||
|
||||
Now that you've built the Ghostscript driver, converting a PDF to DjVu requires just one command:
|
||||
|
||||
```
|
||||
$ djvudigital --words mydocument.pdf mydocument.djvu
|
||||
```
|
||||
|
||||
This transforms all pages, bookmarks, and embedded text in a PDF into a DjVu file. The `--words` option maps all mapped embedded PDF text to the corresponding points in the DjVu file. If there is no embedded PDF, then no embedded text is carried over. Using this tool, you can use convenient PDF functions from your applications and end up with DjVu files.
|
||||
|
||||
### Why DjVu and CBZ?
|
||||
|
||||
DjVu and comic book archive are great additional document formats for your archival arsenal. It seems silly to stuff a series of images into a PostScript format, like PDF, or a format clearly meant mostly for text, like EPUB, so it's nice to have CBZ and DjVu as additional options. They might not be right for all of your documents, but it's good to get comfortable with them so you can use one when it makes the most sense.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/3/comic-book-archive-djvu
|
||||
|
||||
作者:[Seth Kenlon (Red Hat, Community Moderator)][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.fireengineering.com/articles/print/volume-56/issue-27/features/chief-john-kenlon-of-new-york-city.html
|
||||
[2]: https://en.wikipedia.org/wiki/Comic_book_archive
|
||||
[3]: https://comicbookplus.com/
|
||||
[4]: https://digitalcomicmuseum.com/
|
||||
[5]: https://wiki.gnome.org/Apps/Evince
|
||||
[6]: https://okular.kde.org
|
||||
[7]: https://f-droid.org/en/packages/org.sufficientlysecure.viewer/
|
||||
[8]: https://f-droid.org/en/packages/com.nkanaev.comics/
|
||||
[9]: http://djvu.org/
|
||||
[10]: http://djvu.js.org/
|
||||
[11]: https://github.com/RussCoder/djvujs
|
||||
[12]: https://elpa.gnu.org/packages/djvu.html
|
||||
[13]: http://djvu.sourceforge.net/djview4.html
|
||||
[14]: http://djvu.org
|
||||
[15]: http://djvu.sourceforge.net
|
||||
[16]: https://www.imagemagick.org/
|
||||
[17]: https://en.wikipedia.org/wiki/Lisp_(programming_language)
|
||||
[18]: /file/426061
|
||||
[19]: https://opensource.com/sites/default/files/uploads/outline.png (A DjVu with an outline as viewed in Okular)
|
||||
[20]: https://sourceforge.net/projects/djvu/files/GSDjVu/1.10/
|
@ -0,0 +1,73 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Sweet Home 3D: An open source tool to help you decide on your dream home)
|
||||
[#]: via: (https://opensource.com/article/19/3/tool-find-home)
|
||||
[#]: author: (Jeff Macharyas (Community Moderator) )
|
||||
|
||||
Sweet Home 3D: An open source tool to help you decide on your dream home
|
||||
======
|
||||
|
||||
Interior design application makes it easy to render your favorite house—real or imaginary.
|
||||
|
||||
![Houses in a row][1]
|
||||
|
||||
I recently accepted a new job in Virginia. Since my wife was working and watching our house in New York until it sold, it was my responsibility to go out and find a new house for us and our cat. A house that she would not see until we moved into it!
|
||||
|
||||
I contracted with a real estate agent and looked at a few houses, taking many pictures and writing down illegible notes. At night, I would upload the photos into a Google Drive folder, and my wife and I would review them simultaneously over the phone while I tried to remember whether the room was on the right or the left, whether it had a fan, etc.
|
||||
|
||||
Since this was a rather tedious and not very accurate way to present my findings, I went in search of an open source solution to better illustrate what our future dream house would look like that wouldn't hinge on my fuzzy memory and blurry photos.
|
||||
|
||||
[Sweet Home 3D][2] did exactly what I wanted it to do. Sweet Home 3D is available on Sourceforge and released under the GNU General Public License. The [website][3] is very informative, and I was able to get it up and running in no time. Sweet Home 3D was developed by Paris-based Emmanuel Puybaret of eTeks.
|
||||
|
||||
### Hanging the drywall
|
||||
|
||||
I downloaded Sweet Home 3D onto my MacBook Pro and added a PNG version of a flat floorplan of a house to use as a background base map.
|
||||
|
||||
From there, it was a simple matter of using the Rooms palette to trace the pattern and set the "real life" dimensions. After I mapped the rooms, I added the walls, which I could customize by color, thickness, height, etc.
|
||||
|
||||
![Sweet Home 3D floorplan][5]
|
||||
|
||||
Now that I had the "drywall" built, I downloaded various pieces of "furniture" from a large array that includes actual furniture as well as doors, windows, shelves, and more. Each item downloads as a ZIP file, so I created a folder of all my uncompressed pieces. I could customize each piece of furniture, and repetitive items, such as doors, were easy to copy-and-paste into place.
|
||||
|
||||
Once I had all my walls and doors and windows in place, I used the application's 3D view to navigate through the house. Drawing upon my photos and memory, I made adjustments to all the objects until I had a close representation of the house. I could have spent more time modifying the house by adding textures, additional furniture, and objects, but I got it to the point I needed.
|
||||
|
||||
![Sweet Home 3D floorplan][7]
|
||||
|
||||
After I finished, I exported the plan as an OBJ file, which can be opened in a variety of programs, such as [Blender][8] and Preview on the Mac, to spin the house around and examine it from various angles. The Video function was most useful, as I could create a starting point, draw a path through the house, and record the "journey." I exported the video as a MOV file, which I opened and viewed on the Mac using QuickTime.
|
||||
|
||||
My wife was able to see (almost) exactly what I saw, and we could even start arranging furniture ahead of the move, too. Now, all I have to do is load up the moving truck and head south.
|
||||
|
||||
Sweet Home 3D will also prove useful at my new job. I was looking for a way to improve the map of the college's buildings and was planning to just re-draw it in [Inkscape][9] or Illustrator or something. However, since I have the flat map, I can use Sweet Home 3D to create a 3D version of the floorplan and upload it to our website to make finding the bathrooms so much easier!
|
||||
|
||||
### An open source crime scene?
|
||||
|
||||
An interesting aside: according to the [Sweet Home 3D blog][10], "the French Forensic Police Office (Scientific Police) recently chose Sweet Home 3D as a tool to design plans [to represent roads and crime scenes]. This is a concrete application of the recommendation of the French government to give the preference to free open source solutions."
|
||||
|
||||
This is one more bit of evidence of how open source solutions are being used by citizens and governments to create personal projects, solve crimes, and build worlds.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/3/tool-find-home
|
||||
|
||||
作者:[Jeff Macharyas (Community Moderator)][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/house_home_colors_live_building.jpg?itok=HLpsIfIL (Houses in a row)
|
||||
[2]: https://sourceforge.net/projects/sweethome3d/
|
||||
[3]: http://www.sweethome3d.com/
|
||||
[4]: /file/426441
|
||||
[5]: https://opensource.com/sites/default/files/uploads/virginia-house-create-screenshot.png (Sweet Home 3D floorplan)
|
||||
[6]: /file/426451
|
||||
[7]: https://opensource.com/sites/default/files/uploads/virginia-house-3d-screenshot.png (Sweet Home 3D floorplan)
|
||||
[8]: https://opensource.com/article/18/5/blender-hotkey-cheat-sheet
|
||||
[9]: https://opensource.com/article/19/1/inkscape-cheat-sheet
|
||||
[10]: http://www.sweethome3d.com/blog/2018/12/10/customization_for_the_forensic_police.html
|
@ -0,0 +1,141 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Program the real world using Rust on Raspberry Pi)
|
||||
[#]: via: (https://opensource.com/article/19/3/physical-computing-rust-raspberry-pi)
|
||||
[#]: author: (Rahul Thakoor https://opensource.com/users/rahul27)
|
||||
|
||||
Program the real world using Rust on Raspberry Pi
|
||||
======
|
||||
|
||||
rust_gpizero uses the Rust programming language to do physical computing on the Raspberry Pi.
|
||||
|
||||
![][1]
|
||||
|
||||
If you own a Raspberry Pi, chances are you may already have experimented with physical computing—writing code to interact with the real, physical world, like blinking some LEDs or [controlling a servo motor][2]. You may also have used [GPIO Zero][3], a Python library that provides a simple interface to GPIO devices from Raspberry Pi with a friendly Python API. GPIO Zero is developed by [Opensource.com][4] community moderator [Ben Nuttall][5].
|
||||
|
||||
I am working on [**rust_gpiozero**][6], a port of the awesome GPIO Zero library that uses the Rust programming language. It is still a work in progress, but it already includes some useful components.
|
||||
|
||||
[Rust][7] is a systems programming language developed at Mozilla. It is focused on performance, reliability, and productivity. The Rust website has [great resources][8] if you'd like to learn more about it.
|
||||
|
||||
### Getting started
|
||||
|
||||
Before starting with rust_gpiozero, it's smart to have a basic grasp of the Rust programming language. I recommend working through at least the first three chapters in [The Rust Programming Language][9] book.
|
||||
|
||||
I recommend [installing Rust][10] on your Raspberry Pi using [**rustup**][11]. Alternatively, you can set up a cross-compilation environment using [cross][12] (which works only on an x86_64 Linux host) or [this how-to][13].
|
||||
|
||||
After you've installed Rust, create a new Rust project by entering:
|
||||
|
||||
```
|
||||
cargo new rust_gpiozero_demo
|
||||
```
|
||||
|
||||
Add **rust_gpiozero** as a dependency (currently in v0.2.0) by adding the following to the dependencies section in your **Cargo.toml** file
|
||||
|
||||
```
|
||||
rust_gpiozero = "0.2.0"
|
||||
```
|
||||
|
||||
Next, blink an LED—the "hello world" of physical computing by modifying the **main.rs** file with the following:
|
||||
```
|
||||
use rust_gpiozero::*;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() {
|
||||
// Create a new LED attached to Pin 17
|
||||
let led = LED::new(17);
|
||||
|
||||
// Blink the LED 5 times
|
||||
for _ in 0.. 5{
|
||||
led.on();
|
||||
thread::sleep(Duration::from_secs(1));
|
||||
led.off();
|
||||
thread::sleep(Duration::from_secs(1));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
rust_gpiozero provides an easier interface for blinking an LED. You can use the blink method, providing the number of seconds it should stay on and off. This simplifies the code to the following:
|
||||
```
|
||||
use rust_gpiozero::*;
|
||||
fn main() {
|
||||
// Create a new LED attached to Pin 17
|
||||
let mut led = LED::new(17);
|
||||
|
||||
// on_time = 2 secs, off_time=3 secs
|
||||
led.blink(2.0,3.0);
|
||||
|
||||
// prevent program from exiting immediately
|
||||
led.wait();
|
||||
}
|
||||
```
|
||||
|
||||
### Other components
|
||||
|
||||
rust_gpiozero provides several components that are similar to GPIO Zero for controlling output and input devices. These include [LED][14], [Buzzer][15], [Motor][16], Pulse Width Modulation LED ([PWMLED][17]), [Servo][18], and [Button][19].
|
||||
|
||||
Support for other components, sensors, and devices will be added eventually. You can refer to the [documentation][20] for further usage information.
|
||||
|
||||
### More resources
|
||||
|
||||
rust_gpiozero is still a work in progress. If you need more resources for getting started with Rust on your Raspberry Pi, here are some useful links:
|
||||
|
||||
#### Raspberry Pi Peripheral Access Library (RPPAL)
|
||||
|
||||
Similar to GPIO Zero, which is based on the [RPi.GPIO][21] library, rust_gpiozero builds upon the awesome **[RPPAL][22]** library by [Rene van der Meer][23]. If you want more control for your projects using Rust, you should definitely try RPPAL. It has support for GPIO, Inter-Integrated Circuit (I 2C), hardware and software Pulse Width Modulation (PWM), and Serial Peripheral Interface (SPI). Universal asynchronous receiver-transmitter (UART) support is currently in development.
|
||||
|
||||
#### Sense HAT support
|
||||
|
||||
**[Sensehat-rs][24]** is a library by [Jonathan Pallant][25] ([@therealjpster][26]) that provides Rust support for the Raspberry Pi [Sense HAT][27] add-on board. Jonathan also has a [starter workshop][28] for using the library and he wrote a beginner's intro to use Rust on Raspberry Pi, "Read Sense HAT with Rust," in [Issue 73 of _The MagPi_][29] magazine.
|
||||
|
||||
### Wrap Up
|
||||
|
||||
Hopefully, this has inspired you to use the Rust programming language for physical computing on your Raspberry Pi. rust_gpiozero is a library which provides useful components such as LED, Buzzer, Motor, PWMLED, Servo, and Button. More features are planned and you can follow me on [twitter][30] or check out [my blog][31] to stay tuned.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/3/physical-computing-rust-raspberry-pi
|
||||
|
||||
作者:[Rahul Thakoor][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003784_02_os.comcareers_os_rh2x.png?itok=jbRfXinl
|
||||
[2]: https://projects.raspberrypi.org/en/projects/grandpa-scarer/4
|
||||
[3]: https://gpiozero.readthedocs.io/en/stable/#
|
||||
[4]: http://Opensource.com
|
||||
[5]: https://opensource.com/users/bennuttall
|
||||
[6]: https://crates.io/crates/rust_gpiozero
|
||||
[7]: https://www.rust-lang.org/
|
||||
[8]: https://www.rust-lang.org/learn
|
||||
[9]: https://doc.rust-lang.org/book/
|
||||
[10]: https://www.rust-lang.org/tools/install
|
||||
[11]: https://rustup.rs/
|
||||
[12]: https://github.com/rust-embedded/cross
|
||||
[13]: https://github.com/kunerd/clerk/wiki/How-to-use-HD44780-LCD-from-Rust#setting-up-the-cross-toolchain
|
||||
[14]: https://docs.rs/rust_gpiozero/0.2.0/rust_gpiozero/output_devices/struct.LED.html
|
||||
[15]: https://docs.rs/rust_gpiozero/0.2.0/rust_gpiozero/output_devices/struct.Buzzer.html
|
||||
[16]: https://docs.rs/rust_gpiozero/0.2.0/rust_gpiozero/output_devices/struct.Motor.html
|
||||
[17]: https://docs.rs/rust_gpiozero/0.2.0/rust_gpiozero/output_devices/struct.PWMLED.html
|
||||
[18]: https://docs.rs/rust_gpiozero/0.2.0/rust_gpiozero/output_devices/struct.Servo.html
|
||||
[19]: https://docs.rs/rust_gpiozero/0.2.0/rust_gpiozero/input_devices/struct.Button.html
|
||||
[20]: https://docs.rs/rust_gpiozero/
|
||||
[21]: https://pypi.org/project/RPi.GPIO/
|
||||
[22]: https://github.com/golemparts/rppal
|
||||
[23]: https://twitter.com/golemparts
|
||||
[24]: https://crates.io/crates/sensehat
|
||||
[25]: https://github.com/thejpster
|
||||
[26]: https://twitter.com/therealjpster
|
||||
[27]: https://www.raspberrypi.org/products/sense-hat/
|
||||
[28]: https://github.com/thejpster/pi-workshop-rs/
|
||||
[29]: https://www.raspberrypi.org/magpi/issues/73/
|
||||
[30]: https://twitter.com/rahulthakoor
|
||||
[31]: https://rahul-thakoor.github.io/
|
@ -0,0 +1,266 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Install MEAN.JS Stack In Ubuntu 18.04 LTS)
|
||||
[#]: via: (https://www.ostechnix.com/install-mean-js-stack-ubuntu/)
|
||||
[#]: author: (sk https://www.ostechnix.com/author/sk/)
|
||||
|
||||
Install MEAN.JS Stack In Ubuntu 18.04 LTS
|
||||
======
|
||||
|
||||
![Install MEAN.JS Stack][1]
|
||||
|
||||
**MEAN.JS** is an Open-Source, full-Stack JavaScript solution for building fast, and robust web applications. **MEAN.JS** stack consists of **MongoDB** (NoSQL database), **ExpressJs** (NodeJS server-side application web framework), **AngularJS** (Client-side web application framework), and **Node.js** (JavaScript run-time, popular for being a web server platform). In this tutorial, we will be discussing how to install MEAN.JS stack in Ubuntu. This guide was tested in Ubuntu 18.04 LTS server. However, it should work on other Ubuntu versions and Ubuntu variants.
|
||||
|
||||
### Install MongoDB
|
||||
|
||||
**MongoDB** is a free, cross-platform, open source, NoSQL document-oriented database. To install MongoDB on your Ubuntu system, refer the following guide:
|
||||
|
||||
* [**Install MongoDB Community Edition In Linux**][2]
|
||||
|
||||
|
||||
|
||||
### Install Node.js
|
||||
|
||||
**NodeJS** is an open source, cross-platform, and lightweight JavaScript run-time environment that can be used to build scalable network applications.
|
||||
|
||||
To install NodeJS on your system, refer the following guide:
|
||||
|
||||
* [**How To Install NodeJS On Linux**][3]
|
||||
|
||||
|
||||
|
||||
After installing, MongoDB, and Node.js, we need to install the other required components such as **Yarn** , **Grunt** , and **Gulp** for MEAN.js stack.
|
||||
|
||||
### Install Yarn package manager
|
||||
|
||||
Yarn is a package manager used by MEAN.JS stack to manage front-end packages.
|
||||
|
||||
To install Bower, run the following command:
|
||||
|
||||
```
|
||||
$ npm install -g yarn
|
||||
```
|
||||
|
||||
### Install Grunt Task Runner
|
||||
|
||||
Grunt Task Runner is used to to automate the development process.
|
||||
|
||||
To install Grunt, run:
|
||||
|
||||
```
|
||||
$ npm install -g grunt-cli
|
||||
```
|
||||
|
||||
To verify if Yarn and Grunt have been installed, run:
|
||||
|
||||
```
|
||||
$ npm list -g --depth=0 /home/sk/.nvm/versions/node/v11.11.0/lib ├── [email protected] ├── [email protected] └── [email protected]
|
||||
```
|
||||
|
||||
### Install Gulp Task Runner (Optional)
|
||||
|
||||
This is optional. You can use Gulp instead of Grunt. To install Gulp Task Runner, run the following command:
|
||||
|
||||
```
|
||||
$ npm install -g gulp
|
||||
```
|
||||
|
||||
We have installed all required prerequisites. Now, let us deploy MEAN.JS stack.
|
||||
|
||||
### Download and Install MEAN.JS Stack
|
||||
|
||||
Install Git if it is not installed already:
|
||||
|
||||
```
|
||||
$ sudo apt-get install git
|
||||
```
|
||||
|
||||
Next, git clone the MEAN.JS repository with command:
|
||||
|
||||
```
|
||||
$ git clone https://github.com/meanjs/mean.git meanjs
|
||||
```
|
||||
|
||||
**Sample output:**
|
||||
|
||||
```
|
||||
Cloning into 'meanjs'...
|
||||
remote: Counting objects: 8596, done.
|
||||
remote: Compressing objects: 100% (12/12), done.
|
||||
remote: Total 8596 (delta 3), reused 0 (delta 0), pack-reused 8584 Receiving objects: 100% (8596/8596), 2.62 MiB | 140.00 KiB/s, done.
|
||||
Resolving deltas: 100% (4322/4322), done.
|
||||
Checking connectivity... done.
|
||||
```
|
||||
|
||||
The above command will clone the latest version of the MEAN.JS repository to **meanjs** folder in your current working directory.
|
||||
|
||||
Go to the meanjs folder:
|
||||
|
||||
```
|
||||
$ cd meanjs/
|
||||
```
|
||||
|
||||
Run the following command to install the Node.js dependencies required for testing and running our application:
|
||||
|
||||
```
|
||||
$ npm install
|
||||
```
|
||||
|
||||
This will take some time. Please be patient.
|
||||
|
||||
* * *
|
||||
|
||||
**Troubleshooting:**
|
||||
|
||||
When I run the above command in Ubuntu 18.04 LTS, I get the following error:
|
||||
|
||||
```
|
||||
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.5.3/linux-x64-67_binding.node
|
||||
Cannot download "https://github.com/sass/node-sass/releases/download/v4.5.3/linux-x64-67_binding.node":
|
||||
|
||||
HTTP error 404 Not Found
|
||||
|
||||
[....]
|
||||
```
|
||||
|
||||
If you ever get these type of common errors like “node-sass and gulp-sass”, do the following:
|
||||
|
||||
First uninstall the project and global gulp-sass modules using the following commands:
|
||||
|
||||
```
|
||||
$ npm uninstall gulp-sass
|
||||
$ npm uninstall -g gulp-sass
|
||||
```
|
||||
|
||||
Next uninstall the global node-sass module:
|
||||
|
||||
```
|
||||
$ npm uninstall -g node-sass
|
||||
```
|
||||
|
||||
Install the global node-sass first. Then install the gulp-sass module at the local project level.
|
||||
|
||||
```
|
||||
$ npm install -g node-sass
|
||||
$ npm install gulp-sass
|
||||
```
|
||||
|
||||
Now try the npm install again from the project folder using command:
|
||||
|
||||
```
|
||||
$ npm install
|
||||
```
|
||||
|
||||
Now all dependencies will start to install without any issues.
|
||||
|
||||
* * *
|
||||
|
||||
Once all dependencies are installed, run the following command to install all the front-end modules needed for the application:
|
||||
|
||||
```
|
||||
$ yarn --allow-root --config.interactive=false install
|
||||
```
|
||||
|
||||
Or,
|
||||
|
||||
```
|
||||
$ yarn --allow-root install
|
||||
```
|
||||
|
||||
You will see the following message at the end if the installation is successful.
|
||||
|
||||
```
|
||||
[...]
|
||||
> meanjs@0.6.0 snyk-protect /home/sk/meanjs
|
||||
> snyk protect
|
||||
|
||||
Successfully applied Snyk patches
|
||||
|
||||
Done in 99.47s.
|
||||
```
|
||||
|
||||
### Test MEAN.JS
|
||||
|
||||
MEAN.JS stack has been installed. We can now able to start a sample application using command:
|
||||
|
||||
```
|
||||
$ npm start
|
||||
```
|
||||
|
||||
After a few seconds, you will see a message like below. This means MEAN.JS stack is working!
|
||||
|
||||
```
|
||||
[...]
|
||||
MEAN.JS - Development Environment
|
||||
|
||||
Environment: development
|
||||
Server: http://0.0.0.0:3000
|
||||
Database: mongodb://localhost/mean-dev
|
||||
App version: 0.6.0
|
||||
MEAN.JS version: 0.6.0
|
||||
```
|
||||
|
||||
![][4]
|
||||
|
||||
To verify, open up the browser and navigate to **<http://localhost:3000>** or **<http://IP-Address:3000/>**. You should see a screen something like below.
|
||||
|
||||
![][5]
|
||||
|
||||
Mean stack test page
|
||||
|
||||
Congratulations! MEAN.JS stack is ready to start building web applications.
|
||||
|
||||
For further details, I recommend you to refer **[MEAN.JS stack official documentation][6]**.
|
||||
|
||||
* * *
|
||||
|
||||
Want to setup MEAN.JS stack in CentOS, RHEL, Scientific Linux? Check the following link for more details.
|
||||
|
||||
* **[Install MEAN.JS Stack in CentOS 7][7]**
|
||||
|
||||
|
||||
|
||||
* * *
|
||||
|
||||
And, that’s all for now, folks. Hope this tutorial will help you to setup MEAN.JS stack.
|
||||
|
||||
If you find this tutorial useful, please share it on your social, professional networks and support OSTechNix.
|
||||
|
||||
More good stuffs to come. Stay tuned!
|
||||
|
||||
Cheers!
|
||||
|
||||
**Resources:**
|
||||
|
||||
* **[MEAN.JS website][8]**
|
||||
* [**MEAN.JS GitHub Repository**][9]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/install-mean-js-stack-ubuntu/
|
||||
|
||||
作者:[sk][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.ostechnix.com/author/sk/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
|
||||
[2]: https://www.ostechnix.com/install-mongodb-linux/
|
||||
[3]: https://www.ostechnix.com/install-node-js-linux/
|
||||
[4]: http://www.ostechnix.com/wp-content/uploads/2016/03/meanjs.png
|
||||
[5]: http://www.ostechnix.com/wp-content/uploads/2016/03/mean-stack-test-page.png
|
||||
[6]: http://meanjs.org/docs.html
|
||||
[7]: http://www.ostechnix.com/install-mean-js-stack-centos-7/
|
||||
[8]: http://meanjs.org/
|
||||
[9]: https://github.com/meanjs/mean
|
@ -1,164 +0,0 @@
|
||||
安利 Power(Shell)
|
||||
======
|
||||
|
||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_lightbulbs.png?itok=pwp22hTw)
|
||||
|
||||
早些年,[Powershell Core][1] 在 [MIT][3] 开源协议下逐步开放。PowerShell 算不上是新技术。自 2006 年第一版 Windows 版的 PowerShell 发布以来,PowerShell 的创建者在合并 Unⅸ shell 的强大和灵活的同时也在弥补他们所意识到的缺点,特别是从组合命令中获取值时,所要进行的文本操作。
|
||||
|
||||
在 5 个主要版本发布之后,PowerShell 允许在所有主流操作系统上本地运行相同的 shell 和命令行环境(包括 OS X 和 Linux)。一些人(大多数)可能依旧在嘲弄这位 Windows 出生的闯入者为远古时期便存在强大 shell 环境的平台引荐自己。在本帖中,我希望可以将 PowerShell 的优势提供大部分人,甚至是那些经验老道的用户。
|
||||
|
||||
### 一致性跨平台
|
||||
|
||||
如果你计划将脚本从一个执行环境迁移到另一个平台时,你需要确保只使用了那些在两个平台下都起作用的命令和语法。比如在 GNU 系统中,你可以通过以下方式获取昨天的日期:
|
||||
|
||||
```
|
||||
date --date="1 day ago"
|
||||
|
||||
```
|
||||
|
||||
在 BSD 系统中(比如 OS X),上述语法将没办法工作,因为 BSD date 工具需要以下语法:
|
||||
|
||||
```
|
||||
date -v -1d
|
||||
|
||||
```
|
||||
|
||||
因为 PowerShell 具有宽松的许可证,并且为所有的平台都有构建,所以你可以和你的应用一起迁移 PowerShell。因此,你可以使用与你的测试环境相同的命令,将脚本运行在目标系统中。
|
||||
|
||||
### 对象和结构化的数据
|
||||
|
||||
*nix 命令和工具依赖于你的能力,来操控非结构化数据。对于那些长期活在 `sed` `grep` 和 `awk` 环境下的人们来说,这可能是小菜一碟,但现在有更好的选择。
|
||||
|
||||
让我们使用 PowerShell 从写获取昨天日期的实例。为了获取当前日期,使用 `Get-Date` cmdlet(读作 "commandlet"):
|
||||
```
|
||||
> Get-Date
|
||||
|
||||
|
||||
|
||||
Sunday, January 21, 2018 8:12:41 PM
|
||||
|
||||
```
|
||||
|
||||
你所看到的输出实际上并不是一个文本字符串。不如说,是 .Net Core 对象的一个字符串表现形式。就像任何 OOP 环境中的对象一样,它具有类型以及你可以调用的方法。
|
||||
|
||||
让我们来证明这一点:
|
||||
```
|
||||
> $(Get-Date).GetType().FullName
|
||||
|
||||
System.DateTime
|
||||
|
||||
```
|
||||
|
||||
`$(...)` 语法就像你所期望的 POSIX shell 中那样,计算括弧中的命令然后替换整个表达式。但是在 PowerShell 中,这种表达式中的 $ 是可选的。并且,最重要的是,结果是一个 .Net 对象,而不是文本。因此我们可以调用该对象中的 `GetType()` 方法来获取该对象类型(类似于 Java 中的 `Class` 对象),`FullName` [属性][5] 则用来获取该类型的全称。
|
||||
|
||||
那么,这种对象导向的 shell 是如何让你的工作变得更加简单呢?
|
||||
|
||||
首先,你可将任何对象排进 `Get-Member` cmdlet 来查看它提供的所有方法和属性。
|
||||
|
||||
```
|
||||
> (Get-Date) | Get-Member
|
||||
PS /home/yevster/Documents/ArticlesInProgress> $(Get-Date) | Get-Member
|
||||
|
||||
|
||||
TypeName: System.DateTime
|
||||
|
||||
|
||||
Name MemberType Definition
|
||||
---- ---------- ----------
|
||||
Add Method datetime Add(timespan value)
|
||||
AddDays Method datetime AddDays(double value)
|
||||
AddHours Method datetime AddHours(double value)
|
||||
AddMilliseconds Method datetime AddMilliseconds(double value)
|
||||
AddMinutes Method datetime AddMinutes(double value)
|
||||
AddMonths Method datetime AddMonths(int months)
|
||||
AddSeconds Method datetime AddSeconds(double value)
|
||||
AddTicks Method datetime AddTicks(long value)
|
||||
AddYears Method datetime AddYears(int value)
|
||||
CompareTo Method int CompareTo(System.Object value), int ...
|
||||
```
|
||||
|
||||
你可以很快的看到 DateTime 对象具有一个 `AddDays` 方法,从而可以使用它来快速的获取昨天的日期:
|
||||
|
||||
```
|
||||
> (Get-Date).AddDays(-1)
|
||||
|
||||
|
||||
Saturday, January 20, 2018 8:24:42 PM
|
||||
```
|
||||
|
||||
为了做一些更刺激的事,让我们调用 Yahoo 的天气服务(因为这不需要 API 通证)然后获取你的本地天气。
|
||||
|
||||
```
|
||||
$city="Boston"
|
||||
$state="MA"
|
||||
$url="https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22${city}%2C%20${state}%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"
|
||||
```
|
||||
|
||||
现在,我们可以使用老派的方法然后直接运行 `curl $url` 来获取 JSON 二进制对象,或者 ...
|
||||
|
||||
```
|
||||
$weather=(Invoke-RestMethod $url)
|
||||
```
|
||||
|
||||
如果你查看了 `$weather` 类型(运行 `echo $weather.GetType().FullName`),你将会发现它是一个 `PSCustomObject`。这是一个用来反射 JSON 结构的动态对象。
|
||||
|
||||
然后 PowerShell 可以通过 tab 补齐来帮助你完成命令输入。只需要输入 `$weather.`(确报包含了 ".")然后按下 Tab 键。你将看到所有根级别的 JSON 键。输入其中的一个,然后跟上 `.` ,再一次按下 Tab 键,你将看到它所有的子键(如果有的话)。
|
||||
|
||||
因此,你可以轻易的导航到你所想要的数据:
|
||||
```
|
||||
> echo $weather.query.results.channel.atmosphere.pressure
|
||||
1019.0
|
||||
|
||||
|
||||
> echo $weather.query.results.channel.wind.chill
|
||||
41
|
||||
```
|
||||
|
||||
并且如果你有非结构化的 JSON 或 CSV 数据(通过外部命令返回的),只需要将它相应的排进 `ConverFrom-Json` 或 `ConvertFrom-CSV` cmdlet,然后你可以得到一个漂亮干净的对象。
|
||||
|
||||
### 计算 vs. 自动化
|
||||
|
||||
我们使用 shell 用于两种目的。一个是用于计算,运行独立的命令然后手动的响应他们的输出。另一个是自动化,通过写脚本执行躲过命令,然后以编程的方式相应他们的输出。
|
||||
|
||||
我们大多数人都能发现这两种目的在 shell 上的不同且互相冲突的要求。计算任务要求 shell 简洁明了。用户输入的越少,越好。但如果用户输入对其他用户来说几乎难以理解,那这一点就不重要了。脚本,从另一个角度来讲是代码。可读性和可维护性是关键。这一方面,POSIX 工具通常是失败的。虽然一些命令通常会为它们的参数提供简洁明了的语法(如:`-f` 和 `--force`),但是命令名字本身就不简洁明了。
|
||||
|
||||
PowerShell 提供了几个机制来消除这种浮士德士的平衡。
|
||||
|
||||
首先,tab 补齐可以消除键入参数名的需要。比如:键入 `Get-Random -Mi`,按下 Tab 然后 PowerShell 将会为你完成参数:`Get-Random -Minimum`。但是如果你想更简洁一些,你甚至不需要按下 Tab。如下所示,PowerShell 可以理解
|
||||
|
||||
```
|
||||
Get-Random -Mi 1 -Ma 10
|
||||
```
|
||||
|
||||
应为 `Mi` 和 `Ma` 每一个都具有独立不同的补齐。
|
||||
|
||||
你可能已经留意到所有的 PowerShell cmdlet 名称具有动名词结构。这有助于脚本的可读性,但是你可能不想一而再,再而三的键入 `Get-`。所以并不需要!如果你之间键入了一个名词而没有动词的话,PowerShell 将查找带有该名词的 `Get-` 命令。
|
||||
|
||||
小心:尽管 PowerShell 不区分大小写,但在使用 PowerShell 命令是时,名词首字母大写是一个好习惯。比如,键入 `date` 将会调用系统中的 `date` 工具。键入 `Date` 将会调用 PowerShell 的 `Get-Date` cmdlet。
|
||||
|
||||
如果这还不够,PowerShell 还提供了别名,用来创建简单的名字。比如,如果键入 `alias -name cd`,你将会发现 `cd` 在 PowerShell 实际上时 `Set-Location` 命令的别名。
|
||||
|
||||
所以回顾以下 — 你可以使用强大的 tab 补全,别名,和名词补全来保持命令名词简洁,自动化和一致性参数名截断,与此同时还可以享受丰富,可读的语法格式。
|
||||
|
||||
### 那么... 朋友?
|
||||
|
||||
这些只是 PowerShell 的一部分优势。还有更多特性和 cmdlet,我还没讨论(如果你想弄哭 `grep` 的话,可以查看 [Where-Object][6] 或其别称 `?`)。如果你有点怀旧的话,PowerShell 可以为你加载本地工具。但是给自己足够的时间来适应 PowerShell 面向对象 cmdlet 的世界,然后你将发现自己会选择忘记回去的路。
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/2/powershell-people
|
||||
|
||||
作者:[Yev Bronshteyn][a]
|
||||
译者:[sanfusu](https://github.com/sanfusu)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/yevster
|
||||
[1]:https://github.com/PowerShell/PowerShell/blob/master/README.md
|
||||
[2]:https://blogs.msdn.microsoft.com/powershell/2018/01/10/powershell-core-6-0-generally-available-ga-and-supported/
|
||||
[3]:https://spdx.org/licenses/MIT
|
||||
[4]:http://www.jsnover.com/Docs/MonadManifesto.pdf
|
||||
[5]:https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties
|
||||
[6]:https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/where-object?view=powershell-6
|
@ -0,0 +1,87 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Linux security: Cmd provides visibility, control over user activity)
|
||||
[#]: via: (https://www.networkworld.com/article/3342454/linux-security-cmd-provides-visibility-control-over-user-activity.html)
|
||||
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
|
||||
|
||||
Linux 安全:Cmd 提供可视化控制用户活动
|
||||
======
|
||||
|
||||
![](https://images.techhive.com/images/article/2017/01/background-1900329_1920-100705659-large.jpg)
|
||||
|
||||
你应该知道一个新的 Linux 安全工具--Cmd(读作 “see em dee”)极大地改变了可以对 Linux 用户进行控制的类型。它远远超出了传统的用户权限配置,,并在监视和控制用户能够在 Linux 系统上运行的命令方面发挥积极作用。
|
||||
|
||||
它由同名公司开发,Cmd 专注于云应用。鉴于越来越多的应用迁移到依赖于 Linux 的云环境中,可用工具的缺口使得难以充分实施所需的安全性。而且,Cmd 还可用于管理和保护本地系统。
|
||||
|
||||
### Cmd 与传统 Linux 安全控件的区别
|
||||
|
||||
Cmd 公司的领导 Milun Tesovic 和 Jake King 表示,组织无法自信地预测或控制用户行为,直到他们了解了用户日常如何工作以及什么认为是“正常”。他们寻求提供一种能够精细控制、监控和验证用户活动的工具。
|
||||
|
||||
Cmd 通过形成用户活动配置文件(表示这些用户通常进行的活动)监视用户活动,注意其在线行为的异常(登录时间、使用的命令、用户位置等),以及预防和报告某些意味着系统攻击的活动(例如,下载或修改文件和运行特权命令)。产品的行为是可配置的,可以快速进行更改。
|
||||
|
||||
我们大多数人如今用来检测威胁、识别漏洞和控制用户权限的工具已经花费了很长的时间,但我们仍在努力保持系统和数据的安全。Cmd 让我们更能够确定恶意用户的意图,无论这些用户是设法侵入帐户还是代表内部威胁。
|
||||
|
||||
![1 sources live sessions][1]
|
||||
|
||||
查看实时 Linux 会话
|
||||
|
||||
### Cmd 如何工作?
|
||||
|
||||
在监视和管理用户活动时,Cmd:
|
||||
|
||||
* 收集描述用户活动的信息
|
||||
* 使用基线来确定什么是正常的
|
||||
* 使用特定指标检测并主动防止威胁
|
||||
* 向负责人发送警报
|
||||
|
||||
|
||||
|
||||
![2 triggers][3]
|
||||
|
||||
在 Cmd 中构建自定义策略
|
||||
|
||||
Cmd 扩展了系统管理员通过传统方法控制的内容,例如配置 sudo 权限,提供更精细和特定情境的控制。
|
||||
|
||||
管理员可以选择可以与 Linux 系统管理员管理的用户权限控制分开管理的升级策略。
|
||||
|
||||
Cmd 客户端提供实时可视化(不是事后日志分析),并且可以阻止操作,它需要额外的身份验证或根据需要协商授权。
|
||||
|
||||
此外,如果存在用户位置,Cmd 支持基于地理定位的自定义规则。并且可以在几分钟内将新策略推送到部署在主机上的客户端。
|
||||
|
||||
![3 command blocked][4]
|
||||
|
||||
在 Cmd 中构建触发器查询
|
||||
|
||||
|
||||
### Cmd 的融资新闻
|
||||
|
||||
[Cmd][2] 最近完成了由 [GV][6] (前身为 Google Ventures)领投,Expa、Amplify Partners 和其他战略投资者跟投的 [1500 万美元的融资][5]。这使该公司的融资金额达到了 2160 万美元,这将帮助其继续为该产品增加新的防御能力并发展其工程师团队。
|
||||
|
||||
此外,该公司还任命 GV 的普通合伙人 Karim Faris 为董事会成员。
|
||||
|
||||
在 [Facebook][7] 和 [LinkedIn][8] 中加入 Network World 社区,评论顶部话题。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3342454/linux-security-cmd-provides-visibility-control-over-user-activity.html
|
||||
|
||||
作者:[Sandra Henry-Stocker][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://images.idgesg.net/images/article/2019/02/1-sources-live-sessions-100789431-large.jpg
|
||||
[2]: https://cmd.com
|
||||
[3]: https://images.idgesg.net/images/article/2019/02/2-triggers-100789432-large.jpg
|
||||
[4]: https://images.idgesg.net/images/article/2019/02/3-command-blocked-100789433-large.jpg
|
||||
[5]: https://www.linkedin.com/pulse/changing-cybersecurity-announcing-cmds-15-million-funding-jake-king/
|
||||
[6]: https://www.gv.com/
|
||||
[7]: https://www.facebook.com/NetworkWorld/
|
||||
[8]: https://www.linkedin.com/company/network-world
|
@ -0,0 +1,58 @@
|
||||
[#]: collector: "lujun9972"
|
||||
[#]: translator: "sanfusu "
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
[#]: subject: "Blockchain 2.0: An Introduction [Part 1]"
|
||||
[#]: via: "https://www.ostechnix.com/blockchain-2-0-an-introduction/"
|
||||
[#]: author: "EDITOR https://www.ostechnix.com/author/editor/"
|
||||
|
||||
# 区块链 2.0: 一份介绍 [Part 1]
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2019/03/blockchain-introduction-720x340.png)
|
||||
|
||||
### 区块链 2.0 - 下一个计算范式
|
||||
|
||||
**区块链**现在被认为是一种转型技术,它将为人们使用互联网的方式带来革新。本系列文章将探讨即将到来的基于区块链 2.0 的技术和应用。不同的涉众对它表现出的极大兴趣证明了区块链的存在。
|
||||
|
||||
对于任何打算使用互联网做任何事情的人来说,了解它是什么以及它是如何工作的都是至关重要的。即使你所做的只是盯着 Instagram 上朋友们的早餐照片,或者寻找下一个最好的视频片段,你也需要知道这项技术能对这些提供什么样的帮助。
|
||||
|
||||
尽管区块链的基本概念早在上世纪 90 年代就被学术界提及,但它之所以成为网民热词,要归功于诸如**比特币**和 **Ethers** 等支付平台的崛起。
|
||||
|
||||
比特币最初是一种去中心化的数字货币。它的出现意味着你基本上可以通过互联网进行完全匿名,安全可靠的支付。不过,在比特币这个简单的金融令牌系统背后,是区块链。您可以将比特币技术或任何加密货币看作是 3 层结构。区块链基础技术包括验证、记录和确认交易,在这个基础之上是协议,本质上来讲是一个规则或在线礼仪,用来尊重、记录和确认交易,当然,最重要的是通常被称作比特币的加密货币令牌。一旦记录了协议相关的事务,区块链就会生成令牌。
|
||||
|
||||
虽然大多数人只看到了最顶层,即代表比特币真正含义的硬币或代币,但很少有人敢于深入了解,在区块链基金会的帮助下,金融交易只是众多此类可能性中的一种。目前正在探讨这些可能性,以产生和开发所有去中心化交易方式的新标准。
|
||||
|
||||
在最基本的层次上,区块链可以被认为是一个包含所有记录和交易的账簿。这实际上意味着区块链理论上可以处理所有类型的记录。未来这方面的发展可能会导致各种硬资产(如房地产契约、实物钥匙等)和软无形资产(如身份记录、专利、商标、预约等)被编码为数字资产,通过区块链进行保护和转让。
|
||||
|
||||
对于不熟悉区块链的人来说,区块链上的事务本质上被认为是无偏见的永久记录。这是可能的,因为协议中内置了**共识系统**。所有交易均由系统参与者确认、审核和记录,在比特币加密货币平台中,该角色由**矿商**和交易所负责。这可能因平台而异,也可能因区块链到区块链而异。根据定义,构建该平台的协议栈应该是开放源码的,并且对任何具有技术能力的人都是免费的。与目前互联网上运行的许多其他平台不同,该系统内置了透明度。
|
||||
|
||||
一旦事务被记录并编码到区块链中,它们就会被看穿。参与者有义务按照他们最初打算执行的方式履行他们的交易和合同。除非最初的条款禁止执行,否则执行本身将由平台自动处理,因为它是硬编码的。区块链平台对于试图篡改记录、记录的持久性等方面的恢复能力,在因特网上是闻所未闻的。当这项技术的支持者们宣称其日益重要的意义时,这种能力是经常被提及的附加信任层。
|
||||
|
||||
这些特性并不是最近发现的隐藏的平台潜力,而是从一开始就被设想出来的。公报中,**Satoshi Nakamoto(中本聪)**,传说中的比特币创造者,**“我花了数年的时间来构造一个用来支撑巨大的各种可能事务类型的设计……如果比特币能够流行起来,这些都是我们未来要探索的……但是他们从设计之初,就要确保他们以后可能性。”**。结合这样一个事实,即这些特性被设计并融入到已经存在的协议中。关键的想法是,去中性化的事务分类账(如区块链的功能)可以用于传输、部署和执行各种形式的契约。
|
||||
|
||||
领先机构目前正在探索重新发明股票、养老金和衍生品等金融工具的可能性,而世界各国政府更关注区块链的防篡改和永久性保存记录的潜力。该平台的支持者声称,一旦开发达到一个关键的门槛,从你的酒店钥匙卡到版权和专利,那时起,一切都将通过区块链记录和实现。
|
||||
|
||||
**Ledra Capital**在[**这个**][1]页面上编译并维护了几乎完整的项目和细节列表,这些项目和细节理论上可以通过区块链模型实现。想要真正意识到区块链对我们生活的影响有多大是一项艰巨的任务,但看看这个清单就会重申这么做的重要性。
|
||||
|
||||
现在,上面提到的所有官僚和商业用途可能会让你相信,这样的技术只会出现在政府和大型私营企业领域。然而,事实远非如此。鉴于该系统的巨大潜力使其对此类用途具有吸引力,区块链还具有其他可能性和特性。还有一些与该技术相关的更复杂的概念,如**DApps**、**DAOs**、**DACs**、**DASs**等,本系列文章将深入讨论这些概念。
|
||||
|
||||
基本上,开发正在如火如荼地进行,任何人都还没有来得及对基于区块链的系统的定义、标准和功能进行评论,以便进行更广泛的推广,但是这种可能性及其即将产生的影响无疑是存在的。甚至有人谈到基于区块链的智能手机和选举期间的投票。
|
||||
|
||||
这只是一个简短的鸟瞰平台的能力。我们将通过一系列这样详细的帖子和文章来研究这些不同的可能性。关注[**本系列的下一篇文章**][2],它将探索区块链是如何革新交易和契约的。
|
||||
|
||||
---
|
||||
|
||||
via: https://www.ostechnix.com/blockchain-2-0-an-introduction/
|
||||
|
||||
作者:[EDITOR][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[sanfusu](https://github.com/sanfusu)
|
||||
校对:[校对者 ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux 中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.ostechnix.com/author/editor/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: http://ledracapital.com/blog/2014/3/11/bitcoin-series-24-the-mega-master-blockchain-list
|
||||
[2]: https://www.ostechnix.com/blockchain-2-0-revolutionizing-the-financial-system/
|
Loading…
Reference in New Issue
Block a user