From 75a971fe1303e04253edfb6c09d67cbaac5ec0ea Mon Sep 17 00:00:00 2001 From: DarkSun Date: Thu, 5 Nov 2020 05:02:40 +0800 Subject: [PATCH 001/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201030=20?= =?UTF-8?q?How=20to=20rebase=20to=20Fedora=2033=20on=20Silverblue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201030 How to rebase to Fedora 33 on Silverblue.md --- ...ow to rebase to Fedora 33 on Silverblue.md | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 sources/tech/20201030 How to rebase to Fedora 33 on Silverblue.md diff --git a/sources/tech/20201030 How to rebase to Fedora 33 on Silverblue.md b/sources/tech/20201030 How to rebase to Fedora 33 on Silverblue.md new file mode 100644 index 0000000000..c17bf28706 --- /dev/null +++ b/sources/tech/20201030 How to rebase to Fedora 33 on Silverblue.md @@ -0,0 +1,93 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to rebase to Fedora 33 on Silverblue) +[#]: via: (https://fedoramagazine.org/how-to-rebase-to-fedora-33-on-silverblue/) +[#]: author: (Michal Konečný https://fedoramagazine.org/author/zlopez/) + +How to rebase to Fedora 33 on Silverblue +====== + +![][1] + +Silverblue is [an operating system for your desktop built on Fedora][2]. It’s excellent for daily use, development, and container-based workflows. It offers [numerous advantages][3] such as being able to roll back in case of any problems. If you want to update to Fedora 33 on your Silverblue system, this article tells you how. It not only shows you what to do, but also how to revert things if something unforeseen happens. + +Prior to actually doing the rebase to Fedora 33, you should apply any pending updates. Enter the following in the terminal: + +``` +$ rpm-ostree update +``` + +or install updates through GNOME Software and reboot. + +### Rebasing using GNOME Software + +The GNOME Software shows you that there is new version of Fedora available on the Updates screen. + +![Fedora 33 is available][4] + +First thing you need to do is to download the new image, so click on the _Download_ button. This will take some time and after it’s done you will see that the update is ready to install. + +![Fedora 33 is ready for installation][5] + +Click on the _Install_ button. This step will take only a few moments and then you will be prompted to restart your computer. + +![Restart is needed to rebase to Fedora 33 Silverblue][6] + +Click on _Restart_ button and you are done. After restart you will end up in new and shiny release of Fedora 33. Easy, isn’t it? + +### Rebasing using terminal + +If you prefer to do everything in a terminal, than this next guide is for you. + +Rebasing to Fedora 33 using terminal is easy. First, check if the 33 branch is available: + +``` +$ ostree remote refs fedora +``` + +You should see the following in the output: + +``` +fedora:fedora/33/x86_64/silverblue +``` + +Next, rebase your system to the Fedora 33 branch. + +``` +$ rpm-ostree rebase fedora:fedora/33/x86_64/silverblue +``` + +Finally, the last thing to do is restart your computer and boot to Fedora 33. + +### How to roll back + +If anything bad happens—for instance, if you can’t boot to Fedora 33 at all—it’s easy to go back. Pick the previous entry in the GRUB menu at boot, and your system will start in its previous state before switching to Fedora 33. To make this change permanent, use the following command: + +``` +$ rpm-ostree rollback +``` + +That’s it. Now you know how to rebase Silverblue to Fedora 33 and roll back. So why not do it today? + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/how-to-rebase-to-fedora-33-on-silverblue/ + +作者:[Michal Konečný][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/zlopez/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/02/fedora-silverblue-logo.png +[2]: https://docs.fedoraproject.org/en-US/fedora-silverblue/ +[3]: https://fedoramagazine.org/give-fedora-silverblue-a-test-drive/ +[4]: https://fedoramagazine.org/wp-content/uploads/2020/10/Screenshot-from-2020-10-29-12-53-37-1024x725.png +[5]: https://fedoramagazine.org/wp-content/uploads/2020/10/Screenshot-from-2020-10-29-13-00-15-1024x722.png +[6]: https://fedoramagazine.org/wp-content/uploads/2020/10/Screenshot-from-2020-10-29-13-01-32-1024x727.png From da3e84b3e207314ec08e72e8615418306390f530 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Thu, 5 Nov 2020 05:09:40 +0800 Subject: [PATCH 002/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020200711=20?= =?UTF-8?q?scanimage:=20scan=20from=20the=20command=20line!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20200711 scanimage- scan from the command line.md --- ...1 scanimage- scan from the command line.md | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 sources/tech/20200711 scanimage- scan from the command line.md diff --git a/sources/tech/20200711 scanimage- scan from the command line.md b/sources/tech/20200711 scanimage- scan from the command line.md new file mode 100644 index 0000000000..91cda0b4ae --- /dev/null +++ b/sources/tech/20200711 scanimage- scan from the command line.md @@ -0,0 +1,75 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (scanimage: scan from the command line!) +[#]: via: (https://jvns.ca/blog/2020/07/11/scanimage--scan-from-the-command-line/) +[#]: author: (Julia Evans https://jvns.ca/) + +scanimage: scan from the command line! +====== + +Here’s another quick post about a command line tool I was delighted by. + +Last night, I needed to scan some documents for some bureaucratic reasons. I’d never used a scanner on Linux before and I was worried it would take hours to figure out. I started by using `gscan2pdf` and had trouble figuring out the user interface – I wanted to scan both sides of the page at the same time (which I knew our scanner supported) but couldn’t get it to work. + +### enter scanimage! + +`scanimage` is a command line tool, in the `sane-utils` Debian package. I think all Linux scanning tools use the `sane` libraries (“scanner access now easy”) so my guess is that it has similar abilities to any other scanning software. I didn’t need OCR in this case so we’re not going to talk about OCR. + +### get your scanner’s name with `scanimage -L` + +`scanimage -L` lists all scanning devices you have. + +At first I couldn’t get this to work and I was a bit frustrated but it turned out that I’d connected the scanner to my computer, but not plugged it into the wall. Oops. + +Once everything was plugged in it worked right away. Apparently our scanner is called `fujitsu:ScanSnap S1500:2314`. Hooray! + +### list options for your scanner with `--help` + +Apparently each scanner has different options (makes sense!) so I ran this command to get the options for my scanner: + +``` +scanimage --help -d 'fujitsu:ScanSnap S1500:2314' +``` + +I found out that my scanner supported a `--source` option (which I could use to enable duplex scanning) and a `--resolution` option (which I changed to 150 to decrease the file sizes and make scanning faster). + +### scanimage doesn’t output PDFs (but you can write a tiny script) + +The only downside was – I wanted a PDF of my scanned document, and scanimage doesn’t seem to support PDF output. + +So I wrote this 5-line shell script to scan a bunch of PNGs into a temp directory and convert the resulting PNGs to a PDF. + +``` +#!/bin/bash +set -e + +DIR=`mktemp -d` +CUR=$PWD +cd $DIR +scanimage -b --format png -d 'fujitsu:ScanSnap S1500:2314' --source 'ADF Front' --resolution 150 +convert *.png $CUR/$1 +``` + +I ran the script like this. `scan-single-sided output-file-to-save.pdf` + +You’ll probably need a different `-d` and `--source` for your scanner. + +### it was so easy! + +I always expect using printers/scanners on Linux to be a nightmare and I was really surprised how `scanimage` Just Worked – I could just run my script with `scan-single-sided receipts.pdf` and it would scan a document and save it to `receipts.pdf`!. +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2020/07/11/scanimage--scan-from-the-command-line/ + +作者:[Julia Evans][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://jvns.ca/ +[b]: https://github.com/lujun9972 From ce1e17c077d736b36c4e054fdf1e35b43955b701 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Thu, 5 Nov 2020 05:10:12 +0800 Subject: [PATCH 003/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020200619=20?= =?UTF-8?q?A=20little=20bit=20of=20plain=20Javascript=20can=20do=20a=20lot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20200619 A little bit of plain Javascript can do a lot.md --- ...le bit of plain Javascript can do a lot.md | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 sources/tech/20200619 A little bit of plain Javascript can do a lot.md diff --git a/sources/tech/20200619 A little bit of plain Javascript can do a lot.md b/sources/tech/20200619 A little bit of plain Javascript can do a lot.md new file mode 100644 index 0000000000..ac36191038 --- /dev/null +++ b/sources/tech/20200619 A little bit of plain Javascript can do a lot.md @@ -0,0 +1,115 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (A little bit of plain Javascript can do a lot) +[#]: via: (https://jvns.ca/blog/2020/06/19/a-little-bit-of-plain-javascript-can-do-a-lot/) +[#]: author: (Julia Evans https://jvns.ca/) + +A little bit of plain Javascript can do a lot +====== + +I’ve never worked as a professional frontend developer, so even though I’ve been writing HTML/CSS/JS for 15 years for little side projects, all of the projects have been pretty small, sometimes I don’t write any Javascript for years in between, and I often don’t quite feel like I know what I’m doing. + +Partly because of that, I’ve leaned on libraries a lot! Ten years ago I used to use jQuery, and since maybe 2017 I’ve been using a lot of vue.js for my little Javascript projects (you can see a [little whack-a-mole game I made here as an intro to Vue][1]). + +But last week, for the first time in a while, I wrote some plain Javascript without a library and it was fun so I wanted to talk about it a bit! + +### experimenting with just plain Javascript + +I really like Vue. But last week when I started building , I had slightly different constraints than usual – I wanted to use the same HTML to generate both a PDF (with [Prince][2]) and to make an interactive version of the questions. + +I couldn’t really see how that would work with Vue (because Vue wants to create all the HTML itself), and because it was a small project I decided to try writing it in plain Javascript with no libraries – just write some HTML/CSS and add a single ``. + +I hadn’t done this in a while, and I learned a few things along the way that made it easier than I thought it would be when I started. + +### do almost everything by adding & removing CSS classes + +I decided to implement almost all of the UI by just adding & removing CSS classes, and using [CSS transitions][3] if I want to animate a transition. + +here’s a small example, where clicking the “next” question button adds the “done” class to the parent div. + +``` +div.querySelector('.next-question').onclick = function () { + show_next_row(); + this.parentElement.parentElement.classList.add('done'); +} +``` + +This worked pretty well. My CSS as always is a bit of a mess but it felt manageable. + +### add/remove CSS classes with `.classList` + +I started out by editing the classes like this: `x.className = 'new list of classes'`. That felt a bit messy though and I wondered if there was a better way. And there was! + +You can also add CSS classes like this: + +``` +let x = document.querySelector('div'); +x.classList.add('hi'); +x.classList.remove('hi'); +``` + +`element.classList.remove('hi')` is way cleaner than what I was doing before. + +### find elements with `document.querySelectorAll` + +When I started learning jQuery I remember thinking that if you wanted to easily find something in the DOM you had to use jQuery (like `$('.class')`). I just learned this week that you can actually write `document.querySelectorAll('.some-class')` instead, and then you don’t need to depend on any library! + +I got curious about when `querySelectorAll` was introduced. I Googled a tiny bit and it looks like the [Selectors API was built sometime between 2008 and 2013 – I found a [post from the jQuery author discussing the proposed implementation in 2008][4], and [a blog post from 2011][5] saying it was in all major browsers by then, so maybe it didn’t exist when I started using jQuery but it’s definitely been around for quite a while :) + +### set `.innerHTML` + +In one place I wanted to change a button’s HTML contents. Creating DOM elements with `document.createElement` is pretty annoying, so I tried to do that as little as possible and instead set `.innerHTML` to the HTML string I wanted: + +``` +button.innerHTML = `I learned something! + +`; +``` + +### scroll through the page with `.scrollIntoView` + +The last fun thing I learned about is `.scrollIntoView` – I wanted to scroll down to the next question automatically when someone clicked “next question”. Turns out this is just one line of code: + +``` +row.classList.add('revealed'); +row.scrollIntoView({behavior: 'smooth', block: 'center'}); +``` + +### another vanilla JS example: peekobot + +Another small example of a plain JS library I thought was nice is [peekobot][6], which is a little chatbot interface that’s 100 lines of JS/CSS. + +Looking at [its Javascript][7], it uses some similar patterns – a lot of `.classList.add`, some adding elements to the DOM, some `.querySelectorAll`. + +I learned from reading peekobot’s source about [.closest][8] which finds the closest ancestor that matches a given selector. That seems like it would be a nice way to get rid of some of the `.parentElement.parentElement` that I was writing in my Javascript, which felt a bit fragile. + +### plain Javascript can do a lot! + +I was pretty surprised by how much I could get done with just plain JS. I ended up writing about 50 lines of JS to do everything I wanted to do, plus a bit extra to collect some anonymous metrics about what folks were learning. + +As usual with my frontend posts, this isn’t meant to be Serious Frontend Engineering Advice – my goal is to be able to write little websites with less than 200 lines of Javascript that mostly work. If you are also flailing around in frontend land I hope this helps a bit! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2020/06/19/a-little-bit-of-plain-javascript-can-do-a-lot/ + +作者:[Julia Evans][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://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://jvns.ca/blog/2017/06/26/vue-js-fun/ +[2]: https://www.princexml.com/ +[3]: https://3dtransforms.desandro.com/card-flip +[4]: https://johnresig.com/blog/thoughts-on-queryselectorall/ +[5]: https://tiffanybbrown.com/2011/08/12/meet-the-selectors-api/ +[6]: https://peekobot.github.io/peekobot/ +[7]: https://github.com/Peekobot/peekobot/blob/master/peekobot.js +[8]: https://developer.mozilla.org/en-US/docs/Web/API/Element/closest From a034604ad2b1e84430d9a6ca0c8f8223ac13a783 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Thu, 5 Nov 2020 05:10:20 +0800 Subject: [PATCH 004/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020200617=20?= =?UTF-8?q?What=20happens=20when=20you=20update=20your=20DNS=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20200617 What happens when you update your DNS.md --- ...7 What happens when you update your DNS.md | 236 ++++++++++++++++++ 1 file changed, 236 insertions(+) create mode 100644 sources/tech/20200617 What happens when you update your DNS.md diff --git a/sources/tech/20200617 What happens when you update your DNS.md b/sources/tech/20200617 What happens when you update your DNS.md new file mode 100644 index 0000000000..0a17d1d621 --- /dev/null +++ b/sources/tech/20200617 What happens when you update your DNS.md @@ -0,0 +1,236 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What happens when you update your DNS?) +[#]: via: (https://jvns.ca/blog/how-updating-dns-works/) +[#]: author: (Julia Evans https://jvns.ca/) + +What happens when you update your DNS? +====== + +I’ve seen a lot of people get confused about updating their site’s DNS records to change the IP address. Why is it slow? Do you really have to wait 2 days for everything to update? Why do some people see the new IP and some people see the old IP? What’s happening? + +So I wanted to write a quick exploration of what’s happening behind the scenes when you update a DNS record. + +### how DNS works: recursive vs authoritative DNS servers + +First, we need to explain a little bit about DNS. There are 2 kinds of DNS servers: **authoritative** and **recursive**. + +**authoritative** DNS servers (also known as **nameservers**) have a database of IP addresses for each domain they’re responsible for. For example, right now an authoritative DNS server for github.com is ns-421.awsdns-52.com. You can ask it for github.com’s IP like this; + +``` +dig @ns-421.awsdns-52.com github.com +``` + +**recursive** DNS servers, by themselves, don’t know anything about who owns what IP address. They figure out the IP address for a domain by asking the right authoritative DNS servers, and then cache that IP address in case they’re asked again. 8.8.8.8 is a recursive DNS server. + +When people visit your website, they’re probably making their DNS queries to a recursive DNS server. So, how do recursive DNS servers work? Let’s see! + +### how does a recursive DNS server query for github.com? + +Let’s go through an example of what a recursive DNS server (like 8.8.8.8) does when you ask it for an IP address (A record) for github.com. First – if it already has something cached, it’ll give you what it has cached. But what if all of its caches are expired? Here’s what happens: + +**step 1**: it has IP addresses for the root DNS servers hardcoded in its source code. You can see this in [unbound’s source code here][1]. Let’s say it picks `198.41.0.4` to start with. Here’s the [official source][2] for those hardcoded IP addresses, also known as a “root hints file”. + +**step 2**: Ask the root nameservers about `github.com`. + +We can roughly reproduce what happens with `dig`. What this gives us is a new authoritative nameserver to ask: a nameserver for `.com`, with the IP `192.5.6.30`. + +``` +$ dig @198.41.0.4 github.com +... +com. 172800 IN NS a.gtld-servers.net. +... +a.gtld-servers.net. 172800 IN A 192.5.6.30 +... +``` + +The details of the DNS response are a little more complicated than that – in this case, there’s an authority section with some NS records and an additional section with A records so you don’t need to do an extra lookup to get the IP addresses of those nameservers. + +(in practice, 99.99% of the time it’ll already have the address of the `.com` nameservers cached, but we’re pretending we’re really starting from scratch) + +**step 3**: Ask the `.com` nameservers about `github.com`. + +``` +$ dig @192.5.6.30 github.com +... +github.com. 172800 IN NS ns-421.awsdns-52.com. +ns-421.awsdns-52.com. 172800 IN A 205.251.193.165 +... +``` + +We have a new IP address to ask! This one is the nameserver for `github.com`. + +**step 4**: Ask the `github.com` nameservers about `github.com`. + +We’re almost done! + +``` +$ dig @205.251.193.165 github.com + +github.com. 60 IN A 140.82.112.4 +``` + +Hooray!! We have an `A` record for `github.com`! Now the recursive nameserver has `github.com`’s IP address and can return it back to you. And it could do all of this by only hardcoding a few IP addresses: the addresses of the root nameservers. + +### how to see all of a recursive DNS server’s steps: `dig +trace` + +When I want to see what a recursive DNS server would do when resolving a domain, I run + +``` +$ dig @8.8.8.8 +trace github.com +``` + +This shows all the DNS records that it requests, starting at the root DNS servers – all the 4 steps that we just went through. + +### let’s update some DNS records! + +Now that we know the basics of how DNS works, let’s update some DNS records and see what happens. + +When you update your DNS records, there are two main options: + + 1. keep the same nameservers + 2. change nameservers + + + +### let’s talk about TTLs + +We’ve forgotten something important though! TTLs! You know how we said earlier that the recursive DNS server will cache records until they expire? The way it decides whether the record should expire is by looking at its **TTL** or “time to live”. + +In this example, the TTL for the A record github’s nameserver returns for its DNS record is `60`, which means 60 seconds: + +``` +$ dig @205.251.193.165 github.com + +github.com. 60 IN A 140.82.112.4 +``` + +That’s a pretty short TTL, and _in theory_ if everybody’s DNS implementation followed the [DNS standard][3] it means that if Github decided to change the IP address for `github.com`, everyone should get the new IP address within 60 seconds. Let’s see how that plays out in practice + +### option 1: update a DNS record on the same nameservers + +First, I updated my nameservers (Cloudflare) to have a new DNS record: an A record that maps `test.jvns.ca` to `1.2.3.4`. + +``` +$ dig @8.8.8.8 test.jvns.ca +test.jvns.ca. 299 IN A 1.2.3.4 +``` + +This worked immediately! There was no need to wait at all, because there was no `test.jvns.ca` DNS record before that could have been cached. Great. But it looks like the new record is cached for ~5 minutes (299 seconds). + +So, what if we try to change that IP? I changed it to `5.6.7.8`, and then ran the same DNS query. + +``` +$ dig @8.8.8.8 test.jvns.ca +test.jvns.ca. 144 IN A 1.2.3.4 +``` + +Hmm, it seems like that DNS server has the `1.2.3.4` record still cached for another 144 seconds. Interestingly, if I query `8.8.8.8` multiple times I actually get inconsistent results – sometimes it’ll give me the new IP and sometimes the old IP, I guess because 8.8.8.8 actually load balances to a bunch of different backends which each have their own cache. + +After I waited 5 minutes, all of the `8.8.8.8` caches had updated and were always returning the new `5.6.7.8` record. Awesome. That was pretty fast! + +### you can’t always rely on the TTL + +As with most internet protocols, not everything obeys the DNS specification. Some ISP DNS servers will cache records for longer than the TTL specifies, like maybe for 2 days instead of 5 minutes. And people can always hardcode the old IP address in their /etc/hosts. + +What I’d expect to happen in practice when updating a DNS record with a 5 minute TTL is that a large percentage of clients will move over to the new IPs quickly (like within 15 minutes), and then there will be a bunch of stragglers that slowly update over the next few days. + +### option 2: updating your nameservers + +So we’ve seen that when you update an IP address without changing your nameservers, a lot of DNS servers will pick up the new IP pretty quickly. Great. But what happens if you change your nameservers? Let’s try it! + +I didn’t want to update the nameservers for my blog, so instead I went with a different domain I own and use in the examples for the [HTTP zine][4]: `examplecat.com`. + +Previously, my nameservers were set to dns1.p01.nsone.net. I decided to switch them over to Google’s nameservers – `ns-cloud-b1.googledomains.com` etc. + +When I made the change, my domain registrar somewhat ominiously popped up the message – “Changes to examplecat.com saved. They’ll take effect within the next 48 hours”. Then I set up a new A record for the domain, to make it point to `1.2.3.4` + +Okay, let’s see if that did anything + +``` +$ dig @8.8.8.8 examplecat.com +examplecat.com. 17 IN A 104.248.50.87 +``` + +No change. If I ask a different DNS server, it knows the new IP: + +``` +$ dig @1.1.1.1 examplecat.com +examplecat.com. 299 IN A 1.2.3.4 +``` + +but 8.8.8.8 is still clueless. The reason 1.1.1.1 sees the new IP even though I just changed it 5 minutes ago is presumably that nobody had ever queried 1.1.1.1 about examplecat.com before, so it had nothing in its cache. + +### nameserver TTLs are much longer + +The reason that my registrar was saying “THIS WILL TAKE 48 HOURS” is that the TTLs on NS records (which are how recursive nameservers know which nameserver to ask) are MUCH longer! + +The new nameserver is definitely returning the new IP address for `examplecat.com` + +``` +$ dig @ns-cloud-b1.googledomains.com examplecat.com +examplecat.com. 300 IN A 1.2.3.4 +``` + +But remember what happened when we queried for the `github.com` nameservers, way back? + +``` +$ dig @192.5.6.30 github.com +... +github.com. 172800 IN NS ns-421.awsdns-52.com. +ns-421.awsdns-52.com. 172800 IN A 205.251.193.165 +... +``` + +172800 seconds is 48 hours! So nameserver updates will in general take a lot longer to expire from caches and propagate than just updating an IP address without changing your nameserver. + +### how do your nameservers get updated? + +When I update the nameservers for `examplecat.com`, what happens is that he `.com` nameserver gets a new `NS` record with the new domain. Like this: + +``` +dig ns @j.gtld-servers.net examplecat.com + +examplecat.com. 172800 IN NS ns-cloud-b1.googledomains.com +``` + +But how does that new NS record get there? What happens is that I tell my **domain registrar** what I want the new nameservers to be by updating it on the website, and then my domain registrar tells the `.com` nameservers to make the update. + +For `.com`, these updates happen pretty fast (within a few minutes), but I think for some other TLDs the TLD nameservers might not apply updates as quickly. + +### your program’s DNS resolver library might also cache DNS records + +One more reason TTLs might not be respected in practice: many programs need to resolve DNS names, and some programs will also cache DNS records indefinitely in memory (until the program is restarted). + +For example, AWS has an article on [Setting the JVM TTL for DNS Name Lookups][5]. I haven’t written that much JVM code that does DNS lookups myself, but from a little Googling about the JVM and DNS it seems like you can configure the JVM so that it caches every DNS lookup indefinitely. (like [this elasticsearch issue][6]) + +### that’s all! + +I hope this helps you understand what’s going on when updating your DNS! + +As a disclaimer, again – TTLs definitely don’t tell the whole story about DNS propagation – some recursive DNS servers definitely don’t respect TTLs, even if the major ones like 8.8.8.8 do. So even if you’re just updating an A record with a short TTL, it’s very possible that in practice you’ll still get some requests to the old IP for a day or two. + +Also, I changed the nameservers for `examplecat.com` back to their old values after publishing this post. + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/how-updating-dns-works/ + +作者:[Julia Evans][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://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://github.com/NLnetLabs/unbound/blob/6e0756e819779d9cc2a14741b501cadffe446c93/iterator/iter_hints.c#L131 +[2]: https://www.iana.org/domains/root/files +[3]: https://tools.ietf.org/html/rfc1035 +[4]: https://wizardzines.com/zines/http/ +[5]: https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/java-dg-jvm-ttl.html +[6]: https://github.com/elastic/elasticsearch/issues/16412 From 5eb262dfb77cbb38d874333b471b41379fd7e7fc Mon Sep 17 00:00:00 2001 From: DarkSun Date: Thu, 5 Nov 2020 05:10:35 +0800 Subject: [PATCH 005/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020200508=20?= =?UTF-8?q?Metaphors=20in=20man=20pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20200508 Metaphors in man pages.md --- .../tech/20200508 Metaphors in man pages.md | 182 ++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 sources/tech/20200508 Metaphors in man pages.md diff --git a/sources/tech/20200508 Metaphors in man pages.md b/sources/tech/20200508 Metaphors in man pages.md new file mode 100644 index 0000000000..8a9ea9c3b9 --- /dev/null +++ b/sources/tech/20200508 Metaphors in man pages.md @@ -0,0 +1,182 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Metaphors in man pages) +[#]: via: (https://jvns.ca/blog/2020/05/08/metaphors-in-man-pages/) +[#]: author: (Julia Evans https://jvns.ca/) + +Metaphors in man pages +====== + +This morning I was watching a [great talk by Maggie Appleton][1] about metaphors. In the talk, she explains the difference between a “figurative metaphor” and a “cognitive metaphor”, and references this super interesting book called [Metaphors We Live By][2] which I immediately got and started reading. + +Here’s an example from “Metaphors We Live By” of a bunch of metaphors we use for ideas: + + * ideas as **food**: “_raw_ facts”, “_half-baked_ ideas”, “_swallow_ that claim”, “_spoon-feed_ our students”, “_meaty_ part of the paper”, “that idea has been _fermenting_ for years” + * ideas as **people**: “the theory of relativity _gave birth_ to an enormous number of ideas”, “whose _brainchild_ was that”, “those ideas _died off_ in the middle ages”, “cognitive psychology is in its _infancy_“ + * ideas as **products**: “we’ve _generated_ a lot of ideas this week”, “it needs to be _refined_”, “his _intellectual productivity_ has decreased in recent years” + * ideas as **commodities**: “he won’t _buy_ that”, “that’s a _worthless_ idea”, “she has _valuable_ ideas” + * ideas as **resources**: “he _ran out_ of ideas”, “let’s _pool_ our ideas”, “that idea will _go a long way_“ + * ideas as **cutting instruments**: “that’s an _incisive_ idea”, “that _cuts right to the heart_ of the matter”, “he’s _sharp_“ + * ideas as **fashions**: “that idea _went out of style_ years ago”, “marxism is _fashionable_ in western europe”, “berkeley is a center of _avant-garde_ thought”, “semiotics has become quite _chic_“ + + + +There’s a [long list of more English metaphors here][3], including many metaphors from the book. + +I was surprised that there were so many different metaphors for ideas, and that we’re using metaphors like this all the time in normal language. + +### let’s look for metaphors in man pages! + +Okay, let’s get to the point of this blog post, which is just a small fun exploration – there aren’t going to be any Deep Programming Insights here. + +I went through some of the examples of metaphors in Metaphors To Live By and grepped all the man pages on my computer for them. + +### processes as people + +This is one of the richer categories – a lot of different man pages seem to agree that processes are people, or at least alive in some way. + + * Hangup detected on controlling terminal or **death** of controlling process (`man 7 signal`) + * can access the local **agent** through the forwarded connection (`man ssh_config`) + * If the exit of the process causes a process group to become **orphaned** (`man exit`) + * If a parent process terminates, then its **“zombie” children** (if any) (`man wait`) + * … send SIGHUP to the **parent** process of the client (`man tmux`) + * Otherwise, it **“runs” to catch up** or waits (`man mplayer`) + * However, Git does not (and it should not) change tags **behind users back** (`man git-tag`) + * will **listen** forever for a connection (`man nc_openbsd`) + * this monitor scales badly with the number of files being **observed** (`man fswatch`) + * If you try to use the **birth** time of a reference file (`man file`) + * a program **died** due to a fatal signal (`man xargs`) + * protocol version in the TLS **handshake** (`man curl`) + * it will **look for** a debug object at… (`man valgrind`) + + + +### data as food + + * “Apparently some digital cameras get **indigestion** if you feed them a CF card) (`man mkfs`) + * “Send packets using **raw** ethernet frames or IP packets” (`man nmap`) + * “the above example can be thought of as a maximizing repeat that must **swallow** everything it can” (`man pcrepattern`) + * “This will allow you to **feed** newline-delimited name=value pairs to the script on’ (`man CGI`) + + + +### data as objects + + * Kill the tmux server and clients and **destroy** all sessions (`tmux`) + * Each command will produce one **block** of output on standard output. (`man tmux`) + * “HTTPS guarantees that the password will not **travel** in the clear” (`man Net::SSLeay`) + * “way to **pack** more than one certificate into an ASN.1 structure” (`man gpgsm`) + + + +### processes as machines/objects + + * “This is **fragile**, subject to change, and thus should not be relied upon” (`man ps`) + * “This is useful if you have to use **broken** DNS” (`man aria2c`) + * “This provides good safety measures, but **breaks down** when” (`man git-apply`) + * “debugfs is a debugging tool. It has **rough edges**!” (`man debugfs`) + + + +### containers + +There are LOTS of containers: directories, files, strings, caches, queues, buffers, etc. + + * can exploit that to **get out** of the chroot directory (`man chroot`) + * “The file **containing** the RFC 4648 Section 5 base64url encoded 128-bit secret key” + * “Keys must start with a lowercase character and **contain** only hyphens” + * “just specify an **empty** string” (`man valgrind`) + * “the cache is **full** and a new page that isn’t cached becomes visible” (`man zathurarc`) + * “Number of table **overflows**” (`man lnstat`) + * “likely **overflow** the buffer” (`man g++`) + + + +### resources + +There are also lots of kinds of resources: bandwidth, TCP sockets, session IDs, stack space, memory, disk space. + + * This is not recommended and **wastes** bitrate (`man bitrate`) + * corruption or **lost** data if the system crashes (`man btree`) + * you don’t want Wget to **consume** the entire available bandwidth (`man wget`) + * Larger values will be slower and cause x264 to **consume** more memory (`man mplayer`) + * the resulting file can **consume** some disk space (`man socat`) + * attempting to **reuse** SSL session-ID (`man curl`) + * This option controls stack space **reuse** (`man gcc`) + * Keep the TCP socket open between queries and **reuse** it rather than creating a new TCP socket (`man dig`) + * the maximum value will easily **eat up** three extra gigabytes or so of memory (`man valgrind`) + + + +### orientation (up, down, above, below) + + * Send the escape character to the **frontend** (`man qemu-system`) + * Note that TLS 1.3 is only supported by a subset of TLS **backends** (`man curl`) + * This option may be useful if you are **behind** a router (`man mplayer`) + * When a file that exists on the **lower** layer is renamed (`man rename`) + * Several of the socket options should be handled at **lower** levels (`man getsockopt`) + * while still performing such **higher** level functionality (`man nmap`) + * This is the same string passed **back to** the front end (`man sudo_plugin`) + * On Linux, `futimens` is a library function implemented **on top** of the `utimensat` system call (`man futimens`) + + + +### buildings + +Limits as rooms/buildings (which have floors, and ceilings, which you hit) are kind of fun: + + * the kernel places a **floor** of 32 pages on this size limit (`man execve`) + * This specifies a **ceiling** to which the process’s nice value can be raised (`man getrlimit`) + * If this limit is **hit** the search is aborted (`man gcc`) + * these libraries are used as the **foundation** for many of the libraries (`man Glib`) + + + +### money / wealth + + * This is a very **expensive** operation for large projects, so use it with caution (`man git-log`) + * Note that since this operation is very I/O **expensive** (`man git-filter-branch`) + * provides a **rich** interface for scripts to print disk layouts (`man fdisk`) + * The number of times the softirq handler function terminated per second because its **budget** was consumed (`man sar.sysstat`) + * the extra **cost** depends a lot on the application at hand (`man valgrind`) + + + +### more miscellaneous metaphors + +here are some more I found that didn’t fit into any of those categories yet. + + * when a thread is created under glibc, just one **big** lock is used for all thread setup (`man valgrind`) + * will likely **drop** the connection (`man x11vnc`) + * on all **paths** from the load to the function entry (`man gcc`) + * it is a very good idea to **wipe** filesystem signatures, data, etc. before (`man cryptsetup`) + * they will be **embedded** into the document + * the client should automatically **follow** referrals returned + * even if there exist mappings that **cover** the whole address space requested (`man mremap`) + * when a network interface **disappears** (`man systemd-resolve`) + + + +### we’re all using metaphors all the time + +I found a lot more metaphors than I expected, and most of them are just part of how I’d normally talk about a program. Interesting! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2020/05/08/metaphors-in-man-pages/ + +作者:[Julia Evans][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://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://www.youtube.com/watch?v=K8MF3aDg-bM&feature=youtu.be&t=14991 +[2]: https://www.goodreads.com/book/show/34459.Metaphors_We_Live_By +[3]: https://metaphor.icsi.berkeley.edu/pub/en/index.php/Category:Metaphor From ea99949a0a02f66e8b4a264916f4f28e989739fe Mon Sep 17 00:00:00 2001 From: DarkSun Date: Wed, 18 Nov 2020 05:03:11 +0800 Subject: [PATCH 006/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201118=20?= =?UTF-8?q?How=20to=20Write,=20Compile=20and=20Run=20a=20C=20Program=20in?= =?UTF-8?q?=20Ubuntu=20and=20Other=20Linux=20Distributions=20[Beginner?= =?UTF-8?q?=E2=80=99s=20Tip]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201118 How to Write, Compile and Run a C Program in Ubuntu and Other Linux Distributions -Beginner-s Tip.md --- ...her Linux Distributions -Beginner-s Tip.md | 138 ++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 sources/tech/20201118 How to Write, Compile and Run a C Program in Ubuntu and Other Linux Distributions -Beginner-s Tip.md diff --git a/sources/tech/20201118 How to Write, Compile and Run a C Program in Ubuntu and Other Linux Distributions -Beginner-s Tip.md b/sources/tech/20201118 How to Write, Compile and Run a C Program in Ubuntu and Other Linux Distributions -Beginner-s Tip.md new file mode 100644 index 0000000000..5fa80a38de --- /dev/null +++ b/sources/tech/20201118 How to Write, Compile and Run a C Program in Ubuntu and Other Linux Distributions -Beginner-s Tip.md @@ -0,0 +1,138 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Write, Compile and Run a C Program in Ubuntu and Other Linux Distributions [Beginner’s Tip]) +[#]: via: (https://itsfoss.com/run-c-program-linux/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +How to Write, Compile and Run a C Program in Ubuntu and Other Linux Distributions [Beginner’s Tip] +====== + +How do you program in C on Linux? It is indeed very easy and consists of three simple steps. + +**Step 1**: You write your program and save the file with a .c extension. For example, my_program.c. + +**Step 2**: You compile the program and generate the object file using gcc compiler in a terminal like this: + +``` +gcc -o my_program my_program.c +``` + +**Step 3**: You run the generated object file to run your C program in Linux: + +``` +./my_program +``` + +![][1] + +This was just the quick summary on how to compile and run C program in Linux. If you are new to either C or Linux, I’ll show these steps in detail so that you feel comfortable coding C program in Linux environment. + +In fact, I’ll discuss how to run C programs in Linux terminal as well as in code editor. + +![][2] + +### Method 1: How to run C programs in Linux terminal + +In order to run a C program in Linux, you need to have a C compiler present on your systems. The most popular compiler is gcc ([GNU Compiler Collection][3]). + +You can install gcc using your distribution’s package manager. In Debian and Ubuntu-based Linux distributions, use the apt command: + +``` +sudo apt install gcc +``` + +Switch to directory where you have kept your C program (or provide the path) and then generate the object file by compiling the program: + +``` +gcc -o my_program my_program.c +``` + +Keep in mind that it is optional to provide the output object file (-o my_program). If you won’t do that, an object file named a.out will be automatically generated. But this is not good because it will be overwritten for each C program and you won’t be able to know which program the a.out object file belongs to. + +Once you have your object file generated, run it to run the C program. It is already executable. Simple use it like this: + +``` +./my_program +``` + +And it will display the desired output, if your program is correct. As you can see, this is not very different from [running C++ programs in Linux][4]. + +_**Every time you make a change in your program, you have to compile it first and then run the generated object file to run the C program.**_ + +### Method 2: How to run C programs in Linux using a code editor like Visual Studio Code + +Not everyone is comfortable with command line and terminal and I totally understand that. + +You can use a proper C/C++ IDE like Eclipse or Code Blocks but they are often too heavy programs and more suitable for large projects. + +I recommend using an open source code editor like Visual Studio Code or Atom. These are basically text editors and you can install add-ons to compile and run programs directly from the graphical code editor. + +I am using [Visual Studio Code editor][5] in this example. It’s a hugely [popular open source code editor][6] from Microsoft. + +First thing first, [install Visual Studio Code in Ubuntu][7] from the software center. For other distributions, please check your Linux distribution’s package manager or software center. You may also check the official website for more information. + +Start Visual Studio Code and open/create a project and create your C program here. I am using a sample Hello World program. + +![][8] + +You must ensure that you have gcc compiler installed on your Linux system. + +``` +sudo apt install gcc +``` + +Next thing you would want is to use an extension that allows you to run the C code. Microsoft may prompt you for installing its own extension for C/C++ program but it is complicated to setup and hence I won’t recommend it. + +Instead, I suggest using the Code Runner extension. It’s a no-nonsense extension and you can run C and C++ code easily without additional configuration. + +Go to the Extensions tab and search for ‘Code Runner’ and install it. + +![Install Code Runner extension for running C/C++ program][9] + +Restart Visual Studio Code. Now, you should be able to run the C code by using one of the following way: + + * Using the shortcut Ctrl+Alt+N. + * Press F1 and then select or type Run Code. + * Right click the text editor and the click Run code from context menu. + + + +![Right click the program file and choose Run Code][10] + +When you run the program, it is compiled automatically and then run. You can see the output in terminal that is opened at the bottom of the editor. What could be better than this? + +![Program output is displayed in the bottom section of the editor][11] + +Which method do you prefer? + +Running a few C programs in Linux command line is okay but using a code editor is much easier and saves time. Won’t you agree? + +I let you decide whichever method you want to use. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/run-c-program-linux/ + +作者:[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://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/running-c-program-linux.png?resize=795%2C399&ssl=1 +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/Run-C-Program-Linux.png?resize=800%2C450&ssl=1 +[3]: https://gcc.gnu.org/ +[4]: https://itsfoss.com/c-plus-plus-ubuntu/ +[5]: https://code.visualstudio.com +[6]: https://itsfoss.com/best-modern-open-source-code-editors-for-linux/ +[7]: https://itsfoss.com/install-visual-studio-code-ubuntu/ +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/c-program-visual-studio-code-linux.png?resize=800%2C441&ssl=1 +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/running-c-program-in-linux-with-visual-studio-code.png?resize=800%2C500&ssl=1 +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/running-c-program-in-linux-with-visual-studio-code.jpg?resize=800%2C500&ssl=1 +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/run-c-program-in-linux-with-visual-studio-code.jpg?resize=800%2C500&ssl=1 From c1c2557c62084c81f6c79f0e473877c1fe128725 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Wed, 18 Nov 2020 05:03:25 +0800 Subject: [PATCH 007/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201118=20?= =?UTF-8?q?LazPaint:=20A=20Free=20&=20Open=20Source=20Paint.NET=20Alternat?= =?UTF-8?q?ive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201118 LazPaint- A Free - Open Source Paint.NET Alternative.md --- ...ree - Open Source Paint.NET Alternative.md | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 sources/tech/20201118 LazPaint- A Free - Open Source Paint.NET Alternative.md diff --git a/sources/tech/20201118 LazPaint- A Free - Open Source Paint.NET Alternative.md b/sources/tech/20201118 LazPaint- A Free - Open Source Paint.NET Alternative.md new file mode 100644 index 0000000000..ad0c5f6594 --- /dev/null +++ b/sources/tech/20201118 LazPaint- A Free - Open Source Paint.NET Alternative.md @@ -0,0 +1,102 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (LazPaint: A Free & Open Source Paint.NET Alternative) +[#]: via: (https://itsfoss.com/lazpaint/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +LazPaint: A Free & Open Source Paint.NET Alternative +====== + +_**Brief: LazPaint is an open-source Paint.NET alternative with cross-platform support. It is a lightweight program with a bunch of essential options to edit images quickly. Here’s an overview of LazPaint.**_ + +### LazPaint: Open Source Paint.NET Alternative for Linux + +![][1] + +If you are fond of using tools to quickly edit and manipulate images and screenshots, you may have heard about [Paint.NET][2], which is available only for Windows systems. + +It is a popular nifty tool to get a lot of basic editing tasks done along with a bunch of options available. You might be aware of several [ima][3][ge editing tools][3] but Paint.NET is a pretty popular option just because it is easy to use without any bloated feature for an average user. + +[LazPaint][4] comes to the rescue as an impressive open source replacement to Paint.NET for Linux, Windows, and macOS. It offers most of the essential features one would need to manipulate images while being easy to use. + +![][5] + +Since it is cross-platform application, even if you’re not using a Linux system, you could still start using it as a no-nonsense free and open-source tool, if that’s your priority. Now, let us take a look at some features it offers. + +### Features of LazPaint + +![][6] + +As I mentioned earlier, LazPaint offers a bunch of essential features. Here, I’ll list the key highlights that can help you decide if you need it. However, I’d recommend you to explore it to know more about it. + + * All major file formats supported (including layered Bitmaps and 3D files) + * Selection Tools, Crop to Selection, Selection Pen, Invert Selection + * Export to [Krita][7] supported + * Image resampling with various quality settings + * Motion Blur, Custom Blur, Radial Blur, and Pixelate tool + * Ability to remove transparency and flatten the image + * Rotate and Flip images + * Convert images to Negatives + * Ability to re-size Canvas + * Deforming tool (perspective) + * Advanced Drawing tools + * Set workspace color + * Dark theme + * Supports script functionality + * Layer support with essential management options + * Layer effects + * Filters + * Grayscale effect + * Ability to enable/disable the toolbar in or attach them to the Dock + + + +**Recommended Read:** + +![][8] + +#### [Drawing is an Open Source MS-Paint Type of App for Linux Desktop][9] + +### Installing LazPaint on Linux + +You should find it available in your official repositories to install it via your default package manager but to get the latest version, you will have to download the .**deb** file or compile it from source on non-Debian based Distributions. + +I wish there was a Flatpak available to get the latest version on every Linux distribution — but nothing as of now. + +It is available for Windows and macOS as well. You will also find a portable version available for Windows, that could come in handy. + +[LazPaint][4] + +### Closing Thoughts on LazPaint + +I found it really easy to use and the variety of quality settings to re-sample (or resize) an image is definitely a good addition. If you’ve already installed it, you must have noticed that it does not take a significant amount of storage to get installed and is a lightweight program overall. + +It’s snappy, and most of the functions that I tested in my quick usage worked quite well without any issues. + +What do you think about LazPaint as a Paint.NET alternative? Let me know your thoughts in the comments below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/lazpaint/ + +作者:[Ankush Das][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/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/lazpaint.jpg?resize=800%2C397&ssl=1 +[2]: https://www.getpaint.net +[3]: https://itsfoss.com/image-applications-ubuntu-linux/ +[4]: https://lazpaint.github.io/ +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/lazpaint-screenshot-2.png?resize=800%2C481&ssl=1 +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/lazpaint-screenshot.jpg?resize=800%2C484&ssl=1 +[7]: https://krita.org/en +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/09/drawing-app-interface.jpg?fit=789%2C449&ssl=1 +[9]: https://itsfoss.com/drawing-app/ From 347e077e9a545f6265d4ad09fc7d7ce83ed18511 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Wed, 18 Nov 2020 05:03:44 +0800 Subject: [PATCH 008/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201117=20?= =?UTF-8?q?My=20top=207=20Rust=20commands=20for=20using=20Cargo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201117 My top 7 Rust commands for using Cargo.md --- ... My top 7 Rust commands for using Cargo.md | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 sources/tech/20201117 My top 7 Rust commands for using Cargo.md diff --git a/sources/tech/20201117 My top 7 Rust commands for using Cargo.md b/sources/tech/20201117 My top 7 Rust commands for using Cargo.md new file mode 100644 index 0000000000..14f6672be1 --- /dev/null +++ b/sources/tech/20201117 My top 7 Rust commands for using Cargo.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (My top 7 Rust commands for using Cargo) +[#]: via: (https://opensource.com/article/20/11/commands-rusts-cargo) +[#]: author: (Mike Bursell https://opensource.com/users/mikecamel) + +My top 7 Rust commands for using Cargo +====== +Spend some time investigating Rust's package manager, Cargo. +![Person drinking a hot drink at the computer][1] + +I've been using Rust for a little over six months now. I'm far from an expert, but I have stumbled across many, many gotchas and learned many, many things along the way; things that I hope will be of use to those who are learning what is easily my favourite programming language. + +This is the third article in my miniseries for Rust newbs like me. You can find my other excursions into Rust in: + + * [My top 7 keywords in Rust][2] + * [My top 7 functions in Rust][3] + + + +I plan to write more, and this article is about Rust's package manager, [Cargo][4]. I'm ashamed to admit that I don't use Cargo's power as widely as I should, but researching this article gave me a better view of its commands' capabilities. In fact, I wasn't even aware of some of the options available until I started looking in more detail. + +For this list of my top seven Cargo commands, I'll assume you have basic familiarity with Cargo—that you have it installed, and you can create a package using `cargo new `, for instance. I could have provided more commands (there are many options!), but here are my "lucky 7." + + 1. **cargo help <command>:** You can always find out more about a command with the `--help` option. The same goes for Cargo itself: `cargo --help` will give you a quick intro to what's out there. To get more information on a command (more like a man page), you can try using the command `new`. For instance, `cargo help new` will give extended information about `cargo new`. This behaviour is pretty typical for command-line tools, particularly in the Linux/Unix world, but it's very expressively implemented for Cargo, and you can gain lots of quick information with it. + + 2. **cargo build --bin <target>:** What happens when you have multiple .rs files in your package, but you want to build just one of them? I have a package called `test-and-try` that I use for, well, testing and trying functionality, features, commands, and crates. It has around a dozen different files in it. By default, `cargo build` will try to build _all_ of them, and as they're often in various states of repair (some of them generating lots of warnings, some of them not even fully compiling), this can be a real pain. Instead, I place a section in my `Cargo.toml` file for each one like this: [code] + +[[bin]] +name = "warp-body" +path = "src/warp-body.rs" + +[/code] I can then use `cargo build --bin warp-body` to build _just_ this file (and any dependencies). I can then run it with a similar command: `cargo run --bin warp-body`. + + 3. **cargo test:** I have an admission; I am not as assiduous about creating automatic tests in my Rust code as I ought to be. This is because I'm currently mainly writing proof of concept rather than production code, and also because I'm lazy. Maybe changing this behaviour should be a New Year's resolution, but when I _do_ get round to writing tests, Cargo is there to help me (as it is for you). All you need to do is add a line before the test code in your .rs file: [code]`#[cfg(test)]`[/code] When you run `cargo test`, Cargo will "automagically" find these tests, run them, and tell you if you have problems. As with many of the commands here, you'll find much more information online, but it's particularly worth familiarising yourself with the basics of this capability in the relevant [Rust By Example section][5]. + + 4. **cargo search <query>:** This is one of the commands that I didn't even know existed until I started researching this article—and which would have saved me so much time over the past few months if I'd known about it. It searches [Crates.io][6], Rust's repository of public (and _sometimes_ maintained) packages and tells you which ones may be relevant. (You can specify a different repository if you want, with the intuitively named `--registry` option.) I've recently been doing some work on network protocols for non-String data, so I've been working with Concise Binary Object Representation ([CBOR][7]). Here's what happens if I use `cargo search`: + +![Cargo search output][8] + +(Mike Bursell, [CC BY-SA 4.0][9]) + +This is great! I can, of course, also combine this command with tools like grep to narrow down the search yet further, like so: `cargo search cbor --limit 70 | grep serde`. + + 5. **cargo tree:** Spoiler alert: this one may scare you. You've probably noticed that when you first build a new package, or when you add a new dependency, or just do a `cargo clean` and then `cargo build`, you see a long list of crates printed out as Cargo pulls them down from the relevant repositories and compiles them. How can you tell ahead of time, however, what will be pulled down and what version it will be? More importantly, how can you know what other dependencies a new crate has pulled into your build? The answer is `cargo tree`. Just to warn you: For any marginally complex project, you can expect to have a _lot_ of dependencies. I tried `cargo tree | wc -l` to count the number of dependent crates for a smallish project I'm working on and got an answer of 350! I tried providing an example, but it didn't display well, so I recommend that you try it yourself—be prepared for lots of output! + + 6. **cargo clippy:** If you try running this and it doesn't work, that's because I cheated a little with these last two commands: you may have to install them explicitly (depending on your setup). For this one, run `cargo install clippy`—you'll be glad you did. Clippy is Rust's linter; it goes through your code, looking at ways to reduce and declutter it by removing or changing commands. I try to run `cargo clippy` before every `git commit`—partly because the Git repositories I tend to commit to have automatic actions to reject files that need linting, and partly to keep my code generally more tidy. Here's an example: + +![Cargo clippy output][10] + +(Mike Bursell, [CC BY-SA 4.0][9]) + +Let's face it; this isn't a major issue (though clippy will find errors, too, if you run it on non-compiling code), but it's an easy fix, so you might as well deal with it—either by removing the code or prefixing the variable with an underscore. As I plan to use this variable later but haven't yet implemented the function to consume it, I will perform the latter fix. + + 7. **cargo readme:** While it's not the most earth-shattering of commands, this is another that is very useful (and that, as with `cargo clippy`, you may need to install explicitly). If you add the relevant lines to your .rs files, you can output README files from Cargo. For instance, I have the following lines at the beginning of my main.rs file: + +![Cargo readme input][11] + +(Mike Bursell, [CC BY-SA 4.0][9]) + +I'll leave the `cargo readme` command's output as an exercise for the reader, but it's interesting to me that the Licence (or "License," if you must) declaration is added. Use this to create simple documentation for your users and make them happy with minimal effort (always a good approach!). + + + + +I've just scratched the surface of Cargo's capabilities in this article; all the commands above are actually way more powerful than I described. I heartily recommend that you spend some time investigating Cargo and finding out how it can make your life better. + +* * * + +_This article was originally published on [Alice, Eve, and Bob][12] and is reprinted with the author's permission._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/11/commands-rusts-cargo + +作者:[Mike Bursell][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/mikecamel +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_tea_laptop_computer_work_desk.png?itok=D5yMx_Dr (Person drinking a hot drink at the computer) +[2]: https://opensource.com/article/20/10/keywords-rust +[3]: https://opensource.com/article/20/10/rust-functions +[4]: https://doc.rust-lang.org/cargo/ +[5]: https://doc.rust-lang.org/stable/rust-by-example/testing/unit_testing.html +[6]: https://crates.io/ +[7]: https://cbor.io/ +[8]: https://opensource.com/sites/default/files/uploads/cargo-search-output-5.png (Cargo search output) +[9]: https://creativecommons.org/licenses/by-sa/4.0/ +[10]: https://opensource.com/sites/default/files/uploads/cargo-clippy-output-1.png (Cargo clippy output) +[11]: https://opensource.com/sites/default/files/uploads/cargo-readme-input.png (Cargo readme input) +[12]: https://aliceevebob.com/2020/11/03/my-top-7-cargo-rust-commands/ From 5b41acccb86b046e7db2c79113e667448063e658 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Wed, 18 Nov 2020 05:03:58 +0800 Subject: [PATCH 009/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201117=20?= =?UTF-8?q?Getting=20started=20with=20btrfs=20for=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201117 Getting started with btrfs for Linux.md --- ...17 Getting started with btrfs for Linux.md | 250 ++++++++++++++++++ 1 file changed, 250 insertions(+) create mode 100644 sources/tech/20201117 Getting started with btrfs for Linux.md diff --git a/sources/tech/20201117 Getting started with btrfs for Linux.md b/sources/tech/20201117 Getting started with btrfs for Linux.md new file mode 100644 index 0000000000..484638c901 --- /dev/null +++ b/sources/tech/20201117 Getting started with btrfs for Linux.md @@ -0,0 +1,250 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Getting started with btrfs for Linux) +[#]: via: (https://opensource.com/article/20/11/btrfs-linux) +[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss) + +Getting started with btrfs for Linux +====== +The B-tree filesystem is a filesystem and volume manager rolled into +one. It offers a lot of promise for delivering an advanced filesystem +feature set to Linux. +![Filing cabinet for organization][1] + +Btrfs has been available for Linux for several years, so you may already be familiar with it. If not, you may have questions about it, especially if you use Fedora Workstation (Btrfs is now its default filesystem). This article aims to help you get familiar with it and its advanced features, such as [copy-on-write][2] and [checksums][3]. + +Btrfs, short for B-Tree Filesystem, is actually a filesystem and volume manager rolled into one. It's often seen as a response to ZFS, introduced in Sun Microsystem's Solaris OS back in 2005, now largely replaced by an open source implementation called OpenZFS. Ubuntu Linux and FreeBSD often feature OpenZFS. Other examples with similar features are Red Hat's Stratis and the Linux Logical Volume Manager (LVM). + +### Setup + +To try Btrfs, I [downloaded][4] the Fedora 33 Workstation ISO file and installed it into a new virtual machine (VM). The installation process has not changed from previous versions. I did not customize any settings, including drive partitioning and formatting, to maintain an accurate "out of the box" setup for this tutorial. Once the VM was up and running, I installed and ran the GNOME Partition Editor ([GParted][5]) for a nice, factory-fresh view of the drive layout. + +![GParted's view of Btrfs on Fedora 33 Workstation using GParted][6] + +(Alan Formy-Duvall, [CC BY-SA 4.0][7]) + +From this point, it's not much different from what you're used to; in fact, you can use the system normally, and you might not even notice that the filesystem is Btrfs. However, having this new default enables you to leverage several cool features. + +### Examine the Btrfs filesystem + +I am not aware of any Btrfs-specific graphical tools, although some of its functions have been incorporated into existing disk-management tools. + +From the command line, you can get a closer look at the Btrfs format: + + +``` +# btrfs filesystem show +Label: 'fedora_localhost-live'  uuid: f2bb02f9-5c41-4c91-8eae-827a801ee58a +        Total devices 1 FS bytes used 6.36GiB +        devid    1 size 10.41GiB used 8.02GiB path /dev/vda3 +``` + +### Change Btrfs labels + +The first thing I noticed was the filesystem label set by the installer: `fedora_localhost-live`. This is inaccurate because it is now an installed system and no longer a [live CD][8]. So I changed it using the `btrfs filesystem label` command. + +Changing a Btrfs filesystem label is simple: + + +``` +# btrfs filesystem label / +fedora_localhost-live +# btrfs filesystem label / fedora33workstation +# btrfs filesystem label / +fedora33workstation +``` + +### Manage Btrfs subvolumes + +A subvolume appears to be a standard directory that can be managed by Btrfs. There are several subvolumes on my new Fedora 33 Workstation: + + +``` +# btrfs subvolume list / +ID 256 gen 2458 top level 5 path home +ID 258 gen 2461 top level 5 path root +ID 265 gen 1593 top level 258 path var/lib/machines +``` + +Create a new subvolume using the `btrfs subvolume create` command, or delete a subvolume with `btrfs subvolume delete`: + + +``` +# btrfs subvolume create /opt/foo +Create subvolume '/opt/foo' +# btrfs subvolume list / +ID 256 gen 2884 top level 5 path home +ID 258 gen 2888 top level 5 path root +ID 265 gen 1593 top level 258 path var/lib/machines +ID 276 gen 2888 top level 258 path opt/foo +# btrfs subvolume delete /opt/foo +Delete subvolume (no-commit): '/opt/foo' +``` + +Subvolumes allow actions like setting a quota, taking a snapshot, and replicating to other locations and hosts. How can system administrators take advantage of these capabilities? How about for user home directories? + +#### Add a user + +As has been the case since olden times, adding a new user account creates a home directory for the account to use: + + +``` +# useradd student1 +# getent passwd student1 +student1❌1006:1006::/home/student1:/bin/bash +# ls -l /home +drwx------. 1 student1 student1  80 Oct 29 00:21 student1 +``` + +Traditionally, a user's home directory is a subdirectory of `/home`. Ownership and privileges are tailored to the owner, but there are no special functions for managing them. The enterprise server environment is another scenario. Often, a directory is reserved for use by a particular application and its user. You can take advantage of Btrfs to manage and apply constraints to these directories. + +To accommodate Btrfs subvolumes as user homes, there is a new option to the `useradd` command: `--btrfs-subvolume-home`. Although the man pages have not been updated (as of this writing), you can see the option by running `useradd --help`. By passing this option when adding a new user, a new Btrfs subvolume will be created. It functions just like the `-d` option does for creating a regular directory: + + +``` +# useradd --btrfs-subvolume-home student2 +Create subvolume '/home/student2' +``` + +Verify the user with `getent passwd student2`, and it will appear normal. However, run the `btrfs subvolume` command to list subvolumes, and you will see something interesting: the new user's home directory! + + +``` +# btrfs subvolume list / +ID 256 gen 2458 top level 5 path home +ID 258 gen 2461 top level 5 path root +ID 265 gen 1593 top level 258 path var/lib/machines +ID 272 gen 2459 top level 256 path home/student2 +``` + +Explore the second scenario of an enterprise server environment. Suppose you need to install a [WildFly][9] server in `/opt` and deploy a Java web application. Often, your first step is to create a `wildfly` user.  Do this using the new `--btrfs-subvolume-home` option along with the `-b` option to specify `/opt` as the base directory: + + +``` +# useradd -b /opt --btrfs-subvolume-home wildfly +Create subvolume '/opt/wildfly' +``` + +Now, the `wildfly` user can log in and complete the installation in `/opt/wildfly`. + +#### Delete a user + +When you delete a user, sometimes you want to delete that user's files and the home directory at the same time. The `userdel` command has the `-r` option for this, and it also deletes Btrfs subvolumes: + + +``` +# userdel -r student2 +Delete subvolume (commit): '/home/student2' +``` + +#### Set disk-usage quotas + +In one of my computer science classes, a student ran a C program that went out of control and wrote to the disk until the entire `/home` was filled on the department's Unix system! The server became unavailable until the admin killed the runaway process and cleared some space. The same is true for the scenario above; that Wildfly enterprise application will have a growing number of log files and content stores for its users. How can you prevent a server from grinding to a halt because the disk has filled up? Setting disk-usage constraints is a good idea. Fortunately, Btrfs supports this by way of quotas. + +There are several steps required to configure quotas. The first step is to enable `quota` on the Btrfs filesystem: + + +``` +`# btrfs quota enable /` +``` + +Make sure you know each subvolume's quota group (qgroup) ID number, which is displayed by the `btrfs subvolume list` command. Each subvolume needs an associated qgroup based on its ID number. This can be done on an individual basis with `btrfs qgroup create`, but, conveniently, the Btrfs wiki provides the following command to expedite creating qgroups for subvolumes on a filesystem: + + +``` +`>btrfs subvolume list \ | cut -d' ' -f2 | xargs -I{} -n1 btrfs qgroup destroy 0/{} \` +``` + +In a freshly installed Fedora 33 workstation system, you are operating on the root filesystem path, `/`. Substitute `\` with the root path: + + +``` +`# btrfs subvolume list / | cut -d' ' -f2 | xargs -I{} -n1 btrfs qgroup create 0/{} /` +``` + +Then run `btrfs quota rescan` and take a look at the new qgroups: + + +``` +# btrfs quota rescan / +quota rescan started +# btrfs qgroup show / +qgroupid         rfer         excl +\--------         ----         ---- +0/5          16.00KiB     16.00KiB +0/256       272.04MiB    272.04MiB +0/258         6.08GiB      6.08GiB +0/265        16.00KiB     16.00KiB +0/271        16.00KiB     16.00KiB +0/273        16.00KiB     16.00KiB +``` + +Now you can assign a quota to one of the qgroups, which, in turn, is applied to its associated subvolume. So, if you want to limit student3's home directory usage to 1GB, use the `btrfs qgroup limit` command: + + +``` +`# btrfs qgroup limit 1G /home/student3` +``` + +Confirm the quota for the specific subvolume: + + +``` +# btrfs qgroup show -reF /home/student3 +qgroupid         rfer         excl     max_rfer     max_excl +\--------         ----         ----     --------     -------- +0/271        16.00KiB     16.00KiB      1.00GiB         none +``` + +Slightly different options will show all qgroups and any quotas that are set: + + +``` +# btrfs qgroup show -re / +qgroupid         rfer         excl     max_rfer     max_excl +\--------         ----         ----     --------     -------- +0/5          16.00KiB     16.00KiB         none         none +0/256       272.04MiB    272.04MiB         none         none +0/258         6.08GiB      6.08GiB         none         none +0/265        16.00KiB     16.00KiB         none         none +0/271        16.00KiB     16.00KiB      1.00GiB         none +0/273        16.00KiB     16.00KiB         none         none +``` + +### Other features + +These examples provide some idea of Btrfs' features. Run `btrfs --help` to see the full list of commands. Many other notable capabilities exist; for instance, snapshots and send/receive are two worth learning. + +### Final thoughts + +Btrfs offers a lot of promise for delivering an advanced filesystem feature set to Linux. It wasn't the first; I credit ZFS for my introduction to this type of filesystem some 15 years ago, but Btrfs is fully open source and unencumbered by patents. + +I advise starting with a virtual machine or spare system if you want to explore this filesystem. + +I would like to see some graphical management utilities produced for system administrators who like to operate in the GUI world. Fortunately, Btrfs has strong development activity, as evidenced by the Fedora project's decision to make it default on Workstation 33. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/11/btrfs-linux + +作者:[Alan Formy-Duval][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/alanfdoss +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/files_documents_organize_letter.png?itok=GTtiiabr (Filing cabinet for organization) +[2]: https://en.wikipedia.org/wiki/Copy-on-write +[3]: https://en.wikipedia.org/wiki/Checksum +[4]: https://getfedora.org/en/workstation/download/ +[5]: https://gparted.org/ +[6]: https://opensource.com/sites/default/files/uploads/gparted_btrfs.png (GParted's view of Btrfs on Fedora 33 Workstation using GParted) +[7]: https://creativecommons.org/licenses/by-sa/4.0/ +[8]: https://en.wikipedia.org/wiki/Live_CD +[9]: https://www.wildfly.org/ From e1bfacc70311451f97bfa53914913998c3c60f99 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Wed, 18 Nov 2020 05:04:11 +0800 Subject: [PATCH 010/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201117=20?= =?UTF-8?q?How=20to=20upgrade=20to=20Terraform=200.12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201117 How to upgrade to Terraform 0.12.md --- ...201117 How to upgrade to Terraform 0.12.md | 503 ++++++++++++++++++ 1 file changed, 503 insertions(+) create mode 100644 sources/tech/20201117 How to upgrade to Terraform 0.12.md diff --git a/sources/tech/20201117 How to upgrade to Terraform 0.12.md b/sources/tech/20201117 How to upgrade to Terraform 0.12.md new file mode 100644 index 0000000000..6f38dd9201 --- /dev/null +++ b/sources/tech/20201117 How to upgrade to Terraform 0.12.md @@ -0,0 +1,503 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to upgrade to Terraform 0.12) +[#]: via: (https://opensource.com/article/20/11/update-terraform) +[#]: author: (Jessica Cherry https://opensource.com/users/cherrybomb) + +How to upgrade to Terraform 0.12 +====== +Updating your environment to Terraform 0.12 is not for the faint of +heart, but this how-to will make it less painful. +![Green graph of measurements][1] + +In [getting started with Terraform][2], I used Terraform version 0.11. As some readers pointed out, this version lacks some significant features, so in this article, I'll explain how to update Terraform to the more feature-rich version 0.12. + +You may be surprised to learn that many people still use Terraform 0.11, including large organizations and stubborn users who like to stay on tried-and-true technology. Converting from Terraform 0.11 to 0.12 can be very complex. If you want to take advantage of the newer features but think you're not ready to update, this article should help make the conversion easier. + +In this article, I'll use the code from my "getting started" article and the [tfenv][3] tool, which enables you to use different versions of Terraform on the same machine. I'll also assume that you're familiar with two versions of Terraform (the one you're using, and the one you're migrating to), and how to use the `terraform` command in general. + +### Code changes needed for version 12 + +Some things work in Terraform version 0.11 that do not work in version 0.12. Here is an example of code I used in my previous article: + + +``` +resource "kubernetes_namespace" "1-minikube-namespace" { +  metadata { +        name = "my-first-terraform-namespace" +  } +} +``` + +As one reader pointed out, this code block does not work in version 0.12 due to changes in the way the latest Terraform works. This is a simple example, and it gets more complicated. Here are some examples of how much things may need to change in a production environment. + +The new Terraform needs slightly different syntax and structure. For starters, add a `vars.tf` file: + + +``` +variable "namespace" { +  type = "string" +  default = "helloworld" +} + +variable "cluster" { +  type = "string" +  default = "minikube" +} +``` + +Then, change parts of the `main.tf` file to incorporate the new `vars.tf` file. The Kubernetes provider now looks like this: + + +``` +provider "kubernetes" { +  config_context_cluster   = "${var.cluster}" +} +``` + +Here is the revised namespace resource: + + +``` +resource "kubernetes_namespace" "1-minikube-namespace" { +  metadata { +        name = "${var.namespace}" +  } +} +``` + +Finally, the changed [Helm provider][4]: + + +``` +provider "helm" { +  kubernetes { +        config_context_cluster   = "${var.cluster}" +  } +} +``` + +Beware! These small changes will matter when switching between versions. + +### Deploy before conversion + +Before moving forward, [set up tfenv][5] to use the correct version of Terraform: + + +``` +jess@Athena:~/terraform_doc$ tfenv list +  0.12.29 +  0.11.15-oci +jess@Athena:~/terraform_doc$ tfenv use 0.11.15-oci +Switching default version to v0.11.15-oci +Switching completed +jess@Athena:~/terraform_doc$ terraform --version +Terraform v0.11.15-oci +\+ provider.helm v1.2.2 +\+ provider.kubernetes v1.11.2 + +Your version of Terraform is out of date! The latest version +is 0.xx.y. You can update by downloading from [www.terraform.io/downloads.html][6] +``` + +If you (like me) have done other work with Terraform after using the code in my previous Terraform article, you need to redeploy everything. Set up the Minikube cluster for this Terraform deployment by starting a new, clean cluster: + + +``` +$ minikube delete +🔥  Deleting "minikube" in kvm2 ... +💀  Removed all traces of the "minikube" cluster. +jess@Athena:~/terraform_doc$ minikube start +😄  minikube v1.14.0 on Ubuntu 18.04 +``` + +After the cluster is set up, you can deploy your modified Terraform code. Start with the `init` command: + + +``` +$ terraform init + +Initializing provider plugins... + +The following providers do not have any version constraints in configuration, +so the latest version was installed. + +To prevent automatic upgrades to new major versions that may contain breaking +changes, it is recommended to add version = "..." constraints to the +corresponding provider blocks in configuration, with the constraint strings +suggested below. + +* provider.helm: version = "~> 1.2" +* provider.kubernetes: version = "~> 1.11" + +Terraform has been successfully initialized! + +You may now begin working with Terraform. Try running "terraform plan" to see +any changes that are required for your infrastructure. All Terraform commands +should now work. [...] +``` + +Next, run your plan: + + +``` +$ terraform plan +Refreshing Terraform state in-memory prior to plan... +helm_release.local: Refreshing state... (ID: buildachart) +kubernetes_namespace.1-minikube-namespace: Refreshing state... (ID: my-first-terraform-namespace) [...] + +Terraform will perform the following actions: + +  + helm_release.local +        id:                            <computed> +        atomic:                        "false" +        chart:                         "./buildachart" +        cleanup_on_fail:               "false" +        create_namespace:              "false" +        dependency_update:             "false" +        disable_crd_hooks:             "false" +        disable_openapi_validation: "false" +        [...] +  + kubernetes_namespace.1-minikube-namespace +        id:                            <computed> +        metadata.#:                     "1" +        [...] + +Note: You didn't specify an "-out" parameter to save this plan, so Terraform +can't guarantee that exactly these actions will be performed if +"terraform apply" is subsequently run. +``` + +Finally, apply the Terraform: + + +``` +$ terraform apply --auto-approve +helm_release.local: Refreshing state... (ID: buildachart) +kubernetes_namespace.1-minikube-namespace: Refreshing state... (ID: my-first-terraform-namespace) +kubernetes_namespace.1-minikube-namespace: Creating... +  metadata.#:                   "" => "1" +  metadata.0.generation:       "" => "<computed>" +  [...] +helm_release.local: Creating... +  atomic:                      "" => "false" +  chart:                       "" => "./buildachart" +  cleanup_on_fail:             "" => "false" +  create_namespace:            "" => "false" + [...] +  version:                     "" => "0.1.0" +  wait:                        "" => "true" +kubernetes_namespace.1-minikube-namespace: Creation complete after 1s (ID: helloworld) +helm_release.local: Still creating... (10s elapsed) +helm_release.local: Creation complete after 13s (ID: buildachart) + +Apply complete! Resources: 2 added, 0 changed, 0 destroyed. +``` + +Now you have a local backup of the Terraform state: + + +``` +$ ls -lrt + +drwxr-xr-x 6 jess jess 4096 May 16 14:15 buildachart +-rw-r--r-- 1 jess jess  363 Oct 24 13:06 main.tf +-rw-rw-r-- 1 jess jess  132 Oct 24 13:17 vars.tf +-rw-rw-r-- 1 jess jess 3897 Oct 24 13:20 terraform.tfstate.backup +-rw-rw-r-- 1 jess jess 3821 Oct 24 13:21 terraform.tfstate +``` + +### Convert from Terraform 0.11 to 0.12 + +Once everything is deployed using Terraform 0.11, you must work through the conversion process without damaging what you have in your new production cluster. First, change your Terraform version to 0.12 using tfenv: + + +``` +$ tfenv list +  0.12.29 +* 0.11.15-oci (set by /home/jess/.tfenv/version) +jess@Athena:~/terraform_doc$ tfenv use 0.12.29 +Switching default version to v0.12.29 +Switching completed +jess@Athena:~/terraform_doc$ terraform --version +Terraform v0.12.29 +\+ provider.helm v1.2.2 +\+ provider.kubernetes v1.11.2 +``` + +Now that you're on Terraform 0.12, you're ready to convert. Luckily, Terraform has a built-in command for this, as shown in this snippet from the Terraform command list: + + +``` +All other commands: +        0.12upgrade     Rewrites pre-0.12 module source code for v0.12 +``` + +Test the `upgrade` command to see what will be rewritten, then enter `yes` to do the upgrade: + + +``` +$ terraform 0.12upgrade + +This command will rewrite the configuration files in the given directory so +that they use the new syntax features from Terraform v0.12, and will identify +any constructs that may need to be adjusted for correct operation with +Terraform v0.12. +[...] +Would you like to upgrade the module in the current directory? +  Only 'yes' will be accepted to confirm. + +  Enter a value: yes + +\----------------------------------------------------------------------------- + +Upgrade complete! + +The configuration files were upgraded successfully. Use your version control +system to review the proposed changes, make any necessary adjustments, and +then commit. +``` + +It seems to have gone well. It may have rewritten some things, but that will not account for everything that needs to be changed with the Terraform files. However, it does a great job of making notes within the files. Here are the changes it made to the `vars.tf` file: + + +``` +variable "namespace" { +  type  = string +  default = "helloworld" +} + +variable "cluster" { +  type  = string +  default = "minikube" +} +``` + +The `type` changed to remove quotes around the word `string` (quoting in Terraform files has changed over time). Next, look at the `main.tf` file: + + +``` +provider "kubernetes" { +  config_context_cluster = var.cluster +} + +# TF-UPGRADE-TODO: In Terraform v0.11 and earlier, it was possible to begin a +# resource name with a number, but it is no longer possible in Terraform v0.12. +# +# Rename the resource and run `terraform state mv` to apply the rename in the +# state. Detailed information on the `state move` command can be found in the +# documentation online: +resource "kubernetes_namespace" "1-minikube-namespace" { +  metadata { +        name = var.namespace +  } +} + +provider "helm" { +  kubernetes { +        config_context_cluster = var.cluster +  } +} + +resource "helm_release" "local" { +  name  = "buildachart" +  chart = "./buildachart" +} +``` + +The quotes changed here, too, and variables are no longer wrapped in `${}` characters. The biggest section is a large TODO note that the conversion command placed in the code to show what needs to change in the resource name to be acceptable in version 0.12. Even better, it explains how to fix this issue and the command you need to run. The other major changes are the new `versions.tf` file and a new backup file: + + +``` +$ ls -lrt +drwxr-xr-x 6 jess jess 4096 May 16 14:15 buildachart +-rw-rw-r-- 1 jess jess 3897 Oct 24 13:20 terraform.tfstate.backup +-rw-r--r-- 1 jess jess   46 Oct 24 13:28 versions.tf +-rw-rw-r-- 1 jess jess  140 Oct 24 13:55 vars.tf +-rw-r--r-- 1 jess jess  369 Oct 24 13:56 main.tf +-rw-rw-r-- 1 jess jess 3821 Oct 24 13:56 terraform.tfstate.1603562212.backup +-rw-rw-r-- 1 jess jess 3827 Oct 24 13:56 terraform.tfstate +``` + +To update your production cluster, start with a different name that is better suited for this version: + + +``` +resource "kubernetes_namespace" "upgrade-minikube-namespace" { +  metadata { +        name = var.namespace +  } +} +``` + +#### Smoothing the rough edges + +After that change, you must run the `terraform state mv` command (as referenced in the large TODO note). But first, run `state list` to see what you're working with: + + +``` +$ terraform state list +helm_release.local +Kubernetes_namespace.1-minikube-namespace +``` + +The namespace is still set in the state as `1-minikube-namespace`, and that's the state you need to move. This can be done by ensuring you have the new and old resource names, then running the `terraform state mv` command. But before that, you must switch back to 0.11, using tfenv to make those changes, because this was deployed using Terraform 0.11, and 0.12 doesn't recognize the numbers at the start of the resource name (as the TODO says). You'll have to revert all the code changes the Terraform upgrade made except for the resource name change: + +**main.tf** + + +``` +provider "kubernetes" { +  config_context_cluster   = "${var.cluster}" +} + +resource "kubernetes_namespace" "upgrade-minikube-namespace" { +  metadata { +        name = "${var.namespace}" +  } +} + +provider "helm" { +  kubernetes { +        config_context_cluster   = "${var.cluster}" +  } +} +resource "helm_release" "local" { +  name          = "buildachart" +  chart         = "./buildachart" +} +``` + +**Vars.tf** + + +``` +variable "namespace" { +  type  = "string" +  default = "helloworld" +} + +variable "cluster" { +  type  = "string" +  default = "minikube" +} +``` + +Once the changes are back in place, switch tfenv back to version 0.11, and run the `state mv` command: + + +``` +$ tfenv use 0.11.15-oci +Switching default version to v0.11.15-oci +Switching completed +jess@Athena:~/terraform_doc$ terraform state mv 'kubernetes_namespace.1-minikube-namespace' 'kubernetes_namespace.upgrade-minikube-namespace' +Moved kubernetes_namespace.1-minikube-namespace to kubernetes_namespace.upgrade-minikube-namespace +``` + +### Final steps + +After this is complete, change tfenv back to version 0.12, and then remove your `versions.tf` file to make sure the conversion completes. If you don't remove this file, you'll get an error message: + + +``` +$ terraform 0.12upgrade +Error: Module already upgraded + +  on versions.tf line 3, in terraform: +   3:  required_version = ">= 0.12" + +The module in directory . has a version constraint that suggests it has +already been upgraded for v0.12. If this is incorrect, either remove this +constraint or override this heuristic with the -force argument. Upgrading a +module that was already upgraded may change the meaning of that module. +``` + +Remove the file and run the command: + + +``` +$ terraform 0.12upgrade + +This command will rewrite the configuration files in the given directory so +that they use the new syntax features from Terraform v0.12, and will identify +any constructs that may need to be adjusted for correct operation with +Terraform v0.12. [...] + +Would you like to upgrade the module in the current directory? +  Enter a value: yes + +\----------------------------------------------------------------------------- + +Upgrade complete! +``` + +#### Test the conversion with another deployment + +Test your new conversion by re-running your `init`, `plan`, and `apply` commands (I omitted chunks of the output in these snippets): + + +``` +$ terraform init + +Initializing the backend... +Initializing provider plugins... +[...] +Terraform has been successfully initialized! + +$ terraform plan +Refreshing Terraform state in-memory prior to plan... +The refreshed state will be used to calculate this plan, but will not be +persisted to local or remote state storage. + +helm_release.local: Refreshing state... [id=buildachart] +kubernetes_namespace.upgrade-minikube-namespace: Refreshing state... [id=helloworld] + +\------------------------------------------------------------------------ + +No changes. Infrastructure is up-to-date + +$ terraform apply +helm_release.local: Refreshing state... [id=buildachart] +kubernetes_namespace.upgrade-minikube-namespace: Refreshing state... [id=helloworld] + +Apply complete! Resources: 0 added, 0 changed, 0 destroyed. +``` + +As this shows, once everything was preconfigured and the state moved and reapplied during the conversion, no other changes were made because the infrastructure is in place. + +### Final thoughts + +Code and application upgrades are hard to do, especially in a live production environment. This is very true when converting from Terraform 0.11 to 0.12. I've done this on a large scale, and it involved extensive planning over a two-week timeframe. + +If you're going to do this in your production environment, make sure you: + + * Start by removing any resources or modules with prepended numbers. + * Move the state before running the upgrade. + * Keep your upgraded Terraform files in a forked repo for safety. + + + +I hope this article helps you move forward more quickly and easily than I did. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/11/update-terraform + +作者:[Jessica Cherry][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/cherrybomb +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_lead-steps-measure.png?itok=DG7rFZPk (Green graph of measurements) +[2]: https://opensource.com/article/20/7/terraform-kubernetes +[3]: https://github.com/tfutils/tfenv +[4]: https://opensource.com/article/20/3/helm-kubernetes-charts +[5]: https://opensource.com/article/20/11/tfenv +[6]: http://www.terraform.io/downloads.html From f2d1d0491ee56186d5d3ef731e9865643d2eacc0 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Wed, 18 Nov 2020 05:04:25 +0800 Subject: [PATCH 011/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201116=20?= =?UTF-8?q?Day=205:=20drawing=20lots=20of=20faces=20with=20sketch-rnn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201116 Day 5- drawing lots of faces with sketch-rnn.md --- ...- drawing lots of faces with sketch-rnn.md | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 sources/tech/20201116 Day 5- drawing lots of faces with sketch-rnn.md diff --git a/sources/tech/20201116 Day 5- drawing lots of faces with sketch-rnn.md b/sources/tech/20201116 Day 5- drawing lots of faces with sketch-rnn.md new file mode 100644 index 0000000000..0b1e0a4d5f --- /dev/null +++ b/sources/tech/20201116 Day 5- drawing lots of faces with sketch-rnn.md @@ -0,0 +1,87 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Day 5: drawing lots of faces with sketch-rnn) +[#]: via: (https://jvns.ca/blog/2020/11/16/day-5--lots-of-faces-with-sketch-rnn/) +[#]: author: (Julia Evans https://jvns.ca/) + +Day 5: drawing lots of faces with sketch-rnn +====== + +Hello! This week it’s generative art week at RC, and I thought it would be fun to generate drawings of faces. + +Someone suggested the [Google Quickdraw][1] dataset, which has a lot of pictures of faces. And even though I think most of the faces in there are not really that interesting, I really quite like some of them, like these two: + +![][2] ![][3] + +So that seems like somewhere to start! + +### step 1: get the sketch-rnn model + +sketch-rnn is an RNN trained on the quickdraw dataset that generates line drawings. You can see it in action in Monica Dinculescu’s very fun [magic sketchpad][4] demo here – you start making a drawing, and it’ll complete you drawing as a cat / bridge / whatever you want. + +I figured that would be a fun place to start, and [ml5js][5] has a [tutorial showing how to write Javascript code to draw things with sketch-rnn][6], which I followed. + +### step 2: make the tutorial code use async/await + +The ml5js example had a bunch of global variables and callbacks and I found it difficult to work with, so I spent a while refactoring it to use async/await so that I could play around with it more easily. This took a while but I got it to work. + +### step 3: make sketch-rnn draw lots of faces and put them into a gallery + +I started out with making a more interactive website, but decided to instead do something really simple to start: just get the model to draw a lot of faces and see how I felt about them. + +Here’s the resulting (very janky, not responsive) website I made, which draws faces and then puts them into a little “gallery” on the right: [lots of sketch-rnn faces][7]. You can see it “live” drawing the faces which is fun. + +The set of images that comes out looks something like this: + +![][8] + +I don’t really like _any_ of these faces, but it’s a start! It’s also very slow on my 2015 laptop, but faster on the iPad. I didn’t spend a lot of time profiling it, but it seems to spend a lot of time in some function with `lstm` in its name – I don’t know what an LSTM is exactly but I know it’s a component of an RNN, so I guess (as you’d expect) it just has a lot of math to do in Javascript to calculate the next line to draw and that’s slow. + +### next step: maybe find out if sketch-rnn can tell the difference between “interesting” and “boring” faces + +I think that this face: + +![][2] + +is a lot more interesting than this face: + +![][9] + +Can I convince the neural network to distinguish between faces that I think are ‘interesting’ and ‘boring’ and maybe only generate more “interesting” faces? We’ll see! Right now I am stuck on trying to get a pre-trained model loaded into Python, so there’s a long way to go. + +I did find someone who’d done something kind of similar, on [bad flamingos vs good flamingos][10] in the quickdraw dataset. + +I still don’t really know anything about RNNs, but maybe if I can answer this question I will learn something about them. + +### also there’s a refrigerator poetry forum + +Here’s that refrigerator poetry forum I was talking about last week: . You can write magnet poetry-style poems on a refrigerator. People wrote some charming poems and I’m happy with it. I think I might use Rails for another project in the future. + +Hopefully people won’t abuse it, if there’s abuse I’ll just take it off the internet probably. + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2020/11/16/day-5--lots-of-faces-with-sketch-rnn/ + +作者:[Julia Evans][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://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://quickdraw.withgoogle.com/data/face +[2]: https://jvns.ca/images/face1.jpg +[3]: https://jvns.ca/images/face2.jpg +[4]: https://magic-sketchpad.glitch.me/ +[5]: https://learn.ml5js.org +[6]: https://github.com/ml5js/ml5-library/tree/main/examples/javascript/SketchRNN/SketchRNN_interactive +[7]: https://lots-of-sketchrnn-faces.netlify.app/ +[8]: https://jvns.ca/images/faces.png +[9]: https://jvns.ca/images/boring-face.png +[10]: https://colinmorris.github.io/blog/bad_flamingos From e92a69376da31c4ecf4e7f2569c184fd6a477766 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Wed, 18 Nov 2020 19:40:21 +0800 Subject: [PATCH 012/139] APL --- sources/tech/20201111 Using Fedora 33 with Microsoft-s WSL2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20201111 Using Fedora 33 with Microsoft-s WSL2.md b/sources/tech/20201111 Using Fedora 33 with Microsoft-s WSL2.md index ba5f635617..f2d0bf45e9 100644 --- a/sources/tech/20201111 Using Fedora 33 with Microsoft-s WSL2.md +++ b/sources/tech/20201111 Using Fedora 33 with Microsoft-s WSL2.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (wxy) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) From e9371d88cd45b487510878e846685edcd1987a35 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Wed, 18 Nov 2020 20:27:45 +0800 Subject: [PATCH 013/139] TSL&PRF --- ...1 Using Fedora 33 with Microsoft-s WSL2.md | 146 ------------------ ...1 Using Fedora 33 with Microsoft-s WSL2.md | 112 ++++++++++++++ 2 files changed, 112 insertions(+), 146 deletions(-) delete mode 100644 sources/tech/20201111 Using Fedora 33 with Microsoft-s WSL2.md create mode 100644 translated/tech/20201111 Using Fedora 33 with Microsoft-s WSL2.md diff --git a/sources/tech/20201111 Using Fedora 33 with Microsoft-s WSL2.md b/sources/tech/20201111 Using Fedora 33 with Microsoft-s WSL2.md deleted file mode 100644 index f2d0bf45e9..0000000000 --- a/sources/tech/20201111 Using Fedora 33 with Microsoft-s WSL2.md +++ /dev/null @@ -1,146 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (wxy) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Using Fedora 33 with Microsoft’s WSL2) -[#]: via: (https://fedoramagazine.org/wsl-fedora-33/) -[#]: author: (Jim Perrin https://fedoramagazine.org/author/jperrin/) - -Using Fedora 33 with Microsoft’s WSL2 -====== - -![][1] - -Photo by [Matthias Heil][2] on [Unsplash][3] - -If you’re like me, you may find yourself running Windows for a variety of reasons from work to gaming. Sure you could run Fedora in a virtual machine or as a container, but those don’t blend into a common windows experience as easily as the Windows Subsystem for Linux (WSL). Using Fedora via WSL will let you blend the two environments together for a fantastic development environment. - -### Prerequisites - -There are a few basics you’ll need in order to make this all work. You should be running Windows 10, and have WSL2 installed already. If not, check out the [Microsoft documentation for instructions][4], and come back here when you’re finished. Microsoft recommends setting wsl2 as the distro default for simplicity. This guide assumes you’ve done that. - -Next, you’re going to need some means of unpacking xz compressed files. You can do this with another WSL-based distribution, or use [7zip][5]. - -### Download a Fedora 33 rootfs - -Since Fedora doesn’t ship an actual rootfs archive, we’re going to abuse the one used to generate the container image for dockerhub. You will want to download the [tar.xz file][6] from the fedora-cloud GitHub repository. Once you have the tar.xz, uncompress it, but don’t unpack it. You want to end up with something like fedora-33-_datestamp_.tar. Once you have that, you’re ready to build the image. - -### Composing the WSL Fedora build - -I prefer to use _c:\distros_, but you can choose nearly whatever location you want. Whatever you choose, make sure the top level path exists before you import the build. Now open a cmd or powershell prompt, because it’s time to import: -``` - -``` - -wsl.exe --import Fedora-33 c:\distros\Fedora-33 $HOME\Downloads\fedora-33.tar -``` - -``` - -You will see Fedora-33 show up in wsl’s list -``` - -``` - -PS C:\Users\jperrin> wsl.exe -l -v -  NAME                   STATE           VERSION -  Fedora-33                 Stopped         2 -``` - -``` - -From here, you can start to play around with Fedora in wsl, but we have a few things we need to do to make it actually _useful_ as a wsl distro. -``` - -``` - -wsl -d Fedora-33 -``` - -``` - -This will launch Fedora’s wsl instance as the root user. From here, you’re going to install a few core packages and set a new default user. You’re also going to need to configure sudo, otherwise you won’t be able to easily elevate privileges if you need to install something else later. -``` - -``` - -dnf update -dnf install wget curl sudo ncurses dnf-plugins-core dnf-utils passwd findutils -``` - -``` - -_wslutilites_ uses _curl_ and _wget_ for things like VS Code integration, so they’re useful to have around. Since you need to use a Copr repo for this, you want the added dnf functionality. - -### Add your user - -Now it’s time to add your user, and set it as the default. -``` - -``` - -useradd -G wheel yourusername -passwd yourusername -``` - -``` - -Now that you’ve created your username and added a password, make sure they work. Exit the wsl instance, and launch it again, this time specifying the username. You’re also going to test sudo, and check your uid. -``` - -``` - -wsl -d Fedora-33 -u yourusername -$id -u -1000 -$ sudo cat /etc/shadow -``` - -``` - -Assuming everything worked fine, you’re now ready to set the default user for your Fedora setup in Windows. To do this, exit the wsl instance and get back into Powershell. This Powershell one-liner configures your user properly: -``` - -``` - -Get-ItemProperty Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\\*\ DistributionName | Where-Object -Property DistributionName -eq Fedora-33  | Set-ItemProperty -Name DefaultUid -Value 1000 -``` - -``` - -Now you should be able to launch WSL again without specifying a user, and be yourself instead of root. - -### Customize! - -From here, you’re done getting the basic Fedora 33 setup running in wsl, but it doesn’t have the Windows integration piece yet. If this is something you want, there’s a Copr repo to enable. If you choose to add this piece, you’ll be able to run Windows apps directly from inside your shell, as well as integrate your Linux environment easily with VS Code. Note that Copr is not officially supported by Fedora infrastructure. Use packages at your own risk -``` - -``` - -dnf copr enable trustywolf/wslu -``` - -``` - -Now you can go configure your terminal, setup a Python development environment, or however else you want to use Fedora 33. Enjoy! - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/wsl-fedora-33/ - -作者:[Jim Perrin][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/jperrin/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2020/11/wsl-fedora33-816x345.jpg -[2]: https://unsplash.com/@matthias_heil?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText -[3]: https://unsplash.com/s/photos/windows?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText -[4]: https://docs.microsoft.com/en-us/windows/wsl/install-win10 -[5]: https://www.7-zip.org/download.html -[6]: https://github.com/fedora-cloud/docker-brew-fedora/tree/33/x86_64 diff --git a/translated/tech/20201111 Using Fedora 33 with Microsoft-s WSL2.md b/translated/tech/20201111 Using Fedora 33 with Microsoft-s WSL2.md new file mode 100644 index 0000000000..b94d6b5cdc --- /dev/null +++ b/translated/tech/20201111 Using Fedora 33 with Microsoft-s WSL2.md @@ -0,0 +1,112 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Using Fedora 33 with Microsoft’s WSL2) +[#]: via: (https://fedoramagazine.org/wsl-fedora-33/) +[#]: author: (Jim Perrin https://fedoramagazine.org/author/jperrin/) + +通过微软的 WSL2 使用 Fedora 33 +====== + +![][1] + +如果你像我一样,你可能会发现自己因为各种原因而运行 Windows,无论是因为工作还是游戏。当然,你可以在虚拟机或容器中运行 Fedora,但这些并不像 Windows 的 Linux 子系统(WSL)那样容易融合到普通的 Windows 体验中。通过 WSL 使用 Fedora 可以让你将这两种环境融合在一起,创造一个奇妙的开发环境。 + +### 先决条件 + +为了达成这一目标,你需要一些基本条件。你应该运行 Windows 10,并且已经安装了 WSL2。如果没有,请查看[微软文档说明][4],完成后再回来这里。微软建议为了简单起见,将 WSL2 设置为发行版的默认设置。本指南假设你已经这样做了。 + +接下来,你将需要一些解压 xz 压缩文件的方法。你可以用另一个基于 WSL 的发行版来解压,或者使用 [7zip][5]。 + +### 下载 Fedora 33 rootfs + +由于 Fedora 并没有提供实际的 rootfs 存档,所以我们将借用一个用于生成 Dockerhub 容器镜像的存档。你需要从 fedora-cloud 的 GitHub 仓库下载该 [tar.xz 文件][6] 。一旦你有了这个 tar.xz 文件,解压它,但不要展开 tar 包。你会得到一个类似 `fedora-33-时间标签.tar` 的文件。有了这个文件,你就可以构建镜像了。 + +### 组合 WSL Fedora 的构建版本 + +我喜欢使用 `c:\distros` 目录,但你可以选择几乎任何你想要的位置。无论你选择什么目录,在你导入该构建版本之前,确保其顶层路径存在。现在打开一个 CMD 或 Powershell 提示符,因为是时候导入了: + +``` +wsl.exe --import Fedora-33 c:\distros\Fedora-33 $HOME\Downloads\fedora-33.tar +``` + +你会看到 Fedora-33 显示在 WSL 的列表当中: + +``` +PS C:\Users\jperrin> wsl.exe -l -v + NAME STATE VERSION + Fedora-33 Stopped 2 +``` + +下面,你就可以开始在 WSL 中摆弄 Fedora 了,但我们还需要做一些事情来使它真正成为一个有用的 WSL 发行版。 + +``` +wsl -d Fedora-33 +``` + +这将以 root 用户的身份启动 Fedora 的 WSL 实例。下面,你将安装一些核心包并设置一个新的默认用户。你还需要配置 `sudo`,否则你将无法在以后需要安装其他东西时轻松提升权限。 + +``` +dnf update +dnf install wget curl sudo ncurses dnf-plugins-core dnf-utils passwd findutils +``` + +`wslutilites` 使用 `curl` 和 `wget` 来实现与 VS Code 的集成,所以它们很有用。由于你需要使用 COPR 仓库,你需要增加 `dnf` 功能。 + +### 添加你的用户 + +现在是时候添加你的用户,并将其设置为默认用户。 + +``` +useradd -G wheel 用户名 +passwd 用户名 +``` + +现在,你已经创建了你的用户名,并添加了密码,确保它们可以工作。退出 WSL 实例,并再次启动它,这次指定用户名。你还要测试 `sudo`,并检查你的 uid。 + +``` +wsl -d Fedora-33 -u 用户名 +$id -u +1000 +$ sudo cat /etc/shadow +``` + +假设一切正常,你现在已经准备好在 Windows 中为你的 Fedora 环境设置默认用户。要做到这一点,请退出 WSL 实例并回到 Powershell 中。这个 Powershell 单行代码可以正确配置你的用户: + +``` +Get-ItemProperty Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\\*\ DistributionName | Where-Object -Property DistributionName -eq Fedora-33  | Set-ItemProperty -Name DefaultUid -Value 1000 +``` + +现在你应该可以再次启动 WSL,而不需要指定就可以成为自己的用户而不是 root。 + +### 自定义! + +至此,你已经有了可以在 WSL 中运行的基本 Fedora 33 环境,但它还没有 Windows 集成的部分。如果你想要这个,有一个 COPR 仓库可以启用。如果你选择添加这部分,你就可以直接在 shell 里面运行 Windows 应用,也可以轻松地将你的 Linux 环境与 VS Code 集成。需要注意的是,COPR 并没有得到 Fedora 基础架构的官方支持。使用该软件包,风险自担。 + +``` +dnf copr enable trustywolf/wslu +``` + +现在你可以去配置终端、设置一个 Python 开发环境,或者其它你想使用 Fedora 33 的方式。享受吧! + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/wsl-fedora-33/ + +作者:[Jim Perrin][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/jperrin/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/11/wsl-fedora33-816x345.jpg +[2]: https://unsplash.com/@matthias_heil?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[3]: https://unsplash.com/s/photos/windows?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[4]: https://docs.microsoft.com/en-us/windows/wsl/install-win10 +[5]: https://www.7-zip.org/download.html +[6]: https://github.com/fedora-cloud/docker-brew-fedora/tree/33/x86_64 From 54c19dda69ac7ecf1122a576a6299a3616883b60 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Wed, 18 Nov 2020 20:36:38 +0800 Subject: [PATCH 014/139] APL --- ...ternet in Linux Terminal With These Command Line Browsers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md b/sources/tech/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md index 7c00882a6b..9f841a910c 100644 --- a/sources/tech/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md +++ b/sources/tech/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (wxy) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) From 222cdd80798407fc1665b544cbaea1e977ae382b Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Wed, 18 Nov 2020 21:20:51 +0800 Subject: [PATCH 015/139] TSL --- ...rminal With These Command Line Browsers.md | 170 ------------------ ...rminal With These Command Line Browsers.md | 170 ++++++++++++++++++ 2 files changed, 170 insertions(+), 170 deletions(-) delete mode 100644 sources/tech/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md create mode 100644 translated/tech/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md diff --git a/sources/tech/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md b/sources/tech/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md deleted file mode 100644 index 9f841a910c..0000000000 --- a/sources/tech/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md +++ /dev/null @@ -1,170 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (wxy) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (You can Surf Internet in Linux Terminal With These Command Line Browsers) -[#]: via: (https://itsfoss.com/terminal-web-browsers/) -[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) - -You can Surf Internet in Linux Terminal With These Command Line Browsers -====== - -I’m guessing that you are probably using Firefox or a Chrome-based browser like [Brave][1] to read this article. Or, maybe, Google Chrome or [Chromium][2]. - -In other words, you are utilizing a GUI-based approach to browse the web. However, back in the days, people used the terminal to fetch resources and browse the web because everything was mostly text-based information. - -Even though you cannot get every information from a terminal now, you can still try the command line browsers for some text-based information and open a web page from the Linux terminal. - -Not just limited to that, but if you are accessing a remote server or stuck in a terminal without a GUI, a terminal web browser can prove to be useful as well. - -So, in this article, I will be mentioning some terminal based web browsers that you can try on Linux. - -### Best Terminal-based Web Browsers for Linux Users - -_**Note:** The list is in no particular order of ranking._ - -#### 1\. W3M - -![][3] - -w3m is a popular open-source text-based web browser for the terminal. Even though the original project is no longer active, an active version of it is being maintained by a different developer Tatsuya Kinoshita. - -w3m is quite simple, supports SSL connections, colors, and in-line images as well. Of course, depending on what resource you are trying to access, things might look different on your end. As per my quick test, it didn’t seem to load up [DuckDuckGo][4] but I could [use Google in terminal][5] just fine. - -You can simply type **w3m** in the terminal to get help after installation. If you’re curious, you can also check out the repository at [GitHub][6]. - -##### How to install and use w3m? - -W3M is available on most of the default repositories for any Debian-based Linux distribution. If you have an Arch-based distro, you might want to check [AUR][7] if it’s not available directly. - -For Ubuntu, you can install it by typing in: - -``` -sudo apt install w3m w3m-img -``` - -Here, we are installing the w3m package along with image extension for in-line image support. Next, to get started, you have to simply follow the command below: - -``` -w3m xyz.com -``` - -Of course, you need to replace xyz.com to any website that you want to browse/test. Finally, you should know that you can use the keyboard arrow keys to navigate and press enter when you want to take an action. - -To quit, you can press **SHIFT+Q**, and to go back to the previous page — **SHIFT+B**. Additional shortcuts include **SHIFT + T** to open a new tab and **SHIFT + U** to open a new URL. - -You can explore more about it by heading to its man page as well. - -#### 2\. Lynx - -![][8] - -Lynx is yet another open source command line browser which you can try. Fortunately, more websites tend to work when using Lynx, so I’d say it is definitely better in that aspect. I was able to load up DuckDuckGo and make it work. - -In addition to that, I also noticed that it lets you accept/deny cookies when visiting various web resources. You can set it to always accept or deny as well. So, that’s a good thing. - -On the other hand, the window does not re-size well while using it from the terminal. I haven’t looked for any solutions to that, so if you’re trying this out, you might want to do that. In either case, it works great and you get all the instructions for the keyboard shortcuts right when you launch it in the terminal. - -Note that it does not match the system terminal theme, so it will look different no matter how your terminal looks like. - -##### How to install Lynx? - -Unlike w3m, you do get some Win32 installers if you’re interested to try. But, on Linux, it is available on the most of the default repositories. - -For Ubuntu, you just need to type in: - -``` -sudo apt install lynx -``` - -To get started, you just have to follow the command below: - -``` -lynx examplewebsite.com -``` - -Here, you just need to replace the example website with the resource you want to visit. - -If you want to explore the packages for other Linux distros, you can check out their [official website resources][9]. - -#### 3\. Links2 - -![][10] - -Links2 is an interesting text-based browser that you can easily utilize on your terminal with a good user experience. It gives you a nice interface to type in the URL and then proceed as soon as you launch it. - -![][11] - -It is worth noting that the theme will depend on your terminal settings, I have it set as “black-green”, hence this is what you see. Once you launch it as a command line browser, you just need to press any key to bring the URL prompt or Q to quit it. It works good enough and renders text from most of the sites. - -Unlike Lynx, you do not get the ability to accept/reject cookies. Other than that, it seems to work just fine. - -##### How to install Links2? - -As you’d expect, you will find it available in the most of the default repositories. For Ubuntu, you can install it by typing the following command in the terminal: - -``` -sudo apt install links2 -``` - -You can refer to its [official][12] [][12][website][12] for packages or documentations if you want to install it on any other Linux distribution. - -#### 4\. eLinks - -![][13] - -eLinks is similar to Links2 — but it is no longer maintained. You will still find it in the default repositories of various distributions, hence, I kept it in this list. - -It does not blend in with your system terminal theme. So, this may not be a pretty experience as a text-based browser without a “dark” mode if you needed that. - -##### How to install eLinks? - -On Ubuntu, it is easy to install it. You just have to type in the following in the terminal: - -``` -sudo apt install elinks -``` - -For other Linux distributions, you should find it available on the standard repositories. But, you can refer to the [official installation instructions][14] if you do not find it in the repository. - -### Wrapping Up - -It’s no surprise that there aren’t a lot of text-based web browsers to run on the terminal. Some projects like [Browsh][15] have tried to present a modern Linux command-line browser but it did not work in my case. - -While tools like curl and wget allow you to [download files from the Linux command line][16], these terminal-based web browsers provide additional features. - -In addition to command-line browsers, you may also like to try some [command line games for Linux][17], if you want to play around in the terminal. - -What do you think about the text-based web browsers for Linux terminal? Feel free to let me know your thoughts in the comments below. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/terminal-web-browsers/ - -作者:[Ankush Das][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/ankush/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/brave-web-browser/ -[2]: https://itsfoss.com/install-chromium-ubuntu/ -[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/10/w3m-google.jpg?resize=800%2C463&ssl=1 -[4]: https://duckduckgo.com/ -[5]: https://itsfoss.com/review-googler-linux/ -[6]: https://github.com/tats/w3m -[7]: https://itsfoss.com/aur-arch-linux/ -[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/10/lynx-terminal.jpg?resize=800%2C497&ssl=1 -[9]: https://lynx.invisible-island.net/lynx-resources.html -[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/10/links2-terminal.jpg?resize=800%2C472&ssl=1 -[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/links2-terminal-welcome.jpg?resize=800%2C541&ssl=1 -[12]: http://links.twibright.com/download.php -[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/elinks-terminal.jpg?resize=800%2C465&ssl=1 -[14]: http://elinks.or.cz/documentation/installation.html -[15]: https://www.brow.sh/ -[16]: https://itsfoss.com/download-files-from-linux-terminal/ -[17]: https://itsfoss.com/best-command-line-games-linux/ diff --git a/translated/tech/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md b/translated/tech/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md new file mode 100644 index 0000000000..53d2eb571a --- /dev/null +++ b/translated/tech/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md @@ -0,0 +1,170 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (You can Surf Internet in Linux Terminal With These Command Line Browsers) +[#]: via: (https://itsfoss.com/terminal-web-browsers/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +使用命令行浏览器在 Linux 终端上网浏览 +====== + +我猜你可能是用 Firefox 或基于 Chrome 的浏览器(如 [Brave][1])来阅读这篇文章。或者,也可能是 Chrome 浏览器或 [Chromium][2]。 + +换句话说,你正在利用基于 GUI 的方式浏览网页。然而,在以前,人们使用终端来获取资源和浏览网页,因为所有的东西大多是基于文本的信息。 + +虽然现在不能从终端上获取每一个信息,但对于一些文本信息,还是可以尝试使用命令行浏览器,从 Linux 终端上打开网页。 + +不仅如此,如果你访问的是远程服务器,或者只有一个没有 GUI 的终端,终端网页浏览器也可以证明它是有用的。 + +因此,在本文中,我将介绍一些基于终端的网络浏览器,你可以在 Linux 上尝试它们。 + +### Linux 用户的最佳终端 Web 浏览器 + +注:榜单排名不分先后。 + +#### 1、W3M + +![][3] + +`w3m` 是一个流行的基于文本的开源终端 Web 浏览器。尽管最初的项目已经不再活跃,但它的一个活跃版本正由另一个开发者 Tatsuya Kinoshita 维护。 + +`w3m` 相当简单,支持 SSL 连接、彩色,也支持内嵌图片。当然,根据你试图访问的资源,你那边的情况可能会有所不同。根据我的简单测试,它似乎无法加载 [DuckDuckGo][4],但我可以[在终端中使用 Google][5]就可以了。 + +安装后,你可以简单的在终端中输入 `w3m` 以得到帮助。如果你感兴趣的话,也可以到 [GitHub][6] 上去查看它的仓库。 + +**如何安装和使用 w3m?** + +`w3m` 在任何基于 Debian 的 Linux 发行版的默认仓库中都是可用的。如果你有一个基于 Arch 的发行版,如果没有直接可用的软件包,你可能需要查看一下 [AUR][7]。 + +对于 Ubuntu,你可以通过键入以下内容来安装它: + +``` +sudo apt install w3m w3m-img +``` + +在这里,我们将 w3m 包和图片扩展一起安装,以支持内嵌图片。接下来,要开始安装,你只需要按照下面的命令进行操作即可: + +``` +w3m xyz.com +``` + +当然,你需要将 `xyz.com` 替换成任何你想浏览/测试的网站。最后,你应该知道,你可以使用键盘上的方向键来导航,当你想采取一个动作时,按回车键。 + +要退出,你可以按 `SHIFT+Q`,返回上一页是 `SHIFT+B`。其他快捷键包括 `SHIFT+T` 打开新标签页和 `SHIFT+U` 打开新的 URL。 + +你可以通过访问它的手册页面来了解更多信息。 + +#### 2、Lynx + +![][8] + +Lynx 是又一个开源的命令行浏览器,你可以试试。幸运的是,很多的网站在使用 Lynx 时往往能正常工作,所以我说它在这方面肯定更好。我能够加载 DuckDuckGo,并使其工作。 + +除此之外,我还注意到它可以让你在访问各种网络资源时接受或拒绝 cookie。你也可以将它设置为总是接受或拒绝。所以,这是件好事。 + +另一方面,在终端上使用时,窗口不能很好地调整大小。我还没有寻找到任何解决方法,所以如果你正在尝试这个,你可能会想要这样做。不管是哪种情况,它都很好用,当你在终端启动它时,你会得到所有键盘快捷键的说明。 + +请注意,它与系统终端主题不匹配,所以无论你的终端看起来如何,它都会看起来不同。 + +**如何安装 Lynx?** + +与 w3m 不同的是,如果你有兴趣尝试的话,确实可以找到一些 Win32 上的安装程序。但是,在 Linux 上,它在大多数的默认仓库中都是可用的。 + +对于 Ubuntu 来说,你只需要输入: + +``` +sudo apt install lynx +``` + +要想使用,你只需要按照下面的命令进行操作: + +``` +lynx examplewebsite.com +``` + +在这里,你只需要将示例网站替换成你想要访问的资源即可。 + +如果你想找其他 Linux 发行版的软件包,可以查看他们的[官网资源][9]。 + +#### 3、Links2 + +![][10] + +Links2 是一款有趣的基于文本的浏览器,你可以在你的终端上轻松使用,用户体验良好。它给你提供了一个很好的界面,你启动它后,只要输入网址就可以了 + +![][11] + +值得注意的是,主题将取决于你的终端设置,我设置为“黑绿色”主题,因此你看到的就是这个。当你以命令行浏览器的方式启动它后,你只需要按任意键就会出现 URL 提示,或者按 `Q` 键退出。它足够好用,可以渲染大多数网站的文字。 + +与 Lynx 不同的是,你没有接受或拒绝 cookie 的功能。除此之外,它似乎工作的还不错。 + +**如何安装 Links2?** + +正如你所期望的,你会发现它在大多数默认的资源库中都有。对于 Ubuntu,你可以在终端输入以下命令来安装它: + +``` +sudo apt install links2 +``` + +如果你想在其他 Linux 发行版上安装它,你可以参考它的[官方网站][12]获取软件包或文档。 + +#### 4、eLinks + +![][13] + +eLinks 类似于 Links2,但它已经不再维护了。你仍然可以在各种发行版的默认仓库中找到它,因此,我把它保留在这个列表中。 + +它不会与你的系统终端主题相融合。所以,如果你需要的话,作为一个没有“黑暗”模式的文本型浏览器,这可能不是一个漂亮的体验。 + +**如何安装 eLinks?** + +在 Ubuntu 上,安装它很容易。你只需要在终端中输入以下内容: + +``` +sudo apt install elinks +``` + +对于其他 Linux 发行版,你应该可以在标准软件库中找到它。但是,如果你在软件库中找不到它,你可以参考[官方安装说明][14]。 + +### 总结 + +在终端上运行的基于文本的 Web 浏览器并不多,这并不奇怪。一些项目,如 [Browsh][15],试图呈现一个现代的 Linux 命令行浏览器,但在我这里它不能工作。 + +虽然像 `curl` 和 `wget` 这样的工具允许你[从 Linux 命令行下载文件][16],但这些基于终端的 Web 浏览器提供了额外的功能。 + +除了命令行浏览器之外,如果你想在终端上玩玩,也可以尝试一些[Linux 命令行游戏][17]。 + +对于 Linux 终端上的文本型 Web 浏览器,你有什么看法?欢迎在下面的评论中告诉我你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/terminal-web-browsers/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/brave-web-browser/ +[2]: https://itsfoss.com/install-chromium-ubuntu/ +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/10/w3m-google.jpg?resize=800%2C463&ssl=1 +[4]: https://duckduckgo.com/ +[5]: https://itsfoss.com/review-googler-linux/ +[6]: https://github.com/tats/w3m +[7]: https://itsfoss.com/aur-arch-linux/ +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/10/lynx-terminal.jpg?resize=800%2C497&ssl=1 +[9]: https://lynx.invisible-island.net/lynx-resources.html +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/10/links2-terminal.jpg?resize=800%2C472&ssl=1 +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/links2-terminal-welcome.jpg?resize=800%2C541&ssl=1 +[12]: http://links.twibright.com/download.php +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/elinks-terminal.jpg?resize=800%2C465&ssl=1 +[14]: http://elinks.or.cz/documentation/installation.html +[15]: https://www.brow.sh/ +[16]: https://itsfoss.com/download-files-from-linux-terminal/ +[17]: https://itsfoss.com/best-command-line-games-linux/ From dda5d01ddf60f3a68920672b97cbd854f639fa86 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Wed, 18 Nov 2020 22:59:25 +0800 Subject: [PATCH 016/139] PRF @geekpi --- ...t I love about the newest GNOME desktop.md | 34 +++++++------------ 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/translated/tech/20201110 What I love about the newest GNOME desktop.md b/translated/tech/20201110 What I love about the newest GNOME desktop.md index 2422efa87d..9169285098 100644 --- a/translated/tech/20201110 What I love about the newest GNOME desktop.md +++ b/translated/tech/20201110 What I love about the newest GNOME desktop.md @@ -1,46 +1,40 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) +[#]: reviewer: (wxy) [#]: publisher: ( ) [#]: url: ( ) [#]: subject: (What I love about the newest GNOME desktop) [#]: via: (https://opensource.com/article/20/11/new-gnome) [#]: author: (Jim Hall https://opensource.com/users/jim-hall) -我对最新的 GNOME 桌面的喜爱之处 +我喜欢最新的 GNOME 桌面 ====== -看看 GNOME 3.38 桌面的最新功能。 -![Digital images of a computer desktop][1] + +> 看看 GNOME 3.38 桌面最重要的新功能。 + +![](https://img.linux.net.cn/data/attachment/album/202011/18/225213tmv6aeev1x0t1p4k.jpg) Fedora 33 [刚出来][2],我就马上安装了它。在这个新版 Linux 发行版的众多功能中,其中之一是最新的 GNOME 桌面。GNOME 3.38 于 2020 年 9 月发布,我很喜欢它。 ### 我为什么喜欢 GNOME 3.38? -GNOME 3.38 [发布说明][3]中列出了这次更新中的一些重大的新功能。其中,如果你是新用户的话,新用户的欢迎页面得到了重大的改版,现在更加容易使用,并且提供了更多有用的信息。 +GNOME 3.38 [发布说明][3]中列出了这次更新中的一些重大的新功能。其中,新用户的欢迎页面有了重大改版,现在更加容易使用,如果你是新用户的话,它提供了更多有用的信息。 ![The new "Welcome GNOME"][4] -([GNOME][5], [CC BY-SA 4.0][6]) - -我还喜欢在 GNOME 应用概览中拖动来重新排列应用图标的功能。这让我在 GNOME 下组织我一直使用的应用变得轻而易举。你甚至可以将图标拖放在一起,并自动将它们放入文件夹。 +我还喜欢在 GNOME 应用概览中拖动来重新排列应用图标的功能。这让我在 GNOME 下组织我一直使用的应用变得轻而易举。你甚至可以将图标拖放到一起,并自动将它们放入一个文件夹。 ![GNOME 3.38 Application Overview][7] -([GNOME][5], [CC BY-SA 4.0][6]) - -我的家人在不同的时区,更新后的 GNOME 时钟使得添加新的世界时钟变得更加容易,所以当我给家人打电话时,我不必弄清楚现在是什么时间。他们是提前一个小时还是晚了一个小时?我只需查看 GNOME 时钟,就能一目了然地看到每个人的当地时间。另外,虽然我并不经常使用闹钟功能,但我喜欢我可以自己设置铃声持续时间和每个闹钟的默认”打盹“时间。 +我的家人在不同的时区,更新后的 GNOME 时钟使得添加新的世界时钟变得更加容易,所以当我给家人打电话时,我不必弄清楚现在是什么时间,他们是早一个小时还是晚一个小时?我只需查看 GNOME 时钟,就能一目了然地看到每个人的当地时间。另外,虽然我并不经常使用闹钟功能,但我喜欢我可以自己设置铃声持续时间和每个闹钟的默认“打盹”时间。 ![Adding a new world clock in GNOME Clocks][8] -([GNOME][5], [CC BY-SA 4.0][6]) - -除了所有的功能更新之外,GNOME 3.38 中最大的改进是性能。正如 GNOME 开发者 Emmanuele Bassi [今年早些时候的解释][9]:“GNOME 中的每个人都为使速度更快而做了很多工作,即使是在树莓派等更有限的系统上运行的人。为了让 GNOME 表现得更好,大家做了很多工作。因为人们真的很关心它”。而这一点在新版本中体现得淋漓尽致!GNOME 桌面感觉反应更灵敏。 +除了所有这些功能更新之外,GNOME 3.38 中最大的改进是性能。正如 GNOME 开发者 Emmanuele Bassi [今年早些时候的解释][9]:“GNOME 中的每个人都为使速度更快而做了很多工作,即使是在树莓派等这样受限的系统上运行的人也是如此。为了让 GNOME 表现得更好,大家做了很多工作。因为人们真的很关心它”。而这一点在新版本中体现得淋漓尽致!GNOME 桌面感觉反应更灵敏。 ![Applications running on GNOME 3.38][10] -([GNOME][5], [CC BY-SA 4.0][6]) - -作为我的咨询和培训业务的一部分,我经常在几个开放的应用之间切换,包括 LibreOffice、GIMP、Inkscape、一个网络浏览器等。在 GNOME 3.38 中,启动一个新的应用或在开放应用之间切换感觉更快。 +作为我的咨询和培训业务的一部分,我经常在几个打开的应用之间切换,包括 LibreOffice、GIMP、Inkscape、Web 浏览器等。在 GNOME 3.38 中,启动一个新的应用或在打开的应用之间切换感觉更快。 ### 除了一件事 @@ -48,14 +42,10 @@ GNOME 3.38 [发布说明][3]中列出了这次更新中的一些重大的新功 ![GNOME Screenshot tool][11] -(Jim Hall, [CC BY-SA 4.0][6]) - 当我浏览用户界面或电脑屏幕时,我自然会像阅读书籍或杂志那样浏览:从左到右,从上到下。当我使用新的屏幕截图工具进行屏幕截图时,我从左上角开始,然后进行选择。大多数时候,我只需要改变选区的捕捉区域,所以我点击那个按钮,然后寻找截图的按钮。但我总是要花点时间才能找到左上角的**截图**按钮。它并不在窗口的底部,也不是我希望找到它的地方。 ![GNOME Screenshot tool][12] -(Jim Hall, [CC BY-SA 4.0][6]) - 到目前为止,这似乎是我在 GNOME 3.38 中唯一的烦恼。总的来说,我对新的 GNOME 感到非常兴奋。我希望你也是! 要了解更多关于 GNOME 3.38 的信息,请访问 [GNOME 网站][13]或阅读 [GNOME 3.38 公告][5]。 @@ -67,7 +57,7 @@ via: https://opensource.com/article/20/11/new-gnome 作者:[Jim Hall][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From da1eab251784057110eff4180d4d0bd602dbc2e9 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Wed, 18 Nov 2020 23:00:10 +0800 Subject: [PATCH 017/139] PUB @geekpi https://linux.cn/article-12839-1.html --- .../20201110 What I love about the newest GNOME desktop.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename {translated/tech => published}/20201110 What I love about the newest GNOME desktop.md (98%) diff --git a/translated/tech/20201110 What I love about the newest GNOME desktop.md b/published/20201110 What I love about the newest GNOME desktop.md similarity index 98% rename from translated/tech/20201110 What I love about the newest GNOME desktop.md rename to published/20201110 What I love about the newest GNOME desktop.md index 9169285098..0246663267 100644 --- a/translated/tech/20201110 What I love about the newest GNOME desktop.md +++ b/published/20201110 What I love about the newest GNOME desktop.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) [#]: reviewer: (wxy) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12839-1.html) [#]: subject: (What I love about the newest GNOME desktop) [#]: via: (https://opensource.com/article/20/11/new-gnome) [#]: author: (Jim Hall https://opensource.com/users/jim-hall) From 1a57b376cde7b779708a7e00f8094a5414e077e6 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Thu, 19 Nov 2020 03:50:18 +0800 Subject: [PATCH 018/139] =?UTF-8?q?Revert=20"Revert=20"=E8=B6=85=E6=9C=9F?= =?UTF-8?q?=E5=9B=9E=E6=94=B6:=20sources/talk/20191009=20Why=20to=20choose?= =?UTF-8?q?=20Rust=20as=20your=20next=20programming=20language.md""?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 39c610369b794f68ed736c2276384c579ad324a2. --- ...1009 Why to choose Rust as your next programming language.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/talk/20191009 Why to choose Rust as your next programming language.md b/sources/talk/20191009 Why to choose Rust as your next programming language.md index 871b31abc6..d8cad5c342 100644 --- a/sources/talk/20191009 Why to choose Rust as your next programming language.md +++ b/sources/talk/20191009 Why to choose Rust as your next programming language.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: (MATRIXKOO) +[#]: translator: ( ) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) From de4c0371aacdf0e1a888160139818387f21b7083 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Thu, 19 Nov 2020 05:02:40 +0800 Subject: [PATCH 019/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201118=20?= =?UTF-8?q?Cloud=20control=20vs=20local=20control:=20What=20to=20choose=20?= =?UTF-8?q?for=20your=20home=20automation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201118 Cloud control vs local control- What to choose for your home automation.md --- ...What to choose for your home automation.md | 134 ++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 sources/tech/20201118 Cloud control vs local control- What to choose for your home automation.md diff --git a/sources/tech/20201118 Cloud control vs local control- What to choose for your home automation.md b/sources/tech/20201118 Cloud control vs local control- What to choose for your home automation.md new file mode 100644 index 0000000000..b1d86bd080 --- /dev/null +++ b/sources/tech/20201118 Cloud control vs local control- What to choose for your home automation.md @@ -0,0 +1,134 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Cloud control vs local control: What to choose for your home automation) +[#]: via: (https://opensource.com/article/20/11/cloud-vs-local-home-automation) +[#]: author: (Steve Ovens https://opensource.com/users/stratusss) + +Cloud control vs local control: What to choose for your home automation +====== +Cloud may be more convenient, but local control gives you more privacy +and other options in your Home Assistant ecosystem. +![clouds in windows][1] + +There are a lot of factors to consider when investing in a home automation ecosystem. In my first article in this series, I explained [why I picked Home Assistant][2], and in this article, I'll explain some of the foundational issues and technologies in home automation, which may influence how you approach and configure your Internet of Things (IoT) devices. + +### Cloud connectivity + +Most devices you can buy today are tied to some type of cloud service. While the cloud brings a certain level of convenience, it also opens a host of problems. For starters, there are privacy issues related to a company having access to your personal habits—when you are home, what shows you watch, what time you go to bed, etc. Although most people are not as concerned about these issues as I am, privacy should still be a consideration, even if it is a small one. + +Cloud access also creates issues around being reliant on something outside your control. In 2019, Sonos came under fire for [remotely bricking][3] older smart speakers. Speakers usually continue to work for years after their warranty ends; in fact, they usually function until they physically break. There's also the case of Automatic, which produced a cloud-based car tracker. When it announced in May 2020 that it would be [shutting down][4] its services, it advised customers to "please discard your adapter by following standard electronic recycling procedures." + +Being dependent on a third-party provider for critical functionality can come back to bite you. [IFTTT][5], a popular service for programming events based on external conditions, recently altered its free plan's [terms and conditions][6] to severely limit the number of events you can create—from an unlimited number to three. This is even though IFTTT charges device manufacturers for certification with its system, which allows products like [Meross smart bulbs][7] to proudly display their compatibility with IFTTT. + +![Meross screenshot from Amazon][8] + +(Amazon screenshot by Steve Ovens, [CC BY-SA 4.0][9]) + +Some of these decisions are purely financial, but there are more than a few anecdotal cases where a company blocks a person's access to a device they purchased simply because they [did not like what the user said][10] about them. How crazy is that? + +Another consideration with cloud connectivity is a device's responsivity if its signals must travel from your home to a cloud server (which may be halfway around the world) and then back to the device. This can lead to a two-second (or more) delay on any action. For some people, this is not a deal-breaker. For others, that delay is unbearable. + +Finally, what happens if there is an internet outage? While most modern home internet connections are quite reliable, they do happen. [Some large][11], well-known cloud [service providers][12] have experienced outages this year. Are you OK trading convenience for possibly having your automations break and losing control of your smart devices for periods of time? + +### Local control + +There are several ways you can regain control over your smart devices. Commercially, you could try something like [Hubitat][13], which is a proprietary platform that emphasizes local control. I have no experience with these devices, as I don't like to rely on an intermediary. + +In my home, I standardized on WiFi (although I may branch out to [Zigbee][14] in the future) and [Home Assistant][15]. Using WiFi means I need to buy or make my devices based on their compatibility with alternative open source firmware, such as [Tasmota][16] or [ESPHome][17]. I admit that neither of these options is "plug-and-play friendly" unless you buy devices from sources like [Shelly][18], which is very friendly to the community, or [CloudFree][19], which has Tasmota installed by default. + +(As a small aside, I have both flashed my own devices and purchased them from CloudFree. There are some savings with the DIY approach, but I buy pre-flashed devices for my father's house because this eliminates a lot of hassle.) + +I won't go into more detail about alternative firmware, how to flash it, and so on. I simply want to introduce you to the idea that there are options for local control. + +### Achieving local control with MQTT + +A local control device probably uses either a direct [API][20] call, where Home Assistant talks directly to the device, or Message Queuing Telemetry Transport ([MQTT][21]). + +MQTT is one of the most widely used protocols for local IoT communication. I'll share some of the basics, but the Hook Up has an [in-depth video][22] you can watch if you want to learn more, and HiveMQ has an [entire series][23] on MQTT essentials. + +MQTT uses three components for communication. The first, the **sender**, is the component that triggers the action. The second, the **broker**, is kind of like a bulletin board where messages are posted. The final component is the **device** that will perform the action. This process is called the _publish-subscribe_ model. + +Say you have a button on the wall that you want to use to turn on the projector, lower the blinds, and turn on a fan. The button (sender) posts the _message_ **ON** to a specific section of the broker, called a _topic_. The topic might be something like `/livingroom/POWER`. The fan, the projector, and the blinds _subscribe_ to this topic. When the message **ON** is posted to the topic, all of the devices activate their respective functions, turning on the projector, lowering the blinds, and starting the fan. + +Unlike a message board, messages have different Quality of Service (QoS) states. The HiveMQ website has a good explanation of the [three QoS levels][24]. In short: + + * **QoS 0:** The message is sent to the broker in a fire-and-forget way. No attempt is made to verify that the broker received the message. + + + +![MQTTT QoS 0][25] + +(© 2015 [HiveMQ][24], reused with permission) + + * **QoS 1**: The message is posted, and the broker replies once the message is received. Multiple messages can be sent before the broker replies. For example, if you are trying to raise the projector's brightness, multiple brightness bars may be inadvertantly adjusted before the broker tells the sender to stop publishing messages. + + + +![MQTTT QoS 1][26] + +(© 2015 [HiveMQ][24], reused with permission) + + * **QoS 2:** This is the slowest but safest level. It guarantees that the message is received only once. Similar to TCP, if a message is lost, the sender will resend the message. + + + +![MQTTT QoS 2][27] + +(© 2015 [HiveMQ][24], reused with permission) + +In addition, MQTT has a **retain** flag that can be enabled on the messages, but it is not set by default. Going back to the bulletin board analogy, it's like if someone posts a message to a bulletin board, but another person walks up to the board, takes the message down, reads it, and throws it away. If a third person looks at the bulletin board five minutes later, they would have no knowledge of the message. However, if the **retain** flag is set to true, it's like leaving the message pinned on the board until a new message is received. This means that no matter when people come to read messages, they will all know the latest message. + +In home automation terms, whether or not the **retain** flag is set depends completely on the use case. + +In this series, I will use Home Assistant's [Mosquitto MQTT broker][28] add-on. Most of my devices use MQTT; however, I do have a couple of non-critical Tuya devices that require a cloud account. I may replace them with locally controllable ones in the future. + +### Wrapping up + +Home Assistant is a large, wonderful piece of software. It is complex in some areas, and it will help you to be familiar with these fundamental technologies when you need to troubleshoot and coordinate your setup. + +In the next article, I will talk about the "big three" wireless protocols that you are likely to encounter in smart devices: Zigbee, Z-Wave, and WiFi. Don't worry—I'm almost done with the underlying theories, and soon I'll get on with installing Home Assistant. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/11/cloud-vs-local-home-automation + +作者:[Steve Ovens][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/stratusss +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cloud-windows-building-containers.png?itok=0XvZLZ8k (clouds in windows) +[2]: https://opensource.com/article/20/11/home-assistant +[3]: https://www.bbc.com/news/technology-51768574 +[4]: https://www.cnet.com/roadshow/news/automatic-connected-car-service-dead-may-coronavirus/ +[5]: https://ifttt.com/ +[6]: https://ifttt.com/plans +[7]: https://www.amazon.ca/meross-Dimmable-Equivalent-Compatible-Required/dp/B07WN2J3C7 +[8]: https://opensource.com/sites/default/files/uploads/ifttt_add.png (Meross screenshot from Amazon) +[9]: https://creativecommons.org/licenses/by-sa/4.0/ +[10]: https://www.techrepublic.com/article/iot-company-bricks-customers-device-after-negative-review/ +[11]: https://www.theverge.com/2020/9/28/21492688/microsoft-outlook-office-teams-azure-outage-down +[12]: https://www.cnn.com/2020/08/30/tech/internet-outage-cloudflare/index.html +[13]: https://hubitat.com/ +[14]: https://zigbeealliance.org/ +[15]: https://www.home-assistant.io/ +[16]: https://tasmota.github.io/docs/ +[17]: https://esphome.io/ +[18]: https://shelly.cloud/ +[19]: https://cloudfree.shop/ +[20]: https://en.wikipedia.org/wiki/API +[21]: https://en.wikipedia.org/wiki/MQTT +[22]: https://www.youtube.com/watch?v=NjKK5ab0-Kk +[23]: https://www.hivemq.com/tags/mqtt-essentials/ +[24]: https://www.hivemq.com/blog/mqtt-essentials-part-6-mqtt-quality-of-service-levels/ +[25]: https://opensource.com/sites/default/files/uploads/ha-config8-qos0.png (MQTTT QoS 0) +[26]: https://opensource.com/sites/default/files/uploads/ha-config8-qos1.png (MQTTT QoS 1) +[27]: https://opensource.com/sites/default/files/uploads/ha-config9-qos2.png (MQTTT QoS 2) +[28]: https://mosquitto.org/ From ec534cdec42ca28fa6a68659f7b839b8515f8806 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Thu, 19 Nov 2020 05:02:53 +0800 Subject: [PATCH 020/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201118=20?= =?UTF-8?q?Secure=20your=20containers=20with=20SELinux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201118 Secure your containers with SELinux.md --- ...118 Secure your containers with SELinux.md | 275 ++++++++++++++++++ 1 file changed, 275 insertions(+) create mode 100644 sources/tech/20201118 Secure your containers with SELinux.md diff --git a/sources/tech/20201118 Secure your containers with SELinux.md b/sources/tech/20201118 Secure your containers with SELinux.md new file mode 100644 index 0000000000..1f63e033cc --- /dev/null +++ b/sources/tech/20201118 Secure your containers with SELinux.md @@ -0,0 +1,275 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Secure your containers with SELinux) +[#]: via: (https://opensource.com/article/20/11/selinux-containers) +[#]: author: (Mike Calizo https://opensource.com/users/mcalizo) + +Secure your containers with SELinux +====== +Hack your system to understand why it's important to configure SELinux +to be your first line of container defense. +![Three closed doors][1] + +When things aren't working correctly in your Linux environment, the easiest thing to do is disable Security-Enhanced Linux ([SELinux][2]). Things suddenly begin to work, and you forget about it—but this is a common pitfall that means you've lost a very powerful security tool. + +Threats are rising alongside the rise of containers, microservices, and distributed architecture. This is due to an old, well-known issue: velocity. The advantage of containers is that they enable you to move fast, do more, and change quickly. This means container adoption has gone off the roof, but the speed it affords also means you will encounter more issues and vulnerabilities. This happens naturally when you're doing more things faster and quicker. + +### How to mitigate threats + +As Sun Tzu said, "The wise warrior avoids the battle." This quote really resonates when it comes to containers' basic defense. To avoid problems (battles), make sure that your container host is secure and that you can use SELinux as your first line of defense. + +SELinux is an open source project released in 2000 and integrated into the Linux kernel in 2003. According to [Red Hat's explainer][3], "SELinux is a security architecture for [Linux systems][4] that allows administrators to have more control over who can access the system. It was originally developed by the United States National Security Agency (NSA) as a series of patches to the [Linux kernel][5] using Linux Security Modules (LSM)." + +### Get started + +When you think about containers, the first thing that probably comes into mind is [Docker][6]. Docker started a container adoption revolution after it emerged in 2013. It is one of the main reasons that containers exploded in popularity, but as mentioned above, the high level of adoption increased users' vulnerability to security risks. + +Before you can secure your Docker containers with SELinux, you need to set some things up. + +#### Prerequisites: + + * CentOS 8/RHEL 8 installed and configured + * Docker CE installed and configured + * Two accounts created: root and non-root (`mcalizo` in the examples below) + + + +If you need to set up Docker on your RHEL 8/CentOS 8 server, you can follow these [instructions][7]. If you're running RHEL 8, you need to remove the pre-installed Podman and runc packages before beginning. + +First, make sure SELinux is enabled: + + +``` +[mcalizo@Rhel82 ~]$ sestatus +SELinux status:                 enabled +SELinuxfs mount:                /sys/fs/selinux +SELinux root directory:         /etc/selinux +Loaded policy name:             targeted +Current mode:                   enforcing +Mode from config file:          enforcing +Policy MLS status:              enabled +Policy deny_unknown status:     allowed +Memory protection checking:     actual (secure) +Max kernel policy version:      31 +[mcalizo@Rhel82 ~]$ +``` + +Then, verify your OS version and that Docker is running. Log in as root and run: + + +``` +[root@rhel82 ~]# cat /etc/redhat-release +Red Hat Enterprise Linux release 8.2 (Ootpa) +[root@rhel82 ~]# + +[root@rhel82 ~]# systemctl status docker +● docker.service - Docker Application Container Engine +   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) +   Active: active (running) since Wed 2020-10-28 19:10:14 EDT; 15s ago +     Docs: + Main PID: 30768 (dockerd) +    Tasks: 8 +   Memory: 39.0M +   CGroup: /system.slice/docker.service +           └─30768 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock + +Oct 28 19:10:13 rhel82.home.labs.com dockerd[30768]: time="2020-10-28T19:10:13.889602941-04:00" level=error msg="> +Oct 28 19:10:13 rhel82.home.labs.com dockerd[30768]: time="2020-10-28T19:10:13.903413613-04:00" level=warning msg> +Oct 28 19:10:13 rhel82.home.labs.com dockerd[30768]: time="2020-10-28T19:10:13.903427451-04:00" level=warning msg> +Oct 28 19:10:13 rhel82.home.labs.com dockerd[30768]: time="2020-10-28T19:10:13.903538271-04:00" level=info msg="L> +Oct 28 19:10:14 rhel82.home.labs.com dockerd[30768]: time="2020-10-28T19:10:14.132060506-04:00" level=info msg="D> +Oct 28 19:10:14 rhel82.home.labs.com dockerd[30768]: time="2020-10-28T19:10:14.308943088-04:00" level=info msg="L> +Oct 28 19:10:14 rhel82.home.labs.com dockerd[30768]: time="2020-10-28T19:10:14.319438549-04:00" level=info msg="D> +Oct 28 19:10:14 rhel82.home.labs.com dockerd[30768]: time="2020-10-28T19:10:14.319570298-04:00" level=info msg="D> +Oct 28 19:10:14 rhel82.home.labs.com dockerd[30768]: time="2020-10-28T19:10:14.333419209-04:00" level=info msg="A> +Oct 28 19:10:14 rhel82.home.labs.com systemd[1]: Started Docker Application Container Engine +``` + +Check your Docker version: + + +``` +[root@rhel82 ~]# docker --version +Docker version 19.03.13, build 4484c46d9d +``` + +### Hack your host + +One of the best ways to understand a problem is to experience it. So, I'll show you how easy it is to inject malicious code into a Docker host if your security is not set up properly. + +To be able to do something bad on the Docker host, the malicious non-root user (`mcalizo` in this tutorial) must be part of the group that can instantiate Docker containers. + +First, confirm what group the `mcalizo` user belongs to: + + +``` +[root@Rhel82 ~]# groups mcalizo +mcalizo : mcalizo +``` + +The output shows that `mcalizo` belongs only to its own group. This means `mcalizo` can't instantiate Docker containers and will get this error if it tries: + + +``` +[mcalizo@Rhel82 ~]$ docker run -it --rm centos:latest /bin/sh +docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/create: dial unix /var/run/docker.sock: connect: permission denied. +See 'docker run --help'. +``` + +To allow `mcalizo` to instantiate the container, add the user to the `docker` group: + + +``` +[root@Rhel82 ~]# usermod -G docker -a mcalizo +[root@Rhel82 ~]# groups mcalizo +mcalizo : mcalizo docker +``` + +Next, deploy a `fedora:latest` container and log into the instantiated container to explore it: + + +``` +[mcalizo@Rhel82 ~]$ docker run -it --rm fedora:latest /bin/sh +Unable to find image 'fedora:latest' locally +latest: Pulling from library/fedora +ee7e89337106: Pull complete +Digest: sha256:b9ec86d36fca7b1d3de39cd7c258e8d90c377d312c21a7748071ce49069b8db4 +Status: Downloaded newer image for fedora:latest +sh-5.0# cat /etc/redhat-release +Fedora release 33 (Thirty Three) +``` + +While you're logged into the newly created container, you can see you are automatically logged in as root: + + +``` +sh-5.0# whoami +root +sh-5.0# +``` + +As `root` user, you can do anything in this container, which means you can exploit the container host and do a lot of damage. Because you can instantiate a container, you can do things to the host even if you are not part of the host's sudoers account. + +Exit the container you just created, and create a new container to demonstrate the exploit: + + +``` +[mcalizo@Rhel82 ~]$ docker run -it --rm -v /:/exploit fedora:latest /bin/bash +[root@131043f2e306 /]# +``` + +The [-v option][8] mounts the Docker host's `/` directory to the container under the `/exploit` directory: + + +``` +[root@131043f2e306 /]#ls exploit/ +bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var +``` + +Because it is mounted, you can do _anything_ on the Docker host. For example, you can delete files, edit specific configurations to harm the system, or even install a Trojan horse application or other malware to steal important information. + +### Why does this happen? + +You may be wondering why this is possible since SELinux is in enforcing mode. Dig deeper into SELinux to see where things went wrong. + +Verify that SELinux has a [Docker context][9]: + + +``` +[mcalizo@Rhel82 ~]$ ps -eZ | grep docker +system_u:system_r:container_runtime_t:s0 30768 ? 00:00:04 dockerd +[mcalizo@Rhel82 ~]$ +``` + +As expected, it does. This means SELinux manages the Docker daemon. Inspect the Docker daemon to see if SELinux is enabled by default: + + +``` +[mcalizo@Rhel82 ~]$ docker info | grep Security -A3 + Security Options: +  seccomp +   Profile: default + Kernel Version: 4.18.0-193.el8.x86_64 +``` + +SELinux is _not_ enabled by default. This is the problem! To fix it, enable SELinux to control and manage Docker by updating or creating the file `/etc/docker/daemon.json` as [documented here][10] (you must have root access to do this): + + +``` +[root@Rhel82 ~]# cat /etc/docker/daemon.json +{ +  "selinux-enabled": true +} +[root@Rhel82 ~]# +[root@Rhel82 ~]# systemctl restart docker +``` + +After creating or updating the file and restarting Docker, you should see that SELinux support is enabled in the Docker daemon: + + +``` +[root@Rhel82 ~]# systemctl restart docker +[mcalizo@Rhel82 root]$ docker info | grep Security -A3 + Security Options: +  seccomp +   Profile: default +  selinux +[mcalizo@Rhel82 root]$ +``` + +While it's still possible to mount a specific filesystem in your Docker host on your Docker container, updating or accessing the file is no longer allowed: + + +``` +[mcalizo@Rhel82 root]$ docker run -it --rm -v /:/exploit fedora:latest /bin/bash +[root@ecb5836da1f6 /]# touch /exploit/etc/shadow.sh +touch: cannot touch '/exploit/etc/shadow.sh': Permission denied +[root@ecb5836da1f6 /]# +``` + +### Learn more + +Your first line of defense in the container world depends on how strongly you set up your container hosts' operating system. There are numerous ways to implement Linux security, including options available on the market to augment your security posture. + +SELinux is an additional layer of security that is built into [Linux distributions][11] by default. To take advantage of it and protect your system against compromise, make sure SELinux remains on. + +If you want to learn more, see: + + * [How to install Docker CE on CentOS 8 / RH][7] + * [Docker security cheat sheet][12] + * [dockerd documentation][10] + * [Use volumes documentation][8] + * [What is SELinux?][3] + + + +Few things in the Linux world evoke a strong reaction like SELinux , the security enhancement for... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/11/selinux-containers + +作者:[Mike Calizo][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/mcalizo +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDU_UnspokenBlockers_1110_A.png?itok=x8A9mqVA (Three closed doors) +[2]: https://en.wikipedia.org/wiki/Security-Enhanced_Linux +[3]: https://www.redhat.com/en/topics/linux/what-is-selinux +[4]: https://www.redhat.com/en/topics/linux/what-is-linux +[5]: https://www.redhat.com/en/topics/linux/what-is-the-linux-kernel +[6]: https://opensource.com/resources/what-docker +[7]: https://www.linuxtechi.com/install-docker-ce-centos-8-rhel-8/ +[8]: https://docs.docker.com/storage/volumes/ +[9]: https://docs.docker.com/engine/reference/commandline/context/ +[10]: https://docs.docker.com/engine/reference/commandline/dockerd/ +[11]: https://www.redhat.com/en/topics/linux/whats-the-best-linux-distro-for-you +[12]: https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html From ee8f5512e35de36788c1fa0087aea2b5045db1a6 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Thu, 19 Nov 2020 05:03:08 +0800 Subject: [PATCH 021/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201118=20?= =?UTF-8?q?Apply=20the=20Scientific=20Method=20to=20agile=20development?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201118 Apply the Scientific Method to agile development.md --- ... Scientific Method to agile development.md | 170 ++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 sources/tech/20201118 Apply the Scientific Method to agile development.md diff --git a/sources/tech/20201118 Apply the Scientific Method to agile development.md b/sources/tech/20201118 Apply the Scientific Method to agile development.md new file mode 100644 index 0000000000..983e15a972 --- /dev/null +++ b/sources/tech/20201118 Apply the Scientific Method to agile development.md @@ -0,0 +1,170 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Apply the Scientific Method to agile development) +[#]: via: (https://opensource.com/article/20/11/hypothesis-driven-development) +[#]: author: (Alex Bunardzic https://opensource.com/users/alex-bunardzic) + +Apply the Scientific Method to agile development +====== +Hypothesis-driven development allows constant analysis of new +information to implement new insights (and deliver new customer value) +on an ongoing basis. +![Science lab with beakers][1] + +> "The only way it’s all going to go according to plan is if you don’t learn anything." —Kent Beck + +Experimentation is the foundation of the scientific method, which is a systematic means of exploring the world around us. But experimentation is not only reserved for the field of scientific research. It has a central place in the world of business too. + +Most of us are by now familiar with the business methodology called [Minimum Viable Product (MVP)][2]. This Minimum Viable Product is basically just an experiment. By building and launching MVPs, business operations are engaging in a systematic means of exploring the markets. + +If we look at market leaders today, we learn that they’re not doing projects anymore; the only thing they’re doing is experiments. Customer discovery and lean strategies are only used to test assumptions about the markets. Such an approach is equivalent to Test-Driven Development (TDD), which is the process we are intimately familiar with. In TDD, we write the hypothesis (the test) first. We then use that test to guide our implementation. Ultimately, product or service development is no different than TDD—we first write a hypothesis, then that hypothesis guides our implementation, which serves as measurable validation of the hypothesis. + +### Information discovery + +Back in the pre-agile days, requirements gathering was an important activity that used to always kick off the project. A bunch of subject matter experts (SMEs) would get assigned to the project and be tasked with gathering the requirements. After a prolonged period of upfront information discovery, the gathered requirements got reviewed and, if agreed upon, signed off and frozen. No more changes allowed! + +Back then, it seemed a perfectly reasonable thing to do. The fly in the ointment always showed up once the build phase commenced. Sooner or later, as the project progresses, new information comes to light. Suddenly, what we initially viewed as incontrovertible truth gets challenged by the newly acquired information and evidence. + +But the clincher was in the gated phases. Remember, once requirements get signed off, they get frozen—no more changes, no scope creep allowed—which means newly obtained market insights get willfully ignored. + +Well, that’s kind of foolish neglect. The newly emerging evidence could be of critical importance to the health of the business operation. Can we afford to ignore it? Absolutely not! We have no choice but to embrace the change. + +After a number of prominent fiascos in the industry, many software development projects switched to the agile approach. With agile, information discovery is partial. With agile, we never claim that we have gathered the requirements and are now ready to implement them. We discover information and implement it on an ongoing basis. We do it in tiny steps, keeping our efforts interruptible and steerable at all times. + +### How to leverage the scientific method + +The scientific method is empirical and consists of the following steps: + +Step 1: Make and record careful observations. + +Step 2: Perform orientation with regard to observed evidence. + +Step 3: Formulate a hypothesis, including measurable indicators for hypothesis evaluation. + +Step 4: Design an experiment that will enable testing of the hypothesis. + +Step 5: Conduct the experiment (i.e., release the partial implementation). + +Step 6: Collect the telemetry that results from running the experiment. + +Step 7: Evaluate the results of the experiment. + +Step 8: Accept or reject the hypothesis. + +Step 9: Return to Step 1. + +### How to formulate a hypothesis + +When switching from project to experiments, the traditional user story framework (As a__I want to__so that__) has proven insufficient. The traditional user story format does not expose the signals needed in order to evaluate the outcomes. Instead, the old school user story format is focused on outputs. + +The problem with doing an experiment without first formulating a hypothesis is that there is a danger of introducing a bias when interpreting the results of an experiment. Defining the measurable signals that will enable us to corroborate our hypothesis must be done before we conduct the experiment. That way, we can remain completely impartial when interpreting the results of the experiment. We cannot be swayed by wishful thinking. + +The best way to proceed with formulating a hypothesis is to use the following format: + +We believe [this capability] will result in [this outcome]. We will have the confidence to proceed when [we see a measurable signal]. + +### Working software is not a measure of progress + +Output-based metrics and concepts (definition of "done," acceptance criteria, burndown charts, and velocity) are good for detecting working software but fall miserably when it comes to detecting if working software adds value. + +"Done" only matters if it adds value. Working software that doesn’t add value cannot be declared "done." + +### The forgotten column + +Technology-centric projects break activities down into four columns: + + 1. Backlog of ideas + 2. Analysis + 3. In progress + 4. Shipped + + + +The above structure is based on the strong belief that all software that works is valuable. That focus must now shift toward continuously delivering real value, something that serves customers. Agilists value outcomes (value to the customers) over features. + +The new breakdown for hypothesis-driven development looks something like this: + +Ideas Backlog + +| + +Analysis + +| + +In Progress + +| + +Shipped + +| + +Achieved Desired Outcome + +---|---|---|---|--- + +Hypothesis 11 + +Hypothesis 12 + +Hypothesis 13 + +Hypothesis 14 + +Hypothesis 15 + +Hypothesis 16 + +Hypothesis 17 + +Hypothesis 18 + +Hypothesis 19 + +| + +Hypothesis 20 + +Hypothesis 21 + +| + +Hypothesis 26 + +| + +Hypothesis 2 + +Hypothesis 5 + +Hypothesis 9 + +Hypothesis 10 + +| + +Hypothesis 1 + +Hypothesis 5 + +All eyes must remain on the Achieved Desired Outcome column. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/11/hypothesis-driven-development + +作者:[Alex Bunardzic][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/alex-bunardzic +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/science_experiment_beaker_lab.png?itok=plKWRhlU (Science lab with beakers) +[2]: https://en.wikipedia.org/wiki/Minimum_viable_product#:~:text=A%20minimum%20viable%20product%20%28MVP,feedback%20for%20future%20product%20development.&text=The%20concept%20can%20be%20used,developments%20of%20an%20existing%20product. From cd895c2fc9b6a020904ab5ee471f3095134c30d9 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 19 Nov 2020 08:50:55 +0800 Subject: [PATCH 022/139] translated --- ...cher on Linux for Making Live Linux USB.md | 136 ----------------- ...cher on Linux for Making Live Linux USB.md | 137 ++++++++++++++++++ 2 files changed, 137 insertions(+), 136 deletions(-) delete mode 100644 sources/tech/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md create mode 100644 translated/tech/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md diff --git a/sources/tech/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md b/sources/tech/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md deleted file mode 100644 index cb7c463b33..0000000000 --- a/sources/tech/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md +++ /dev/null @@ -1,136 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to Install and Use Etcher on Linux for Making Live Linux USB) -[#]: via: (https://itsfoss.com/install-etcher-linux/) -[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) - -How to Install and Use Etcher on Linux for Making Live Linux USB -====== - -_**Etcher is a popular USB flasher app for creating bootable Linux USB drives. Let me show you how to install it and how to use it for making a live Linux disk.**_ - -### Etcher: An open source tool to flash Linux ISO on SD Cards & USB drives - -Etcher is an open-source project by [Balena][1] to help flash SD cards for Raspberry Pi. In fact, we used it in our tutorial on [how to install Raspbian OS on a SD Card][2]. - -Not just limited to SD Cards, you can also use Etcher to [make a bootable USB drive][3] just like we created a [live USB of Manjaro in Linux][4] with the help of it. - -Ever since its first release, Etcher caught the attention for its neat interface and simplicity of use. - -![][5] - -In this article, I will be focusing on the steps to help you install Etcher on Linux. And then, I’ll also show how to use it. Before I do that, let me give you an overview of the features it offers: - -### Features of Etcher - - * Validate drive before flashing - * Beautiful user interface - * Auto-detects USB drive/SD card to prevent wiping the HDD on your computer - * Cross-platform support (Windows, macOS, and Linux) - * Fast flashing - * Simple three-step process - - - -On paper, you get everything one would need to flash OS images on an SD card and a USB drive. It is also exciting to know that they plan to add the support simultaneous writing to multiple devices as per their [roadmap][6]. - -### Installing Etcher on Linux - -To get started, you have to grab the AppImage file that it offers (suitable for any Linux distribution) from its official website. - -You just need to head on to its [homepage][7] and download the one for your system (32-bit/64-bit): - -![][8] - -In my case, I got the 64-bit AppImage file for Ubuntu. You can go through our guide on [using AppImage files on Linux][9], but I’ll give you a head start on what you need to do next. - -You need to give the file permissions to execute and you can do that by right-clicking on the **AppImage file -> Properties**. - -![][10] - -Next, click on “**Allow executing as a program**” under the Permissions tab as shown in the image below. - -![][11] - -Now, just double-click on the AppImage file to launch balenaEtcher! - -This should work on any Linux distribution. In either case, you can also head over to its [GitHub releases se][12][c][12][tion][12] to find RPM, DEB, and the source file if you want to build it from source or just install it using the .rpm or .deb files. - -You can also refer to our guide on [using deb file in Ubuntu][13] to install applications. - -Attention! - -It’s been noticed that when you use Etcher to create live USB of Linux distributions, it leaves the USB in an apparent unusable state where it has only a few MB of free state and cannot be formatted directly. On Linux, you can [use the Disks tool to manually delete the partitions and then format it][14]. - -### Using Etcher on Linux - -It is just a three-step process to get started using Etcher. It should be self-explanatory as per the on-screen instructions after you launch it, but just to give you a head start, here’s what you have to do: - -**Step 1:** Select the appropriate ISO image file or the URL of the file that you need to flash (as shown in the image below). - -![][15] - -**Step 2**: Next, you will have to select the target device. It automatically detects and highlights removable devices to help you prevent selecting any internal storage locations. - -![][16] - -In this case, I have a USB drive connected, and I have it selected as well (as shown in the screenshot below). - -![][17] - -**Step 3:** Now, all you have to do is — flash the image and wait for it to complete successfully. - -![][18] - -Here’s how the progress looks: - -![][19] - -And, it is done! - -![][20] - -[Download balenaEtcher][7] - -### Wrapping Up - -Etcher is a useful tool to flash OS images for both SD cards and USB drives. I tend to use it primarily to create live USB drives to test Linux distros and I’m happy with it. - -What do you prefer to use to create bootable drives? Have you tried Etcher already? Let me know your thoughts in the comments down below. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/install-etcher-linux/ - -作者:[Ankush Das][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/ankush/ -[b]: https://github.com/lujun9972 -[1]: https://www.balena.io/ -[2]: https://itsfoss.com/tutorial-how-to-install-raspberry-pi-os-raspbian-wheezy/ -[3]: https://itsfoss.com/create-bootable-ubuntu-usb-drive-mac-os/ -[4]: https://itsfoss.com/create-live-usb-manjaro-linux/ -[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/etcher-mxlinux-2.png?resize=800%2C518&ssl=1 -[6]: https://github.com/balena-io/etcher/milestones -[7]: https://www.balena.io/etcher -[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/etcher-official-site-download.png?resize=800%2C580&ssl=1 -[9]: https://itsfoss.com/use-appimage-linux/ -[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/balena-etcher-permission.jpg?resize=800%2C378&ssl=1 -[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/balena-etcher-execute.jpg?resize=800%2C445&ssl=1 -[12]: https://github.com/balena-io/etcher/releases/tag/v1.5.109 -[13]: https://itsfoss.com/install-deb-files-ubuntu/ -[14]: https://itsfoss.com/cant-format-usb-disk/ -[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/balena-etcher-select.jpg?resize=800%2C521&ssl=1 -[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/etcher-select-target.jpg?resize=800%2C509&ssl=1 -[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/etcher-target-device.jpg?resize=800%2C521&ssl=1 -[18]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/etcher-flash.jpg?resize=800%2C516&ssl=1 -[19]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/etcher-flashing.jpg?resize=800%2C510&ssl=1 -[20]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/etcher-flash-complete.jpg?resize=800%2C507&ssl=1 diff --git a/translated/tech/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md b/translated/tech/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md new file mode 100644 index 0000000000..bb8aa29cde --- /dev/null +++ b/translated/tech/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md @@ -0,0 +1,137 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Install and Use Etcher on Linux for Making Live Linux USB) +[#]: via: (https://itsfoss.com/install-etcher-linux/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +如何在 Linux 上安装和使用 Etcher 来制作 Live Linux USB +====== + +_**Etcher 是一款流行的 USB 烧录应用,可用于创建可启动的 Linux USB。让我来告诉你如何安装它,以及如何使用它来制作一个 Live Linux 盘。**_ + +### Etcher:一个用于在 SD 卡和 USB 驱动器中烧录 Linux ISO 的开源工具 + +Etcher 是一个由 [Balena][1] 开发的开源项目,来用于为树莓派烧录 SD 卡。事实上,我们在[如何在 SD 卡上安装 Raspbian OS][2] 的教程中就使用了它。 + +它不仅仅局限于 SD 卡,你还可以使用 Etcher 来[制作一个可启动的 USB 驱动器][3],就像我们在它的帮助下在 Linux 中制作了一个 [Manjaro 的 Live USB][4]。 + +自首次发布以来,Etcher 就以其整洁的界面和简单的使用方式引起了人们的注意。 + +![][5] + +在本文中,我将重点介绍帮助你在 Linux 上安装 Etcher 的步骤。然后,我还将展示如何使用它。在这之前,让我先给大家介绍一下它的功能。 + +### Etcher 的功能 + + * 在烧录前验证驱动器 + * 漂亮的用户界面 + * 自动检测 USB 驱动器/SD 卡,防止电脑上的硬盘被擦除。 + * 跨平台支持(Windows、macOS 和 Linux)。 + * 快速烧录 + * 简单的三步过程 + + + +理论上,你已经有了在 SD 卡和 USB 驱动器上烧录操作系统镜像所需的一切。同样令人激动的是,他们计划根据他们的[路线图][6],增加对多个设备的同步写入支持。 + +### 在 Linux 上安装 Etcher + +要开始使用,你需要从它的官方网站上下载它提供的 AppImage 文件(适用于任何 Linux 发行版)。 + +你只需要前往它的[主页][7],并根据你的系统(32 位/64 位)下载一个程序: + +![][8] + + +在我的例子中,我下载了 Ubuntu 的 64 位 AppImage 文件。你可以通过我们的指南来了解[在 Linux 上使用 AppImage文件][9],但我会让你先知道下一步需要做什么。 + +你需要给文件执行权限,你可以右击**AppImage 文件 -> 属性**来实现。 + +![][10] + +接下来,点击权限选项卡下的“**允许作为程序执行**”,如下图所示。 + +![][11] + +现在,只需双击 AppImage 文件即可启动 Etcher! + +这应该可以在任何 Linux 发行版上运行。在任何情况下,如果你想从源码构建或者直接使用 .rpm 或 .deb 文件安装,你也可以前往它的 [Github 发布页][12]找到 RPM、DEB 和源码。 + +你也可以参考我们的[在 Ubuntu 中使用 deb 文件][13]来安装应用。 + +注意! + +我们注意到,当你使用 Etcher 创建 Linux 发行版的 Live USB 时,它会使 USB 处于明显的不可使用状态,即它只有几 MB 的空闲空间,并且不能直接格式化。在 Linux 上,你可以[使用磁盘工具手动删除分区,然后格式化它][14]。 + +### 在 Linux 上使用 Etcher + +只需三步就可以开始使用 Etcher。在你启动它之后,根据屏幕上的提示应该是清晰的,但为了给你一个好的开始,以下是你要做的事情: + +**步骤 1:**选择合适的 ISO 镜像文件或你需要烧录的文件的 URL(如下图所示)。 + +![][15] + +**步骤 2:**接下来,你需要选择目标设备。它会自动检测并高亮显示可移动设备,以防止你选择任何内部存储位置。 + +![][16] + +在这里,我连接了一个 USB 驱动器,我也选择了它(如下图所示)。 + +![][17] + +**步骤 3:**现在,你所有需要做的就是烧录镜像并等待它成功完成。 + +![][18] + +这是进度的样子: + +![][19] + +完成了! + +![][20] + +[Download balenaEtcher][7] + +### 总结 + +Etcher 是一个有用的工具,可以为 SD 卡和 USB 驱动器烧录操作系统镜像。我倾向于主要使用它来创建 Live USB 驱动器来测试 Linux 发行版,我对它很满意。 + +你更喜欢用什么来创建可启动驱动器?你是否已经尝试过 Etcher?请在下面的评论中告诉我你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-etcher-linux/ + +作者:[Ankush Das][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://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://www.balena.io/ +[2]: https://itsfoss.com/tutorial-how-to-install-raspberry-pi-os-raspbian-wheezy/ +[3]: https://itsfoss.com/create-bootable-ubuntu-usb-drive-mac-os/ +[4]: https://itsfoss.com/create-live-usb-manjaro-linux/ +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/etcher-mxlinux-2.png?resize=800%2C518&ssl=1 +[6]: https://github.com/balena-io/etcher/milestones +[7]: https://www.balena.io/etcher +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/etcher-official-site-download.png?resize=800%2C580&ssl=1 +[9]: https://itsfoss.com/use-appimage-linux/ +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/balena-etcher-permission.jpg?resize=800%2C378&ssl=1 +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/balena-etcher-execute.jpg?resize=800%2C445&ssl=1 +[12]: https://github.com/balena-io/etcher/releases/tag/v1.5.109 +[13]: https://itsfoss.com/install-deb-files-ubuntu/ +[14]: https://itsfoss.com/cant-format-usb-disk/ +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/balena-etcher-select.jpg?resize=800%2C521&ssl=1 +[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/etcher-select-target.jpg?resize=800%2C509&ssl=1 +[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/etcher-target-device.jpg?resize=800%2C521&ssl=1 +[18]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/etcher-flash.jpg?resize=800%2C516&ssl=1 +[19]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/etcher-flashing.jpg?resize=800%2C510&ssl=1 +[20]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/etcher-flash-complete.jpg?resize=800%2C507&ssl=1 From c564796d66d0570e84e186abccba86e594643e78 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 19 Nov 2020 08:53:33 +0800 Subject: [PATCH 023/139] translating --- sources/tech/20201116 Podman with capabilities on Fedora.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20201116 Podman with capabilities on Fedora.md b/sources/tech/20201116 Podman with capabilities on Fedora.md index 236ea0072e..dd8ab976e8 100644 --- a/sources/tech/20201116 Podman with capabilities on Fedora.md +++ b/sources/tech/20201116 Podman with capabilities on Fedora.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (geekpi) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) From 02a6191d92d0d10a27c4f9a295812d030ebc9400 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Thu, 19 Nov 2020 23:00:04 +0800 Subject: [PATCH 024/139] PRF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @xiao-song-123 翻译的不错! --- ...steps to learn any programming language.md | 116 ++++++++---------- 1 file changed, 51 insertions(+), 65 deletions(-) diff --git a/translated/tech/20201022 5 steps to learn any programming language.md b/translated/tech/20201022 5 steps to learn any programming language.md index 8104c71dbb..695bfab59a 100644 --- a/translated/tech/20201022 5 steps to learn any programming language.md +++ b/translated/tech/20201022 5 steps to learn any programming language.md @@ -1,84 +1,78 @@ [#]: collector: "lujun9972" [#]: translator: "xiao-song-123" -[#]: reviewer: " " +[#]: reviewer: "wxy" [#]: publisher: " " [#]: url: " " [#]: subject: "5 steps to learn any programming language" [#]: via: "https://opensource.com/article/20/10/learn-any-programming-language" [#]: author: "Seth Kenlon https://opensource.com/users/seth" -学习任何编程语言的 5 个步骤 +五步学会任何编程语言 ====== -只需一点编程经验,您就可以在几天内(有时更少)学习一种新语言。 -![Learning to program][1] -有些人喜欢学习新的编程语言,也有一些人连学习一种都是可望不可即的事情。在本文中,我将向您展示如何像程序员一样思考,以便您可以自信地学习所需的任何编程语言。 +> 只需一点编程经验,你就可以在短短几天内(有时更少)学会一种新编程语言。 -事实上,一旦您学会了如何编程,您使用的语言就不再是一个障碍,而更像是一种形式。这只是教育家们倡导 [让孩子尽早学习编程][2] 的众多原因之一。不管他们的入门语言有多简单,这种编程的逻辑和儿童(或成人学习者)以后可能遇到的其他东西的逻辑有着相同之处。 +![](https://img.linux.net.cn/data/attachment/album/202011/19/225851j7miw3kd17joowa7.jpg) -只需有一点编程经验(您可以从 Opensource.com 上的任何一篇介绍性文章中获得),您就可以在几天内(有时更短)学习任何编程语言。这并不是魔法,现在您也必须要为此付出一些努力。诚然,学习一种语言每个的可用库,或者学习打包代码以及进行交付的细微差别,需要的时间远远不止几天。但是,就入门来说,比您想像中的要容易许多,剩下的则要通过不断练习来完成。 +有些人喜欢学习新的编程语言,也有一些人觉得学习一种都是可望不可及的事情。在本文中,我将向你展示如何像程序员一样思考,这样你就可以自信地学习任何一门你想要学习的编程语言。 -当有经验的程序员静下心来学习一门新的编程语言时,他们会寻找五样东西。只要您知道了这五件事,您就可以开始编码了。 +事实上,一旦你学会了如何编程,你使用的编程语言就不再是一个障碍,而更像是一种形式。实际上,这就是教育家们倡导 [让孩子尽早学习编程][2] 的众多原因之一。不管他们的入门语言有多简单,这种编程的逻辑和儿童们(或成人学习者)以后可能遇到的其他语言的逻辑有着想通之处。 -### 1\. 语法 +只需有一点编程经验(你可以从我们这里的几篇介绍性文章中获得),你就可以在短短几天内(有时更短)学习任何编程语言。这并不是魔法,你也确实要为此付出一些努力。诚然,学习一种编程语言每个的可用库,或者学习打包代码以及进行交付的细微差别,需要的时间远远不止几天。但是,就入门来说,比你想像中的要容易许多,剩下的则要通过不断练习来完成。 + +当有经验的程序员静下心来学习一门新的编程语言时,他们会寻找五样东西。只要你知道了这五件事,你就可以开始编码了。 + +### 1、语法 ![Syntax][3] -(Seth Kenlon, [CC BY-SA 4.0][4]) - 语言的语法描述了代码的结构。这包括如何逐行编写代码,以及用于构造代码语句的实际单词。 -例如,[Python][5] 因使用缩进来指示一个代码块在哪里结束以及另一代码块在哪里开始而闻名: - +例如,[Python][5] 以使用缩进来指示一个代码块在哪里结束以及另一代码块在哪里开始而闻名: ``` -while j < rows: -    while k < columns: -        tile = Tile(k * w) -        board.add(tile) -        k += 1 -    j += 1 -    k = 0 +while j < rows: + while k < columns: + tile = Tile(k * w) + board.add(tile) + k += 1 + j += 1 + k = 0 ``` -[Lua][6] 只是使用关键字 `end`: - +[Lua][6] 只是使用关键字 `end`: ``` for i,obj in ipairs(hit) do -  if obj.moving == 1 then -     obj.x,obj.y = v.mouse.getPosition() -  end + if obj.moving == 1 then + obj.x,obj.y = v.mouse.getPosition() + end end ``` -[Java][7], [C][8], C++, 和类似的编程语言使用花括号: - +[Java][7]、[C][8]、C++ 之类的编程语言使用花括号: ``` while (std::getline(e,r)) { -  wc++; -  } + wc++; + } ``` -编程语言的语法还包括包括库、设置变量和终止行等内容。通过练习,您将学会在阅读示例代码时下意识地识别语法需求(和惯例)。 +编程语言的语法还包括包括库、设置变量和终止行等内容。通过练习,你将学会在阅读示例代码时下意识地识别语法需求(和惯例)。 #### 实践 -当学习一门新的编程语言时,要努力理解它的语法。您不需要去记住它,只需要知道如果忘记了以后去哪里看。使用好的 [IDE][9] 也很有帮助,因为很多 IDE 在出现语法错误时会提醒您。 +当学习一门新的编程语言时,要努力理解它的语法。你不需要去记住它,只需要知道如果忘记了以后去哪里查找。使用好的 [IDE][9] 也很有帮助,因为很多 IDE 在出现语法错误时会提醒你。 -### 2\. 内置函数和条件 +### 2、内置函数和条件 ![built-in words][10] -(Seth Kenlon, [CC BY-SA 4.0][4]) +就像自然语言一样,编程语言可以识别的合法单词是有限的。这个词汇表可以使用其他库进行扩展,但是核心语言知道一组特定的关键字。大多数语言并没有你想的那么多关键字。即使在像 C 语言这样非常低级的语言中,也只有 32 个关键字,比如 `for`、`do`、`while`、`int`、`float`、`char`、`break` 等等。 -就像自然语言一样,编程语言可以识别的合法单词是有限的。这个词汇表可以使用其他库进行扩展,但是核心语言知道一组特定的关键字。大多数语言并没有您想的那么多关键字。即使在像 C 语言这样非常低级的语言中,也只有 32 个关键字,比如 `for`, `do`, `while`, `int`, `float`, `char`, `break` 等等。 - -了解了这些关键字,您就可以编写基本的表达式,也就是构建程序的代码块。许多内置的关键字能帮助您构建条件语句,这些条件语句影响整个程序的流程。例如,如果您想编写一个允许单击和拖动图标的程序,那么您的代码就必须检测用户的鼠标指针何时位于图标上。只有当鼠标光标位于图标外部边缘相同的坐标时,才执行导致使鼠标抓取图标的代码。这是一个经典的 if / then 语句,不同的语言可以用不同的方式表达。 - -Python 使用 `if`, `elif `和 `else` 的组合来实现条件语句,但是并不显式的关闭语句: +了解了这些关键字,你就可以编写基本的表达式,也就是构建程序的代码块。许多内置的关键字能帮助你构建条件语句,这些条件语句影响整个程序的流程。例如,如果你想编写一个允许单击和拖动图标的程序,那么你的代码就必须检测用户的鼠标指针何时位于图标上。只有当鼠标光标位于图标外部边缘相同的坐标时,才执行导致使鼠标抓取图标的代码。这是一个经典的 `if` / `then` 语句,但不同的语言可以用不同的方式表达。 +Python 使用 `if`、`elif `和 `else` 的组合来实现条件语句,但是并不显式的关闭语句: ``` if var == 1: @@ -89,8 +83,7 @@ else:     # some other action ``` -[Bash][11] 使用 `if`, `elif`, `else`, 并且使用 `fi` 来结束语句: - +[Bash][11] 使用 `if`、`elif`、`else`,并且使用 `fi` 来结束语句: ``` if [ "$var" = "foo" ]; then @@ -102,8 +95,7 @@ else fi ``` -然而 C 和 Java, 使用 `if`, `else` 和 `else if`, 用花括号把它们括起来: - +然而 C 和 Java, 使用 `if`、`else` 和 `else if`,用花括号把它们括起来: ``` if (boolean) { @@ -115,59 +107,53 @@ if (boolean) { } ``` -各种编程语言虽然在关键字的选择和语法上有细微的变化,但基本是相同的。学习如何在编程语言中定义条件语句,包括 `if/then`, `do...while` 和 `case` 语句。 +各种编程语言虽然在关键字的选择和语法上有细微的变化,但基本是相同的。学习如何在编程语言中定义条件语句,包括 `if` / `then`、`do...while` 和 `case` 语句。 #### 实践 -要去熟悉编程语言能够理解的关键字集。在实践中,您的代码将不仅仅包含一种语言的关键字。可以肯定的是,有许多库中包含一些简单的函数,它们可以帮助您完成诸如将输出打印到屏幕或显示窗口之类的操作。然而,驱动这些库的逻辑始于编程语言的内置关键字。 +要熟悉编程语言能够理解的关键字集。在实践中,你的代码将不仅仅包含编程语言的关键字,可以肯定的是,有包含很多简单函数的库来帮助你做一些事情,诸如将输出打印到屏幕或显示窗口之类。然而,驱动这些库的逻辑始于编程语言的内置关键字。 -### 3\. 数据类型 +### 3、数据类型 ![Data types][12] -(Seth Kenlon, [CC BY-SA 4.0][4]) - -代码是用来处理数据的,因此您必须学习编程语言如何识别不同类型的数据。所有编程语言都能理解整数,大多数的语言能理解小数和单个字符 (a, b, c 等等)。它们通常被表示为 `int` , `float`,`double` 和 `char`, 当然,语言的内置词汇表会告诉您如何引用这些实体。 +代码是用来处理数据的,因此你必须学习编程语言如何识别不同类型的数据。所有编程语言都能理解整数,大多数的语言能理解小数和单个字符(`a`、`b`、`c` 等等)。它们通常被表示为 `int`、 `float`、`double` 和 `char`,当然,语言的内置词汇表会告诉你如何引用这些实体。 有时候,在编程语言中内置了一些额外的数据类型,也有时是通过引用库来启用复杂的数据类型。例如,Python 可以识别关键字为 `str` 的字符串,但是 C 语言的代码中必须包含 `string.h` 头文件才能实现字符串特性。 #### 实践 -库可以为您的代码解锁所有类型的数据,但是学习编程语言中包含的基本数据类型是一个明智的起点。 +库可以为你的代码解锁各种类型的数据,但是学习编程语言中包含的基本数据类型是一个明智的起点。 -### 4\. 运算符和解析器 +### 4、运算符和解析器 ![Operators][13] -(Seth Kenlon, [CC BY-SA 4.0][4]) +一旦你理解了编程语言可处理的数据类型,就可以学习如何分析这些数据了。幸运的是,数学这门学科是相当稳定的,所以算数运算符在许多语言中通常是相同的(或至少非常相似)。例如,两个整数相加通常用 `+` 符号完成,而测试一个整数是否大于另一个整数通常用 `>` 符号完成。测试是否相等通常使用 `==` 来完成(是的,是两个等号,因为通常一个等号用来赋值)。 -一旦您理解了编程语言可处理的数据类型,就可以学习如何分析这些数据了。幸运的是,数学这门学科是相当稳定的,所以算数运算符在许多语言中通常是相同的(或至少非常相似)。例如,两个整数相加通常用 `+` 符号完成,而测试一个整数是否大于另一个整数通常用 `>` 符号完成。测试是否相等通常使用 `==` 来完成(是的,是两个等号,因为通常一个等号用来赋值)。 +当然也有一些例外,比如像 Lisp 和 Bash 语言算数运算符就不是如此,但与其他语言一样,这只是一个心理翻译的问题。一旦你了解了表达方式有何不同,很快就可以适应它。快速浏览一下一门编程语言的算数运算符通常足以让你了解算数操作是如何完成的。 -当然也有一些例外,比如像 Lisp 和 Bash 语言算数运算符就不是如此,但与其他语言一样,这只是一个音译的问题。一旦您了解了表达方式有何不同,很快就可以适应它。快速回顾一门编程语言的算数运算符通常足以让您了解算数操作是如何完成的。 - -您还需要知道如何比较和操作非数值数据,比如字符和字符串。这些通常是通过编程语言的核心库来进行的的。例如,Python 提供了 `split()` 方法,而 C 语言需要引入头文件 `string.h` 来提供 `strtok()` 函数。 +你还需要知道如何比较和操作非数值数据,比如字符和字符串。这些通常是通过编程语言的核心库来进行的的。例如,Python 提供了 `split()` 方法,而 C 语言需要引入头文件 `string.h` 来提供 `strtok()` 函数。 #### 实践 -了解用于处理基本数据类型的基本函数和关键字,并寻找可帮助您完成复杂操作的核心库。 +了解用于处理基本数据类型的基本函数和关键字,并寻找可帮助你完成复杂操作的核心库。 -### 5\. 函数 +### 5、函数 ![Class][14] -(Seth Kenlon, [CC BY-SA 4.0][4]) +代码不只是计算机的待办清单。通常情况下,在编写代码时你往往希望向计算机提供一组理论条件和一组操作指令,当满足每个条件时计算机就会采取这些操作。尽管使用条件语句以及数学和逻辑运算符进行流控制可以做很多事情,但是引入了函数和类之后,代码会变得更加高效,因为它们使你可以定义子程序。例如,如果应用程序非常频繁地需要一个确认对话框,那么将其作为类的实例编写一次要比每次需要它时重新编写实现起来要容易得多。 -代码不只是计算机的待办清单。通常情况下,在编写代码时您往往希望向计算机提供一组理论条件和一组操作指令,当满足每个条件时计算机就会采取这些操作。尽管使用条件语句以及数学和逻辑运算符进行流控制可以做很多事情,但是引入了函数和类之后,代码会变得更加高效,因为它们使您可以定义子程序。 例如,如果应用程序需要非常频繁地确认一个对话框,那么将其作为类的实例编写一次要比每次需要它时重新编写实现起来要容易得多。 - -您需要学习如何在编程语言中定义类和函数。更准确地说,您首先需要了解编程语言中是否支持类和函数。大多数现代语言都支持函数,但是类是面向对象的编程语言中所特有的。 +你需要学习如何在编程语言中定义类和函数。更准确地说,你首先需要了解编程语言中是否支持类和函数。大多数现代语言都支持函数,但是类是面向对象的编程语言中所特有的。 #### 实践 -学习语言中可用的结构,这些结构可以帮助您高效地编写和使用代码。 +学习语言中可用的结构,这些结构可以帮助你高效地编写和使用代码。 -### 您可以学到任何东西 +### 你可以学到任何东西 -学习编程语言,就其本身而言,是一种编码过程中的子程序。一旦理解了代码如何工作,您所使用的语言就只是一种传递逻辑的媒介。学习一门新语言的过程几乎都是一样的:通过简单的练习来学习语法,通过学习词汇来积累进行复杂动作的能力,然后练习、练习、再练习。 +学习编程语言,就其本身而言,是一种编码过程中的子程序。一旦理解了代码如何工作,你所使用的语言就只是一种传递逻辑的媒介。学习一门新编程语言的过程几乎都是一样的:通过简单的练习来学习语法,通过学习词汇来积累进行复杂动作的能力,然后练习、练习、再练习。 -------------------------------------------------------------------------------- @@ -176,7 +162,7 @@ via: https://opensource.com/article/20/10/learn-any-programming-language 作者:[Seth Kenlon][a] 选题:[lujun9972][b] 译者:[xiao-song-123](https://github.com/xiao-song-123) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 2f31c7248a956acc06355652c28110d1758d1b27 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Thu, 19 Nov 2020 23:03:38 +0800 Subject: [PATCH 025/139] PUB @xiao-song-123 https://linux.cn/article-12842-1.html --- .../20201022 5 steps to learn any programming language.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename {translated/tech => published}/20201022 5 steps to learn any programming language.md (99%) diff --git a/translated/tech/20201022 5 steps to learn any programming language.md b/published/20201022 5 steps to learn any programming language.md similarity index 99% rename from translated/tech/20201022 5 steps to learn any programming language.md rename to published/20201022 5 steps to learn any programming language.md index 695bfab59a..e4fae4c258 100644 --- a/translated/tech/20201022 5 steps to learn any programming language.md +++ b/published/20201022 5 steps to learn any programming language.md @@ -1,8 +1,8 @@ [#]: collector: "lujun9972" [#]: translator: "xiao-song-123" [#]: reviewer: "wxy" -[#]: publisher: " " -[#]: url: " " +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-12842-1.html" [#]: subject: "5 steps to learn any programming language" [#]: via: "https://opensource.com/article/20/10/learn-any-programming-language" [#]: author: "Seth Kenlon https://opensource.com/users/seth" From 7033d39583a5d99ebdd21b8ff94deecef44335f1 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Fri, 20 Nov 2020 05:02:52 +0800 Subject: [PATCH 026/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201120=20?= =?UTF-8?q?How=20to=20Increase=20Disk=20Size=20of=20Your=20Existing=20Virt?= =?UTF-8?q?ual=20Machines=20in=20VirtualBox?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201120 How to Increase Disk Size of Your Existing Virtual Machines in VirtualBox.md --- ...Existing Virtual Machines in VirtualBox.md | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 sources/tech/20201120 How to Increase Disk Size of Your Existing Virtual Machines in VirtualBox.md diff --git a/sources/tech/20201120 How to Increase Disk Size of Your Existing Virtual Machines in VirtualBox.md b/sources/tech/20201120 How to Increase Disk Size of Your Existing Virtual Machines in VirtualBox.md new file mode 100644 index 0000000000..f0240e9ad7 --- /dev/null +++ b/sources/tech/20201120 How to Increase Disk Size of Your Existing Virtual Machines in VirtualBox.md @@ -0,0 +1,89 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Increase Disk Size of Your Existing Virtual Machines in VirtualBox) +[#]: via: (https://itsfoss.com/increase-disk-size-virtualbox/) +[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/) + +How to Increase Disk Size of Your Existing Virtual Machines in VirtualBox +====== + +Here’s the scenario you may come across sooner or later. + +You installed one or more operating systems in [VirtualBox][1]. While creating those virtual operating systems, you also created virtual hard disks for them in VirtualBox. + +You specified the maximum size of the virtual disk to say 15 or 20 GB but now after using it for some time, you realize that your virtual machine is running out of space. + +While [there are ways to free up disk space on Ubuntu][2] and other operating systems, a more robust way of handling the situation is to increase the disk size of your virtual machines created in VirtualBox. + +Yes, you can enlarge the virtual hard disk in VirtualBox even after creation. Although this is a safe and tested procedure, it is highly recommended to create a backup of your virtual machine before you perform such an action. + +### How to enlarge VirtualBox disk size + +![][3] + +I will show you how to resize disk in VirtualBox graphically and via command line (for Linux geeks). Both methods are easy and straightforward. + +#### Method 1: Using the Virtual Media Manager in VirtualBox + +VirtualBox 6 added a graphical option for resizing virtual disks. You can find it at the file tab of VirtualBox home page. + +Go to _**File->Virtual Media Manager**_: + +![][4] + +Select one of your virtual machines in the list and use the “Size” slider or type the size value that you need. Once done click “Apply”. + +![][5] + +Keep in mind that though you increased the size of your virtual disk, the **actual partition size remains the same if your space is dynamically allocated**. + +#### Method 2: Increase VirtualBox disk space using Linux command line + +If you are using a Linux operating system as a host, open the terminal and type the following command to resize VDI: + +``` +VBoxManage modifymedium "/path_to_vdi_file" --resize +``` + +The resize process should finish right after you click the enter button to execute the command. + +Note + +The commands **modifyvdi** and **modifyhd** of earlier versions of VirtualBox commands are also supported and mapped internally to the **modifymedium** command. + +![][6] + +If you are not sure where your virtual machines are saved, you can find the default location from the VirtualBox home page by clicking on **Files -> Preferences** or by using the keyboard shortcut **Ctrl+G**. + +![][7] + +#### Conclusion + +Personally, I prefer to use the terminal on every Linux distribution that I use for expanding disk, the graphical option is a very handy addition to the latest VirtualBox release. + +This is an easy and quick tip but a great addition to VirtualBox fundamentals. If you find this tip useful, check out a few features of [VirtualBox guest additions][8]. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/increase-disk-size-virtualbox/ + +作者:[Dimitrios Savvopoulos][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/dimitrios/ +[b]: https://github.com/lujun9972 +[1]: https://www.virtualbox.org/ +[2]: https://itsfoss.com/free-up-space-ubuntu-linux/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/enlarge-disk-size-virtualbox.png?resize=800%2C450&ssl=1 +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/1-virtual-box-media-manager.png?resize=800%2C600&ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/2-virtual-box-increase-disc-space.png?resize=800%2C505&ssl=1 +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/3-virtual-box-increase-disc-space-terminal.png?resize=800%2C600&ssl=1 +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/4-virtual-box-preferences.png?resize=800%2C450&ssl=1 +[8]: https://itsfoss.com/install-fedora-in-virtualbox/ From 21badcf98225456344051dd1174245ee98845724 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Fri, 20 Nov 2020 05:03:09 +0800 Subject: [PATCH 027/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201119=20?= =?UTF-8?q?Automate=20your=20tasks=20with=20this=20Ansible=20cheat=20sheet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201119 Automate your tasks with this Ansible cheat sheet.md --- ...our tasks with this Ansible cheat sheet.md | 224 ++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 sources/tech/20201119 Automate your tasks with this Ansible cheat sheet.md diff --git a/sources/tech/20201119 Automate your tasks with this Ansible cheat sheet.md b/sources/tech/20201119 Automate your tasks with this Ansible cheat sheet.md new file mode 100644 index 0000000000..4ef4961a33 --- /dev/null +++ b/sources/tech/20201119 Automate your tasks with this Ansible cheat sheet.md @@ -0,0 +1,224 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Automate your tasks with this Ansible cheat sheet) +[#]: via: (https://opensource.com/article/20/11/ansible-cheat-sheet) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Automate your tasks with this Ansible cheat sheet +====== +Start automating your repetitive tasks by getting to know Ansible's +modules, YAML structure, and more. +![Cheat Sheet cover image][1] + +Ansible is one of the primary tools in the world of [automation and orchestration][2] because of its broad usefulness and flexibility. However, those same traits are the very reason it can be difficult to get started with [Ansible][3]. It isn't a graphical application, and yet it also isn't a scripting or programming language. But like a programming language, the answer to the common question of "what can I do with it?" is "everything," which makes it difficult to know where to begin doing _anything_. + +Here's how I view Ansible: It's an "engine" that uses other people's modules to accomplish complex tasks you describe in a special "pseudo-code" text format called YAML. This means you need to have three things to get started with Ansible: + + 1. Ansible + 2. A repetitive task you want to automate + 3. A basic understanding of YAML + + + +This article aims to help you get started with these three things. + +### Install Ansible + +Part of Ansible's widespread popularity can be attributed to how it lets you (the user) completely ignore what operating system (OS) you're targeting. Generally, you don't have to think about whether your Ansible task will be executed on Linux, macOS, Windows, or BSD. Ansible takes care of the messy platform-specific bits for you. + +However, to _run_ Ansible, you do need to have Ansible installed somewhere. The computer where Ansible is installed is called the _control node_. Any computer that Ansible targets is called a _host_. + +Only the control node needs to have Ansible installed. + +If you're on Linux, you can install Ansible from your software repository with your package manager. + +As yet, Windows is unable to serve as an Ansible control node, although the more progress it makes toward [POSIX][4], the better things look for it, so keep a close watch on Microsoft's [Windows Subsystem for Linux (WSL)][5] product. + +On macOS, you can use a third-party package manager like [Homebrew][6] or [MacPorts][7]. + +### Ansible modules + +Ansible is just an engine. The parts that do 90% of the work are [Ansible modules][8]. These modules are programmed by lots of different people all over the world. Some have become so popular that the Ansible team adopts them and helps maintain them. + +As a user, much of your interaction with Ansible is directed to its modules. Choosing a module is like choosing an app on your phone or computer: you have a task you want done, so you look for an Ansible module that claims to assist. + +Most modules are tied to specific applications. For instance, the [file][9] module helps create and manage files. The [authorized_key][10] module helps manage SSH keys, [Database][11] modules help control and manipulate databases, and so on. + +Part of deciding on a task to offload onto Ansible is finding the module that will help you accomplish it. Ansible plays run _tasks_, and tasks consist of Ansible keywords or Ansible modules. + +### YAML and Ansible + +The YAML text format is a highly structured way to feed instructions to an application, making it almost a form of code. Like a programming language, you must write YAML according to a specific set of syntax rules. A YAML file intended for Ansible is called a _playbook_, and it consists of one or more Ansible _plays_. + +An Ansible play, like YAML, has a very limited structure. There are two kinds of instructions: a _sequence_ and a _mapping_. An Ansible play, as with YAML, always starts with 3 dashes (`---`). + +#### Sequences + +A _sequence_ element is a list. For example, here's a list of penguin species in YAML: + + +``` +\--- +\- Emperor +\- Gentoo +\- Yellow-eyed +\---- +``` + +#### Mapping + +A _mapping_ element consists of two parts: a key and a value. A _key_ in Ansible is usually a keyword defined by an Ansible module, and the value is sometimes Boolean (`true` or `false`) or some choice of parameters defined by the module, or something arbitrary, a variable, depending on what's being set. + +Here's a simple mapping in YAML: + + +``` +\--- +\- Name: "A list of penguin species" +\---- +``` + +#### Sequences and mapping + +These two data types aren't mutually exclusive. + +You can put a sequence into a mapping. In such a case, the sequence is a value for a mapping's key. When placing a sequence into a mapping, you indent the sequence so that it is a "descendent" (or "child") of its key: + + +``` +\--- +\- Penguins: + - Emperor +  - Gentoo +  - Yellow-eyed +\---- +``` + +You can also place mappings in a sequence: + + +``` +\--- +\- Penguin: Emperor +\- Mammal: Gnu +\- Planar: Demon +\---- +``` + +Those are all the rules you need to be familiar with to write valid YAML. + +### Write an Ansible play + +For Ansible plays, whether you use a sequence or a mapping (or a mapping in a sequence, or a sequence in a mapping) is dictated by Ansible or the Ansible module you're using. The "language" of Ansible mostly speaks to configuration options to help you determine how and where your play will run. A quick reference to all Ansible keywords is available in the [Ansible playbook documentation][12]. + +From the list of keywords, you can create an opening for your play. You start with three dashes because that's how a YAML file always starts. Then you give your play a name in a mapping block. You must also define what hosts (computers) you want the play to run on, and how Ansible is meant to reach the computer. + +For this example, I set the host to `localhost`, so the play runs only on _this_ computer, and the connection type to `local` (the default is `ssh`): + + +``` +\--- +\- name: "My first Ansible play" +  hosts: localhost +  connection: local +\---- +``` + +Most of the YAML you'll write in a play is probably configuration options for a specific Ansible module. To find out what instructions a module expects from your Ansible play, refer to that module's documentation. [Modules maintained by Ansible][8] are documented on Ansible's website. + +For this example, I'll use the debug module. + +![Documentation for Ansible debugger module][13] + +On [debug's documentation page][14], three parameters are listed: + + * `msg` is an optional string to print to the terminal. + * `var` is an optional variable, interpreted as a string. This is mutually exclusive with `msg`, so you can use one or the other—not both. + * `verbosity` is an integer you can use to control how verbose this debugger is. Its default is 0, so there is no threshold to pass. + + + +It's a simple module, but the thing to look for is the YAML data type of each parameter. Can you determine from my description whether these parameters are a sequence (a list) or a mapping (a key and value pair)? Knowing what kind of YAML block to use in your play helps you write valid plays. + +Here's a simple "hello world" Ansible play: + + +``` +\--- +\- name: "My first Ansible play" +  hosts: localhost +  connection: local +  tasks: +    - name: "Print a greeting" +      debug: +        msg: "Hello world" +\---- +``` + +Notice that the play contains a `task`. This task is a mapping that contains a sequence of exactly one item. The item in this task is `name` (and its value), the module being used by the task, and a `msg` parameter (along with its value). These are all part of the task mapping, so they're indented to show inheritance. + +You can test this Ansible play by using the `ansible-playbook` command with the `--check` option: + + +``` +$ ansible-playbook --check hello.yaml +PLAY [My first Ansible play] ************************* + +TASK [Gathering Facts] ******************************* +ok: [localhost] + +TASK [Print a greeting] ****************************** +ok: [localhost] => { +    "msg": "Hello world" +} + +PLAY RECAP ******************************************* +localhost: ok=2  changed=0  unreachable=0  failed=0 +``` + +It's verbose, but you can debug the message in your "Print a greeting" task, right where you put it. + +### Testing modules + +Using a new Ansible module is like trying out a new Linux command. You read its documentation, study its syntax, and then try some tests. + +There are at least two other modules you could use to write a "hello world" play: [assert][15] and [meta][16]. Try reading through the documentation for these modules, and see if you can create a simple test play based on what you learned above. + +For further examples of how modules are used to get work done, visit [Ansible Galaxy][17], an open source repository of community-contributed plays. + +### For a quick reference of important Ansible commands, download our [Ansible cheat sheet][18]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/11/ansible-cheat-sheet + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coverimage_cheat_sheet.png?itok=lYkNKieP (Cheat Sheet cover image) +[2]: https://opensource.com/article/20/11/orchestration-vs-automation +[3]: https://opensource.com/resources/what-ansible +[4]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains +[5]: https://docs.microsoft.com/en-us/windows/wsl/install-win10 +[6]: https://opensource.com/article/20/6/homebrew-mac +[7]: https://opensource.com/article/20/11/macports +[8]: https://docs.ansible.com/ansible/2.8/modules/modules_by_category.html +[9]: https://docs.ansible.com/ansible/2.8/modules/file_module.html#file-module +[10]: https://docs.ansible.com/ansible/2.8/modules/authorized_key_module.html#authorized-key-module +[11]: https://docs.ansible.com/ansible/2.8/modules/list_of_database_modules.html +[12]: https://docs.ansible.com/ansible/latest/reference_appendices/playbooks_keywords.html +[13]: https://opensource.com/sites/default/files/screenshot_from_2020-11-13_20-44-15.png (Documentation for Ansible debugger module) +[14]: https://docs.ansible.com/ansible/2.8/modules/debug_module.html +[15]: https://docs.ansible.com/ansible/2.8/modules/assert_module.html +[16]: https://docs.ansible.com/ansible/2.8/modules/meta_module.html +[17]: https://galaxy.ansible.com/ +[18]: https://opensource.com/downloads/ansible-cheat-sheet From 475fa148b7c3000a3e1a4cce3ed25cd0f2b28344 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Fri, 20 Nov 2020 05:03:22 +0800 Subject: [PATCH 028/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201119=20?= =?UTF-8?q?The=20relationship=20between=20labor=20and=20open=20source?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201119 The relationship between labor and open source.md --- ...ationship between labor and open source.md | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 sources/tech/20201119 The relationship between labor and open source.md diff --git a/sources/tech/20201119 The relationship between labor and open source.md b/sources/tech/20201119 The relationship between labor and open source.md new file mode 100644 index 0000000000..bd600b76fe --- /dev/null +++ b/sources/tech/20201119 The relationship between labor and open source.md @@ -0,0 +1,51 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (The relationship between labor and open source) +[#]: via: (https://opensource.com/article/20/11/working-public-review) +[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja) + +The relationship between labor and open source +====== +Readers of all levels of involvement in open source will find value in +this informative and illustrative book. +![Stack of books for reading][1] + +The open source software ecosystem is a fascinating blend of personal passion projects and massive, collaborative corporate efforts. Sometimes there is even overlap when the passion projects are actually key components of the huge corporate projects or when a corporate project is abandoned by the original maintainers, but someone takes up the cause and makes it their personal passion project. Regardless of where an open source project falls on that spectrum, there is a lot of labor involved in the development and maintenance of open source projects. [_Working in Public: The Making and Maintenance of Open Source Software_][2] by Nadia Eghbal thoroughly examines the relationship between labor and open source. + +In addition to an introduction and conclusion, _Working in Public_ consists of five chapters split between two parts: "Part 1: How People Make" and "Part 2: How People Maintain." The first part covers "GitHub as a platform," "The Structure of an Open Source Project," and "Roles, Incentives, and Relationships." The second part explores "The Work Required by Software" and "Managing the Costs of Production." Each chapter deftly covers the topic at hand and provides copious footnotes and end-notes to support the information presented. + +** + +** + +** + +_![Book cover][3]_ + +_Working in Public_ begins with a brief overview of the history of open software development that covers the free software movement, the open source movement, and the modern, GitHub-centered version of open, which Eghbal notes is more focused on the practical aspects of open than philosophical aspects that are key parts of the free software and open source movements. The book provides a solid history of open source software development before transitioning to an examination of how things—and people—work in open source. There are many examples of the whys and the hows of working in open source, often including amusing analogies to make these complex topics easy to understand for readers who are not already enmeshed in open source. Eghbal’s writing manages to strike a balance between informative and entertaining. + +There is sometimes a tendency to treat coding as the only form of open source labor, but _Working in Public_ does not make that mistake. For example, there is an interesting discussion in the introduction about maintainers having to spend time dealing with minor pull requests instead of writing in-depth, substantive code of their own. Throughout the book, Eghbal explores labor in open source beyond just code. It provides valuable insights for readers of all levels and all manners of open source involvement—project maintainers, casual contributors, and users. + +The only flaw with _Working in Public_ is that it tries to serve as both an introduction to open source and an exploration of the labor involved in open source projects. This makes the book extremely approachable for readers with limited knowledge of open source, but that means that more experienced readers might find themselves skipping over lengthy passages that explain basic concepts. For example, half of the first full paragraph on page 12 is a parenthetical explanation of what software libraries are. The tendency to overexplain basic concepts does not distract from the overarching narrative too much, but it might turn some readers off before they get to the interesting parts. + +Overall, I really recommend picking up a copy of this book. It is enjoyable to read and does a good job of covering its topic, though there are issues brought up in some of the footnotes that are worthy of further exploration by the author or by other researchers. Even the parts of the book that overexplain basic concepts are interesting but, as noted above, may fail to capture the attention of readers who are already well versed in open source development. Minor issues aside, the book provides an engaging overview of the history of open source and an insightful examination of the labor involved in open source development. In short, _Working in Public_ is worth reading whether you are a maintainer, contributor, or user of open source. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/11/working-public-review + +作者:[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/books_read_list_stack_study.png?itok=GZxb9OAv (Stack of books for reading) +[2]: https://www.amazon.com/dp/0578675862/ +[3]: https://opensource.com/sites/default/files/uploads/working_in_public.jpg (Book cover) From e8aaa5faa2d93a8c3b44eb937fda2ef36afd0c2b Mon Sep 17 00:00:00 2001 From: DarkSun Date: Fri, 20 Nov 2020 05:03:35 +0800 Subject: [PATCH 029/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201118=20?= =?UTF-8?q?Day=208:=20Start=20with=20something=20that=20works?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201118 Day 8- Start with something that works.md --- ... Day 8- Start with something that works.md | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 sources/tech/20201118 Day 8- Start with something that works.md diff --git a/sources/tech/20201118 Day 8- Start with something that works.md b/sources/tech/20201118 Day 8- Start with something that works.md new file mode 100644 index 0000000000..3ba5299dbd --- /dev/null +++ b/sources/tech/20201118 Day 8- Start with something that works.md @@ -0,0 +1,66 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Day 8: Start with something that works) +[#]: via: (https://jvns.ca/blog/2020/11/18/how-to-do-hard-projects--start-with-something-that-works/) +[#]: author: (Julia Evans https://jvns.ca/) + +Day 8: Start with something that works +====== + +Today at RC I’m a little stuck so here’s a very short reflection on how to do hard programming problems :) + +I was talking to a friend yesterday about how to do programming projects that are a bit out of your comfort zone, and I realized that there’s a pattern to how I approach new-to-me topics! Here I’m especially thinking about little side projects where you want to get the thing done pretty efficiently. + +When I start on a new project using some technology I haven’t worked with before, I often: + + 1. Find some code on the internet that already does something a little like what I want + 2. Incrementally modify that code until it does what I want, often completely changing everything about the original code in the process + + + +Here are a couple of quick thoughts about this process: + +### it’s important that the initial code _works_ + +Often when I’m out looking for examples, I’ll find a lot of code that I can’t get to work quickly, often because the code is kind of old and things have changed since then. Whenever possible, I try to find code that I can get to work on my computer pretty quickly. + +It’s been pretty helpful to me to give up relatively quickly on code that I can’t get to work right away and look for another example – often there is something out there that’s more recent and that I can get to work more quickly! + +### you have to be able to incrementally change the code into what you want + +Today I’ve been working with some neural network code, and one thing I’m really struggling with for the last couple of days is that I find it pretty easy to find somewhat relevant Jupyter notebooks that do RNN things, and pretty hard to modify those examples to do something closer to what I want. They keep breaking and I then don’t know how to fix them. + +Last week I was working on a Rails app, which I think is something that’s very easy to incrementally change into the program you want: `rails new` gives you a webserver that does almost nothing, but it works! And then you just need to change it one tiny step at a time into the website you want to build. + +### examples of “something that works” + + * If you want to write a window manager, [tinywm][1] is a window manager in 50 lines of C! + * this tiny kernel written in Rust that does nothing was a fun starting point for an operating system (probably it’s not a good starting point today) + * `rails new`, like I talked about above + * I love that projects let you “view source” on the backend of any Glitch project + * Jupyter notebooks, like [these great NLP tutorials by Allison Parrish][2] + + + +### that’s all! + +I think little starting points like this are so important and can be really magical. Finding the right starting point can be hard, but when I find a good one it makes everything so much easier! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2020/11/18/how-to-do-hard-projects--start-with-something-that-works/ + +作者:[Julia Evans][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://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: http://incise.org/tinywm.html +[2]: https://twitter.com/aparrish/status/876117075567284225 From d3cf8fe1abfe5abe1c7f18f995d64d0f71fe1949 Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 20 Nov 2020 08:32:37 +0800 Subject: [PATCH 030/139] translated --- ... encrypted disks on Linux automatically.md | 272 ------------------ ... encrypted disks on Linux automatically.md | 271 +++++++++++++++++ 2 files changed, 271 insertions(+), 272 deletions(-) delete mode 100644 sources/tech/20201116 Unlock encrypted disks on Linux automatically.md create mode 100644 translated/tech/20201116 Unlock encrypted disks on Linux automatically.md diff --git a/sources/tech/20201116 Unlock encrypted disks on Linux automatically.md b/sources/tech/20201116 Unlock encrypted disks on Linux automatically.md deleted file mode 100644 index d8460ba951..0000000000 --- a/sources/tech/20201116 Unlock encrypted disks on Linux automatically.md +++ /dev/null @@ -1,272 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Unlock encrypted disks on Linux automatically) -[#]: via: (https://opensource.com/article/20/11/nbde-linux) -[#]: author: (Curt Warfield https://opensource.com/users/rcurtiswarfield) - -Unlock encrypted disks on Linux automatically -====== -Open encrypted disks without having to manually enter a passcode by -using Network-Bound Disk Encryption (NBDE). -![Lock][1] - -From a security viewpoint, it's important to encrypt your sensitive data to protect it from prying eyes and hackers. Linux Unified Key Setup ([LUKS][2]) is a great tool and a common standard for Linux disk encryption. Because it stores all pertinent setup information in the partition header, it makes migrating data easy. - -To configure encrypted disks or partitions with LUKS, you will need to use the [cryptsetup][3] utility. Unfortunately, one of the downsides of encrypting your disks is that you have to manually provide the password every time the system is rebooted or the disk is remounted. - -However, Network-Bound Disk Encryption (NBDE) can automatically and securely unlock encrypted disks without any user intervention. It is available in several Linux distributions, beginning with Red Hat Enterprise Linux 7.4, CentOS 7.4, and Fedora 24, and in later versions of each. - -NBDE is implemented with the following technologies: - - * **[Clevis framework][4]:** A pluggable framework tool that automatically decrypts and unlocks LUKS volumes - * **[Tang server][5]:** A service for binding cryptographic keys to network presence - - - -Tang provides the encryption keys to the Clevis client. According to Tang's developers, this provides a secure, stateless, anonymous alternative to key escrow services. - -Because NBDE uses the client-server architecture, you must configure both the client and the server. You can use a virtual machine on your local network for your Tang server. - -### Server installation - -Install Tang using sudo: - - -``` -`sudo yum install tang -y` -``` - -Enable the Tang server: - - -``` -`sudo systemctl enable tangd.socket --now` -``` - -The Tang server works on port 80 and must be added to firewalld. Add the appropriate firewalld rule: - - -``` -sudo  firewall-cmd --add-port=tcp/80 --perm -sudo firewall-cmd --reload -``` - -The server should now be installed. - -### Client installation - -For this example, assume you have added a new 1GB disk named `/dev/vdc` to your system. - -Create the primary partition using fdisk or parted: - - -``` -sudo fdisk /dev/vdc -``` - -Complete the following steps to install the client. - - -``` -Welcome to fdisk (util-linux 2.23.2). - -Changes will remain in memory only, until you decide to write them. -Be careful before using the write command. - -Device does not contain a recognized partition table -Building a new DOS disklabel with disk identifier 0x4a6812d4. - -Command (m for help): -``` - -Enter **n** to create the new partition: - - -``` -Partition type: -   p   primary (0 primary, 0 extended, 4 free) -   e   extended   -Select (default p): -``` - -Hit the **Enter** key to select the primary partition: - - -``` -Using default response p -Partition number (1-4, default 1): -``` - -Hit the **Enter** key to select the default partition number: - - -``` -First sector (2048-2097151, default 2048): -Using default value 2048 -Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): -``` - -Hit the **Enter** key to select the last sector: - - -``` -Using default value 2097151 -Partition 1 of type Linux and of size 1023 MiB is set - -Command (m for help): wq -``` - -Type **wq** to save the changes and exit fdisk: - - -``` -The partition table has been altered! - -Calling ioctl() to re-read partition table. -Syncing disks. -``` - -Run `partprobe` to inform the system of the partition table changes: - - -``` -`sudo partprobe` -``` - -Install the cryptsetup package using sudo: - - -``` -`sudo yum install cryptsetup -y` -``` - -Use the `cryptsetup luksFormat` command to encrypt the disk. You will need to type **YES** when prompted and also choose and enter a passphrase to encrypt the disk: - - -``` -sudo cryptsetup luksFormat /dev/vdc1 -WARNING! -======== -This will overwrite data on /dev/vdc1 irrevocably. - -Are you sure? (Type uppercase yes): - -Enter passphrase for /dev/vdc1: -Verify passphrase: -``` - -Use the `cryptsetup luksOpen` command to map the encrypted partition to a logical device. For example, use `encryptedvdc1` as the name. You will also need to enter the passphrase again: - - -``` -sudo cryptsetup luksOpen /dev/vdc1 encryptedvdc1 -Enter passphrase for /dev/vdc1: -``` - -The encrypted partition is now available at `/dev/mapper/encryptedvdc1`. - -Create an XFS filesystem on the encrypted partition: - - -``` -`sudo mkfs.xfs /dev/mapper/encryptedvdc1` -``` - -Create a directory for mounting the encrypted partition: - - -``` -`sudo mkdir /encrypted` -``` - -Use the `cryptsetup luksClose` command to lock the partition: - - -``` -`cryptsetup luksClose encryptedvdc1` -``` - -Install the Clevis packages using sudo: - - -``` -`sudo yum install clevis clevis-luks clevis-dracut -y` -``` - -Modify /etc/crypttab to open the encrypted volume at boot time: - - -``` -`sudo vim /etc/crypttab` -``` - -Add the following line: - - -``` -`encryptedvdc1       /dev/vdc1  none   _netdev` -``` - -Modify /etc/fstab to automatically mount the encrypted volume during a reboot or at boot time: - - -``` -`sudo vim /etc/fstab` -``` - -Add the following line: - - -``` -`/dev/mapper/encryptedvdc1   /encrypted       xfs    _netdev        1 2` -``` - -For this example, assume the Tang server's IP address is `192.168.1.20`. You can also use the hostname or domain if you prefer. - -Run the following `clevis` command: - - -``` -sudo clevis bind luks -d /dev/vdc1 tang '{"url":"' -The advertisement contains the following signing keys: - -rwA2BAITfYLuyNiIeYUMBzkhk7M - -Do you wish to trust these keys? [ynYN] Y -Enter existing LUKS password: -``` - -Type **Y** to accept the keys for the Tang server and provide the existing LUKS password for the initial setup. - -Enable clevis-luks-askpass.path via systemctl in order to prevent being prompted for the passphrase for non-root partitions. - - -``` -`sudo systemctl enable clevis-luks-askpass.path` -``` - -The client is installed. Now, whenever you reboot the server, the encrypted disk should automatically be decrypted and mounted by retrieving the keys from the Tang server. - -If the Tang server is unavailable for any reason, you'll need to provide the passphrase manually in order to decrypt and mount the partition. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/20/11/nbde-linux - -作者:[Curt Warfield][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/rcurtiswarfield -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security-lock-password.jpg?itok=KJMdkKum (Lock) -[2]: https://en.wikipedia.org/wiki/Linux_Unified_Key_Setup -[3]: https://gitlab.com/cryptsetup/cryptsetup -[4]: https://github.com/latchset/clevis -[5]: https://github.com/latchset/tang diff --git a/translated/tech/20201116 Unlock encrypted disks on Linux automatically.md b/translated/tech/20201116 Unlock encrypted disks on Linux automatically.md new file mode 100644 index 0000000000..7e97ec99a6 --- /dev/null +++ b/translated/tech/20201116 Unlock encrypted disks on Linux automatically.md @@ -0,0 +1,271 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Unlock encrypted disks on Linux automatically) +[#]: via: (https://opensource.com/article/20/11/nbde-linux) +[#]: author: (Curt Warfield https://opensource.com/users/rcurtiswarfield) + +自动解锁 Linux 上的加密磁盘 +====== +通过使用网络绑定磁盘加密 (NBDE),无需手动输入密码即可打开加密磁盘。 +![Lock][1] + +从安全的角度来看,对敏感数据进行加密以保护其免受窥探和黑客的攻击是很重要的。Linux 统一密钥设置([LUKS][2])是一个很好的工具,也是 Linux 磁盘加密的通用标准。因为它将所有相关的设置信息存储在分区头中,所以它使数据迁移变得简单。 + +要使用 LUKS 配置加密磁盘或分区,你需要使用 [cryptsetup][3] 工具。不幸的是,加密磁盘的一个缺点是,每次系统重启或磁盘重新挂载时,你都必须手动提供密码。 + +然而,网络绑定磁盘加密 (NBDE) 可以在没有任何用户干预的情况下自动安全地解锁加密磁盘。它可以在一些 Linux 发行版中使用,从 Red Hat Enterprise Linux 7.4、CentOS 7.4 和 Fedora 24 开始,以及之后的后续版本。 + +NBDE 采用以下技术实现: + +* **[Clevis 框架][4]:**一个可插拔的框架工具,可自动解密和解锁 LUKS 卷 +* **[Tang 服务器][5]:**用于将加密密钥绑定到网络状态的服务 + + + +Tang 向 Clevis 客户端提供加密密钥。 据 Tang 的开发人员介绍,这为密钥托管服务提供了一个安全、无状态、匿名的替代方案。 + +由于 NBDE 使用客户端-服务器架构,你必须同时配置客户端和服务器。你可以在你的本地网络上使用一个虚拟机作为 Tang 服务器。 + +### 服务器安装 + +用 sudo 安装 Tang: + + +``` +`sudo yum install tang -y` +``` + +启用 Tang 服务器: + + +``` +`sudo systemctl enable tangd.socket --now` +``` + +Tang 服务器工作在 80 端口,且必须加入 firewalld。 添加相应的 firewalld 规则: + + +``` +sudo firewall-cmd --add-port=tcp/80 --perm +sudo firewall-cmd --reload +``` + +现在安装好了服务器。 + +### 客户端安装 + +在本例中,假设你已经添加了一个名为 `/dev/vdc` 的新的 1GB 磁盘到你的系统中。 + +使用 fdisk 或 parted 创建主分区: + + +``` +sudo fdisk /dev/vdc +``` + +完成以下步骤来安装客户端。 + + +``` +Welcome to fdisk (util-linux 2.23.2). + +Changes will remain in memory only, until you decide to write them. +Be careful before using the write command. + +Device does not contain a recognized partition table +Building a new DOS disklabel with disk identifier 0x4a6812d4. + +Command (m for help): +``` + +输入 **n** 来创建新的分区: + + +``` +Partition type: + p primary (0 primary, 0 extended, 4 free) + e extended +Select (default p): +``` + +按下**回车**键选择主分区: + + +``` +Using default response p +Partition number (1-4, default 1): +``` + +按下**回车**键选择默认分区号: + + +``` +First sector (2048-2097151, default 2048): +Using default value 2048 +Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): +``` + +按**回车**键选择最后一个扇区: + + +``` +Using default value 2097151 +Partition 1 of type Linux and of size 1023 MiB is set + +Command (m for help): wq +``` + +输入 **wq** 保存更改并退出 fdisk: + + +``` +The partition table has been altered! + +Calling ioctl() to re-read partition table. +Syncing disks. +``` + +运行 `partprobe` 通知系统分区表的变化: + + +``` +`sudo partprobe` +``` + +使用 sudo 安装 cryptsetup 软件包: + + +``` +`sudo yum install cryptsetup -y` +``` + +使用 `cryptsetup luksFormat` 命令对磁盘进行加密。当提示时,你需要输入 **YES**,并选择和输入密码来加密磁盘: + + +``` +sudo cryptsetup luksFormat /dev/vdc1 +WARNING! +======== +This will overwrite data on /dev/vdc1 irrevocably. + +Are you sure? (Type uppercase yes): + +Enter passphrase for /dev/vdc1: +Verify passphrase: +``` + +使用 `cryptsetup luksOpen` 命令将加密的分区映射到一个逻辑设备上。例如,使用 `encryptedvdc1` 作为名称。你还需要再次输入密码: + + +``` +sudo cryptsetup luksOpen /dev/vdc1 encryptedvdc1 +Enter passphrase for /dev/vdc1: +``` + +加密分区现在在 `/dev/mapper/encryptedvdc1` 中可用。 + +在加密的分区上创建一个 XFS 文件系统: + + +``` +`sudo mkfs.xfs /dev/mapper/encryptedvdc1` +``` + +创建一个挂载加密分区的目录: + + +``` +`sudo mkdir /encrypted` +``` + +使用 `cryptsetup luksClose` 命令锁定分区: + + +``` +`cryptsetup luksClose encryptedvdc1` +``` + +使用 sudo 安装 Clevis 软件包: + + +``` +`sudo yum install clevis clevis-luks clevis-dracut -y` +``` + +修改 /etc/crypttab,在启动时打开加密卷: + + +``` +`sudo vim /etc/crypttab` +``` + +增加以下一行: + + +``` +`encryptedvdc1 /dev/vdc1 none _netdev` +``` + +修改 /etc/fstab,在重启时或启动时自动挂载加密卷: + + +``` +`sudo vim /etc/fstab` +``` + +增加以下一行: + + +``` +`/dev/mapper/encryptedvdc1 /encrypted xfs _netdev 1 2` +``` + +在这个例子中,假设 Tang 服务器的 IP 地址是 `192.168.1.20`。如果你喜欢,也可以使用主机名或域名。 + +运行以下 `clevis` 命令: + + +``` +sudo clevis bind luks -d /dev/vdc1 tang '{"url":"' +The advertisement contains the following signing keys: + +rwA2BAITfYLuyNiIeYUMBzkhk7M + +Do you wish to trust these keys? [ynYN] Y +Enter existing LUKS password: +``` + +输入 **Y** 接受 Tang 服务器的密钥,并提供现有的 LUKS 密码进行初始设置。 + +通过 systemctl 启用 clevis-luks-askpass.path,以防止非 root 分区被提示输入密码。 + + +``` +`sudo systemctl enable clevis-luks-askpass.path` +``` + +客户端已经安装完毕。 现在,每当你重启服务器时,加密后的磁盘应该会自动解密,并通过 Tang 服务器取回密钥进行挂载。 + +如果 Tang 服务器因为任何原因不可用,你需要手动提供密码,才能解密和挂载分区。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/11/nbde-linux + +作者:[Curt Warfield][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://opensource.com/users/rcurtiswarfield +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security-lock-password.jpg?itok=KJMdkKum (Lock) +[2]: https://en.wikipedia.org/wiki/Linux_Unified_Key_Setup +[3]: https://gitlab.com/cryptsetup/cryptsetup +[4]: https://github.com/latchset/clevis +[5]: https://github.com/latchset/tang \ No newline at end of file From 78622bdd6e00d87aaa4592ec5da0259c1f024e3d Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 20 Nov 2020 08:38:06 +0800 Subject: [PATCH 031/139] translating --- sources/tech/20201106 Reclaim hard-drive space with LVM.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20201106 Reclaim hard-drive space with LVM.md b/sources/tech/20201106 Reclaim hard-drive space with LVM.md index 14be3ae564..dcd1a96f7b 100644 --- a/sources/tech/20201106 Reclaim hard-drive space with LVM.md +++ b/sources/tech/20201106 Reclaim hard-drive space with LVM.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (geekpi) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) From 40a26b26c3685f0bef8b403cdaf26863c137fcfc Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Fri, 20 Nov 2020 20:06:57 +0800 Subject: [PATCH 032/139] PUB @wxy https://linux.cn/article-12845-1.html --- .../20201111 Using Fedora 33 with Microsoft-s WSL2.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename {translated/tech => published}/20201111 Using Fedora 33 with Microsoft-s WSL2.md (98%) diff --git a/translated/tech/20201111 Using Fedora 33 with Microsoft-s WSL2.md b/published/20201111 Using Fedora 33 with Microsoft-s WSL2.md similarity index 98% rename from translated/tech/20201111 Using Fedora 33 with Microsoft-s WSL2.md rename to published/20201111 Using Fedora 33 with Microsoft-s WSL2.md index b94d6b5cdc..fb2f0d24bd 100644 --- a/translated/tech/20201111 Using Fedora 33 with Microsoft-s WSL2.md +++ b/published/20201111 Using Fedora 33 with Microsoft-s WSL2.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (wxy) [#]: reviewer: (wxy) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12845-1.html) [#]: subject: (Using Fedora 33 with Microsoft’s WSL2) [#]: via: (https://fedoramagazine.org/wsl-fedora-33/) [#]: author: (Jim Perrin https://fedoramagazine.org/author/jperrin/) From c68d8a821e691db363b3901c6b3b5a6036ede427 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Fri, 20 Nov 2020 21:06:53 +0800 Subject: [PATCH 033/139] APL --- sources/tech/20201023 Secure NTP with NTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20201023 Secure NTP with NTS.md b/sources/tech/20201023 Secure NTP with NTS.md index 00cfdfd20d..6572c0f133 100644 --- a/sources/tech/20201023 Secure NTP with NTS.md +++ b/sources/tech/20201023 Secure NTP with NTS.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (wxy) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) From eb99ce38d2ffa66dad2b6206cb5d61e9e4ddfea1 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Fri, 20 Nov 2020 23:00:32 +0800 Subject: [PATCH 034/139] TSL --- sources/tech/20201023 Secure NTP with NTS.md | 171 ------------------ .../tech/20201023 Secure NTP with NTS.md | 167 +++++++++++++++++ 2 files changed, 167 insertions(+), 171 deletions(-) delete mode 100644 sources/tech/20201023 Secure NTP with NTS.md create mode 100644 translated/tech/20201023 Secure NTP with NTS.md diff --git a/sources/tech/20201023 Secure NTP with NTS.md b/sources/tech/20201023 Secure NTP with NTS.md deleted file mode 100644 index 6572c0f133..0000000000 --- a/sources/tech/20201023 Secure NTP with NTS.md +++ /dev/null @@ -1,171 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (wxy) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Secure NTP with NTS) -[#]: via: (https://fedoramagazine.org/secure-ntp-with-nts/) -[#]: author: (Miroslav Lichvar https://fedoramagazine.org/author/mlichvar/) - -Secure NTP with NTS -====== - -![][1] - -Many computers use the Network Time Protocol (NTP) to synchronize their system clocks over the internet. NTP is one of the few unsecured internet protocols still in common use. An attacker that can observe network traffic between a client and server can feed the client with bogus data and, depending on the client’s implementation and configuration, force it to set its system clock to any time and date. Some programs and services might not work if the client’s system clock is not accurate. For example, a web browser will not work correctly if the web servers’ certificates appear to be expired according to the client’s system clock. Use Network Time Security (NTS) to secure NTP. - -Fedora 33[1][2] is the first Fedora release to support NTS. NTS is a new authentication mechanism for NTP. It enables clients to verify that the packets they receive from the server have not been modified while in transit. The only thing an attacker can do when NTS is enabled is drop or delay packets. See [RFC8915][3] for further details about NTS. - -NTP can be secured well with symmetric keys. Unfortunately, the server has to have a different key for each client and the keys have to be securely distributed. That might be practical with a private server on a local network, but it does not scale to a public server with millions of clients. - -NTS includes a Key Establishment (NTS-KE) protocol that automatically creates the encryption keys used between the server and its clients. It uses Transport Layer Security (TLS) on TCP port 4460. It is designed to scale to very large numbers of clients with a minimal impact on accuracy. The server does not need to keep any client-specific state. It provides clients with cookies, which are encrypted and contain the keys needed to authenticate the NTP packets. Privacy is one of the goals of NTS. The client gets a new cookie with each server response, so it doesn’t have to reuse cookies. This prevents passive observers from tracking clients migrating between networks. - -The default NTP client in Fedora is _chrony_. Chrony added NTS support in version 4.0. The default configuration hasn’t changed. Chrony still uses public servers from the [pool.ntp.org][4] project and NTS is not enabled by default. - -Currently, there are very few public NTP servers that support NTS. The two major providers are Cloudflare and Netnod. The [Cloudflare servers][5] are in various places around the world. They use anycast addresses that should allow most clients to reach a close server. The [Netnod servers][6] are located in Sweden. In the future we will probably see more public NTP servers with NTS support. - -A general recommendation for configuring NTP clients for best reliability is to have at least three working servers. For best accuracy, it is recommended to select close servers to minimize network latency and asymmetry caused by asymmetric network routing. If you are not concerned about fine-grained accuracy, you can ignore this recommendation and use any NTS servers you trust, no matter where they are located. - -If you do want high accuracy, but you don’t have a close NTS server, you can mix distant NTS servers with closer non-NTS servers. However, such a configuration is less secure than a configuration using NTS servers only. The attackers still cannot force the client to accept arbitrary time, but they do have a greater control over the client’s clock and its estimate of accuracy, which may be unacceptable in some environments. - -### Enable client NTS in the installer - -When installing Fedora 33, you can enable NTS in the _Time & Date_ dialog in the _Network Time_ configuration. Enter the name of the server and check the NTS support before clicking the **+** (Add) button. You can add one or more servers or pools with NTS. To remove the default pool of servers (_2.fedora.pool.ntp.org_), uncheck the corresponding mark in the _Use_ column. - -![Network Time configuration in Fedora installer][7] - -### Enable client NTS in the configuration file - -If you upgraded from a previous Fedora release, or you didn’t enable NTS in the installer, you can enable NTS directly in _/etc/chrony.conf_. Specify the server with the _nts_ option in addition to the recommended _iburst_ option. For example: - -``` -server time.cloudflare.com iburst nts -server nts.sth1.ntp.se iburst nts -server nts.sth2.ntp.se iburst nts -``` - -You should also allow the client to save the NTS keys and cookies to disk, so it doesn’t have to repeat the NTS-KE session on each start. Add the following line to _chrony.conf_, if it is not already present: - -``` -ntsdumpdir /var/lib/chrony -``` - -If you don’t want NTP servers provided by DHCP to be mixed with the servers you have specified, remove or comment out the following line in _chrony.conf_: - -``` -sourcedir /run/chrony-dhcp -``` - -After you have finished editing _chrony.conf_, save your changes and restart the _chronyd_ service: - -``` -systemctl restart chronyd -``` - -### Check client status - -Run the following command under the root user to check whether the NTS key establishment was successful: - -``` -# chronyc -N authdata -Name/IP address Mode KeyID Type KLen Last Atmp NAK Cook CLen -========================================================================= -time.cloudflare.com NTS 1 15 256 33m 0 0 8 100 -nts.sth1.ntp.se NTS 1 15 256 33m 0 0 8 100 -nts.sth2.ntp.se NTS 1 15 256 33m 0 0 8 100 -``` - -The _KeyID_, _Type_, and _KLen_ columns should have non-zero values. If they are zero, check the system log for error messages from _chronyd_. One possible cause of failure is a firewall is blocking the client’s connection to the server’s TCP port ( port 4460). - -Another possible cause of failure is a certificate that is failing to verify because the client’s clock is wrong. This is a chicken-or-the-egg type problem with NTS. You may need to manually correct the date or temporarily disable NTS in order to get NTS working. If your computer has a real-time clock, as almost all computers do, and it’s backed up by a good battery, this operation should be needed only once. - -If the computer doesn’t have a real-time clock or battery, as is common with some small ARM computers like the Raspberry Pi, you can add the _-s_ option to _/etc/sysconfig/chronyd_ to restore time saved on the last shutdown or reboot. The clock will be behind the true time, but if the computer wasn’t shut down for too long and the server’s certificates were not renewed too close to their expiration, it should be sufficient for the time checks to succeed. As a last resort, you can disable the time checks with the _nocerttimecheck_ directive. See the _chrony.conf(5)_ man page for details. - -Run the following command to confirm that the client is making NTP measurements: - -``` -# chronyc -N sources -MS Name/IP address Stratum Poll Reach LastRx Last sample -=============================================================================== -^* time.cloudflare.com 3 6 377 45 +355us[ +375us] +/- 11ms -^+ nts.sth1.ntp.se 1 6 377 44 +237us[ +237us] +/- 23ms -^+ nts.sth2.ntp.se 1 6 377 44 -170us[ -170us] +/- 22ms -``` - -The _Reach_ column should have a non-zero value; ideally 377. The value 377 shown above is an octal number. It indicates that the last eight requests all had a valid response. The validation check will include NTS authentication if enabled. If the value only rarely or never gets to 377, it indicates that NTP requests or responses are getting lost in the network. Some major network operators are known to have middleboxes that block or limit rate of large NTP packets as a mitigation for amplification attacks that exploit the monitoring protocol of _ntpd_. Unfortunately, this impacts NTS-protected NTP packets, even though they don’t cause any amplification. The NTP working group is considering an alternative port for NTP as a workaround for this issue. - -### Enable NTS on the server - -If you have your own NTP server running _chronyd_, you can enable server NTS support to allow its clients to be synchronized securely. If the server is a client of other servers, it should use NTS or a symmetric key for its own synchronization. The clients assume the synchronization chain is secured between all servers up to the primary time servers. - -Enabling server NTS is similar to enabling HTTPS on a web server. You just need a private key and certificate. The certificate could be signed by the Let’s Encrypt authority using the _certbot_ tool, for example. When you have the key and certificate file (including intermediate certificates), specify them in _chrony.conf_ with the following directives: - -``` -ntsserverkey /etc/pki/tls/private/foo.example.net.key -ntsservercert /etc/pki/tls/certs/foo.example.net.crt -``` - -Make sure the _ntsdumpdir_ directive mentioned previously in the client configuration is present in _chrony.conf_. It allows the server to save its keys to disk, so the clients of the server don’t have to get new keys and cookies when the server is restarted. - -Restart the _chronyd_ service: - -``` -systemctl restart chronyd -``` - -If there are no error messages in the system log from _chronyd_, it should be accepting client connections. If the server has a firewall, it needs to allow both the UDP 123 and TCP 4460 ports for NTP and NTS-KE respectively. - -You can perform a quick test from a client machine with the following command: - -``` -$ chronyd -Q -t 3 'server foo.example.net iburst nts maxsamples 1' -2020-10-13T12:00:52Z chronyd version 4.0 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 +DEBUG) -2020-10-13T12:00:52Z Disabled control of system clock -2020-10-13T12:00:55Z System clock wrong by -0.001032 seconds (ignored) -2020-10-13T12:00:55Z chronyd exiting -``` - -If you see a _System clock wrong_ message, it’s working correctly. - -On the server, you can use the following command to check how many NTS-KE connections and authenticated NTP packets it has handled: - -``` -# chronyc serverstats -NTP packets received : 2143106240 -NTP packets dropped : 117180834 -Command packets received : 16819527 -Command packets dropped : 0 -Client log records dropped : 574257223 -NTS-KE connections accepted: 104 -NTS-KE connections dropped : 0 -Authenticated NTP packets : 52139 -``` - -If you see non-zero _NTS-KE connections accepted_ and _Authenticated NTP packets_, it means at least some clients were able to connect to the NTS-KE port and send an authenticated NTP request. - -_— Cover photo by Louis. K on Unsplash —_ - -* * * - -1\. The Fedora 33 _Beta_ installer contains an older chrony prerelease which doesn’t work with current NTS servers because the NTS-KE port has changed. Consequently, in the Network Time configuration in the installer, the servers will always appear as not working. After installation, the chrony package needs to be updated before it will work with current servers. - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/secure-ntp-with-nts/ - -作者:[Miroslav Lichvar][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/mlichvar/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2020/10/secure-ntp-with-nts-816x345.jpg -[2]: tmp.rl0XC1HIGm#footnote1 -[3]: https://tools.ietf.org/html/rfc8915 -[4]: https://www.pool.ntp.org -[5]: https://developers.cloudflare.com/time-services/nts/usage -[6]: https://www.netnod.se/time-and-frequency/how-to-use-nts -[7]: https://fedoramagazine.org/wp-content/uploads/2020/10/anaconda-nts.png diff --git a/translated/tech/20201023 Secure NTP with NTS.md b/translated/tech/20201023 Secure NTP with NTS.md new file mode 100644 index 0000000000..2146e717e2 --- /dev/null +++ b/translated/tech/20201023 Secure NTP with NTS.md @@ -0,0 +1,167 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Secure NTP with NTS) +[#]: via: (https://fedoramagazine.org/secure-ntp-with-nts/) +[#]: author: (Miroslav Lichvar https://fedoramagazine.org/author/mlichvar/) + +用 NTS 保证 NTP 的安全 +====== + +![][1] + +许多计算机使用网络时间协议Network Time Protocol(NTP)通过互联网同步系统时钟。NTP 是少数几个仍在普遍使用的不安全的互联网协议之一。攻击者如果能够观察到客户端和服务器之间的网络流量,就可以向客户端提供虚假的数据,并根据客户端的实现和配置,强迫其将系统时钟设置为任何时间和日期。如果客户端的系统时钟不准确,一些程序和服务可能无法工作。例如,如果根据客户端的系统时钟,Web 服务器的证书似乎已经过期,Web 浏览器将无法正常工作。可以使用网络时间安全Network Time Security(NTS)来保证 NTP 的安全。 + +Fedora 33 [^1] 是第一个支持 NTS 的 Fedora 版本。NTS 是一种新的 NTP 验证机制。它使客户端能够验证他们从服务器接收的数据包在传输过程中有没有被修改。当 NTS 启用时,攻击者唯一能做的就是丢弃或延迟数据包。关于 NTS 的更多细节,请参见 [RFC8915][3]。 + +使用对称密钥可以很好地保证 NTP 的安全。遗憾的是,服务器必须为每个客户端配备不同的密钥,而且密钥必须安全地分发。这对于本地网络上的私有服务器来说可能是实用的,但它不能扩展到有着数百万客户端的公共服务器上。 + +NTS 包括一个密钥建立Key Establishment(NTS-KE)协议,它可以自动创建服务器与其客户端之间使用的加密密钥。它在 TCP 端口 4460 上使用传输层安全Transport Layer Security(TLS)。它被设计成可以扩展到非常多的客户端,而对准确性的影响最小。服务器不需要保存任何客户端特定的状态。它为客户提供 cookie,cookie 是加密的,包含验证 NTP 数据包所需的密钥。隐私是 NTS 的目标之一。客户端在每次服务器响应时都会得到一个新的 cookie,所以它不必重复使用 cookie。这可以防止被动观察者跟踪在网络之间迁移的客户端。 + +Fedora 中默认的 NTP 客户端是 Chrony。Chrony 在 4.0 版本中增加了 NTS 支持,但并没有改变默认配置。Chrony 仍然使用 [pool.ntp.org][4] 项目中的公共服务器,而且默认情况下 NTS 没有启用。 + +目前,支持 NTS 的公共 NTP 服务器非常少。两个主要的提供商是 Cloudflare 和 Netnod。[Cloudflare 服务器][5]分布在世界各地的不同地方。他们使用的是任播anycast地址,应该可以让大多数客户到达一个接近的服务器。[Netnod 服务器][6]位于瑞典。在未来,我们可能会看到更多支持 NTS 的公共 NTP 服务器。 + +为了获得最佳的可靠性,配置 NTP 客户端的一般建议是至少有三个工作的服务器。为了达到最好的精度,建议选择距离较近的服务器,以减少网络延迟和非对称网络路由造成的不对称性。如果你不关心细粒度的精度,你可以忽略这个建议,使用任何你信任的 NTS 服务器,无论它们位于哪里。 + +如果你确实想要高准确度,但又没有近距离的 NTS 服务器,你可以将远处的 NTS 服务器和近处的非 NTS 服务器混合使用。但是,这样的配置不如只使用 NTS 服务器的配置安全。攻击者仍然不能强迫客户机接受任意时间,但他们确实对客户机的时钟及其估计精度有更大的控制权,这在某些环境下可能是不可接受的。 + +### 在安装程序中启用客户端 NTS + +安装 Fedora 33 时,你可以在“Network Time”配置的“Time & Date”对话框中启用 NTS。在点击“+”(添加)按钮之前,请输入服务器的名称并检查 NTS 支持情况。你可以添加一个或多个具有 NTS 的服务器或池。要删除默认的服务器池(`2.fedora.pool.ntp.org`),请取消选中“Use”列中的相应标记。 + +![Fedora 安装程序中的网络时间配置][7] + +### 在配置文件中启用客户端 NTS + +如果你从之前的 Fedora 版本升级,或者你没有在安装程序中启用 NTS,你可以直接在 `/etc/chrony.conf` 中启用 NTS。除了推荐的 `iburst` 选项外,还可以对指定服务器使用 `nts` 选项。例如: + +``` +server time.cloudflare.com iburst nts +server nts.sth1.ntp.se iburst nts +server nts.sth2.ntp.se iburst nts +``` + +你还应该允许客户端将 NTS 密钥和 cookie 保存到磁盘上,这样它就不必在每次启动时重复 NTS-KE 会话。在 `chrony.conf` 中添加以下一行,如果还没有的话: + +``` +ntsdumpdir /var/lib/chrony +``` + +如果不想让 DHCP 提供的 NTP 服务器与你指定的服务器混在一起,请在 `chrony.conf` 中删除或注释以下一行: + +``` +sourcedir /run/chrony-dhcp +``` + +当你完成编辑 `chrony.conf` 后,保存你的更改并重新启动 `chronyd` 服务: + +``` +systemctl restart chronyd +``` + +### 检查客户端状态 + +在 root 用户下运行以下命令,检查 NTS 密钥建立是否成功: + +``` +# chronyc -N authdata +Name/IP address Mode KeyID Type KLen Last Atmp NAK Cook CLen +========================================================================= +time.cloudflare.com NTS 1 15 256 33m 0 0 8 100 +nts.sth1.ntp.se NTS 1 15 256 33m 0 0 8 100 +nts.sth2.ntp.se NTS 1 15 256 33m 0 0 8 100 +``` + +`KeyID`、`Type` 和 `KLen` 列应该有非零值。如果它们为零,请检查系统日志中是否有来自 `chronyd` 的错误信息。一个可能的故障原因是防火墙阻止了客户端与服务器的 TCP 端口(端口 4460)的连接。 + +另一个可能的故障原因是由于客户机的时钟错误而导致证书无法验证。这是 NTS 的先有鸡还是先有蛋的问题。你可能需要手动修正日期或暂时禁用 NTS,以使 NTS 正常工作。如果你的电脑有实时时钟,几乎所有的电脑都有,而且有好的电池做备份,这种操作应该只需要一次。 + +如果计算机没有实时时钟或电池,就像一些常见的小型 ARM 计算机(如树莓派)那样,你可以在 `/etc/sysconfig/chronyd` 中添加 `-s` 选项来恢复上次关机或重启时保存的时间。时钟会落后于真实时间,但如果电脑没有关机太久,服务器的证书也没有在离到期时间太近的时候更新,应该足以让时间检查成功。作为最后的手段,你可以用 `nocerttimecheck` 指令禁用时间检查。详情请参见`chrony.conf(5)` 手册页。 + +运行下面的命令来确认客户端是否在进行 NTP 测量: + +``` +# chronyc -N sources +MS Name/IP address Stratum Poll Reach LastRx Last sample +=============================================================================== +^* time.cloudflare.com 3 6 377 45 +355us[ +375us] +/- 11ms +^+ nts.sth1.ntp.se 1 6 377 44 +237us[ +237us] +/- 23ms +^+ nts.sth2.ntp.se 1 6 377 44 -170us[ -170us] +/- 22ms +``` + +`Reach` 列应该有一个非零值,最好是 377。上图所示的值 377 是一个八进制数,它表示最后八个请求都有有效的响应。如果启用了 NTS 的话,验证检查将包括 NTS 认证。如果该值一直很少或从未达到 377,则表明 NTP 请求或响应在网络中丢失了。众所周知,一些主要的网络运营商有中间机器,它可以阻止或限制大的 NTP 数据包的速率,以缓解利用 `ntpd` 的监控协议进行的放大攻击。不幸的是,这影响了受 NTS 保护的 NTP 数据包,尽管它们不会引起任何放大。NTP 工作组正在考虑为 NTP 提供一个替代端口,作为解决这个问题的办法。 + +### 在服务器上启用 NTS + +如果你有自己的 NTP 服务器,运行着 `chronyd`,你可以启用服务器的 NTS 支持,让它的客户端安全同步。如果该服务器是其他服务器的客户端,它应该使用 NTS 或对称密钥与之同步。客户端假设同步链在所有服务器到主时间服务器之间是安全的。 + +启用服务器 NTS 类似于在 Web 服务器上启用HTTPS。你只需要一个私钥和证书。例如,证书可以由 Let's Encrypt 权威机构使用 `certbot` 工具签署。当你有了密钥和证书文件(包括中间证书),在 `chrony.conf` 中用以下指令指定它们: + +``` +ntsserverkey /etc/pki/tls/private/foo.example.net.key +ntsservercert /etc/pki/tls/certs/foo.example.net.crt +``` + +确保之前在客户端配置中提到的 `ntsdumpdir` 指令存在于 `chrony.conf` 中。它允许服务器将其密钥保存到磁盘上,这样服务器的客户端在重启服务器时就不必获取新的密钥和 cookie 了。 + +重新启动 `chronyd` 服务: + +``` +systemctl restart chronyd +``` + +如果系统日志中没有来自 `chronyd` 的错误信息,那么它应该是可以接受客户端连接的,如果服务器有防火墙,则需要同时允许 UDP 123 和 TCP 4460 端口的 NTP 和 NTS-KE 服务。 + +你可以用下面的命令在客户端机器上进行快速测试: + +``` +$ chronyd -Q -t 3 'server foo.example.net iburst nts maxsamples 1' +2020-10-13T12:00:52Z chronyd version 4.0 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 +DEBUG) +2020-10-13T12:00:52Z Disabled control of system clock +2020-10-13T12:00:55Z System clock wrong by -0.001032 seconds (ignored) +2020-10-13T12:00:55Z chronyd exiting +``` + +如果你看到一个“System clock wrong”消息,说明它是正确工作的。 + +在服务器上,你可以使用下面的命令来检查它已经处理了多少个 NTS-KE 连接和认证的 NTP 数据包: + +``` +# chronyc serverstats +NTP packets received : 2143106240 +NTP packets dropped : 117180834 +Command packets received : 16819527 +Command packets dropped : 0 +Client log records dropped : 574257223 +NTS-KE connections accepted: 104 +NTS-KE connections dropped : 0 +Authenticated NTP packets : 52139 +``` + +如果你看到非零的 “NTS-KE connections accepted” 和 “Authenticated NTP packets”,这意味着至少有一些客户端能够连接到 NTS-KE 端口,并发送一个认证的 NTP 请求。 + +[^1]: Fedora 33 Beta 安装程序包含一个较旧的 Chrony 预发布版本,它不能与当前的 NTS 服务器一起工作,因为 NTS-KE 端口已经改变。因此,在安装程序中的网络时间配置中,服务器总是显示为不工作。安装后,需要更新 chrony 包,才能与当前的服务器配合使用。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/secure-ntp-with-nts/ + +作者:[Miroslav Lichvar][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/mlichvar/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/10/secure-ntp-with-nts-816x345.jpg +[2]: tmp.rl0XC1HIGm#footnote1 +[3]: https://tools.ietf.org/html/rfc8915 +[4]: https://www.pool.ntp.org +[5]: https://developers.cloudflare.com/time-services/nts/usage +[6]: https://www.netnod.se/time-and-frequency/how-to-use-nts +[7]: https://fedoramagazine.org/wp-content/uploads/2020/10/anaconda-nts.png From dc7192f7ef219efbdbb4f790edabb53efd00f1cf Mon Sep 17 00:00:00 2001 From: DarkSun Date: Sat, 21 Nov 2020 05:02:56 +0800 Subject: [PATCH 035/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201120=20?= =?UTF-8?q?How=20we=20develop=20success=20metrics=20for=20open=20source=20?= =?UTF-8?q?events?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201120 How we develop success metrics for open source events.md --- ... success metrics for open source events.md | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 sources/tech/20201120 How we develop success metrics for open source events.md diff --git a/sources/tech/20201120 How we develop success metrics for open source events.md b/sources/tech/20201120 How we develop success metrics for open source events.md new file mode 100644 index 0000000000..392164e686 --- /dev/null +++ b/sources/tech/20201120 How we develop success metrics for open source events.md @@ -0,0 +1,98 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How we develop success metrics for open source events) +[#]: via: (https://opensource.com/article/20/11/chaoss-open-source-events) +[#]: author: (Neofytos Kolokotronis https://opensource.com/users/neofytosk) + +How we develop success metrics for open source events +====== +The CHAOSS App Ecosystem Working Group is establishing ways to measure +how well virtual and in-person events meet their goals. +![Metrics and a graph illustration][1] + +As many open source communities grow larger and older, they may face problems managing members' engagement. People turn towards metrics to understand large systems and prioritize resources, but there has not been a consensus set of metrics for understanding open source communities. + +The Community Health Analytics Open Source Software ([CHAOSS][2]) project, a Linux Foundation-sponsored community of industry professionals and academics, is working to solve this problem by defining metrics for open source projects. The CHAOSS project focused first on developing metrics for open source event organizers because open source communities often depend on events like hackathons, meetups, conferences, and user group meetings to grow their communities and work on important project updates. + +The [CHAOSS App Ecosystem Working Group][3], which developed the metrics for events and worked together on this article, is comprised of [members][4] who have organized and participated in many open source events. While we developed these metrics to help the GNOME and KDE communities, we believe they can help other open source event organizers create their own metrics strategy. We also hope that more people will be inspired by this work and join us to improve it. + +### How we began + +The CHAOSS App Ecosystem Working Group emerged from the [SCALE 18x][5] conference in March 2020, when CHAOSS and GNOME members began talking about how to measure the [Linux App Summit][6] (LAS) community, an event co-hosted by GNOME and KDE.  + +We realized that we did not have sufficient data to measure our progress towards LAS's goals, and that hindered our ability to make important decisions to support those goals. For LAS (and the whole Linux app ecosystem) to thrive, we recognized the need to be more data-driven in our approach. We also realized the importance of extending this mindset to other similarly organized communities. + +From our experience at [CHAOSScon][7], we found opportunities to partner with the CHAOSS community around open source metrics. Therefore, we organized ourselves under the CHAOSS project, which provides a platform for working on metrics. + +We chose the name App Ecosystem Working Group because one of the GNOME and KDE communities' primary goals is to grow the Linux app ecosystem. Although we had the GNOME and KDE communities in mind at the start, we are creating the metrics to help everyone involved in the effort to grow the Linux app ecosystem. + +We chose to begin with the event organizer use case because of the nature of events: Events tend to have clearly defined boundaries, with a set start and end date, a list of registered attendees, and activities like talks, presentations, and workshops. This clarity does not generally exist in open source projects and communities, where the various projects, contributors, and users are less often strictly defined. + +The GNOME and KDE communities both had events coming up in 2020, so we believed we could iterate faster using feedback gathered from the events we organized, separately and together. + +### Approach to data gathering + +The CHAOSS project uses the [goal-question-metric][8] (GQM) approach to gathering data. One problem with metrics is that often we try to measure everything without understanding how the data will be helpful. But data should help inform decisions. Therefore, the GQM approach starts with a list of high-level goals that are important to a particular persona. + +The goals are the community's strategic objectives. For each goal, we look at questions that help determine whether we are achieving the goal. Metrics then provide quantitative information that helps answer those questions. + +Before diving into metrics, the App Ecosystem Working Group brainstormed goals and the personas that those goals affect. We collected [17 different goals][9], spread across seven stakeholder personas, that a community or project ecosystem might have. + +We collected and curated these goals from community members' experience in major open source projects like GNOME and KDE. Although each community is different, we think most of these goals are relevant to and will help a wide variety of open source projects. + +### Metrics for event organizers + +The [full list of metrics for event organizers][10] focus on three goals that event organizers care about: + + * Attracting and retaining contributors + * Understanding company contributions to an event + * Ensuring events contribute towards diversity goals and closing skill gaps in the community + + + +We came up with 19 questions that event organizers have about how well they are doing in reaching these goals. The metrics are directly linked to these questions to give the event organizers actionable insights. + +### Privacy implications + +While this work was developed by and for the GNOME and KDE communities, we hope that the metrics will help other open source communities. + +While GNOME and KDE have not implemented the metrics yet (and do not yet have a timeline to do so), one known limitation is privacy concerns around data collection. Every geographic location has laws that may limit data collection, which open source and free software projects must take into account. + +Once GNOME and KDE implement these metrics in their communities, they plan to share the legal considerations they took into account. + +### Join us + +We are hopeful that these metrics will be useful to open source event organizers interested in integrating virtual and in-person events into their community-building and engagement strategies. + +If you'd like to participate in developing these metrics, we welcome your experience, insight, and voice! The CHAOSS App Ecosystem Working Group [meets biweekly][11]; please join us. + +You can also communicate with us asynchronously through our [GitHub repository][3]. For more information on other ways to contribute or connect with us, we encourage you to visit the [CHAOSS community participation page][12]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/11/chaoss-open-source-events + +作者:[Neofytos Kolokotronis][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/neofytosk +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_graph_stats_blue.png?itok=OKCc_60D (Metrics and a graph illustration) +[2]: https://chaoss.community/ +[3]: https://github.com/chaoss/wg-app-ecosystem +[4]: https://github.com/chaoss/wg-app-ecosystem#contributors +[5]: https://www.socallinuxexpo.org/scale/18x +[6]: https://linuxappsummit.org/ +[7]: https://chaoss.community/chaosscon-2020-eu/ +[8]: https://en.wikipedia.org/wiki/GQM +[9]: https://docs.google.com/document/d/1ghREXIO5C9PLiwXMtouOR4AjPLGz9pD34LIxO8N2-xo/edit +[10]: https://github.com/chaoss/wg-app-ecosystem/blob/master/event-organizers.md +[11]: https://github.com/chaoss/wg-app-ecosystem#workflow +[12]: https://chaoss.community/participate From a14e9e4c31cd7ce81c451a7221f930ba40baa491 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Sat, 21 Nov 2020 05:03:09 +0800 Subject: [PATCH 036/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201120=20?= =?UTF-8?q?What=20do=20open=20source=20product=20teams=20do=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201120 What do open source product teams do.md --- ...20 What do open source product teams do.md | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 sources/tech/20201120 What do open source product teams do.md diff --git a/sources/tech/20201120 What do open source product teams do.md b/sources/tech/20201120 What do open source product teams do.md new file mode 100644 index 0000000000..c227ff3b8e --- /dev/null +++ b/sources/tech/20201120 What do open source product teams do.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What do open source product teams do?) +[#]: via: (https://opensource.com/article/20/11/open-source-product-teams) +[#]: author: (Scott McCarty https://opensource.com/users/fatherlinux) + +What do open source product teams do? +====== +Product managers play an essential role in creating differentiated value +that customers will pay for. +![a checklist for a team][1] + +If you go to any hip product management conference, you'll hear about product teams. At a minimum, a product team has a product manager, but it often includes roles in marketing, technical architecture, and even user experience (UX). Previous articles in this series have covered [open source as a supply chain model][2] and [defining products in the open source software supply chain][3], and this article specifically focuses on the role of product management within the product team. + +### Who's on the product team? + +Product managers and product marketing managers are the two most common product management roles, but product management can be further split into any number of roles, including competitive analysis, business strategy, sales enablement, revenue growth, content creation, sales tools, and more. With a very large product, even the product management role may be broken up into separate roles. You may even hear titles like technical marketing manager, product evangelist, and business owner, not to mention people-management roles for groups of individual contributor roles. For the purpose of this article, I refer to all of these roles collectively as "product management." + +Product management is a [tough career][4], and there are many frameworks for learning and understanding it. One of the oldest and most mature is the [Pragmatic Framework][5], which defines 37 different areas of responsibility. The Pragmatic Framework is a bit too complex for this article. Instead, I'll emphasize a subset of tasks that are applicable in open source products: + + * **Market problems:** Talk to customers and figure out what they need + * **Product roadmap:** Determine what features will be added to the product and when + * **Build:** Invest in building technology in-house + * **Buy:** Purchase technology from another company + * **Partner:** Deliver a solution to a customer by leveraging a partner's technology + * **Pricing:** Determine the price + * **Packaging:** Determine what's included in the price + * **Channel training:** Train the salespeople so that they can educate potential customers + + + +The rest of this series will look into how these different roles affect and are affected by an open source supply chain. + +### Build, buy, or partner? + +Which is more important, the business need or the technology? This is probably the classic paradox of business strategy. The answer is neither. Execution is what matters. The product management team is tasked with creating and retaining customers. This can be done by building technology, buying technology, or partnering to acquire technology or services that, when combined, provide value to customers. For example, if customers need an encryption feature that's missing from a software product, the product manager can: + + * Ask engineering to build it, test it, document it, and maintain it. + * Influence the executive team to buy a company or software package that provides it. (However, less than 2% of product managers have access to P&L data, [much less the budget to buy companies][6].) + * Deliver it to the customer through a verified partner. If a partner already provides a solution, this is the quickest way to deliver a solution, but it could raise the product's price or require the customer to purchase additional software. + + + +With traditional proprietary software products and services, this could mean building, buying, or partnering for a foundational piece of software, like a database. With products built on open source software, this can be thought of as choosing an open source project as a supplier. The purchase is made by contributing engineering time, code, documentation, testing, infrastructure, etc. Because open source is not free as in beer, somebody has to write it, test it, document it, etc. It's very difficult to provide value to customers if you don't contribute upstream. + +This combination of built, bought, and partner-delivered capabilities is what differentiates a product, whether open source or proprietary. Proprietary licensing does not differentiate a product. Let me repeat: _proprietary licensing does not differentiate a product_. People confuse proprietary licensing with providing value to a customer. Proprietary licenses are a perfectly valid and useful way to monetize users, but they do not provide customers with more value. Licenses do not create value; they help extract it. If you believe [open core][7] or hybrid licensing are the only way to make money with open source, read this paragraph five times until it sinks in (hint, focus on creating value). + +Both open source and proprietary products must create value. Customers buy capabilities as part of a solution (i.e., new things they couldn't do before). If product management spends more brainpower on delivering capabilities than determining what can be held back with proprietary licensing, the customer will be happier, more loyal, and receive more value. + +### Types of products built on open source + +Most modern software products are delivered by adding new value to the value provided by the open source supply chain. This could include extra downstream testing, documentation, quality engineering, performance testing, security testing, industry certifications, a partner ecosystem, training, professional services, or even extra proprietary code not included upstream (open core). By considering this new model, many of the old debates about open source can be clarified: + + * **Open source products:** The entire supply chain of code that goes into the product is open source. This can include multiple upstream projects like enterprise Linux distributions or sophisticated products like [Red Hat Satellite][8] or [OpenShift][9]. + * **Open core products:** Some of the supply chain of code that goes into the product is open source while other parts are proprietary. This mix of licensing can be used to control pricing, packaging, and distribution. It can also have the downside of putting engineering contributions to the product at odds with the open source supply chain (see _[Goodbye open core—good riddance to bad rubbish][10]_). + * **Paid software-as-a-service products:** The supply chain of SaaS products can be made up of open source languages and libraries, while the business logic built in-house is often proprietary. This allows product managers to tightly control pricing and packaging through very measurable distribution channels. There are many examples of online companies using this model, including customer resource management platforms, databases, caching layers, identity management, document management, and office and email solutions. + * **Free SaaS products:** The supply chain of free SaaS products (e.g., Facebook, Google Search, YouTube, etc.) is essentially the same as paid SaaS products. Instead of tightly controlling the pricing and packaging, the product is monetized through user data or advertisements. + * **Cloud providers vs. software vendors:** The recent interest in and creation of new quasi-open source licenses like the [Server Side Public License][11], [Redis Source Available License][12], or [PolyForm][13] are better understood by thinking of open source as a supply chain and SaaS as a pricing and packaging model. These new licenses exert some control on how buyers from the open source supply chain can price and package their products (e.g., limiting how a large cloud provider can deliver a service built on freely available code and binaries). This is not unheard of, even in traditional manufacturing supply chains. It's a defensive play because these licenses don't deliver new value to customers. + * **Open source as awareness:** In this model, the buzz around the upstream project is used to deliver awareness for the products built on it. In marketing, awareness of a technology is a critical first step for having a product's customers build on it. For example, if users are aware of and believe in Kubernetes, they are potential customers for products built on Kubernetes; when people looking for a Kubernetes solution hear that your product is built on Kubernetes, they immediately become potential customers. In a way, this is similar to Lenovo laptops advertising "Intel inside" or [Arm & Hammer laundry detergent advertising OxiClean][14] as part of their supply chain. If you like OxiClean, you'll love Arm & Hammer detergent. + * **Open core as marketing:** This goes a step further than open source as awareness. A single vendor almost always controls the upstream open source projects that go into open core products. They attempt to use the supply chain, often unsuccessfully, to generate market awareness in what's perceived to be free or inexpensive marketing and lead generation. Open core products advertise that they include the open source project to provide core value propositions. Going back to the Arm & Hammer example: If you like open source, you'll love our proprietary software with open source goodness inside. + + + +### The supply chain + +Continuing the analogy from my [last article][3], when General Motors develops a car, the product team doesn't tell Bosch what fuel injectors they want. They tell Bosch how much power the new vehicle will generate, how much towing capacity it needs to have, etc. They give Bosch a set of technical requirements. Then Bosch provides GM with a fuel-injection solution that not only includes the fuel injectors but also the wiring harnesses and perhaps even software that makes it run. It's cheaper and often better quality to rely on a supply chain for components that are shared among virtually every vehicle in the marketplace. + +Like an automobile, the sum of a software product is greater than the individual parts. When a manufacturer delivers a car, it's more than the braking, steering, power plant, infotainment system, financing, and mechanical service program. It has an associated brand, build quality, reliability, and an experience. Most of the parts aren't differentiated between vendors. Software products, especially ones built on an open source supply chain, are no different. Product management needs to differentiate their products from the underlying software components in the supply chain. The value of a software product is a layer of differentiation built on top of a supply chain of dependencies. This value is what product management must focus on. + +### Differentiated value + +Product management is not about picking and choosing what bugs are fixed upstream or downstream. It's not about holding back enough value in the open source project so that users purchase the product. It's not about coming up with special licenses to monetize an open source project's user base. It's about creating differentiated value that customers will pay for. It's about listening to their needs, internalizing them, and knowing them intimately. It's about influencing a supply chain, switching supply chains, and building a partner ecosystem that gives your product gravity. + +Product managers who think about differentiated value on top of an open source supply chain can easily answer the following questions: + + * As an open source product manager, should I attend conferences for the upstream projects? _Sure, because it's like attending a trade show for one of your suppliers._ + * How should product management handle a situation where the upstream project isn't delivering what their customers need? _Add more investment. If the open source community is healthy, it will produce what you need._ + * What should product management do when an upstream community is struggling with contributions or is unhealthy? _The same thing that a manufacturer would do if their supplier lost contracts with their two biggest competitors because they were failing: switch suppliers._ + + + +In the next article, I will delve into the distinct value created in products, focusing on the value that upstream projects can't provide. If product management is done well, there is no unnatural tension between upstream suppliers and downstream products. When done right, both the upstream projects and downstream products create unique and differentiated value that satisfies the needs of users and customers alike. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/11/open-source-product-teams + +作者:[Scott McCarty][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/fatherlinux +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/checklist_hands_team_collaboration.png?itok=u82QepPk (a checklist for a team) +[2]: https://opensource.com/article/20/10/open-source-supply-chain +[3]: https://opensource.com/article/20/10/defining-product-open-source +[4]: https://www.mindtheproduct.com/forget-product-management-tough-career/ +[5]: https://www.pragmaticinstitute.com/framework +[6]: http://developmentcorporate.com/2019/04/02/the-myth-of-the-product-management-pl/ +[7]: https://medium.com/open-consensus/2-open-core-definition-examples-tradeoffs-e4d0c044da7c +[8]: https://en.wikipedia.org/wiki/Satellite_(software) +[9]: https://en.wikipedia.org/wiki/OpenShift +[10]: https://medium.com/@adamhjk/goodbye-open-core-good-riddance-to-bad-rubbish-ae3355316494 +[11]: https://www.mongodb.com/licensing/server-side-public-license +[12]: https://redislabs.com/wp-content/uploads/2019/03/Redis-Source-Available-License-PDF-2.pdf +[13]: https://polyformproject.org/licenses/ +[14]: https://www.armandhammer.com/laundry/liquid-laundry-detergent/liquid-laundry-detergent/plus-oxiclean-with-fade-defense-liquid-laundry-detergent From 52e51f02a9c980df92a5640f409fbdc9e9b0eaf5 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Sat, 21 Nov 2020 05:03:23 +0800 Subject: [PATCH 037/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201119=20?= =?UTF-8?q?Day=209:=20Generating=20a=20lot=20of=20nonsense=20with=20an=20R?= =?UTF-8?q?NN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201119 Day 9- Generating a lot of nonsense with an RNN.md --- ...enerating a lot of nonsense with an RNN.md | 151 ++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 sources/tech/20201119 Day 9- Generating a lot of nonsense with an RNN.md diff --git a/sources/tech/20201119 Day 9- Generating a lot of nonsense with an RNN.md b/sources/tech/20201119 Day 9- Generating a lot of nonsense with an RNN.md new file mode 100644 index 0000000000..5b6c7c22f6 --- /dev/null +++ b/sources/tech/20201119 Day 9- Generating a lot of nonsense with an RNN.md @@ -0,0 +1,151 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Day 9: Generating a lot of nonsense with an RNN) +[#]: via: (https://jvns.ca/blog/2020/11/19/day-9--generating-a-lot-of-nonsense-with-an-rnn/) +[#]: author: (Julia Evans https://jvns.ca/) + +Day 9: Generating a lot of nonsense with an RNN +====== + +Hello! On Monday I posted about [generating faces with sketch-rnn][1], which I did using a pre-trained RNN model. + +I want to train that model to genreate more complicated faces (which may or may not work!), but I decided that since I knew literally nothing about neural networks it would be good to start with something simpler: [this char-rnn model from Karpathy that generates text that sounds vaguely Shakespearean][2]. + +After spending some time playing with Tensorflow, I decided to use PyTorch with the [fast.ai][3] helper libraries because it’s what my friend Ray was using for his project. + +Here are some initial things I’ve learned about training neural networks. All of this is pretty disjointed and I still have no idea what I’m doing. + +### there are a lot of tensors + +All the data seems to be tensors! A 1-d tensor is a vector, a 2-d tensor is a matrix, and a 3-d tensor is, well, who knows. This is a little new but I have some vague intuition about tensor products from learning about quantum computing ten [years][4] ago so this seems okay. + +They seem not too bad to manipulate, like `tensor.flatten()` will flatten a multidimensional tensor into a vector. I still feel a bit uncertain about the exact order things get flattened in, I need to experiment & think it through. + +The word “dimension” for tensors is also used in a different way than I expected, like I’d usually think that the “dimension” of a 8x9 matrix is 72 (becuase that’s the dimension of the vector space of 8x9 matrices), but in Torch land the “dimension” of a 8x9 matrix seems to be 2. That seems fine though. + +### there are a lot of dimension mismatches + +I’ve spent a lot of hours over the last couple of days staring at error messages like + +``` +ValueError: Expected target size (77, 64) got torch.Size (77, 70) +``` + +Some reasons I’ve gotten errors like this so far + + * I tried to pass a 3-dimensional tensor to a loss function that wanted a 2-dimensional tensor + * I forgot to embed my input data (which is a bunch of class labels) into a higher dimensional space so that every number turns into a 64-dimensional vector + * I multiplied a vector by a matrix with the wrong dimensions + + + +Something that I find a bit confusing about the tensors and dimension mismatches is that a lot of the time you seem to be able to pass in both a 2-dimensional tensor and a 3-dimensional tensor to the same method. For example, if I have a 2x3 matrix, I can multiply that by a 3x4 tensor, or by a 3x4x89 tensor, or by a 3x92x12x238 tensor, or whatever. This corresponds to what I remember about tensors from quantum computing, but I find a bit harder to think about in terms of numbers in a matrix on a computer. + +I tweeted about this and a bunch of people agreed with me that they have also spent a bunch of time debugging dimension mismatches so at least I’m not alone :) + +### the cross entropy loss in pytorch isn’t the cross entropy + +A “loss function” is basically a function you use to check how similar 2 vectors are. Lower is better. + +Today I got pretty confused because I was trying to compute the cross entropy loss for two identical vectors, and the result wasn’t 0! I thought that the result was going to be 0, because the vectors were identical! + +It turns out that in PyTorch the “cross entropy loss” of x and y isn’t actually the [cross entropy][5] of x and y (which would be 0 if x and y are identical!), instead it’s `cross_entropy(softmax(x), y)` – you apply a “softmax” function to x first. + +### it goes a LOT faster with a GPU + +At some point I was training a model on a CPU, and then I switched to a GPU and every batch trained literally 10x faster. + +### colab is pretty useful + +I’ve been using Google’s [Colab][6], which seems to be a fork of Jupyter notebook. It comes with some free GPUs that you can use, which is nice. + +The main annoying thing I’ve run into about Colab is that they pretty aggressively kill your running notebooks if they’re idle to reduce resource usage. This is actually fine on its own (you can save your data to Google Drive and restore it!). + +BUT as far as I can tell, if I want to use the Google Drive to get my files, I need to reauthenticate the notebook to Google Drive every single time by clicking a link and pasting in an OAuth (or something) code. I don’t really understand why it can’t just authenticate me once and then have it work forever. + +### it’s bad if your training loss never goes down + +I’ve been having the same problem for most of yesterday and today, which is that I have a model and some training data, and when I try to train the model my training loss never improves, which measn that basically the model isn’t training. + +And then when I make predictions from the model, I get results like this: + +``` +eto e enaih eet codosueonites st tne esee ob nmnoesnrertieieeu ooe +``` + +which makes it seem like it’s learned _something_ – those letters are common letters in the English language, sure! It’s better than generating `zxisqqqqxw`, which is more like the results I’d expect if the network hadn’t learned anything at all. But it definitely hasn’t learned a lot. + +### some code that does not work + +If you’re interested in what some code for an RNN that DOES NOT WORK looks like, here’s [the code I’ve written so far][7] + +the neural network part looks like this: + +``` +class RNN(nn.Module): + def __init__(self): + super().__init__() + self.i2h = nn.Linear(nv, nh) # Wxh + self.h2h = nn.Linear(nh, nh) # Whh + self.h2o = nn.Linear(nh, nv) # Why + self.hidden = torch.zeros(1, nh).cuda() + + def forward(self, input): + x = self.i2h(torch.nn.functional.one_hot(input, num_classes=nv).type(torch.FloatTensor).cuda()) + y = self.h2h(self.hidden) + hidden = torch.tanh(y + x) + self.hidden = hidden.detach() + z = self.h2o(hidden) + return z +``` + +and it basically sets up a bunch of matrices that are meant to correspond to this code from Karpathy’s blog post: + +``` +def step(self, x): + # update the hidden state + self.h = np.tanh(np.dot(self.W_hh, self.h) + np.dot(self.W_xh, x)) + # compute the output vector + y = np.dot(self.W_hy, self.h) + return y +``` + +but unlike his code, it does not generate text that looks vaguely Shakespeare after I train it, it generates gibberish! Maybe tomorrow I will find out why. + +Here’s a snippet of code that samples from the model’s output probability vector using a “temperature” – at a very low temperature it just always picks the letter that the model thinks is most likely (which by the way right now in my case is LITERALLY ALWAYS A SPACE which is also a sign that something is wrong). At higher temperatures it might pick another likely letter. + +``` +temperature = 1 +prediction_vector = F.softmax(learn.model(x)[0]/temperature) +v.textify(torch.multinomial(prediction_vector, 1).flatten(), sep='') +``` + +### that’s all! + +As usual when I learn things I am mostly trying to do it without reading any books or watching any videos – there’s this whole video course from that seems pretty good, but for whatever reason I prefer to just bang my head against a problem I’m trying to solve until I get VERY CONFUSED and then resort to reading things that might help me understand what’s going on then. So that’s the plan, we’ll see how it goes. + +It’s been pretty fun so far, I know a bunch of things about loss functions that I didn’t know before at least, and now I kind of know what a softmax is! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2020/11/19/day-9--generating-a-lot-of-nonsense-with-an-rnn/ + +作者:[Julia Evans][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://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://lots-of-sketchrnn-faces.netlify.app/ +[2]: https://karpathy.github.io/2015/05/21/rnn-effectiveness/ +[3]: https://www.fast.ai/ +[4]: https://github.com/jvns/masters-thesis/ +[5]: https://en.wikipedia.org/wiki/Cross_entropy +[6]: https://colab.research.google.com/ +[7]: https://gist.github.com/jvns/ce24d85c9d645c32b0d552b69359979f From b46ba16213a6c283314dce2777b1ccc816383976 Mon Sep 17 00:00:00 2001 From: niko Date: Sat, 21 Nov 2020 15:51:41 +0800 Subject: [PATCH 038/139] frogOAO translating --- ...tualBox -With Steps for USB, Clipboard and Folder Sharing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md b/sources/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md index 1d5095113f..69b067c82b 100644 --- a/sources/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md +++ b/sources/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (frogOAO) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) From 3cbbd1432a8db41b893c4acb5cd0d8b4e2dc24b1 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Sat, 21 Nov 2020 21:44:44 +0800 Subject: [PATCH 039/139] PRF @geekpi --- ...cher on Linux for Making Live Linux USB.md | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/translated/tech/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md b/translated/tech/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md index bb8aa29cde..00313094e7 100644 --- a/translated/tech/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md +++ b/translated/tech/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md @@ -1,22 +1,24 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) +[#]: reviewer: (wxy) [#]: publisher: ( ) [#]: url: ( ) [#]: subject: (How to Install and Use Etcher on Linux for Making Live Linux USB) [#]: via: (https://itsfoss.com/install-etcher-linux/) [#]: author: (Ankush Das https://itsfoss.com/author/ankush/) -如何在 Linux 上安装和使用 Etcher 来制作 Live Linux USB +如何在 Linux 上安装和使用 Etcher 来制作 Linux 临场 USB ====== -_**Etcher 是一款流行的 USB 烧录应用,可用于创建可启动的 Linux USB。让我来告诉你如何安装它,以及如何使用它来制作一个 Live Linux 盘。**_ +![](https://img.linux.net.cn/data/attachment/album/202011/21/214209xor9upp7jznd9djd.jpg) + +> Etcher 是一款流行的 USB 烧录应用,可用于创建可启动的 Linux USB。让我来告诉你如何安装它,以及如何使用它来制作一个 Linux 临场盘。 ### Etcher:一个用于在 SD 卡和 USB 驱动器中烧录 Linux ISO 的开源工具 Etcher 是一个由 [Balena][1] 开发的开源项目,来用于为树莓派烧录 SD 卡。事实上,我们在[如何在 SD 卡上安装 Raspbian OS][2] 的教程中就使用了它。 -它不仅仅局限于 SD 卡,你还可以使用 Etcher 来[制作一个可启动的 USB 驱动器][3],就像我们在它的帮助下在 Linux 中制作了一个 [Manjaro 的 Live USB][4]。 +它不仅仅局限于 SD 卡,你还可以使用 Etcher 来[制作一个可启动的 USB 驱动器][3],我们就通过它的帮助在 Linux 中制作了一个 [Manjaro 的临场 USB][4]。 自首次发布以来,Etcher 就以其整洁的界面和简单的使用方式引起了人们的注意。 @@ -33,9 +35,7 @@ Etcher 是一个由 [Balena][1] 开发的开源项目,来用于为树莓派烧 * 快速烧录 * 简单的三步过程 - - -理论上,你已经有了在 SD 卡和 USB 驱动器上烧录操作系统镜像所需的一切。同样令人激动的是,他们计划根据他们的[路线图][6],增加对多个设备的同步写入支持。 +理论上,你已经有了在 SD 卡和 USB 驱动器上烧录操作系统镜像所需的一切。同样令人激动的是,根据他们的[路线图][6],他们计划增加对多个设备的同步写入支持。 ### 在 Linux 上安装 Etcher @@ -45,10 +45,9 @@ Etcher 是一个由 [Balena][1] 开发的开源项目,来用于为树莓派烧 ![][8] - 在我的例子中,我下载了 Ubuntu 的 64 位 AppImage 文件。你可以通过我们的指南来了解[在 Linux 上使用 AppImage文件][9],但我会让你先知道下一步需要做什么。 -你需要给文件执行权限,你可以右击**AppImage 文件 -> 属性**来实现。 +你需要给文件执行权限,你可以右击**AppImage 文件 -> 属性**来实现。 ![][10] @@ -62,19 +61,19 @@ Etcher 是一个由 [Balena][1] 开发的开源项目,来用于为树莓派烧 你也可以参考我们的[在 Ubuntu 中使用 deb 文件][13]来安装应用。 -注意! - -我们注意到,当你使用 Etcher 创建 Linux 发行版的 Live USB 时,它会使 USB 处于明显的不可使用状态,即它只有几 MB 的空闲空间,并且不能直接格式化。在 Linux 上,你可以[使用磁盘工具手动删除分区,然后格式化它][14]。 +> 注意! +> +> 我们注意到,当你使用 Etcher 创建 Linux 发行版的临场 USB 时,它会使 USB 处于明显的不可使用状态,即它只有几 MB 的空闲空间,并且不能直接格式化。在 Linux 上,你可以[使用磁盘工具手动删除分区,然后格式化它][14]。 ### 在 Linux 上使用 Etcher 只需三步就可以开始使用 Etcher。在你启动它之后,根据屏幕上的提示应该是清晰的,但为了给你一个好的开始,以下是你要做的事情: -**步骤 1:**选择合适的 ISO 镜像文件或你需要烧录的文件的 URL(如下图所示)。 +**步骤 1:** 选择合适的 ISO 镜像文件或你需要烧录的文件的 URL(如下图所示)。 ![][15] -**步骤 2:**接下来,你需要选择目标设备。它会自动检测并高亮显示可移动设备,以防止你选择任何内部存储位置。 +**步骤 2:** 接下来,你需要选择目标设备。它会自动检测并高亮显示可移动设备,以防止你选择任何内部存储位置。 ![][16] @@ -82,7 +81,7 @@ Etcher 是一个由 [Balena][1] 开发的开源项目,来用于为树莓派烧 ![][17] -**步骤 3:**现在,你所有需要做的就是烧录镜像并等待它成功完成。 +**步骤 3:** 现在,你所有需要做的就是烧录镜像并等待它成功完成。 ![][18] @@ -94,11 +93,11 @@ Etcher 是一个由 [Balena][1] 开发的开源项目,来用于为树莓派烧 ![][20] -[Download balenaEtcher][7] +- [下载 balenaEtcher][7] ### 总结 -Etcher 是一个有用的工具,可以为 SD 卡和 USB 驱动器烧录操作系统镜像。我倾向于主要使用它来创建 Live USB 驱动器来测试 Linux 发行版,我对它很满意。 +Etcher 是一个有用的工具,可以为 SD 卡和 USB 驱动器烧录操作系统镜像。我倾向于主要使用它来创建临场 USB 驱动器来测试 Linux 发行版,我对它很满意。 你更喜欢用什么来创建可启动驱动器?你是否已经尝试过 Etcher?请在下面的评论中告诉我你的想法。 @@ -109,7 +108,7 @@ via: https://itsfoss.com/install-etcher-linux/ 作者:[Ankush Das][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From de3fa29c78adceb9040aa7f77a674a9856fc5e63 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Sat, 21 Nov 2020 21:56:34 +0800 Subject: [PATCH 040/139] PUB @geekpi https://linux.cn/article-12847-1.html --- ...stall and Use Etcher on Linux for Making Live Linux USB.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename {translated/tech => published}/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md (98%) diff --git a/translated/tech/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md b/published/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md similarity index 98% rename from translated/tech/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md rename to published/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md index 00313094e7..74ab8519d5 100644 --- a/translated/tech/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md +++ b/published/20201112 How to Install and Use Etcher on Linux for Making Live Linux USB.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) [#]: reviewer: (wxy) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12847-1.html) [#]: subject: (How to Install and Use Etcher on Linux for Making Live Linux USB) [#]: via: (https://itsfoss.com/install-etcher-linux/) [#]: author: (Ankush Das https://itsfoss.com/author/ankush/) From be6e59c65cb251853085ddd7890906a5fb05de90 Mon Sep 17 00:00:00 2001 From: MjSeven Date: Sun, 22 Nov 2020 00:00:46 +0800 Subject: [PATCH 041/139] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...roduction to mutation testing in Python.md | 160 ------------------ ...roduction to mutation testing in Python.md | 147 ++++++++++++++++ 2 files changed, 147 insertions(+), 160 deletions(-) delete mode 100644 sources/tech/20200720 An introduction to mutation testing in Python.md create mode 100644 translated/tech/20200720 An introduction to mutation testing in Python.md diff --git a/sources/tech/20200720 An introduction to mutation testing in Python.md b/sources/tech/20200720 An introduction to mutation testing in Python.md deleted file mode 100644 index 4a946fe59c..0000000000 --- a/sources/tech/20200720 An introduction to mutation testing in Python.md +++ /dev/null @@ -1,160 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (MjSeven) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (An introduction to mutation testing in Python) -[#]: via: (https://opensource.com/article/20/7/mutmut-python) -[#]: author: (Moshe Zadka https://opensource.com/users/moshez) - -An introduction to mutation testing in Python -====== -Turn invisible bugs into visible fixes with mutation testing. -![Searching for code][1] - -You have tests for everything; maybe you even have a badge in your project repository stating 100% test coverage. But what are these tests helping you do? How do you know? - -The _costs_ of unit tests are clear to developers. Tests have to be written. Occasionally they don't work as intended: there are false alarms or flapping tests that alternate success and failure without any code changes. The small bugs you can find through unit tests are valuable, but often they happen quietly on a developer machine and are fixed before a commit ever goes into version control. But the truly alarming bugs are mostly invisible. And the worst of all, the _missing alarms_ are completely invisible: you don't see the bugs you failed to catch until the code gets into a user's hands—and sometimes not even then. - -There is one type of test that makes it possible to make the invisible visible: [mutation testing][2]. - -Mutation testing algorithmically modifies source code and checks if any "mutants" survived each test. Any mutant that survives the unit test is a problem: it means that a modification to the code, likely introducing a bug, was not caught by the standard test suite. - -One framework for mutation testing in [Python][3] is `mutmut`. - -Imagine you need to write code that calculates the angle between the hour hand and the minute hand in an analog clock to the nearest degree. The code might look something like: - - -``` -def hours_hand(hour, minutes): -    base = (hour % 12 ) * (360 // 12) -    correction = int((minutes / 60) * (360 // 12)) -    return base + correction - -def minutes_hand(hour, minutes): -    return minutes * (360 // 60) - -def between(hour, minutes): -    return abs(hours_hand(hour, minutes) - minutes_hand(hour, minutes)) -``` - -To begin, write a simple unit test: - - -``` -import angle - -def test_twelve(): -    assert angle.between(12, 00) == 0 -``` - -Is this enough? The code has no `if` statement, so if you check coverage: - - -``` -$ coverage run `which pytest` -============================= test session starts ============================== -platform linux -- Python 3.8.3, pytest-5.4.3, py-1.8.2, pluggy-0.13.1 -rootdir: /home/moshez/src/mut-mut-test -collected 1 item                                                               - -tests/test_angle.py .                                                    [100%] - -============================== 1 passed in 0.01s =============================== -``` - -Perfect! The tests pass, and coverage is at 100%. Testing expert, you are. But what does that coverage look like when you use mutation testing? - - -``` -$ mutmut run --paths-to-mutate angle.py -<snip> -Legend for output: -🎉 Killed mutants.   The goal is for everything to end up in this bucket. -⏰ Timeout.          Test suite took 10 times as long as the baseline so were killed. -🤔 Suspicious.       Tests took a long time, but not long enough to be fatal. -🙁 Survived.         This means your tests needs to be expanded. -🔇 Skipped.          Skipped. -<snip> -⠋ 21/21  🎉 5  ⏰ 0  🤔 0  🙁 16  🔇 0 -``` - -Oh no. Out of 21 mutants, 16 survived. Only five cases passed the mutation testing. But what does that mean? - -For each mutation test, `mutmut` modified portions of your source code that simulates potential bugs. An example of a modification is changing a `>` comparison to `>=` to see what happens. If there is no unit test for this boundary condition, this mutation will "survive": this is a potential bug that none of the tests will detect. - -It's time to write better unit tests. It is easy to check which changes were made with `results`: - - -``` -$ mutmut results -<snip> -Survived 🙁 (16) - -\---- angle.py (16) ---- - -4-7, 9-14, 16-21 -$ mutmut apply 4 -$ git diff -diff --git a/angle.py b/angle.py -index b5dca41..3939353 100644 -\--- a/angle.py -+++ b/angle.py -@@ -1,6 +1,6 @@ - def hours_hand(hour, minutes): -     hour = hour % 12 -\-    base = hour * (360 // 12) -\+    base = hour / (360 // 12) -     correction = int((minutes / 60) * (360 // 12)) -     return base + correction -``` - -This is a typical example of a mutation `mutmut` performs; it analyzes the source code and changes operators to different operators: addition to subtraction or, in this case, multiplication to division. Unit tests, generally speaking, should catch bugs when an operator changes; otherwise, they are not testing the behavior effectively. Following this logic, `mutmut` twiddles through source code to double-check your tests. - -You can use `mutmut apply` to apply a failed mutant. Wow, it turns out you barely checked whether the `hour` parameter was used correctly. Fix that: - - -``` -$ git diff -diff --git a/tests/test_angle.py b/tests/test_angle.py -index f51d43a..1a2e4df 100644 -\--- a/tests/test_angle.py -+++ b/tests/test_angle.py -@@ -2,3 +2,6 @@ import angle -  - def test_twelve(): -     assert angle.between(12, 00) == 0 -+ -+def test_three(): -\+    assert angle.between(3, 00) == 90 -``` - -Previously, you tested only for 12. Will adding a test for three be enough to improve? - - -``` -$ mutmut run --paths-to-mutate angle.py -<snip> -⠋ 21/21  🎉 7  ⏰ 0  🤔 0  🙁 14  🔇 0 -``` - -This new test managed to kill two of the mutants—better than before, but still a long way to go. I won't work through each of the 14 cases left to fix, because I think the pattern is clear. (Can you get them down to zero?) - -Mutation testing is another tool, along with coverage measurement, that allows you to see how comprehensive your test suite is. Using it makes the case that tests need to be improved: any one of those surviving mutants is a mistake a human being can make while fat-fingering code, as well as a potential bug creeping into your program. Keep testing and happy hunting. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/20/7/mutmut-python - -作者:[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/search_find_code_python_programming.png?itok=ynSL8XRV (Searching for code) -[2]: https://opensource.com/article/19/8/mutation-testing-evolution-tdd -[3]: https://opensource.com/resources/python diff --git a/translated/tech/20200720 An introduction to mutation testing in Python.md b/translated/tech/20200720 An introduction to mutation testing in Python.md new file mode 100644 index 0000000000..f6bfc3ff6a --- /dev/null +++ b/translated/tech/20200720 An introduction to mutation testing in Python.md @@ -0,0 +1,147 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (An introduction to mutation testing in Python) +[#]: via: (https://opensource.com/article/20/7/mutmut-python) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +Python 突变测试简介 +====== +通过突变测试来修复未知的 bug。 +![Searching for code][1] + +你一定对所有内容都进行了测试,也许你甚至在项目仓库中有一个徽章,标明有 100% 的测试覆盖率,但是这些测试真的帮到你了吗?你怎么知道的? + +开发人员很清楚单元测试的 _成本_,必须编写测试。有时它们无法按照预期工作:存在假告警或者抖动测试。在不更改任何代码的情况下有时成功,有时失败。通过单元测试发现的小问题很有价值,但是通常它们悄无声息的出现在开发人员的机器上,并且在提交到版本控制之前就已得到修复。但真正令人担忧的问题大多是不可见的。最糟糕的是,_丢失的告警_ 是完全不可见的:你看不到没能捕获的错误,直到出现在用户手上--有时甚至连用户都看不到。 + +有一种测试可以使不可见的错误变为可见:[突变测试][2]。 + +变异测试通过算法修改源代码,并检查每次测试是否都有“变异体”存活。任何在单元测试中幸存下来的变异体都是问题:这意味着对代码的修改(可能会引入错误)没有被标准测试套件捕获。 + +[Python][3] 中用于突变测试的一个框架是 `mutmut`。 + +假设你需要编写代码来计算钟表中时针和分针之间的角度,直到最接近的度数,代码可能会这样写: +``` +def hours_hand(hour, minutes): +    base = (hour % 12 ) * (360 // 12) +    correction = int((minutes / 60) * (360 // 12)) +    return base + correction + +def minutes_hand(hour, minutes): +    return minutes * (360 // 60) + +def between(hour, minutes): +    return abs(hours_hand(hour, minutes) - minutes_hand(hour, minutes)) +``` + +首先,写一个简单的单元测试: +``` +import angle + +def test_twelve(): +    assert angle.between(12, 00) == 0 +``` + +足够了吗?代码没有 `if` 语句,所以如果你查看覆盖率: +``` +$ coverage run `which pytest` +============================= test session starts ============================== +platform linux -- Python 3.8.3, pytest-5.4.3, py-1.8.2, pluggy-0.13.1 +rootdir: /home/moshez/src/mut-mut-test +collected 1 item                                                               + +tests/test_angle.py .                                                    [100%] + +============================== 1 passed in 0.01s =============================== +``` + +完美!测试通过,覆盖率为 100%,你真的是一个测试专家。但是,当你使用突变测试时,覆盖率会变成多少? +``` +$ mutmut run --paths-to-mutate angle.py +<snip> +Legend for output: +🎉 Killed mutants.   The goal is for everything to end up in this bucket. +⏰ Timeout.          Test suite took 10 times as long as the baseline so were killed. +🤔 Suspicious.       Tests took a long time, but not long enough to be fatal. +🙁 Survived.         This means your tests needs to be expanded. +🔇 Skipped.          Skipped. +<snip> +⠋ 21/21  🎉 5  ⏰ 0  🤔 0  🙁 16  🔇 0 +``` + +天啊,在 21 个突变体中,只有 16 个存活。只有 5 个通过了突变测试,但是,这意味着什么呢? + +对于每个突变测试,`mutmut` 会修改部分源代码,以模拟潜在的错误,修改的一个例子是将 `>` 比较更改为 `>=`,查看会发生什么。如果没有针对这个边界条件的单元测试,那么这个突变将会“存活”:这是一个没有任何测试用例能够检测到的潜在错误。 + +是时候编写更好的单元测试了。很容易检查使用 `results` 所做的更改: +``` +$ mutmut results +<snip> +Survived 🙁 (16) + +\---- angle.py (16) ---- + +4-7, 9-14, 16-21 +$ mutmut apply 4 +$ git diff +diff --git a/angle.py b/angle.py +index b5dca41..3939353 100644 +\--- a/angle.py ++++ b/angle.py +@@ -1,6 +1,6 @@ + def hours_hand(hour, minutes): +     hour = hour % 12 +\-    base = hour * (360 // 12) +\+    base = hour / (360 // 12) +     correction = int((minutes / 60) * (360 // 12)) +     return base + correction +``` + +这是 `mutmut` 执行突变的一个典型例子,它会分析源代码并将运算符更改为不同的运算符:减法变加法。在本例中由乘法变为除法。一般来说,单元测试应该在操作符更换时捕获错误。否则,它们将无法有效地测试行为。按照这种逻辑,`mutmut` 会遍历源代码仔细检查你的测试。 + +你可以使用 `mutmut apply` 来应用失败的突变体。事实证明你几乎没有检查过 `hour` 参数是否被正确使用。修复它: +``` +$ git diff +diff --git a/tests/test_angle.py b/tests/test_angle.py +index f51d43a..1a2e4df 100644 +\--- a/tests/test_angle.py ++++ b/tests/test_angle.py +@@ -2,3 +2,6 @@ import angle +  + def test_twelve(): +     assert angle.between(12, 00) == 0 ++ ++def test_three(): +\+    assert angle.between(3, 00) == 90 +``` + +以前,你只测试了 12 点钟,现在增加一个 3 点钟的测试就足够了吗? + +``` +$ mutmut run --paths-to-mutate angle.py +<snip> +⠋ 21/21  🎉 7  ⏰ 0  🤔 0  🙁 14  🔇 0 +``` + +这项新测试成功杀死了两个突变体,比以前更好,当然还有很长的路要走。我不会一一解决剩下的 14 个测试用例,因为我认为模式已经很明确了。(你能将它们降低到零吗?) + +变异测试和覆盖率一样,是一种工具,它允许你查看测试套件的全面程度。使用它使得测试用例需要改进:那些幸存的突变体中的任何一个都是人类在篡改代码时可能犯的错误,以及潜伏在程序中的隐藏错误。继续测试,愉快地搜寻 bug 吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/7/mutmut-python + +作者:[Moshe Zadka][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/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/search_find_code_python_programming.png?itok=ynSL8XRV (Searching for code) +[2]: https://opensource.com/article/19/8/mutation-testing-evolution-tdd +[3]: https://opensource.com/resources/python From 3774f144c81fbe522139658c38ea470f4fd2cd14 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Sun, 22 Nov 2020 05:02:18 +0800 Subject: [PATCH 042/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201122=20?= =?UTF-8?q?How=20to=20Save=20the=20Output=20of=20a=20Command=20to=20a=20Fi?= =?UTF-8?q?le=20in=20Linux=20Terminal=20[Beginner=E2=80=99s=20Tip]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201122 How to Save the Output of a Command to a File in Linux Terminal -Beginner-s Tip.md --- ... File in Linux Terminal -Beginner-s Tip.md | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 sources/tech/20201122 How to Save the Output of a Command to a File in Linux Terminal -Beginner-s Tip.md diff --git a/sources/tech/20201122 How to Save the Output of a Command to a File in Linux Terminal -Beginner-s Tip.md b/sources/tech/20201122 How to Save the Output of a Command to a File in Linux Terminal -Beginner-s Tip.md new file mode 100644 index 0000000000..1abd6c775d --- /dev/null +++ b/sources/tech/20201122 How to Save the Output of a Command to a File in Linux Terminal -Beginner-s Tip.md @@ -0,0 +1,114 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Save the Output of a Command to a File in Linux Terminal [Beginner’s Tip]) +[#]: via: (https://itsfoss.com/save-command-output-to-file-linux/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +How to Save the Output of a Command to a File in Linux Terminal [Beginner’s Tip] +====== + +When you run a command or script in the Linux terminal, it prints the output on the screen for your immediate viewing. + +There will be times when you need to save the output to a file for future references. Now, [you can surely copy and paste in Linux terminal][1] but there are better ways to save the output of a shell script or command in Linux command line. Let me show them to you. + +### Method 1: Use redirection to save command output to file in Linux + +You can [use redirection in Linux for this purpose][2]. With redirection operator, instead of showing the output on the screen, it goes to the provided file. + + * The > redirects the command output to a file replacing any existing content on the file. + * The >> redirects adds the command output at the end of the existing content (if any) of the file. + + + +Use the STDOUT redirection operator > for redirecting the output to a file like this: + +``` +command > file.txt +``` + +If the file.txt doesn’t exist, it will be created automatically. If you use the > redirect again with the same file, the file content is replaced by the new output. + +The example below demonstrates it better. It first saves the output of _ls -l_ command. And then later, it replaces the content of the file with the output of _ls *.c_ command. + +![Redirecting command output to file][3] + +If you don’t want to lose the content of the existing file while saving the output of a script or command, use the redirection operation in append mode with >>. + +``` +command >> file.txt +``` + +This example demonstrates it better: + +![Redirecting command output to file in append mode][4] + +Even here if the file doesn’t exist, it is created automatically. + +Bonus Tip: Save Linux command output as well as error to a file + +If your Linux command returns an error, it doesn’t get saved in the file. You can save both the command output and command error in the same file using 2>&1 like this: + +**command > file.txt 2>&1** + +Basically, 0 stands for standard input, 1 for standard output and 2 for standard error. Here, you are redirecting (>) standard error (2) to same address (&) as standard output (1). + +### Method 2: Use tee command to display the output and save it to a file as well + +By the way, did you notice that when you send the command output to a file, you cannot see it anymore on the display? The [tee command in Linux][5] solves this problem for you. + +Like a tee pipe that sends water stream into two directions, the tee command send the output to the display as well as to a file (or as input to another command). You can use it like this: + +``` +command | tee file.txt +``` + +Again, the file will be created automatically, if it doesn’t exist already. + +You may also use the tee command in append mode with option -a in this manner: + +``` +command | tee -a file.txt +``` + +Let me demonstrate it with some easy to follow examples: + +![][6] + +I have used simple Linux commands in my examples. But rest assured, you can use these methods to save the output of bash scripts as well. + +### Note: Avoid pipe pitfall while saving command output to file + +You probably are familiar with pipe redirection. You may use it to combine Linux commands but you cannot pipe the output to a file. It will result in error that filename command not found: + +![][7] + +This is because pipe redirects the output of one command to input of another command. And in this case, you give it a file name while it was expecting a command. + +If you are new to Linux command line, I hope this quick tutorial added to your Linux knowledge a bit. [I/O redirection][8] is an essential concept that one should be aware of. + +As always, questions and suggestions are always welcome. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/save-command-output-to-file-linux/ + +作者:[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://itsfoss.com/copy-paste-linux-terminal/ +[2]: https://linuxhandbook.com/redirection-linux/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/redirecting_command_output_to_file_in_linux.png?resize=741%2C456&ssl=1 +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/redirecting_command_output_to_file.png?resize=741%2C494&ssl=1 +[5]: https://linuxhandbook.com/tee-command/ +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/display-and-save-linux-command-output.png?resize=741%2C494&ssl=1 +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/pipe-output-to-file-linux.png?resize=687%2C266&ssl=1 +[8]: https://tldp.org/LDP/abs/html/io-redirection.html#FTN.AEN17894 From 0afab5d94e1b193d60ab1742757d5737257a7b50 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Sun, 22 Nov 2020 05:02:35 +0800 Subject: [PATCH 043/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201121=20?= =?UTF-8?q?Open=20source=20brings=20musicians=20together=20virtually?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201121 Open source brings musicians together virtually.md --- ...rce brings musicians together virtually.md | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 sources/tech/20201121 Open source brings musicians together virtually.md diff --git a/sources/tech/20201121 Open source brings musicians together virtually.md b/sources/tech/20201121 Open source brings musicians together virtually.md new file mode 100644 index 0000000000..943f21e8ad --- /dev/null +++ b/sources/tech/20201121 Open source brings musicians together virtually.md @@ -0,0 +1,67 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Open source brings musicians together virtually) +[#]: via: (https://opensource.com/article/20/11/open-source-drum-bugle-corps) +[#]: author: (Vicki Walker https://opensource.com/users/vicki-walker) + +Open source brings musicians together virtually +====== +The open source ethos is embedded in many areas of life, including music +and art. +![Drums ][1] + +When the COVID-19 pandemic began canceling live music events in spring 2020, it wasn't just the big arena shows, music festivals, and small, local venues that suffered—the big annual marching band competition leagues, like [Drum Corps International][2] (DCI) and [WGI World Championships][3], were also called off. This was a huge disappointment for the thousands of musicians and band directors who were already preparing for the spring and summer competition season. But the members of the [Drumcorps subreddit][4] saw it as an opportunity to take drum corps virtual. + +The [Open Source Drum and Bugle Corps][5] (OSDBC) is one such organization bringing open source to drum corps. The group was founded on the principles of openness, inclusiveness, and collaboration. And, like most things in open source, OSDBC was created to solve a problem. + +OSDBC launched in early April 2020, in the early weeks of US pandemic-related shutdowns, and immediately had 100 members in the group's Discord; within half a year, its membership approached 400 brass and percussion players across the United States. To date, the organization has released two performances and is working on its third. + +All of the content OSDBC produces—including guides, documentation, sheet music, clicktracks, and virtual performances—is released under [Creative Commons][6] licenses so that other groups can replicate the project if they wish. + +### Who's involved? + +Most OSDBC members are professional musicians, teachers, and high school and college students. Because the drum corps community is relatively small, there's a strong possibility that students and their teachers might be participating together on the same project, leading to uncomfortableness or even potential legal issues relating to students and teachers being in the same group chats. Therefore, OSDBC members work anonymously, wearing hats and sunglasses in their performance videos, and many use pseudonyms within the group. It's an imperfect solution, but it does provide "plausible deniability" about someone's identity, says one member, a high school senior who serves on the project's all-volunteer staff. + +Anonymity also levels the playing field among musicians with different levels of experience, which helps open up collaboration and personal growth opportunities, including the ability to ask for help without fear of embarrassment or judgment. + +Members come from multiple disciplines—musicians, artists, composers, and audio engineers—volunteering their time and talent to produce multimedia content. Because everyone is a volunteer, there is no cost to be involved in the project. + +### How it works + +Unlike a typical drum corps, OSDBC can't perform together in person, first, because of the pandemic, and second because of the members' geographical distribution. Selecting a composition is a community effort, with votes taken both to pick a public domain musical piece to play and then to choose a composer (based on members' original compositions of the selected piece). The winner of the composition contest distributes sheet music, clicktracks, and advice for playing the piece, and the audio and video editors share [submission guidelines][7] about how to record and submit videos for inclusion in the project. Approximately a fifth of the members have submitted performances for each of the first three projects. + +Once the submission deadline has passed and all the performances are collected, the design team begins to mix the individual videos into a cohesive performance. + +Because editing a performance is a significant amount of work that requires specialized audio and video production knowledge and tools, the work is distributed among section leaders (e.g., trumpets, low brass, percussion, etc.). They use a mix of open source and proprietary software, chiefly [Audacity][8], Reaper, and FL Studios, to produce the videos; while open source is the preference, the members must use the applications that they are familiar with and have access to at their universities or jobs. + +### Get involved + +OSDBC plans to continue working together even after the COVID-19 pandemic. Given the uncertainty around the 2021 drum corps season, with WGI planning a virtual season and DCI weighing the feasibility of an abbreviated season, OSDBC provides a valuable option for the tight-knit community to collaborate and make music together. + +The project eagerly welcomes new performers, organizers, arrangers, and others. If you would like to get involved, visit the [website][5] and join the project's [Discord][9] for updated information and opportunities to participate in the next project. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/11/open-source-drum-bugle-corps + +作者:[Vicki Walker][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/vicki-walker +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/drums-beat.png?itok=vhr6E_f1 (Drums ) +[2]: https://www.dci.org/ +[3]: https://www.wgi.org/ +[4]: https://www.reddit.com/r/drumcorps/ +[5]: https://opensourcedbc.org/ +[6]: https://creativecommons.org/ +[7]: https://opensourcedbc.org/info-for-members/ +[8]: https://opensource.com/education/16/9/audacity-classroom +[9]: https://discord.gg/6QmCSK3 From a6afd8247bd9b56c26b9838a2626b3bc101ba9ea Mon Sep 17 00:00:00 2001 From: DarkSun Date: Sun, 22 Nov 2020 05:02:49 +0800 Subject: [PATCH 044/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201120=20?= =?UTF-8?q?Day=2010:=20Training=20an=20RNN=20to=20count=20to=20three?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201120 Day 10- Training an RNN to count to three.md --- ...y 10- Training an RNN to count to three.md | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 sources/tech/20201120 Day 10- Training an RNN to count to three.md diff --git a/sources/tech/20201120 Day 10- Training an RNN to count to three.md b/sources/tech/20201120 Day 10- Training an RNN to count to three.md new file mode 100644 index 0000000000..a8352615fb --- /dev/null +++ b/sources/tech/20201120 Day 10- Training an RNN to count to three.md @@ -0,0 +1,56 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Day 10: Training an RNN to count to three) +[#]: via: (https://jvns.ca/blog/2020/11/20/day-10--training-an-rnn-to-count-to-three/) +[#]: author: (Julia Evans https://jvns.ca/) + +Day 10: Training an RNN to count to three +====== + +Yesterday I was trying to train an RNN to generate English that sounds kind of like Shakespeare. That was not working, so today I instead tried to do something MUCH simpler: train an RNN to generate sequences like + +``` +0 1 2 0 1 2 0 1 2 0 1 2 +``` + +and slightly more complicated sequences like + +``` +0 1 2 1 0 1 2 1 0 1 2 1 0 1 2 1 0 +``` + +I used (I think) the exact same RNN that I couldn’t get to work yesterday to generate English by training it on Shakespeare, so it was cool to see that I could at least use it for this much simpler task (memorize short sequences of numbers). + +### the jupyter notebook + +It’s late so I won’t explain all the code in this blog post, but here’s the PyTorch code I wrote to train the RNN to count to three. + + * Here it is as a [github gist][1] + * and [here it is on Colab][2] if you want to run it yourself + + + +In the gist there are a few experiments with different sequence lengths, like (unsurprisingly) it takes longer to train it to memorize a sequence of length 20 than a sequence of length 5. + +### simplifying is nice + +I’m super happy that I got an RNN to do something that I actually understand! I feel pretty hopeful that on Monday I’ll be able to go back to the character RNN problem of trying to get the RNN to generate English words now that I have this simpler thing working. + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2020/11/20/day-10--training-an-rnn-to-count-to-three/ + +作者:[Julia Evans][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://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://gist.github.com/jvns/b8804fb9d0672ce147a28d22648b4bd7 +[2]: https://colab.research.google.com/gist/jvns/b8804fb9d0672ce147a28d22648b4bd7/rnn-123.ipynb From 303ed50e92c158eb2cc6b47e4ab547f94a33b9de Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Sun, 22 Nov 2020 21:29:56 +0800 Subject: [PATCH 045/139] PRF&PUB @wxy https://linux.cn/article-12850-1.html --- ...rminal With These Command Line Browsers.md | 60 ++++++++++--------- 1 file changed, 31 insertions(+), 29 deletions(-) rename {translated/tech => published}/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md (68%) diff --git a/translated/tech/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md b/published/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md similarity index 68% rename from translated/tech/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md rename to published/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md index 53d2eb571a..54811507c5 100644 --- a/translated/tech/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md +++ b/published/20201027 You can Surf Internet in Linux Terminal With These Command Line Browsers.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (wxy) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12850-1.html) [#]: subject: (You can Surf Internet in Linux Terminal With These Command Line Browsers) [#]: via: (https://itsfoss.com/terminal-web-browsers/) [#]: author: (Ankush Das https://itsfoss.com/author/ankush/) @@ -10,33 +10,35 @@ 使用命令行浏览器在 Linux 终端上网浏览 ====== -我猜你可能是用 Firefox 或基于 Chrome 的浏览器(如 [Brave][1])来阅读这篇文章。或者,也可能是 Chrome 浏览器或 [Chromium][2]。 +![](https://img.linux.net.cn/data/attachment/album/202011/22/212007f9s7aabmcj4aa9lo.jpg) -换句话说,你正在利用基于 GUI 的方式浏览网页。然而,在以前,人们使用终端来获取资源和浏览网页,因为所有的东西大多是基于文本的信息。 +我猜你阅读这篇文章可能是用 Firefox 或基于 Chrome 的浏览器(如 [Brave][1]),或者,也可能是 Chrome 浏览器或 [Chromium][2]。 -虽然现在不能从终端上获取每一个信息,但对于一些文本信息,还是可以尝试使用命令行浏览器,从 Linux 终端上打开网页。 +换句话说,你正在利用基于 GUI 的方式浏览网页。然而,在以前,人们使用终端来获取资源和浏览网页,因为所有的东西大多是基于文本的。 -不仅如此,如果你访问的是远程服务器,或者只有一个没有 GUI 的终端,终端网页浏览器也可以证明它是有用的。 +虽然现在不能从终端上获取每个信息,但对于一些文本信息,还是可以尝试使用命令行浏览器,从 Linux 终端上打开网页。 -因此,在本文中,我将介绍一些基于终端的网络浏览器,你可以在 Linux 上尝试它们。 +不仅如此,如果你访问的是远程服务器,或者只有一个没有 GUI 的终端,终端网页浏览器就可以发挥用处了。 + +因此,在本文中,我将介绍一些基于终端的 Web 浏览器,你可以在 Linux 上尝试它们。 ### Linux 用户的最佳终端 Web 浏览器 -注:榜单排名不分先后。 +注:此榜单排名不分先后。 #### 1、W3M ![][3] -`w3m` 是一个流行的基于文本的开源终端 Web 浏览器。尽管最初的项目已经不再活跃,但它的一个活跃版本正由另一个开发者 Tatsuya Kinoshita 维护。 +`w3m` 是一个流行的基于文本的开源终端 Web 浏览器。尽管其初始项目已经不再活跃,但另一个开发者 Tatsuya Kinoshita 正在维护着它的一个活跃分支。 -`w3m` 相当简单,支持 SSL 连接、彩色,也支持内嵌图片。当然,根据你试图访问的资源,你那边的情况可能会有所不同。根据我的简单测试,它似乎无法加载 [DuckDuckGo][4],但我可以[在终端中使用 Google][5]就可以了。 +`w3m` 相当简单,支持 SSL 连接、色彩,也支持内嵌图片。当然,根据你试图访问的资源,你那边的情况可能会有所不同。根据我的简单测试,它似乎无法加载 [DuckDuckGo][4],但我可以[在终端中使用 Google][5]就够了。 安装后,你可以简单的在终端中输入 `w3m` 以得到帮助。如果你感兴趣的话,也可以到 [GitHub][6] 上去查看它的仓库。 **如何安装和使用 w3m?** -`w3m` 在任何基于 Debian 的 Linux 发行版的默认仓库中都是可用的。如果你有一个基于 Arch 的发行版,如果没有直接可用的软件包,你可能需要查看一下 [AUR][7]。 +`w3m` 在任何基于 Debian 的 Linux 发行版的默认仓库中都是可用的。如果你有一个基于 Arch 的发行版,但没有直接可用的软件包,你可能需要查看一下 [AUR][7]。 对于 Ubuntu,你可以通过键入以下内容来安装它: @@ -50,27 +52,27 @@ sudo apt install w3m w3m-img w3m xyz.com ``` -当然,你需要将 `xyz.com` 替换成任何你想浏览/测试的网站。最后,你应该知道,你可以使用键盘上的方向键来导航,当你想采取一个动作时,按回车键。 +当然,你需要将 `xyz.com` 替换成任何你想浏览或测试的网站。最后,你应该知道,你可以使用键盘上的方向键来导航,当你想采取一个动作时,按回车键。 -要退出,你可以按 `SHIFT+Q`,返回上一页是 `SHIFT+B`。其他快捷键包括 `SHIFT+T` 打开新标签页和 `SHIFT+U` 打开新的 URL。 +要退出,你可以按 `SHIFT+Q`,返回上一页是 `SHIFT+B`。其他快捷键包括用 `SHIFT+T` 打开新标签页和用 `SHIFT+U` 打开新的 URL。 -你可以通过访问它的手册页面来了解更多信息。 +你可以通过访问它的手册页来了解更多信息。 #### 2、Lynx ![][8] -Lynx 是又一个开源的命令行浏览器,你可以试试。幸运的是,很多的网站在使用 Lynx 时往往能正常工作,所以我说它在这方面肯定更好。我能够加载 DuckDuckGo,并使其工作。 +Lynx 是另一个开源的命令行浏览器,你可以试试。幸运的是,很多的网站在使用 Lynx 时往往能正常工作,所以我说它在这方面肯定更好。我能够加载 DuckDuckGo,并使其工作。 -除此之外,我还注意到它可以让你在访问各种网络资源时接受或拒绝 cookie。你也可以将它设置为总是接受或拒绝。所以,这是件好事。 +除此之外,我还注意到它可以让你在访问各种 Web 资源时接受或拒绝 cookie。你也可以将它设置为总是接受或拒绝。所以,这是件好事。 -另一方面,在终端上使用时,窗口不能很好地调整大小。我还没有寻找到任何解决方法,所以如果你正在尝试这个,你可能会想要这样做。不管是哪种情况,它都很好用,当你在终端启动它时,你会得到所有键盘快捷键的说明。 +另一方面,在终端上使用时,窗口不能很好地调整大小。我还没有寻找到任何解决方法,所以如果你正在尝试这个,你可能会想要这样做。不论如何,它都很好用,当你在终端启动它时,你会得到所有键盘快捷键的说明。 请注意,它与系统终端主题不匹配,所以无论你的终端看起来如何,它都会看起来不同。 **如何安装 Lynx?** -与 w3m 不同的是,如果你有兴趣尝试的话,确实可以找到一些 Win32 上的安装程序。但是,在 Linux 上,它在大多数的默认仓库中都是可用的。 +与 w3m 不同的是,如果你有兴趣尝试的话,确实可以找到一些 Win32 上的安装程序。不过,在 Linux 上,它在大多数的默认仓库中都是可用的。 对于 Ubuntu 来说,你只需要输入: @@ -92,17 +94,17 @@ lynx examplewebsite.com ![][10] -Links2 是一款有趣的基于文本的浏览器,你可以在你的终端上轻松使用,用户体验良好。它给你提供了一个很好的界面,你启动它后,只要输入网址就可以了 +Links2 是一款有趣的基于文本的浏览器,你可以在你的终端上轻松使用,用户体验良好。它提供了一个很好的界面,你启动它后,只要输入网址就可以了。 ![][11] -值得注意的是,主题将取决于你的终端设置,我设置为“黑绿色”主题,因此你看到的就是这个。当你以命令行浏览器的方式启动它后,你只需要按任意键就会出现 URL 提示,或者按 `Q` 键退出。它足够好用,可以渲染大多数网站的文字。 +值得注意的是,主题将取决于你的终端设置,我设置为“黑绿色”主题,因此你看到的就是这个。当你以命令行浏览器的方式启动它后,你只需要按任意键就会出现 URL 提示,或者按 `Q` 键退出。它相当好用,可以渲染大多数网站的文字。 与 Lynx 不同的是,你没有接受或拒绝 cookie 的功能。除此之外,它似乎工作的还不错。 **如何安装 Links2?** -正如你所期望的,你会发现它在大多数默认的资源库中都有。对于 Ubuntu,你可以在终端输入以下命令来安装它: +正如你所期望的,你会发现它在大多数默认的仓库中都有。对于 Ubuntu,你可以在终端输入以下命令来安装它: ``` sudo apt install links2 @@ -126,7 +128,7 @@ eLinks 类似于 Links2,但它已经不再维护了。你仍然可以在各种 sudo apt install elinks ``` -对于其他 Linux 发行版,你应该可以在标准软件库中找到它。但是,如果你在软件库中找不到它,你可以参考[官方安装说明][14]。 +对于其他 Linux 发行版,你应该可以在标准软件仓库中找到它。但是,如果你在软件仓库中找不到它,你可以参考[官方安装说明][14]。 ### 总结 @@ -145,7 +147,7 @@ via: https://itsfoss.com/terminal-web-browsers/ 作者:[Ankush Das][a] 选题:[lujun9972][b] 译者:[wxy](https://github.com/wxy) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -153,17 +155,17 @@ via: https://itsfoss.com/terminal-web-browsers/ [b]: https://github.com/lujun9972 [1]: https://itsfoss.com/brave-web-browser/ [2]: https://itsfoss.com/install-chromium-ubuntu/ -[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/10/w3m-google.jpg?resize=800%2C463&ssl=1 +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/10/w3m-google.jpg [4]: https://duckduckgo.com/ [5]: https://itsfoss.com/review-googler-linux/ [6]: https://github.com/tats/w3m [7]: https://itsfoss.com/aur-arch-linux/ -[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/10/lynx-terminal.jpg?resize=800%2C497&ssl=1 +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/10/lynx-terminal.jpg [9]: https://lynx.invisible-island.net/lynx-resources.html -[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/10/links2-terminal.jpg?resize=800%2C472&ssl=1 -[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/links2-terminal-welcome.jpg?resize=800%2C541&ssl=1 +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/10/links2-terminal.jpg +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/links2-terminal-welcome.jpg [12]: http://links.twibright.com/download.php -[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/elinks-terminal.jpg?resize=800%2C465&ssl=1 +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/elinks-terminal.jpg [14]: http://elinks.or.cz/documentation/installation.html [15]: https://www.brow.sh/ [16]: https://itsfoss.com/download-files-from-linux-terminal/ From 1a00e763e7a9859070becb6cc573df98a6d3fd27 Mon Sep 17 00:00:00 2001 From: MjSeven Date: Sun, 22 Nov 2020 21:34:04 +0800 Subject: [PATCH 046/139] Translating --- ...How to use Serializers in the Django Python web framework.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20201116 How to use Serializers in the Django Python web framework.md b/sources/tech/20201116 How to use Serializers in the Django Python web framework.md index 9a5f441221..54e18e6a1e 100644 --- a/sources/tech/20201116 How to use Serializers in the Django Python web framework.md +++ b/sources/tech/20201116 How to use Serializers in the Django Python web framework.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (MjSeven) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) From 5e7bd627614de0154ebac2db33e534a2ca5430ca Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 23 Nov 2020 08:39:42 +0800 Subject: [PATCH 047/139] translated --- ...1116 Podman with capabilities on Fedora.md | 115 ------------------ ...1116 Podman with capabilities on Fedora.md | 115 ++++++++++++++++++ 2 files changed, 115 insertions(+), 115 deletions(-) delete mode 100644 sources/tech/20201116 Podman with capabilities on Fedora.md create mode 100644 translated/tech/20201116 Podman with capabilities on Fedora.md diff --git a/sources/tech/20201116 Podman with capabilities on Fedora.md b/sources/tech/20201116 Podman with capabilities on Fedora.md deleted file mode 100644 index dd8ab976e8..0000000000 --- a/sources/tech/20201116 Podman with capabilities on Fedora.md +++ /dev/null @@ -1,115 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Podman with capabilities on Fedora) -[#]: via: (https://fedoramagazine.org/podman-with-capabilities-on-fedora/) -[#]: author: (shiwanibiradar https://fedoramagazine.org/author/shiwanibiradar/) - -Podman with capabilities on Fedora -====== - -![][1] - -Containerization is a booming technology. As many as seventy-five percent of global organizations could be running some type of containerization technology in the near future. Since widely used technologies are more likely to be targeted by hackers, securing containers is especially important. This article will demonstrate how [POSIX capabilities][2] are used to secure Podman containers. Podman is the default container management tool in RHEL8. - -### Determine the Podman container’s privilege mode - -Containers run in either privileged or unprivileged mode. In privileged mode, [the container uid 0 is mapped to the host’s uid 0][3]. For some use cases, unprivileged containers [lack sufficient access][4] to the resources of the host machine. Technologies and techniques including Mandatory Access Control (apparmor, SELinux), seccomp filters, dropping of capabilities, and namespaces help to secure containers regardless of their mode of operation. - -**To determine the privilege mode from outside the container:** - -``` -$ podman inspect --format="{{.HostConfig.Privileged}}" -``` - -If the above command returns _true_ then the container is running in privileged mode. If it returns _false_ then the container is running in unprivileged mode. - -**To determine the privilege mode from inside the container:** - -``` -$ ip link add dummy0 type dummy -``` - -If this command allows you to create an interface then you are running a privileged container. Otherwise you are running an unprivileged container. - -### Capabilities - -Namespaces isolate a container’s processes from arbitrary access to the resources of its host and from access to the resources of other containers running on the same host. Processes within _privileged_ containers, however, might still be able to do things like alter the IP routing table, trace arbitrary processes, and load kernel modules. Capabilities allow one to apply finer-grained restrictions on what resources the processes within a container can access or alter; even when the container is running in privileged mode. Capabilities also allow one to assign privileges to an unprivileged container that it would not otherwise have. - -For example, to add the _NET_ADMIN_ capability to an unprivileged container so that a network interface can be created inside of the container, you would run _podman_ with parameters similar to the following: - -``` -[root@vm1 ~]# podman run -it --cap-add=NET_ADMIN centos -[root@b27fea33ccf1 /]# ip link add dummy0 type dummy -[root@b27fea33ccf1 /]# ip link -``` - -The above commands demonstrate a _dummy0_ interface being created in an unprivileged container. Without the _NET_ADMIN_ capability, an unprivileged container would not be able to create an interface. The above commands demonstrate how to grant a capability to an unprivileged container. - -Currently, there are about [39 capabilities][5] that can be granted or denied. Privileged containers are granted many capabilities by default. It is advisable to drop unneeded capabilities from privileged containers to make them more secure. - -**To drop all capabilities from a container:** - -``` -$ podman run -it -d --name mycontainer --cap-drop=all centos -``` - -**To list a container’s capabilities:** - -``` -$ podman exec -it 48f11d9fa512 capsh --print -``` - -The above command should show that no capabilities are granted to the container. - -**Refer to the _capabilities_ man page for a complete list of capabilities:** - -``` -$ man capabilities -``` - -**Use the _capsh_ command to list the capabilities you currently possess:** - -``` -$ capsh --print -``` - -As another example, the below command demonstrates dropping the _NET_RAW_ capability from a container. Without the _NET_RAW_ capability, servers on the internet cannot be pinged from within the container. - -``` -$ podman run -it --name mycontainer1 --cap-drop=net_raw centos ->>> ping google.com (will output error, operation not permitted) -``` - -As a final example, if your container were to only need the _SETUID_ and _SETGID_ capabilities, you could achieve such a permission set by dropping all capabilities and then re-adding only those two. - -``` -$ podman run -d --cap-drop=all --cap-add=setuid --cap-add=setgid fedora sleep 5 > /dev/null; pscap | grep sleep -``` - -The _pscap_ command shown above should show the capabilities that have been granted to the container. - -I hope you enjoyed this brief exploration of how capabilities are used to secure Podman containers. - -Thank You! - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/podman-with-capabilities-on-fedora/ - -作者:[shiwanibiradar][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/shiwanibiradar/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2018/10/podman-816x345.jpg -[2]: https://www.linuxjournal.com/magazine/making-root-unprivileged -[3]: https://linuxcontainers.org/lxc/security/#privileged-containers -[4]: https://github.com/containers/podman/blob/master/rootless.md -[5]: https://man7.org/linux/man-pages/man7/capabilities.7.html diff --git a/translated/tech/20201116 Podman with capabilities on Fedora.md b/translated/tech/20201116 Podman with capabilities on Fedora.md new file mode 100644 index 0000000000..c35e7fbfc3 --- /dev/null +++ b/translated/tech/20201116 Podman with capabilities on Fedora.md @@ -0,0 +1,115 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Podman with capabilities on Fedora) +[#]: via: (https://fedoramagazine.org/podman-with-capabilities-on-fedora/) +[#]: author: (shiwanibiradar https://fedoramagazine.org/author/shiwanibiradar/) + +在 Fedora 中使用 Podman 结合 Capabilities +====== + +![][1] + +容器化是一项蓬勃发展的技术。在不久的将来,多达百分之七十五的全球组织可能会运行某种类型的容器化技术。由于广泛使用的技术更容易成为黑客攻击的目标,因此保护容器的安全就显得尤为重要。本文将演示如何使用 [POSIX Capabilities][2] 来保护 Podman 容器的安全。Podman 是 RHEL8 中默认的容器管理工具。 + +### 确定 Podman 容器的权限模式 + +容器以特权模式或无特权模式运行。在特权模式下,[容器的 uid 0 被映射到主机的 uid 0][3]。对于某些情况,无特权的容器[缺乏对主机资源的充足访问][4]。包括强制访问控制(apparmor、SELinux)、seccomp 过滤器、删除 Capabilities 和命名空间在内的技有助于确保容器的安全,而不管其操作模式如何。 + +**要从容器外部确定特权模式:** + +``` +$ podman inspect --format="{{.HostConfig.Privileged}}" +``` + +如果上面的命令返回 _true_,那么容器在特权模式下运行。如果返回 _false_,那么容器在非特权模式下运行。 + +**要从容器内部确定特权模式:** + +``` +$ ip link add dummy0 type dummy +``` + +如果该命令允许你创建一个接口,那么你运行的是一个特权容器,否则你运行的是一个非特权容器。 + +### Capabilities + +命名空间隔离了容器的进程,使其无法任意访问主机的资源,也无法访问在同一主机上运行的其他容器的资源。然而,在_特权_容器内的进程仍然可以做一些事情,如改变 IP 路由表、跟踪任意进程和加载内核模块。Capabilities 允许人们对容器内的进程可以访问或更改的资源施加更细微的限制,即使容器在特权模式下运行也一样。Capabilities 还允许人们为无特权的容器分配它本来不会拥有的特权。 + +例如,如果要将 _NET_ADMIN_ 功能添加到一个无特权的容器中,以便在容器内部创建一个网络接口,你可以用下面的参数运行 _podman_: + +``` +[root@vm1 ~]# podman run -it --cap-add=NET_ADMIN centos +[root@b27fea33ccf1 /]# ip link add dummy0 type dummy +[root@b27fea33ccf1 /]# ip link +``` + +上面的命令演示了在一个无特权的容器中创建一个_dummy0_ 接口。如果没有 _NET_ADMIN_ Capability,非特权容器将无法创建接口。上面的命令演示了如何将一个 Capability 授予一个无特权的容器。 + +目前,大约有 [39 种 Capabilities][5] 可以被授予或拒绝。特权容器默认会被授予许多 Capability。建议从特权容器中删除不需要的 Capability,以使其更加安全。 + +**要从容器中删除所有 Capability:** + +``` +$ podman run -it -d --name mycontainer --cap-drop=all centos +``` + +**列出一个容器的 Capability:** + +``` +$ podman exec -it 48f11d9fa512 capsh --print +``` + +上述命令显示没有向容器授予任何 Capability。 + +**请参考 _capabilities_ 手册页以获取完整的 Capability 列表:** + +``` +$ man capabilities +``` + +**使用 _capsh_ 命令来列出目前拥有的 Capability:** + +``` +$ capsh --print +``` + +作为另一个例子,下面的命令演示了如何从容器中删除 _NET_RAW_ Capability。如果没有 _NET_RAW_ Capability,就不能从容器中 ping 互联网上的服务器。 + +``` +$ podman run -it --name mycontainer1 --cap-drop=net_raw centos +>>> ping google.com (will output error, operation not permitted) +``` + +最后一个例子,如果你的容器只需要 _SETUID_ 和 _SETGID_ 功能,你可以删除所有 Capability,然后只重新添加这两个 Capability 来实现这样的权限设置。 + +``` +$ podman run -d --cap-drop=all --cap-add=setuid --cap-add=setgid fedora sleep 5 > /dev/null; pscap | grep sleep +``` + +上面的 _pscap_ 命令会显示容器被授予的 Capability。 + +我希望你喜欢这个关于如何使用 Capabilities 来保护 Podman 容器的简短探索。 + +谢谢! + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/podman-with-capabilities-on-fedora/ + +作者:[shiwanibiradar][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/shiwanibiradar/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2018/10/podman-816x345.jpg +[2]: https://www.linuxjournal.com/magazine/making-root-unprivileged +[3]: https://linuxcontainers.org/lxc/security/#privileged-containers +[4]: https://github.com/containers/podman/blob/master/rootless.md +[5]: https://man7.org/linux/man-pages/man7/capabilities.7.html From ee1d456c3e77ab552dce3d8b1bd355dc1e0a1e0a Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 23 Nov 2020 08:43:54 +0800 Subject: [PATCH 048/139] translating --- ...1118 LazPaint- A Free - Open Source Paint.NET Alternative.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20201118 LazPaint- A Free - Open Source Paint.NET Alternative.md b/sources/tech/20201118 LazPaint- A Free - Open Source Paint.NET Alternative.md index ad0c5f6594..0481069619 100644 --- a/sources/tech/20201118 LazPaint- A Free - Open Source Paint.NET Alternative.md +++ b/sources/tech/20201118 LazPaint- A Free - Open Source Paint.NET Alternative.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (geekpi) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) From ec54953c90c8a3e96ec18ceb0639f782fecbb4c7 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Mon, 23 Nov 2020 10:48:35 +0800 Subject: [PATCH 049/139] PRF @geekpi --- ... encrypted disks on Linux automatically.md | 106 +++++++----------- 1 file changed, 42 insertions(+), 64 deletions(-) diff --git a/translated/tech/20201116 Unlock encrypted disks on Linux automatically.md b/translated/tech/20201116 Unlock encrypted disks on Linux automatically.md index 7e97ec99a6..e7a44a312b 100644 --- a/translated/tech/20201116 Unlock encrypted disks on Linux automatically.md +++ b/translated/tech/20201116 Unlock encrypted disks on Linux automatically.md @@ -1,31 +1,31 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12851-1.html) [#]: subject: (Unlock encrypted disks on Linux automatically) [#]: via: (https://opensource.com/article/20/11/nbde-linux) [#]: author: (Curt Warfield https://opensource.com/users/rcurtiswarfield) 自动解锁 Linux 上的加密磁盘 ====== -通过使用网络绑定磁盘加密 (NBDE),无需手动输入密码即可打开加密磁盘。 -![Lock][1] -从安全的角度来看,对敏感数据进行加密以保护其免受窥探和黑客的攻击是很重要的。Linux 统一密钥设置([LUKS][2])是一个很好的工具,也是 Linux 磁盘加密的通用标准。因为它将所有相关的设置信息存储在分区头中,所以它使数据迁移变得简单。 +> 通过使用网络绑定磁盘加密(NBDE),无需手动输入密码即可打开加密磁盘。 + +![](https://img.linux.net.cn/data/attachment/album/202011/23/104735lmx18sxxs18f4xcc.jpg) + +从安全的角度来看,对敏感数据进行加密以保护其免受窥探和黑客的攻击是很重要的。Linux 统一密钥设置Linux Unified Key Setup([LUKS][2])是一个很好的工具,也是 Linux 磁盘加密的通用标准。因为它将所有相关的设置信息存储在分区头部中,所以它使数据迁移变得简单。 要使用 LUKS 配置加密磁盘或分区,你需要使用 [cryptsetup][3] 工具。不幸的是,加密磁盘的一个缺点是,每次系统重启或磁盘重新挂载时,你都必须手动提供密码。 -然而,网络绑定磁盘加密 (NBDE) 可以在没有任何用户干预的情况下自动安全地解锁加密磁盘。它可以在一些 Linux 发行版中使用,从 Red Hat Enterprise Linux 7.4、CentOS 7.4 和 Fedora 24 开始,以及之后的后续版本。 +然而,网络绑定磁盘加密Network-Bound Disk Encryption(NBDE) 可以在没有任何用户干预的情况下自动安全地解锁加密磁盘。它可以在一些 Linux 发行版中使用,包括从 Red Hat Enterprise Linux 7.4、CentOS 7.4 和 Fedora 24 开始,以及之后的后续版本。 NBDE 采用以下技术实现: -* **[Clevis 框架][4]:**一个可插拔的框架工具,可自动解密和解锁 LUKS 卷 -* **[Tang 服务器][5]:**用于将加密密钥绑定到网络状态的服务 +* [Clevis 框架][4]:一个可插拔的框架工具,可自动解密和解锁 LUKS 卷 +* [Tang 服务器][5]:用于将加密密钥绑定到网络状态的服务 - - -Tang 向 Clevis 客户端提供加密密钥。 据 Tang 的开发人员介绍,这为密钥托管服务提供了一个安全、无状态、匿名的替代方案。 +Tang 向 Clevis 客户端提供加密密钥。据 Tang 的开发人员介绍,这为密钥托管服务提供了一个安全、无状态、匿名的替代方案。 由于 NBDE 使用客户端-服务器架构,你必须同时配置客户端和服务器。你可以在你的本地网络上使用一个虚拟机作为 Tang 服务器。 @@ -33,19 +33,17 @@ Tang 向 Clevis 客户端提供加密密钥。 据 Tang 的开发人员介绍, 用 sudo 安装 Tang: - ``` -`sudo yum install tang -y` +sudo yum install tang -y ``` 启用 Tang 服务器: - ``` -`sudo systemctl enable tangd.socket --now` +sudo systemctl enable tangd.socket --now ``` -Tang 服务器工作在 80 端口,且必须加入 firewalld。 添加相应的 firewalld 规则: +Tang 服务器工作在 80 端口,需加入到 firewalld 防火墙。添加相应的 firewalld 规则: ``` @@ -59,15 +57,13 @@ sudo firewall-cmd --reload 在本例中,假设你已经添加了一个名为 `/dev/vdc` 的新的 1GB 磁盘到你的系统中。 -使用 fdisk 或 parted 创建主分区: - +使用 `fdisk` 或 `parted` 创建主分区: ``` sudo fdisk /dev/vdc ``` -完成以下步骤来安装客户端。 - +完成以下步骤来安装客户端: ``` Welcome to fdisk (util-linux 2.23.2). @@ -81,8 +77,7 @@ Building a new DOS disklabel with disk identifier 0x4a6812d4. Command (m for help): ``` -输入 **n** 来创建新的分区: - +输入 `n` 来创建新的分区: ``` Partition type: @@ -99,8 +94,7 @@ Using default response p Partition number (1-4, default 1): ``` -按下**回车**键选择默认分区号: - +按下回车键选择默认分区号: ``` First sector (2048-2097151, default 2048): @@ -108,8 +102,7 @@ Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): ``` -按**回车**键选择最后一个扇区: - +按回车键选择最后一个扇区: ``` Using default value 2097151 @@ -118,8 +111,7 @@ Partition 1 of type Linux and of size 1023 MiB is set Command (m for help): wq ``` -输入 **wq** 保存更改并退出 fdisk: - +输入 `wq` 保存更改并退出 `fdisk`: ``` The partition table has been altered! @@ -130,20 +122,17 @@ Syncing disks. 运行 `partprobe` 通知系统分区表的变化: - ``` -`sudo partprobe` +sudo partprobe ``` -使用 sudo 安装 cryptsetup 软件包: - +使用 `sudo` 安装 cryptsetup 软件包: ``` -`sudo yum install cryptsetup -y` +sudo yum install cryptsetup -y ``` -使用 `cryptsetup luksFormat` 命令对磁盘进行加密。当提示时,你需要输入 **YES**,并选择和输入密码来加密磁盘: - +使用 `cryptsetup luksFormat` 命令对磁盘进行加密。当提示时,你需要输入大写的 `YES`,并输入密码来加密磁盘: ``` sudo cryptsetup luksFormat /dev/vdc1 @@ -159,7 +148,6 @@ Verify passphrase: 使用 `cryptsetup luksOpen` 命令将加密的分区映射到一个逻辑设备上。例如,使用 `encryptedvdc1` 作为名称。你还需要再次输入密码: - ``` sudo cryptsetup luksOpen /dev/vdc1 encryptedvdc1 Enter passphrase for /dev/vdc1: @@ -169,67 +157,58 @@ Enter passphrase for /dev/vdc1: 在加密的分区上创建一个 XFS 文件系统: - ``` -`sudo mkfs.xfs /dev/mapper/encryptedvdc1` +sudo mkfs.xfs /dev/mapper/encryptedvdc1 ``` 创建一个挂载加密分区的目录: - ``` -`sudo mkdir /encrypted` +sudo mkdir /encrypted ``` 使用 `cryptsetup luksClose` 命令锁定分区: - ``` -`cryptsetup luksClose encryptedvdc1` +cryptsetup luksClose encryptedvdc1 ``` -使用 sudo 安装 Clevis 软件包: - +使用 `sudo` 安装 Clevis 软件包: ``` -`sudo yum install clevis clevis-luks clevis-dracut -y` +sudo yum install clevis clevis-luks clevis-dracut -y ``` -修改 /etc/crypttab,在启动时打开加密卷: - +修改 `/etc/crypttab`,在启动时打开加密卷: ``` -`sudo vim /etc/crypttab` +sudo vim /etc/crypttab ``` 增加以下一行: - ``` -`encryptedvdc1 /dev/vdc1 none _netdev` +encryptedvdc1 /dev/vdc1 none _netdev ``` -修改 /etc/fstab,在重启时或启动时自动挂载加密卷: - +修改 `/etc/fstab`,在重启时或启动时自动挂载加密卷: ``` -`sudo vim /etc/fstab` +sudo vim /etc/fstab ``` 增加以下一行: - ``` -`/dev/mapper/encryptedvdc1 /encrypted xfs _netdev 1 2` +/dev/mapper/encryptedvdc1 /encrypted xfs _netdev 1 2 ``` 在这个例子中,假设 Tang 服务器的 IP 地址是 `192.168.1.20`。如果你喜欢,也可以使用主机名或域名。 运行以下 `clevis` 命令: - ``` -sudo clevis bind luks -d /dev/vdc1 tang '{"url":"' +sudo clevis bind luks -d /dev/vdc1 tang '{"url":"http://192.168.1.20"}' The advertisement contains the following signing keys: rwA2BAITfYLuyNiIeYUMBzkhk7M @@ -238,16 +217,15 @@ Do you wish to trust these keys? [ynYN] Y Enter existing LUKS password: ``` -输入 **Y** 接受 Tang 服务器的密钥,并提供现有的 LUKS 密码进行初始设置。 - -通过 systemctl 启用 clevis-luks-askpass.path,以防止非 root 分区被提示输入密码。 +输入 `Y` 接受 Tang 服务器的密钥,并提供现有的 LUKS 密码进行初始设置。 +通过 `systemctl` 启用 `clevis-luks-askpass.path`,以防止非根分区被提示输入密码。 ``` -`sudo systemctl enable clevis-luks-askpass.path` +sudo systemctl enable clevis-luks-askpass.path ``` -客户端已经安装完毕。 现在,每当你重启服务器时,加密后的磁盘应该会自动解密,并通过 Tang 服务器取回密钥进行挂载。 +客户端已经安装完毕。现在,每当你重启服务器时,加密后的磁盘应该会自动解密,并通过 Tang 服务器取回密钥进行挂载。 如果 Tang 服务器因为任何原因不可用,你需要手动提供密码,才能解密和挂载分区。 @@ -258,7 +236,7 @@ via: https://opensource.com/article/20/11/nbde-linux 作者:[Curt Warfield][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 6b02deeffacfa29f4ed73ce249cb0b3fad8ad501 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Mon, 23 Nov 2020 10:49:09 +0800 Subject: [PATCH 050/139] PUB @geekpi https://linux.cn/article-12851-1.html --- .../20201116 Unlock encrypted disks on Linux automatically.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20201116 Unlock encrypted disks on Linux automatically.md (100%) diff --git a/translated/tech/20201116 Unlock encrypted disks on Linux automatically.md b/published/20201116 Unlock encrypted disks on Linux automatically.md similarity index 100% rename from translated/tech/20201116 Unlock encrypted disks on Linux automatically.md rename to published/20201116 Unlock encrypted disks on Linux automatically.md From 6824b07cced48e37da9847d1cd54cc0cea51c2d0 Mon Sep 17 00:00:00 2001 From: niko Date: Mon, 23 Nov 2020 21:12:27 +0800 Subject: [PATCH 051/139] frogOAO --- ...s for USB, Clipboard and Folder Sharing.md | 168 +++++++++--------- 1 file changed, 87 insertions(+), 81 deletions(-) diff --git a/sources/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md b/sources/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md index 69b067c82b..4ccd0f00f6 100644 --- a/sources/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md +++ b/sources/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md @@ -7,221 +7,227 @@ [#]: via: (https://itsfoss.com/install-fedora-in-virtualbox/) [#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/) -How to Install Fedora in VirtualBox [With Steps for USB, Clipboard and Folder Sharing] +如何在 Fedora 中安装 VirtualBox 【附带 USB,剪切板,文件夹共享教程】 ====== -If you are curious about Fedora Linux, there are several ways to try it. +如果您对 Fedora Linux 感兴趣,这有几种方式可以尝试它。 -The easiest way that won’t affect your current operating system is to [create a live USB of Fedora.][1] +最简单还不影响您操作系统的方式是 [制作 Fedora 的 USB 启动盘][1] -An alternative way to try Fedora, is to get advantage of virtualization technology through an installation in VirtualBox. This way, you use Fedora like an application on your current operating system. +另一种方式是安装 VirtualBox 利用虚拟化技术来尝试 Fedora。这样,你可以在你的操作系统上像使用应用程序一样使用 Fedora。 -This way, you can perform more thorough testing without messing up your current operating system. +通过这种方式,您可以执行更彻底的测试,而不会搞乱当前的操作系统。 -You can even copy your virtual setup and re-install it on some other system. Sounds handy? Let me show you how to do it. +您甚至可以复制您的虚拟安装程序,并在其他系统上重新安装它。听起来方便吗?让我来教你怎么做。 -### Installing Fedora in VirtualBox +### 在 Fedora 上安装 Fedora ![][2] -Let’s see the steps for installing Fedora Linux in Oracle VirtualBox. +让我们分步在 Oracle VirtualBox 上安装 Fedora。 -#### Step 1: Install VirtualBox +#### 步骤一:安装 VirtualBox -If you haven’t already installed VirtualBox on your system, you can download it from the official website. You can find instructions for Windows, Mac OS and Linux. [Ubuntu users can refer to this detailed tutorial on installing VirtualBox][3]. +如果您的系统还没有安装 VirtualBox,您可以从官方网站下载。您可以找到 Windows,MacOs 和 Linux 的说明。 [Ubuntu 用户可以参考这个关于安装 VirtualBox 的详细教程。][3]. ![][4] -[Download VirtualBox][5] +[下载 VirtualBox][5] -#### **Step 2: Download the Fedora ISO** +#### **步骤二: 下载 Fedora ISO** -If you are not familiar with fedora, there are a few images to be aware of. +如果您不熟悉 Fedora,那么这些镜像您需要知道。 -[Fedora IoT][6] is to be used for scalable infrastructure, [Fedora workstation][7] is an image with a set of tools oriented for a desktop in a vanilla GNOME desktop environment and [Fedora server][8] as its name reveals, is tailored for a server or data center. +[Fedora IoT][6] 是用于可扩展基础设施的, [Fedora workstation][7] 是一个镜像,带有一组面向普通GNOME桌面环境中的桌面的工具。[Fedora server][8] 顾名思义,是为服务器或数据中心定制的。 -If GNOME isn’t your first choice, you can download a [spin][9] of Fedora desktop with an alternative desktop environment. For this tutorial, I chose [Fedora 33][10] with the GNOME desktop environment. +如果GNOME不是您的首选,您可以下载一个带有替代桌面环境的[定制版][9]Fedora桌面。 对于本教程,我选择了带有GNOME桌面环境的[Fedora 33][10]。 -[Download Fedora][11] +[下载 Fedora][11] -#### Step 3: Create an empty virtual machine and configure it +#### 步骤三: 创建一个空虚拟机并对其进行配置 -Fedora requires a minimum of 20GB disk space & 2GB RAM, to install and run successfully. Although double those amounts is recommended for a smoother user experience. Based on that I will create and configure the virtual machine. +要成功安装和运行 Fedora,至少需要 20GB 磁盘空间和 2GB RAM。不过,为了获得更流畅的用户体验,建议增加一倍。在此基础上,我将创建并配置虚拟机。 -Start Virtual Box and click on New. +开启 Virtual Box 点击 New。 -![Create a new virtual machine][12] +![创建一个新的虚拟机][12] -The most important option to pay attention, is the **type to be set to Linux and the version to Fedora (64-bit)**. If you start typing Fedora at the name prompt, VirtualBox will automatically pick the correct settings for you. Although the name doesn’t have to be Fedora, it can be anything you like. +需要注意,最重要的选项是 **将类型设置为 Linux and 版本设置为 Fedora (64-bit)**。如果您在名称提示符处开始输入 Fedora,VirtualBox 将自动为您选择正确的设置。虽然名字不一定非得是 Fedora,它可以是任何你喜欢的。 -_If you have access to 32-bit version only, you need to enable virtualization technology on BIOS, if you have an AMD CPU it is called SVM. Worst-case scenario is that your CPU doesn’t support virtualization technology. If you are not sure, check this first._ +_如果您只能访问32位版本,那么您需要在 BIOS 上启用虚拟化技术,如果您有一个 AMD CPU,它被称为 SVM。最坏的情况是您的 CPU 不支持虚拟化技术。如果你不确定,先检查这个。_ -Once you have similar settings with me, click on the create button. +如果您的设置和我一样,点击 create 按钮。 ![Name your VM and assign it at least 3 GB RAM][13] -As mentioned before, you need at least 20 GB of disk space to be able to install Fedora. I have 32 GB of RAM on my system so I assigned 8 GB here. You should be fine with 3 GB of RAM. +如前所述,至少需要 20gb 的磁盘空间才能安装 Fedora。我的系统上有 32gb 的内存,所以我分配了 8gb。3 GB 的内存应该没问题。 -A word about RAM consumption, the RAM will only be consumed by the virtual machine when you are running it. Otherwise, it will be available for regular usage. +顺便说下内存的使用,只有在运行虚拟机时,虚拟机才会使用内存。否则,它将可用于常规使用。 -Make sure that the rest of the settings match the example and click Create. +确保其余设置与示例匹配,并点击 Create。 ![Assign 15-20 GB of disk space in VDI format][14] -Before you click the start button of your virtual machine, you need to load the ISO as shown below [Optical Drive]. +在你点击虚拟机的 Start 按钮之前,你需要加载如下所示的 ISO [光驱]。 ![Add the Fedora ISO to optical drive storage][15] -As your virtual hard drive is empty, the virtual machine will boot from this ISO. Think of it as using a live USB or disk for installing Linux. +因为你的虚拟硬盘是空的,虚拟机将从这个 ISO 启动。可以把它看作是使用 live USB 或磁盘安装 Linux。 ![Go to Settings and add ISO as optical drive][16] -Then, if you have a multi-core CPU it is recommended to assign 2 or more cores for your virtual machine. You may find the CPU cores under the system tab. When you configure your system click ok and start the virtual machine. +然后,如果您有一个多核CPU,建议为虚拟机分配 2 个或更多的核。您可以在 system 选项卡下找到 CPU 核心。配置系统时,单击 ok 并启动虚拟机。 ![Optional step: Assign number of CPU cores][17] -Once you have configured everything, click on the start button to begin the installation. +配置好所有内容后,单击 start 按钮开始安装。 -#### Step 4: Install Fedora in VirtualBox +#### 步骤四:在 VirtualBox 中安装 Fedora。 -If you have followed the process correctly, when you start the virtual machine you will boot directly from the ISO file. When you see a similar to below screen select Start Fedora, and press the enter key. +如果您正确地遵循了这个过程,那么当您启动虚拟机时,您将直接从 ISO 文件启动。当您看到类似下面的屏幕时,选择 Start Fedora,并按 enter 键。 ![Fedora running in live environment in virtual machine][18] -To start the installation dialog box, click on Install to Hard Drive. +要启动安装对话框,单击 Install To Hard Drive。 ![Click on “install to hard drive”][19] -Before you proceed to the installation, it is essential to define your keyboard layout, your timezone and finally where the operating system will be installed. +在您继续安装之前,有必要定义您的键盘布局、您的时区以及最终安装操作系统的位置。 ![Choose keyboard, time and date and then go to Installation Destination][20] -The partitioning process is straight forward. You made some free space as VDI earlier. It should be automatically recognized. +划分过程很简单。您像前面的 VDI 那样划分一些空闲空间。它应该被自动识别。 -Select your disk and set the storage configuration to automatic. Click on Done to go to the previous dialog box. + +选择您的磁盘并将存储配置设置为 automatic。单击 Done 进入上一个对话框。 ![Disk should be automatically recognized][21] -Once you have configured the above, click on “Begin Installation”. +一旦你配置了上面的,点击 “Begin Installation”。 ![Begin installation of Fedora][22] -Now you just need to wait for five-six minutes for installation completion. Click on the “Finish installation” button when installation is finished. +现在只需等待 5 - 6 分钟即可完成安装。安装完成后,点击 “Finish installation” 按钮。 -As a last step, you need to power off your system. If you are unfamiliar with the GNOME desktop environment you can do it like so. +最后一步,需要关闭系统的电源。如果您不熟悉 GNOME 桌面环境,您可以这样做。 ![Turn off Fedora live environment after installation][23] -You have to manually unload the ISO file that you loaded at the initial steps. +您必须手动卸载在初始步骤中加载的 ISO 文件。 ![Remove Fedora ISO From Optical Drive][24] -The next time you start the virtual machine with Fedora, you will be prompted to create a user account and set your password for Fedora Linux. +下一次使用 Fedora 启动虚拟机时,系统将提示您为 Fedora Linux 创建用户帐户并设置密码。 -### Use VirtualBox guest additions for additional features like clipboard sharing, folder sharing and more +### 使用 VirtualBox 客户添加的附加功能,如剪贴板共享,文件夹共享等 -[Guest Additions][25] are designed to be installed inside a virtual machine post installation of the guest operating system. They contain device drivers and system applications that optimize the guest operating system for better performance and usability. +[增强功能包][25] 客户附加程序设计为在客户操作系统安装后安装在虚拟机中。它们包含对客户操作系统进行优化的设备驱动程序和系统应用程序,以获得更好的性能和可用性。 -The Guest Additions ISO file is mounted as a virtual CD-ROM in order to be installed. +客户添加 ISO 文件被安装为虚拟 CD-ROM 以便安装。 -This is a straightforward process. Simply click on the devices tab and then click on “Insert Guest Additions CD image” +这是一个简单的过程。只需单击设备选项卡,然后单击 “Insert Guest Additions CD image”。 ![][26] -You will be prompted to download the guest additions image, when prompt click on Download. +当提示符单击 download 时,系统将弹出您下载增强功能包界面。 ![Install VirtualBox Guest Additions][27] -#### **Shared clipboard** +#### **共享剪贴板** -At some point you’ll need to move some content between your virtual machine and the host operating system. The shared clipboard/drag and drop support will allow you to copy items on one platform and paste them on the other. +有时候,您需要在虚拟机和主机操作系统之间移动一些内容。共享剪贴板/拖放支持将允许您在一个平台上复制项目,并将它们粘贴到另一个平台上。 -To enable this feature, choose **Settings** on the VirtualBox home page and follow the instructions as below. I find the **Bidirectional** option the most convenient. +要启用此功能,请在VirtualBox主页上选择 **Settings**,并按照下面的说明操作。**双向** 的选项是最方便的。 ![Enable clipboard sharing between guest and host systems][28] -#### **Shared folders** +#### **共享文件夹** -There are two types of shares: +有两种类型的分享: - * Permanent shares, that are saved with the Virtual Machine settings. - * Transient shares, that are disappear when the Virtual Machine is powered off. These can be created using a checkbox in the VirtualBox Manager. + * 永久共享,与虚拟机设置一起保存。 + * 暂态共享,当虚拟机关闭时就会消失。可以使用 VirtualBox 管理器中的复选框创建暂态共享。 -In this tutorial, I will make a permanent shared folder. In the VM settings add the host system folder you want to share and choose the name that you want to appear at your VM. +在本教程中,我将创建一个永久共享文件夹。在 VM 设置中添加您想要共享的主机系统文件夹,并选择您想要在 VM 中出现的名称。 ![][29] -The next time you start the virtual machine, the folder should appear as a network drive. +下次启动虚拟机时,该文件夹应该显示为网络驱动器。 ![][30] -#### **Better video support** +#### **更好的视频支持** -While the virtual graphics card which Oracle VirtualBox provides all the basic features, the custom video drivers that are installed with the Guest Additions provide you with extra high and non-standard video modes, as well as accelerated video performance. +虽然 Oracle VirtualBox 提供了所有基本功能的虚拟显卡,但客户添加的自定义视频驱动程序为您提供了超高和非标准的视频模式,以及加速的视频性能。 -Using Guest Additions, the guest OS’s resolution will dynamically resize as you adjust the VirtualBox window on your computer. +使用增强安装包,操作系统的分辨率将随着您调整计算机上的 VirtualBox 窗口而动态调整大小。 -Finally, Guest Additions can take advantage of your computer’s graphics card. If you’re a gamer or using productivity software in a WM, this makes a huge difference. +最后,增强安装包可以利用您的计算机的显卡。如果你是一名游戏玩家或在 WM 中使用高效软件,这就会产生巨大的改变。 -#### USB and Network Devices sharing +#### USB 和网络设备共享 -With VirtualBox, users have the ability to use a fully-functional operating system, without having to do the setup on different hardware. However, sharing USB and network devices between the host and guest machine is not as straightforward as it should be. +有了 VirtualBox,用户就可以使用一个功能齐全的操作系统,而不必在不同的硬件上进行设置。然而,在主机和客户机器之间共享USB和网络设备并不像想的那样简单。 -To access USB devices, you will need to install [the VirtualBox extension pack][31]. +要访问USB设备,您将需要安装 [VirtualBox 扩展包][31]. ![Install VirtualBox Extensions pack][32] -_**This is for Linux only**_ because I am using all this in Linux. +_**下面这些仅对 Linux**_,因为我使用的是 Linux。 -In order for VirtualBox to have access to the USB subsystem, the user (on host system) running VirtualBox must belong to the vboxuser group. To do this, open up a terminal and issue the following command: +为了使 VirtualBox 能够访问 USB 子系统,运行 VirtualBox 的用户(在主机系统上)必须属于 vboxuser 组。为此,打开一个终端并发出以下命令: ``` sudo usermod -aG vboxusers 'your username' ``` -Once you run the command, you should either log out and log back in, or restart your host machine. +运行该命令后,您应该注销并重新登录,或者重新启动主机。 -At this step, plug in your USB stick and through your VM settings you should be able to find and add the medium as shown at the example. +在这一步,插入你的 u 盘,通过你的 VM 设置,你应该能够找到并添加介质,如例子中所示。 ![][33] -Your USB will be accessible the next time you start your virtual machine. +当您下次启动虚拟机,您的USB将是可访问的。 ![][34] -### Bonus Tip: Save and export the Virtual Machine so that you can use it later on any system +### 额外提示:保存并导出虚拟机,以便以后可以在任何系统上使用它 -You may want to use your virtual machine to another computer or it is time to build a new machine and you need to keep your virtual machine as it is. You can easily export your current setup and import it to another machine at a few easy steps. +您可能想在另一台计算机上使用虚拟机,或者是时候构建一台新机器了,并且您需要保持虚拟机的原样。只需几个简单的步骤,就可以轻松地导出当前设置并将其导入到另一台机器。 -At the VirtualBox home panel, click on file and the export appliance. If you prefer keyboard shortcuts, you can simply click **Ctrl+E**. +在 VirtualBox 主面板上,单击 file 和 export 工具。如果你喜欢键盘快捷键,你可以简单地点击 **Ctrl+E** ![][35] -Choose the virtual machine you want to export and click on next. +选择要导出的虚拟机,然后单击 next。 ![][36] -The Format option needs some attention. There are three different options of Open Virtualization Format 0.9, 1.0 and 2.0, which can be either ovf or ova extensions. +格式选项需要注意一下。开放虚拟化格式 0.9、1.0 和 2.0 有三种不同的选项,可以是 ovf 或 ova 扩展。 -With ovf extension, several files will be written separately, compared to ova extension, which combines all the files into one Open Virtualization Format archive. -The default format, Open Virtualization Format 1.0, should be fine. +使用 ovf 扩展名,可以分别编写几个文件,而 ova 扩展名则将所有文件合并到一个开放的虚拟化格式归档文件中。 + + +默认格式 Open Virtualization format 1.0 应该没问题。 ![][37] -To finish the process, click next and at the next dialog box click export. +要完成该过程,单击 next,然后在下一个对话框中单击 export。 -#### Conclusion +#### 总结 -By using a virtual machine you can’t just test an operating system but deploy a fully functioning system, equally comparable to a physical machine. Nowadays, hardware has become so powerful and affordable that most of its power is not being utilized. +通过使用虚拟机,您不仅可以测试操作系统,还可以部署与物理机器同等重要的功能完整的系统。如今,硬件已经变得如此强大和廉价,它的大部分功能都没有被利用。 -Through virtualization technology, you can use those wasted resources. The need for physical machines is reduced, and consequently the energy consumption is less. You can save money both from hardware and reduced running costs. -On a larger scale, server virtualization is more of a basic requirement than an advanced concept. +通过虚拟化技术,您可以使用这些浪费的资源。对物理机器的需求减少了,因此能源消耗也减少了。您可以从硬件和降低运行成本两方面省钱。 -I hope you found this tutorial helpful in installing Fedora Linux in VirtualBox. If you face any issues, please let me know in the comments. + +在更大的范围内,服务器虚拟化更多的是一种基本需求,而不是一种高级概念。 + + +我希望本教程对您在 VirtualBox 中安装 Fedora Linux 有帮助。如果你遇到任何问题,请在评论中告诉我。 -------------------------------------------------------------------------------- @@ -229,7 +235,7 @@ via: https://itsfoss.com/install-fedora-in-virtualbox/ 作者:[Dimitrios Savvopoulos][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) +译者:[译者ID](https://github.com/frogOAO) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 758d562504481e23146df1f7c21f3d18831f8f7d Mon Sep 17 00:00:00 2001 From: niko Date: Mon, 23 Nov 2020 21:21:38 +0800 Subject: [PATCH 052/139] frogOAO --- ...s for USB, Clipboard and Folder Sharing.md | 281 ------------------ 1 file changed, 281 deletions(-) delete mode 100644 sources/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md diff --git a/sources/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md b/sources/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md deleted file mode 100644 index 4ccd0f00f6..0000000000 --- a/sources/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md +++ /dev/null @@ -1,281 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (frogOAO) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to Install Fedora in VirtualBox [With Steps for USB, Clipboard and Folder Sharing]) -[#]: via: (https://itsfoss.com/install-fedora-in-virtualbox/) -[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/) - -如何在 Fedora 中安装 VirtualBox 【附带 USB,剪切板,文件夹共享教程】 -====== - -如果您对 Fedora Linux 感兴趣,这有几种方式可以尝试它。 - -最简单还不影响您操作系统的方式是 [制作 Fedora 的 USB 启动盘][1] - -另一种方式是安装 VirtualBox 利用虚拟化技术来尝试 Fedora。这样,你可以在你的操作系统上像使用应用程序一样使用 Fedora。 - -通过这种方式,您可以执行更彻底的测试,而不会搞乱当前的操作系统。 - -您甚至可以复制您的虚拟安装程序,并在其他系统上重新安装它。听起来方便吗?让我来教你怎么做。 - -### 在 Fedora 上安装 Fedora - -![][2] - -让我们分步在 Oracle VirtualBox 上安装 Fedora。 - -#### 步骤一:安装 VirtualBox - -如果您的系统还没有安装 VirtualBox,您可以从官方网站下载。您可以找到 Windows,MacOs 和 Linux 的说明。 [Ubuntu 用户可以参考这个关于安装 VirtualBox 的详细教程。][3]. - -![][4] - -[下载 VirtualBox][5] - -#### **步骤二: 下载 Fedora ISO** - -如果您不熟悉 Fedora,那么这些镜像您需要知道。 - -[Fedora IoT][6] 是用于可扩展基础设施的, [Fedora workstation][7] 是一个镜像,带有一组面向普通GNOME桌面环境中的桌面的工具。[Fedora server][8] 顾名思义,是为服务器或数据中心定制的。 - -如果GNOME不是您的首选,您可以下载一个带有替代桌面环境的[定制版][9]Fedora桌面。 对于本教程,我选择了带有GNOME桌面环境的[Fedora 33][10]。 - -[下载 Fedora][11] - -#### 步骤三: 创建一个空虚拟机并对其进行配置 - -要成功安装和运行 Fedora,至少需要 20GB 磁盘空间和 2GB RAM。不过,为了获得更流畅的用户体验,建议增加一倍。在此基础上,我将创建并配置虚拟机。 - -开启 Virtual Box 点击 New。 - -![创建一个新的虚拟机][12] - -需要注意,最重要的选项是 **将类型设置为 Linux and 版本设置为 Fedora (64-bit)**。如果您在名称提示符处开始输入 Fedora,VirtualBox 将自动为您选择正确的设置。虽然名字不一定非得是 Fedora,它可以是任何你喜欢的。 - -_如果您只能访问32位版本,那么您需要在 BIOS 上启用虚拟化技术,如果您有一个 AMD CPU,它被称为 SVM。最坏的情况是您的 CPU 不支持虚拟化技术。如果你不确定,先检查这个。_ - -如果您的设置和我一样,点击 create 按钮。 - -![Name your VM and assign it at least 3 GB RAM][13] - -如前所述,至少需要 20gb 的磁盘空间才能安装 Fedora。我的系统上有 32gb 的内存,所以我分配了 8gb。3 GB 的内存应该没问题。 - -顺便说下内存的使用,只有在运行虚拟机时,虚拟机才会使用内存。否则,它将可用于常规使用。 - -确保其余设置与示例匹配,并点击 Create。 - -![Assign 15-20 GB of disk space in VDI format][14] - -在你点击虚拟机的 Start 按钮之前,你需要加载如下所示的 ISO [光驱]。 - -![Add the Fedora ISO to optical drive storage][15] - -因为你的虚拟硬盘是空的,虚拟机将从这个 ISO 启动。可以把它看作是使用 live USB 或磁盘安装 Linux。 - -![Go to Settings and add ISO as optical drive][16] - -然后,如果您有一个多核CPU,建议为虚拟机分配 2 个或更多的核。您可以在 system 选项卡下找到 CPU 核心。配置系统时,单击 ok 并启动虚拟机。 - -![Optional step: Assign number of CPU cores][17] - -配置好所有内容后,单击 start 按钮开始安装。 - -#### 步骤四:在 VirtualBox 中安装 Fedora。 - -如果您正确地遵循了这个过程,那么当您启动虚拟机时,您将直接从 ISO 文件启动。当您看到类似下面的屏幕时,选择 Start Fedora,并按 enter 键。 - -![Fedora running in live environment in virtual machine][18] - -要启动安装对话框,单击 Install To Hard Drive。 - -![Click on “install to hard drive”][19] - -在您继续安装之前,有必要定义您的键盘布局、您的时区以及最终安装操作系统的位置。 - -![Choose keyboard, time and date and then go to Installation Destination][20] - -划分过程很简单。您像前面的 VDI 那样划分一些空闲空间。它应该被自动识别。 - - -选择您的磁盘并将存储配置设置为 automatic。单击 Done 进入上一个对话框。 - -![Disk should be automatically recognized][21] - -一旦你配置了上面的,点击 “Begin Installation”。 - -![Begin installation of Fedora][22] - -现在只需等待 5 - 6 分钟即可完成安装。安装完成后,点击 “Finish installation” 按钮。 - -最后一步,需要关闭系统的电源。如果您不熟悉 GNOME 桌面环境,您可以这样做。 - -![Turn off Fedora live environment after installation][23] - -您必须手动卸载在初始步骤中加载的 ISO 文件。 - -![Remove Fedora ISO From Optical Drive][24] - -下一次使用 Fedora 启动虚拟机时,系统将提示您为 Fedora Linux 创建用户帐户并设置密码。 - -### 使用 VirtualBox 客户添加的附加功能,如剪贴板共享,文件夹共享等 - -[增强功能包][25] 客户附加程序设计为在客户操作系统安装后安装在虚拟机中。它们包含对客户操作系统进行优化的设备驱动程序和系统应用程序,以获得更好的性能和可用性。 - -客户添加 ISO 文件被安装为虚拟 CD-ROM 以便安装。 - -这是一个简单的过程。只需单击设备选项卡,然后单击 “Insert Guest Additions CD image”。 - -![][26] - -当提示符单击 download 时,系统将弹出您下载增强功能包界面。 - -![Install VirtualBox Guest Additions][27] - -#### **共享剪贴板** - -有时候,您需要在虚拟机和主机操作系统之间移动一些内容。共享剪贴板/拖放支持将允许您在一个平台上复制项目,并将它们粘贴到另一个平台上。 - -要启用此功能,请在VirtualBox主页上选择 **Settings**,并按照下面的说明操作。**双向** 的选项是最方便的。 - -![Enable clipboard sharing between guest and host systems][28] - -#### **共享文件夹** - -有两种类型的分享: - - * 永久共享,与虚拟机设置一起保存。 - * 暂态共享,当虚拟机关闭时就会消失。可以使用 VirtualBox 管理器中的复选框创建暂态共享。 - - - -在本教程中,我将创建一个永久共享文件夹。在 VM 设置中添加您想要共享的主机系统文件夹,并选择您想要在 VM 中出现的名称。 - -![][29] - -下次启动虚拟机时,该文件夹应该显示为网络驱动器。 - -![][30] - -#### **更好的视频支持** - -虽然 Oracle VirtualBox 提供了所有基本功能的虚拟显卡,但客户添加的自定义视频驱动程序为您提供了超高和非标准的视频模式,以及加速的视频性能。 - -使用增强安装包,操作系统的分辨率将随着您调整计算机上的 VirtualBox 窗口而动态调整大小。 - -最后,增强安装包可以利用您的计算机的显卡。如果你是一名游戏玩家或在 WM 中使用高效软件,这就会产生巨大的改变。 - -#### USB 和网络设备共享 - -有了 VirtualBox,用户就可以使用一个功能齐全的操作系统,而不必在不同的硬件上进行设置。然而,在主机和客户机器之间共享USB和网络设备并不像想的那样简单。 - -要访问USB设备,您将需要安装 [VirtualBox 扩展包][31]. - -![Install VirtualBox Extensions pack][32] - -_**下面这些仅对 Linux**_,因为我使用的是 Linux。 - -为了使 VirtualBox 能够访问 USB 子系统,运行 VirtualBox 的用户(在主机系统上)必须属于 vboxuser 组。为此,打开一个终端并发出以下命令: - -``` -sudo usermod -aG vboxusers 'your username' -``` - -运行该命令后,您应该注销并重新登录,或者重新启动主机。 - -在这一步,插入你的 u 盘,通过你的 VM 设置,你应该能够找到并添加介质,如例子中所示。 - -![][33] - -当您下次启动虚拟机,您的USB将是可访问的。 - -![][34] - -### 额外提示:保存并导出虚拟机,以便以后可以在任何系统上使用它 - -您可能想在另一台计算机上使用虚拟机,或者是时候构建一台新机器了,并且您需要保持虚拟机的原样。只需几个简单的步骤,就可以轻松地导出当前设置并将其导入到另一台机器。 - -在 VirtualBox 主面板上,单击 file 和 export 工具。如果你喜欢键盘快捷键,你可以简单地点击 **Ctrl+E** - -![][35] - -选择要导出的虚拟机,然后单击 next。 - -![][36] - -格式选项需要注意一下。开放虚拟化格式 0.9、1.0 和 2.0 有三种不同的选项,可以是 ovf 或 ova 扩展。 - - -使用 ovf 扩展名,可以分别编写几个文件,而 ova 扩展名则将所有文件合并到一个开放的虚拟化格式归档文件中。 - - -默认格式 Open Virtualization format 1.0 应该没问题。 - -![][37] - -要完成该过程,单击 next,然后在下一个对话框中单击 export。 - -#### 总结 - -通过使用虚拟机,您不仅可以测试操作系统,还可以部署与物理机器同等重要的功能完整的系统。如今,硬件已经变得如此强大和廉价,它的大部分功能都没有被利用。 - - -通过虚拟化技术,您可以使用这些浪费的资源。对物理机器的需求减少了,因此能源消耗也减少了。您可以从硬件和降低运行成本两方面省钱。 - - -在更大的范围内,服务器虚拟化更多的是一种基本需求,而不是一种高级概念。 - - -我希望本教程对您在 VirtualBox 中安装 Fedora Linux 有帮助。如果你遇到任何问题,请在评论中告诉我。 - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/install-fedora-in-virtualbox/ - -作者:[Dimitrios Savvopoulos][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/frogOAO) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/dimitrios/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/create-fedora-live-usb-ubuntu/ -[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/install-fedora-in-virtualbox.png?resize=800%2C450&ssl=1 -[3]: https://itsfoss.com/install-virtualbox-ubuntu/ -[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/download-virtulabox.jpg?resize=799%2C294&ssl=1 -[5]: https://www.virtualbox.org/ -[6]: https://getfedora.org/en/iot/ -[7]: https://getfedora.org/en/workstation/ -[8]: https://getfedora.org/en/server/ -[9]: https://spins.fedoraproject.org/ -[10]: https://itsfoss.com/fedora-33/ -[11]: https://getfedora.org/ -[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/0.-create-a-new-vm.png?resize=800%2C550&ssl=1 -[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/10/1-create-vm-fedora.png?resize=800%2C533&ssl=1 -[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/10/2-fedora-vm-disk.png?resize=800%2C533&ssl=1 -[15]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/fedora-vm-settings-iso.png?resize=800%2C640&ssl=1 -[16]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/3-fedora-vm-settings2.png?resize=800%2C600&ssl=1 -[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/10/4-fedora-vm-cpu.png?resize=800%2C533&ssl=1 -[18]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/6-fedora-vm-boot.png?resize=800%2C600&ssl=1 -[19]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/7-fedora-vm-install-1.png?resize=800%2C622&ssl=1 -[20]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/9-fedora-vm-partitioning-2.png?resize=800%2C706&ssl=1 -[21]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/10-fedora-vm-hdd.png?resize=732%2C645&ssl=1 -[22]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/12-fedora-vm-installation-1.png?resize=800%2C706&ssl=1 -[23]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/15-power-off-fedora-gnome.png?resize=800%2C706&ssl=1 -[24]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/remove-fedora-iso-from-optical-drive.png?resize=800%2C589&ssl=1 -[25]: https://www.virtualbox.org/manual/ch04.html -[26]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/16-Fedora-vm-guest-additions.png?resize=800%2C706&ssl=1 -[27]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/17-Fedora-vm-guest-additions.png?resize=800%2C686&ssl=1 -[28]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/19-fedora-vm-shared-clipboard-2.png?resize=800%2C650&ssl=1 -[29]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/20-fedora-vm-shared-folders-1.png?resize=800%2C650&ssl=1 -[30]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/22-fedora-vm-shared-folders2-1.png?resize=800%2C547&ssl=1 -[31]: https://download.virtualbox.org/virtualbox/6.1.16/Oracle_VM_VirtualBox_Extension_Pack-6.1.16.vbox-extpack -[32]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/21.-fedora-vm-extension-pack.png?resize=800%2C600&ssl=1 -[33]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/25.-fedora-vm-usb-1.png?resize=800%2C527&ssl=1 -[34]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/26.-fedora-vm-usb-1.png?resize=800%2C578&ssl=1 -[35]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/23.-fedora-vm-export.png?resize=800%2C600&ssl=1 -[36]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/24.-fedora-vm-export-1.png?resize=800%2C545&ssl=1 -[37]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/25.-fedora-vm-export-800x545.png?resize=800%2C545&ssl=1 From 147d3570e38e7ae3a69e379b6ea59bcac2504128 Mon Sep 17 00:00:00 2001 From: niko Date: Mon, 23 Nov 2020 21:26:32 +0800 Subject: [PATCH 053/139] frogOAO --- ...s for USB, Clipboard and Folder Sharing.md | 281 ++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 translated/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md diff --git a/translated/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md b/translated/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md new file mode 100644 index 0000000000..4ccd0f00f6 --- /dev/null +++ b/translated/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md @@ -0,0 +1,281 @@ +[#]: collector: (lujun9972) +[#]: translator: (frogOAO) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Install Fedora in VirtualBox [With Steps for USB, Clipboard and Folder Sharing]) +[#]: via: (https://itsfoss.com/install-fedora-in-virtualbox/) +[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/) + +如何在 Fedora 中安装 VirtualBox 【附带 USB,剪切板,文件夹共享教程】 +====== + +如果您对 Fedora Linux 感兴趣,这有几种方式可以尝试它。 + +最简单还不影响您操作系统的方式是 [制作 Fedora 的 USB 启动盘][1] + +另一种方式是安装 VirtualBox 利用虚拟化技术来尝试 Fedora。这样,你可以在你的操作系统上像使用应用程序一样使用 Fedora。 + +通过这种方式,您可以执行更彻底的测试,而不会搞乱当前的操作系统。 + +您甚至可以复制您的虚拟安装程序,并在其他系统上重新安装它。听起来方便吗?让我来教你怎么做。 + +### 在 Fedora 上安装 Fedora + +![][2] + +让我们分步在 Oracle VirtualBox 上安装 Fedora。 + +#### 步骤一:安装 VirtualBox + +如果您的系统还没有安装 VirtualBox,您可以从官方网站下载。您可以找到 Windows,MacOs 和 Linux 的说明。 [Ubuntu 用户可以参考这个关于安装 VirtualBox 的详细教程。][3]. + +![][4] + +[下载 VirtualBox][5] + +#### **步骤二: 下载 Fedora ISO** + +如果您不熟悉 Fedora,那么这些镜像您需要知道。 + +[Fedora IoT][6] 是用于可扩展基础设施的, [Fedora workstation][7] 是一个镜像,带有一组面向普通GNOME桌面环境中的桌面的工具。[Fedora server][8] 顾名思义,是为服务器或数据中心定制的。 + +如果GNOME不是您的首选,您可以下载一个带有替代桌面环境的[定制版][9]Fedora桌面。 对于本教程,我选择了带有GNOME桌面环境的[Fedora 33][10]。 + +[下载 Fedora][11] + +#### 步骤三: 创建一个空虚拟机并对其进行配置 + +要成功安装和运行 Fedora,至少需要 20GB 磁盘空间和 2GB RAM。不过,为了获得更流畅的用户体验,建议增加一倍。在此基础上,我将创建并配置虚拟机。 + +开启 Virtual Box 点击 New。 + +![创建一个新的虚拟机][12] + +需要注意,最重要的选项是 **将类型设置为 Linux and 版本设置为 Fedora (64-bit)**。如果您在名称提示符处开始输入 Fedora,VirtualBox 将自动为您选择正确的设置。虽然名字不一定非得是 Fedora,它可以是任何你喜欢的。 + +_如果您只能访问32位版本,那么您需要在 BIOS 上启用虚拟化技术,如果您有一个 AMD CPU,它被称为 SVM。最坏的情况是您的 CPU 不支持虚拟化技术。如果你不确定,先检查这个。_ + +如果您的设置和我一样,点击 create 按钮。 + +![Name your VM and assign it at least 3 GB RAM][13] + +如前所述,至少需要 20gb 的磁盘空间才能安装 Fedora。我的系统上有 32gb 的内存,所以我分配了 8gb。3 GB 的内存应该没问题。 + +顺便说下内存的使用,只有在运行虚拟机时,虚拟机才会使用内存。否则,它将可用于常规使用。 + +确保其余设置与示例匹配,并点击 Create。 + +![Assign 15-20 GB of disk space in VDI format][14] + +在你点击虚拟机的 Start 按钮之前,你需要加载如下所示的 ISO [光驱]。 + +![Add the Fedora ISO to optical drive storage][15] + +因为你的虚拟硬盘是空的,虚拟机将从这个 ISO 启动。可以把它看作是使用 live USB 或磁盘安装 Linux。 + +![Go to Settings and add ISO as optical drive][16] + +然后,如果您有一个多核CPU,建议为虚拟机分配 2 个或更多的核。您可以在 system 选项卡下找到 CPU 核心。配置系统时,单击 ok 并启动虚拟机。 + +![Optional step: Assign number of CPU cores][17] + +配置好所有内容后,单击 start 按钮开始安装。 + +#### 步骤四:在 VirtualBox 中安装 Fedora。 + +如果您正确地遵循了这个过程,那么当您启动虚拟机时,您将直接从 ISO 文件启动。当您看到类似下面的屏幕时,选择 Start Fedora,并按 enter 键。 + +![Fedora running in live environment in virtual machine][18] + +要启动安装对话框,单击 Install To Hard Drive。 + +![Click on “install to hard drive”][19] + +在您继续安装之前,有必要定义您的键盘布局、您的时区以及最终安装操作系统的位置。 + +![Choose keyboard, time and date and then go to Installation Destination][20] + +划分过程很简单。您像前面的 VDI 那样划分一些空闲空间。它应该被自动识别。 + + +选择您的磁盘并将存储配置设置为 automatic。单击 Done 进入上一个对话框。 + +![Disk should be automatically recognized][21] + +一旦你配置了上面的,点击 “Begin Installation”。 + +![Begin installation of Fedora][22] + +现在只需等待 5 - 6 分钟即可完成安装。安装完成后,点击 “Finish installation” 按钮。 + +最后一步,需要关闭系统的电源。如果您不熟悉 GNOME 桌面环境,您可以这样做。 + +![Turn off Fedora live environment after installation][23] + +您必须手动卸载在初始步骤中加载的 ISO 文件。 + +![Remove Fedora ISO From Optical Drive][24] + +下一次使用 Fedora 启动虚拟机时,系统将提示您为 Fedora Linux 创建用户帐户并设置密码。 + +### 使用 VirtualBox 客户添加的附加功能,如剪贴板共享,文件夹共享等 + +[增强功能包][25] 客户附加程序设计为在客户操作系统安装后安装在虚拟机中。它们包含对客户操作系统进行优化的设备驱动程序和系统应用程序,以获得更好的性能和可用性。 + +客户添加 ISO 文件被安装为虚拟 CD-ROM 以便安装。 + +这是一个简单的过程。只需单击设备选项卡,然后单击 “Insert Guest Additions CD image”。 + +![][26] + +当提示符单击 download 时,系统将弹出您下载增强功能包界面。 + +![Install VirtualBox Guest Additions][27] + +#### **共享剪贴板** + +有时候,您需要在虚拟机和主机操作系统之间移动一些内容。共享剪贴板/拖放支持将允许您在一个平台上复制项目,并将它们粘贴到另一个平台上。 + +要启用此功能,请在VirtualBox主页上选择 **Settings**,并按照下面的说明操作。**双向** 的选项是最方便的。 + +![Enable clipboard sharing between guest and host systems][28] + +#### **共享文件夹** + +有两种类型的分享: + + * 永久共享,与虚拟机设置一起保存。 + * 暂态共享,当虚拟机关闭时就会消失。可以使用 VirtualBox 管理器中的复选框创建暂态共享。 + + + +在本教程中,我将创建一个永久共享文件夹。在 VM 设置中添加您想要共享的主机系统文件夹,并选择您想要在 VM 中出现的名称。 + +![][29] + +下次启动虚拟机时,该文件夹应该显示为网络驱动器。 + +![][30] + +#### **更好的视频支持** + +虽然 Oracle VirtualBox 提供了所有基本功能的虚拟显卡,但客户添加的自定义视频驱动程序为您提供了超高和非标准的视频模式,以及加速的视频性能。 + +使用增强安装包,操作系统的分辨率将随着您调整计算机上的 VirtualBox 窗口而动态调整大小。 + +最后,增强安装包可以利用您的计算机的显卡。如果你是一名游戏玩家或在 WM 中使用高效软件,这就会产生巨大的改变。 + +#### USB 和网络设备共享 + +有了 VirtualBox,用户就可以使用一个功能齐全的操作系统,而不必在不同的硬件上进行设置。然而,在主机和客户机器之间共享USB和网络设备并不像想的那样简单。 + +要访问USB设备,您将需要安装 [VirtualBox 扩展包][31]. + +![Install VirtualBox Extensions pack][32] + +_**下面这些仅对 Linux**_,因为我使用的是 Linux。 + +为了使 VirtualBox 能够访问 USB 子系统,运行 VirtualBox 的用户(在主机系统上)必须属于 vboxuser 组。为此,打开一个终端并发出以下命令: + +``` +sudo usermod -aG vboxusers 'your username' +``` + +运行该命令后,您应该注销并重新登录,或者重新启动主机。 + +在这一步,插入你的 u 盘,通过你的 VM 设置,你应该能够找到并添加介质,如例子中所示。 + +![][33] + +当您下次启动虚拟机,您的USB将是可访问的。 + +![][34] + +### 额外提示:保存并导出虚拟机,以便以后可以在任何系统上使用它 + +您可能想在另一台计算机上使用虚拟机,或者是时候构建一台新机器了,并且您需要保持虚拟机的原样。只需几个简单的步骤,就可以轻松地导出当前设置并将其导入到另一台机器。 + +在 VirtualBox 主面板上,单击 file 和 export 工具。如果你喜欢键盘快捷键,你可以简单地点击 **Ctrl+E** + +![][35] + +选择要导出的虚拟机,然后单击 next。 + +![][36] + +格式选项需要注意一下。开放虚拟化格式 0.9、1.0 和 2.0 有三种不同的选项,可以是 ovf 或 ova 扩展。 + + +使用 ovf 扩展名,可以分别编写几个文件,而 ova 扩展名则将所有文件合并到一个开放的虚拟化格式归档文件中。 + + +默认格式 Open Virtualization format 1.0 应该没问题。 + +![][37] + +要完成该过程,单击 next,然后在下一个对话框中单击 export。 + +#### 总结 + +通过使用虚拟机,您不仅可以测试操作系统,还可以部署与物理机器同等重要的功能完整的系统。如今,硬件已经变得如此强大和廉价,它的大部分功能都没有被利用。 + + +通过虚拟化技术,您可以使用这些浪费的资源。对物理机器的需求减少了,因此能源消耗也减少了。您可以从硬件和降低运行成本两方面省钱。 + + +在更大的范围内,服务器虚拟化更多的是一种基本需求,而不是一种高级概念。 + + +我希望本教程对您在 VirtualBox 中安装 Fedora Linux 有帮助。如果你遇到任何问题,请在评论中告诉我。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-fedora-in-virtualbox/ + +作者:[Dimitrios Savvopoulos][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/frogOAO) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/dimitrios/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/create-fedora-live-usb-ubuntu/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/install-fedora-in-virtualbox.png?resize=800%2C450&ssl=1 +[3]: https://itsfoss.com/install-virtualbox-ubuntu/ +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/download-virtulabox.jpg?resize=799%2C294&ssl=1 +[5]: https://www.virtualbox.org/ +[6]: https://getfedora.org/en/iot/ +[7]: https://getfedora.org/en/workstation/ +[8]: https://getfedora.org/en/server/ +[9]: https://spins.fedoraproject.org/ +[10]: https://itsfoss.com/fedora-33/ +[11]: https://getfedora.org/ +[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/0.-create-a-new-vm.png?resize=800%2C550&ssl=1 +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/10/1-create-vm-fedora.png?resize=800%2C533&ssl=1 +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/10/2-fedora-vm-disk.png?resize=800%2C533&ssl=1 +[15]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/fedora-vm-settings-iso.png?resize=800%2C640&ssl=1 +[16]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/3-fedora-vm-settings2.png?resize=800%2C600&ssl=1 +[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/10/4-fedora-vm-cpu.png?resize=800%2C533&ssl=1 +[18]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/6-fedora-vm-boot.png?resize=800%2C600&ssl=1 +[19]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/7-fedora-vm-install-1.png?resize=800%2C622&ssl=1 +[20]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/10/9-fedora-vm-partitioning-2.png?resize=800%2C706&ssl=1 +[21]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/10-fedora-vm-hdd.png?resize=732%2C645&ssl=1 +[22]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/12-fedora-vm-installation-1.png?resize=800%2C706&ssl=1 +[23]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/15-power-off-fedora-gnome.png?resize=800%2C706&ssl=1 +[24]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/remove-fedora-iso-from-optical-drive.png?resize=800%2C589&ssl=1 +[25]: https://www.virtualbox.org/manual/ch04.html +[26]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/16-Fedora-vm-guest-additions.png?resize=800%2C706&ssl=1 +[27]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/17-Fedora-vm-guest-additions.png?resize=800%2C686&ssl=1 +[28]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/19-fedora-vm-shared-clipboard-2.png?resize=800%2C650&ssl=1 +[29]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/20-fedora-vm-shared-folders-1.png?resize=800%2C650&ssl=1 +[30]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/22-fedora-vm-shared-folders2-1.png?resize=800%2C547&ssl=1 +[31]: https://download.virtualbox.org/virtualbox/6.1.16/Oracle_VM_VirtualBox_Extension_Pack-6.1.16.vbox-extpack +[32]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/21.-fedora-vm-extension-pack.png?resize=800%2C600&ssl=1 +[33]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/25.-fedora-vm-usb-1.png?resize=800%2C527&ssl=1 +[34]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/26.-fedora-vm-usb-1.png?resize=800%2C578&ssl=1 +[35]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/23.-fedora-vm-export.png?resize=800%2C600&ssl=1 +[36]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/24.-fedora-vm-export-1.png?resize=800%2C545&ssl=1 +[37]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/25.-fedora-vm-export-800x545.png?resize=800%2C545&ssl=1 From d662ae3082ccc6894ad1f991f30a095d5a5d8e4f Mon Sep 17 00:00:00 2001 From: niko Date: Mon, 23 Nov 2020 21:31:50 +0800 Subject: [PATCH 054/139] frogOAO --- ...tualBox -With Steps for USB, Clipboard and Folder Sharing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md b/translated/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md index 4ccd0f00f6..47d60deb03 100644 --- a/translated/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md +++ b/translated/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md @@ -54,7 +54,7 @@ 需要注意,最重要的选项是 **将类型设置为 Linux and 版本设置为 Fedora (64-bit)**。如果您在名称提示符处开始输入 Fedora,VirtualBox 将自动为您选择正确的设置。虽然名字不一定非得是 Fedora,它可以是任何你喜欢的。 -_如果您只能访问32位版本,那么您需要在 BIOS 上启用虚拟化技术,如果您有一个 AMD CPU,它被称为 SVM。最坏的情况是您的 CPU 不支持虚拟化技术。如果你不确定,先检查这个。_ +_如果您只能访问 32 位版本,那么您需要在 BIOS 上启用虚拟化技术,如果您有一个 AMD CPU,它被称为 SVM。最坏的情况是您的 CPU 不支持虚拟化技术。如果你不确定,先检查这个。_ 如果您的设置和我一样,点击 create 按钮。 From ca670ca18e48e515e8cbc5efb7eda08d13eadfff Mon Sep 17 00:00:00 2001 From: DarkSun Date: Tue, 24 Nov 2020 05:02:18 +0800 Subject: [PATCH 055/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201124=20?= =?UTF-8?q?Compare=20Files=20and=20Folders=20Graphically=20in=20Linux=20Wi?= =?UTF-8?q?th=20Meld?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201124 Compare Files and Folders Graphically in Linux With Meld.md --- ... Folders Graphically in Linux With Meld.md | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 sources/tech/20201124 Compare Files and Folders Graphically in Linux With Meld.md diff --git a/sources/tech/20201124 Compare Files and Folders Graphically in Linux With Meld.md b/sources/tech/20201124 Compare Files and Folders Graphically in Linux With Meld.md new file mode 100644 index 0000000000..8fc78ae320 --- /dev/null +++ b/sources/tech/20201124 Compare Files and Folders Graphically in Linux With Meld.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Compare Files and Folders Graphically in Linux With Meld) +[#]: via: (https://itsfoss.com/meld-gui-diff/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Compare Files and Folders Graphically in Linux With Meld +====== + +How do you compare two similar files to check for differences? The obvious answer is [to use the diff command in Linux][1]. + +The problem is that not everyone would be comfortable comparing files in Linux terminal. And the diff command output could be confusing for some. + +Take this diff command output for example: + +![][2] + +There is definitely a learning curve involved here. However, if you are using desktop Linux, you can use [GUI][3] applications to easily compare two files for any differences. + +There are several GUI diff tools available for Linux. I am going to highlight my favorite tool Meld in this week’s Linux application highlight. + +### Meld: Visual Diff and Merge tool for Linux (and Windows) + +With [Meld][4], you can compare two files in side by side view. Not only that, you may also modify the files to make changes accordingly. That’s what you would want to do in most situations, right? + +![File Comparison][5] + +Meld is also capable of comparing directories and show which files are different. It will also show while files are new or missing. + +![Directory Comparison][6] + +You may also use Meld for a three-way comparison. + +![Three Way File Comparison][7] + +The graphical side-by-side comparison helps in a number of situations. If you are a developer, you can use it to understand code patches. Meld also supports version control systems like Git, [Mercurial][8], [Subversion][9] etc. + +### Features of Meld + +![][10] + +The open source Meld tools has the following main features: + + * Perform two and three-way difference comparison + * Edit files in-place and the difference comparison updates immediately + * Navigate between differences and conflicts + * Visualize global and local differences with insertions, changes and conflicts marked accordingly + * Use regex text filtering to ignore certain differences + * Syntax highlighting + * Compare two or three directories for newly added, missing and altered files + * Exclude some files from comparison + * Support for popular version control systems like Git, Mercurial, Bazaar and SVN + * Support for many international languages + * Open source GPL v2 license + * Available for Linux as well as Windows + + + +### Installing Meld on Linux + +Meld is a popular application and it is available in the official repositories of most Linux distributions. + +Check your distribution’s software center and see if Meld is available. + +![Meld In Ubuntu Software Center][11] + +Alternatively, you can also use command line package manager of your distribution to install Meld. On [Ubuntu, it is available in the Universe repository][12] and can be [installed using the apt command][13]: + +``` +sudo apt install meld +``` + +You may find the source code of Meld on GNOME’s GitLab repository: + +[Meld Source Code][14] + +### Worth it? + +I know that [most modern open source code editors][15] come with this feature but sometimes you just want a simple interface without the trouble of installing additional add-ons for comparing files. Meld provides you just that. + +Do you use some other tools for checking differences between files? Which tool would that be? What’s your experience with Meld, if you ever used it? The comment sections is all yours for sharing your opinion. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/meld-gui-diff/ + +作者:[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://linuxhandbook.com/diff-command/ +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/diff-command-complicated-output.png?resize=795%2C551&ssl=1 +[3]: https://itsfoss.com/gui-cli-tui/ +[4]: https://meldmerge.org +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/file-comaprison-in-Linux-with-meld.png?resize=800%2C498&ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/directory-comparison-in-Linux-with_meld.png?resize=800%2C497&ssl=1 +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/three-way-file-comaprison-with-meld-in-linux.png?resize=800%2C466&ssl=1 +[8]: https://www.mercurial-scm.org/ +[9]: https://subversion.apache.org/ +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/meld-visual-diff.png?resize=786%2C455&ssl=1 +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/Meld-in-Ubuntu-Software-Center.png?resize=800%2C384&ssl=1 +[12]: https://itsfoss.com/ubuntu-repositories/ +[13]: https://itsfoss.com/apt-command-guide/ +[14]: https://gitlab.gnome.org/GNOME/meld +[15]: https://itsfoss.com/best-modern-open-source-code-editors-for-linux/ From 0c5149d14af9d575a0da0caa79a1b2c6fac2ed89 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Tue, 24 Nov 2020 05:02:36 +0800 Subject: [PATCH 056/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201123=20?= =?UTF-8?q?6=20predictions=20for=20JavaScript=20build=20tools?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201123 6 predictions for JavaScript build tools.md --- ... predictions for JavaScript build tools.md | 152 ++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 sources/tech/20201123 6 predictions for JavaScript build tools.md diff --git a/sources/tech/20201123 6 predictions for JavaScript build tools.md b/sources/tech/20201123 6 predictions for JavaScript build tools.md new file mode 100644 index 0000000000..630df77227 --- /dev/null +++ b/sources/tech/20201123 6 predictions for JavaScript build tools.md @@ -0,0 +1,152 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (6 predictions for JavaScript build tools) +[#]: via: (https://opensource.com/article/20/11/javascript-build-tools) +[#]: author: (Shedrack Akintayo https://opensource.com/users/shedrack-akintayo) + +6 predictions for JavaScript build tools +====== +The JavaScript frontend tooling ecosystem is dynamic and competitive, +and only the best survive. +![Magnifying glass on code][1] + +Code used in production is different from development code. In production, you need to build packages that run fast, manage dependencies, automate tasks, load external modules, and more. [JavaScript][2] tools that make it possible to turn development code into production code are called _build tools._ + +The reason frontend code is "built" can be explained by looking into the various build steps and their importance. + +### Steps in building frontend code + +There are four steps involved in building frontend code: + +#### 1\. Transpiling + +Transpiling lets developers take advantage of the newest, hottest updates to languages and extensions and maintain browser compatibility. Here is an example using [Babel][3]: + + +``` +// arrow function syntax in array map +const double = [1, 2, 3].map((num) => num * 2); +// after being transpiled +const double = [1, 2, 3].map(function(num) { +  return num * 2; +}); +``` + +#### 2\. Bundling + +Bundling is the process of taking all the "import" or "require" statements; finding the matching JavaScript snippets, packages, and libraries; adding them to the appropriate scope; and packaging it all into one big JavaScript file. Commonly used bundlers include Browserify, Webpack, and Parcel. + +#### 3\. Minifing + +Minifying reduces the final file size by removing white space and code comments. You can take this a step further by adding an obfuscate step, which changes variable names and method names, obscuring the code, so it is less human-readable once it's delivered to the client. Here is an example using Grunt: + + +``` +// before minifying +const double = [1, 2, 3].map(function(num) { +  return num * 2; +}); +// after minifying +const double = [1, 2, 3].map(function(num) { +  return num * 2; +}); +``` + +#### 4\. Packaging + +After all the steps above are finished, the compatible, bundled, minified/obfuscated file must be put somewhere. Packaging is the process of putting the results of the above steps somewhere specified by the developer. This is usually done by the bundler. + +### Frontend build tools + +Frontend tooling and build tools can be split into the following categories: + + * Package managers: NPM, Yarn + * Transpilers: Babel, etc. + * Bundlers: Webpack, Parcel, Browserify + * Minifiers: UglifyJS, Packer, Minify, etc. + + + +There are a variety of build tools you can use in the JavaScript ecosystem, including the following. + +#### Grunt and Bower + +[Grunt][4] was introduced as a command-line tool that provided just one script to specify and configure tasks. [Bower][5] followed shortly after as a way to manage client-side packages. The two, along with NPM, seemed to fulfill the majority of automation needs and were used regularly together. The problem with Grunt was that it didn't provide developers the freedom to configure more complex task chains, while Bower made developers manage twice as many packages as usual because it separates frontend and backend packages (i.e., Bower components vs. Node modules). + +**The future of Grunt and Bower:** Grunt and Bower are on their way out of the JavaScript tooling ecosystem, but there are several replacements. + +#### Gulp and Browserify + +[Gulp][6] was released a year and a half after Grunt. It felt natural. Writing a build script in JavaScript compared to JSON gave freedom. You could write functions, create variables on the fly, use conditionals anywhere—not that this would make for a particularly good-looking build script, but it was possible. [Browserify][7] and Gulp can be used in tandem. Browserify allows NPM packages (which are for backend Node servers) to be brought into the frontend, making Bower obsolete. It also looks and feels better, with one package manager for the frontend and backend. + +**The future of Gulp:** Gulp can be improved to match the current popular build tools, but this is entirely up to the creators. It is still in use but not as popular as it was before. + +#### Webpack and NPM/Yarn scripts + +[Webpack][8] is the hottest kid on the block in modern frontend development tooling. Webpack is an open-source JavaScript module bundler. It is made primarily for JavaScript, but it can transform frontend assets like HTML, CSS, and images if the corresponding loaders are included. With Webpack, you can also write scripts like Gulp and execute them with [NPM/Yarn][9]. + +**The future of Webpack:** Webpack is currently the hottest thing in the JavaScript tooling ecosystem, and all the JS cool kids are using React and Webpack these days. It is currently in version 4 and not going anywhere anytime soon. + +#### Parcel + +[Parcel][10] is a web application bundler that launched in 2018 and is differentiated by its developer experience. It offers blazing-fast performance utilizing multicore processing and requires zero configuration. Parcel is also a new kid on the block, but adoption hasn't been fast, especially for large applications. Developers prefer to use Webpack over Parcel because of the former's extensive support and customizability. + +**The future of Parcel:** Parcel is very easy to use, it is faster than Webpack if you measure bundle and build time, and it also offers a better developer experience. The reason Parcel hasn't been adopted much might be because it's still relatively new. Parcel has a very bright future in the frontend build tools ecosystem, and it will be around for a while. + +#### Rollup + +[Rollup][11] is a module bundler for JavaScript that compiles small pieces of code into something larger and more complex, such as a library or an application. It is advisable to use Rollup when building a library with minimal third-party imports. + +**The future of Rollup:** Rollup is super-cool and is being adopted rapidly. It has great features and will be part of the frontend tooling ecosystem for a long time. + +### Learn more + +The JavaScript tooling ecosystem is dynamic and competitive, and only the best tools survive. In the future, we will see tools that require less (or no) configuration, better customizability, more extensibility, and higher speed. + +The tools you use for an application's frontend are a personal call that you need to make based on your project's requirements. Choose what works best for you, and most of the time, there are tradeoffs. + +For more information, see: + + * [JavaScript tooling: The evolution and future of JS/frontend build tools][12] + * [Tools and modern workflow for frontend developers][13] + * [Modern frontend: The tools and build process explained][14] + * [Best build tools in frontend development][15] + + + +* * * + +_This article originally appeared on [Shedrack Akintayo's blog][16] and is republished with his permission._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/11/javascript-build-tools + +作者:[Shedrack Akintayo][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/shedrack-akintayo +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0 (Magnifying glass on code) +[2]: https://www.javascript.com/ +[3]: https://babeljs.io/ +[4]: https://gruntjs.com/ +[5]: https://bower.io/ +[6]: https://gulpjs.com/ +[7]: http://browserify.org/ +[8]: https://webpack.js.org/ +[9]: https://github.com/yarnpkg/yarn +[10]: https://parceljs.org/ +[11]: https://rollupjs.org/guide/en/ +[12]: https://qmo.io/blog/javascript-tooling-the-evolution-and-future-of-js-front-end-build-tools/ +[13]: https://blog.logrocket.com/tools-and-modern-workflow-for-front-end-developers-505c7227e917/ +[14]: https://medium.com/@trevorpoppen/modern-front-end-the-tools-and-build-process-explained-36641b5c1a53 +[15]: https://www.developerdrive.com/best-build-tools-frontend-development/ +[16]: https://www.sheddy.xyz/posts/javascript-build-tools-past-and-beyond From a512d19bec9ce507712b14f4a76063e72c5c6604 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Tue, 24 Nov 2020 05:02:49 +0800 Subject: [PATCH 057/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201123=20?= =?UTF-8?q?A=20beginner's=20guide=20to=20Kubernetes=20Jobs=20and=20CronJob?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201123 A beginner-s guide to Kubernetes Jobs and CronJobs.md --- ...s guide to Kubernetes Jobs and CronJobs.md | 233 ++++++++++++++++++ 1 file changed, 233 insertions(+) create mode 100644 sources/tech/20201123 A beginner-s guide to Kubernetes Jobs and CronJobs.md diff --git a/sources/tech/20201123 A beginner-s guide to Kubernetes Jobs and CronJobs.md b/sources/tech/20201123 A beginner-s guide to Kubernetes Jobs and CronJobs.md new file mode 100644 index 0000000000..21af972870 --- /dev/null +++ b/sources/tech/20201123 A beginner-s guide to Kubernetes Jobs and CronJobs.md @@ -0,0 +1,233 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (A beginner's guide to Kubernetes Jobs and CronJobs) +[#]: via: (https://opensource.com/article/20/11/kubernetes-jobs-cronjobs) +[#]: author: (Mike Calizo https://opensource.com/users/mcalizo) + +A beginner's guide to Kubernetes Jobs and CronJobs +====== +Use Jobs and CronJobs to control and manage Kubernetes pods and +containers. +![Ships at sea on the web][1] + +[Kubernetes][2] is the default orchestration engine for containers. Its options for controlling and managing pods and containers include: + + 1. Deployments + 2. StatefulSets + 3. ReplicaSets + + + +Each of these features has its own purpose, with the common function to ensure that pods run continuously. In failure scenarios, these controllers either restart or reschedule pods to ensure the services in the pods continue running. + +As the [Kubernetes documentation explains][3], a Kubernetes Job creates one or more pods and ensures that a specified number of the pods terminates when the task (Job) completes. + +Just like in a typical operating system, the ability to perform automated, scheduled jobs without user interaction is important in the Kubernetes world. But Kubernetes Jobs do more than just run automated jobs, and there are multiple ways to utilize them through: + + 1. Jobs + 2. CronJobs + 3. Work queues (this is beyond the scope of this article) + + + +Sounds simple right? Well, maybe. Anyone who works on containers and microservice applications knows that some require services to be transient so that they can do specific tasks for applications or within the Kubernetes clusters. + +In this article, I will go into why Kubernetes Jobs are important, how to create Jobs and CronJobs, and when to use them for applications running on the Kubernetes cluster. + +### Differences between Kubernetes Jobs and CronJobs + +Kubernetes Jobs are used to create transient pods that perform specific tasks they are assigned to. [CronJobs][4] do the same thing, but they run tasks based on a defined schedule. + +Jobs play an important role in Kubernetes, especially for running batch processes or important ad-hoc operations. Jobs differ from other Kubernetes controllers in that they run tasks until completion, rather than managing the desired state such as in Deployments, ReplicaSets, and StatefulSets. + +### How to create Kubernetes Jobs and CronJobs + +With that background in hand, you can start creating Jobs and CronJobs. + +#### Prerequisites + +To do this exercise, you need to have the following: + + 1. A working Kubernetes cluster; you can install it with either: + * [CentOS 8][5] + * [Minikube][6] + 2. The [kubectl][7] Kubernetes command line + + + +Here is the Minikube deployment I used for this demonstration: + + +``` +$ minikube version +minikube version: v1.8.1 + +$ kubectl cluster-info +Kubernetes master is running at +KubeDNS is running at + +$ kubectl get nodes +NAME       STATUS   ROLES    AGE   VERSION +minikube   Ready    master   88s   v1.17.3 +``` + +#### Kubernetes Jobs + +Just like anything else in the Kubernetes world, you can create Kubernetes Jobs with a definition file. Create a file called `sample-jobs.yaml` using your favorite editor. + +Here is a snippet of the file that you can use to create an example Kubernetes Job: + + +``` +apiVersion: batch/v1          ## The version of the Kubernetes API +kind: Job                     ## The type of object for jobs +metadata: + name: job-test +spec:                        ## What state you desire for the object + template: +   metadata: +     name: job-test +   spec: +     containers: +     - name: job +       image: busybox                  ##  Image used +       command: ["echo", "job-test"]   ##  Command used to create logs for verification later +     restartPolicy: OnFailure          ##  Restart Policy in case container failed +``` + +Next, apply the Jobs in the cluster: + + +``` +`$ kubectl apply -f sample-jobs.yaml` +``` + +Wait a few minutes for the pods to be created. You can view the pod creation's status: + + +``` +`$ kubectl get pod –watch` +``` + +After a few seconds, you should see your pod created successfully: + + +``` +$ kubectl get pods +  NAME                  READY   STATUS          RESTARTS         AGE +  job-test                      0/1     Completed       0            11s +``` + +Once the pods are created, verify the Job's logs: + + +``` +`$ kubectl logs job-test job-test` +``` + +You have created your first Kubernetes Job, and you can explore details about it: + + +``` +`$ kubectl describe job job-test` +``` + +Clean up the Jobs: + + +``` +`$ kubectl delete jobs job-test` +``` + +#### Kubernetes CronJobs + +You can use CronJobs for cluster tasks that need to be executed on a predefined schedule. As the [documentation explains][8], they are useful for periodic and recurring tasks, like running backups, sending emails, or scheduling individual tasks for a specific time, such as when your cluster is likely to be idle. + +As with Jobs, you can create CronJobs via a definition file. Following is a snippet of the CronJob file `cron-test.yaml`. Use this file to create an example CronJob: + + +``` +apiVersion: batch/v1beta1            ## The version of the Kubernetes API +kind: CronJob                        ## The type of object for Cron jobs +metadata: +  name: cron-test +spec: +  schedule: "*/1 * * * *"            ## Defined schedule using the *nix style cron syntax +  jobTemplate: +    spec: +      template: +        spec: +          containers: +          - name: cron-test +            image: busybox            ## Image used +            args: +           - /bin/sh +            - -c +            - date; echo Hello this is Cron test +          restartPolicy: OnFailure    ##  Restart Policy in case container failed +``` + +Apply the CronJob to your cluster: + + +``` +$ kubectl apply -f cron-test.yaml + cronjob.batch/cron-test created +``` + +Verify that the CronJob was created with the schedule in the definition file: + + +``` +$ kubectl get cronjob cron-test + NAME        SCHEDULE      SUSPEND   ACTIVE   LAST SCHEDULE   AGE + cron-test   */1 * * * *   False     0        <none>          10s +``` + +After a few seconds, you can find the pods that the last scheduled job created and view the standard output of one of the pods: + + +``` +$ kubectl logs cron-test-1604870760 +  Sun Nov  8 21:26:09 UTC 2020 +  Hello from the Kubernetes cluster +``` + +You have created a Kubernetes CronJob that creates an object once per execution based on the schedule `schedule: "*/1 * * * *"`. Sometimes the creation can be missed because of environmental issues in the cluster. Therefore, they need to be [idempotent][9]. + +### Other things to know + +Unlike deployments and services in Kubernetes, you can't change the same Job configuration file and reapply it at once. When you make changes in the Job configuration file, you must delete the previous Job from the cluster before you apply it. + +Generally, creating a Job creates a single pod and performs the given task, as in the example above. But by using completions and [parallelism][10], you can initiate several pods, one after the other. + +### Use your Jobs + +You can use Kubernetes Jobs and CronJobs to manage your containerized applications. Jobs are important in Kubernetes application deployment patterns where you need a communication mechanism along with interactions between pods and the platforms. This may include cases where an application needs a "controller" or a "watcher" to complete tasks or needs to be scheduled to run periodically. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/11/kubernetes-jobs-cronjobs + +作者:[Mike Calizo][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/mcalizo +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/kubernetes_containers_ship_lead.png?itok=9EUnSwci (Ships at sea on the web) +[2]: https://kubernetes.io/ +[3]: https://kubernetes.io/docs/concepts/workloads/controllers/job/ +[4]: https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/ +[5]: https://phoenixnap.com/kb/how-to-install-kubernetes-on-centos +[6]: https://minikube.sigs.k8s.io/docs/start/ +[7]: https://kubernetes.io/docs/reference/kubectl/kubectl/ +[8]: https://v1-18.docs.kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/ +[9]: https://en.wikipedia.org/wiki/Idempotence +[10]: https://kubernetes.io/docs/concepts/workloads/controllers/job/#parallel-jobs From 01f6e14b98072def62c9bcadb9b68f3034f2a657 Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 24 Nov 2020 08:46:17 +0800 Subject: [PATCH 058/139] translated --- ...01106 Reclaim hard-drive space with LVM.md | 90 ------------------- ...01106 Reclaim hard-drive space with LVM.md | 90 +++++++++++++++++++ 2 files changed, 90 insertions(+), 90 deletions(-) delete mode 100644 sources/tech/20201106 Reclaim hard-drive space with LVM.md create mode 100644 translated/tech/20201106 Reclaim hard-drive space with LVM.md diff --git a/sources/tech/20201106 Reclaim hard-drive space with LVM.md b/sources/tech/20201106 Reclaim hard-drive space with LVM.md deleted file mode 100644 index dcd1a96f7b..0000000000 --- a/sources/tech/20201106 Reclaim hard-drive space with LVM.md +++ /dev/null @@ -1,90 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Reclaim hard-drive space with LVM) -[#]: via: (https://fedoramagazine.org/reclaim-hard-drive-space-with-lvm/) -[#]: author: (Troy Curtis Jr https://fedoramagazine.org/author/troycurtisjr/) - -Reclaim hard-drive space with LVM -====== - -![Hard drive image][1] - -Photo by Frank R @ Unsplash.com - -LVM is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes. It is commonly used on Fedora installations (prior to BTRFS as default it was LVM+Ext4). But have you ever started up your system to find out that Gnome just said the home volume is almost out of space! Luckily, there is likely some space sitting around in another volume, unused and ready to re-alocate. Here’s how to reclaim hard-drive space with LVM. - -The key to easily re-alocate space between volumes is the [Logical Volume Manager (LVM)][2]. Fedora 32 and before use LVM to divide disk space by default. This technology is similar to standard hard-drive partitions, but LVM is a lot more flexible. LVM enables not only flexible volume size management, but also advanced capabilities such as read-write snapshots, striping or mirroring data across multiple drives, using a high-speed drive as a cache for a slower drive, and much more. All of these advanced options can get a bit overwhelming, but resizing a volume is straight-forward. - -### LVM basics - -The _volume group_ serves as the main container in the LVM system. By default Fedora only defines a single volume group, but there can be as many as needed. Actual hard-drive and hard-drive partitions are added to the _volume group_ as _physical volumes_. _Physical volumes_ add available free space to the _volume group_. A typical Fedora install has one formatted boot partition, and the rest of the drive is a partition configured as an LVM _physical volume_. - -Out of this pool of available space, the _volume group_ allocates one or more _logical volumes_. These volumes are similar to hard-drive partitions, but without the limitation of contiguous space on the disk. LVM _logical volumes_ can even span multiple devices! Just like hard-drive partitions, _logical volumes_ have a defined size and can contain any filesystem which can then be mounted to specific directories. - -### What’s needed - -Confirm the system uses LVM with the _gnome-disks_ application, and make sure there is free space available in some other volume. Without space to reclaim from another volume, this guide isn’t useful. A [Fedora live CD/USB][3] is also needed. Any file system that needs to shrink must be unmounted. Running from a live image allows all the volumes on the hard-disk to remain unmounted, even important directories like _/_ and _/home_. - -![Use gnome-disks to verify free space][4] - -### A word of warning - -No data should be lost by following this guide, but it does muck around with some very low-level and powerful commands. One mistake could destroy all data on the hard-drive. So backup all the data on the disk first! - -### Resizing LVM volumes - -To begin, boot the Fedora live image and select _Try Fedora_ at the dialog. Next, use the _Run Command_ to launch the _blivet-gui_ application (accessible by pressing _Alt-F2_, typing _blivet-gui_, then pressing _enter_). Select the volume group on the left under _LVM_. The logical volumes are on the right. - -![Explore logical volumes in blivet-gui][5] - -The logical volume labels consist of both the volume group name and the logical volume name. In the example, the volume group is “fedora_localhost-live” and there are “home”, “root”, and “swap” logical volumes allocated. To find the full volume, select each one, click on the _gear_ icon, and choose _resize_. The slider in the resize dialog indicates the allowable sizes for the volume. The minimum value on the left is the space already in use within the file system, so this is the minimum possible volume size (without deleting data). The maximum value on the right is the greatest size the volume can have based on available free space in the _volume group_. - -![Resize dialog in blivet-gui][6] - -A grayed out _resize_ option means the volume is full and there is no free space in the volume group. It’s time to change that! Look through all of the volumes to find one with plenty of extra space, like in the screenshot above. Move the slider to the left to set the new size. Free up enough space to be useful for the full volume, but still leave plenty of space for future data growth. Otherwise, this volume will be the next to fill up. - -Click _resize_ and note that a new item appears in the volume listing: _free space_. Now select the full volume that started this whole endeavor, and move the slider all the way to the right. Press _resize_ and marvel at the new improved volume layout. However, nothing has changed on the hard drive yet. Click on the _check-mark_ to commit the changes to disk. - -![Review changes in blivet-gui][7] - -Review the summary of the changes, and if everything looks right, click _Ok_ to proceed. Wait for _blivet-gui_ to finish. Now reboot back into the main Fedora install and enjoy all the new space in the previously full volume. - -### Planning for the future - -It is challenging to know how much space any particular volume will need in the future. Instead of immediately allocating all available free space, consider leaving it free in the volume group. In fact, Fedora Server reserves space in the volume group by default. Extending a volume is possible while it is online and in use. No live image or reboot needed. When a volume is almost full, easily extend the volume using part of the available free space and keep working. Unfortunately the default disk manager, _gnome-disks_, does not support LVM volume resizing, so install _[blivet-gui][8]_ for a graphical management tool. Alternately, there is a simple terminal command to extend a volume: - -``` -lvresize -r -L +1G /dev/fedora_localhost-live/root -``` - -### Wrap-up - -Reclaiming hard-drive space with LVM just scratches the surface of LVM capabilities. Most people, especially on the desktop, probably don’t need the more advanced features. However, LVM is there when the need arises, though it can get a bit complex to implement. [BTRFS][9] is the default filesystem, without LVM, starting with [Fedora 33][10]. BTRFS can be easier to manage while still flexible enough for most common usages. Check out the recent [Fedora Magazine articles on BTRFS][11] to learn more. - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/reclaim-hard-drive-space-with-lvm/ - -作者:[Troy Curtis Jr][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/troycurtisjr/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2020/11/lvm-resize-816x345.jpg -[2]: http://sourceware.org/lvm2/ -[3]: https://getfedora.org/en/workstation/download/ -[4]: https://fedoramagazine.org/wp-content/uploads/2020/11/gnome-disks.png -[5]: https://fedoramagazine.org/wp-content/uploads/2020/11/blivet-overview.png -[6]: https://fedoramagazine.org/wp-content/uploads/2020/11/blivet-resize-1024x525.png -[7]: https://fedoramagazine.org/wp-content/uploads/2020/11/blivet-summary-1024x525.png -[8]: https://fedoraproject.org/wiki/Blivet-gui -[9]: https://fedoramagazine.org/btrfs-coming-to-fedora-33/ -[10]: https://fedoramagazine.org/whats-new-fedora-33-workstation/ -[11]: https://fedoramagazine.org/btrfs-snapshots-backup-incremental/ diff --git a/translated/tech/20201106 Reclaim hard-drive space with LVM.md b/translated/tech/20201106 Reclaim hard-drive space with LVM.md new file mode 100644 index 0000000000..7485899982 --- /dev/null +++ b/translated/tech/20201106 Reclaim hard-drive space with LVM.md @@ -0,0 +1,90 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Reclaim hard-drive space with LVM) +[#]: via: (https://fedoramagazine.org/reclaim-hard-drive-space-with-lvm/) +[#]: author: (Troy Curtis Jr https://fedoramagazine.org/author/troycurtisjr/) + +使用 LVM 回收硬盘空间 +====== + +![Hard drive image][1] + +照片:Frank R @ Unsplash.com + +LVM 是一个逻辑卷管理工具,包括分配磁盘、区代化、镜像和调整逻辑卷的大小。它在 Fedora 安装中被普遍使用(在 BTRFS 作为默认之前是 LVM+Ext4)。但是你是否曾经遇到过启动系统时,Gnome 提示主卷几乎没有空间了!幸运的是,很有可能有一些空间在另一个卷中,而未被使用,并准备重新分配。下面就来看看如何用 LVM 回收硬盘空间。 + +在卷之间轻松重新分配空间的关键是[逻辑卷管理器 (LVM)][2]。Fedora 32 及以前的系统默认使用 LVM 来划分磁盘空间。这种技术类似于标准的硬盘分区,但 LVM 更加灵活。LVM 不仅可以实现灵活的卷大小管理,还可以实现一些高级功能,比如读写快照、在多个硬盘上进行数据区带化或镜像、将高速硬盘作为慢速硬盘的缓存等等。所有这些高级选项可能会让人有点不知所措,但调整卷的大小很直接的。 + +### LVM 基础 + +_卷组_作为 LVM 系统中的主要容器。默认情况下,Fedora 只定义了一个卷组,但你可以根据需要定义多个卷组。实际的硬盘和硬盘分区被添加到 _卷组_中作为_物理卷_。_物理卷_会将可用的空间添加到_卷组_中。一个典型的 Fedora 安装有一个格式化的启动分区,其余的硬盘是一个配置为 LVM _物理卷_的分区。 + +从这个可用空间池中,_卷组_分配了一个或多个_逻辑卷_。这些卷类似于硬盘分区,但没有磁盘上连续空间的限制。LVM 的_逻辑卷_甚至可以跨越多个设备!就像硬盘分区一样,_逻辑卷_有一个定义的大小,可以包含任何文件系统,然后可以挂载到特定的目录。 + +### 需要什么 + +在 gnome-disks 应用中确认系统使用 LVM ,并确保其他卷中有可用的空间。如果没有从另一个卷中回收的空间,这个指南就没有用。还需要一个 [Fedora live CD/USB][3]。任何需要收缩的文件系统都必须卸载。从 Live 镜像运行可以让硬盘上的所有卷保持未挂载状态,甚至包括像 _/_ 和 _/home_ 这样的重要目录。 + +![Use gnome-disks to verify free space][4] + +### 一句话警告 + +按照这个指南,应该不会丢失任何数据,但它确实会使用一些非常底层和强大的命令。一个错误可能会破坏硬盘上的所有数据。所以要先备份磁盘上的所有数据! + +### 调整 LVM 卷的大小 + +开始时,启动 Fedora Live 镜像并在对话框中选择 _Try Fedora_。接下来,使用 _Run Command_ 启动 _blivet-gui_ 应用(按 _Alt-F2_,输入 _blivet-gui_,然后按_回车_)。选择左侧 _LVM_ 下的卷组。逻辑卷在右边。 + +![Explore logical volumes in blivet-gui][5] + +逻辑卷标签由卷组名称和逻辑卷名称组成。在本例中,卷组是 “fedora_localhost-live”,分配了 “home”、“root” 和 “swap” 逻辑卷。要找到完整的卷,选择每一个卷,点击_齿轮_图标,然后选择 _resize_。调整大小对话框中的滑块表示卷的允许大小。左边的最小值是文件系统中已经使用的空间,所以这是最小可能的体积大小(不删除数据)。右边的最大值是基于_卷组_中的最大可用空间。 + +![Resize dialog in blivet-gui][6] + +灰色的 _resize_ 选项意味着该卷已经满了,而且卷组中没有可用空间。现在可以更改大小了!查看所有的卷,就像上面的截图那样,找到一个有足够空间的卷。并像上面的截图那样,在所有的卷中找到一个有大量额外空间的卷。向左移动滑块来设置新的大小。腾出足够的空间对整个卷有用,但仍然为未来的数据增长留出足够的空间。否则,这个卷将是下一个被填满的卷。 + +点击 _resize_,注意卷列表中出现了一个新项目:_空闲空间_。现在选择这次要调整的卷,并将滑块一直向右移动。按 _resize_ 键,并查看新改进的卷的布局。然而,硬盘驱动器上的任何东西都还没有改变。点击_勾选按钮_将更改提交到磁盘。 + +![Review changes in blivet-gui][7] + +查看更改的摘要,如果一切看起来都是正确的,点击 _Ok_ 继续。等待 _blivet-gui_ 完成。现在重新启动回到 Fedora ,享受之前被充满的卷上的新空间。 + +### 为未来计划 + +要知道任何特定卷在未来需要多少空间是很困难的。与其立即分配所有可用的空闲空间,不如考虑在卷组中留出空闲空间。事实上,Fedora Server 默认在卷组中保留空间。当一个卷处于在线和使用中时,扩展卷是可能的。不需要 Live 镜像或重启。当一个卷几乎满的时候,可以使用部分可用空间轻松扩展卷并继续工作。遗憾的是,默认的磁盘管理器 _gnome-disks_ 不支持 LVM 卷的大小调整,所以安装 _[blivet-gui][8]_ 作为图形化管理工具。另外,还有一个简单的终端命令来扩展卷。 + +``` +lvresize -r -L +1G /dev/fedora_localhost-live/root +``` + +### 总结 + +用 LVM 回收硬盘空间只是 LVM 功能的表面。大多数人,特别是在桌面中,可能不需要更高级的功能。然而,当需要的时候,LVM 就在那里,尽管它的实现可能会变得有点复杂。从 [Fedora 33][10] 开始,[BTRFS][9] 是默认的文件系统,没有 LVM。BTRFS 可以更容易管理,同时对于大多数常见的使用来说也足够灵活。查看最近 [Fedora Magazine 关于 BTRFS 的文章][11]了解更多。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/reclaim-hard-drive-space-with-lvm/ + +作者:[Troy Curtis Jr][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/troycurtisjr/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/11/lvm-resize-816x345.jpg +[2]: http://sourceware.org/lvm2/ +[3]: https://getfedora.org/en/workstation/download/ +[4]: https://fedoramagazine.org/wp-content/uploads/2020/11/gnome-disks.png +[5]: https://fedoramagazine.org/wp-content/uploads/2020/11/blivet-overview.png +[6]: https://fedoramagazine.org/wp-content/uploads/2020/11/blivet-resize-1024x525.png +[7]: https://fedoramagazine.org/wp-content/uploads/2020/11/blivet-summary-1024x525.png +[8]: https://fedoraproject.org/wiki/Blivet-gui +[9]: https://fedoramagazine.org/btrfs-coming-to-fedora-33/ +[10]: https://fedoramagazine.org/whats-new-fedora-33-workstation/ +[11]: https://fedoramagazine.org/btrfs-snapshots-backup-incremental/ From c07498e1dd2392d61cf3dd8fb6648ab11095e915 Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 24 Nov 2020 08:51:23 +0800 Subject: [PATCH 059/139] translating --- ...Disk Size of Your Existing Virtual Machines in VirtualBox.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20201120 How to Increase Disk Size of Your Existing Virtual Machines in VirtualBox.md b/sources/tech/20201120 How to Increase Disk Size of Your Existing Virtual Machines in VirtualBox.md index f0240e9ad7..6922caa8de 100644 --- a/sources/tech/20201120 How to Increase Disk Size of Your Existing Virtual Machines in VirtualBox.md +++ b/sources/tech/20201120 How to Increase Disk Size of Your Existing Virtual Machines in VirtualBox.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (geekpi) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) From 74f0da10e917c00399e8798ccf6435389fd1c84b Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Tue, 24 Nov 2020 11:39:10 +0800 Subject: [PATCH 060/139] PRF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @frogOAO 恭喜你,完成了第一篇翻译贡献! --- ...s for USB, Clipboard and Folder Sharing.md | 180 +++++++++--------- 1 file changed, 91 insertions(+), 89 deletions(-) diff --git a/translated/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md b/translated/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md index 47d60deb03..a216b01e74 100644 --- a/translated/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md +++ b/translated/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md @@ -1,24 +1,34 @@ [#]: collector: (lujun9972) [#]: translator: (frogOAO) -[#]: reviewer: ( ) +[#]: reviewer: (wxy) [#]: publisher: ( ) [#]: url: ( ) [#]: subject: (How to Install Fedora in VirtualBox [With Steps for USB, Clipboard and Folder Sharing]) [#]: via: (https://itsfoss.com/install-fedora-in-virtualbox/) [#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/) -如何在 Fedora 中安装 VirtualBox 【附带 USB,剪切板,文件夹共享教程】 +如何在 Fedora 中安装 VirtualBox ====== -如果您对 Fedora Linux 感兴趣,这有几种方式可以尝试它。 +如果你对 Fedora Linux 感兴趣,这有几种方式可以尝试它。 -最简单还不影响您操作系统的方式是 [制作 Fedora 的 USB 启动盘][1] +最简单还不影响你操作系统的方式是 [制作 Fedora 的 USB 临场启动盘][1]。 + +> **LCTT 译注**: +> +> 在 Linux 发行版的使用方式上,有一种可以无需安装而通过光盘或 USB 存储棒直接在计算机上启动完整的 Linux 操作系统的方式,这种方式称之为 “Live” 方式,如 Live CD、Live USB。 +> +> 通常,Live 一词并不翻译,不过,我认为,除了英文缩写和部分历史原因造成直接使用的英文单词,大部分场景都应该使用本地化的语言来描述,否则,中英文混杂的港台式中文,实在有些不伦不类;抑或,外文翻译本身就不存在意义了。 +> +> 因此,对于 “Live” 一词如何翻译,我们也颇费心思。这个词,在维基百科中文中,被翻译为“[自生系统](https://zh.wikipedia.org/wiki/Live_CD)”,在某些场景下偶见 “现场”、“临场” 等翻译。考虑到 Live CD/USB 的特性,我认为翻译为 “临场” 比较好。 +> +> 于此抛出愚见,希望得到大家的积极反馈。wxy@LCTT 另一种方式是安装 VirtualBox 利用虚拟化技术来尝试 Fedora。这样,你可以在你的操作系统上像使用应用程序一样使用 Fedora。 -通过这种方式,您可以执行更彻底的测试,而不会搞乱当前的操作系统。 +通过这种方式,你可以执行更彻底的测试,而不会搞乱当前的操作系统。 -您甚至可以复制您的虚拟安装程序,并在其他系统上重新安装它。听起来方便吗?让我来教你怎么做。 +你甚至可以复制你的虚拟环境,并在其他系统上重新安装它。听起来方便吗?让我来教你怎么做。 ### 在 Fedora 上安装 Fedora @@ -28,129 +38,126 @@ #### 步骤一:安装 VirtualBox -如果您的系统还没有安装 VirtualBox,您可以从官方网站下载。您可以找到 Windows,MacOs 和 Linux 的说明。 [Ubuntu 用户可以参考这个关于安装 VirtualBox 的详细教程。][3]. +如果你的系统还没有安装 VirtualBox,你可以从官方网站下载。你可以找到 Windows、MacOs 和 Linux 的说明。 [Ubuntu 用户可以参考这个关于安装 VirtualBox 的详细教程。][3] ![][4] -[下载 VirtualBox][5] +- [下载 VirtualBox][5] -#### **步骤二: 下载 Fedora ISO** +#### 步骤二: 下载 Fedora ISO -如果您不熟悉 Fedora,那么这些镜像您需要知道。 +如果你不熟悉 Fedora,那么这些镜像你需要知道。 -[Fedora IoT][6] 是用于可扩展基础设施的, [Fedora workstation][7] 是一个镜像,带有一组面向普通GNOME桌面环境中的桌面的工具。[Fedora server][8] 顾名思义,是为服务器或数据中心定制的。 +[Fedora IoT][6] 是用于可扩展基础设施的,[Fedora workstation][7] 是一个带有一组面向普通 GNOME 桌面环境中的桌面工具的镜像。[Fedora server][8] 顾名思义,是为服务器或数据中心定制的。 -如果GNOME不是您的首选,您可以下载一个带有替代桌面环境的[定制版][9]Fedora桌面。 对于本教程,我选择了带有GNOME桌面环境的[Fedora 33][10]。 +如果 GNOME 不是你的首选,你可以下载一个带有替代桌面环境的[定制版][9] Fedora 桌面。对于本教程,我选择了带有 GNOME 桌面环境的[Fedora 33][10]。 -[下载 Fedora][11] +- [下载 Fedora][11] #### 步骤三: 创建一个空虚拟机并对其进行配置 要成功安装和运行 Fedora,至少需要 20GB 磁盘空间和 2GB RAM。不过,为了获得更流畅的用户体验,建议增加一倍。在此基础上,我将创建并配置虚拟机。 -开启 Virtual Box 点击 New。 +开启 Virtual Box 点击 “New”。 ![创建一个新的虚拟机][12] -需要注意,最重要的选项是 **将类型设置为 Linux and 版本设置为 Fedora (64-bit)**。如果您在名称提示符处开始输入 Fedora,VirtualBox 将自动为您选择正确的设置。虽然名字不一定非得是 Fedora,它可以是任何你喜欢的。 +需要注意,最重要的选项是 **将类型设置为 Linux ,版本设置为 Fedora (64-bit)**。如果你在名称提示符处开始输入 “Fedora”,VirtualBox 将自动为你选择正确的设置。虽然名字不一定非得是 Fedora,它可以是任何你喜欢的。 -_如果您只能访问 32 位版本,那么您需要在 BIOS 上启用虚拟化技术,如果您有一个 AMD CPU,它被称为 SVM。最坏的情况是您的 CPU 不支持虚拟化技术。如果你不确定,先检查这个。_ +*如果你只能访问 32 位版本,那么你需要在 BIOS 上启用虚拟化技术,如果你有一个 AMD CPU,它被称为 SVM。最坏的情况是你的 CPU 不支持虚拟化技术。如果你不确定,先检查这个。 -如果您的设置和我一样,点击 create 按钮。 +如果你的设置和我类似,点击 “create” 按钮。 -![Name your VM and assign it at least 3 GB RAM][13] +![命名你的虚拟机,并未它指定至少 3 GB RAM][13] -如前所述,至少需要 20gb 的磁盘空间才能安装 Fedora。我的系统上有 32gb 的内存,所以我分配了 8gb。3 GB 的内存应该没问题。 +如前所述,至少需要 20GB 的磁盘空间才能安装 Fedora。我的系统上有 32GB 的内存,所以我分配了 8GB 内存。3 GB 的内存应该也没问题。 顺便说下内存的使用,只有在运行虚拟机时,虚拟机才会使用内存。否则,它将可用于常规使用。 -确保其余设置与示例匹配,并点击 Create。 +确保其余设置与示例匹配,并点击 “Create” 按钮。 -![Assign 15-20 GB of disk space in VDI format][14] +![以 VDI 格式分配 15-20 GB 的磁盘空间][14] 在你点击虚拟机的 Start 按钮之前,你需要加载如下所示的 ISO [光驱]。 -![Add the Fedora ISO to optical drive storage][15] +![将 Fedora ISO 添加到光驱存储中][15] -因为你的虚拟硬盘是空的,虚拟机将从这个 ISO 启动。可以把它看作是使用 live USB 或磁盘安装 Linux。 +因为你的虚拟硬盘是空的,虚拟机将从这个 ISO 启动。可以把它看作是使用临场 USB 或磁盘安装 Linux。 -![Go to Settings and add ISO as optical drive][16] +![在设置中将 ISO 添加为光驱][16] -然后,如果您有一个多核CPU,建议为虚拟机分配 2 个或更多的核。您可以在 system 选项卡下找到 CPU 核心。配置系统时,单击 ok 并启动虚拟机。 +然后,如果你有一个多核 CPU,建议为虚拟机分配 2 个或更多的核。你可以在 “System” 选项卡下找到 CPU 核心。配置系统时,单击 “OK” 并启动虚拟机。 -![Optional step: Assign number of CPU cores][17] +![可选:分配 CPU 核数][17] -配置好所有内容后,单击 start 按钮开始安装。 +配置好所有内容后,单击 “Start” 按钮开始安装。 #### 步骤四:在 VirtualBox 中安装 Fedora。 -如果您正确地遵循了这个过程,那么当您启动虚拟机时,您将直接从 ISO 文件启动。当您看到类似下面的屏幕时,选择 Start Fedora,并按 enter 键。 +如果你正确地遵循了这个过程,那么当你启动虚拟机时,你将直接从 ISO 文件启动。当你看到类似下面的屏幕时,选择 “Start Fedora”,并按回车键。 -![Fedora running in live environment in virtual machine][18] +![Fedora 运行在虚拟机的临场环境中][18] -要启动安装对话框,单击 Install To Hard Drive。 +要启动安装对话框,单击 “Install To Hard Drive”。 -![Click on “install to hard drive”][19] +![点击 “install to hard drive”][19] -在您继续安装之前,有必要定义您的键盘布局、您的时区以及最终安装操作系统的位置。 +在你继续安装之前,有必要定义你的键盘布局、你的时区以及最终安装操作系统的位置。 -![Choose keyboard, time and date and then go to Installation Destination][20] +![选择键盘布局、日期和时间,然后是安装目标位置][20] -划分过程很简单。您像前面的 VDI 那样划分一些空闲空间。它应该被自动识别。 +分区过程很简单。你像前面的 VDI 那样划分一些空闲空间。它应该被自动识别。 +选择你的磁盘并将存储配置设置为 “Automatic”。单击 “Done” 进入上一个对话框。 -选择您的磁盘并将存储配置设置为 automatic。单击 Done 进入上一个对话框。 +![磁盘应该会自动识别][21] -![Disk should be automatically recognized][21] +一旦你配置完了上面的,点击 “Begin Installation”。 -一旦你配置了上面的,点击 “Begin Installation”。 - -![Begin installation of Fedora][22] +![开始 Fedora 的安装][22] 现在只需等待 5 - 6 分钟即可完成安装。安装完成后,点击 “Finish installation” 按钮。 -最后一步,需要关闭系统的电源。如果您不熟悉 GNOME 桌面环境,您可以这样做。 +最后一步,需要关闭系统的电源。如果你不熟悉 GNOME 桌面环境,你可以如下这样做。 -![Turn off Fedora live environment after installation][23] +![安装后关闭 Fedora 临场环境][23] -您必须手动卸载在初始步骤中加载的 ISO 文件。 +你必须手动卸载在初始步骤中加载的 ISO 文件。 -![Remove Fedora ISO From Optical Drive][24] +![从光驱中移走 Fedora ISO][24] -下一次使用 Fedora 启动虚拟机时,系统将提示您为 Fedora Linux 创建用户帐户并设置密码。 +下一次使用 Fedora 启动虚拟机时,系统将提示你为 Fedora Linux 创建用户帐户并设置密码。 -### 使用 VirtualBox 客户添加的附加功能,如剪贴板共享,文件夹共享等 +### 使用 VirtualBox Guest Additions 的附加功能,如剪贴板共享,文件夹共享等 -[增强功能包][25] 客户附加程序设计为在客户操作系统安装后安装在虚拟机中。它们包含对客户操作系统进行优化的设备驱动程序和系统应用程序,以获得更好的性能和可用性。 +[Guest Additions][25] 设计为在访客guest操作系统安装后安装在虚拟机中。它们包含对客户操作系统进行优化的设备驱动程序和系统应用程序,以获得更好的性能和可用性。 -客户添加 ISO 文件被安装为虚拟 CD-ROM 以便安装。 +Guest Additions ISO 文件被安装为虚拟 CD-ROM 以便安装。 这是一个简单的过程。只需单击设备选项卡,然后单击 “Insert Guest Additions CD image”。 ![][26] -当提示符单击 download 时,系统将弹出您下载增强功能包界面。 +当提示单击 “Download” 时,系统将弹出下载 Guest Additions 镜像界面。 -![Install VirtualBox Guest Additions][27] +![安装 VirtualBox Guest Additions][27] -#### **共享剪贴板** +#### 共享剪贴板 -有时候,您需要在虚拟机和主机操作系统之间移动一些内容。共享剪贴板/拖放支持将允许您在一个平台上复制项目,并将它们粘贴到另一个平台上。 +有时候,你需要在虚拟机和宿主机host操作系统之间移动一些内容。共享剪贴板/拖放支持将允许你在一个平台上复制项目,并将它们粘贴到另一个平台上。 -要启用此功能,请在VirtualBox主页上选择 **Settings**,并按照下面的说明操作。**双向** 的选项是最方便的。 +要启用此功能,请在 VirtualBox 主页上选择 “Settings”,并按照下面的说明操作。“Bidirectional” 的选项是最方便的。 -![Enable clipboard sharing between guest and host systems][28] +![启用访客和宿主系统间的剪贴板共享][28] -#### **共享文件夹** +#### 共享文件夹 有两种类型的分享: * 永久共享,与虚拟机设置一起保存。 - * 暂态共享,当虚拟机关闭时就会消失。可以使用 VirtualBox 管理器中的复选框创建暂态共享。 + * 暂时共享,当虚拟机关闭时就会消失。可以使用 VirtualBox 管理器中的复选框创建暂时共享。 - - -在本教程中,我将创建一个永久共享文件夹。在 VM 设置中添加您想要共享的主机系统文件夹,并选择您想要在 VM 中出现的名称。 +在本教程中,我将创建一个永久共享文件夹。在 VM 设置中添加你想要共享的宿主机系统文件夹,并选择你想要在 VM 中出现的名称。 ![][29] @@ -158,76 +165,71 @@ _如果您只能访问 32 位版本,那么您需要在 BIOS 上启用虚拟化 ![][30] -#### **更好的视频支持** +#### 更好的视频支持 -虽然 Oracle VirtualBox 提供了所有基本功能的虚拟显卡,但客户添加的自定义视频驱动程序为您提供了超高和非标准的视频模式,以及加速的视频性能。 +虽然 Oracle VirtualBox 提供了具有基本功能的虚拟显卡,但访客系统添加的自定义视频驱动程序为你提供了超高和非标准的视频模式,以及视频加速。 -使用增强安装包,操作系统的分辨率将随着您调整计算机上的 VirtualBox 窗口而动态调整大小。 +使用 Guest Additions,操作系统的分辨率将随着你调整计算机上的 VirtualBox 窗口而动态调整大小。 -最后,增强安装包可以利用您的计算机的显卡。如果你是一名游戏玩家或在 WM 中使用高效软件,这就会产生巨大的改变。 +最后,Guest Additions 可以利用你的计算机的显卡。如果你是一名游戏玩家或在 WM 中使用高效软件,这就会产生巨大的改变。 #### USB 和网络设备共享 -有了 VirtualBox,用户就可以使用一个功能齐全的操作系统,而不必在不同的硬件上进行设置。然而,在主机和客户机器之间共享USB和网络设备并不像想的那样简单。 +有了 VirtualBox,用户就可以使用一个功能齐全的操作系统,而不必在不同的硬件上进行设置。然而,在宿主机和访客机器之间共享 USB 和网络设备并不像想的那样简单。 -要访问USB设备,您将需要安装 [VirtualBox 扩展包][31]. +要访问 USB 设备,你将需要安装 [VirtualBox 扩展包][31]。 -![Install VirtualBox Extensions pack][32] +![安装 VirtualBox 扩展包][32] -_**下面这些仅对 Linux**_,因为我使用的是 Linux。 +**下面这些仅对 Linux**,因为我使用的是 Linux。 -为了使 VirtualBox 能够访问 USB 子系统,运行 VirtualBox 的用户(在主机系统上)必须属于 vboxuser 组。为此,打开一个终端并发出以下命令: +为了使 VirtualBox 能够访问 USB 子系统,运行 VirtualBox 的用户(在宿主机系统上)必须属于 `vboxuser` 组。为此,打开一个终端并发出以下命令: ``` sudo usermod -aG vboxusers 'your username' ``` -运行该命令后,您应该注销并重新登录,或者重新启动主机。 +运行该命令后,你应该注销并重新登录,或者重新启动主机。 -在这一步,插入你的 u 盘,通过你的 VM 设置,你应该能够找到并添加介质,如例子中所示。 +在这一步,插入你的 U 盘,通过你的 VM 设置,你应该能够找到并添加介质,如例子中所示。 ![][33] -当您下次启动虚拟机,您的USB将是可访问的。 +当你下次启动虚拟机,你的 USB 将是可访问的。 ![][34] ### 额外提示:保存并导出虚拟机,以便以后可以在任何系统上使用它 -您可能想在另一台计算机上使用虚拟机,或者是时候构建一台新机器了,并且您需要保持虚拟机的原样。只需几个简单的步骤,就可以轻松地导出当前设置并将其导入到另一台机器。 +你可能想在另一台计算机上使用虚拟机,或者是时候构建一台新机器了,并且你需要保持虚拟机的原样。只需几个简单的步骤,就可以轻松地导出当前设置并将其导入到另一台机器。 -在 VirtualBox 主面板上,单击 file 和 export 工具。如果你喜欢键盘快捷键,你可以简单地点击 **Ctrl+E** +在 VirtualBox 主面板上,单击 “file”、“Export Appliance”。如果你喜欢键盘快捷键,你可以简单地点击 `Ctrl+E`。 ![][35] -选择要导出的虚拟机,然后单击 next。 +选择要导出的虚拟机,然后单击 “Next”。 ![][36] -格式选项需要注意一下。开放虚拟化格式 0.9、1.0 和 2.0 有三种不同的选项,可以是 ovf 或 ova 扩展。 +“Format” 选项需要注意一下。有三种不同的选项:开放虚拟化格式Open Virtualization Format 0.9、1.0 和 2.0 ,可以是 ovf 或 ova 扩展名。 +使用 ovf 扩展名,会分别写入几个文件,而 ova 扩展名则将所有文件合并到一个开放虚拟化格式归档文件中。 -使用 ovf 扩展名,可以分别编写几个文件,而 ova 扩展名则将所有文件合并到一个开放的虚拟化格式归档文件中。 - - -默认格式 Open Virtualization format 1.0 应该没问题。 +默认格式 OVF 1.0 应该没问题。 ![][37] -要完成该过程,单击 next,然后在下一个对话框中单击 export。 +要完成该过程,单击 “Next”,然后在下一个对话框中单击 “Export”。 -#### 总结 +### 总结 -通过使用虚拟机,您不仅可以测试操作系统,还可以部署与物理机器同等重要的功能完整的系统。如今,硬件已经变得如此强大和廉价,它的大部分功能都没有被利用。 +通过使用虚拟机,你不仅可以测试操作系统,还可以部署与物理机器同等重要的功能完整的系统。如今,硬件已经变得如此强大和廉价,它的大部分功能都没有被利用。 +通过虚拟化技术,你可以使用这些浪费的资源。对物理机器的需求减少了,因此能源消耗也减少了。你可以从硬件和降低运行成本两方面省钱。 -通过虚拟化技术,您可以使用这些浪费的资源。对物理机器的需求减少了,因此能源消耗也减少了。您可以从硬件和降低运行成本两方面省钱。 +在大规模服务环境中,服务器虚拟化更多的是一种基本需求,而不是一种高级概念。 - -在更大的范围内,服务器虚拟化更多的是一种基本需求,而不是一种高级概念。 - - -我希望本教程对您在 VirtualBox 中安装 Fedora Linux 有帮助。如果你遇到任何问题,请在评论中告诉我。 +我希望本教程对你在 VirtualBox 中安装 Fedora Linux 有帮助。如果你遇到任何问题,请在评论中告诉我。 -------------------------------------------------------------------------------- @@ -235,8 +237,8 @@ via: https://itsfoss.com/install-fedora-in-virtualbox/ 作者:[Dimitrios Savvopoulos][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/frogOAO) -校对:[校对者ID](https://github.com/校对者ID) +译者:[frogOAO](https://github.com/frogOAO) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 8ddf28dbb90ac89d1baa9a0d9bc9e9642f45c589 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Tue, 24 Nov 2020 11:40:32 +0800 Subject: [PATCH 061/139] PUB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @frogOAO 本文首发地址:https://linux.cn/article-12854-1.html 你的 LCTT 专页地址: https://linux.cn/lctt/frogOAO --- ...alBox -With Steps for USB, Clipboard and Folder Sharing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename {translated/tech => published}/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md (99%) diff --git a/translated/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md b/published/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md similarity index 99% rename from translated/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md rename to published/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md index a216b01e74..fa05060946 100644 --- a/translated/tech/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md +++ b/published/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (frogOAO) [#]: reviewer: (wxy) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12854-1.html) [#]: subject: (How to Install Fedora in VirtualBox [With Steps for USB, Clipboard and Folder Sharing]) [#]: via: (https://itsfoss.com/install-fedora-in-virtualbox/) [#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/) From 35f7dd0bd41693088e851ca5d318d2e812fa8563 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Tue, 24 Nov 2020 17:58:10 +0800 Subject: [PATCH 062/139] PRF --- ...alBox -With Steps for USB, Clipboard and Folder Sharing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/published/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md b/published/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md index fa05060946..23edba8404 100644 --- a/published/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md +++ b/published/20201114 How to Install Fedora in VirtualBox -With Steps for USB, Clipboard and Folder Sharing.md @@ -7,7 +7,7 @@ [#]: via: (https://itsfoss.com/install-fedora-in-virtualbox/) [#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/) -如何在 Fedora 中安装 VirtualBox +如何在 VirtualBox 中安装 Fedora ====== 如果你对 Fedora Linux 感兴趣,这有几种方式可以尝试它。 @@ -30,7 +30,7 @@ 你甚至可以复制你的虚拟环境,并在其他系统上重新安装它。听起来方便吗?让我来教你怎么做。 -### 在 Fedora 上安装 Fedora +### 在 VirtualBox 上安装 Fedora ![][2] From 56fb211c91ee3234fccdfe77c000193da65a5917 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Tue, 24 Nov 2020 18:14:09 +0800 Subject: [PATCH 063/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201124=20?= =?UTF-8?q?Customize=20Task=20Switching=20Experience=20on=20GNOME=20Deskto?= =?UTF-8?q?p=20With=20These=20Nifty=20Tools?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201124 Customize Task Switching Experience on GNOME Desktop With These Nifty Tools.md --- ...on GNOME Desktop With These Nifty Tools.md | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 sources/tech/20201124 Customize Task Switching Experience on GNOME Desktop With These Nifty Tools.md diff --git a/sources/tech/20201124 Customize Task Switching Experience on GNOME Desktop With These Nifty Tools.md b/sources/tech/20201124 Customize Task Switching Experience on GNOME Desktop With These Nifty Tools.md new file mode 100644 index 0000000000..251f2e5edb --- /dev/null +++ b/sources/tech/20201124 Customize Task Switching Experience on GNOME Desktop With These Nifty Tools.md @@ -0,0 +1,108 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Customize Task Switching Experience on GNOME Desktop With These Nifty Tools) +[#]: via: (https://itsfoss.com/customize-gnome-task-switcher/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Customize Task Switching Experience on GNOME Desktop With These Nifty Tools +====== + +Unless you’re new to Linux, you know that there are several [popular desktop environment][1] choices for users. And if you’re that newbie, I recommend you to learn [what a desktop environment is][2] along with this tutorial. + +Here, I shall be focusing on tweaking the task switching experience on GNOME. I know that the majority of users just tend to use it as is and stock settings are good enough for the most part. + +I mean there is nothing wrong with the application switcher that [you use with Alt+Tab keyboard shortcut in Ubuntu][3]. + +![][4] + +However, if you are a tinkerer who wants to [customize the look and feel of your GNOME desktop][5], including the task switcher and animation effects when launching or minimizing an app — you might want to continue reading this article. + +### Change GNOME Task Switcher to Windows 7 Style Effect + +![][6] + +Switching between running applications using the key bind **Alt+Tab** is fast but it may not be the most intuitive experience for some. You just get to cycle through a bunch of icons depending on the number of active applications. + +What if you want to change how the task switcher looks? + +Well, you can easily give it a look of Windows 7 Aero Flip 3D effect. And, here’s how it will look: + +![][7] + +It definitely looks interesting to have a different task switcher. Why? Just for fun or to share your desktop’s screenshot on Linux communities. + +Now, to get this on your GNOME desktop, here’s what you have to do: + +Step 1: Enable GNOME extensions if you haven’t already. You can follow our guide to [learn how to use GNOME shell extensions][8]. + +Step 2: Once you are done with the setup, you can proceed downloading and installing the [Coverflow GNOME extension][9] from GNOME extensions website. + +In case you haven’t installed the browser extension, you can just click on the link “**Click here to install browser extension**” from the notice as shown in the screenshot below. + +![][10] + +Step 3: Next, you just have to refresh the web page and enable the extension as shown in the screenshot below. + +![][11] + +You also get some customization options if you click on the “gear” icon right to the toggle button. + +![][12] + +Of course, depending on how fast you want it to be or how good you want it to look, you will have to adjust the animation speed accordingly. + +Next, why not some kind of cool effect when you interact with applications (minimize/close)? I have just the solution for you. + +### Add Genie Animation Effect While Minimizing & Re-opening Applications + +There’s an interesting effect (sort of like genie popping out of a lamp) that you can add to see when you minimize or re-open an app. + +This also comes as a GNOME extension, so you do not need to do anything else to get started. + +You just have to head to the extensions page, which is [Compiz alike Magic Lamp effect][13] and then enable the extension to see it in action. + +![][14] + +Here’s how it looks in action: + +![][15] + +It would look even cooler if you switch the Ubuntu dock to the bottom. + +Exciting GNOME extensions, right? You can play around to tweak your GNOME experience using the [GNOME tweaks app][16] and [install some beautiful icon themes][17] or explore different options. + +How do you prefer to customize your GNOME experience? Is there any other cool GNOME extension or an app that you tend to utilize? Feel free to share your thoughts in the comments below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/customize-gnome-task-switcher/ + +作者:[Ankush Das][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/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/best-linux-desktop-environments/ +[2]: https://itsfoss.com/what-is-desktop-environment/ +[3]: https://itsfoss.com/ubuntu-shortcuts/ +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2017/10/gnome-app-switcher.jpeg?resize=800%2C255&ssl=1 +[5]: https://itsfoss.com/gnome-tricks-ubuntu/ +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/ubuntu-coverflow-screenshot.jpg?resize=800%2C387&ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/coverflow-task-switcher.jpg?resize=800%2C392&ssl=1 +[8]: https://itsfoss.com/gnome-shell-extensions/ +[9]: https://extensions.gnome.org/extension/97/coverflow-alt-tab/ +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/gnome-shell-extension-browser.jpg?resize=800%2C401&ssl=1 +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/coverflow-enable.jpg?resize=800%2C303&ssl=1 +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/11/coverflow-settings.png?resize=800%2C481&ssl=1 +[13]: https://extensions.gnome.org/extension/3740/compiz-alike-magic-lamp-effect/ +[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/11/magic-lamp-extension.jpg?resize=800%2C355&ssl=1 +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/11/magic-lamp-effect-800x380.gif?resize=800%2C380&ssl=1 +[16]: https://itsfoss.com/gnome-tweak-tool/ +[17]: https://itsfoss.com/best-icon-themes-ubuntu-16-04/ From fc99ed2f7d4440481597bba1a21dd3708c1a40ce Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Tue, 24 Nov 2020 18:14:19 +0800 Subject: [PATCH 064/139] APL --- .../20201028 5 new sudo features you need to know in 2020.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20201028 5 new sudo features you need to know in 2020.md b/sources/tech/20201028 5 new sudo features you need to know in 2020.md index 1a341c50ca..6459d389f9 100644 --- a/sources/tech/20201028 5 new sudo features you need to know in 2020.md +++ b/sources/tech/20201028 5 new sudo features you need to know in 2020.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (wxy) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) From 3cbec139d64768993b5f067e5ddd31d523eeef8c Mon Sep 17 00:00:00 2001 From: DarkSun Date: Tue, 24 Nov 2020 18:17:08 +0800 Subject: [PATCH 065/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201124=20?= =?UTF-8?q?Build=20a=20motion=20detection=20system=20with=20a=20Raspberry?= =?UTF-8?q?=20Pi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201124 Build a motion detection system with a Raspberry Pi.md --- ...on detection system with a Raspberry Pi.md | 295 ++++++++++++++++++ 1 file changed, 295 insertions(+) create mode 100644 sources/tech/20201124 Build a motion detection system with a Raspberry Pi.md diff --git a/sources/tech/20201124 Build a motion detection system with a Raspberry Pi.md b/sources/tech/20201124 Build a motion detection system with a Raspberry Pi.md new file mode 100644 index 0000000000..f32e2c848e --- /dev/null +++ b/sources/tech/20201124 Build a motion detection system with a Raspberry Pi.md @@ -0,0 +1,295 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Build a motion detection system with a Raspberry Pi) +[#]: via: (https://opensource.com/article/20/11/motion-detection-raspberry-pi) +[#]: author: (Lukas Janėnas https://opensource.com/users/lukasjan) + +Build a motion detection system with a Raspberry Pi +====== +Set up an inexpensive home security system to alert you when someone is +lurking around your house. +![Houses in a row][1] + +If you want a home security system to tell you if someone is lurking around your property, you don't need an expensive, proprietary solution from a third-party vendor. You can set up your own system using a Raspberry Pi, a passive infrared (PIR) motion sensor, and an LTE modem that will send SMS messages whenever it detects movement. + +### Prerequisites + +You will need: + + * A Raspberry Pi with Ethernet connection and Raspberry Pi OS + * An HC-SR501 PIR motion sensor + * 1 red LED + * 1 green LED + * An LTE modem (I used the Teltonika [TRM240][2]) + * A SIM card + + + +#### The PIR motion sensor + +The PIR motion sensor will sense motion when something that emits infrared rays (e.g., a human, animal, or anything that emits heat) moves in the range of the sensor's field or reach. PIR motion sensors are low power and inexpensive, so they're used in many products that detect motion. They can't say how many people are in the area and how close they are to the sensor; they just detect motion. + +![PIR sensor][3] + +(Lukas Janenas, [CC BY-SA 4.0][4]) + +A PIR sensor has two potentiometers, one for setting the delay time and another for sensitivity. The delay time adjustment sets how long the output should remain high after detecting motion; it can be anywhere from five seconds to five minutes. The sensitivity adjustment sets the detection range, which can be anywhere from three to seven meters. + +#### The LTE modem + +Long-term evolution (LTE) is a standard for wireless broadband communication based on the GSM/EDGE and UMTS/HSPA technologies. The LTE modem I'm using is a USB device that can add 3G or 4G (LTE) cellular connectivity to a Raspberry PI computer. In this project, I'm not using the modem for cellular connectivity, but to send messages to my phone when motion is detected. I can control the modem with serial communication and AT commands; the latter send messages from the modem to my phone number. + +![LTE modem][5] + +(Lukas Janenas, [CC BY-SA 4.0][4]) + +### How to set up your home security system + +#### Step 1: Install the software + +First, install the necessary software on your Raspberry Pi. In the Raspberry Pi's terminal, enter: + + +``` +`sudo apt install python3 python3-gpiozero python-serial -y` +``` + +#### Step 2: Set up the modem + +Insert your SIM card into your LTE modem by following these [instructions][6] for the TRM240. Make sure to mount the antenna on the modem for a better signal. + +#### Step 3: Connect the modem to the Raspberry Pi + +Connect the LTE modem to one of the Raspberry Pi's USB ports, then wait for the device to boot up. You should see four new USB ports in the `/dev` directory. You can check them by executing this command in the terminal: + + +``` +`ls /dev/ttyUSB*` +``` + +You should now see these devices: + +![USB ports output][7] + +(Lukas Janenas, [CC BY-SA 4.0][4]) + +You will use the **ttyUSB2** port to communicate with the device by sending AT commands. + +#### Step 4: Connect the sensors to the Raspberry Pi + + 1. **Connect the PIR sensor:** +Connect the **VCC** and **GND** pins to the respective pins on the Raspberry Pi, and connect the motion sensor's output pin to the **8 pin** on the Raspberry Pi. See below for a schematic on these connections, and you can learn more about [Raspberry Pi pin numbering][8] in the GPIO Zero docs. + + 2. **Connect the LED lights:** +If you want indicator LEDs to light up when motion is detected, connect the cathode (short leg, flat side) of the LED to a ground pin; connect the anode (longer leg) to a current-limiting resistor; and connect the other side of the resistor to a GPIO pin (the limiting resistor can be placed either side of the LED). Connect the red LED to the **38 pin** on the board and the green LED to the **40 pin**. + + + + +Note that this step is optional. If you don't want indicator LEDs when motion is detected, delete the LED sections from the example code below. + +![Raspberry Pi wiring diagram][9] + +(Lukas Janenas, [CC BY-SA 4.0][4]) + +#### Step 5: Launch the program + +Using the terminal (or any text editor), create a file named `motion_sensor.py`, and paste in the [example code][10] below. + +Find and change these fields: + + * `phone_number` + * `message` + + + +If you used different pins to connect the sensors, make sure to change the code accordingly. + +When everything is set and ready to go, start the program from the terminal by entering: + + +``` +`python3 motion_sensor.py` +``` + +If you don't have the required privileges to start the program, try this command: + + +``` +`sudo python3 motion_sensor.py` +``` + +![Motion sensor hardware][11] + +(Lukas Janenas, [CC BY-SA 4.0][4]) + +### Example code + + +``` +from gpiozero import MotionSensor, LED +from time import sleep, time +from sys import exit +import serial +import threading + +# Raspberry Pi GPIO pin config +sensor = MotionSensor(14) +green = LED(21) +red = LED(20) + +# Modem configuration +device = '/dev/ttyUSB2' +message = '<message>' +phone_number = '<phone_number>' +sms_timeout = 120 # min seconds between SMS messages + +def setup(): +    port.close() + +    try: +        port.open() +    except serial.SerialException as e: +        print('Error opening device: ' + str(e)) +        return False + +    # Turn off echo mode +    port.write(b'ATE0 \r') +    if not check_response('OK', 10): +        print('Failed on ATE0') +        return False + +    # Enter SMS text mode +    port.write(b'AT+CMGF=1 \r') +    if not check_response('OK', 6): +        print('Failed on CMGF') +        return False + +    # Switch character set to 'international reference alphabet' +    # Note: this still doesn't support all characters +    port.write(b'AT+CSCS="IRA" \r') +    if not check_response('OK', 6): +        print('Failed on CSCS') +        return False + +    return True + +def check_response(string, amount): +    result = '' + +    try: +        result = port.read(amount).decode() +    except: +        return False + +    if not string in result: +        try: +            # Write 'ESC' to exit SMS input mode, just in case +            port.write(b'\x1B \r') +        except: +            return False + +    return string in result + +def send_sms(): +    global currently_sending, last_msg_time +    currently_sending = True + +    try: +        port.write('AT+CMGS="{}" \r'.format(phone_number).encode()) +        if not check_response('>', 6): +            print('Failed on CMGS') +            currently_sending = False +            return + +        # Write the message terminated by 'Ctrl+Z' or '1A' in ASCII +        port.write('{}\x1A \r'.format(message).encode()) + +        while True: +            result = port.readline().decode() + +            if 'OK' in result: +                print('> SMS sent successfully') +                last_msg_time = time() +                currently_sending = False +                return + +            if 'ERROR' in result: +                print('> Failed to send SMS [{}]'.format(result.rstrip())) +                currently_sending = False +                return +    except: +        # Initiate setup if the got while the program was running +        setup() +        currently_sending = False + +def on_motion(): +    print('Motion detected!') +    green.off() +    red.on() + +    if time() - last_msg_time > sms_timeout and not currently_sending: +        print('> Sending SMS...') +        threading.Thread(target=send_sms).start() + +def no_motion(): +    green.on() +    red.off() + +print('* Setting up...') +green.on() +red.on() + +port = serial.Serial() +port.port = device +port.baudrate = 115200 +port.timeout = 2 + +last_msg_time = 0 +currently_sending = False + +if not setup(): +    print('* Retrying...') +    if not setup(): +        print('* Try restarting the modem') +        exit(1) + +print('* Do not move, setting up the PIR sensor...') +sensor.wait_for_no_motion() + +print('* Device ready! ', end='', flush=True) +green.on() +red.off() + +sensor.when_motion = on_motion +sensor.when_no_motion = no_motion +input('Press Enter or Ctrl+C to exit\n\n') +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/11/motion-detection-raspberry-pi + +作者:[Lukas Janėnas][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/lukasjan +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/house_home_colors_live_building.jpg?itok=HLpsIfIL (Houses in a row) +[2]: https://teltonika-networks.com/product/trm240/ +[3]: https://opensource.com/sites/default/files/uploads/pir-sensor.jpg (PIR sensor) +[4]: https://creativecommons.org/licenses/by-sa/4.0/ +[5]: https://opensource.com/sites/default/files/uploads/modem.jpg (LTE modem) +[6]: https://wiki.teltonika-networks.com/view/TRM240_SIM_Card +[7]: https://opensource.com/sites/default/files/uploads/deviceoutput.png (USB ports output) +[8]: https://gpiozero.readthedocs.io/en/stable/recipes.html#pin-numbering +[9]: https://opensource.com/sites/default/files/uploads/wiring.png (Raspberry Pi wiring diagram) +[10]: tmp.4ePb9Wjuou#code +[11]: https://opensource.com/sites/default/files/uploads/motionssensorsetup.jpg (Motion sensor hardware) From 72bae07c53ab967ea14874b58d607a03a31c0323 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Tue, 24 Nov 2020 18:17:26 +0800 Subject: [PATCH 066/139] =?UTF-8?q?=E9=80=89=E9=A2=98[tech]:=2020201124=20?= =?UTF-8?q?A=20beginner's=20guide=20to=20developing=20with=20React?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20201124 A beginner-s guide to developing with React.md --- ...ginner-s guide to developing with React.md | 284 ++++++++++++++++++ 1 file changed, 284 insertions(+) create mode 100644 sources/tech/20201124 A beginner-s guide to developing with React.md diff --git a/sources/tech/20201124 A beginner-s guide to developing with React.md b/sources/tech/20201124 A beginner-s guide to developing with React.md new file mode 100644 index 0000000000..7928fb6b43 --- /dev/null +++ b/sources/tech/20201124 A beginner-s guide to developing with React.md @@ -0,0 +1,284 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (A beginner's guide to developing with React) +[#]: via: (https://opensource.com/article/20/11/reactjs-tutorial) +[#]: author: (Shedrack Akintayo https://opensource.com/users/shedrack-akintayo) + +A beginner's guide to developing with React +====== +A step-by-step guide to using React in your web and mobile user +interfaces. +![Gears connecting][1] + +[React][2] is a JavaScript user interface (UI) library that was built and is maintained by Facebook. React helps JavaScript developers think logically and functionally about how they want to build a UI. + +With React, you can build: + + 1. Single-page applications + 2. Applications that are easy to understand + 3. Scalable applications + 4. Cross-platform applications + + + +React allows developers to build applications declaratively and offers a unidirectional flow of data. + +### React's advantages + +The following features explain why React is one of the [most popular][3] web frameworks. + + * **It is declarative:** React makes it extremely painless to build interactive user interfaces, design basic views for your application based on various states, and update and render new views when the data in your application changes. + * **It is component-based:** React gives you the ability to build encapsulated components that can manage their own state, then puts them together to build complex UIs. The logic of these components is written in JavaScript instead of templates, so you easily pass actual data and keep state out of the [document object model][4] (DOM). + * **You can learn once, write anywhere:** React gives you the ability to build for both mobile (React Native) and the web. There's no need to rewrite your existing codebase; you can just integrate React with your existing code. + * **The virtual DOM:** React introduced a wrapper around the regular DOM called the virtual DOM (VDOM). This allows React to render elements and update its state faster than the regular DOM. + * **Performance:** React has great performance benefits due to the VDOM and one-way flow of data. + + + +### The virtual DOM + +React's VDOM is like a virtual copy of the original DOM. It offers one-way data binding, which makes manipulating and updating the VDOM quicker than updating the original DOM. The VDOM can handle multiple operations in milliseconds without affecting the general page performance. + +This VDOM supports React's declarative API: You basically tell React what state you want the UI to be in, and it ensures that the DOM matches that state. + +### Prerequisites for learning React + +Learning React requires basic knowledge of JavaScript, HTML, and CSS. To use React's power effectively, it helps to be familiar with [ECMAScript 6][5] (ES6) and functional and object-oriented programming. + +You also need the following things installed on your computer: + + * [NodeJS][6] + * [npm][7] (comes bundled with NodeJS) + * [Yarn][8] (an alternative to NPM) + + + +### Basic React concepts + +It also helps to have an understanding of React's concepts. + +#### Components + +Components are standalone, reusable pieces of code. They have the same purpose as JavaScript functions but work alone and return HTML via a built-in render function. They are two main types of components: + + * **Class components** offer more control in the form of lifecycle hooks, managing and handling state, and API calls. For example: [code] class MyComponent extends React.Component { +  render() { +    return <div>This is a class component</div>; +  } +} +``` + * **Functional components** were used for rendering just views without any form of state management or data request until [React Hooks][9] was introduced. For example: [code] Function myComponent() { +  return ( +      <div>A functional Component</div> +  ) + } +``` + + + +#### Props + +React props are like function arguments in JavaScript and attributes in HTML. They are read-only. For example: + + +``` +function Welcome(props) { +  return <h1>Hello, {props.name}</h1>; +} +``` + +#### State + +React components have a built-in object called _state_, which is where you store property values that belong to a particular component. If a component's state changes at any point in time, the component re-renders. For example: + + +``` +class Car extends React.Component { +  constructor(props) { +    super(props); +    this.state = { brand: 'Ford' }; +  } +  render() { +    return ( +      <div> +        <h1>My Car</h1> +      </div> +    ); +  } +} +``` + +#### JSX + +JSX is a syntax extension to JavaScript. It is similar to a template language but has the full power of JavaScript. JSX is compiled to `React.createElement()` calls, which return plain JavaScript objects called _React elements_. For example: + + +``` +return ( +  <div> +    <h1>My Car</h1> +  </div> +); +``` + +The code between the return method that looks like HTML is JSX. + +### How to use React + +Ready to get started? I'll go step-by-step through two options for using React in your app: + + * Adding its content delivery network (CDN) to your HTML file + * Starting a blank React app with Create React App + + + +#### Add its CDN to your HTML file + +You can quickly use React in your HTML page by adding its CDN directly to your HTML file using the following steps: + +**Step 1:** In the HTML page you want to add React to, add an empty `
` tag to create a container where you want to render something with React. For example: + + +``` +<!-- ... old HTML ... --> + +<[div][10] id="button_container"></[div][10]> + +<!-- ... old HTML ... --> +``` + +**Step 2:** Add three `