Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu.Wang 2018-12-10 22:09:11 +08:00
commit 21a02a857d
27 changed files with 4905 additions and 351 deletions

View File

@ -0,0 +1,122 @@
NASA 在开放科学方面做了些什么
======
![][1]
最近我们刚为开设了一个新的“[科学类][2]”的文章分类。其中发表的最新一篇文章名为:[开源是怎样影响科学的][3]。在这篇文章中我们主要讨论了 [NASA][4] 的积极努力,这些努力包括他们通过开源实践来促进科学研究的积极作用。
### NASA 是怎样使用开源手段促进科学研究的
NASA 将他们的整个研究库对整个公共领域开放,这是一项[壮举][5]。
没错!每个人都能访问他们的整个研究库,并能从他们的研究中获益。
他们现已开放的资料可以大致分为以下三类:
* 开源 NASA
* 开放 API
* 开放数据
### 1、开源 NASA
这里有一份 [GitHub][7] 的联合创始人之一和执行总裁 [Chris Wanstrath][6] 的采访,他向我们介绍道,一切都是从很多年前开始的。
- [Chris Wanstrath on NASA, open source and Github](https://youtu.be/dUFzMe8GM3M)
该项目名为 “[code.nasa.gov][8]”截至本文发表为止NASA 已经[通过 GitHub 开源][9]了 365 个科学软件LCTT 译注:本文原文发表于 2018/3/28截止至本译文发布已经有 454 个项目了)。对于一位热爱程序的开发者来说,即使一天研究一个软件,想把 NASA 的这些软件全部研究过来也要整整一年的时间。
即使你不是一位开发者,你也可以在这个门户网站浏览这个壮观的软件合集。
其中就有[阿波罗 11 号][10]的制导计算机的源代码。阿波罗 11 号空间飞行器[首次将两名人类带上月球][11],分别是 [Neil Armstrong][12] 和 [Edwin Aldrin][13] 。如果你对 Edwin Aldrin 感兴趣,可以点击[这里][14]了解更多。
#### NASA 开源代码促进会使用的开源代码许可
它们采用了几种[开源许可证][15],其分类如下:
- [Apache 许可证 2.0](https://www.apache.org/licenses/LICENSE-2.0)
- [Nasa 开源许可证 3.0](https://opensource.org/licenses/NASA-1.3)
- [GPL v3](https://www.gnu.org/licenses/gpl.html)
- [MIT 许可证](https://en.wikipedia.org/wiki/MIT_License)
### 2、开放 API
开放 [API][16] 在推行开放科学中起到了很大作用。与[开源促进会][17]类似,对于 API也有一个 [开放 API 促进会][18]。下面这张示意图可以告诉你 API 是怎样将应用程序和它的开发者连接起来的。
![][19]
记得点击这个[链接](https://sproutsocial.com/insights/what-is-an-api/)看看。链接内的文章使用了简单易懂的方法解读了 API ,文末总结了五大要点。
![][20]
这会让你感受到专有 API 和开放 API 会有多么大的不同。
![][22]
[NASA 的 Open API][23] 主要针对应用程序开发者,旨在显著改善数据的可访问性,也包括图片内容在内。该网站有一个实时编辑器,可供你调用[每日天文一图APOD][24] 的 API。
#### 3、开放数据
![][25]
在[我们发布的第一篇开放科学的文章][3]中,我们在“开放科学”段落下提到的三个国家 —— 法国、印度和美国的多种开放数据形式。NASA 有着类似的想法和行为。这种重要的意识形态已经被[多个国家][26]所接受。
[NASA 的开放数据门户][27]致力于开放拥有不断增长的可供大众自由使用的开放数据。将数据集纳入到这个数据集对于任何研究活动来说都是必要且重要的。NASA 还在他们的门户网站上征集各方的数据需求,以一同收录在他们的数据库中。这一举措不仅是领先的、创新的,还顺应了[数据科学][28]、[AI 和深度学习][29]的趋势。
下面的视频讲的是学者和学生们是怎样通过大量研究得出对数据科学的定义的。这个过程十分的激动人心。瑞尔森大学罗杰斯商学院的 [Murtaza Haider 教授][30]在视频结尾中提到了开源的出现对数据科学的改变,尤其让是旧有的闭源方式逐渐变得开放。而这也确实成为了现实。
- [What is Data Science? Data Science 101](https://youtu.be/z1kPKBdYks4)
![][31]
现在任何人都能在 NASA 上征集数据。正如前面的视频中所说NASA 的举措很大程度上与征集和分析优化数据有关。
![][32]
你只需要免费注册即可。考虑到论坛上的公开讨论以及数据集在可能存在的每一类分析领域中的重要性,这一举措在未来会有非常积极的影响,对数据的统计分析当然也会大幅进展。在之后的文章中我们还会具体讨论这些细节,还有它们和开源模式之间的相关性。
以上就是对 NASA 开放科学模式的一些探索成就,希望您能继续关注我们接下来的相关文章!
--------------------------------------------------------------------------------
via: https://itsfoss.com/nasa-open-science/
作者:[Avimanyu Bandyopadhyay][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[Valoniakim](https://github.com/Valoniakim)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/avimanyu/
[1]:https://itsfoss.com/wp-content/uploads/2018/03/tux-in-space.jpg
[2]:https://itsfoss.com/category/science/
[3]:https://itsfoss.com/open-source-impact-on-science/
[4]:https://www.nasa.gov/
[5]:https://futurism.com/free-science-nasa-just-opened-its-entire-research-library-to-the-public/
[6]:http://chriswanstrath.com/
[7]:https://github.com/
[8]:http://code.nasa.gov
[9]:https://github.com/open-source
[10]:https://www.nasa.gov/mission_pages/apollo/missions/apollo11.html
[11]:https://www.space.com/16758-apollo-11-first-moon-landing.html
[12]:https://www.jsc.nasa.gov/Bios/htmlbios/armstrong-na.html
[13]:https://www.jsc.nasa.gov/Bios/htmlbios/aldrin-b.html
[14]:https://buzzaldrin.com/the-man/
[15]:https://itsfoss.com/open-source-licenses-explained/
[16]:https://en.wikipedia.org/wiki/Application_programming_interface
[17]:https://opensource.org/
[18]:https://www.openapis.org/
[19]:https://itsfoss.com/wp-content/uploads/2018/03/api-bridge.jpeg
[20]:https://itsfoss.com/wp-content/uploads/2018/03/open-api-diagram.jpg
[21]:http://www.apiacademy.co/resources/api-strategy-lesson-201-private-apis-vs-open-apis/
[22]:https://itsfoss.com/wp-content/uploads/2018/03/nasa-open-api-live-example.jpg
[23]:https://api.nasa.gov/
[24]:https://apod.nasa.gov/apod/astropix.html
[25]:https://itsfoss.com/wp-content/uploads/2018/03/nasa-open-data-portal.jpg
[26]:https://www.xbrl.org/the-standard/why/ten-countries-with-open-data/
[27]:https://data.nasa.gov/
[28]:https://en.wikipedia.org/wiki/Data_science
[29]:https://www.kdnuggets.com/2017/07/ai-deep-learning-explained-simply.html
[30]:https://www.ryerson.ca/tedrogersschool/bm/programs/real-estate-management/murtaza-haider/
[31]:https://itsfoss.com/wp-content/uploads/2018/03/suggest-dataset-nasa-1.jpg
[32]:https://itsfoss.com/wp-content/uploads/2018/03/suggest-dataset-nasa-2-1.jpg

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (seriouszyx)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: subject: (What the open source community means to me)

View File

@ -0,0 +1,78 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: subject: (5 reasons to give Linux for the holidays)
[#]: via: (https://opensource.com/article/18/12/reasons-give-linux-holidays)
[#]: author: (Don Watkins https://opensource.com/users/don-watkins)
[#]: url: ( )
5 reasons to give Linux for the holidays
======
If a computer is on your gift-giving list, here's why it should be Linux.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tux_linux_penguin_code_binary.jpg?itok=TxGxW0KY)
Every year around this time, people ask me about the best computer to give (or get) for the holidays. I always give the same answer: Linux. After all, if you want your recipients to be happy, why wouldn't you give them the best operating system on the planet?
Many people don't realize they have options when it comes to computer operating systems. Just recently, two friends (who didn't do their research) fell for the clever marketing and bought brand-new systems at premium prices. I'm willing to bet that within six months they'll be dissatisfied with those expensive computers.
In contrast, I recently purchased a four-year-old computer with an i5 processor, 4GB of RAM, and a 128GB SSD drive, and I love it. It's fast and has all the applications I need to be successful and happy. That's because I'm running Linux. Whether I'm using Firefox or Chrome, all my websites load quickly and the video is great. In fact, the web is faster on Linux than it is on MacOS or Windows.
So, if you're in the mood to give a computer for the holidays, here are five good reasons it should be Linux.
### 1\. Linux is easy to use
Linux distributions like [Fedora][1], [Ubuntu][2], [PopOS][3], [Linux Mint][4], and [Raspbian][5] come with loads of documentation and access to a user community eager to help. And desktop environments such as [GNOME][6], [KDE][7], and [LXDE][8] mean the Linux operating system is just plain easy. If you have a problem with a Linux operating system, you won't have to wait in a long telephone queue for an answer—you can tap into the community's knowledge.
### 2\. Free applications for practically anything you need
There are hundreds of high-quality, free software packages available for Linux. My favorites are [LibreOffice][9] and [GnuCash][10]. I cannot imagine any writing task that is beyond the scope of LibreOffice. I use it and recommend it to everyone I know. Why spend money on a name-brand productivity suite when LibreOffice, the best one out there, is free? (If you agree and you're able, you really ought to consider contributing to the project.)
### 3\. Security
Linux is secure, an important fact in an age when security tops most people's essential features list. On Linux, viruses and malware are minimal. I spend many days each year helping friends recover their Windows systems that have been hacked or infected with malware. That's rare on Linux, and if you want to be doubly sure no one gains improper access to your computer, there are plenty of open source solutions that can help prevent it. My favorites are [ClamAV][11] and [Rootkit Hunter][12]. Linux respects your privacy. It does not upload user data to Redmond or Cupertino.
### 4\. Freedom
Linux gives me the freedom to use my operating system however I choose, whether that is as a standalone workstation for personal productivity, a content server, a firewall for my home network, or something else. Unlike proprietary desktop operating systems, you don't have to purchase an upgrade or extension to expand your system's capabilities. There are no limitations. Best of all, I can give all of this knowledge away and encourage others to do the same. Isn't giving to others the spirit of holiday traditions?
### 5\. Stability
Linux is reliable and stable. The operating system does not crash. When you get updates, they don't require you to reboot while you're in the middle of doing something else. If you're using an older version of Fedora, Ubuntu, or Linux Mint and are happy with the status quo, you don't have to upgrade. Linux also offers more support for drivers of legacy printers and other peripherals than other operating systems.
### How to give Linux
Linux could be the best present your friends ever receive. Instead of buying holiday gifts from your favorite retailer, buy some 8GB or 16GB USB drives, download your favorite distribution, and [make some bootable USB][13] drives to give away. Volunteer your time (or include instructions) to help your friends to explore the "live" editions of these distributions before they install the operating system. Or, if you have an old, unused laptop or desktop, consider installing Linux and loaning it out for training purposes. Most of your friends will have no idea what a wonderful gift you are giving them—in the process, you will discover the joy of giving yourself to others.
If you really want to buy a new computer, this year I recommend you look at [System 76][14] or Dell's [XPS Developer][15] edition. If you don't want a new model, there are plenty of great offerings on [eBay][16], [DellRefurbished.com][17], and other sites that sell good-quality older laptops that are great candidates for an easy Linux install.
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/12/reasons-give-linux-holidays
作者:[Don Watkins][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/don-watkins
[b]: https://github.com/lujun9972
[1]: https://getfedora.org/
[2]: https://www.ubuntu.com/
[3]: https://system76.com/pop
[4]: https://linuxmint.com/
[5]: https://www.raspbian.org/
[6]: https://www.gnome.org/
[7]: https://www.kde.org/
[8]: https://lxde.org/
[9]: https://www.libreoffice.org/
[10]: https://www.gnucash.org/
[11]: https://www.clamav.net/
[12]: http://rkhunter.sourceforge.net/
[13]: https://opensource.com/article/18/7/getting-started-etcherio
[14]: https://system76.com/
[15]: https://www.dell.com/en-us/work/shop/dell-laptops-and-notebooks/xps-13-developer-edition/spd/xps-13-9370-laptop?appliedRefinements=302
[16]: https://www.ebay.com/b/Computers-Tablets-Network-Hardware/58058/bn_1865247
[17]: http://DellRefurbished.com

View File

@ -0,0 +1,81 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: subject: (F-Words in Linux Kernel Code Replaced with "Hug"?)
[#]: via: (https://itsfoss.com/swear-words-linux-kernel/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
[#]: url: ( )
F-Words in Linux Kernel Code Replaced with "Hug"?
======
**Brief: To comply with the new code of conduct, a developer from Intel proposes to replace F-words in the Linux kernel code with “hug”.**
![Polite Linus Torvalds after Code of Conduct][1]
Change is in air for the Linux Kernel Community.
Ever since the introduction of the [Linux code of conduct][2], things are going in a polite direction.
To refresh your memory, a few months back a new code of conduct was introduced for the Linux kernel developers. This code of conduct asks the developers to be nice and welcoming to other developers and be more open to diversity.
The new code of conduct caused a huge controversy as many Linux users and developers saw it as a conspiracy by Social Justice Warriors (SJW) to infiltrate Linux. The rumors were especially boosted by the [controversial past of the Contributor Covenant creator Coraline Ada Ehmke][2]. The Linux code of conduct is based on the same Contributor Covenant.
Right after signing the new code of conduct, Linux creator [Linus Torvalds took a month-long break to improve his behavior][3].
Torvalds who is known for being ruthless against poor code is a changed man now. After [coming back from the break][4], Torvalds controlled his rage and instead of lashing out against a developer, he replied nicely and pointed his mistake in a polite way.
### No more F-words in the Linux Kernel code?
There have been F-words in the Linux kernel code. To be clear, these F-words are in the code comments, not in the actual code.
You might expect that there will be way too many F-words in the 15+ millions of lines of Linux kernel code but thats not the case.
Jarkko Sakkinen from Intel pushed [these patches][5] that replace the F-words 33 times in the 3.3 million lines of code comments.
Interestingly, the patch email is titled “ **Zero ****s, hugload of hugs <3**“:
> In order to comply with the CoC, replace 选题模板.txt 中文排版指北.md core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LCTT翻译规范.md LICENSE published README.md scripts sources translated with a hug.
So now comments have become:
* Only Sun can take such nice parts and **hug** up the programming interface like this
* IOC3 is **hugging** **hugged** beyond belief
* **Hug** , we are miserable poor guys…
### Do you give a hug about these changes?
At this point, its not clear if this hugging patch has been accepted or not. Its more of an attempt to bring attention to profanity inside the kernel code.
So, we have to wait and watch if this patch sets a trend for removing offensive words from the Linux kernel code.
What do you think of it? Is using hug a good choice or do you have a better word for replacing the F-words?
And what do you think of these changes altogether. Do you think all these are unnecessary and futile exercises?
And when you comment, please replace your F-words with hugs :)
Story source: [Phoronix][6]
--------------------------------------------------------------------------------
via: https://itsfoss.com/swear-words-linux-kernel/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/abhishek/
[b]: https://github.com/lujun9972
[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/12/hug-you-linus-torvalds.jpeg?resize=800%2C450&ssl=1
[2]: https://itsfoss.com/linux-code-of-conduct/
[3]: https://itsfoss.com/torvalds-takes-a-break-from-linux/
[4]: https://itsfoss.com/torvalds-is-back/
[5]: https://lists.freedesktop.org/archives/dri-devel/2018-November/198581.html
[6]: https://www.phoronix.com/scan.php?page=news_item&px=Linux-Kernel-Hugs

View File

@ -0,0 +1,94 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (6 steps to optimize software delivery with value stream mapping)
[#]: via: (https://opensource.com/article/18/12/optimizing-delivery-value-stream-mapping)
[#]: author: (Dominika Bula https://opensource.com/users/dominika)
6 steps to optimize software delivery with value stream mapping
======
Learn how VSM can help you streamline processes, boost efficiency, and better meet customer expectations.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/checklist_hands_team_collaboration.png?itok=u82QepPk)
Do your efforts to improve software development fall short due to confusion and too much debate? Does your organization have a clear picture of what is achievable, and are you sure youre moving in the right direction? Can you determine how much business value you've delivered so far? Are the bottlenecks in your process known? Do you know how to optimize your current process?
If you are looking for a tool that will help you answer these questions, consider integrating [value stream mapping][1] and [lean concepts][2] into the way you deliver software.
### What is value stream mapping (VSM)?
Popularized in the 90s by James Womack and Daniel Jones, value stream mapping is a lean enterprise technique that is currently used by many organizations. In short, the value stream is the sequence of activities that are performed by the organization to deliver customer requests. Value stream mapping helps determine what is valuable and what doesnt bring value by identifying activities that matter to your customer. The ultimate benefit of using VSM is a better understanding of how to improve your current development process to generate more value and impact.
### 6 steps to optimizing software delivery
1. **Select the process**
Any process can be modeled as a sequence of activities. For example, a [system development life cycle][3] is a value stream consisting of product specification, design, development, deployment, operation and maintenance, and finally, disposition. In this example, product design can be viewed as a value stream segment.
2. **Identify the parties involved in the project**
Select a project sponsor and team. Keep in mind that each area of the process should be represented. Holistic thinking helps identify and set expectations, which in turn reduces resistance to change.
3. **Create the current state map**
Creating the current state map helps establish a better understanding of how work is currently done. Documenting your current process is key to success at this stage. The goal is to identify the specific items that flow through your value stream.
4. **Challenge the current thinking**
Make sure that what you are doing adds value—if there are actions in your process that do not add value, stop doing them. Look at the [software development waste types][2] for ideas. Mary Poppendieck and Tom Poppendieck identify these and transfer them from manufacturing to software engineering in their book, [Lean Software Development: An Agile Toolkit][4]. The waste types are:
* Partially done work
* Extra processes
* Extra features
* Task switching
* Waiting
* Motion
* Defects
* Management activities
5. **Generate the future state map and execute improvements**
Think of what can be done to reduce or ideally eliminate the identified wastes.
While working on the future state map, follow the principle that humans should do only what they can do best, and the rest should be [automated][5]. The future state design should aim to eliminate hands-on work and deliver completed software projects in less time with higher quality.
Talk about the changes, let people ask questions—this will help reduce resistance to change. As you start executing improvements, remember that value stream mapping is an evolutionary process, and you might need to adjust the original plan. The value stream should be continuously improved; it will not be perfect the first time.
6. ****Measure benefits****
Karen Martin and Mike Osterling identify key performance metrics for software delivery in their book, [Value Stream Mapping][6]:
* Total lead time: the total time it takes to deliver on a customer request
* Total process time: the total work effort required by all functions on the timeline critical path of the value stream
* Activity ratio: the degree of flow in the value stream
* Compounded effect: the quality of output across the value stream
Well-executed value stream mapping not only improves the way work gets delivered, but it also provides a transformational opportunity for your organization and a tool to facilitate a shift in mindsets and behaviors.
### What to read next
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/12/optimizing-delivery-value-stream-mapping
作者:[Dominika Bula][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/dominika
[b]: https://github.com/lujun9972
[1]: https://en.wikipedia.org/wiki/Value_stream_mapping
[2]: https://en.wikipedia.org/wiki/Lean_software_development
[3]: https://en.wikipedia.org/wiki/Systems_development_life_cycle
[4]: https://www.oreilly.com/library/view/lean-software-development/0321150783/
[5]: https://xkcd.com/1205/
[6]: https://mhebooklibrary.com/doi/book/10.1036/9780071828949

View File

@ -0,0 +1,316 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (YAML: probably not so great after all)
[#]: via: (https://arp242.net/weblog/yaml_probably_not_so_great_after_all.html)
[#]: author: (Martin Tournoij https://arp242.net/)
YAML: probably not so great after all
======
I previously wrote [why using JSON for human-editable configuration files is a bad idea][1]. Today were going to look at some general problems with the YAML format.
### Insecure by default
YAML is insecure by default. Loading a user-provided (untrusted) YAML string needs careful consideration.
```
!!python/object/apply:os.system
args: ['ls /']
```
Running it with `print(yaml.load(open('a.yaml')))` should give you something like:
```
bin etc lib lost+found opt root sbin tmp var sys
boot dev efi home lib64 mnt proc run srv usr
0
```
Many other languages (including Ruby and PHP) are also unsafe by default. [Searching for `yaml.load` on GitHub][2] gives a whopping 2.8 million results. [`yaml.safe_load`][3] only gives 26,000 results.
Mind you, many of those `yaml.load()`s are fine loading in a config file with `yaml.load()` is often okay since its usually (though not always!) from a trusted source, and many are from test files with static YAML. But still, one cant help but wonder how many exploits are hidden in those 2.8 million results.
This is not a theoretical problem. In 2013 [every Ruby on Rails application ever written was found to be vulnerable][4] to remote code execution due to exactly this problem.
One might argue this is not really the fault of the YAML format as such, but rather the fault of the libraries implementing it wrong, but it seems to be the case that the majority of libraries are unsafe by default (especially the dynamic languages), so de-facto it is a problem with YAML.
One might also argue that fixing it is as easy as replacing `load()` with `safe_load()`, but many people are unaware of the problem, and even if youre aware of it, its one of those things that can be easy to forget. Its pretty bad API design.
### Can be hard to edit, especially for large files
YAML files can be hard to edit, and this difficulty grows fast as the file gets larger.
A good example of this are Ruby on Rails translation files; for example:
```
en:
formtastic:
labels:
title: "Title" # Default global value
article:
body: "Article content"
post:
new:
title: "Choose a title..."
body: "Write something..."
edit:
title: "Edit title"
body: "Edit body"
```
This still looks okay, right? But what if this file has 100 lines? Or 1,000 lines? It is difficult to see “where” in the file you are because it may be off the screen. Youll need to scroll up, but then you need to keep track of the indentation, which can be pretty hard even with indentation guides, especially since 2-space indentation is the norm and [tab indentation is forbidden][5].
And accidentally getting the indentation wrong often isnt an error; it will often just deserialize to something you didnt intend. Happy debugging!
Ive been happily programming Python for over a decade, so Im used to significant whitespace, but sometimes Im still struggling with YAML. In Python the drawbacks and loss of clarity are contained by not having functions that are several pages long, but data or configuration files have no such natural limits to their length.
For small files this is not a problem; but it really doesnt scale well to larger files, especially not if you want to edit them later on.
### Its pretty complex
YAML may seem simple and obvious when glancing at a basic example, but turns out its not. The [YAML spec][6] is 23,449 words; for comparison, [TOML][7] is 3,339 words, [JSON][8] is 1,969 words, and [XML][9] is 20,603 words.
Who among us have read all that? Who among us have read and understood all of that? Who among of have read, understood, and **remembered** all of that?
For example did you know there are [nine ways to write a multi-line string in YAML][10] with subtly different behaviour?
Yeah :-/
That post gets even more interesting if you look at [its revision history][11], as the author of the post discovers more and more ways to do this and more of the subtleties involved.
Its telling that the YAML spec starts with a preview, which states (emphases mine):
> This section provides a quick glimpse into the expressive power of YAML. **It is not expected that the first-time reader grok all of the examples**. Rather, these selections are used as motivation for the remainder of the specification.
#### Surprising behaviour
What does this parse to (examples courtesy of [Colm OConnor][12]):
```
- Don Corleone: Do you have faith in my judgment?
- Clemenza: Yes
- Don Corleone: Do I have your loyalty?
```
Yup!
```
[
{'Don Corleone': 'Do you have faith in my judgment?'},
{'Clemenza': True},
{'Don Corleone': 'Do I have your loyalty?'}
]
```
Or what about:
```
python: 3.5.3
postgres: 9.3
```
`3.5.3` gets recognized as as string, but `9.3` gets recognized as a number instead of a string:
```
{'python': '3.5.3', 'postgres': 9.3}
```
Or what about:
```
Effenaar: Eindhoven
013: Tilburg
```
013 is a popular music Venue in Tilburg, but YAML will send you the wrong way since its parsed as an octal number:
```
{11: 'Tilburg', 'Effenaar': 'Eindhoven'}
```
All of this and more is why many experienced YAMLers will often quote all strings, even when its not strictly required. Many people dont use quotes, and it can be easy to forget especially if the rest of the file possibly written by other people doesnt use quotes.
#### Its not portable
Because its so complex, its claims of portability have been greatly exaggerated. For example consider this example taken from the YAML spec:
```
? - Detroit Tigers
- Chicago cubs
:
- 2001-07-23
? [ New York Yankees,
Atlanta Braves ]
: [ 2001-07-02, 2001-08-12,
2001-08-14 ]
```
Aside from the fact that most readers of this probably wont even know what this does, try parsing it in Python with PyYAML:
```
yaml.constructor.ConstructorError: while constructing a mapping
in "a.yaml", line 1, column 1
found unhashable key
in "a.yaml", line 1, column 3
```
In Ruby it works:
```
{
["Detroit Tigers", "Chicago cubs"] => [
#<Date: 2001-07-23 ((2452114j,0s,0n),+0s,2299161j)>
],
["New York Yankees", "Atlanta Braves"] => [
#<Date: 2001-07-02 ((2452093j,0s,0n),+0s,2299161j)>,
#<Date: 2001-08-12 ((2452134j,0s,0n),+0s,2299161j)>,
#<Date: 2001-08-14 ((2452136j,0s,0n),+0s,2299161j)>
]
}
```
The reason for this is because you cant use a list as a dict key in Python:
```
>>> {['a']: 'zxc'}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'
```
And this restriction is not unique to Python; common languages such as PHP, JavaScript, and Go all share this restriction.
So use this in a YAML file, and you wont be able to read it in most languages.
Heres another example again taken from the examples section of the YAML spec:
```
# Ranking of 1998 home runs
---
- Mark McGwire
- Sammy Sosa
- Ken Griffey
# Team ranking
---
- Chicago Cubs
- St Louis Cardinals
```
Python says:
```
yaml.composer.ComposerError: expected a single document in the stream
in "a.yaml", line 3, column 1
but found another document
in "a.yaml", line 8, column 1
```
While Ruby outputs:
```
["Mark McGwire", "Sammy Sosa", "Ken Griffey"]
```
The reason for this is that there are multiple YAML documents in a single file (`---` start the document). In Python there is the `load_all()` function to parse all documents. Rubys `load()` just loads the first document, and as near as I can tell, doesnt have a way to load multiple documents.
There are [many more incompatibilities between implementations][13].
### Goals achieved?
The spec states:
> The design goals for YAML are, in decreasing priority:
>
> 1. YAML is easily readable by humans.
> 2. YAML data is portable between programming languages.
> 3. YAML matches the native data structures of agile languages.
> 4. YAML has a consistent model to support generic tools.
> 5. YAML supports one-pass processing.
> 6. YAML is expressive and extensible.
> 7. YAML is easy to implement and use.
>
So how well does it do?
> YAML is easily readable by humans.
True only if you stick to a small subset. The full set is complex much more so than XML or JSON.
> YAML data is portable between programming languages.
Not really true, as its too easy to create constructs that are not supported by common languages.
> YAML matches the native data structures of agile languages.
See above. Plus, why only support agile (or dynamic) languages? What about other languages?
> YAML has a consistent model to support generic tools.
I am not even sure what this means and I cant find any elaboration.
> YAML supports one-pass processing.
Ill take their word for it.
> YAML is expressive and extensible.
Well, it is, but its too expressive (e.g. too complex).
> YAML is easy to implement and use.
```
$ cat `ls -1 ~/gocode/src/github.com/go-yaml/yaml/*.go | grep -v _test` | wc -l
9247
$ cat /usr/lib/python3.5/site-packages/yaml/*.py | wc -l
5713
```
### Conclusion
Dont get me wrong, its not like YAML is absolutely terrible its certainly not as [problematic as using JSON][1] but its not exactly great either. There are some drawbacks and surprises that are not at all obvious at first, and there are a number of better alternatives such as [TOML][7] and other more specialized formats.
Personally, Im not likely to use it again when Ive got a choice.
If you must use YAML then I recommend you use [StrictYAML][14], which removes some (though not all) of the more hairy parts.
### Feedback
You can mail me at [martin@arp242.net][15] or [create a GitHub issue][16] for feedback, questions, etc.
--------------------------------------------------------------------------------
via: https://arp242.net/weblog/yaml_probably_not_so_great_after_all.html
作者:[Martin Tournoij][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://arp242.net/
[b]: https://github.com/lujun9972
[1]: http://arp242.net/weblog/JSON_as_configuration_files-_please_dont.html
[2]: https://github.com/search?q=yaml.load&type=Code&utf8=%E2%9C%93
[3]: https://github.com/search?q=yaml.safe_load&type=Code&utf8=%E2%9C%93
[4]: https://www.sitepoint.com/anatomy-of-an-exploit-an-in-depth-look-at-the-rails-yaml-vulnerability/
[5]: http://www.yaml.org/faq.html
[6]: http://yaml.org/spec/1.2/spec.pdf
[7]: https://github.com/toml-lang/toml
[8]: http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf
[9]: https://www.w3.org/TR/REC-xml/
[10]: http://stackoverflow.com/a/21699210/660921
[11]: http://stackoverflow.com/posts/21699210/revisions
[12]: https://github.com/crdoconnor/strictyaml/blob/master/FAQ.rst#what-is-wrong-with-implicit-typing
[13]: https://github.com/cblp/yaml-sucks
[14]: https://github.com/crdoconnor/strictyaml
[15]: mailto:martin@arp242.net
[16]: https://github.com/Carpetsmoker/arp242.net/issues/new

View File

@ -1,236 +0,0 @@
Manage your workstation with Ansible: Automating configuration Translating By FelixYFZ
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/robot_arm_artificial_ai.png?itok=8CUU3U_7)
Ansible is an amazing automation and configuration management tool. It is mainly used for servers and cloud deployments, and it gets far less attention for its use in workstations, both desktops and laptops, which is the focus of this series.
In the [first part][1] of this series, I showed you basic usage of the `ansible-pull` command, and we created a playbook that installs a handful of packages. That wasn't extremely useful by itself, but it set the stage for further automation.
In this article, everything comes together full circle, and by the end we will have a fully working solution for automating workstation configuration. This time, we'll set up our Ansible configuration such that future changes we make will automatically be applied to our workstations. At this point, I'm assuming you already worked through part one. If you haven't, feel free to do that now and then return to this article when you're done. You should already have a GitHub repository with the code from the first article inside it. We're going to build directly on what we did before.
First, we need to do some reorganization because we're going to do more than just install packages. At this point, we currently have a playbook named `local.yml` with the following content:
```
- hosts: localhost
  become: true
  tasks:
  - name: Install packages
    apt: name={{item}}
    with_items:
      - htop
      - mc
      - tmux
```
That's all well and good if we only want to perform one task. As we add new things to our configuration, this file will become quite large and get very cluttered. It's better to organize our plays into individual files with each responsible for a different type of configuration. To achieve this, create what's called a taskbook, which is very much like a playbook but the contents are more streamlined. Let's create a directory for our taskbooks inside our Git repository:
```
mkdir tasks
```
The code inside our current `local.yml` playbook lends itself well to become a taskbook for installing packages. Let's move this file into the `tasks` directory we just created with a new name:
```
mv local.yml tasks/packages.yml
```
Now, we can edit our `packages.yml` taskbook and strip it down quite a bit. In fact, we can strip everything except for the individual task itself. Let's make `packages.yml` look like this:
```
- name: Install packages
  apt: name={{item}}
  with_items:
    - htop
    - mc
    - tmux
```
As you can see, it uses the same syntax, but we stripped out everything that isn't necessary to the task it's performing. Now we have a dedicated taskbook for installing packages. However, we still need a file named `local.yml`, since `ansible-pull` still expects to find a file with that name. So we'll create a fresh one with this content in the root of our repository (not in the `tasks` directory):
```
- hosts: localhost
  become: true
  pre_tasks:
    - name: update repositories
      apt: update_cache=yes
      changed_when: False
  tasks:
    - include: tasks/packages.yml
```
This new `local.yml` acts as an index that will import all our taskbooks. I've added a few new things to this file that you haven't seen yet in this series. First, at the beginning of the file, I added `pre_tasks`, which allows us to have Ansible perform a task before all the other tasks run. In this case, we're telling Ansible to update our distribution's repository index. This line does that for us:
```
apt: update_cache=yes
```
Normally the `apt` module allows us to install packages, but we can also tell it to update our repository index. The idea is that we want all our individual plays to work with a fresh index each time Ansible runs. This will help ensure we don't have an issue with a stale index while attempting to install a package. Note that the `apt` module works only with Debian, Ubuntu, and their derivatives. If you're running a different distribution, you'll want to use a module specific to your distribution rather than `apt`. See the documentation for Ansible if you need to use a different module.
The following line is also worth further explanation:
```
changed_when: False
```
This line on an individual task stops Ansible from reporting the results of the play as changed even when it results in a change in the system. In this case, we don't care if the repository index contains new data; it almost always will, since repositories are always changing. We don't care about changes to `apt` repositories, as index changes are par for the course. If we omit this line, we'll see the summary at the end of the process report that something has changed, even if it was merely about the repository being updated. It's better to ignore these types of changes.
Next is our normal tasks section, and we import the taskbook we created. Each time we add another taskbook, we add another line here:
```
tasks:
  - include: tasks/packages.yml
```
If you were to run the `ansible-pull` command here, it should essentially do the same thing as it did in the last article. The difference is that we have improved our organization and we can more efficiently expand on it. The `ansible-pull` command syntax, to save you from finding the previous article, is this:
```
sudo ansible-pull -U https://github.com/<github_user>/ansible.git
```
If you recall, the `ansible-pull` command pulls down a Git repository and applies the configuration it contains.
Now that our foundation is in place, we can expand upon our Ansible config and add features. Specifically, we'll add configuration to automate the deployment of future changes to our workstations. To support this goal, the first thing we should do is to create a user specifically to apply our Ansible configuration. This isn't required—we can continue to run our Ansible configuration under our own user. But using a separate user segregates this to a system process that will run in the background, without our involvement.
We could create this user with the normal method, but since we're using Ansible, we should shy away from manual changes. Instead, we'll create a taskbook to handle user creation. This taskbook will create just one user for now, but you can always add additional plays to this taskbook to add additional users. I'll call this user `ansible`, but you can name it something else if you wish (if you do, make sure to update all occurrences). Let's create a taskbook named `users.yml` and place this code inside of it:
```
- name: create ansible user
  user: name=ansible uid=900
```
Next, we need to edit our `local.yml` file and append this new taskbook to the file, so it will look like this:
```
- hosts: localhost
  become: true
  pre_tasks:
    - name: update repositories
      apt: update_cache=yes
      changed_when: False
  tasks:
    - include: tasks/users.yml
    - include: tasks/packages.yml
```
Now when we run our `ansible-pull` command, a user named `ansible` will be created on the system. Note that I specifically declared `User ID 900` for this user by using the `UID` option. This isn't required, but it's recommended. The reason is that UIDs under 1,000 are typically not shown on the login screen, which is great because there's no reason we would need to log into a desktop session as our `ansible` user. UID 900 is arbitrary; it should be any number under 1,000 that's not already in use. You can find out if UID 900 is in use on your system with the following command:
```
cat /etc/passwd |grep 900
```
However, you shouldn't run into a problem with this UID because I've never seen it used by default in any distribution I've used so far.
Now, we have an `ansible` user that will later be used to apply our Ansible configuration automatically. Next, we can create the actual cron job that will be used to automate this. Rather than place this in the `users.yml` taskbook we just created, we should separate this into its own file. Create a taskbook named `cron.yml` in the tasks directory and place the following code inside:
```
- name: install cron job (ansible-pull)
  cron: user="ansible" name="ansible provision" minute="*/10" job="/usr/bin/ansible-pull -o -U https://github.com/<github_user>/ansible.git > /dev/null"
```
The syntax for the cron module should be fairly self-explanatory. With this play, we're creating a cron job to be run as the `ansible` user. The job will execute every 10 minutes, and the command it will execute is this:
```
/usr/bin/ansible-pull -o -U https://github.com/<github_user>/ansible.git > /dev/null
```
Also, we can put additional cron jobs we want all our workstations to have into this one file. We just need to add additional plays to add new cron jobs. However, simply adding a new taskbook for cron isn't enough—we'll also need to add it to our `local.yml` file so it will be called. Place the following line with the other includes:
```
- include: tasks/cron.yml
```
Now when `ansible-pull` is run, it will set up a new cron job that will be run as the `ansible` user every 10 minutes. But, having an Ansible job running every 10 minutes isn't ideal because it will take considerable CPU power. It really doesn't make sense for Ansible to run every 10 minutes unless we've changed something in the Git repository.
However, we've already solved this problem. Notice the `-o` option I added to the `ansible-pull` command in the cron job that we've never used before. This option tells Ansible to run only if the repository has changed since the last time `ansible-pull` was called. If the repository hasn't changed, it won't do anything. This way, you're not wasting valuable CPU for no reason. Sure, some CPU will be used when it pulls down the repository, but not nearly as much as it would use if it were applying your entire configuration all over again. When `ansible-pull` does run, it will go through all the tasks in the Playbook and taskbooks, but at least it won't run for no purpose.
Although we've added all the required components to automate `ansible-pull`, it actually won't work properly yet. The `ansible-pull` command will run with `sudo`, which would give it access to perform system-level commands. However, our `ansible` user is not set up to perform tasks as `sudo`. Therefore, when the cron job triggers, it will fail. Normally we could just use `visudo` and manually set the `ansible` user up to have this access. However, we should do things the Ansible way from now on, and this is a great opportunity to show you how the `copy` module works. The `copy` module allows you to copy a file from your Ansible repository to somewhere else in the filesystem. In our case, we'll copy a config file for `sudo` to `/etc/sudoers.d/` so that the `ansible` user can perform administrative tasks.
Open up the `users.yml` taskbook, and add the following play to the bottom:
```
- name: copy sudoers_ansible
  copy: src=files/sudoers_ansible dest=/etc/sudoers.d/ansible owner=root group=root mode=0440
```
The `copy` module, as we can see, copies a file from our repository to somewhere else. In this case, we're grabbing a file named `sudoers_ansible` (which we will create shortly) and copying it to `/etc/sudoers.d/ansible` with `root` as the owner.
Next, we need to create the file that we'll be copying. In the root of your Ansible repository, create a `files` directory:
```
mkdir files
```
Then, in the `files` directory we just created, create the `sudoers_ansible` file with the following content:
```
ansible ALL=(ALL) NOPASSWD: ALL
```
Creating a file in `/etc/sudoers.d`, like we're doing here, allows us to configure `sudo` for a specific user. Here we're allowing the `ansible` user full access to the system via `sudo` without a password prompt. This will allow `ansible-pull` to run as a background task without us needing to run it manually.
Now, you can run `ansible-pull` again to pull down the latest changes:
```
sudo ansible-pull -U https://github.com/<github_user>/ansible.git
```
From this point forward, the cron job for `ansible-pull` will run every 10 minutes in the background and check your repository for changes. If it finds changes, it will run your playbook and apply your taskbooks.
So now we have a fully working solution. When you first set up a new laptop or desktop, you'll run the `ansible-pull` command manually, but only the first time. From that point forward, the `ansible` user will take care of subsequent runs in the background. When you want to make a change to your workstation machines, you simply pull down your Git repository, make the changes, then push those changes back to the repository. Then, the next time the cron job fires on each machine, it will pull down those changes and apply them. You now only have to make changes once, and all your workstations will follow suit. This method may be a bit unconventional though. Normally, you'd have an `inventory` file with your machines listed and several roles each machine could be a member of. However, the `ansible-pull` method, as described in this article, is a very efficient way of managing workstation configuration.
I have updated the code in my [GitHub repository][2] for this article, so feel free to browse the code there and check your syntax against mine. Also, I moved the code from the previous article into its own directory in that repository.
In part 3, we'll close out the series by using Ansible to configure GNOME desktop settings. I'll show you how to set your wallpaper and lock screen, apply a desktop theme, and more.
In the meantime, it's time for a little homework assignment. Most of us have configuration files we like to maintain for various applications we use. This could be configuration files for Bash, Vim, or whatever tools you use. I challenge you now to automate copying these configuration files to your machines via the Ansible repository we've been working on. In this article, I've shown you how to copy a file, so take a look at that and see if you can apply that knowledge to your personal files.
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/3/manage-your-workstation-configuration-ansible-part-2
作者:[Jay LaCroix][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
选题:[lujun9972](https://github.com/lujun9972)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/jlacroix
[1]:https://opensource.com/article/18/3/manage-workstation-ansible
[2]:https://github.com/jlacroix82/ansible_article.git

View File

@ -0,0 +1,291 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Manage NTP with Chrony)
[#]: via: (https://opensource.com/article/18/12/manage-ntp-chrony)
[#]: author: (David Both https://opensource.com/users/dboth)
Manage NTP with Chrony
======
Chronyd is a better choice for most networks than ntpd for keeping computers synchronized with the Network Time Protocol.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/clocks_time.png?itok=_ID09GDk)
> "Does anybody really know what time it is? Does anybody really care?"
> [Chicago][1], 1969
Perhaps that rock group didn't care what time it was, but our computers do need to know the exact time. Timekeeping is very important to computer networks. In banking, stock markets, and other financial businesses, transactions must be maintained in the proper order, and exact time sequences are critical for that. For sysadmins and DevOps professionals, it's easier to follow the trail of email through a series of servers or to determine the exact sequence of events using log files on geographically dispersed hosts when exact times are kept on the computers in question.
I used to work at an organization that received over 20 million emails per day and had four servers just to accept and do a basic filter on the incoming flood of email. From there, emails were sent to one of four other servers to perform more complex anti-spam assessments, then they were delivered to one of several additional servers where the emails were placed in the correct inboxes. At each layer, the emails would be sent to one of the next-level servers, selected only by the randomness of round-robin DNS. Sometimes we had to trace a new message through the system until we could determine where it "got lost," according to the pointy-haired bosses. We had to do this with frightening regularity.
Most of that email turned out to be spam. Some people actually complained that their [joke, cat pic, recipe, inspirational saying, or other-strange-email]-of-the-day was missing and asked us to find it. We did reject those opportunities.
Our email and other transactional searches were aided by log entries with timestamps that—today—can resolve down to the nanosecond in even the slowest of modern Linux computers. In very high-volume transaction environments, even a few microseconds of difference in the system clocks can mean sorting thousands of transactions to find the correct one(s).
### The NTP server hierarchy
Computers worldwide use the [Network Time Protocol][2] (NTP) to synchronize their times with internet standard reference clocks via a hierarchy of NTP servers. The primary servers are at stratum 1, and they are connected directly to various national time services at stratum 0 via satellite, radio, or even modems over phone lines. The time service at stratum 0 may be an atomic clock, a radio receiver tuned to the signals broadcast by an atomic clock, or a GPS receiver using the highly accurate clock signals broadcast by GPS satellites.
To prevent time requests from time servers lower in the hierarchy (i.e., with a higher stratum number) from overwhelming the primary reference servers, there are several thousand public NTP stratum 2 servers that are open and available for anyone to use. Many organizations with large numbers of hosts that need an NTP server will set up their own time servers so that only one local host accesses the stratum 2 time servers, then they configure the remaining network hosts to use the local time server which, in my case, is a stratum 3 server.
### NTP choices
The original NTP daemon, **ntpd** , has been joined by a newer one, **chronyd**. Both keep the local host's time synchronized with the time server. Both services are available, and I have seen nothing to indicate that this will change anytime soon.
Chrony has features that make it the better choice for most environments for the following reasons:
* Chrony can synchronize to the time server much faster than NTP. This is good for laptops or desktops that don't run constantly.
* It can compensate for fluctuating clock frequencies, such as when a host hibernates or enters sleep mode, or when the clock speed varies due to frequency stepping that slows clock speeds when loads are low.
* It handles intermittent network connections and bandwidth saturation.
* It adjusts for network delays and latency.
* After the initial time sync, Chrony never steps the clock. This ensures stable and consistent time intervals for system services and applications.
* Chrony can work even without a network connection. In this case, the local host or server can be updated manually.
The NTP and Chrony RPM packages are available from standard Fedora repositories. You can install both and switch between them, but modern Fedora, CentOS, and RHEL releases have moved from NTP to Chrony as their default time-keeping implementation. I have found that Chrony works well, provides a better interface for the sysadmin, presents much more information, and increases control.
Just to make it clear, NTP is a protocol that is implemented with either NTP or Chrony. If you'd like to know more, read this [comparison between NTP and Chrony][3] as implementations of the NTP protocol.
This article explains how to configure Chrony clients and servers on a Fedora host, but the configuration for CentOS and RHEL current releases works the same.
### Chrony structure
The Chrony daemon, **chronyd** , runs in the background and monitors the time and status of the time server specified in the **chrony.conf** file. If the local time needs to be adjusted, **chronyd** does it smoothly without the programmatic trauma that would occur if the clock were instantly reset to a new time.
Chrony's **chronyc** tool allows someone to monitor the current status of Chrony and make changes if necessary. The **chronyc** utility can be used as a command that accepts subcommands, or it can be used as an interactive text-mode program. This article will explain both uses.
### Client configuration
The NTP client configuration is simple and requires little or no intervention. The NTP server can be defined during the Linux installation or provided by the DHCP server at boot time. The default **/etc/chrony.conf** file (shown below in its entirety) requires no intervention to work properly as a client. For Fedora, Chrony uses the Fedora NTP pool, and CentOS and RHEL have their own NTP server pools. Like many Red Hat-based distributions, the configuration file is well commented.
```
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
pool 2.fedora.pool.ntp.org iburst
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# Allow NTP client access from local network.
#allow 192.168.0.0/16
# Serve time even if not synchronized to a time source.
#local stratum 10
# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys
# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
```
Let's look at the current status of NTP on a virtual machine I use for testing. The **chronyc** command, when used with the **tracking** subcommand, provides statistics that report how far off the local system is from the reference server.
```
[root@studentvm1 ~]# chronyc tracking
Reference ID    : 23ABED4D (ec2-35-171-237-77.compute-1.amazonaws.com)
Stratum         : 3
Ref time (UTC)  : Fri Nov 16 16:21:30 2018
System time     : 0.000645622 seconds slow of NTP time
Last offset     : -0.000308577 seconds
RMS offset      : 0.000786140 seconds
Frequency       : 0.147 ppm slow
Residual freq   : -0.073 ppm
Skew            : 0.062 ppm
Root delay      : 0.041452706 seconds
Root dispersion : 0.022665167 seconds
Update interval : 1044.2 seconds
Leap status     : Normal
[root@studentvm1 ~]#
```
The Reference ID in the first line of the result is the server the host is synchronized to—in this case, a stratum 3 reference server that was last contacted by the host at 16:21:30 2018. The other lines are described in the [chronyc(1) man page][4].
The **sources** subcommand is also useful because it provides information about the time source configured in **chrony.conf**.
```
[root@studentvm1 ~]# chronyc sources
210 Number of sources = 5
MS Name/IP address         Stratum Poll Reach LastRx Last sample              
===============================================================================
^+ 192.168.0.51                  3   6   377     0  -2613us[-2613us] +/-   63ms
^+ dev.smatwebdesign.com         3  10   377   28m  -2961us[-3534us] +/-  113ms
^+ propjet.latt.net              2  10   377   465  -1097us[-1085us] +/-   77ms
^* ec2-35-171-237-77.comput>     2  10   377    83  +2388us[+2395us] +/-   95ms
^+ PBX.cytranet.net              3  10   377   507  -1602us[-1589us] +/-   96ms
[root@studentvm1 ~]#
```
The first source in the list is the time server I set up for my personal network. The others were provided by the pool. Even though my NTP server doesn't appear in the Chrony configuration file above, my DHCP server provides its IP address for the NTP server. The "S" column—Source State—indicates with an asterisk ( ***** ) the server our host is synced to. This is consistent with the data from the **tracking** subcommand.
The **-v** option provides a nice description of the fields in this output.
```
[root@studentvm1 ~]# chronyc sources -v
210 Number of sources = 5
  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample              
===============================================================================
^+ 192.168.0.51                  3   7   377    28  -2156us[-2156us] +/-   63ms
^+ triton.ellipse.net            2  10   377    24  +5716us[+5716us] +/-   62ms
^+ lithium.constant.com          2  10   377   351   -820us[ -820us] +/-   64ms
^* t2.time.bf1.yahoo.com         2  10   377   453   -992us[ -965us] +/-   46ms
^- ntp.idealab.com               2  10   377   799  +3653us[+3674us] +/-   87ms
[root@studentvm1 ~]#
```
If I wanted my server to be the preferred reference time source for this host, I would add the line below to the **/etc/chrony.conf** file.
```
server 192.168.0.51 iburst prefer
```
I usually place this line just above the first pool server statement near the top of the file. There is no special reason for this, except I like to keep the server statements together. It would work just as well at the bottom of the file, and I have done that on several hosts. This configuration file is not sequence-sensitive.
The **prefer** option marks this as the preferred reference source. As such, this host will always be synchronized with this reference source (as long as it is available). We can also use the fully qualified hostname for a remote reference server or the hostname only (without the domain name) for a local reference time source as long as the search statement is set in the **/etc/resolv.conf** file. I prefer the IP address to ensure that the time source is accessible even if DNS is not working. In most environments, the server name is probably the better option, because NTP will continue to work even if the server's IP address changes.
If you don't have a specific reference source you want to synchronize to, it is fine to use the defaults.
### Configuring an NTP server with Chrony
The nice thing about the Chrony configuration file is that this single file configures the host as both a client and a server. To add a server function to our host—it will always be a client, obtaining its time from a reference server—we just need to make a couple of changes to the Chrony configuration, then configure the host's firewall to accept NTP requests.
Open the **/etc/ ** **chrony****.conf** file in your favorite text editor and uncomment the **local stratum 10** line. This enables the Chrony NTP server to continue to act as if it were connected to a remote reference server if the internet connection fails; this enables the host to continue to be an NTP server to other hosts on the local network.
Let's restart **chronyd** and track how the service is working for a few minutes. Before we enable our host as an NTP server, we want to test a bit.
```
[root@studentvm1 ~]# systemctl restart chronyd ; watch chronyc tracking
```
The results should look like this. The **watch** command runs the **chronyc tracking** command every two seconds so we can watch changes occur over time.
```
Every 2.0s: chronyc tracking                                           studentvm1: Fri Nov 16 20:59:31 2018
Reference ID    : C0A80033 (192.168.0.51)
Stratum         : 4
Ref time (UTC)  : Sat Nov 17 01:58:51 2018
System time     : 0.001598277 seconds fast of NTP time
Last offset     : +0.001791533 seconds
RMS offset      : 0.001791533 seconds
Frequency       : 0.546 ppm slow
Residual freq   : -0.175 ppm
Skew            : 0.168 ppm
Root delay      : 0.094823152 seconds
Root dispersion : 0.021242738 seconds
Update interval : 65.0 seconds
Leap status     : Normal
```
Notice that my NTP server, the **studentvm1** host, synchronizes to the host at 192.168.0.51, which is my internal network NTP server, at stratum 4. Synchronizing directly to the Fedora pool machines would result in synchronization at stratum 3. Notice also that the amount of error decreases over time. Eventually, it should stabilize with a tiny variation around a fairly small range of error. The size of the error depends upon the stratum and other network factors. After a few minutes, use Ctrl+C to break out of the watch loop.
To turn our host into an NTP server, we need to allow it to listen on the local network. Uncomment the following line to allow hosts on the local network to access our NTP server.
```
# Allow NTP client access from local network.
allow 192.168.0.0/16
```
Note that the server can listen for requests on any local network it's attached to. The IP address in the "allow" line is just intended for illustrative purposes. Be sure to change the IP network and subnet mask in that line to match your local network's.
Restart **chronyd**.
```
[root@studentvm1 ~]# systemctl restart chronyd
```
To allow other hosts on your network to access this server, configure the firewall to allow inbound UDP packets on port 123. Check your firewall's documentation to find out how to do that.
### Testing
Your host is now an NTP server. You can test it with another host or a VM that has access to the network on which the NTP server is listening. Configure the client to use the new NTP server as the preferred server in the **/etc/chrony.conf** file, then monitor that client using the **chronyc** tools we used above.
### Chronyc as an interactive tool
As I mentioned earlier, **chronyc** can be used as an interactive command tool. Simply run the command without a subcommand and you get a **chronyc** command prompt.
```
[root@studentvm1 ~]# chronyc
chrony version 3.4
Copyright (C) 1997-2003, 2007, 2009-2018 Richard P. Curnow and others
chrony comes with ABSOLUTELY NO WARRANTY.  This is free software, and
you are welcome to redistribute it under certain conditions.  See the
GNU General Public License version 2 for details.
chronyc>
```
You can enter just the subcommands at this prompt. Try using the **tracking** , **ntpdata** , and **sources** commands. The **chronyc** command line allows command recall and editing for **chronyc** subcommands. You can use the **help** subcommand to get a list of possible commands and their syntax.
### Conclusion
Chrony is a powerful tool for synchronizing the times of client hosts, whether they are all on the local network or scattered around the globe. It's easy to configure because, despite the large number of options available, only a few configurations are required for most circumstances.
After my client computers have synchronized with the NTP server, I like to set the system hardware clock from the system (OS) time by using the following command:
```
/sbin/hwclock --systohc
```
This command can be added as a cron job or a script in **cron.daily** to keep the hardware clock synced with the system time.
Chrony and NTP (the service) both use the same configuration, and the files' contents are interchangeable. The man pages for [chronyd][5], [chronyc][4], and [chrony.conf][6] contain an amazing amount of information that can help you get started or learn about esoteric configuration options.
Do you run your own NTP server? Let us know in the comments and be sure to tell us which implementation you are using, NTP or Chrony.
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/12/manage-ntp-chrony
作者:[David Both][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/dboth
[b]: https://github.com/lujun9972
[1]: https://en.wikipedia.org/wiki/Does_Anybody_Really_Know_What_Time_It_Is%3F
[2]: https://en.wikipedia.org/wiki/Network_Time_Protocol
[3]: https://chrony.tuxfamily.org/comparison.html
[4]: https://linux.die.net/man/1/chronyc
[5]: https://linux.die.net/man/8/chronyd
[6]: https://linux.die.net/man/5/chrony.conf

View File

@ -0,0 +1,191 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (My Google-free Android life)
[#]: via: (https://lushka.al/my-android-setup/)
[#]: author: (Anxhelo Lushka https://lushka.al/)
My Google-free Android life
======
People have been asking me a lot lately about my phone, my Android setup and how I manage to use my smartphone without Google Services. Well, this is a post that aims to address precisely that. I would like to make this article really beginner-friendly so Ill try to go slow, going through things one by one and including screenshots so you can have a better view on how things happen and work like.
At first Ill start with why Google Services are (imo) bad for your device. I could cut it short and guide you to this [post][1] by [Richard Stallman][2], but Im grabbing a few main points from it and adding them here.
* Nonfree software required
* In general, most Google services require running nonfree Javascript code. Nowadays, nothing whatsoever appears if Javascript is disabled, even making a Google account requires running nonfree software (Javascript sent by the site), same thing for logging in.
* Surveillance
* Google quietly combines its ad-tracking profiles with its browsing profiles and stores a huge amount of data on each user.
* Terms of Service
* Google cuts off accounts for users that resell Pixel phones. They lose access to all of their mail and documents stored in Google servers under that account.
* Censorship
* Amazon and Google have cut off domain-fronting, a feature used to enable people in tyrannical countries to reach communication systems that are banned there.
* Google has agreed to perform special censorship of Youtube for the government of Pakistan, deleting views that the state opposes. This will help the illiberal Pakistani state suppress dissent.
* Youtubes “content ID” automatically deletes posted videos in a way copyright law does not require.
These are just a few reasons, but you can read the post by RMS I linked above in which he tries to explain these points in detail. Although it may look like a tinfoil hat reaction to you, all these actions already happen everyday in real life.
### Next on the list, my setup and a tutorial on how I achieved it
I own a **[Xiaomi Redmi Note 5 Pro][3]** smartphone (codename **whyred** ), produced in China by [Xiaomi][4], which I bought for around 185 EUR 4 months ago (from the time of writing this post).
Now you might be thinking, but why did you buy a Chinese brand, they are not reliable. Yes, it is not made from the usuals as you would expect, such as Samsung (which people often associate with Android, which is plain wrong), OnePlus, Nokia etc, but you should know almost every phone is produced in China.
There were a few reasons I chose this phone, first one of course being the price. It is a quite **budget-friendly** device, so most people are able to afford it. Next one would be the specs, which on paper (not only) are pretty decents for the price tag. With a 6 inch screen (Full HD resolution), a **4000 mAh battery** (superb battery life), 4GB of RAM, 64GB of storage, dual back cameras (12MP + 5MP), a front camera with flash (13MP) and a decent efficient Snapdragon 636, it was probably the best choice at that moment.
The issue with it was that it came with [MIUI][5], the Android skin that Xiaomi ships with most of its devices (except the Android One project devices). Yes, it is not that horrible, it has some extra features, but the problems lie deeper within. One of the reasons these devices from Xiaomi are so cheap (afaik they only have 5-10% win margin from sales) is that **they include data mining and ads in the system altogether with MIUI**. In this way, the system apps requires extra unnecessary permissions that mine your data and bombard you with ads, from which Xiaomi earns money.
Funnily enough, the Weather app included wanted access to my contacts and to make calls, why would it need that if it would just show the weather? Another case was with the Recorder app, it also required contacts and internet permissions, probably to send those recordings back to Xiaomi.
To fix this, Id have to format the phone and get rid of MIUI. This has become increasingly difficult with the latest phones in the market.
The concept of formatting a phone is simple, you remove the existing system and install a new one of your preference (Android-only in this case). To do that, you have to have your [bootloader][6] unlocked.
> A bootloader is a computer program that loads an operating system (OS) or runtime environment for the computer after completion of the self-tests. — [Wikipedia][7]
The problem here is that Xiaomi has a specific policy about the bootloader unlocking. A few months ago, the process was like this. You would have to [make a request][8] to Xiaomi to obtain an unlock code for your phone, by giving a valid reason, but this would not always work, as they could just refuse your request without reason and explanation.
Now, that process has changed. Youll have to download a specific software from Xiaomi, called [Mi Unlock][9], install it in your Windows PC, [activate Debugging Settings in Developer Options][10] on your phone, reboot to the bootloader mode (by holding the Volume Down + Power button while the phone is off) and connect the phone to your computer to start a process called “Approval”. This process starts a timer on the Xiaomi servers that will allow you to **unlock the phone only after a period of 15 days** (or a month in some rare cases, totally random) goes by.
![Mi Unlock app][11]
After this period of 15 days has passed, you have to re-connect your phone and do the same procedure as above, then by pressing the Unlock button your bootloader will be unlocked and this will allow you to install other ROM-s (systems). **Careful, make sure to backup your data because unlocking the bootloader deletes everything in the phone**.
The next step would be finding a system ([ROM][12]) that works for your device. I searched through the [XDA Developers Forum][13], which is a place where Android developers and users exchange ideas, apps etc. Fortunately, my phone is quite popular so it had [its own forum category][14]. There, I skimmed through some popular ROM-s for my device and decided to use the [AOSiP ROM][15] (AOSiP standing for Android Open Source illusion Project).
**EDIT** : Someone emailed me to say that my article is exactly what [/e/][16] does and is targeted to. I wanted to say thank you for reaching out but that is not true at all. The reasoning behind my opinion about /e/ can also be found in this [website][17], but Ill list a few of the reasons here.
eelo is a “foundation” that got over 200K € in funding from Kickstarter and IndieGoGo, promising to create a mobile OS and web services that are open and secure and protect your privacy.
1. Their OS is based on LineageOS 14.1 (Android 7.1) with microG and other open source apps with it, which already exists for a long time now and its called [Lineage for microG][18].
2. Instead of building all apps from the source code, they download the APKs from [APKPure][19] and put them in the ROM, without knowing if those APKs contain proprietary code/malware in them.
3. At one point, they were literally just removing the Lineage copyright header from their code and adding theirs.
4. They love to delete negative feedback and censor their users opinions in their Telegram group chat.
In conclusion, I **dont recommend using /e/** ROM-s (at least until now).
Another thing you would likely want to do is have [root access][20] to your phone, to make it truly yours and modify files in the system, such as use a system-wide adblocker etc. To do this, I decided to use [Magisk][21], a godsend app developed by a student to help you gain root access on your device and install what are called [modules][22], basically software.
After downloading the ROM and Magisk, I had to install them on my phone. To do that, I moved the files to my SD card on the phone. Now, to install the system, I had to use something called a [recovery system][23]. The one I use is called [TWRP][24] (standing for TeamWin Recovery Project), a popular solution.
To install the recovery system (sounds hard, I know), I had to [flash][20] the file on the phone. To do that, I connected my phone with the computer (Fedora Linux system) and with something called [ADB Tools][25] I issued a command that overwrites the system recovery with the custom one I had.
> fastboot flash recovery twrp.img
After this was done, I turned off the phone and kept Volume Up + Power button pressed until I saw the TWRP screen show up. That meant I was good to go and it was ready to receive my commands.
![TWRP screen][26]
Next step was to **issue a Wipe command** , necessary when you first install a custom ROM on your phone. As you can see from the image above, the Wipe command clears the Data, Cache and Dalvik (there is also an advanced option that allows us to tick a box to delete the System one too, as we dont need the old one anymore).
This takes a few moments and after that, your phone is basically clean. Now its time to **install the system**. By pressing the Install button on the main screen, we select the zip file we added there before (the ROM file) and swipe the screen to install it. Next, we have to install Magisk, which gives us root access to the device.
**EDIT** : As some more experienced/power Android users might have noticed until now, there is no [GApps][27] (Google Apps) included. This is what we call GApps-less in the Android world, not having those packages installed at all.
Note that one of the downsides of not having Google Services installed is that some of your apps might not work, for example their notifications might take longer to arrive or might not even work at all (this is what happens with Mattermost app for me). This happens because these apps use [Google Cloud Messaging][28] (now called [Firebase][29]) to wake the phone and push notifications to your phone.
You can solve this (partially) by installing and using [microG][30] which provides some features of Google Services but allows for more control on your side. I dont recommend using this because it still helps Google Services and you dont really give up on them, but its a good start if you want to quit Google slowly and not go cold turkey on it.
After successfully installing both, now we reboot the phone and **tada** 🎉, we are in the main screen.
### Next part, installing the apps and configuring everything
This is where things start to get easier. To install the apps, I use [F-Droid][31], an alternative app store that includes **only free and open source apps**. If you need apps that are not available there, you can use [Aurora Store][32], a client to download apps from the Play Store without using your Google account or getting tracked.
F-Droid has what are called repos, a “storehouse” that contains apps you can install. I use the default ones and have added another one from [IzzyOnDroid][33], that contains some more apps not available from the default F-Droid repo and is updated more often.
![My repos][34]
Below you will find a list of the apps I have installed, what they replace and their use.
This is pretty much **my list of the most useful F-Droid apps** I use, but unfortunately these are NOT the only apps I use. The proprietary apps I use (I know, I might sound a hypocrite, but not everything is replaceable, not yet at least) are as below:
* AliExpress
* Boost for Reddit
* Google Camera (coupled with Camera API 2, this app allows me to take wonderful pictures with a 185 EUR phone, its just too impressive)
* Instagram
* MediaBox HD (allows me to stream movies)
* Mi Fit (an app that pairs with my Mi Band 2)
* MyVodafoneAL (the carrier app)
* ProtonMail (email app)
* Shazam Encore (to find those songs you usually listen in coffee shops)
* Snapseed (photo editing app, really simple, powerful and quite good)
* Spotify (music streaming)
* Titanium Backup (to backup my app data, wifi passwords, calls log etc.)
* ViPER4Android FX (music equalizer)
* VSCO (photo editing, never use it really)
* WhatsApp (E2E proprietary messaging app, almost everyone I know has it)
* WiFi Map (mapped hotspots that are available, handy when abroad)
This is pretty much it, all the apps I use on my phone. **The configs are then pretty simple and straightforward and I can give a few tips**.
1. Read and check the permissions of apps carefully, dont click Install mindlessly.
2. Try to use as many open source apps as possible, they both respect your privacy and are free (as in both free beer and freedom).
3. Use a VPN as much as you can, find a reputable one and dont use free ones, otherwise you get to be the product and youll get your data harvested.
4. Dont keep your WiFi/mobile data/location on all the time, it might be a security risk.
5. Try not to rely on fingerprint unlock only, or better yet use only PIN/password/pattern unlock, as biometric data can be cloned and used against you, for example to unlock your phone and steal your data.
And as a bonus for reading far down here, **a screenshot of my home screen** right now.
![Screenshot][35]
--------------------------------------------------------------------------------
via: https://lushka.al/my-android-setup/
作者:[Anxhelo Lushka][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://lushka.al/
[b]: https://github.com/lujun9972
[1]: https://stallman.org/google.html
[2]: https://en.wikipedia.org/wiki/Richard_Stallman
[3]: https://www.gsmarena.com/xiaomi_redmi_note_5_pro-8893.php
[4]: https://en.wikipedia.org/wiki/Xiaomi
[5]: https://en.wikipedia.org/wiki/MIUI
[6]: https://forum.xda-developers.com/wiki/Bootloader
[7]: https://en.wikipedia.org/wiki/Booting
[8]: https://en.miui.com/unlock/
[9]: http://www.miui.com/unlock/apply.php
[10]: https://www.youtube.com/watch?v=7zhEsJlivFA
[11]: https://lushka.al//assets/img/posts/mi-unlock.png
[12]: https://www.xda-developers.com/what-is-custom-rom-android/
[13]: https://forum.xda-developers.com/
[14]: https://forum.xda-developers.com/redmi-note-5-pro
[15]: https://forum.xda-developers.com/redmi-note-5-pro/development/rom-aosip-8-1-t3804473
[16]: https://e.foundation
[17]: https://ewwlo.xyz/evil
[18]: https://lineage.microg.org/
[19]: https://apkpure.com/
[20]: https://lifehacker.com/5789397/the-always-up-to-date-guide-to-rooting-any-android-phone
[21]: https://forum.xda-developers.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445
[22]: https://forum.xda-developers.com/apps/magisk
[23]: http://www.smartmobilephonesolutions.com/content/android-system-recovery
[24]: https://dl.twrp.me/whyred/
[25]: https://developer.android.com/studio/command-line/adb
[26]: https://lushka.al//assets/img/posts/android-twrp.png
[27]: https://opengapps.org/
[28]: https://developers.google.com/cloud-messaging/
[29]: https://firebase.google.com/docs/cloud-messaging/
[30]: https://microg.org/
[31]: https://f-droid.org/
[32]: https://f-droid.org/en/packages/com.dragons.aurora/
[33]: https://android.izzysoft.de/repo
[34]: https://lushka.al//assets/img/posts/android-fdroid-repos.jpg
[35]: https://lushka.al//assets/img/posts/android-screenshot.jpg
[36]: https://creativecommons.org/licenses/by-nc-sa/4.0/

View File

@ -0,0 +1,192 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: subject: (The Top Command Tutorial With Examples For Beginners)
[#]: via: (https://www.ostechnix.com/the-top-command-tutorial-with-examples-for-beginners/)
[#]: author: ([SK](https://www.ostechnix.com/author/sk/))
[#]: url: ( )
The Top Command Tutorial With Examples For Beginners
======
![](https://www.ostechnix.com/wp-content/uploads/2018/11/top-command-720x340.png)
As a Linux administrator, you may need to need to know some basic details of your Linux system, such as the currently running processes, average system load, cpu and memory usage etc., at some point. Thankfully, we have a command line utility called **“top”** to get such details. The top command is a well-known and most widely used utility to display dynamic real-time information about running processes in Unix-like operating systems. In this brief tutorial, we are going to see some common use cases of top command.
### Top Command Examples
**Monitor all processes**
To start monitoring the running processes, simply run the top command without any options:
```
$ top
```
Sample output:
![](https://www.ostechnix.com/wp-content/uploads/2018/11/top-command-1.png)
As you see in the above screenshot, top command displays the list of processes in multiple columns. Each column displays details such as pid, user, cpu usage, memory usage. Apart from the list of processes, you will also see the brief stats about average system load, number of tasks, cpu usage, memory usage and swap usage on the top.
Here is the explanation of the parameters mentioned above.
* **PID** Process id of the task.
* **USER** Username of the the tasks owner.
* **PR** Priority of the task.
* **NI** Nice value of the task. If the nice value is negative, the process gets higher priority. If the nice value is positive, the priority is low. Refer [**this guide**][1] to know more about nice.
* **VIRT** Total amount of virtual memory used by the task.
* **RES** Resident Memory Size, the non-swapped physical memory a task is currently using.
* **SHR** Shared Memory Size. The amount of shared memory used by a task.
* **S** The status of the process (S=sleep R=running Z=zombie).
* **%CPU** CPU usage. The tasks share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.
* **%MEM** Memory Usage. A tasks currently resident share of available physical memory.
* **TIME+** Total CPU time used by the task since it has started, precise to the hundredths of a second.
* **COMMAND** Name of the running program.
**Display path of processes**
If you want to see the absolute path of the running processes, just press **c**. Now you will see the actual path of the programs under the COMMAND column in the below screenshot.
![][3]
**Monitor processes owned by a specific user**
If you run top command without any options, it will list all running processes owned by all users. How about displaying processes owned by a specific user? It is easy! To show the processes owned by a given user, for example **sk** , simply run:
```
$ top -u sk
```
![](https://www.ostechnix.com/wp-content/uploads/2018/11/top-command-3.png)
**Do not show idle/zombie processes**
Instead of viewing all processes, you can simply ignore the idle or zombie processes. The following command will not show any idle or zombie processes:
```
$ top -i
```
**Monitor processes with PID**
If you know the PID of any processes, for example 21180, you can monitor that process using **-p** flag.
```
$ top -p 21180
```
You can specify multiple PIDs with comma-separated values.
**Monitor processes with process name**
I dont know PID, but know only the process name. How to monitor it? Simple!
```
$ top -p $(pgrep -d ',' firefox)
```
Here, **firefox** is the process name and **pgrep -d** picks the respective PID from the process name.
**Display processes by CPU usage**
Sometimes, you might want to display processes sorted by CPU usage. If so, use the following command:
```
$ top -o %CPU
```
![][4]
The processes with higher CPU usage will be displayed on the top. Alternatively, you sort the processes by CPU usage by pressing **SHIFT+p**.
**Display processes by Memory usage**
Similarly, to order processes by memory usage, the command would be:
```
$ top -o %MEM
```
**Renice processes**
You can change the priority of a process at any time using the option **r**. Run the top command and press **r** and type the PID of a process to change its priority.
![][5]
Here, **r** refers renice.
**Set update interval**
Top program has an option to specify the delay between screen updates. If want to change the delay-time, say 5 seconds, run:
```
$ top -d 5
```
The default value is **3.0** seconds.
If you already started the top command, just press **d** and type delay-time and hit ENTER key.
![][6]
**Set number of iterations (repetition)**
By default, top command will keep running until you press **q** to exit. However, you can set the number of iterations after which top will end. For instance, to exit top command automatically after 5 iterations, run:
```
$ top -n 5
```
**Kill running processes**
To kill a running process, simply press **k** and type its PID and hit ENTER key.
![][7]
Top command supports few other options as well. For example, press **z** to switch between mono and color output. It will help you to easily highlight running processes.
![][8]
Press **h** to view all available keyboard shortcuts and help section.
To quit top, just press **q**.
At this stage, you will have a basic understanding of top command. For more details, refer man pages.
```
$ man top
```
As you can see, using Top command to monitor the running processes isnt that hard. Top command is easy to learn and use!
And, thats all for now. More good stuffs to come. Stay tuned!
Cheers!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/the-top-command-tutorial-with-examples-for-beginners/
作者:[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]: https://www.ostechnix.com/change-priority-process-linux/
[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
[3]: http://www.ostechnix.com/wp-content/uploads/2018/11/top-command-2.png
[4]: http://www.ostechnix.com/wp-content/uploads/2018/11/top-command-4.png
[5]: http://www.ostechnix.com/wp-content/uploads/2018/11/top-command-8.png
[6]: http://www.ostechnix.com/wp-content/uploads/2018/11/top-command-7.png
[7]: http://www.ostechnix.com/wp-content/uploads/2018/11/top-command-5.png
[8]: http://www.ostechnix.com/wp-content/uploads/2018/11/top-command-6.png

View File

@ -0,0 +1,108 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: subject: (ANGRYsearch Quick Search GUI Tool for Linux)
[#]: via: (https://itsfoss.com/angrysearch/)
[#]: author: (John Paul https://itsfoss.com/author/john/)
[#]: url: ( )
ANGRYsearch Quick Search GUI Tool for Linux
======
A search application is one of the most important tools you can have on your computer. Most are slow to indexes your system and find results. However, today we will be looking at an application that can display results as you type. Today, we will be looking at ANGRYsearch.
### What is ANGRYsearch?
![][1]
Newly installed ANGRYsearch
[ANGRYsearch][2] is a Python-based application that delivers results as you type your search query. The overall idea and design of the application are both inspired by [Everything][3] a search tool for Windows. (I discovered Everything ad couple of years ago and install it wherever I use Windows.)
ANGRYsearch is able to display the search results so quickly because it only indexes filenames. After you install ANGRYsearch, you create a database of filenames by indexing your system. ANGRYsearch then quickly filters filenames as you type your query.
Even though there is not much to ANGRYsearch, there are several things you can do to customize the experience. First, ANGRYsearch has two different display modes: lite and full. Lite mode only shows the filename and path. Full mode displays filename, path, size, and date of the last modification. Full mode, obviously, takes longer to display. The default is lite mode. In order to switch to full mode, you need to edit the config file at `~/.config/angrysearch/angrysearch.conf`. In that file change the `angrysearch_lite` value to false.
ANGRYsearch also has three different search modes: fast, slow, and regex. Fast mode displays filenames that start with your search term. For example, if you had a folder full of the latest releases of a bunch of Linux distros and you searched “Ubuntu”, ANGRYsearch would display Ubuntu, Ubuntu Mate, Ubuntu Budgie, but not Kubuntu, Xubuntu, or Lubuntu. Fast mode is on by default and can be turned off by unchecking the checkbox next to the “update” button. Slow mode is slightly slower (obviously), but it will display files that have your search term anywhere in their name. In the previous example, ANGRYsearch would show all Ubuntu distros. Regex mode is the slowest and most precise. It uses [regular expressions][4] and is case insensitive. Regex mode is activated by pressing F8.
You can also tell ANGRYsearch to ignore certain folders when it indexes your system. Just click the “update” button and enter the names of the folders you want to be ignored in the space provided. You can also choose from several icon themes, though it doesnt make that much difference.
![][5]Fast mode results
### Installing ANGRYsearch on Linux
ANGRYsearch is available in the [Arch User Repository][6]. It has also been packaged for [Fedora and openSUSE][7].
To install on other distros, follow these instructions. Instructions are written for a Debian or Ubuntu based system.
ANGRYsearch depends on `python3-pyqt5` and`xdg-utils` so you will need to install them first. Most distros have `xdg-utils`already installed.
`sudo apt install python3-pyqt5`
Next. download the latest version (1.0.1).
`wget https://github.com/DoTheEvo/ANGRYsearch/archive/v1.0.1.zip`
Now, unzip the archive file.
`unzip v1.0.1.zip`
Next, we will navigate to the new folder (ANGRYsearch-1.0.1) and run the installer.
`cd ANGRYsearch-1.0.1`
`chmod +x install.sh`
`sudo ./install.sh`
The installation process is very quick, so dont be surprised when a new command line is displayed as soon as you hit `Enter`.
The first time that you start ANGRYsearch, you will need to index your system. ANGRYsearch does not automatically keep its database updated. You can use `crontab` to schedule a system scan.
To open a text editor to create a new cronjob, use `crontab -e`. To make sure that the ANGRYsearch database is updated every 6 hours, use this command `0 */6 选题模板.txt 中文排版指北.md core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LCTT翻译规范.md LICENSE published README.md scripts sources translated 选题模板.txt 中文排版指北.md core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LCTT翻译规范.md LICENSE published README.md scripts sources translated 选题模板.txt 中文排版指北.md core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LCTT翻译规范.md LICENSE published README.md scripts sources translated /usr/share/angrysearch/angrysearch_update_database.py`. `crontab` does not run the job if it is powered off when the timer does off. In some case, you may need to manually update the database, but it should not take long.
![][8]ANGRYsearch update/options menu
### Experience
In the past, I was always frustrated by how painfully slow it was to search my computer. I knew that Windows had the Everything app, but I thought Linux out of luck. It didnt even occur to me to look for something similar on Linux. Im glad I accidentally stumbled upon ANGRYsearch.
I know there will be quite a few people complaining that ANGRYsearch only searches filenames, but most of the time that is all I need. Thankfully, most of the time I only need to remember part of the name to find what I am looking for.
The only thing that annoys me about ANGRYsearch is that fact that it does not automatically update its database. Youd think there would be a way for the installer to create a cron job when you install it.
![][9]Slow mode results
### Final Thoughts
Since ANGRYsearch is basically a Linux port of one of my favorite Windows apps, Im pretty happy with it. I plan to install it on all my systems going forward.
I know that I have ragged on other Linux apps for not being packaged for easy install, but I cant do the same for ANGRYsearch. The installation process is pretty easy. I would definitely recommend it for Linux noobs.
Have you ever used [ANGRYsearch][2]? If not, what is your favorite Linux search application? Let us know in the comments below.
If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][10].
--------------------------------------------------------------------------------
via: https://itsfoss.com/angrysearch/
作者:[John Paul][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/john/
[b]: https://github.com/lujun9972
[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/11/angrysearch3.jpg?resize=800%2C627&ssl=1
[2]: https://github.com/dotheevo/angrysearch/
[3]: https://www.voidtools.com/
[4]: http://www.aivosto.com/articles/regex.html
[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/11/angrysearch1.jpg?resize=800%2C627&ssl=1
[6]: https://aur.archlinux.org/packages/angrysearch/
[7]: https://software.opensuse.org/package/angrysearch
[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/11/angrysearch2.jpg?resize=800%2C626&ssl=1
[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/11/angrysearch4.jpg?resize=800%2C627&ssl=1
[10]: http://reddit.com/r/linuxusersgroup

View File

@ -0,0 +1,86 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: subject: (How to bring good fortune to your Linux terminal)
[#]: via: (https://opensource.com/article/18/12/linux-toy-fortune)
[#]: author: (Jason Baker https://opensource.com/users/jason-baker)
[#]: url: ( )
How to bring good fortune to your Linux terminal
======
Bring quotes and quips to the command line with the fortune utility.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-fortune.png?itok=5PVVZVer)
It's December, and if you haven't found a [tech advent calendar][1] that sparks your fancy yet, well, maybe this one will do the trick. Every day, from now to the 24th, we're bringing you a different Linux command-line toy. What's a command-line toy, you ask? It could be a game or any simple diversion to bring a little happiness to your terminal.
You may have seen some of these before. We hope you'll find something new, too. Either way, we hope you have fun following along.
Today's toy, **fortune** , is an old one. Versions of it date back to the 1980s when it was included with Unix. The version I installed in Fedora was available under a BSD license, and I grabbed it with the following.
```
$ sudo dnf install fortune-mod -y
```
Your distribution may be different. On some, you may need to install the fortunes separately from **fortune** itself (try searching your package manager for "fortunes*"). You can also check out the source code on [GitHub][2]. Then, just run **fortune** to get, well, a fortune.
```
$ fortune
"Time is an illusion.  Lunchtime doubly so."
-- Ford Prefect, _Hitchhiker's Guide to the Galaxy_
```
So why do you need fortunes at the terminal? For fun, of course. Perhaps you'd like to add them to the message of the day on your system?
Personally, I like using the **fortune** command as a built-in piece of dummy data when I'm using the terminal to parse text, particularly with [regular expressions][3], and want something simple to try it out on.
For example, let's say I was testing our a transformation with the **tr** command to replace letter the letter e with a numeral 3.
```
$ fortune | tr 'eE' '3'
Unix 3xpr3ss:
All pass3ng3r bring a pi3c3 of th3 a3roplan3 and a box of tools with th3m to
th3 airport. Th3y gath3r on th3 tarmac, arguing constantly about what kind
of plan3 th3y want to build and how to put it tog3th3r. 3v3ntually, th3
pass3ng3rs split into groups and build s3v3ral diff3r3nt aircraft, but giv3
th3m all th3 sam3 nam3. Som3 pass3ng3rs actually r3ach th3ir d3stinations.
All pass3ng3rs b3li3v3 th3y got th3r3.
```
So what fortunes come with your distribution? Take a look in your **/usr/share/games/fortune** directory to find them all. Here are a few of my favorites.
```
Never laugh at live dragons.
                -- Bilbo Baggins [J.R.R. Tolkien, "The Hobbit"]
I dunno, I dream in Perl sometimes...
             -- Larry Wall in  <8538@jpl-devvax.JPL.NASA.GOV>
I have an existential map.  It has "You are here" written all over it.
                -- Steven Wright
```
Looking for more on **fortune**? You can, of course, always check out the man page to learn more about the options, or read a little bit more about the history of the command on [Wikipedia][4].
Do you have a favorite command-line toy that you think I ought to profile? The calendar for this series is mostly filled out but I've got a few spots left. Let me know in the comments below, and I'll check it out. If there's space, I'll try to include it. If not, but I get some good submissions, I'll do a round-up of honorable mentions at the end.
Check out yesterday's toy, [Drive a locomotive through your Linux terminal][5], and check back tomorrow for another!
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/12/linux-toy-fortune
作者:[Jason Baker][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/jason-baker
[b]: https://github.com/lujun9972
[1]: https://opensource.com/article/16/11/7-tech-advent-calendars-holiday-season
[2]: https://github.com/shlomif/fortune-mod
[3]: https://opensource.com/article/18/5/getting-started-regular-expressions
[4]: https://en.wikipedia.org/wiki/Fortune_%28Unix%29
[5]: https://opensource.com/article/18/12/linux-toy-sl

View File

@ -0,0 +1,222 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: subject: (Bash Variables: Environmental and Otherwise)
[#]: via: (https://www.linux.com/blog/learn/2018/12/bash-variables-environmental-and-otherwise)
[#]: author: (Paul Brown https://www.linux.com/users/bro66)
[#]: url: ( )
Bash Variables: Environmental and Otherwise
======
![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/wynand-van-poortvliet-40467-unsplash.jpg?itok=tr6Eb4N0)
Bash variables, including those pesky _environment variables_ , have been popped up several times in previous articles, and its high time you get to know them better and how they can help you.
So, open your terminal window and let's get started.
### Environment Variables
Consider `HOME`. Apart from the cozy place where you lay down your hat, in Linux it is a variable that contains the path to the current user's home directory. Try this:
```
echo $HOME
```
This will show the path to your home directory, usually _/home/_.
As the name indicates, variables can change according to the context. Indeed, each user on a Linux system will have a `HOME` variable containing a different value. You can also change the value of a variable by hand:
```
HOME=/home/<your username>/Documents
```
will make `HOME` point to your _Documents/_ folder.
There are three things to notice here:
1. There are no spaces between the name of the variable and the `=` or between the `=` and the value you are putting into the variable. Spaces have their own meaning in the shell and cannot be used any old way you want.
2. If you want to put a value into a variable or manipulate it in any way, you just have to write the name of the variable. If you want to see or use the contents of a variable, you put a `$` in front of it.
3. Changing `HOME` is risky! A lot programs rely on `HOME` to do stuff and changing it can have unforeseeable consequences. For example, just for laughs, change `HOME` as shown above and try typing `cd` and then [Enter]. As we have seen elsewhere in this series, you use `cd` to _c_ hange to another _d_ irectory. Without any parameters, `cd` takes you to your home directory. If you change the `HOME` variable, `cd` will take you to the new directory `HOME` points to.
Changes to environment variables like the one described in point 3 above are not permanent. If you close your terminal and open it back up, or even open a new tab in your terminal window and move there, `echo $HOME` will show its original value.
Before we go on to how you make changes permanent, let's look at another environment variable that it does make sense changing.
### PATH
The `PATH` variable lists directories that contain executable programs. If you ever wondered where your applications go when they are installed and how come the shell seems to magically know which programs it can run without you having to tell it where to look for them, `PATH` is the reason.
Have a look inside `PATH` and you will see something like this:
```
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
```
Each directory is separated by a colon (`:`) and if you want to run an application installed in any directory other than the ones listed in `PATH`, you will have to tell the shell where to find it:
```
/home/<user name>/bin/my_program.sh
```
This will run a program calle _my_program.sh_ you have copied into a _bin/_ directory in your home directory.
This is a common problem: you don't want to clutter up your system's _bin/_ directories, or you don't want other users running your own personal scripts, but you don't want to have to type out the complete path every time you need to run a script you use often. The solution is to create your own _bin/_ directory in your home directory:
```
mkdir $HOME/bin
```
And then tell `PATH` all about it:
```
PATH=$PATH:$HOME/bin
```
After that, your _/home//bin_ will show up in your `PATH` variable. But... Wait! We said that the changes you make in a given shell will not last and will lose effect when that shell is closed.
To make changes permanent for your user, instead of running them directly in the shell, put them into a file that gets run every time a shell is started. That file already exists and lives in your home directory. It is called _.bashrc_ and the dot in front of the name makes it a hidden file -- a regular `ls` won't show it, but `ls -a` will.
You can open it with a text editor like [kate][1], [gedit][2], [nano][3], or [vim][4] (NOT LibreOffice Writer -- that's a word processor. Different beast entirely). You will see that _.bashrc_ is full of shell commands the purpose of which are to set up the environment for your user.
Scroll to the bottom and add the following on a new, empty line:
```
export PATH=$PATH:$HOME/bin
```
Save and close the file. You'll be seeing what `export` does presently. In the meantime, to make sure the changes take effect immediately, you need to `source` _.bashrc_ :
```
source .bashrc
```
What `source` does is execute _.bashrc_ for the current open shell, and all the ones that come after it. The alternative would be to log out and log back in again for the changes to take effect, and who has the time for that?
From now on, your shell will find every program you dump in _/home//bin_ without you having to specify the whole path to the file.
### DYI Variables
You can, of course, make your own variables. All the ones we have seen have been written with ALL CAPS, but [you can call a variable more or less whatever you want][5].
Creating a new variables is straightforward: just set a value within it:
```
new_variable="Hello"
```
And you already know how to recover a value contained within a variable:
```
echo $new_variable
```
You often have a program that will require you set up a variable for things to work properly. The variable may set an option to "on", or help the program find a library it needs, and so on. When you run a program in Bash, the shell spawns a daughter process. This means it is not exactly the same shell that executes your program, but a related mini-shell that inherits some of the mother's characteristics. Unfortunately, variables, by default, are not one of them. This is because, by default again, variables are _local_. This means that, for security reasons, a variable set in one shell cannot be read in another, even if it is a daughter shell.
To see what I mean, set a variable:
```
robots="R2D2 & C3PO"
```
... and run:
```
bash
```
You just ran a Bash shell program within a Bash shell program.
Now see if you can read the contents of you variable with:
```
echo $robots
```
You should draw a blank.
Still inside your bash-within-bash shell, set `robots` to something different:
```
robots="These aren't the ones you are looking for"
```
Check `robots`' value:
```
$ echo $robots
These aren't the ones you are looking for
```
Exit the bash-within-bash shell:
```
exit
```
And re-check the value of `robots`:
```
$ echo $robots
R2D2 & C3P0
```
This is very useful to avoid all sorts of messed up configurations, but this presents a problem also: if a program requires you set up a variable, but the program can't access it because Bash will execute it in a daughter process, what can you do? That is exactly what `export` is for.
Try doing the prior experiment, but, instead of just starting off by setting `robots="R2D2 & C3PO"`, export it at the same time:
```
export robots="R2D2 & C3PO"
```
You'll notice that, when you enter the bash-within-bash shell, `robots` still retains the same value it had at the outset.
**Interesting fact:** While the daughter process will "inherit" the value of an exported variable, if the variable is changed within the daughter process, changes will not flow upwards to the mother process. In other words, changing the value of an exported variable in a daughter process does not change the value of the original variable in the mother process.
You can see all exported variables by running
```
export -p
```
The variables you create should be at the end of the list. You will also notice some other interesting variables in the list: `USER`, for example, contains the current user's user name; `PWD` points to the current directory; and `OLDPWD` contains the path to the last directory you visited and since left. That's because, if you run:
```
cd -
```
You will go back to the last directory you visited and `cd` gets the information from `OLDPWD`.
You can also see all the environment variables using the `env` command.
To un-export a variable, use the `-n` option:
```
export -n robots
```
### Next Time
You have now reached a level in which you are dangerous to yourself and others. It is time you learned how to protect yourself from yourself by making your environment safer and friendlier through the use of _aliases,_ and that is exactly what we'll be tackling in the next episode. See you then.
--------------------------------------------------------------------------------
via: https://www.linux.com/blog/learn/2018/12/bash-variables-environmental-and-otherwise
作者:[Paul Brown][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.linux.com/users/bro66
[b]: https://github.com/lujun9972
[1]: https://www.kde.org/applications/utilities/kate/
[2]: https://help.gnome.org/users/gedit/stable/
[3]: https://www.nano-editor.org/
[4]: https://www.vim.org/
[5]: https://bash.cyberciti.biz/guide/Rules_for_Naming_variable_name

View File

@ -0,0 +1,60 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: subject: (Bring some color to your Linux terminal with lolcat)
[#]: via: (https://opensource.com/article/18/12/linux-toy-lolcat)
[#]: author: (Jason Baker https://opensource.com/users/jason-baker)
[#]: url: ( )
Bring some color to your Linux terminal with lolcat
======
With this simple utility, you can add a rainbow of color to the output of any program you want.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-lolcat.png?itok=Es6dYcph)
Today marks the fifth day of the Linux command-line toys advent calendar. If this is your first visit to the series, you might be asking yourself, whats a command-line toy. Even I'm not quite sure, but generally, it could be a game, or any simple diversion that helps you have fun at the terminal.
It's quite possible that some of you will have seen various selections from our calendar before, but we hope theres at least one new thing for everyone.
Today's selection, **lolcat** , is the first utility I'm including that wasn't packaged for my Linux distribution, but it was still an easy install. It's a Ruby program that you ought to be able to easily add to your system with the following.
```
$ gem install lolcat
```
After that, simply pipe some text to it to see the output in the colors of the rainbow. For example, using a couple of utilities from earlier days in our advent calendar, try the following:
```
$ fortune | boxes -a c -d parchment | lolcat
```
Depending on what good fortune you have, you'll likely get something like this:
![](https://opensource.com/sites/default/files/uploads/linux-toy-lolcat-parchment.png)
There are a few parameters you can pass to **lolcat** , and rather than repeat them all here, I'd suggest you either visit the **lolcat** [GitHub page][1] or just see them at the terminal by typing **lolcat --help**. But generally, they're helpful to set the spread and frequency of your rainbow, and my personal favorite, enabling animation. Who doesn't like animated rainbow printing at the terminal? Let's try the above again, with a different box (cat-themed, of course) and a cat-appropriate fortune that was in my fortunes list, with the following.
```
fortune -m "nine tails" | boxes -a c -d cat | lolcat -a
```
![](https://opensource.com/sites/default/files/uploads/linux-toy-lolcat-animated.gif)
**lolcat** is open source under a BSD license.
Do you have a favorite command-line toy that you think I ought to profile? The calendar for this series is mostly filled out but I've got a few spots left. Let me know in the comments below, and I'll check it out. If there's space, I'll try to include it. If not, but I get some good submissions, I'll do a round-up of honorable mentions at the end.
Check out yesterday's toy, [Have a cow at the Linux command line][2], and check back tomorrow for another!
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/12/linux-toy-lolcat
作者:[Jason Baker][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/jason-baker
[b]: https://github.com/lujun9972
[1]: https://github.com/busyloop/lolcat
[2]: https://opensource.com/article/18/12/linux-toy-cowsay

View File

@ -0,0 +1,78 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: subject: (How To Fix Broken Ubuntu OS Without Reinstalling It)
[#]: via: (https://www.ostechnix.com/how-to-fix-broken-ubuntu-os-without-reinstalling-it/)
[#]: author: (SK https://www.ostechnix.com/author/sk/)
[#]: url: ( )
How To Fix Broken Ubuntu OS Without Reinstalling It
======
![](https://www.ostechnix.com/wp-content/uploads/2018/12/Fix-Broken-Ubuntu-OS-720x340.jpg)
Today, I was upgrading my Ubuntu 18.04 LTS system. Unfortunately, the power has gone in mid-way and the system powered off while updating Ubuntu OS. When the power is back, I boot the system again. Right after entering the password at the login screen, its gone blank and didnt respond. Keyboard and mouse also didnt work. All I see is just a blank screen! Thankfully, Its just a test machine and there were no important data in it. I can simply wipe off the entire OS and install it again. But, I dont want to do that. Since I have nothing to lose, I just wanted to repair my broken Ubuntu system without reinstalling it completely and it worked!!! If you ever find yourself in a situation like mine, dont panic. This brief tutorial describes how to easily fix broken Ubuntu OS without losing data and without reinstalling it completely.
### Fix Broken Ubuntu OS
First of all, try to login with live cd and **backup your data** in an external drive. Just in case, if this method didnt work, you can still have your data and reinstall everything!
At the login screen, press **CTRL+ALT+F1** to switch to **tty1**. You can learn more about switching between TTYs [**here**][1].
Now, type the following commands one by one to fix the broken Ubuntu Linux.
```
$ sudo rm /var/lib/apt/lists/lock
$ sudo rm /var/lib/dpkg/lock
$ sudo rm /var/lib/dpkg/lock-frontend
$ sudo dpkg --configure -a
$ sudo apt clean
$ sudo apt update --fix-missing
$ sudo apt install -f
$ sudo dpkg --configure -a
$ sudo apt upgrade
$ sudo apt dist-upgrade
```
Finally, reboot the system using command:
```
$ sudo reboot
```
You can now be able to login to your Ubuntu system as usual.
After I followed these steps, all of my data in Ubuntu 18.04 test system was there and everything is the same as I left it. This method may not work for everyone. However, this small tip worked for me and saved a couple minutes from reinstalling. If you know any other better way, please let me know in the comment section. I will add them in this guide as well.
And, thats all for now. Hope this was useful.
More good stuffs to come. Stay tuned!
Cheers!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/how-to-fix-broken-ubuntu-os-without-reinstalling-it/
作者:[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]: https://www.ostechnix.com/how-to-switch-between-ttys-without-using-function-keys-in-linux/

View File

@ -0,0 +1,106 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How To Boot Into Rescue Mode Or Emergency Mode In Ubuntu 18.04)
[#]: via: (https://www.ostechnix.com/how-to-boot-into-rescue-mode-or-emergency-mode-in-ubuntu-18-04/)
[#]: author: (SK https://www.ostechnix.com/author/sk/)
How To Boot Into Rescue Mode Or Emergency Mode In Ubuntu 18.04
======
![](https://www.ostechnix.com/wp-content/uploads/2018/12/Boot-Into-Rescue-Mode-Or-Emergency-Mode-720x340.png)
As you might already know, **Runlevels** are replaced with **Systemd targets** in many recent Linux distributions like RHEL 7 and Ubuntu 16.04 LTS. For more details about runlevels and systemd target, refer [**this guide**][1]. In this brief tutorial, we are going to see how to boot into **rescue mode** and/or **emergency mode**. This guide is tested in Ubuntu 18.04 LTS, however the steps given below would work on most Linux distributions that uses Systemd as default service manager. Before going further, let me clarify what is rescue mode and emergency mode and what is the purpose of the both modes.
### What is Rescue mode?
The **rescue mode** is equivalent to **single user mode** in Linux distributions that uses **SysV** as the default service manager. In rescue mode, all local filesystems will be mounted, only some important services will be started. However, no normal services (E.g network services) wont be started. The rescue mode is helpful in situations where the system cant boot normally. Also, we can perform some important rescue operations, such as [**reset root password**][2], in rescue mode.
### What is Emergency mode?
In contrast to the rescue mode, nothing is started in the **emergency mode**. No services are started, no mount points mounted, no sockets established, nothing. All you will have is just a **raw shell**. Emergency mode is suitable for debugging purposes.
### Boot Into Rescue Mode In Ubuntu 18.04 LTS
Boot your Ubuntu system. When Grub menu appears, choose the first entry and press **e** to edit.
![](https://www.ostechnix.com/wp-content/uploads/2018/12/Grub-menu.png)
If you dont see the Grub menu, just hit ESC key right after the BIOS logo disappears.
Find the line that starts with word **“linux”** and add the following line at the end of that line (To reach the end, just press **CTRL+e** or use END key or LEFT/RIGHT arrows in your keyboard):
```
systemd.unit=rescue.target
```
![](https://www.ostechnix.com/wp-content/uploads/2018/12/Edit-grub-menu.png)
Once you added the above line, just press **CTRL+x** or **F10** to continue to boot into rescue mode. After a few seconds, you will be ended up in the rescue mode (single user mode) as root user. Here is how rescue mode looks like in Ubuntu 18.04 LTS server:
![](https://www.ostechnix.com/wp-content/uploads/2018/12/Ubuntu-rescue-mode.png)
Next, type the following command to mount root (/) file system into read/write mode.
```
mount -n -o remount,rw /
```
### Boot Into Emergency Mode
Booting your Ubuntu into emergency is as same as above method. All you have to do is replace “systemd.unit=rescue.target” with “systemd.unit=emergency.target” when editing grub menu.
[![emergency mode][3]][4]
Once you added “systemd.unit=emergency.target”, press **Ctrl+x** or **F10** to continue booting into emergency mode.
![](https://www.ostechnix.com/wp-content/uploads/2018/12/emergency-mode-1.png)
Finally, you can mount root filesystem into read/write mode with command:
```
mount -n -o remount,rw /
```
### Switch between Rescue to Emergency mode and vice versa
If you are in rescue mode, you dont have to edit the grub boot entry as I mentioned above. Instead, just type the following command to switch to emergency mode instantly:
```
systemctl emergency
```
Similarly, to switch from emergency to rescue mode, type:
```
systemctl rescue
```
You know now what is rescue and emergency modes and how to boot into those modes in Ubuntu 18.04. Like I already mentioned, the steps provided here will work on many recent Linux versions that uses Systemd.
And, thats all for now. Hope this was useful.
More good stuffs to come. Stay tuned!
Cheers!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/how-to-boot-into-rescue-mode-or-emergency-mode-in-ubuntu-18-04/
作者:[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]: https://www.ostechnix.com/check-runlevel-linux/
[2]: https://www.ostechnix.com/how-to-reset-or-recover-root-user-password-in-linux/
[3]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
[4]: http://www.ostechnix.com/wp-content/uploads/2018/12/emergency-mode.png

View File

@ -0,0 +1,109 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to view XML files in a web browser)
[#]: via: (https://opensource.com/article/18/12/xml-browser)
[#]: author: (Greg Pittman https://opensource.com/users/greg-p)
How to view XML files in a web browser
======
Turn XML files into something more useful.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web_browser_desktop_devlopment_design_system_computer.jpg?itok=pfqRrJgh)
Once you learn that HTML is a form of XML, you might wonder what would happen if you tried to view an XML file in a browser. The results are quite disappointing—Firefox shows you a banner at the top of the page that says, "This XML file does not appear to have any style information associated with it. The document tree is shown below." The document tree looks like the file would look in an editor:
![](https://opensource.com/sites/default/files/uploads/xml_menu.png)
This is the beginning of the **menu.xml** file for the online manual that comes with [Scribus][1], to which I'm a contributor. Although you see blue text, they are not clickable links. I wanted to be able to view this in a regular browser, since sometimes I need to go back and forth from the canvas in Scribus to the manual to figure out how to do something (maybe to see if I need to edit the manual to straighten out some misinformation or to add some missing information).
The way to help a browser know what to do with these XML tags is by using XSLT—Extensible Stylesheet Language Transformations. In a broad sense, you could use XSLT to transform XML to a variety of outputs, or even HTML to XML. Here I want to use it to present the XML tags to a browser as suitable HTML.
One slight modification needs to happen to the XML file:
![](https://opensource.com/sites/default/files/uploads/xml_modified-menu.png)
Adding this second line to the file tells the browser to look for a file named **scribus-manual.xsl** for the style information. The more important part is to create this XSL file. Here is the complete listing of **scribus-manual.xsl** for the Scribus manual:
```
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html>
    <title>Scribus Online Manual</title>
<style type="text/css">
h2,h3,h4 { text-indent: 50px;}
ul { margin-left: 100px;}
</style>
<table border="0" cellspacing="0" cellpadding="0" width="100%"
bgcolor="#183867" >
        <tr>
                <td align="left"><img src="images/docheader1.png" width="222"
height="87"/></td>
                <td align="right"><img src="images/docheader2.png" width="318"
height="87"/></td>
        </tr>
</table>
    <body bgcolor="#ffffff">
      <xsl:for-each select="menu">
        <xsl:for-each select="area">
          <h3><a href="{@file}" ><xsl:value-of select = "@text" /></a></h3>
          <xsl:for-each select="submenuitem">
            <h4><a href="{@file}" ><xsl:value-of select = "@text" /></a></h4>
                <xsl:for-each select="submenuitem">
                  <p><ul>
                    <li><a href="{@file}" ><xsl:value-of select = "@text" /></a></li>
                  </ul></p>
                </xsl:for-each>
          </xsl:for-each>
        <xsl:for-each select="area">
          <h3><a href="{@file}" ><xsl:value-of select = "@text" /></a></h3>
        </xsl:for-each>
        </xsl:for-each>
      </xsl:for-each>
    </body>
    </html>
  </xsl:template>
</xsl:stylesheet>
```
This looks a lot more like HTML, and you can see it contains a number of HTML tags. After some preliminary tags and some particulars about displaying H2, H3, and H4 tags, you see a Table tag. This adds a graphical heading at the top of the page and uses some images already in the documentation files.
After this, you get into the process of dissecting the various **submenuitem** tags, trying to create the nested listing structure as it appears in Scribus when you view the manual. One feature I did not try to duplicate is the ability to collapse and expand **submenuitem** areas. As you can imagine, it takes some time to sort through the number of nested lists you need to create, but when I finished, here is how it looked:
![](https://opensource.com/sites/default/files/uploads/xml_scribusmenuinbrowser.png)
This minimal editing to **menu.xml** does not interfere with Scribus' ability to show the manual in its own browser. I put this modified **menu.xml** file and the **scribus-manual.xsl** in the English documentation folder for 1.5.x versions of Scribus, so anyone using these versions can simply point their browser to the **menu.xml** file and it should show up just like you see above.
A much bigger chore I took on a few years ago was to create a version of the ICD10 (International Classification of Diseases, version 10) when it came out. Many changes were made from the previous version (ICD9) to 10. These are important since these codes must be used for diagnostic purposes in medical practice. You can easily download XML files from the US [Centers for Medicare and Medicaid][2] website since it is public information, but—just as with the Scribus manual—these files are hard to use.
Here is the beginning of the tabular listing of diseases:
![](https://opensource.com/sites/default/files/uploads/xml_tabular_begin.png)
One of the features I created was the color coding used in the listing shown here:
![](https://opensource.com/sites/default/files/uploads/xml_tabular_body.png)
As with **menu.xml** , the only editing I did in this **Tabular.xml** file was to add **<?xml-stylesheet type="text/xsl" href="tabular.xsl"? >** as the second line of the file. I started this project with the 2014 version, and I was quite pleased to find that the original **tabular.xsl** stylesheet worked perfectly when the 2016 version came out, which is the last one I worked on. The** Tabular.xml** file is 8.4MB, quite large for a plaintext file. It takes a few seconds to load into a browser, but once it's loaded, navigation is fast.
While you may not often have to deal with an XML file in this way, if you do, I hope this article shows that your file can easily be turned into something much more usable.
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/12/xml-browser
作者:[Greg Pittman][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/greg-p
[b]: https://github.com/lujun9972
[1]: https://www.scribus.net/
[2]: https://www.cms.gov/

View File

@ -0,0 +1,61 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: subject: (Take a break at the Linux command line with Nyan Cat)
[#]: via: (https://opensource.com/article/18/12/linux-toy-nyancat)
[#]: author: (Jason Baker https://opensource.com/users/jason-baker)
[#]: url: ( )
Take a break at the Linux command line with Nyan Cat
======
Rainbows, Pop-Tarts, and cats in space: What more could you want at your terminal?
![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-nyancat.png?itok=eg1aEmBw)
We're now on day six of the Linux command-line toys advent calendar, where we explore some of the fun, entertaining, and in some cases, utterly useless toys available for your Linux terminal. All are available under an open source license.
Will they all be unique? Yes. Will they all be unique to you? I don't know, but, chances are you'll find at least one new toy to play with by the time our advent calendar is done.
Today's selection is a continuation on the [theme][1] we started yesterday: cats and rainbows. Wait, there's more cat-related rainbow fun to be had at the Linux command line? You bet there is.
So let's make a throwback all the way to 2011's [Nyan Cat][2] with a command-line toy call, not surprisingly, **nyancat**. Did you miss the cultural phenomenon that was Nyan Cat? Watch the embed below, I'll wait.
<https://www.youtube.com/embed/QH2-TGUlwu4>
Now, let's recreate that amazing experience in your terminal. **Nyancat** is packaged for many distributions (Arch, Debian, Gentoo, Ubuntu, etc.) but not for mine (Fedora), but compiling from source was simple. In fact, I grabbed the source, built it, and launched it in one line:
```
git clone https://github.com/klange/nyancat.git && cd nyancat && make && cd src && ./nyancat
```
This launched straight into a **nyancat** experience complete with a counter of how long I had been enjoying the **nyancat** magic for.
![](https://opensource.com/sites/default/files/uploads/linux-toy-nyancat-animated.gif)
You can find the source for **nyancat** [on GitHub][3] under an [NCSA open source license][4].
The command-line version of Nyan Cat used to be [accessible by a public Telnet server][5] (or, for even more pun, with [netcat][6]) so that you didn't even have to install it, but sadly was shut down due to bandwidth limitations. Nevertheless, the [gallery][5] from the old Telnet server running Nyan Cat on a variety of old devices is well-worth checking out, and maybe you'd like to do the community a favor by launching your own public mirror and letting the author know so that they may share it with the public yet again?
Do you have a favorite command-line toy that you think I ought to profile? The calendar for this series is mostly filled out but I've got a few spots left. Let me know in the comments below, and I'll check it out. If there's space, I'll try to include it. If not, but I get some good submissions, I'll do a round-up of honorable mentions at the end.
Check out yesterday's toy, [Bring some color to your Linux terminal with lolcat][1], and check back tomorrow for another!
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/12/linux-toy-nyancat
作者:[Jason Baker][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/jason-baker
[b]: https://github.com/lujun9972
[1]: https://opensource.com/article/18/12/linux-toy-lolcat
[2]: https://en.wikipedia.org/wiki/Nyan_Cat
[3]: https://github.com/klange/nyancat
[4]: http://en.wikipedia.org/wiki/University_of_Illinois/NCSA_Open_Source_License
[5]: http://nyancat.dakko.us/
[6]: http://netcat.sourceforge.net/

View File

@ -0,0 +1,177 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (5 Screen Recorders for the Linux Desktop)
[#]: via: (https://www.linux.com/blog/intro-to-linux/2018/12/5-screen-recorders-linux-desktop)
[#]: author: (Jack Wallen https://www.linux.com/users/jlwallen)
5 Screen Recorders for the Linux Desktop
======
![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/screen-record.png?itok=tKWx29k8)
There are so many reasons why you might need to record your Linux desktop. The two most important are for training and for support. If you are training users, a video recording of the desktop can go a long way to help them understand what you are trying to impart. Conversely, if youre having trouble with one aspect of your Linux desktop, recording a video of the shenanigans could mean the difference between solving the problem and not. But what tools are available for the task? Fortunately, for every Linux user (regardless of desktop), there are options available. I want to highlight five of my favorite screen recorders for the Linux desktop. Among these five, you are certain to find one that perfectly meets your needs. I will only be focusing on those screen recorders that save as video. What video format you prefer may or may not dictate which tool you select.
And, without further ado, lets get on with the list.
### Simple Screen Recorder
Im starting out with my go-to screen recorder. I use [Simple Screen Recorder][1] on a daily basis, and it never lets me down. This particular take on the screen recorder is available for nearly every flavor of Linux and is, as the name implies, very simple to use. With Simple Screen Recorder you can select a single window, a portion of the screen, or the entire screen to record. One of the best features of Simple Screen Recorder is the ability to save profiles (Figure 1), which allows you to configure the input for a recording (including scaling, frame rate, width, height, left edge and top edge spacing, and more). By saving profiles, you can easily use a specific profile to meet a unique need, without having to go through the customization every time. This is handy for those who do a lot of screen recording, with different input variables for specific jobs.
![Simple Screen Recorder ][3]
Figure 1: Simple Screen Recorder input profile window.
[Used with permission][4]
Simple screen recorder also:
* Records audio input
* Allows you to pause and resume recording
* Offers a preview during recording
* Allows for the selection of video containers and codecs
* Adds timestamp to file name (optional)
* Includes hotkey recording and sound notifications
* Works well on slower machines
* And much more
Simple Screen Recorder is one of the most reliable screen recording tools I have found for the Linux desktop. Simple Screen Recorder can be installed from the standard repositories on many desktops, or via easy to follow instructions on the [application download page][5].
### Gtk-recordmydesktop
The next entry, [gtk-recordmydesktop][6], doesnt give you nearly the options found in Simple Screen Recorder, but it does offer a command line component (for those who prefer not working with a GUI). The simplicity that comes along with this tool also means you are limited to a specific video output format (.ogv). That doesnt mean gtk-recordmydesktop isnt without appeal. In fact, there are a few features that make this option in the genre fairly appealing. First and foremost, its very simple to use. Second, the record window automatically gets out of your way while you record (as opposed to Simple Screen Recorder, where you need to minimize the recording window when recording full screen). Another feature found in gtk-recordmydesktop is the ability to have the recording follow the mouse (Figure 2).
![gtk-recordmydesktop][8]
Figure 2: Some of the options for gtk-recordmydesktop.
[Used with permission][4]
Unfortunately, the follow the mouse feature doesnt always work as expected, so chances are youll be using the tool without this interesting option. In fact, if you opt to go the gtk-recordmydesktop route, you should understand the GUI frontend isnt nearly as reliable as is the command line version of the tool. From the command line, you could record a specific position of the screen like so:
```
recordmydesktop -x X_POS -y Y_POS --width WIDTH --height HEIGHT -o FILENAME.ogv
```
where:
* X_POS is the offset on the X axis
* Y_POS is the offset on the Y axis
* WIDTH is the width of the screen to be recorded
* HEIGHT is the height of the screen to be recorded
* FILENAME is the name of the file to be saved
To find out more about the command line options, issue the command man recordmydesktop and read through the manual page.
### Kazam
If youre looking for a bit more than just a recorded screencast, you might want to give Kazam a go. Not only can you record a standard screen video (with the usual—albeit limited amount of—bells and whistles), you can also take screenshots and even broadcast video to YouTube Live (Figure 3).
![Kazam][10]
Figure 3: Setting up YouTube Live broadcasting in Kazam.
[Used with permission][4]
Kazam falls in line with gtk-recordmydesktop, when it comes to features. In other words, its slightly limited in what it can do. However, that doesnt mean you shouldnt give Kazam a go. In fact, Kazam might be one of the best screen recorders out there for new Linux users, as this app is pretty much point and click all the way. But if youre looking for serious bells and whistles, look away.
The version of Kazam, with broadcast goodness, can be found in the following repository:
```
ppa:sylvain-pineau/kazam
```
For Ubuntu (and Ubuntu-based distributions), install with the following commands:
```
sudo apt-add-repository ppa:sylvain-pineau/kazam
sudo apt-get update
sudo apt-get install kazam -y
```
### Vokoscreen
The [Vokoscreen][11] recording app is for new-ish users who need more options. Not only can you configure the output format and the video/audio codecs, you can also configure it to work with a webcam (Figure 4).
![Vokoscreen][13]
Figure 4: Configuring a web cam for a Vokoscreen screen recording.
[Used with permission][4]
As with most every screen recording tool, Vokoscreen allows you to specify what on your screen to record. You can record the full screen (even selecting which display on multi-display setups), window, or area. Vokoscreen also allows you to select a magnification level (200x200, 400x200, or 600x200). The magnification level makes for a great tool to highlight a specific section of the screen (the magnification window follows your mouse).
Like all the other tools, Vokoscreen can be installed from the standard repositories or cloned from its [GitHub repository][14].
### OBS Studio
For many, [OBS Studio][15] will be considered the mack daddy of all screen recording tools. Why? Because OBS Studio is as much a broadcasting tool as it is a desktop recording tool. With OBS Studio, you can broadcast to YouTube, Smashcast, Mixer.com, DailyMotion, Facebook Live, Restream.io, LiveEdu.tv, Twitter, and more. In fact, OBS Studio should seriously be considered the de facto standard for live broadcasting the Linux desktop.
Upon installation (the software is only officially supported for Ubuntu Linux 14.04 and newer), you will be asked to walk through an auto-configuration wizard, where you setup your streaming service (Figure 5). This is, of course, optional; however, if youre using OBS Studio, chances are this is exactly why, so you wont want to skip out on configuring your default stream.
![OBS Studio][17]
Figure 5: Configuring your streaming service for OBS Studio.
[Used with permission][4]
I will warn you: OBS Studio isnt exactly for the faint of heart. Plan on spending a good amount of time getting the streaming service up and running and getting up to speed with the tool. But for anyone needing such a solution for the Linux desktop, OBS Studio is what you want. Oh … it can also record your desktop screencast and save it locally.
### Theres More Where That Came From
This is a short list of screen recording solutions for Linux. Although there are plenty more where this came from, you should be able to fill all your desktop recording needs with one of these five apps.
Learn more about Linux through the free ["Introduction to Linux" ][18]course from The Linux Foundation and edX.
--------------------------------------------------------------------------------
via: https://www.linux.com/blog/intro-to-linux/2018/12/5-screen-recorders-linux-desktop
作者:[Jack Wallen][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.linux.com/users/jlwallen
[b]: https://github.com/lujun9972
[1]: http://www.maartenbaert.be/simplescreenrecorder/
[2]: /files/images/screenrecorder1jpg
[3]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/screenrecorder_1.jpg?itok=hZJ5xugI (Simple Screen Recorder )
[4]: /licenses/category/used-permission
[5]: http://www.maartenbaert.be/simplescreenrecorder/#download
[6]: http://recordmydesktop.sourceforge.net/about.php
[7]: /files/images/screenrecorder2jpg
[8]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/screenrecorder_2.jpg?itok=TEGXaVYI (gtk-recordmydesktop)
[9]: /files/images/screenrecorder3jpg
[10]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/screenrecorder_3.jpg?itok=cvtFjxen (Kazam)
[11]: https://github.com/vkohaupt/vokoscreen
[12]: /files/images/screenrecorder4jpg
[13]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/screenrecorder_4.jpg?itok=c3KVS954 (Vokoscreen)
[14]: https://github.com/vkohaupt/vokoscreen.git
[15]: https://obsproject.com/
[16]: /files/images/desktoprecorder5jpg
[17]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/desktoprecorder_5.jpg?itok=xyM-dCa7 (OBS Studio)
[18]: https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux

View File

@ -0,0 +1,102 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Automatic continuous development and delivery of a hybrid mobile app)
[#]: via: (https://opensource.com/article/18/12/hybrid-mobile-app-development)
[#]: author: (Angelo Manganiello https://opensource.com/users/amanganiello90)
Automatic continuous development and delivery of a hybrid mobile app
======
Hybrid apps are a good middle ground between native and web apps.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/idea_innovation_mobile_phone.png?itok=RqVtvxkd)
Offering a mobile app is essentially a business requirement for organizations today. One of the first steps in developing an app is to understand the different types—native, hybrid (or cross-platform), and web—so you can decide which one will best meet your needs.
### Native is better, right?
**Native apps** represent the vast majority of applications that people download every day. Native applications are developed specifically for an operating system. Thus, a native iOS application will not work on an Android system and vice versa. To develop a native app, you need to know two things:
1. How to develop in a specific programming language (e.g., Swift for Apple devices; Java for Android)
2. The app will not work for other platforms
Even though native apps will work only on the platform they're developed for, they have several notable advantages over hybrid and web apps:
* Increased speed, reliability, and responsiveness and higher resolution, all of which provide a better user experience
* May work offline/without internet service
* Easier access to all phone features (e.g., accelerometer, camera, microphone)
### But my business is still linked to the web…
Most companies have focused their resources on web development and now want to enter the mobile market. But many don't have the right technical resources to develop a native app for each platform. For these companies, **hybrid** development is the right choice. In this model, developers can use their existing frontend skills to develop a single, cross-platform mobile app.
![Hybrid mobile apps][2]
Hybrid apps are a good middle ground: they're faster and less expensive to develop than native apps, and they offer more possibilities than web apps. The tradeoffs are they don't perform as well as native apps and developers can't maintain their existing tight focus on web development (as they could with web apps).
If you already are a fan of the [Angular][3] cross-platform development framework, I recommend trying the [Ionic][4] framework, which "lets web developers build, test, and deploy cross-platform hybrid mobile apps." I see Ionic as an extension of the [Apache Cordova][5] framework, which enables a normal web app (JS, HTML, or CSS) to run as a mobile app in a container. Ionic uses the base Cordova features that support the Angular development for its user interface.
The advantage of this approach is simple: the Angular paradigm is maintained, so developers can continue writing [TypeScript][6] files but target a build for Android, iOS, and Windows by properly configuring the development environment. It also provides two important tools:
* An appealing design and widget that are very similar to a native app's, so your hybrid app will look less "web"
* Cordova Plugins allow the app to communicate with all phone features
### What about the Node.js backend?
The programming world likes to standardize, which is why hybrid apps are so popular. Frontend developers' common skills are useful in the mobile world. But if we have a technology stack for the user interface, why not focus on a single backend with the same programming paradigm?
This makes [Node.js][7] an appealing option. Node.js is a JavaScript runtime built on the Chrome V8 JavaScript engine. It can make the API development backend very fast and easy, and it integrates fully with web technologies. You can develop a Cordova plugin, using your Node.js backend, internally in your hybrid app, as I did with the [nodejs-cordova-plugin][8]. This plugin, following the Cordova guidelines, integrates a mobile-compatible version of the Node.js platform to provide a full-stack mobile app.
If you need a simple CRUD Node.js backend, you can use my [API][9] [node generator][9] that generates an app using a [MongoDB][10] embedded database.
![Cordova Full Stack application][12]
### Deploying your app
Open source offers everything you need to deploy your app in the best way. You just need a GitHub repository and a good continuous integration tool. I recommend [Travis-ci][13], an excellent tool that allows you to build and deploy your product for every commit.
Travis-ci is a fork of the better known [Jenkins][14]. Like with Jenkins, you have to configure your pipeline through a configuration file (in this case a **.travis.yml** file) in your GitHub repo. See the [.travis.yml file][15] in my repository as an example.
![](https://opensource.com/sites/default/files/uploads/3-travis-ci-process.png)
In addition, this pipeline automatically delivers and installs your app on [Appetize.io][16], a web-based iOS simulator and Android emulator, for testing.
You can learn more in the [Cordova Android][17] section of my GitHub repository.
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/12/hybrid-mobile-app-development
作者:[Angelo Manganiello][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/amanganiello90
[b]: https://github.com/lujun9972
[1]: /file/416441
[2]: https://opensource.com/sites/default/files/uploads/1-title.png (Hybrid mobile apps)
[3]: https://angular.io/
[4]: https://ionicframework.com/
[5]: https://cordova.apache.org/
[6]: https://www.typescriptlang.org/
[7]: https://nodejs.org/
[8]: https://github.com/fullStackApp/nodejs-cordova-plugin
[9]: https://github.com/fullStackApp/generator-full-stack-api
[10]: https://www.mongodb.com/
[11]: /file/416351
[12]: https://opensource.com/sites/default/files/uploads/2-cordova-full-stack-app.png (Cordova Full Stack application)
[13]: https://travis-ci.org/
[14]: https://jenkins.io/
[15]: https://github.com/amanganiello90/java-angular-web-app/blob/master/.travis.yml
[16]: https://appetize.io/
[17]: https://github.com/amanganiello90/java-angular-web-app#cordova-android

View File

@ -0,0 +1,132 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Plan your own holiday calendar at the Linux command line)
[#]: via: (https://opensource.com/article/18/12/linux-toy-cal)
[#]: author: (Jason Baker https://opensource.com/users/jason-baker)
Plan your own holiday calendar at the Linux command line
======
Link commands together to build a colorful calendar, and then whisk it away in a snowstorm.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-cal.png?itok=S0F8RY9k)
Welcome to today's installment of the Linux command-line toys advent calendar. If this is your first visit to the series, you might be asking yourself, whats a command-line toy. Even I'm not quite sure, but generally, it could be a game or any simple diversion that helps you have fun at the terminal.
It's quite possible that some of you will have seen various selections from our calendar before, but we hope theres at least one new thing for everyone.
We've somehow made it to the seventh day of our series without creating an actual calendar to celebrate with, so let's use a command-line tool to do that today: **cal**. By itself, **cal** is perhaps not the most amazing of tools, but we can use a few other utilities to spice it up a bit.
Chances are, **cal** is installed on your system already. To use it in this instance, just type **cal**.
```
$ cal
    December 2018  
Su Mo Tu We Th Fr Sa
                   1
 2  3  4  5  6  7  8
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
```
We aren't going to go into advanced usage in this article, so if you want to learn more about **cal** , go check out Opensource.com Community Moderator Don Watkin's excellent [overview of the date and cal commands][1].
Now, let's spice it up with a pretty box, as we covered in our previous Linux toy article. I'll use the diamonds box, and use a little bit of padding to get it nicely aligned.
```
$ cal | boxes -d diamonds -p a1l4t2 
       /\          /\          /\
    /\//\\/\    /\//\\/\    /\//\\/\
 /\//\\\///\\/\//\\\///\\/\//\\\///\\/\
//\\\//\/\\///\\\//\/\\///\\\//\/\\///\\
\\//\/                            \/\\//
 \/                                  \/
 /\           December 2018          /\
//\\      Su Mo Tu We Th Fr Sa      //\\
\\//                         1      \\//
 \/        2  3  4  5  6  7  8       \/
 /\        9 10 11 12 13 14 15       /\
//\\      16 17 18 19 20 21 22      //\\
\\//      23 24 25 26 27 28 29      \\//
 \/       30 31                      \/
 /\                                  /\
//\\/\                            /\//\\
\\///\\/\//\\\///\\/\//\\\///\\/\//\\\//
 \/\\///\\\//\/\\///\\\//\/\\///\\\//\/
    \/\\//\/    \/\\//\/    \/\\//\/
       \/          \/          \/
```
That looks nice, but for good measure, let's put the whole thing in a second box, just for fun. We'll use the scoll design this time.
```
cal | boxes -d diamonds -p a1t2l3 | boxes -a c -d scroll        
 / ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \
|  /~~\                                              /~~\  |
|\ \   |         /\          /\          /\         |   / /|
| \   /|      /\//\\/\    /\//\\/\    /\//\\/\      |\   / |
|  ~~  |   /\//\\\///\\/\//\\\///\\/\//\\\///\\/\   |  ~~  |
|      |  //\\\//\/\\///\\\//\/\\///\\\//\/\\///\\  |      |
|      |  \\//\/                            \/\\//  |      |
|      |   \/                                  \/   |      |
|      |   /\          December 2018           /\   |      |
|      |  //\\     Su Mo Tu We Th Fr Sa       //\\  |      |
|      |  \\//                        1       \\//  |      |
|      |   \/       2  3  4  5  6  7  8        \/   |      |
|      |   /\       9 10 11 12 13 14 15        /\   |      |
|      |  //\\     16 17 18 19 20 21 22       //\\  |      |
|      |  \\//     23 24 25 26 27 28 29       \\//  |      |
|      |   \/      30 31                       \/   |      |
|      |   /\                                  /\   |      |
|      |  //\\/\                            /\//\\  |      |
|      |  \\///\\/\//\\\///\\/\//\\\///\\/\//\\\//  |      |
|      |   \/\\///\\\//\/\\///\\\//\/\\///\\\//\/   |      |
|      |      \/\\//\/    \/\\//\/    \/\\//\/      |      |
|      |         \/          \/          \/         |      |
|      |                                            |      |
 \     |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|     /
  \   /                                              \   /
   ~~~                                                ~~~
```
Perfect. Now, here's where things get a little crazy. I like our design, but, I'd like to go all out. So I'm going to colorize it. But here in the Raleigh, NC office where Opensource.com's staff are based, there's a good chance for snow this weekend. So let's enjoy our colorized advent calendar, and then wipe it out with snow.
For the snow, I'm grabbing a nifty [snippet][2] of Bash and Gawk goodness I found over on CLIMagic. If you're not familiar with CLIMagic, go check out their [website][3] and follow them on [Twitter][4]. You'll be glad you did.
So here we go. Let's clear the screen, throw up our boxy calendar, colorize it, wait a few seconds, then snowstorm it away. All here at the terminal, in one line.
```
$ clear;cal|boxes -d diamonds -p a1t2l3|boxes -a c -d scroll|lolcat;sleep 3;while :;do echo $LINES $COLUMNS $(($RANDOM%$COLUMNS)) $(printf "\u2744\n");sleep 0.1;done|gawk '{a[$3]=0;for(x in a) {o=a[x];a[x]=a[x]+1;printf "\033[%s;%sH ",o,x;printf "\033[%s;%sH%s \033[0;0H",a[x],x,$4;}}'
```
And there we go.
![](https://opensource.com/sites/default/files/uploads/linux-toy-cal-animated.gif)
For this to work on your system, you'll need all of the referenced utilities (boxes, lolcat, cal, gawk, etc.), and you'll need to use a terminal emulator that supports Unicode.
Do you have a favorite command-line toy that you think I ought to profile? The calendar for this series is mostly filled out but I've got a few spots left. Let me know in the comments below, and I'll check it out. If there's space, I'll try to include it. If not, but I get some good submissions, I'll do a round-up of honorable mentions at the end.
Check out yesterday's toy, [Take a break at the Linux command line with Nyan Cat][5], and check back tomorrow for another!
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/12/linux-toy-cal
作者:[Jason Baker][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/jason-baker
[b]: https://github.com/lujun9972
[1]: https://opensource.com/article/16/12/using-calendar-function-linux
[2]: http://climagic.org/coolstuff/let-it-snow.html
[3]: http://climagic.org/
[4]: https://twitter.com/climagic
[5]: https://opensource.com/article/18/12/linux-toy-nyancat

View File

@ -0,0 +1,57 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Play Tetris at your Linux terminal)
[#]: via: (https://opensource.com/article/18/12/linux-toy-tetris)
[#]: author: (Jason Baker https://opensource.com/users/jason-baker)
Play Tetris at your Linux terminal
======
Recreate the magic of the 1980s with everyone's favorite tile-matching game, Tetris.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-tetris.png?itok=_UXtpgzN)
Thanks for joining us for today's installment of the Linux command-line toys advent calendar. If this is your first visit to the series, you might be asking yourself, whats a command-line toy. Even I'm not quite sure, but generally, it could be a game or any simple diversion that helps you have fun at the terminal.
It's quite possible that some of you will have seen various selections from our calendar before, but we hope theres at least one new thing for everyone.
I promised when I started this series I'd be including games, but so far I've neglected to, so let's fix that with today's selection: Tetris.
Tetris and I are almost exactly the same age, having first come into the world in the summer of 1984. Instead of rural North Carolina, though, Tetris originated in Moscow in what was at the time the Soviet Union.
After taking the world by storm, Tetris was cloned many, many times. I would suspect you could find a Tetris clone for just about any operating system in any language you looked for. Seriously, go look. There are some fun ones out there.
The [version][1] I'm bringing you for today's command-line toy is [written in Haskell,][1] and it's one of the better-done versions I've seen, with on-screen preview, score, help, and a clean look.
If you're willing to run a compiled binary from an untrusted source (I wouldn't recommend it), you can grab that directly, but for a safer approach, it's also easy to use a containerized version with [dex][2], or to install from source with [stack][3].
This particular Tetris clone is by Sam Tay and available under a BSD license. [Check it out][1]!
![](https://opensource.com/sites/default/files/uploads/linux-toy-tetris-animated.gif)
If you've got your own favorite Tetris clone (or maybe you've written your own?), let us know!
Do you have a favorite command-line toy that you think I ought to profile? The calendar for this series is mostly filled out but I've got a few spots left. Let me know in the comments below, and I'll check it out. If there's space, I'll try to include it. If not, but I get some good submissions, I'll do a round-up of honorable mentions at the end.
Check out yesterday's toy, [Plan your own holiday calendar at the Linux command line][4], and check back tomorrow for another!
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/12/linux-toy-tetris
作者:[Jason Baker][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/jason-baker
[b]: https://github.com/lujun9972
[1]: https://github.com/samtay/tetris
[2]: https://github.com/dockerland/dex
[3]: https://docs.haskellstack.org/en/stable/README/#how-to-install
[4]: https://opensource.com/article/18/12/linux-toy-cal

View File

@ -0,0 +1,52 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Powers of two, powers of Linux: 2048 at the command line)
[#]: via: (https://opensource.com/article/18/12/linux-toy-2048)
[#]: author: (Jason Baker https://opensource.com/users/jason-baker)
Powers of two, powers of Linux: 2048 at the command line
======
Looking for a terminal-based game to pass the time? Look no further than 2048-cli.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-2048.png?itok=3M6S-n1a)
Hello and welcome to today's installment of the Linux command-line toys advent calendar. Every day, we look at a different toy for your terminal: it could be a game or any simple diversion that helps you have fun.
Maybe you have seen various selections from our calendar before, but we hope theres at least one new thing for everyone.
Today's toy is a [command-line version][1] of one of my all-time favorite casual games, [2048][2] (which itself is a clone of another clone).
To play, you just slide blocks up, down, left, and right to combine matching pairs and increment numbers, until you've made a block that is 2048 in size. The catch (and the challenge), is that you can't just move one block; instead, you move every block on the screen.
It's simple, fun, and easy to get lost in it for hours. This 2048 clone, [2048-][1][cli][1], is by Marc Tiehuis and written in C, and made available as open source under an MIT license. You can find the source code [on GitHub][1], where you can also get installation instructions for your platform. Since it was packaged for Fedora, for me, installing it was as simple as:
```
$ sudo dnf install 2048-cli
```
That's it, have fun!
![](https://opensource.com/sites/default/files/uploads/linux-toy-2048-animated_0.gif)
Do you have a favorite command-line toy that you think I ought to profile? The calendar for this series is mostly filled out but I've got a few spots left. Let me know in the comments below, and I'll check it out. If there's space, I'll try to include it. If not, but I get some good submissions, I'll do a round-up of honorable mentions at the end.
Check out yesterday's toy, [Play Tetris at your Linux terminal][3], and check back tomorrow for another!
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/12/linux-toy-2048
作者:[Jason Baker][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/jason-baker
[b]: https://github.com/lujun9972
[1]: https://github.com/tiehuis/2048-cli
[2]: https://github.com/gabrielecirulli/2048
[3]: https://opensource.com/article/18/12/linux-toy-tetris

View File

@ -0,0 +1,174 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Update Ubuntu [Terminal & GUI Methods] It's FOSS)
[#]: via: (https://itsfoss.com/update-ubuntu/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
How to Update Ubuntu [Terminal & GUI Methods] It's FOSS
======
**This tutorial shows you how to update Ubuntu for both server and desktop versions. It also explains the difference between update and upgrade along with a few other things you should know about updates in Ubuntu Linux.**
If you are a new user and have been using Ubuntu for a few days or weeks, you might be wondering how to update your [Ubuntu][1] system for security patches, bug fixes and application upgrades.
Updating Ubuntu is absolutely simple. I am not exaggerating. Its as simple as running two commands. Let me give you more details on it.
Please note that the tutorial is valid for Ubuntu 18.04, 16.04 or any other version. The command line way is also valid for Ubuntu-based distributions like Linux Mint, Linux Lite, elementary OS etc.
### Update Ubuntu via Command Line
![How to Update Ubuntu][2]
On the desktop, open the terminal. You can find it in the menu or use the Ctrl+Alt+T [keyboard shortcut][3]. If you are logged on to an [Ubuntu server][4], you already have access to a terminal.
In the terminal, you just have to use the following command:
```
sudo apt update && sudo apt upgrade -y
```
It will ask for password and you can use your accounts password. You wont see the anything on the screen while typing so keep on typing your password and hit enter.
Now let me explain the above command.
Actually, its not a single command. Its a combination of two commands. The && is a way to combine two commands in a way that the second command runs only when the previous command ran successfully.
The -y in the end automatically enters yes when the command apt upgrade ask for your confirmation before installing the updates.
Note that you can also use the two commands separately, one by one:
```
sudo apt update
sudo apt upgrade
```
It will take a little longer because you have to wait for one command to finish and then enter the second command.
#### Explanation: sudo apt update
This command updates the local database of available packages. If you wont run this command, the local database wont be updated and your system will not know if there are any new versions available.
This is why when you run the sudo apt update, youll see lots of URLs in the output. The command fetches the package information from the respective repositories (the URLs you see in the output).
![Updating Ubuntu Linux][5]
At the end of the command, it tells you how many packages can be upgraded. You can see these packages by running the following command:
```
apt list --upgradable
```
**Additional Reading:** Read this article to learn [what is Ign, Hit and Get in the apt update command output][6].
#### Explanation: sudo apt upgrade
This command matches the versions of installed packages with the local database. It collects all of them and then it will list all of the packages that have a newer version available. At this point, it will ask if you want to upgrade (the installed packages to the newer version).
![Update Ubuntu Linux via Command Line][7]
You can type yes, y or just press enter to confirm the installation of updates.
So the bottom line is that the sudo apt update checks for the availability of new versions while as the sudo apt upgrade actually performs the update.
The term update might be confusing as you might expect the apt update command to update the system by installing the updates but that doesnt happen.
### Update Ubuntu via GUI [For Desktop Users]
If you are using Ubuntu as a desktop, you dont have to go to terminal just for updating the system. You can still use the command line but its optional for you.
In the menu, look for Software Updater and run it.
![Run Software Updater in Ubuntu][8]
It will check if there are updates available for your system.
![Checking if updates are available for Ubuntu][9]
If there are updates available, it will give provide you with options to install the updates.
![Install Updates via Update Manager in Ubuntu][10]
Click on Install Now, it may ask for your password.
![Installing Updates in Ubuntu Linux via GUI][11]
Once you enter your password, it will start installing the updates.
![Updating Ubuntu via GUI][12]
In some cases, you may need to reboot the system for the installed updates to work properly. Youll be notified at the end of the update if you need to restart the system.
![Updating Ubuntu via GUI][12]
You can choose to restart later if you dont want to reboot your system straightaway.
![Installing updates via GUI in Ubuntu][13]
Tip: If the software updater returns an error, you should use the command sudo apt update in the terminal. The last few lines of the output will contain the actual error message. You can search on the internet for that error and fix the problem.
### Few things to keep in mind abou updating Ubuntu
You just learned how to update your Ubuntu system. If you are interested, you should also know these few things around Ubuntu updates.
#### Clean up after an update
Your system will have some unnecessary packages that wont be required after the updates. You can remove such packages and [free up some space][14] using this command:
```
sudo apt autoremove
```
#### Live patching kernel in Ubuntu Server to avoid rebooting
In case of a Linux kernel updates, youll have to restart the system after the update. This is an issue when you dont want downtime for your server.
[Live patching][15] feature allows the patching of Linux kernel while the kernel is still running. In other words, you dont have to reboot your system.
If you manage servers, you may want to [enable live patching in Ubuntu][16].
#### Version upgrades are different
The updates discussed here is to keep your Ubuntu install fresh and updated. It doesnt cover the [version upgrades][17] (for example upgrading Ubuntu 16.04 to 18.04).
[Ubuntu version][18] upgrades are entirely a different thing. It updates the entire operating system core. You need to make proper backups before starting this lengthy process.
### Conclusion
I hope you liked this tutorial on updating the Ubuntu system and you learned a few new things.
If you have any questions, please fee free to ask. If you are an experienced Linux users and have some tip that can make this tutorial more useful, please share it with the rest of us.
--------------------------------------------------------------------------------
via: https://itsfoss.com/update-ubuntu/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/abhishek/
[b]: https://github.com/lujun9972
[1]: https://www.ubuntu.com/
[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/12/how-to-update-ubuntu.png?resize=800%2C450&ssl=1
[3]: https://itsfoss.com/ubuntu-shortcuts/
[4]: https://www.ubuntu.com/download/server
[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/12/update-ubunt-1.jpeg?resize=800%2C357&ssl=1
[6]: https://itsfoss.com/apt-get-linux-guide/
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/12/update-ubunt-2.jpeg?ssl=1
[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/12/update-ubuntu-via-GUI-1.jpeg?resize=800%2C250&ssl=1
[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/12/update-ubuntu-via-GUI-2.jpeg?resize=800%2C250&ssl=1
[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/12/update-ubuntu-GUI-3.jpeg?resize=800%2C365&ssl=1
[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/12/install-update-ubuntu-1.jpg?resize=800%2C450&ssl=1
[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/12/installing-updates-ubuntu.jpg?ssl=1
[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/12/installing-updates-ubuntu-2.jpeg?ssl=1
[14]: https://itsfoss.com/free-up-space-ubuntu-linux/
[15]: https://www.ubuntu.com/livepatch
[16]: https://www.cyberciti.biz/faq/howto-live-patch-ubuntu-linux-server-kernel-without-rebooting/
[17]: https://itsfoss.com/upgrade-ubuntu-version/
[18]: https://itsfoss.com/how-to-know-ubuntu-unity-version/

View File

@ -1,114 +0,0 @@
当 NASA 开始应用开放科学
======
![][1]
最近我们刚为 NASA 在它的自由开源软件上新开放了[科学][2]板块。其中发表的最新一篇文章名为:[开源手段是怎样影响科学的][3]。在这篇文章中我们主要讨论的是 [NASA][4] 在鼓励使用开源工具之后,是怎样在大量的科研机构潮流中保持自身的动态角色,实现快速发展的。
### NASA 是怎样使用开源手段促进科学研究的
NASA 将他们的整个研究库对整个公共域开放,这是一项[壮举][5]。
没错!每个人都能访问他们的研究库,并能从他们的研究中获益。
他们现已开放的资料可以大致分为一下三类:
* 开放的 NASA 资源
* 开放的应用程序编程接口
* 开放的资料
#### 1\.开放的 NASA 资源
采访 [GitHub][7] 的联合创始人之一和执行总裁 [Chris Wanstrath][6] 时,他向我们介绍道,一切都是从很多年前开始的。
NASA 的账号叫做 “[code.nasa.gov][8]“, 截至现在为止NASA 已经[通过 GitHub 开放][9]了365个科学软件对于一位热爱程序的开发者来说即使一天研究一个软件想把NASA的这些软件全部研究过来也要整整一年的时间。
即使你不是一位开发者,你也可以在入口网站浏览这些壮观软件合集的统计列表。
其中就有[阿波罗11号][10]的制导计算机的源代码。阿波罗11号空间飞行器[首次将两名人类带上月球][11],分别是 [Neil Armstrong][12] 和 [Edwin Aldrin][13] 。如果你对 Edwin Aldrin 感兴趣,可以点击[这里][14]了解更多。
##### NASA 开源代码促进会使用的开源代码许可:
这里有几种[开源代码许可][15],其分类如下:
#### 2\.开放的应用程序编程接口API
开放的[应用程序设计接口][16]或者应用程序编程接口在推行开源技术中起到了很大作用。与[开源代码促进会][17]类似,开放的应用程序编程接口有它们的[开放平台促进会][18]。下面这张示意图可以告诉你 API 是怎样将应用程序和它的开发者连接起来的。
![][19]
记得点击图片上面的链接看看。链接内的文章使用了简单易懂的方法解读 API ,文末将 API 总结为五种架构。
![][20]
这让人忍不住想象由专有 API 变成开放 API 会有多么大的不同。
![][22]
[NASA 的开放 API][23] 主要针对应用程序开发者,大大提高了包括图片内容在内的数据可及性,这是前所未有的。网站设有活动编辑器,为需要查阅[每日天文一图][24]板块 [API][16] 的用户们授权。
#### 3\.开放的资料
![][25]
在[我们发布的第一篇科学文章][3]中我们介绍了“开放科学”板块下提到的三个国家——法国印度和美国的多种开放资料形式。NASA 有着类似的想法和行为。这种意识形态已经被[多个国家][26]所接受。
[NASA 的开放数据门户][27]致力于不断扩大的可供大众使用的开放数据目录。这个数据集的内容对于任何研究活动来说都是必要且重要的。NASA 还在他们的门户网站上征集各方的数据,以一同收录在他们的数据库中。这一行为不仅是领先的,创新的,还顺应了[数据科学][28]和 [AI 深度学习][29]的趋势。
下面的视频讲的是学者和学生们是怎样通过大量研究得出对数据科学的定义的。这个过程十分的激动人心。瑞尔森大学罗杰斯商学院的 [Murtaza Haider 教授][30]在视频中提到了开源的出现对数据科学的改变,尤其让是旧有的封闭发展模式逐渐变得开放。而这也确实成为了现实。
![][31]
现在任何人都能在 NASA 上提交数据。正如视频中所说, NASA 的领先方案很大程度上与征集和分析优化数据有关。
![][32]
你只需要进行免费注册。考虑到论坛上的公开讨论走向和在任何统计分析环境下都能运行的数据集,这个方案在未来会有非常积极的影响,对数据的统计分析当然也会大幅进展。在之后的文章中我们还会具体讨论这些细节,还有他们和开源模式之间的相关性。
以上就是对 NASA 开放科学模式的一些探索成就,希望您能继续关注我们接下来的相关文章!
--------------------------------------------------------------------------------
via: https://itsfoss.com/nasa-open-science/
作者:[Avimanyu Bandyopadhyay][a]
译者:[Valoniakim](https://github.com/Valoniakim)
校对:[校对者ID](https://github.com/校对者ID)
选题:[lujun9972](https://github.com/lujun9972)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/avimanyu/
[1]:https://itsfoss.com/wp-content/uploads/2018/03/tux-in-space.jpg
[2]:https://itsfoss.com/category/science/
[3]:https://itsfoss.com/open-source-impact-on-science/
[4]:https://www.nasa.gov/
[5]:https://futurism.com/free-science-nasa-just-opened-its-entire-research-library-to-the-public/
[6]:http://chriswanstrath.com/
[7]:https://github.com/
[8]:http://code.nasa.gov
[9]:https://github.com/open-source
[10]:https://www.nasa.gov/mission_pages/apollo/missions/apollo11.html
[11]:https://www.space.com/16758-apollo-11-first-moon-landing.html
[12]:https://www.jsc.nasa.gov/Bios/htmlbios/armstrong-na.html
[13]:https://www.jsc.nasa.gov/Bios/htmlbios/aldrin-b.html
[14]:https://buzzaldrin.com/the-man/
[15]:https://itsfoss.com/open-source-licenses-explained/
[16]:https://en.wikipedia.org/wiki/Application_programming_interface
[17]:https://opensource.org/
[18]:https://www.openapis.org/
[19]:https://itsfoss.com/wp-content/uploads/2018/03/api-bridge.jpeg
[20]:https://itsfoss.com/wp-content/uploads/2018/03/open-api-diagram.jpg
[21]:http://www.apiacademy.co/resources/api-strategy-lesson-201-private-apis-vs-open-apis/
[22]:https://itsfoss.com/wp-content/uploads/2018/03/nasa-open-api-live-example.jpg
[23]:https://api.nasa.gov/
[24]:https://apod.nasa.gov/apod/astropix.html
[25]:https://itsfoss.com/wp-content/uploads/2018/03/nasa-open-data-portal.jpg
[26]:https://www.xbrl.org/the-standard/why/ten-countries-with-open-data/
[27]:https://data.nasa.gov/
[28]:https://en.wikipedia.org/wiki/Data_science
[29]:https://www.kdnuggets.com/2017/07/ai-deep-learning-explained-simply.html
[30]:https://www.ryerson.ca/tedrogersschool/bm/programs/real-estate-management/murtaza-haider/
[31]:https://itsfoss.com/wp-content/uploads/2018/03/suggest-dataset-nasa-1.jpg
[32]:https://itsfoss.com/wp-content/uploads/2018/03/suggest-dataset-nasa-2-1.jpg

View File

@ -0,0 +1,231 @@
使用Ansible来管理你的工作站配置自动化
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/robot_arm_artificial_ai.png?itok=8CUU3U_7)
Ansible是一个令人惊讶的自动化的配置管理工具。主要应用在服务器和云部署上但在工作站上的应用无论是台式机还是笔记本却得到了很少的关注这就是本系列所要关注的。
在这个系列的第一部分,我会向你展示'ansible-pull'命令的基本用法我们创建了一个安装了少量包的palybook.它本身是没有多大的用处的,但是它为后续的自动化做了准备。
在这篇文章中所有的事件操作都是闭环的而且在最后部分我们将会有一个针对工作站自动配置的完整的工作解决方案。现在我们将要设置Ansible的配置这样未来将要做的改变将会自动的部署应用到我们的工作站上。现阶段假设你已经完成了第一部分的工作。如果没有的话当你完成的时候回到本文。你应该已经有一个包含第一篇文章中代码的Github库。我们将直接按照之前的方式创建。
首先,因为我们要做的不仅仅是安装包文件,所以我们要做一些重新的组织工作。现在,我们已经有一个名为'local.yml'并包含以下内容的playbook:
```
- hosts: localhost
become: true
tasks:
- name: Install packages
apt: name={{item}}
with_items:
- htop
- mc
- tmux
```
如果我们仅仅想实现一个任务那么上面的配置就足够了。随着向我们的配置中不断的添加内容这个文件将会变的相当的庞大和杂乱。最好能够根据不同类型的配置将play文件分为独立的文件。为了达到这个要求创建一个名为taskbook的文件它和playbook很像但内容更加的流线型。让我们在Git库中为taskbook创建一个目录。
```
mkdir tasks
```
在'local.yml'playbook中的代码使它很好过过渡到成为安装包文件的taskbook.让我们把这个文件移动到刚刚创建好并新命名的目录中。
```
mv local.yml tasks/packages.yml
```
现在,我们编辑'packages.yml'文件将它进行大幅的瘦身,事实上,我们可以精简除了独立任务本身之外的所有内容。让我们把'packages.yml'编辑成如下的形式:
```
- name: Install packages
apt: name={{item}}
with_items:
- htop
- mc
- tmux
```
正如你所看到的它使用同样的语法但我们去掉了对这个任务无用没有必要的所有内容。现在我们有了一个专门安装包文件的taskbook.然而我们仍然需要一个名为'local.yml'的文件,因为执行'ansible-pull'命令时仍然会去发现这个文件。所以我们将在我们库的根目录下(不是在'task'目录下)创建一个包含这些内容的全新文件:
```
- hosts: localhost
become: true
pre_tasks:
- name: update repositories
apt: update_cache=yes
changed_when: False
tasks:
- include: tasks/packages.yml
```
这个新的'local.yml'扮演的是将要导入我们的taksbooks的主页的角色。我已经在这个文件中添加了一些你在这个系列中看不到的内容。首先在这个文件的开头处我添加了'pre——tasks',这个任务的作用是在其他所有任务运行之前先运行某个任务。在这种情况下我们给Ansible的命令是让它去更新我们的分布存储库主页下面的配置将执行这个任务要求
```
apt: update_cache=yes
```
通常'apt'模块是用来安装包文件的但我们也能够让它来更新库索引。这样做的目的是让我们的每个play在Ansible运行的时候能够以最新的索引工作。这将确保我们在使用一个老旧的索引安装一个包的时候不会出现问题。因为'apt'模块仅仅在DebianUbuntu和他们的衍生环境下工作。如果你运行的一个不同的环境你期望在你的环境中使用一个特殊的模块而不是'apt'。如果你需要使用一个不同的模块请查看Ansible的相关文档。
下面这行值得以后解释:
```
changed_when: False
```
在独立任务中的这行阻止了Ansible去报告play改变的结果即使是它本身在系统中导致的一个改变。在这中情况下我们不会去在意库索引是否包含新的数据它几乎总是会的因为库总是在改变的。我们不会去在意'apt'库的改变,因为索引的改变是正常的过程。如果我们删除这行,我们将在过程保告的后面看到所有的变动,即使仅仅库的更新而已。最好能够去忽略这类的改变。
接下来是常规任务的阶段我们将创建好的taskbook导入。我们每次添加另一个taskbook的时候要添加下面这一行
```
tasks:
- include: tasks/packages.yml
```
如果你将要运行'ansible-pull'命令,他应该向上一篇文章中的那样做同样重要的事情。 不同的是我们已经提高了我们的组织并且能够更有效的扩展它。'ansible-pull'命令的语法,为了节省你到上一篇文章中去寻找,参考如下:
```
sudo ansible-pull -U https://github.com/<github_user>/ansible.git
```
如果你还记得话,'ansible-pull'的命令拉取一个Git库并且应用了它所包含的配置。
既然我们的基础已经搭建好我们现在可以扩展我们的Ansible并且添加功能。更特别的是我们将添加配置来自动化的部署对工作站要做的改变。为了支撑这个要求首先我们要创建一个特殊的账户来应用我们的Ansible配置。这个不是必要的我们仍然能够在我们自己的用户下运行Ansible配置。但是使用一个隔离的用户能够将其隔离到不需要我们参与的在后台运行的一个系统进程中
我们可以使用常规的方式来创建这个用户但是既然我们正在使用Ansible,我们应该尽量避开使用手动的改变。替代的是我们将会创建一个taskbook来处理用户的创建任务。这个taskbook目前将会仅仅创建一个用户但你可以在这个taskbook中添加额外的plays来创建更多的用户。我将这个用户命名为'ansible',你可以按照自己的想法来命名(如果你做了这个改变要确保更新所有的变动)。让我们来创建一个名为'user.yml'的taskbook并且将以下代码写进去
```
- name: create ansible user
user: name=ansible uid=900
```
下一步,我们需要编辑'local.yml'文件将这个新的taskbook添加进去像如下这样写
```
- hosts: localhost
become: true
pre_tasks:
- name: update repositories
apt: update_cache=yes
changed_when: False
tasks:
- include: tasks/users.yml
- include: tasks/packages.yml
```
现在当我们运行'ansible-pull'命令的时候,一个名为'ansible'的用户将会在系统中被创建。注意我特地通过参数'UID'为这个用户声明了用户ID为900。这个不是必须的但建议直接创建好UID。因为在1000以下的UID在登陆界面是不会显示的这样是很棒的因为我们根本没有需要去使用'ansibe'账户来登陆我们的桌面。UID 900是固定的它应该是在1000以下没有被使用的任何一个数值。你可以使用以下命令在系统中去验证UID 900是否已经被使用了
```
cat /etc/passwd |grep 900
```
然而你使用这个UID应该不会遇到什么问题因为迄今为止在我使用的任何发行版中我还没遇到过它是被默认使用的。
现在,我们已经拥有了一个名为'ansible'的账户,它将会在之后的自动化配置中使用。接下来,我们可以创建实际的定时作业来自动操作它。而不是将其放置到我们刚刚创建的'users.yml'文件中,我们应该将其分开放到它自己的文件中。在任务目录中创建一个名为'cron.yml'的taskbook并且将以下的代买写进去
```
- name: install cron job (ansible-pull)
cron: user="ansible" name="ansible provision" minute="*/10" job="/usr/bin/ansible-pull -o -U https://github.com/<github_user>/ansible.git > /dev/null"
```
定时模块的语法几乎是不需加以说明的。通过这个play,我们创建了一个通过用户'ansible'运行的定时作业。这个作业将每隔10分钟执行一次下面是它将要执行的命令
```
/usr/bin/ansible-pull -o -U https://github.com/<github_user>/ansible.git > /dev/null
```
同样我们也可以添加想要我们的所有工作站部署的额外定时作业到这个文件中。我们只需要在新的定时作业中添加额外的palys即可。然而仅仅是添加一个定时的taskbook是不够的我们还需要将它添加到'local.yml'文件中以便它能够被调用。将下面的一行添加到末尾:
```
- include: tasks/cron.yml
```
现在当'ansible-pull'命令执行的时候,它将会以通过用户'ansible'每个十分钟设置一个新的定时作业。但是每个十分钟运行一个Ansible作业并不是一个好的方式因为这个将消耗很多的CPU资源。每隔十分钟来运行对于Ansible来说是毫无意义的除非欧文已经在Git库中改变一些东西。
然而,我们已经解决了这个问题。注意到我在定时作业中的命令'ansible-pill'添加的我们之前从未用到过的参数'-o'.这个参数告诉Ansible只有在从上次'ansible-pull'被调用以后库有了变化后才会运行。如果库没有任何变化他将不会做任何事情。通过这个方法你将不会无端的浪费CPU资源。当然一些CPU资源将会在下来存储库的时候被使用但不会像再一次应用整个配置的时候使用的那么多。当'ansible-pull'执行的时候它将会遍历在playbooks和taskbooks中的所有任务但至少它不会毫无目的的运行。
尽管我们已经添加了所有必须的配置要素来自动化'ansible-pull',它任然还不能正常的工作。'ansible-pull'命令需要sudo的权限来运行这将允许它执行系统级的命令。然而我们创建的用户'ansible'并没有被设置为以'sudo'的权限来执行命令,因此当定时作业触发的时候,执行将会失败。通常沃恩可以使用命令'visudo'来手动的去设置用户'ansible'的拥有这个权限。然而我们现在应该以Ansible的方式来操作而且这将会是一个向你展示'copy'模块是如何工作的机会。'copy'模块允许你从库复制一个文件到文件系统的任何位置。在这个案列中,我们将会复制'sudo'的一个配置文件到'/etc/sudoers.d/'以便用户'ansible'能够以管理员的权限执行任务。
打开'users.yml',将下面的play添加到文件末尾。
```
- name: copy sudoers_ansible
copy: src=files/sudoers_ansible dest=/etc/sudoers.d/ansible owner=root group=root mode=0440
```
'copy'模块,正如我们看到的,从库复制一个文件到其他任何位置。在这个过程中,我们正在抓取一个名为'sudoers_ansible'(我们将在后续创建)的文件并将它复制到拥有者为'root'的'/etc/sudoers/ansible'中。
接下来,我们需要创建我们将要复制的文件。在你的库的根目录下,创建一个名为'files'的目录:
```
mkdir files
```
然后,在我们刚刚创建的'files'目录里,创建包含以下内容的名为'sudoers_ansible'的文件:
```
ansible ALL=(ALL) NOPASSWD: ALL
```
在'/etc/sudoer.d'目录里创建一个文件,就像我们正在这样做的,允许我们为一个特殊的用户配置'sudo'权限。现在我们正在通过'sudo'允许用户'ansible'不需要密码拥有完全控制权限。这将允许'ansible-pull'以后台任务的形式运行而不需要手动去运行。
现在,你可以通过再次运行'ansible-pull'来拉取最新的变动:
```
sudo ansible-pull -U https://github.com/<github_user>/ansible.git
```
从这个节点开始,'ansible-pull'的定时作业将会在后台每隔十分钟运行一次来检查你的库是否有变化如果它发现有变化将会运行你的palybook并且应用你的taskbooks.
所以现在我们有了一个完整的工作方案。当你第一次设置一台新的笔记本或者台式机的时候,你要去手动的运行'ansible-pull'命令,但仅仅是在第一次的时候。从第一次之后,用户'ansible'将会在后台接手后续的运行任务。当你想对你的机器做变动的时候你只需要简单的去拉取你的Git库来做变动然后将这些变化回传到库中。接着当定时作业下次在每台机器上运行的时候它将会拉取变动的部分并应用它们。你现在只需要做一次变动你的所有工作站将会跟着一起变动。这方法尽管有一点不方便通常你会有一个你的机器列表的文件和包含不同机器的规则。不管怎样'ansible-pull'的方法,就像在文章中描述的,是管理工作站配置的非常有效的方法。
我已经在我的[Github repository]中更新了这篇文章中的代码,所以你可以随时去浏览来再一次检查你的语法。同时我将前一篇文章中的代码移到了它自己的目录中。
在第三部分我们将通过介绍使用Ansible来配置GNOME桌面设置来结束这个系列。我将会告诉你如何设置你的墙纸和锁屏壁纸应用一个桌面主题以及更多的东西。
同时到了布置一些作业的时候了大多数人有我们使用的各种应用的配置文件。可能是Bash,Vim或者其他你使用的工具的配置文件。现在你可以尝试通过我们在使用的Ansible库来自动复制这些配置到你的机器中。在这篇文章中我已将想你展示了如何去复制文件所以去尝试以下看看你是都已经能应用这些知识。
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/3/manage-your-workstation-configuration-ansible-part-2
作者:[Jay LaCroix][a]
译者:[FelixYFZ](https://github.com/FelixYFZ)
校对:[校对者ID](https://github.com/校对者ID)
选题:[lujun9972](https://github.com/lujun9972)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/jlacroix
[1]:https://opensource.com/article/18/3/manage-workstation-ansible
[2]:https://github.com/jlacroix82/ansible_article.git