Merge pull request #24 from LCTT/master

更新 20190424
This commit is contained in:
FSSlc 2019-04-24 12:29:14 +08:00 committed by GitHub
commit c20dc4d597
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 1262 additions and 210 deletions

View File

@ -0,0 +1,48 @@
[#]: collector: (lujun9972)
[#]: translator: (MjSeven)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-10769-1.html)
[#]: subject: (Which programming languages should you learn?)
[#]: via: (https://opensource.com/article/19/2/which-programming-languages-should-you-learn)
[#]: author: (Marty Kalin https://opensource.com/users/mkalindepauledu)
你应该学习哪种编程语言?
======
> 学习一门新的编程语言是在你的职业生涯中继续前进的好方法,但是应该学习哪一门呢?
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/search_find_code_issue_bug_programming.png?itok=XPrh7fa0)
如果你想要开始你的编程生涯或继续前进,那么学习一门新语言是一个聪明的主意。但是,大量活跃使用的语言引发了一个问题:哪种编程语言是最好的?要回答这个问题,让我们从一个简单的问题开始:你想做什么样的程序?
如果你想在客户端进行网络编程,那么特定语言 HTML、CSS 和 JavaScript看似无穷无尽的方言之一是必须要学习的。
如果你想在服务器端进行 Web 编程那么选择包括常见的通用语言C++、Golang、Java、C#、 Node.js、Perl、Python、Ruby 等等。当然,服务器程序与数据存储(例如关系数据库和其他数据库)打交道,这意味着 SQL 等查询语言可能会发挥作用。
如果你正在为移动设备编写原生应用程序,那么了解目标平台非常重要。对于 Apple 设备Swift 已经取代 Objective C 成为首选语言。对于 Android 设备Java带有专用库和工具集仍然是主要语言。有一些特殊语言如与 C# 一起使用的 Xamarin可以为 Apple、Android 和 Windows 设备生成特定于平台的代码。
那么通用语言呢?通常有各种各样的选择。在*动态*或*脚本*语言(如 Perl、Python 和 Ruby有一些新东西如 Node.js。而 Java 和 C# 的相似之处比它们的粉丝愿意承认的还要多,仍然是针对虚拟机(分别是 JVM 和 CLR的主要*静态编译*语言。在可以编译为*原生可执行文件*的语言中C++ 仍在使用,还有后来出现的 Golang 和 Rust 等。通用的*函数式*语言比比皆是(如 Clojure、Haskell、Erlang、F#、Lisp 和 Scala它们通常都有热情投入的社区。值得注意的是面向对象语言如 Java 和 C#)已经添加了函数式构造(特别是 lambdas而动态语言从一开始就有函数式构造。
让我以 C 语言结尾,它是一种小巧、优雅、可扩展的语言,不要与 C++ 混淆。现代操作系统主要用 C 语言编写,其余部分用汇编语言编写。任何平台上的标准库大多数都是用 C 语言编写的。例如,任何打印 `Hello, world!` 这种问候都是通过调用名为 `write` 的 C 库函数来实现的。
C 作为一种可移植的汇编语言,公开了其他高级语言有意隐藏的底层系统的详细信息。因此,理解 C 可以更好地掌握程序如何竞争执行所需的共享系统资源(如处理器、内存和 I/O 设备。C 语言既高级又接近硬件因此在性能方面无与伦比当然汇编语言除外。最后C 是编程语言中的通用语言,几乎所有通用语言都支持某种形式的 C 调用。
有关现代 C 语言的介绍,参考我的书籍 《[C 语言编程:可移植的汇编器介绍][1]》。无论你怎么做,学习 C 语言,你会学到比另一种编程语言多得多的东西。
你认为学习哪些编程语言很重要?你是否同意这些建议?在评论告知我们!
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/2/which-programming-languages-should-you-learn
作者:[Marty Kalin][a]
选题:[lujun9972][b]
译者:[MjSeven](https://github.com/MjSeven)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/mkalindepauledu
[b]: https://github.com/lujun9972
[1]: https://www.amazon.com/dp/1977056954?ref_=pe_870760_150889320

View File

@ -0,0 +1,117 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-10771-1.html)
[#]: subject: (Managing Partitions with sgdisk)
[#]: via: (https://fedoramagazine.org/managing-partitions-with-sgdisk/)
[#]: author: (Gregory Bartholomew https://fedoramagazine.org/author/glb/)
使用 sgdisk 管理分区
======
![][1]
[Roderick W. Smith][2] 的 `sgdisk` 命令可在命令行中管理硬盘的分区。下面将介绍使用它所需的基础知识。
使用 sgdisk 的大多数基本功能只需要了解以下六个参数:
1、`-p` *打印* 分区表:
```
# sgdisk -p /dev/sda
```
2、 `-d x` *删除* 分区 x
```
# sgdisk -d 1 /dev/sda
```
3、 `-n x:y:z` 创建一个编号 x 的*新*分区,从 y 开始,从 z 结束:
```
# sgdisk -n 1:1MiB:2MiB /dev/sda
```
4、`-c x:y` *更改*分区 x 的名称为 y
```
# sgdisk -c 1:grub /dev/sda
```
5、`-t x:y` 将分区 x 的*类型*更改为 y
```
# sgdisk -t 1:ef02 /dev/sda
```
6、`list-types` 列出分区类型代码:
```
# sgdisk --list-types
```
![The SGDisk Command][3]
如你在上面的例子中所见,大多数命令都要求将要操作的硬盘的[设备文件名][4]指定为最后一个参数。
可以组合上面的参数,这样你可以一次定义所有分区:
```
# sgdisk -n 1:1MiB:2MiB -t 1:ef02 -c 1:grub /dev/sda
```
在值的前面加上 `+``` 符号,可以为某些字段指定相对值。如果你使用相对值,`sgdisk` 会为你做数学运算。例如,上面的例子可以写成:
```
# sgdisk -n 1:1MiB:+1MiB -t 1:ef02 -c 1:grub /dev/sda
```
`0` 值对于以下几个字段有特殊意义:
* 对于*分区号*字段0 表示应使用下一个可用编号(编号从 1 开始)。
* 对于*起始地址*字段0 表示使用最大可用空闲块的头。硬盘开头的一些空间始终保留给分区表本身。
* 对于*结束地址*字段0 表示使用最大可用空闲块的末尾。
通过在适当的字段中使用 `0` 和相对值,你可以创建一系列分区,而无需预先计算任何绝对值。例如,如果在一块空白硬盘中,以下 `sgdisk` 命令序列将创建典型 Linux 安装所需的所有基本分区:
```
# sgdisk -n 0:0:+1MiB -t 0:ef02 -c 0:grub /dev/sda
# sgdisk -n 0:0:+1GiB -t 0:ea00 -c 0:boot /dev/sda
# sgdisk -n 0:0:+4GiB -t 0:8200 -c 0:swap /dev/sda
# sgdisk -n 0:0:0 -t 0:8300 -c 0:root /dev/sda
```
上面的例子展示了如何为基于 BIOS 的计算机分区硬盘。基于 UEFI 的计算机上不需要 [grub 分区][5]。由于 `sgdisk` 在上面的示例中为你计算了所有绝对值,因此你可以在基于 UEFI 的计算机上跳过第一个命令,并且可以无需修改即可运行其余命令。同样,你可以跳过创建交换分区,并且不需要修改其余命令。
还有使用一个命令删除硬盘上所有分区的快捷方式:
```
# sgdisk --zap-all /dev/sda
```
关于最新和详细信息,请查看手册页:
```
$ man sgdisk
```
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/managing-partitions-with-sgdisk/
作者:[Gregory Bartholomew][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://fedoramagazine.org/author/glb/
[b]: https://github.com/lujun9972
[1]: https://fedoramagazine.org/wp-content/uploads/2019/04/managing-partitions-816x345.png
[2]: https://www.rodsbooks.com/
[3]: https://fedoramagazine.org/wp-content/uploads/2019/04/sgdisk.jpg
[4]: https://en.wikipedia.org/wiki/Device_file
[5]: https://en.wikipedia.org/wiki/BIOS_boot_partition

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -1,68 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Linux Foundation Training Courses Sale & Discount Coupon)
[#]: via: (https://itsfoss.com/linux-foundation-discount-coupon/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
Linux Foundation Training Courses Sale & Discount Coupon
======
Linux Foundation is the non-profit organization that employs Linux creator Linus Torvalds and manages the development of the Linux kernel. Linux Foundation aims to promote the adoption of Linux and Open Source in the industry and it is doing a great job in this regard.
Open Source jobs are in demand and no one knows is better than Linux Foundation, the official Linux organization. This is why the Linux Foundation provides a number of training and certification courses on Linux related technology. You can browse the [entire course offering on Linux Foundations training webpage][1].
### Linux Foundation Latest Offer: 40% off on all courses [Limited Time]
At present Linux Foundation is offering some great offers for sysadmin, devops and cloud professionals.
At present, Linux Foundation is offering massive discount of 40% on the entire range of their e-learning courses and certification bundles, including the growing catalog of cloud and devops e-learning courses like Kubernetes!
Just use coupon code **APRIL40** at checkout to get your discount.
[Linux Foundation 40% Off (Coupon Code APRIL40)][2]
_Do note that this offer is valid till 22nd April 2019 only._
### Linux Foundation Discount Coupon [Valid all the time]
You can get a 16% off on any training or certification course provided by The Linux Foundation at any given time. All you have to do is to use the coupon code **FOSS16** at the checkout page.
Note that it might not be combined with sysadmin day offer.
[Get 16% off on Linux Foundation Courses with FOSS16 Code][1]
This article contains affiliate links. Please read our [affiliate policy][3].
#### Should you get certified?
![][4]
This is the question I have been asked regularly. Are Linux certifications worth it? The short answer is yes.
As per the [open source jobs report in 2018][5], over 80% of open source professionals said that certifications helped with their careers. Certifications enable you to demonstrate technical knowledge to potential employers and thus certifications make you more employable in general.
Almost half of the hiring managers said that employing certified open source professionals is a priority for them.
Certifications from a reputed authority like Linux Foundation, Red Hat, LPIC etc are particularly helpful when you are a fresh graduate or if you want to switch to a new domain in your career.
--------------------------------------------------------------------------------
via: https://itsfoss.com/linux-foundation-discount-coupon/
作者:[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://shareasale.com/u.cfm?d=507759&m=59485&u=747593&afftrack=
[2]: http://shrsl.com/1k5ug
[3]: https://itsfoss.com/affiliate-policy/
[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/07/linux-foundation-training-certification-discount.png?ssl=1
[5]: https://www.linuxfoundation.org/publications/open-source-jobs-report-2018/

View File

@ -0,0 +1,148 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (2 new apps for music tweakers on Fedora Workstation)
[#]: via: (https://fedoramagazine.org/2-new-apps-for-music-tweakers-on-fedora-workstation/)
[#]: author: (Justin W. Flory https://fedoramagazine.org/author/jflory7/)
2 new apps for music tweakers on Fedora Workstation
======
![][1]
Linux operating systems are great for making unique customizations and tweaks to make your computer work better for you. For example, the [i3 window manager][2] encourages users to think about the different components and pieces that make up the modern Linux desktop.
Fedora has two new packages of interest for music tweakers: **mpris-scrobbler** and **playerctl**. _mpris-scrobbler_ [tracks your music listening history][3] on a music-tracking service like Last.fm and/or ListenBrainz. _playerctl_ is a command-line [music player controller][4].
## _mpris-scrobbler_ records your music listening trends
_mpris-scrobbler_ is a CLI application to submit play history of your music to a service like [Last.fm][5], [Libre.fm][6], or [ListenBrainz][7]. It listens on the [MPRIS D-Bus interface][8] to detect whats playing. It connects with several different music clients like spotify-client, [vlc][9], audacious, bmp, [cmus][10], and others.
![Last.fm last week in music report. Generated from user-submitted listening history.][11]
### Install and configure _mpris-scrobbler_
_mpris-scrobbler_ is available for Fedora 28 or later, as well as the EPEL 7 repositories. Run the following command in a terminal to install it:
```
sudo dnf install mpris-scrobbler
```
Once it is installed, use _systemctl_ to start and enable the service. The following command starts _mpris-scrobbler_ and always starts it after a system reboot:
```
systemctl --user enable --now mpris-scrobbler.service
```
### Submit plays to ListenBrainz
This article explains how to link _mpris-scrobbler_ with a ListenBrainz account. To use Last.fm or Libre.fm, see the [upstream documentation][12].
To submit plays to a ListenBrainz server, you need a ListenBrainz API token. If you have an account, get the token from your [profile settings page][13]. When you have a token, run this command to authenticate with your ListenBrainz API token:
```
$ mpris-scrobbler-signon token listenbrainz
Token for listenbrainz.org:
```
Finally, test it by playing a song in your preferred music client on Fedora. The songs you play appear on your ListenBrainz profile.
![Basic statistics and play history from a user profile on ListenBrainz. The current track is playing on a Fedora Workstation laptop with mpris-scrobbler.][14]
## _playerctl_ controls your music playback
_playerctl_ is a CLI tool to control any music player implementing the MPRIS D-Bus interface. You can easily bind it to keyboard shortcuts or media hotkeys. Heres how to install it, use it in the command line, and create key bindings for the i3 window manager.
### Install and use _playerctl_
_playerctl_ is available for Fedora 28 or later. Run the following command in a terminal to install it:
```
sudo dnf install playerctl
```
Now that its installed, you can use it right away. Open your preferred music player on Fedora. Next, try the following commands to control playback from a terminal.
To play or pause the currently playing track:
```
playerctl play-pause
```
If you want to skip to the next track:
```
playerctl next
```
For a list of all running players:
```
playerctl -l
```
To play or pause whats currently playing, only on the spotify-client app:
```
playerctl -p spotify play-pause
```
### Create _playerctl_ key bindings in i3wm
Do you use a window manager like the [i3 window manager?][2] Try using _playerctl_ for key bindings. You can bind different commands to different key shortcuts, like the play/pause buttons on your keyboard. Look at the following [i3wm config excerpt][15] to see how:
```
# Media player controls
bindsym XF86AudioPlay exec "playerctl play-pause"
bindsym XF86AudioNext exec "playerctl next"
bindsym XF86AudioPrev exec "playerctl previous"
```
## Try it out with your favorite music players
Need to know more about customizing the music listening experience on Fedora? The Fedora Magazine has you covered. Check out these five cool music players on Fedora:
> [5 cool music player apps][16]
Bring order to your music library chaos by sorting and organizing it with MusicBrainz Picard:
> [Picard brings order to your music library][17]
* * *
_Photo by _[ _Frank Septillion_][18]_ on _[_Unsplash_][19]_._
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/2-new-apps-for-music-tweakers-on-fedora-workstation/
作者:[Justin W. Flory][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://fedoramagazine.org/author/jflory7/
[b]: https://github.com/lujun9972
[1]: https://fedoramagazine.org/wp-content/uploads/2019/04/2-music-tweak-apps-816x345.jpg
[2]: https://fedoramagazine.org/getting-started-i3-window-manager/
[3]: https://github.com/mariusor/mpris-scrobbler
[4]: https://github.com/acrisci/playerctl
[5]: https://www.last.fm/
[6]: https://libre.fm/
[7]: https://listenbrainz.org/
[8]: https://specifications.freedesktop.org/mpris-spec/latest/
[9]: https://www.videolan.org/vlc/
[10]: https://cmus.github.io/
[11]: https://fedoramagazine.org/wp-content/uploads/2019/02/Screenshot_2019-04-13-jflory7%E2%80%99s-week-in-music2-1024x500.png
[12]: https://github.com/mariusor/mpris-scrobbler#authenticate-to-the-service
[13]: https://listenbrainz.org/profile/
[14]: https://fedoramagazine.org/wp-content/uploads/2019/04/Screenshot_2019-04-13-User-jflory-ListenBrainz.png
[15]: https://github.com/jwflory/swiss-army/blob/ba6ac0c71855e33e3caa1ee1fe51c05d2df0529d/roles/apps/i3wm/files/config#L207-L210
[16]: https://fedoramagazine.org/5-cool-music-player-apps/
[17]: https://fedoramagazine.org/picard-brings-order-music-library/
[18]: https://unsplash.com/photos/Qrspubmx6kE?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
[19]: https://unsplash.com/search/photos/music?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText

View File

@ -0,0 +1,68 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (4 open source apps for plant-based diets)
[#]: via: (https://opensource.com/article/19/4/apps-plant-based-diets)
[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja)
4 open source apps for plant-based diets
======
These apps make it easier for vegetarians and vegans—and omnivores who
want to eat healthier—to find food they can eat.
![][1]
Reducing your consumption of meat, dairy, and processed foods is better for the planet and better for your health. Changing your diet can be difficult, but several open source Android applications can help you switch to a more plant-based diet. Whether you are taking part in [Meatless Monday][2], following Mark Bittman's [Vegan Before 6:00][3] guidelines, or switching entirely to a [whole-food, plant-based diet][4], these apps can aid you on your journey by helping you figure out what to eat, discover vegan- and vegetarian-friendly restaurants, and easily communicate your dietary preferences to others. All of these apps are open source and available from the [F-Droid repository][5].
### Daily Dozen
![Daily Dozen app][6]
The [Daily Dozen][7] app provides a checklist of items that Michael Greger, MD, FACLM, recommends as part of a healthy diet and lifestyle. Dr. Greger recommends consuming a whole-food, plant-based diet consisting of diverse foods and supported by daily exercise. This app lets you keep track of how many servings of each type of food you have eaten, how many servings of water (or other approved beverage, such as tea) you drank, and if you exercised each day. Each category of food provides serving sizes and lists of foods that fall under that category; for example, the Cruciferous Vegetable category includes bok choy, broccoli, brussels sprouts, and many other suggestions.
### Food Restrictions
![Food Restrictions app][8]
[Food Restrictions][9] is a simple app that can help you communicate your dietary restrictions to others, even if those people do not speak your language. Users can enter their food restrictions for seven different categories: chicken, beef, pork, fish, cheese, milk, and peppers. There is an "I don't eat" and an "I'm allergic" option for each of those categories. The "don't eat" option shows the icon with a red X over it. The "allergic" option displays the X and a small skull icon. The same information can be displayed using text instead of icons, but the text is only available in English and Portuguese. There is also an option for displaying a text message that says the user is vegetarian or vegan, which summarizes those dietary restrictions more succinctly and more accurately than the pick-and-choose options. The vegan text clearly mentions not eating eggs and honey, which are not options in the pick-and-choose method. However, just like the text version of the pick-and-choose option, these sentences are only available in English and Portuguese.
### OpenFoodFacts
![Open Food Facts app][10]
Avoiding unwanted ingredients when buying groceries can be frustrating, but [OpenFoodFacts][11] can help make the process easier. This app lets you scan the barcodes on products to get a report about the ingredients in a product and how healthy the product is. A product can still be very unhealthy even if it meets the criteria to be a vegan product. Having both the ingredients list and the nutrition facts lets you make informed choices when shopping. The only drawback for this app is that the data is user contributed, so not every product is available, but you can contribute new items, if you want to give back to the project.
### OpenVegeMap
![OpenVegeMap app][12]
Find vegan and vegetarian restaurants in your neighborhood with the [OpenVegeMap][13] app. This app lets you search by either using your phone's current location or by entering an address. Restaurants are classified as Vegan only, Vegan friendly, Vegetarian only, Vegetarian friendly, Non-vegetarian, and Unknown. The app uses data from [OpenStreetMap][14] and user-contributed information about the restaurants, so be sure to double-check to make sure the information provided is up-to-date and accurate.
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/4/apps-plant-based-diets
作者:[Joshua Allen Holm ][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/holmja
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003588_01_rd3os.combacktoschoolserieshe_rh_041x_0.png?itok=tfg6_I78
[2]: https://www.meatlessmonday.com/
[3]: https://www.amazon.com/dp/0385344740/
[4]: https://nutritionstudies.org/whole-food-plant-based-diet-guide/
[5]: https://f-droid.org/
[6]: https://opensource.com/sites/default/files/uploads/daily_dozen.png (Daily Dozen app)
[7]: https://f-droid.org/en/packages/org.nutritionfacts.dailydozen/
[8]: https://opensource.com/sites/default/files/uploads/food_restrictions.png (Food Restrictions app)
[9]: https://f-droid.org/en/packages/br.com.frs.foodrestrictions/
[10]: https://opensource.com/sites/default/files/uploads/openfoodfacts.png (Open Food Facts app)
[11]: https://f-droid.org/en/packages/openfoodfacts.github.scrachx.openfood/
[12]: https://opensource.com/sites/default/files/uploads/openvegmap.png (OpenVegeMap app)
[13]: https://f-droid.org/en/packages/pro.rudloff.openvegemap/
[14]: https://www.openstreetmap.org/

View File

@ -0,0 +1,66 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (8 environment-friendly open software projects you should know)
[#]: via: (https://opensource.com/article/19/4/environment-projects)
[#]: author: (Laura Hilliger https://opensource.com/users/laurahilliger)
8 environment-friendly open software projects you should know
======
Celebrate Earth Day by contributing to these projects dedicated to
improving our environment.
![][1]
For the last few years, I've been helping [Greenpeace][2] build its first fully open source software project, Planet 4. [Planet 4][3] is a global engagement platform where Greenpeace supporters and activists can interact and engage with the organization. The goal is to drive people to action on behalf of our planet. We want to invite participation and use people power to battle global issues like climate change and plastic pollution. Developers, designers, writers, contributors, and others who are looking for an open source way to support environmentalism are more than welcome to [get involved][4]!
Planet 4 is far from the only open source project focused on the environment. For Earth Day, I thought I'd share seven other open source projects that have our planet in mind.
**[Eco Hacker Farm][5]** works to support sustainable communities. It advises and supports projects combining hackerspaces/hackbases and permaculture living. The organization also has online software projects. Visit its [wiki][6] or reach out on [Twitter][7] to learn more about what Eco Hacker Farm is doing.
**[Public Lab][8]** is an open community and nonprofit organization that works to put science in the hands of citizens. Formed after the BP oil disaster in 2010, Public Lab works with open source to aid environmental exploration and investigation. It's a diverse community with lots of ways to [contribute][9].
A while back, Don Watkins, a community moderator here on Opensource.com, wrote about **[Open Climate Workbench][10]** , a project from the Apache Foundation. The [OCW][11] provides software to do climate modeling and evaluation, which can have all sorts of applications.
**[Open Source Ecology][12]** is a project that aims to improve how our economy functions. With an eye on environmental regeneration and social justice, the project seeks to redefine some of our dirty production and distribution techniques to create a more sustainable civilization.
Fostering collaboration around open source and big data tools to enable research in ocean, atmosphere, land, and climate, " **[Pangeo][13]** is first and foremost a community promoting open, reproducible, and scalable science." Big data can change the world!
**[**Leaflet**][14]** is a well-known open source JavaScript library. It can be used for all sorts of things, including environmentally friendly projects like the [Arctic Web Map][15], which allows scientists to accurately visualize and analyze the arctic region, a critical ability for climate research.
And of course, no list would be complete (not that this is a complete list!) without pointing to my friends at Mozilla. The **[Mozilla Science Lab][16]** community is, like all of Mozilla, fiercely open, and it's committed to bringing open source principles to the scientific community. Its projects and communities enable scientists to do the sorts of research our world needs to address some of the most pervasive environmental issues.
### How you can contribute
This Earth Day, make a six-month commitment to contribute some of your time to an open source project that helps fight climate change or otherwise encourages people to step up for Mother Earth. There must be scores of environmentally minded open source projects out there, so please leave your favorites in the comments!
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/4/environment-projects
作者:[Laura Hilliger][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/laurahilliger
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/world_hands_diversity.png?itok=zm4EDxgE
[2]: http://www.greenpeace.org
[3]: http://medium.com/planet4
[4]: https://planet4.greenpeace.org/community/#partners-open-sourcers
[5]: https://wiki.ecohackerfarm.org/start
[6]: https://wiki.ecohackerfarm.org/
[7]: https://twitter.com/EcoHackerFarm
[8]: https://publiclab.org/
[9]: https://publiclab.org/contribute
[10]: https://opensource.com/article/17/1/apache-open-climate-workbench
[11]: https://climate.apache.org/
[12]: https://wiki.opensourceecology.org/wiki/Project_needs
[13]: http://pangeo.io/
[14]: https://leafletjs.com/
[15]: https://webmap.arcticconnect.ca/#ac_3573/2/20.8/-65.5
[16]: https://science.mozilla.org/

View File

@ -0,0 +1,96 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (9 ways to save the planet)
[#]: via: (https://opensource.com/article/19/4/save-planet)
[#]: author: (Jen Wike Huger https://opensource.com/users/jen-wike/users/alanfdoss/users/jmpearce)
9 ways to save the planet
======
These ideas have an open source twist.
![][1]
What can be done to help save the planet? The question can seem depressing at a time when it feels like an individual's contribution isn't enough. But, who are we Earth dwellers if not for a collection of individuals? So, I asked our writer community to share ways that open source software or hardware can be used to make a difference. Here's what I heard back.
### 9 ways to save the planet with an open source twist
**1.** **Disable the blinking cursor in your terminal.**
It might sound silly, but the trivial, blinking cursor can cause up to [2 watts per hour of extra power consumption][2]. To disable it, go to Terminal Settings: Edit > Preferences > Cursor > Cursor blinking > Disabled.
_Recommended by Mars Toktonaliev_
**2\. Reduce your consumption of animal products and processed foods.**
One way to do this is to add these open source apps to your phone: Daily Dozen, OpenFoodFacts, OpenVegeMap, and Food Restrictions. These apps will help you eat a healthy, plant-based diet, find vegan- and vegetarian-friendly restaurants, and communicate your dietary needs to others, even if they do not speak the same language. To learn more about these apps read [_4 open source apps to support eating a plant-based diet_][3].
_Recommendation by Joshua Allen Holm_
**3\. Recycle old computers.**
How? With Linux, of course. Pay it forward by giving creating a new computer for someone who can't one and keep a computer out of the landfill. Here's how we do it at [The Asian Penguins][4].
_Recommendation by Stu Keroff_
**4\. Turn off devices when you're not using them.**
Use "smart power strips" that have a "master" outlet and several "controlled" outlets. Plug your PC into the master outlet, and when you turn on the computer, your monitor, printer, and anything else plugged into the controlled outlets turns on too. A simpler, low-tech solution is a power strip with a timer. That's what I use at home. You can use switches on the timer to set a handy schedule to turn the power on and off at specific times. Automatically turn off your network printer when no one is at home. Or for my six-year-old laptop, extend the life of the battery with a schedule to alternate when it's running from wall power (outlet is on) and when it's running from the battery (outlet is off).
_Recommended by Jim Hall_
**5\. Reduce the use of your HVAC system.**
Sunlight shining through windows adds a lot of heat to your home during the summer. Use Home Assistant to [automatically adjust][5] window blinds and awnings [based on the time of day][6], or even based on the angle of the sun.
_Recommended by Michael Hrivnak_
**6\. Turn your thermostat off or to a lower setting while you're away.**
If your home thermostat has an "Away" feature, activating it on your way out the door is easy to forget. With a touch of automation, any connected thermostat can begin automatically saving energy while you're not home. [Stataway][7] is one such project that uses your phone's GPS coordinates to determine when it should set your thermostat to "Home" or "Away".
_Recommended by Michael Hrivnak_
**7\. Save computing power for later.**
I have an idea: Create a script that can read the power output from an alternative energy array (wind and solar) and begin turning on servers (taking them from a power-saving sleep mode to an active mode) in a computing cluster until the overload power is used (whatever excess is produced beyond what can be stored/buffered for later use). Then use the overload power during high-production times for compute-intensive projects like rendering. This process would be essentially free of cost because the power can't be buffered for other uses. I'm sure the monitoring, power management, and server array tools must exist to do this. Then, it's just an integration problem, making it all work together.
_Recommended by Terry Hancock_
**8\. Turn off exterior lights.**
Light pollution affects more than 80% of the world's population, according to the [World Atlas of Artificial Night Sky Brightness][8], published (Creative Commons Attribution-NonCommercial 4.0) in 2016 in the open access journal _Science Advances_. Turning off exterior lights is a quick way to benefit wildlife, human health, our ability to enjoy the night sky, and of course energy consumption. Visit [darksky.org][9] for more ideas on how to reduce the impact of your exterior lighting.
_Recommended by Michael Hrivnak_
**9\. Reduce your CPU count.**
For me, I remember I used to have a whole bunch of computers running in my basement as my IT playground/lab. I've become more conscious now of power consumption and so have really drastically reduced my CPU count. I like to take advantage of VMs, zones, containers... that type of technology a lot more these days. Also, I'm really glad that small form factor and SoC computers, such as the Raspberry Pi, exist because I can do a lot with one, such as run a DNS or Web server, without heating the room and running up my electricity bill.
P.S. All of these computers are running Linux, FreeBSD, or Raspbian!
_Recommended by Alan Formy-Duvall_
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/4/save-planet
作者:[Jen Wike Huger ][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/jen-wike/users/alanfdoss/users/jmpearce
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/pixelated-world.png?itok=fHjM6m53
[2]: https://www.redhat.com/archives/fedora-devel-list/2009-January/msg02406.html
[3]: https://opensource.com/article/19/4/apps-plant-based-diets
[4]: https://opensource.com/article/19/2/asian-penguins-close-digital-divide
[5]: https://www.home-assistant.io/docs/automation/trigger/#sun-trigger
[6]: https://www.home-assistant.io/components/cover/
[7]: https://github.com/mhrivnak/stataway
[8]: http://advances.sciencemag.org/content/2/6/e1600377
[9]: http://darksky.org/

View File

@ -0,0 +1,132 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Strawberry: A Fork of Clementine Music Player)
[#]: via: (https://itsfoss.com/strawberry-music-player/)
[#]: author: (John Paul https://itsfoss.com/author/john/)
Strawberry: A Fork of Clementine Music Player
======
In this age of streaming music and cloud services, there are still people who need an application to collect and play their music. If you are such a person, this article should interest you.
We have earlier covered [Sayonara music player][1]. Today, we will be taking a look at the Strawberry Music Player.
### Strawberry Music Player: A fork of Clementine
The [Strawberry Music Player][2] is, quite simply, an application to manage and play your music.
![Strawberry media library][3]
Strawberry contains the following list of features:
* Play and organize music
* Supports WAV, FLAC, WavPack, DSF, DSDIFF, Ogg Vorbis, Speex, MPC, TrueAudio, AIFF, MP4, MP3, ASF and Monkeys Audio Audio CD playback
* Native desktop notifications
* Support for playlists in multiple formats
* Advanced audio output and device configuration for bit-perfect playback on Linux
* Edit tags on music files
* Fetch tags from [MusicBrainz Picard][4]
* Album cover art from [Last.fm][5], MusicBrainz and Discogs
* Song lyrics from [AudD][6]
* Support for multiple backends
* Audio analyzer
* Audio equalizer
* Transfer music to iPod, iPhone, MTP or mass-storage USB player
* Streaming support for Tidal
* Scrobbler with support for Last.fm, Libre.fm and ListenBrainz
If you take a look at the screenshots, they probably look familiar. That is because Strawberry is a fork of the [Clementine Music Player][7]. Clementine has not been updated since 2016, while the most recent version of Strawberry (0.5.3) was released early April 2019.
Trivia
You might think that Strawberry music player is named after the fruit. However, its [creator][8] claims that he has named the project after the band [Strawbs][9].
### Installing Strawberry Music player
Now lets take a look at how you can install Strawberry on your system.
#### Ubuntu
The easiest way to install Strawberry on Ubuntu is to install the [official snap][10]. Just type:
```
sudo snap install strawberry
```
If you are not a fan of snaps, you can download a .deb file from Strawberrys GitHub [release page][11]. You can [install the .deb file][12] by double-clicking it and opening it via the Software Center.
Strawberry is not available in the main [Ubuntu repositories][13].
#### Fedora
Installing Strawberry on Fedora is much simpler. Strawberry is in the Fedora repos, so you just have to type `sudo dnf strawberry`. Strawberry is not available on Flatpak.
#### Arch
Just like Fedora, Strawberry is in the Arch repos. All you have to type is `sudo pacman -S strawberry`. The same is true for Manjaro.
You can find a list of Linux distros that have Strawberry in their repos [here][14]. If you have openSUSE or Mageia, click [here][15]. You can also compile Strawberry from source.
### Experience with Strawberry Music Player
![Playing an audio book with Strawberry][16]
I installed Strawberry on Fedora and Windows. I have used Clementine in the past, so I knew what to expect. I downloaded a number of audiobooks and several [Old Time Radio][17] [shows][18] as I dont listen to a lot of music. Instead of using a dedicated [audiobook player like Cozy][19], I used Strawberry for listening to these radio shows.
Once I told Strawberry where my files were located, it quickly imported them. I used [EasyTag][20] to fix some of the MP3 information on the old time radio shows. Strawberry has a tag editor, but EasyTag allows you to edit several folders very quickly. Strawberry undated the media library instantaneously.
The big plus for me was performance. It loaded quickly and ran well. This might have something to do with the fact that it is not another Electron app. Strawberry is written in good-old-fashioned C++ and Qt 5. No need to load a whole web browser every time you want to play music, or in my case listen to audio dramas.
I was not able to test the Tidal streaming feature because I dont have an account. Also, I dont sync music to my iPod.
### Final Thoughts
Strawberry is like a standard music player that makes managing and playing your audio library very easy.
The features that I miss from Clementine include the option to access your media from cloud storage systems (like Box and Dropbox) and the ability to download podcasts. But then, I dont store my media in the cloud and I mainly listen to podcasts on my iPod.
I recommend giving Strawberry a try. You just might like it as much as I do.
Have you ever used Strawberry? What is your favorite music player/manager? Please let us know in the comments below.
If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][21].
--------------------------------------------------------------------------------
via: https://itsfoss.com/strawberry-music-player/
作者:[John Paul][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/john/
[b]: https://github.com/lujun9972
[1]: https://itsfoss.com/sayonara-music-player/
[2]: https://strawbs.org/
[3]: https://itsfoss.com/wp-content/uploads/2019/04/strawberry1-800x471.png
[4]: https://itsfoss.com/musicbrainz-picard/
[5]: https://www.last.fm/
[6]: https://audd.io/
[7]: https://www.clementine-player.org/
[8]: https://github.com/jonaski
[9]: https://en.wikipedia.org/wiki/Strawbs
[10]: https://snapcraft.io/strawberry
[11]: https://github.com/jonaski/strawberry/releases
[12]: https://itsfoss.com/install-deb-files-ubuntu/
[13]: https://itsfoss.com/ubuntu-repositories/
[14]: https://repology.org/project/strawberry/versions
[15]: https://download.opensuse.org/repositories/home:/jonaski:/audio/
[16]: https://itsfoss.com/wp-content/uploads/2019/04/strawberry3-800x471.png
[17]: https://en.wikipedia.org/wiki/Golden_Age_of_Radio
[18]: https://zootradio.com/
[19]: https://itsfoss.com/cozy-audiobook-player/
[20]: https://wiki.gnome.org/Apps/EasyTAG
[21]: http://reddit.com/r/linuxusersgroup

View File

@ -0,0 +1,98 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Tracking the weather with Python and Prometheus)
[#]: via: (https://opensource.com/article/19/4/weather-python-prometheus)
[#]: author: (Moshe Zadka https://opensource.com/users/moshez)
Tracking the weather with Python and Prometheus
======
Create a custom Prometheus integration to keep track of the biggest
cloud provider of all: Mother Earth.
![Tree clouds][1]
Open source monitoring system [Prometheus][2] has integrations to track many types of time-series data, but if you want an integration that doesn't yet exist, it's easy to build one. An often-used example is a custom integration with a cloud provider that uses the provider's APIs to grab specific metrics. In this example, though, we will integrate with the biggest cloud provider of all: Earth.
Luckily, the US government already measures the weather and provides an easy API for integrations. Getting the weather forecast for the next hour at Red Hat headquarters is simple.
```
import requests
HOURLY_RED_HAT = "<https://api.weather.gov/gridpoints/RAH/73,57/forecast/hourly>"
def get_temperature():
result = requests.get(HOURLY_RED_HAT)
return result.json()["properties"]["periods"][0]["temperature"]
```
Now that our integration with Earth is done, it's time to make sure Prometheus can understand what we are saying. We can use the [Prometheus Python library][3] to create a registry with one _gauge_ : the temperature at Red Hat HQ.
```
from prometheus_client import CollectorRegistry, Gauge
def prometheus_temperature(num):
registry = CollectorRegistry()
g = Gauge("red_hat_temp", "Temperature at Red Hat HQ", registry=registry)
g.set(num)
return registry
```
Finally, we need to connect this to Prometheus in some way. That depends a little on the network topology for Prometheus: whether it is easier for Prometheus to talk to our service, or whether the reverse is easier.
The first case is the one usually recommended, if possible, so we need to build a web server exposing the registry and then configure Prometheus to _scrape_ it.
We can build a simple web server with [Pyramid][4].
```
from pyramid.config import Configurator
from pyramid.response import Response
from prometheus_client import generate_latest, CONTENT_TYPE_LATEST
def metrics_web(request):
registry = prometheus_temperature(get_temperature())
return Response(generate_latest(registry),
content_type=CONTENT_TYPE_LATEST)
config = Configurator()
config.add_route('metrics', '/metrics')
config.add_view(metrics_web, route_name='metrics')
app = config.make_wsgi_app()
```
This can be run with any Web Server Gateway Interface (WSGI) server. For example, we can use **python -m twisted web --wsgi earth.app** to run it, assuming we put the code in **earth.py**.
Alternatively, if it is easier for our code to connect to Prometheus, we can push it to Prometheus's [Push gateway][5] periodically.
```
import time
from prometheus_client import push_to_gateway
def push_temperature(url):
while True:
registry = prometheus_temperature(get_temperature())
push_to_gateway(url, "temperature collector", registry)
time.sleep(60*60)
```
The URL is the one for the Push gateway; it often ends in **:9091**.
Good luck building your own custom Prometheus integration so you can track all the things!
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/4/weather-python-prometheus
作者:[Moshe Zadka ][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/moshez
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/life_tree_clouds.png?itok=b_ftihhP (Tree clouds)
[2]: https://prometheus.io/
[3]: https://github.com/prometheus/client_python
[4]: https://trypyramid.com/
[5]: https://github.com/prometheus/pushgateway

View File

@ -0,0 +1,147 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Four Methods To Check The Default Gateway Or Router IP Address In Linux?)
[#]: via: (https://www.2daygeek.com/check-find-default-gateway-or-router-ip-address-in-linux/)
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
Four Methods To Check The Default Gateway Or Router IP Address In Linux?
======
Your default gateway is the IP address of your router that you should aware of that.
Typically this is automatically detected by your operating system during installation, if not then you may need to change it.
If your system not able to ping self then probable it could be a gateway issue and you have to fix it.
This might happen if you have multiple network adapters or routers on the network.
A gateway is a router that acts as an access point to passes network data from one networks to another networks.
The below articles will help you to gather some other information which is similar to this topic.
* **[9 Methods To Check Your Public IP Address In Linux Command Line][1]**
* **[How To Enable (UP) And Disable (DOWN) A Network Interface Port (NIC) In Linux?][2]**
This can be done using below Four commands.
* **`route Command:`** route command is used to show and manipulate the IP routing table.
* **`ip Command:`** IP command is similar to ifconfig, which is very familiar for assigning Static IP Address, Route & Default Gateway, etc.,.
* **`netstat Command:`** netstat (“network statistics”) is a command-line tool that displays network connections related information (both incoming and outgoing) such as routing tables, masquerade connections, multicast memberships and a number of network interface
* **`routel Command:`** routel command is used to list routes with pretty output format.
### 1) How To Check The Default Gateway Or Router IP Address In Linux Using route Command?
route command is used to show and manipulate the IP routing table.
Its primary use is to set up static routes to specific hosts or networks via an interface once the interface was configured.
When the add or del options are used, route modifies the routing tables. Without these options, route displays the current contents of the routing tables.
```
# route
or
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default www.routerlogin 0.0.0.0 UG 600 0 0 wlp8s0
192.168.1.0 0.0.0.0 255.255.255.0 U 600 0 0 wlp8s0
```
### 2) How To Check The Default Gateway Or Router IP Address In Linux Using ip Command?
**[IP command][3]** is similar to ifconfig, which is very familiar for assigning Static IP Address, Route & Default Gateway, etc.,.
ifconfig command was deprecated due to no maintenance since so many years, even though it is still available on most Linux distributions.
ifconfig command has been replaced by IP command which is very powerful and performing several network administration tasks with one command.
IP command utility bundled with iproute2 package. By default iproute2 utility pre-installed all the major Linux distribution.
If no, you can install it by issuing iproute2 on your terminal with help of package manager.
```
# ip r
or
# ip route
or
# ip route show
default via 192.168.1.1 dev wlp8s0 proto dhcp metric 600
192.168.1.0/24 dev wlp8s0 proto kernel scope link src 192.168.1.6 metric 600
```
### 3) How To Check The Default Gateway Or Router IP Address In Linux Using netstat Command?
netstat stands for Network Statistics, is a command-line tool that displays network connections related information (both incoming and outgoing) such as routing tables, masquerade connections, multicast memberships and a number of network interface.
It lists out all the tcp, udp socket connections and the unix socket connections.
It is used for diagnosing network problems in the network and to determine the amount of traffic on the network as a performance measurement.
```
# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
default www.routerlogin 0.0.0.0 UG 0 0 0 wlp8s0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlp8s0
```
### 4) How To Check The Default Gateway Or Router IP Address In Linux Using routel Command?
It used to list routes with pretty output format. These programs are a set of helper scripts you can use instead of raw iproute2 commands.
The routel script will list routes in a format that some might consider easier to interpret then the ip route list equivalent.
The routef script does not take any arguments and will simply flush the routing table down the drain. Beware! This means deleting all routes which will make your network unusable!
```
# routel
target gateway source proto scope dev tbl
default 192.168.1.1 dhcp wlp8s0
192.168.1.0/ 24 192.168.1.6 kernel link wlp8s0
127.0.0.0 broadcast 127.0.0.1 kernel link lo local
127.0.0.0/ 8 local 127.0.0.1 kernel host lo local
127.0.0.1 local 127.0.0.1 kernel host lo local
127.255.255.255 broadcast 127.0.0.1 kernel link lo local
192.168.1.0 broadcast 192.168.1.6 kernel link wlp8s0 local
192.168.1.6 local 192.168.1.6 kernel host wlp8s0 local
192.168.1.255 broadcast 192.168.1.6 kernel link wlp8s0 local
::1 kernel lo
fe80::/ 64 kernel wlp8s0
::1 local kernel lo local
fe80::ad00:2f7e:d882:5add local kernel wlp8s0 local
ff00::/ 8 wlp8s0 local
```
If you would like to print only default gateway then use the following format.
```
# routel | grep default
default 192.168.1.1 dhcp wlp8s0
```
--------------------------------------------------------------------------------
via: https://www.2daygeek.com/check-find-default-gateway-or-router-ip-address-in-linux/
作者:[Magesh Maruthamuthu][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.2daygeek.com/author/magesh/
[b]: https://github.com/lujun9972
[1]: https://www.2daygeek.com/check-find-server-public-ip-address-linux/
[2]: https://www.2daygeek.com/enable-disable-up-down-nic-network-interface-port-linux-using-ifconfig-ifdown-ifup-ip-nmcli-nmtui/
[3]: https://www.2daygeek.com/ip-command-configure-network-interface-usage-linux/

View File

@ -0,0 +1,341 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How To Monitor Disk I/O Activity Using iotop And iostat Commands In Linux?)
[#]: via: (https://www.2daygeek.com/check-monitor-disk-io-in-linux-using-iotop-iostat-command/)
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
How To Monitor Disk I/O Activity Using iotop And iostat Commands In Linux?
======
Do you know what are the tools we can use for troubleshooting or monitoring real-time disk activity in Linux?
If **[Linux system performance][1]** gets slow down we may use **[top command][2]** to see the system performance.
It is used to check what are the processes are consuming high utilization on server.
Its common for most of the Linux administrator.
Its widely used by Linux administrator in the real world.
If you dont see much difference in the process output still you have an option to check other things.
I would like to advise you to check `wa` status in the top output because most of the time the server performance will be degraded due to high I/O Read and Write on hard disk.
If its high or fluctuation, it could be a cause. So, we need to check I/O activity on hard drive.
We can monitory disk I/O statistics for all disks and file system in Linux system using `iotop` and `iostat` commands.
### What Is iotop?
iotop is a top-like utility for displaying real-time disk activity.
iotop watches I/O usage information output by the Linux kernel and displays a table of current I/O usage by processes or threads on the system.
It displays the I/O bandwidth read and written by each process/thread. It also displays the percentage of time the thread/process spent while swapping in and while waiting on I/O.
Total DISK READ and Total DISK WRITE values represent total read and write bandwidth between processes and kernel threads on the one side and kernel block device subsystem on the other.
Actual DISK READ and Actual DISK WRITE values represent corresponding bandwidths for actual disk I/O between kernel block device subsystem and underlying hardware (HDD, SSD, etc.).
### How To Install iotop In Linux?
We can easily install it with help of package manager since the package is available in all the Linux distributions repository.
For **`Fedora`** system, use **[DNF Command][3]** to install iotop.
```
$ sudo dnf install iotop
```
For **`Debian/Ubuntu`** systems, use **[APT-GET Command][4]** or **[APT Command][5]** to install iotop.
```
$ sudo apt install iotop
```
For **`Arch Linux`** based systems, use **[Pacman Command][6]** to install iotop.
```
$ sudo pacman -S iotop
```
For **`RHEL/CentOS`** systems, use **[YUM Command][7]** to install iotop.
```
$ sudo yum install iotop
```
For **`openSUSE Leap`** system, use **[Zypper Command][8]** to install iotop.
```
$ sudo zypper install iotop
```
### How To Monitor Disk I/O Activity/Statistics In Linux Using iotop Command?
There are many options are available in iotop command to check varies statistics about disk I/O.
Run the iotop command without any arguments to see each process or thread current I/O usage.
```
# iotop
```
[![][9]![][9]][10]
If you would like to check which process are actually doing IO then run the iotop command with `-o` or `--only` option.
```
# iotop --only
```
[![][9]![][9]][11]
**Details:**
* **`IO:`** It shows I/O utilization for each process, which includes disk and swap.
* **`SWAPIN:`** It shows only the swap usage of each process.
### What Is iostat?
iostat is used to report Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions.
The iostat command is used for monitoring system input/output device loading by observing the time the devices are active in relation to their average transfer rates.
The iostat command generates reports that can be used to change system configuration to better balance the input/output load between physical disks.
All statistics are reported each time the iostat command is run. The report consists of a CPU header row followed by a row of CPU statistics.
On multiprocessor systems, CPU statistics are calculated system-wide as averages among all processors. A device header row is displayed followed by a line of statistics for each device that is configured.
The iostat command generates two types of reports, the CPU Utilization report and the Device Utilization report.
### How To Install iostat In Linux?
iostat tool is part of sysstat package so, We can easily install it with help of package manager since the package is available in all the Linux distributions repository.
For **`Fedora`** system, use **[DNF Command][3]** to install sysstat.
```
$ sudo dnf install sysstat
```
For **`Debian/Ubuntu`** systems, use **[APT-GET Command][4]** or **[APT Command][5]** to install sysstat.
```
$ sudo apt install sysstat
```
For **`Arch Linux`** based systems, use **[Pacman Command][6]** to install sysstat.
```
$ sudo pacman -S sysstat
```
For **`RHEL/CentOS`** systems, use **[YUM Command][7]** to install sysstat.
```
$ sudo yum install sysstat
```
For **`openSUSE Leap`** system, use **[Zypper Command][8]** to install sysstat.
```
$ sudo zypper install sysstat
```
### How To Monitor Disk I/O Activity/Statistics In Linux Using sysstat Command?
There are many options are available in iostat command to check varies statistics about disk I/O and CPU.
Run the iostat command without any arguments to see complete statistics of the system.
```
# iostat
Linux 4.19.32-1-MANJARO (daygeek-Y700) Thursday 18 April 2019 _x86_64_ (8 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
29.45 0.02 16.47 0.12 0.00 53.94
Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd
nvme0n1 6.68 126.95 124.97 0.00 58420014 57507206 0
sda 0.18 6.77 80.24 0.00 3115036 36924764 0
loop0 0.00 0.00 0.00 0.00 2160 0 0
loop1 0.00 0.00 0.00 0.00 1093 0 0
loop2 0.00 0.00 0.00 0.00 1077 0 0
```
Run the iostat command with `-d` option to see I/O statistics for all the devices
```
# iostat -d
Linux 4.19.32-1-MANJARO (daygeek-Y700) Thursday 18 April 2019 _x86_64_ (8 CPU)
Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd
nvme0n1 6.68 126.95 124.97 0.00 58420030 57509090 0
sda 0.18 6.77 80.24 0.00 3115292 36924764 0
loop0 0.00 0.00 0.00 0.00 2160 0 0
loop1 0.00 0.00 0.00 0.00 1093 0 0
loop2 0.00 0.00 0.00 0.00 1077 0 0
```
Run the iostat command with `-p` option to see I/O statistics for all the devices and their partitions.
```
# iostat -p
Linux 4.19.32-1-MANJARO (daygeek-Y700) Thursday 18 April 2019 _x86_64_ (8 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
29.42 0.02 16.45 0.12 0.00 53.99
Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd
nvme0n1 6.68 126.94 124.96 0.00 58420062 57512278 0
nvme0n1p1 6.40 124.46 118.36 0.00 57279753 54474898 0
nvme0n1p2 0.27 2.47 6.60 0.00 1138069 3037380 0
sda 0.18 6.77 80.23 0.00 3116060 36924764 0
sda1 0.00 0.01 0.00 0.00 3224 0 0
sda2 0.18 6.76 80.23 0.00 3111508 36924764 0
loop0 0.00 0.00 0.00 0.00 2160 0 0
loop1 0.00 0.00 0.00 0.00 1093 0 0
loop2 0.00 0.00 0.00 0.00 1077 0 0
```
Run the iostat command with `-x` option to see detailed I/O statistics for all the devices.
```
# iostat -x
Linux 4.19.32-1-MANJARO (daygeek-Y700) Thursday 18 April 2019 _x86_64_ (8 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
29.41 0.02 16.45 0.12 0.00 54.00
Device r/s rkB/s rrqm/s %rrqm r_await rareq-sz w/s wkB/s wrqm/s %wrqm w_await wareq-sz d/s dkB/s drqm/s %drqm d_await dareq-sz aqu-sz %util
nvme0n1 2.45 126.93 0.60 19.74 0.40 51.74 4.23 124.96 5.12 54.76 3.16 29.54 0.00 0.00 0.00 0.00 0.00 0.00 0.31 30.28
sda 0.06 6.77 0.00 0.00 8.34 119.20 0.12 80.23 19.94 99.40 31.84 670.73 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.13
loop0 0.00 0.00 0.00 0.00 0.08 19.64 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
loop1 0.00 0.00 0.00 0.00 0.40 12.86 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
loop2 0.00 0.00 0.00 0.00 0.38 19.58 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
```
Run the iostat command with `-d [Device_Name]` option to see I/O statistics of particular device and their partitions.
```
# iostat -p [Device_Name]
# iostat -p sda
Linux 4.19.32-1-MANJARO (daygeek-Y700) Thursday 18 April 2019 _x86_64_ (8 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
29.38 0.02 16.43 0.12 0.00 54.05
Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd
sda 0.18 6.77 80.21 0.00 3117468 36924764 0
sda2 0.18 6.76 80.21 0.00 3112916 36924764 0
sda1 0.00 0.01 0.00 0.00 3224 0 0
```
Run the iostat command with `-m` option to see I/O statistics with `MB` for all the devices instead of `KB`. By default it shows the output with KB.
```
# iostat -m
Linux 4.19.32-1-MANJARO (daygeek-Y700) Thursday 18 April 2019 _x86_64_ (8 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
29.36 0.02 16.41 0.12 0.00 54.09
Device tps MB_read/s MB_wrtn/s MB_dscd/s MB_read MB_wrtn MB_dscd
nvme0n1 6.68 0.12 0.12 0.00 57050 56176 0
sda 0.18 0.01 0.08 0.00 3045 36059 0
loop0 0.00 0.00 0.00 0.00 2 0 0
loop1 0.00 0.00 0.00 0.00 1 0 0
loop2 0.00 0.00 0.00 0.00 1 0 0
```
Run the iostat command with certain interval then use the following format. In this example, we are going to capture totally two reports at five seconds interval.
```
# iostat [Interval] [Number Of Reports]
# iostat 5 2
Linux 4.19.32-1-MANJARO (daygeek-Y700) Thursday 18 April 2019 _x86_64_ (8 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
29.35 0.02 16.41 0.12 0.00 54.10
Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd
nvme0n1 6.68 126.89 124.95 0.00 58420116 57525344 0
sda 0.18 6.77 80.20 0.00 3118492 36924764 0
loop0 0.00 0.00 0.00 0.00 2160 0 0
loop1 0.00 0.00 0.00 0.00 1093 0 0
loop2 0.00 0.00 0.00 0.00 1077 0 0
avg-cpu: %user %nice %system %iowait %steal %idle
3.71 0.00 2.51 0.05 0.00 93.73
Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd
nvme0n1 19.00 0.20 311.40 0.00 1 1557 0
sda 0.20 25.60 0.00 0.00 128 0 0
loop0 0.00 0.00 0.00 0.00 0 0 0
loop1 0.00 0.00 0.00 0.00 0 0 0
loop2 0.00 0.00 0.00 0.00 0 0 0
```
Run the iostat command with `-N` option to see the LVM disk I/O statistics report.
```
# iostat -N
Linux 4.15.0-47-generic (Ubuntu18.2daygeek.com) Thursday 18 April 2019 _x86_64_ (2 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.38 0.07 0.18 0.26 0.00 99.12
Device tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda 3.60 57.07 69.06 968729 1172340
sdb 0.02 0.33 0.00 5680 0
sdc 0.01 0.12 0.00 2108 0
2g-2gvol1 0.00 0.07 0.00 1204 0
```
Run the nfsiostat command to see the I/O statistics for Network File System(NFS).
```
# nfsiostat
```
--------------------------------------------------------------------------------
via: https://www.2daygeek.com/check-monitor-disk-io-in-linux-using-iotop-iostat-command/
作者:[Magesh Maruthamuthu][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.2daygeek.com/author/magesh/
[b]: https://github.com/lujun9972
[1]: https://www.2daygeek.com/category/monitoring-tools/
[2]: https://www.2daygeek.com/linux-top-command-linux-system-performance-monitoring-tool/
[3]: https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/
[4]: https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/
[5]: https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/
[6]: https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/
[7]: https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/
[8]: https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/
[9]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
[10]: https://www.2daygeek.com/wp-content/uploads/2015/03/monitor-disk-io-activity-using-iotop-iostat-command-in-linux-1.jpg
[11]: https://www.2daygeek.com/wp-content/uploads/2015/03/monitor-disk-io-activity-using-iotop-iostat-command-in-linux-2.jpg

View File

@ -1,47 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (MjSeven)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Which programming languages should you learn?)
[#]: via: (https://opensource.com/article/19/2/which-programming-languages-should-you-learn)
[#]: author: (Marty Kalin https://opensource.com/users/mkalindepauledu)
应该学习哪种编程语言?
======
学习一门新的编程语言是在你的职业生涯中继续前进的好方法,但是应该学习哪一门呢?
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/search_find_code_issue_bug_programming.png?itok=XPrh7fa0)
如果你想要在编程生涯中起步或继续前进,那么学习一门新语言是一个聪明的主意。但是,大量活跃使用的语言引发了一个问题:哪种编程语言是最好学习的?要回答这个问题,让我们从一个简单的问题开始:你想做什么样的程序?
如果你想在客户端进行网络编程,那么特定语言 HTML、CSS 和 JavaScript一种看似无穷无尽的方言是必须要学习的。
<to 校正这里是 JavaScript 的形容>
如果你想在服务器端进行 Web 编程那么选项包括常见的通用语言C++, Golang, Java, C#, Node.js, Perl, Python, Ruby 等等。当然,服务器程序与数据存储(例如关系数据库和其他数据库)打交道,这意味着 SQL 等查询语言可能会发挥作用。
如果你正在为移动设备编写本地应用程序,那么了解目标平台非常重要。对于 Apple 设备Swift 已经取代 Objective C 成为首选语言。对于 Android 设备Java带有专用库和工具集仍然是主要语言。有一些特殊语言如 与 C# 一起使用的 Xamarin可以为 Apple、Android 和 Windows 设备生成特定于平台的代码。
那么通用语言呢?通常有各种各样的选择。在*动态*或*脚本*语言(如 Perl、Python 和 Ruby有一些新东西如 Node.js。java 和 C# 的相似之处比它们的粉丝愿意承认的还要多,仍然是针对虚拟机(分别是 JVM 和 CLR的主要*静态编译*语言。在编译为*原生可执行文件*的语言中C++ 仍然处于混合状态,以及后来的 Golang 和 Rust 等。通用*函数*语言比比皆是(如 Clojure、Haskell、Erlang、F#、Lisp 和 Scala它们通常都有热情投入的社区。值得注意的是面向对象语言如 Java 和 C#)已经添加了函数构造(特别是 lambdas而动态语言从一开始就有函数构造。
让我以 C 语言结尾,它是一种小巧,优雅,可扩展的语言,不要与 C++ 混淆。现代操作系统主要用 C 语言编写,其余的用汇编语言编写。任何平台上的标准库大多数都是用 C 语言编写的。例如,任何打印 `Hello, world!` 这种问候都是通过调用名为 **write** 的 C 库函数来实现的。
C 作为一种可移植的汇编语言,公开了其他高级语言有意隐藏的底层系统的详细信息。因此,理解 C 可以更好地掌握程序如何竞争执行所需的共享系统资源(如处理器,内存和 I/O 设备。C 语言既高级又接近硬件因此在性能方面无与伦比当然汇编语言除外。最后C 是编程语言中的通用语言,几乎所有通用语言都支持一种或另一种形式的 C 调用。
有关现代 C 语言的介绍,参考我的书籍 [C Programming: Introducing Portable Assembler][1]。无论你怎么做,学习 C 语言,你会学到比另一种编程语言多得多的东西。
你认为学习哪些编程语言很重要?你是否同意这些建议?在评论告知我们!
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/2/which-programming-languages-should-you-learn
作者:[Marty Kalin][a]
选题:[lujun9972][b]
<!-- <!-- 译者:[MjSeven](https://github.com/MjSeven) --> -->
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/mkalindepauledu
[b]: https://github.com/lujun9972
[1]: https://www.amazon.com/dp/1977056954?ref_=pe_870760_150889320

View File

@ -1,94 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Managing Partitions with sgdisk)
[#]: via: (https://fedoramagazine.org/managing-partitions-with-sgdisk/)
[#]: author: (Gregory Bartholomew https://fedoramagazine.org/author/glb/)
使用 sgdisk 管理分区
======
![][1]
[Roderick W. Smith][2] 的 _sgdisk_ 命令可在命令行中管理硬盘的分区。下面将介绍使用它所需的基础知识。
以下六个参数是你使用 sgdisk 大多数基本功能所需了解的:
1. **-p**
_打印_ 分区表:
### sgdisk -p /dev/sda
2. **-d x**
_删除_分区 x
### sgdisk -d 1 /dev/sda
3. **-n x:y:z**
创建一个编号 x 的_新_分区从 y 开始,从 z 结束:
### sgdisk -n 1:1MiB:2MiB /dev/sda
4. **-c x:y**
_更改_分区 x 的名称为 y
### sgdisk -c 1:grub /dev/sda
5. **-t x:y**
将分区 x 的_类型_更改为 y
### sgdisk -t 1:ef02 /dev/sda
6. **list-types**
列出分区类型代码:
### sgdisk --list-types
![The SGDisk Command][3]
如你在上面的例子中所见,大多数命令都要求将要操作的硬盘的[设备文件名][4]指定为最后一个参数。
可以组合上面的参数,这样你可以一次定义所有分区:
### sgdisk -n 1:1MiB:2MiB -t 1:ef02 -c 1:grub /dev/sda
在值的前面加上 **+** 或 **** 符号可以为某些字段指定相对值。如果你使用相对值sgdisk 会为你做数学运算。例如,上面的例子可以写成:
### sgdisk -n 1:1MiB:+1MiB -t 1:ef02 -c 1:grub /dev/sda
**0** 值对于以下几个字段是特殊情况:
* 对于_分区号_字段0 表示应使用下一个可用编号(编号从 1 开始)。
  * 对于_起始地址_字段0 表示使用最大可用空闲块的头。硬盘开头的一些空间始终保留给分区表本身。
  * 对于_结束地址_字段0 表示使用最大可用空闲块的末尾。
通过在适当的字段中使用 **0** 和相对值,你可以创建一系列分区,而无需预先计算任何绝对值。例如,如果在一块空白硬盘中,以下 sgdisk 命令序列将创建典型 Linux 安装所需的所有基本分区:
### sgdisk -n 0:0:+1MiB -t 0:ef02 -c 0:grub /dev/sda
### sgdisk -n 0:0:+1GiB -t 0:ea00 -c 0:boot /dev/sda
### sgdisk -n 0:0:+4GiB -t 0:8200 -c 0:swap /dev/sda
### sgdisk -n 0:0:0 -t 0:8300 -c 0:root /dev/sda
上面的例子展示了如何为基于 BIOS 的计算机分区硬盘。基于 UEFI 的计算机上不需要 [grub分区][5]。由于 sgdisk 在上面的示例中为你计算了所有绝对值,因此你可以在基于 UEFI 的计算机上跳过第一个命令,并且可以无需修改即可运行其余命令。同样,你可以跳过创建交换分区,并且不需要修改其余命令。
还有使用一个命令删除硬盘上所有分区的快捷方式:
### sgdisk --zap-all /dev/sda
关于最新和详细信息,请查看手册页:
$ man sgdisk
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/managing-partitions-with-sgdisk/
作者:[Gregory Bartholomew][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://fedoramagazine.org/author/glb/
[b]: https://github.com/lujun9972
[1]: https://fedoramagazine.org/wp-content/uploads/2019/04/managing-partitions-816x345.png
[2]: https://www.rodsbooks.com/
[3]: https://fedoramagazine.org/wp-content/uploads/2019/04/sgdisk.jpg
[4]: https://en.wikipedia.org/wiki/Device_file
[5]: https://en.wikipedia.org/wiki/BIOS_boot_partition