Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang
2020-04-30 19:42:10 +08:00
14 changed files with 1074 additions and 323 deletions

View File

@@ -1,8 +1,8 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-12168-1.html)
[#]: subject: (What Happened to IPv5? Why there is IPv4, IPv6 but no IPv5?)
[#]: via: (https://itsfoss.com/what-happened-to-ipv5/)
[#]: author: (John Paul https://itsfoss.com/author/john/)
@@ -20,19 +20,19 @@ IPv5 发生了什么?为什么有 IPv4、IPv6 但没有 IPv5
![ARPA Logical Map in 1977 | Image courtesy: Wikipedia][1]
在 1960 年代后期,美国国防部的[高级研究计划局][2] ARPA 发起了一个[项目][3]来连接全国的计算机。最初的目标是创建一个由全国 ARPA 资助的所有计算机组成的网络系统。
在 1960 年代后期,美国国防部的[高级研究计划局][2]DARPA发起了一个[项目][3]来连接全国的计算机。最初的目标是创建一个由全国 ARPA 资助的所有计算机组成的网络系统。
由于这是第一次将如此规模的网络整合在一起,因此他们也在不断发展自己的技术和硬件。他们的第一件工作是名为[传输控制协议][4] TCP 的互联网协议 IP。该协议“可靠、有序并会对通过 IP 网络传输的八进制(字节)流错误检测”。基本上,它确保数据安全到达。
由于这是第一次将如此规模的网络整合在一起,因此他们也在不断发展自己的技术和硬件。他们首先做的工作之一就是开发名为<ruby>[传输控制协议][4]<rt>Transmission Control Protocol</rt></ruby>TCP的<ruby>互联网协议<rt>Internet Protocol</rt></ruby>IP。该协议“可靠、有序并会对运行于通过 IP 网络传输的主机上的应用的八进制(字节)流通讯进行错误检测”。简单来说,它可以确保数据安全到达。
最初TCP 被设计为[“主机级别的端到端协议以及打包和路由协议”][5]。但是,他们意识到他们需要拆分协议以使其更易于管理。于是决定由 IP 处理打包和路由。
最初TCP 被设计为[“主机级别的端到端协议以及封装和路由协议”][5]。但是,他们意识到他们需要拆分协议以使其更易于管理。于是决定由 IP 协议处理封装和路由。
那时TCP 已经经历了三个版本,因此新协议被称为 IPv4。
### IPv5 的诞生
IPv5 以不同的名称开始使用:互联网流协议(或 ST。它是[由 Apple、NeXT 和 Sun Microsystems][6] 创建用于实验流式传输语音和视频。
IPv5 开始时有个不同的名字:<ruby>互联网流协议<rt>Internet Stream Protocol</rt></ruby>ST。它是[由 Apple、NeXT 和 Sun Microsystems][6] 为试验流式语音和视频而创建的
该新协议能够“在保持通信的同时特定频率传输数据包”。
该新协议能够“在保持通信的同时,以特定频率传输数据包”。
### 那么 IPv5 发生了什么?
@@ -40,15 +40,15 @@ IPv5 以不同的名称开始使用:互联网流协议(或 ST。它是[
IPv5 从未被接受为正式的互联网协议。这主要是由于 32 位限制。
IPV5 使用与 IPv4 相同的寻址系统。每个地址由 0 到 255 之间的四组数字组成。这将可能的地址数量限制为 [43 亿][6]。
IPV5 使用与 IPv4 相同的寻址系统。每个地址由 0 到 255 之间的四组数字组成。这将可能的地址数量限制为 [43 亿][6]
在 1970 年代初这似乎比全世界所需要的还要多。但是互联网的爆炸性增长证明了这一想法是错误的。2011年世界正式耗尽了 IPv4 地址。
在 1970 年代初这似乎比全世界所需要的还要多。但是互联网的爆炸性增长证明了这一想法是错误的。2011 年,世界上的IPv4地址正式用完了
在 1990 年代,一个新项目开始致力于下一代互联网协议 IPng。这导致了 128 位的 IPv6。IPv6 地址包含 [“8 组 4 字符的十六进制数字”][6],它可以包含从 0 到 9 的数字和从 A 到 F 的字母。与 IPv4 不同IPv6 拥有数万亿个可能的地址,因此我们应该能安全一阵子。
在 1990 年代,一个新项目开始致力于研究下一代互联网协议IPng。这形成了 128 位的 IPv6。IPv6 地址包含 [“8 组 4 字符的十六进制数字”][6],它可以包含从 0 到 9 的数字和从 A 到 F 的字母。与 IPv4 不同IPv6 拥有数万亿个可能的地址,因此我们应该能安全一阵子。
同时IPv5 奠定了 VoIP 的基础,而该技术已被我们用于当今世界范围内的通信。**因此,我想往小了说,你可以说 IPv5 仍然可以保留到了今天**。
同时IPv5 奠定了 VoIP 的基础,而该技术已被我们用于当今世界范围内的通信。**因此,我想在某种程度上,你可以说 IPv5 仍然可以保留到了今天**。
希望你喜欢有关互联网历史的轶事。你可以阅读其他[关于 Linux 和技术的琐事文章] [8]。
希望你喜欢有关互联网历史的轶事。你可以阅读其他[关于 Linux 和技术的琐事文章][8]。
如果你觉得这篇文章有趣请花一点时间在社交媒体、Hacker News 或 [Reddit][9] 上分享它。
@@ -59,7 +59,7 @@ via: https://itsfoss.com/what-happened-to-ipv5/
作者:[John Paul][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/) 荣誉推出

View File

@@ -1,8 +1,8 @@
[#]: collector: (lujun9972)
[#]: translator: (wxy)
[#]: reviewer: (wxy)
[#]: publisher: ( )
[#]: url: ( )
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-12166-1.html)
[#]: subject: (Manjaro 20 Lysia Arrives with ZFS and Snap Support)
[#]: via: (https://itsfoss.com/manjaro-20-release/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)

View File

@@ -0,0 +1,71 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Java security, mainframes having a moment, and more industry trends)
[#]: via: (https://opensource.com/article/20/4/java-mainframes-dev-skills-more-industry-trends)
[#]: author: (Tim Hildred https://opensource.com/users/thildred)
Java security, mainframes having a moment, and more industry trends
======
A weekly look at open source community and industry trends.
![Person standing in front of a giant computer screen with numbers, data][1]
As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update.
## [How secure is Java compared to other languages?][2]
> In this article, we'll look at how the most commonly used programming languages rank in terms of security. I'll explain some factors that make one language less secure than another, and why identified vulnerabilities have increased so much in the past few years. Finally, I'll suggest a few ways Java developers can reduce vulnerabilities in code.  
**The impact**: If software is eating the world, then hackers are... I guess the thrush thriving in the gullet? Hyperbole aside, the more stuff made of software, the more incentive clever people have to try and figure out how to do things they probably shouldn't be able to. This applies to Java too.
## [Mainframes are having a moment][3]
> In addition to being abundant, mainframe jobs pay well, and so far, appear not to be as affected by the pandemic as other areas of tech employment. Salaries for entry-level enterprise computing jobs [average US $70,100 a year][4] [PDF], according to a 2019 report from tech analyst [Forrester Research][5] commissioned by IBM. As recently as this week, jobs boards such as [Indeed][6] and [Dice.com][7] listed hundreds or in some cases thousands of openings for mainframe positions at all levels. Advertised pay ranges from $30 to $35 an hour for a junior mainframe developer to well over $150,000 a year for a mainframe database administration manager.
**The impact**: That is much, much better than a poke in the eye.
## [The developer skills on the rise, and in decline][8]
> Indeed.com analysed job postings using a list of 500 key technology skill terms to see which ones employers are looking for more these days and which are falling out of favour. Such research has helped identify cutting-edge skills over the past five years, with some previous years risers now well establish, thanks to explosive growth.
**The impact**: The "on the rise" skills outnumber the "in decline" skills. Bad news for browser developers...
## [The IT Pro Podcast: Building cloud-native apps][9]
> The cloud is eating enterprise IT, and while on-premise applications are going to be around for a long time to come, the importance of being able to successfully take advantage of cloud technologies should not be understated. However, its one thing to simply port an existing application to the cloud, but developing software to be run in cloud environments is a different matter altogether.
**The impact**: What is technology if not manifested mindset?
## [Communication is key to culture change][10]
> The outcome is staggering. Business teams feel invested in the development of the solution, they feel a sense of excitement and ownership. So much so, they go out into the corridors of the organisation to evangelise and promote the solution. Conversely, this improves the status of the developers within the business. It allows them to integrate with other stakeholders, contribute to new processes and help to achieve common goals. 
**The impact**: As a communications person, I couldn't agree more. Communication is the difference between an organization and a movement.
_I hope you enjoyed this list and come back next week for more open source community, market, and industry trends._
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/4/java-mainframes-dev-skills-more-industry-trends
作者:[Tim Hildred][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/thildred
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data)
[2]: https://www.javaworld.com/article/3537561/how-secure-is-java-compared-to-other-languages.html
[3]: https://spectrum.ieee.org/tech-talk/computing/software/mainframes-programming-language-cobol-news-coronavirus
[4]: https://www.ibm.com/downloads/cas/1EPYAP5D
[5]: https://go.forrester.com/
[6]: https://www.indeed.com/q-Mainframe-jobs.html
[7]: https://www.dice.com/jobs/q-Mainframe-jobs
[8]: https://www.techcentral.ie/10-developer-skills-on-the-rise-and-five-on-the-decline/
[9]: https://www.itpro.co.uk/cloud/355348/the-it-pro-podcast-building-cloud-native-apps
[10]: https://www.verdict.co.uk/culture-service-digital-enterprise/

View File

@@ -1,197 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (robsean)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Configure SFTP Server with Chroot in Debian 10)
[#]: via: (https://www.linuxtechi.com/configure-sftp-chroot-debian10/)
[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/)
How to Configure SFTP Server with Chroot in Debian 10
======
**SFTP** stands for Secure File Transfer Protocol / SSH File Transfer Protocol, it is one of the most common method which is used to transfer files securely over ssh from our local system to remote server and vice-versa. The main advantage of sftp is that we dont need to install any additional package except **openssh-server**, in most of the Linux distributions openssh-server package is the part of default installation. Other benefit of sftp is that we can allow user to use sftp only not ssh.
[![Configure-sftp-debian10][1]][2]
Recently Debian 10, Code name Buster has been released, in this article we will demonstrate how to configure sftp with Chroot Jail like environment in Debian 10 System. Here Chroot Jail like environment means that users cannot go beyond from their respective home directories or users cannot change directories from their home directories.  Following are the lab details:
* OS = Debian 10
* IP Address = 192.168.56.151
Lets jump into SFTP Configuration Steps,
### Step:1) Create a Group for sftp using groupadd command
Open the terminal, create a group with a name “**sftp_users**” using below groupadd command,
```
root@linuxtechi:~# groupadd sftp_users
```
### Step:2) Add Users to Group sftp_users and set permissions
In case you want to create new user and want to add that user to sftp_users group, then run the following command,
**Syntax:** #  useradd -m -G sftp_users &lt;user_name&gt;
Lets suppose user name is Jonathan
```
root@linuxtechi:~# useradd -m -G sftp_users jonathan
```
set the password using following chpasswd command,
```
root@linuxtechi:~# echo "jonathan:<enter_password>" | chpasswd
```
In case you want to add existing users to sftp_users group then run beneath usermod command, lets suppose already existing user name is chris
```
root@linuxtechi:~# usermod -G sftp_users chris
```
Now set the required permissions on Users,
```
root@linuxtechi:~# chown root /home/jonathan /home/chris/
```
Create an upload folder in both the users home directory and set the correct ownership,
```
root@linuxtechi:~# mkdir /home/jonathan/upload
root@linuxtechi:~# mkdir /home/chris/upload
root@linuxtechi:~# chown jonathan /home/jonathan/upload
root@linuxtechi:~# chown chris /home/chris/upload
```
**Note:** User like Jonathan and Chris can upload files and directories to upload folder from their local systems.
### Step:3) Edit sftp configuration file (/etc/ssh/sshd_config)
As we have already stated that sftp operations are done over the ssh, so its configuration file is “**/etc/ssh/sshd_config**“, Before making any changes I would suggest first take the backup and then edit this file and add the following content,
```
root@linuxtechi:~# cp /etc/ssh/sshd_config /etc/ssh/sshd_config-org
root@linuxtechi:~# vim /etc/ssh/sshd_config
………
#Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem sftp internal-sftp
Match Group sftp_users
X11Forwarding no
AllowTcpForwarding no
ChrootDirectory %h
ForceCommand internal-sftp
…………
```
Save &amp; exit the file.
To make above changes into the affect, restart ssh service using following systemctl command
```
root@linuxtechi:~# systemctl restart sshd
```
In above sshd_config file we have commented out the line which starts with “Subsystem” and added new entry “Subsystem       sftp    internal-sftp” and new lines like,
“**Match Group sftp_users”**  &gt; It means if a user is a part of sftp_users group then apply rules which are mentioned below to this entry.
“**ChrootDierctory %h**” &gt; It means users can only change directories within their respective home directories, they cannot go beyond their home directories, or in other words we can say users are not permitted to change directories, they will get jai like environment within their directories and cant access any other users and systems directories.
“**ForceCommand internal-sftp**” &gt; It means users are limited to sftp command only.
### Step:4) Test and Verify sftp
Login to any other Linux system which is on the same network of your sftp server and then try to ssh sftp server via the users that we have mapped in sftp_users group.
```
[root@linuxtechi ~]# ssh root@linuxtechi
root@linuxtechi's password:
Write failed: Broken pipe
[root@linuxtechi ~]# ssh root@linuxtechi
root@linuxtechi's password:
Write failed: Broken pipe
[root@linuxtechi ~]#
```
Above confirms that users are not allowed to SSH , now try sftp using following commands,
```
[root@linuxtechi ~]# sftp root@linuxtechi
root@linuxtechi's password:
Connected to 192.168.56.151.
sftp> ls -l
drwxr-xr-x 2 root 1001 4096 Sep 14 07:52 debian10-pkgs
-rw-r--r-- 1 root 1001 155 Sep 14 07:52 devops-actions.txt
drwxr-xr-x 2 1001 1002 4096 Sep 14 08:29 upload
```
Lets try to download a file using sftp **get** command
```
sftp> get devops-actions.txt
Fetching /devops-actions.txt to devops-actions.txt
/devops-actions.txt 100% 155 0.2KB/s 00:00
sftp>
sftp> cd /etc
Couldn't stat remote file: No such file or directory
sftp> cd /root
Couldn't stat remote file: No such file or directory
sftp>
```
Above output confirms that we are able to download file from our sftp server to local machine and apart from this we have also tested that users cannot change directories.
Lets try to upload a file under “**upload**” folder,
```
sftp> cd upload/
sftp> put metricbeat-7.3.1-amd64.deb
Uploading metricbeat-7.3.1-amd64.deb to /upload/metricbeat-7.3.1-amd64.deb
metricbeat-7.3.1-amd64.deb 100% 38MB 38.4MB/s 00:01
sftp> ls -l
-rw-r--r-- 1 1001 1002 40275654 Sep 14 09:18 metricbeat-7.3.1-amd64.deb
sftp>
```
This confirms that we have successfully uploaded a file from our local system to sftp server.
Now test the SFTP server with winscp tool, enter the sftp server ip address along users credentials,
[![Winscp-sftp-debian10][1]][3]
Click on Login and then try to download and upload files
[![Download-file-winscp-debian10-sftp][1]][4]
Now try to upload files in upload folder,
[![Upload-File-using-winscp-Debian10-sftp][1]][5]
Above window confirms that uploading is also working fine, thats all from this article. If these steps help you to configure SFTP server with chroot environment in Debian 10 then please do share your feedback and comments.
--------------------------------------------------------------------------------
via: https://www.linuxtechi.com/configure-sftp-chroot-debian10/
作者:[Pradeep Kumar][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.linuxtechi.com/author/pradeep/
[b]: https://github.com/lujun9972
[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
[2]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Configure-sftp-debian10.jpg
[3]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Winscp-sftp-debian10.jpg
[4]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Download-file-winscp-debian10-sftp.jpg
[5]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Upload-File-using-winscp-Debian10-sftp.jpg

View File

@@ -1,108 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Create Stunning Pixel Art With Free and Open Source Editor Pixelorama)
[#]: via: (https://itsfoss.com/pixelorama/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
Create Stunning Pixel Art With Free and Open Source Editor Pixelorama
======
_**Brief: Pixelorama is a cross-platform, free and open source 2D sprite editor. It provides all the necessary tools to create pixel art in a neat user interface.**_
### Pixelorama: open source sprite editor
[Pixelorama][1] is a tool created by young game developers at [Orama Interactive][2]. They have developed a few 2D games and a couple of them use pixel art.
While Orama is primarily into game development, the developers are also creating utility tools that help them (and others) create those games.
The free and open source sprite editor, Pixelorama is such a utility tool. Its built on top of [Godot Engine][3] and is perfect for creating pixel art.
![Pixelorama screenshot][4]
You see the pixel art in the screenshot above? Its been created using Pixelorama. This video shows a timelapse video of creating the above image.
### Features of Pixelorama
Here are the main features Pixelorama provides:
* Multiple tools like penicl, erase, fill bucket color picker etc
* Multiple layer system that allows you to add, remove, move up and down, clone and merge as many layers as you like
* Support for spritesheets
* Import images and edit them inside Pixelorama
* Animation timeline with [Onion Skinning][5]
* Custom brushes
* Save and open your projects in Pixeloramas custom file format, .pxo
* Horizontal &amp; vertical mirrored drawing
* Tile Mode for pattern creation
* Split screen mode and mini canvas preview
* Zoom with mouse scroll wheel
* Unlimited undo and redo
* Scale, crop, flip, rotate, color invert and desaturate your images
* Keyboard shortcuts
* Available in several languages
* Supports Linux, Windows and macOS
### Installing Pixelorama on Linux
Pixelorama is available as a Snap application and if you are using Ubuntu, you can find it in the software center itself.
![Pixelorama is available in Ubuntu Software Center][6]
Alternatively, if you have [Snap support enabled on your Linux distribution][7], you can install it using this command:
```
sudo snap install pixelorama
```
If you dont want to use Snap, no worries. You can download the latest release of Pixelorama from [their GitHub repository][8], [extract the zip file][9] and youll see an executable file. Give this file execute permission and double click on it to run the application.
[Download Pixelorama][10]
**Conclusion**
![Pixelorama Welcome Screen][11]
In the Pixeloaram features, it says that you can import images and edit them. I guess thats only true for certain kind of files because when I tried to import PNG or JPEG files, the application crashed.
However, I could easily doodle like a 3 year old and make random pixel art. I am not that into arts but I think this is a [useful tool for digital artists on Linux][12].
I liked the idea that despite being game developers, they are creating tools that could help other game developers and artists. Thats the spirit of open source.
If you like the project and will be using it, consider supporting them by a donation. [Its FOSS has made a humble donation][13] of $25 to thank their effort.
[Donate to Pixelorama (personal Paypal account of the lead developer)][14]
Do you like Pixelorama? Do you use some other open source sprite editor? Feel free to share your views in the comment section.
--------------------------------------------------------------------------------
via: https://itsfoss.com/pixelorama/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/abhishek/
[b]: https://github.com/lujun9972
[1]: https://www.orama-interactive.com/pixelorama
[2]: https://www.orama-interactive.com/
[3]: https://godotengine.org/
[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/pixelorama-v6.jpg?ssl=1
[5]: https://en.wikipedia.org/wiki/Onion_skinning
[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/pixelorama-ubuntu-software-center.jpg?ssl=1
[7]: https://itsfoss.com/install-snap-linux/
[8]: https://github.com/Orama-Interactive/Pixelorama
[9]: https://itsfoss.com/unzip-linux/
[10]: https://github.com/Orama-Interactive/Pixelorama/releases
[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/pixelorama.jpg?ssl=1
[12]: https://itsfoss.com/best-linux-graphic-design-software/
[13]: https://itsfoss.com/donations-foss/
[14]: https://www.paypal.me/erevos

View File

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

View File

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

View File

@@ -0,0 +1,144 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Drop PNG and JPG for your online images: Use WebP)
[#]: via: (https://opensource.com/article/20/4/webp-image-compression)
[#]: author: (Jeff Macharyas https://opensource.com/users/jeffmacharyas)
Drop PNG and JPG for your online images: Use WebP
======
Get started with this open source image editing tool to save time and
space.
![Painting art on a computer screen][1]
WebP is an image format developed by Google in 2010 that provides superior lossless and lossy compression for images on the web. Using WebP, web developers can create smaller, richer images that improve site speed. A faster loading website is critical to the user experience and for the website's marketing effectiveness.
For optimal loading across all devices and users, images on your site should not be larger than 500 KB in file size.
WebP lossless images are often at least 25% smaller in size compared to PNGs. WebP lossy images are often anywhere from 25-34% smaller than comparable JPEG images at equivalent SSIM (structural similarity) quality index.
Lossless WebP supports transparency, as well. For cases when lossy RGB compression is acceptable, lossy WebP also supports transparency, typically providing three times smaller file sizes compared to PNG.
Google reports a 64% reduction in file size for images converted from animated GIFs to lossy WebP, and a 19% reduction when converted to lossless WebP.
The WebP file format is based on the RIFF (resource interchange file format) document format. The file signature is **52 49 46 46** (RIFF), as you can see with [hexdump][2]:
```
$ hexdump --canonical pixel.webp
00000000  52 49 46 46 26 00 00 00  [...]  |RIFF&amp;...WEBPVP8 |
00000010  1a 00 00 00 30 01 00 9d  [...]  |....0....*......|
00000020  0e 25 a4 00 03 70 00 fe  [...]  |.%...p...`....|
0000002e
```
The standalone libwebp library serves as a reference implementation for the WebP specification and is available from Google's [Git repository][3] or as a tarball.
The WebP format is compatible with 80% of the web browsers in use worldwide. At the time of this writing, it is not compatible with Apple's Safari browser. The workaround for this is to serve up a JPG/PNG alongside a WebP, and there are methods and Wordpress plugins to do that.
### Why does this matter?
Part of my job is to design and maintain our organization's website. Since the website is a marketing tool and site speed is a critical aspect of the user experience, I have been working to improve the speed, and reducing image sizes by converting them to WebP has been a good solution.
To test the speed of one of the pages, I turned to **web.dev**, which is powered by Lighthouse, released under the Apache 2.0 license, and can be found at <https://github.com/GoogleChrome/lighthouse>.
According to its official description, "Lighthouse is an open source, automated tool for improving the quality of web pages. You can run it against any web page—public or requiring authentication. It has audits for performance, accessibility, progressive web apps, SEO, and more. You can run Lighthouse in Chrome DevTools, from the command line, or as a Node module. You give Lighthouse a URL to audit, it runs a series of audits against the page, and then it generates a report on how well the page did. From there, use the failing audits as indicators on how to improve the page. Each audit has a reference doc explaining why the audit is important, as well as how to fix it."
### Creating a smaller WebP image
The page I tested returned three images. In the report it generates, it provides recommendations and targets. I chose the "app-graphic" image, which, it reported, is 650 KB. By converting it to WebP, I should save 589 KB, reducing the image to 61 KB. I converted the image in Photoshop and saved it with the default WebP settings, and it returned a file size of 44.9 KB. Better than expected! As the screenshot from Photoshop shows, the images look identical in visual quality.
![WebP vs JPG comparison][4]
On the left: 650 KB (actual size). On the right: 589 KB (target size after conversion).
Of course, the open source image editor [GIMP][5] also supports WebP as an export format. It offers several options for quality and compression profile:
![GIMP dialog for exporting webp, as a webp][6]
A zoomed-in look of another image:
![WebP vs PNG comparison][7]
PNG (left) and WebP (right), both converted from a JPG, shows the WebP, although smaller in size, is superior in visual quality.
### Convert to an image to WebP
To convert images on Linux from JPG/PNG to WebP, you can also use the command-line:
Use **cwebp** on the command line to convert PNG or JPG image files to WebP format. You can convert a PNG image file to a WebP image with a quality range of 80 with the command:
```
`cwebp -q 80 image.png -o image.webp`
```
Alternatively, you can also use [Image Magick][8], which is probably available in your distribution's software repository. The subcommand for conversion is **convert**, and all that's needed is an input and output file:
```
`convert pixel.png pixel.webp`
```
### Convert an image to WebP with an editor
To convert images to WebP with a photo editor, use [GIMP][9]. From version 2.10 on, it supports WebP natively.
If you're a Photoshop user, you need a plugin to convert the files, as Photoshop does not include it natively. WebPShop 0.2.1, released under the Apache License 2.0 license, is a Photoshop module for opening and saving WebP images, including animations, and can be found at: <https://github.com/webmproject/WebPShop>.
To use the plugin, put the file found in the **bin** folder inside your Photoshop plugin directory:
Windows x64—C:\Program Files\Adobe\Adobe Photoshop\Plug-ins\WebPShop.8bi
Mac—Applications/Adobe Photoshop/Plug-ins/WebPShop.plugin
### WebP on Wordpress
Many websites are built using Wordpress (that's what I use). So, how does Wordpress handle uploading WebP images? At the time of this writing, it doesn't. But, there are, of course, plugins to enable it so you can serve up both WebP alongside PNG/JPG images (for the Apple crowd).
Or there are these [instructions][10] from [Marius Hosting][11]:
"How about directly uploading WebP images to Wordpress? This is easy. Just add some text line on your theme functions.php file. Wordpress does not natively support viewing and uploading WebP files, but I will explain to you how you can make it work in a few simple steps. Log in to your Wordpress admin area and go to Appearance/Theme Editor and find functions.php. Copy and paste the code below at the end of the file and save it. 
```
`//** *Enable upload for webp image files.*/ function webp_upload_mimes($existing_mimes) { $existing_mimes['webp'] = 'image/webp'; return $existing_mimes; } add_filter('mime_types', 'webp_upload_mimes');`
```
If you want to see the thumbnail image preview when you go to Media/Library, you have to add the code below in the same functions.php file. To find the functions.php file, go to Appearance/Theme Editor and find functions.php, then copy and paste the code below at the end of the file and save it."
```
`//** * Enable preview / thumbnail for webp image files.*/ function webp_is_displayable($result, $path) { if ($result === false) { $displayable_image_types = array( IMAGETYPE_WEBP ); $info = @getimagesize( $path ); if (empty($info)) { $result = false; } elseif (!in_array($info[2], $displayable_image_types)) { $result = false; } else { $result = true; } } return $result; } add_filter('file_is_displayable_image', 'webp_is_displayable', 10, 2);`
```
### WebP and the future
WebP is a robust and optimized format. It looks better, it has better compression ratio, and it has all the features of most other common image formats. There's no need to wait—start using it now.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/4/webp-image-compression
作者:[Jeff Macharyas][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/jeffmacharyas
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/painting_computer_screen_art_design_creative.png?itok=LVAeQx3_ (Painting art on a computer screen)
[2]: https://opensource.com/article/19/8/dig-binary-files-hexdump
[3]: https://storage.googleapis.com/downloads.webmproject.org/releases/webp/index.html
[4]: https://opensource.com/sites/default/files/uploads/webp-vs-jpg-app-graphic.png (WebP vs JPG comparison)
[5]: http://gimp.org
[6]: https://opensource.com/sites/default/files/webp-gimp.webp (GIMP dialog for exporting webp, as a webp)
[7]: https://opensource.com/sites/default/files/uploads/xcompare-png-left-webp-right.png (WebP vs PNG comparison)
[8]: https://imagemagick.org
[9]: https://en.wikipedia.org/wiki/GIMP
[10]: https://mariushosting.com/how-to-upload-webp-files-on-wordpress/
[11]: https://mariushosting.com/

View File

@@ -0,0 +1,137 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Open source live streaming with Open Broadcaster Software)
[#]: via: (https://opensource.com/article/20/4/open-source-live-stream)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Open source live streaming with Open Broadcaster Software
======
If you have something to say, a skill to teach, or just something fun to
share, broadcast it to the world with OBS.
![An old-fashioned video camera][1]
If you have a talent you want to share with the world, whether it's making your favorite sourdough bread or speedrunning through a level of your favorite video game, live streaming is the modern show-and-tell. It's a powerful way to tell the world about your hobby through a medium once reserved for exclusive and expensive TV studios. Not only is the medium available to anyone with a relatively good internet connection, but the most popular software to make it happen is open source.
[OBS][2] (Open Broadcaster Software) is a cross-platform application that serves as a control center for your live stream. A _stream_, strictly speaking, means _progressive and coherent data_. The data in a stream can be audio, video, graphics, text, or anything else you can represent as digital data. OBS is programmed to accept data as input, combine streams together (technically referred to as _mixing_) into one product, and then broadcast it.
![OBS flowchart][3]
A _broadcast_ is data that can be received by some target. If you're live streaming, your primary target is a streaming service that can host your stream, so other people can find it in a web browser or media player. A live stream is a live event, so people have to "tune in" to your stream when it's happening, or else they miss it. However, you can also target your own hard drive so you can record a presentation and then post it on the internet later for people to watch at their leisure.
### Installing OBS
To install OBS on Windows or macOS, download an installer package from [OBS's website][2].
To install OBS on Linux, either install it with your package manager (such as **dnf**, **zypper**, or **apt**) or [install it as a Flatpak][4].
### Join a streaming service
In order to live stream, you must have a stream broker. That is, you need a central location on the internet for your stream to be delivered, so your viewers can get to what you're broadcasting. There are a few popular streaming services online, like YouTube and Twitch. You can also [set up your own video streaming server][5] using open source software.
Regardless of which option you choose, before you begin streaming, you must have a destination for your stream. If you do use a streaming service, you must obtain a _streaming key_. A streaming key is a hash value (it usually looks something like **2ae2fad4e33c3a89c21**) that is private and unique to you. You use this key to authenticate yourself through your streaming software. Without it, the streaming service can't know you are who you say you are and won't let you broadcast over your user account.
* * *
* * *
* * *
**![Streaming key][6]**
* In Twitch, your **Primary Stream Key** is available in the **Channel** panel of your **Creator Dashboard**.
* On YouTube, you must enable live streaming by verifying your account. Once you've done that, your **Stream Key** is in the **Other Features** menu option of your **Channel Dashboard**.
* If you're using your own server, there's no maze-like GUI to navigate. You just [create your own streaming key][7].
### Enter your streaming key
Once you have a streaming key, launch OBS and go to the **File** &gt; **Settings** menu.
In the **Settings** window, click on the **Stream** category in the left column. Set the **Service** to your stream service (Custom, Twitch, YouTube, etc.), and enter your stream key. Click the **OK** button in the bottom right to save your changes.
### Create sources
In OBS, _sources_ represent any input signal you want to stream. By default, sources are listed at the bottom of the OBS window.
![OBS sources][8]
This might be a webcam, a microphone, an audio stream (such as the sound of a video game you're playing), a screen capture of your computer (a "screencast"), a slideshow you want to present, an image, and so on. Before you start streaming, you should define all the sources you plan on using for your stream. This means you have to do a little pre-production and consider what you anticipate for your show. Any camera you have set up must be defined as a source in OBS. Any extra media you plan on cutting to during your show must be defined as a source. Any sound effects or background music must be defined as a source.
Not all sources "happen" at once. By adding media to your **Sources** panel in OBS, you're just assembling the raw components for your stream. Once you make devices and data available to OBS, you can create your **Scenes**.
#### Setting up audio
Computers have seemingly dozens of ways to route audio. Here's the workflow to follow when setting up sound for your stream:
1. Check your cables: verify that your microphone is plugged in.
2. Go to your computer's sound control panel and set the input to whatever microphone you want OBS to treat as the main microphone. This might be a gaming headset or a boom mic or a desktop podcasting mic or a Bluetooth device or a fancy audio interface with XLR ports. Whatever it is, make sure your computer "hears" your main sound input.
3. In OBS, create a source for your main microphone and name it something obvious (e.g., boom mic, master sound, or mic).
4. Do a test. Make sure OBS "hears" your microphone by referring to the audio-level monitors at the bottom of the OBS window. If it's not responding to the input you believe you've set as input, check your cables, check your computer sound control panel, and check OBS.
I've seen more people panic over audio sources than any other issue when streaming, and we've _all_ made the same dumb mistakes (several times each, probably!) when attempting to set a microphone for a live stream or videoconference call. Breathe deep, check your cables, check your inputs and outputs, and [get comfortable with audio][9]. It'll pay off in the end.
### Create scenes
A **Scene** in OBS is a screen layout and consists of one or more sources.
![Scenes in OBS][10]
For instance, you might create a scene called **Master shot** that shows you sitting at your desk in front of your computer or at the kitchen counter ready to mix ingredients together. The source could be a webcam mounted on a tripod a meter or two in front of you. Because you want to cut to a detail shot, you might create a second scene called **Close-up**, which uses the computer screen and audio as one input source and your microphone as another source, so you can narrate as you demonstrate what you're doing. If you're doing a baking show, you might want to mount a second webcam above the counter, so you can cut to an overhead shot of ingredients being mixed. Here, your source is a different webcam but probably the same microphone (to avoid making changes in the audio).
A _scene_, in other words, is a lot like a _shot_ in traditional production vernacular, but it can be the combination of many shots. The fun thing about OBS is that you can mix and match a lot of different sources together, so when you're adding a **Scene**, you can resize and position different sources to achieve picture-in-picture, or split-screen, or any other effect you might want. It's common in video game "let's play" streams to have the video game in full-screen, with the player inset in the lower right or left. Or, if you're recording a panel or a multi-player game like D&amp;D you might have several cameras covering several players in a _Brady Bunch_ grid.
The possibilities are endless. During streaming, you can cut from one scene to another as needed. This is intended to be a dynamic system, so you can change scenes depending on what the viewer needs to see at any given moment.
Generally, you want to have some preset scenes before you start to stream. Even if you have a friend willing to do video mixing as you stream, you always want a safe scene to fall back to, so take time beforehand to set up at least a master shot that shows you doing whatever it is you're doing. If all else fails, at least you'll have your main shot you can safely and reliably cut to.
### Transitions
When switching from one scene to another, OBS uses a transition. Once you have more than one scene, you can configure what kind of transition it uses in the **Transitions** panel. Simple transitions are usually best. By default, OBS uses a subtle crossfade, but you can experiment with others as you see fit.
### Go live
To start streaming, do your vocal exercises, find your motivation, and press the **Start Streaming** button.
![Start streaming in OBS][11]
As long as you've set up your streaming service correctly, you're on the air (or on the wires, anyway).
If you're the talent (the person in front of the camera), it might be easiest to have someone control OBS during streaming. But if that's not possible, you can control it yourself as long as you've practiced a little in advance. If you're screencasting, it helps to have a two-monitor setup so you can control OBS without it being on screen.
### Streaming for success
Many of us take streaming for granted now that the internet exists and can broadcast media created by _anyone_. It's a hugely powerful means of communication, and we're all responsible for making the most of it.
If you have something positive to say, a skill to teach, words of encouragement, or just something fun that you want to share, and you feel like you want to broadcast to the world, then take the time to learn OBS. You might not get a million viewers, but independent media is a vital part of [free culture][12]. The world can always use empowering and positive open source voices, and yours may be one of the most important of all.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/4/open-source-live-stream
作者:[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/LIFE_film.png?itok=aElrLLrw (An old-fashioned video camera)
[2]: http://obsproject.com
[3]: https://opensource.com/sites/default/files/obs-flowchart.jpg (OBS flowchart)
[4]: https://flatpak.org/setup
[5]: https://opensource.com/article/19/1/basic-live-video-streaming-server
[6]: https://opensource.com/sites/default/files/twitch-key.jpg (Streaming key)
[7]: https://opensource.com/article/19/1/basic-live-video-streaming-server#obs
[8]: https://opensource.com/sites/default/files/uploads/obs-sources.jpg (OBS sources)
[9]: https://opensource.com/article/17/1/linux-plays-sound
[10]: https://opensource.com/sites/default/files/uploads/obs-scenes.jpg (Scenes in OBS)
[11]: https://opensource.com/sites/default/files/uploads/obs-stream-start.jpg (Start streaming in OBS)
[12]: https://opensource.com/article/18/1/creative-commons-real-world

View File

@@ -0,0 +1,80 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (The life-changing magic of git rebase -i)
[#]: via: (https://opensource.com/article/20/4/git-rebase-i)
[#]: author: (Dave Neary https://opensource.com/users/dneary)
The life-changing magic of git rebase -i
======
Make everyone think you write perfect code the first time (and make your
patches easier to review and merge).
![Hands programming][1]
Software development is messy. So many wrong turns, typos to fix, quick hacks and kludges to correct later, off-by-one errors you find late in the process. With version control, you have a pristine record of every wrong turn and correction made during the process of creating the "perfect" final product—a patch ready to submit upstream. Like the outtakes from movies, they are a little embarrassing and sometimes amusing.
Wouldn't it be great if you could use version control to save your work regularly at waypoints, and then when you have something you are ready to submit for review, you could hide all of that private drafting work and just submit a single, perfect patch? Meet **git rebase -i**, the perfect way to rewrite history and make everyone think that you produce perfect code the first time!
### What does git rebase do?
In case you're not familiar with the intricacies of Git, here is a brief overview. Under the covers, Git associates different versions of your project with a unique identifier, which is made up of a hash of the parent node's unique identifier, and the difference between the new version and its parent node. This creates a tree of revisions, and each person who checks out the project gets their own copy. Different people can take the project in different directions, each starting from potentially different branch points.
![Master branch vs. private branch][2]
The master branch in the "origin" repo on the left and the private branch on your personal copy on the right.
There are two ways to integrate your work back with the master branch in the original repository: one is to use **git merge**, and the other is to use **git rebase**. They work in very different ways.
When you use **git merge**, a new commit is created on the master branch that includes all of the changes from origin plus all of your local changes. If there are any conflicts (for example, if someone else has changed a file you are also working with), these will be marked, and you have an opportunity to resolve the conflicts before committing this merge commit to your local repository. When you push your changes back to the parent repository, all of your local work will appear as a branch for other users of the Git repository.
But **git rebase** works differently. It rewinds your commits and replays those commits again from the tip of the master branch. This results in two main changes. First, since your commits are now branching off a different parent node, their hashes will be recalculated, and anyone who has cloned your repository may now have a broken copy of the repository. Second, you do not have a merge commit, so any merge conflicts are identified as your changes are being replayed onto the master branch, and you need to fix them before proceeding with the rebase. When you push your changes now, your work does not appear on a branch, and it looks as though you wrote all of your changes off the very latest commit to the master branch.
![Merge commits preserve history, and rebase rewrites history.][3]
Merge commits (left) preserve history, while rebase (right) rewrites history.
However, both of these options come with a downside: everyone can see all your scribbles and edits as you worked through problems locally before you were ready to share your code. This is where the **\--interactive** (or **-i** for short) flag to **git rebase** comes into the picture.
### Introducing git rebase -i
The big advantage of **git rebase** is that it rewrites history. But why stop at just pretending you branched off a later point? There is a way to go even further and rewrite how you arrived at your ready-to-propose code: **git rebase -i**, an interactive **git rebase**.
This feature is the "magic time machine" function in Git. The flag allows you to make sophisticated changes to revision history while doing a rebase. You can hide your mistakes! Merge many small changes into one pristine feature patch! Reorder how things appear in revision history!
![output of git rebase -i][4]
When you run **git rebase -i**, you get an editor session listing all of the commits that are being rebased and a number of options for what you can do to them. The default choice is **pick**.
* **Pick** maintains the commit in your history.
* **Reword** allows you to change a commit message, perhaps to fix a typo or add additional commentary.
* **Edit** allows you to make changes to the commit while in the process of replaying the branch.
* **Squash** merges multiple commits into one.
* You can reorder commits by moving them around in the file.
When you are finished, simply save the final result, and the rebase will execute. At each stage where you have chosen to modify a commit (either with **reword**, **edit**, **squash**, or when there is a conflict), the rebase stops and allows you to make the appropriate changes before continuing.
The example above results in "One-liner bug fix" and "Integrate new header everywhere" being merged into one commit, and "New header for docs website" and "D'oh - typo. Fixed" into another. Like magic, the work that went into the other commits is still there on your branch, but the associated commits have disappeared from your history!
This makes it easy to submit a clean patch to an upstream project using **git send-email** or by creating a pull request against the parent repository with your newly tidied up patchset. This has a number of advantages, including that it makes your code easier to review, easier to accept, and easier to merge.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/4/git-rebase-i
作者:[Dave Neary][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/dneary
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop.png?itok=pGfEfu2S (Hands programming)
[2]: https://opensource.com/sites/default/files/uploads/master-private-branches.png (Master branch vs. private branch)
[3]: https://opensource.com/sites/default/files/uploads/merge-commit-vs-rebase.png (Merge commits preserve history, and rebase rewrites history.)
[4]: https://opensource.com/sites/default/files/uploads/git-rebase-i.png (output of git rebase -i)

View File

@@ -0,0 +1,161 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Why strace doesn't work in Docker)
[#]: via: (https://jvns.ca/blog/2020/04/29/why-strace-doesnt-work-in-docker/)
[#]: author: (Julia Evans https://jvns.ca/)
Why strace doesn't work in Docker
======
While editing the capabilities page of the [how containers work][1] zine, I found myself trying to explain why `strace` doesnt work in a Docker container.
The problem here is if you run `strace` in a Docker container, this happens:
```
$ docker run -it ubuntu:18.04 /bin/bash
$ # ... install strace ...
[email protected]:/# strace ls
strace: ptrace(PTRACE_TRACEME, ...): Operation not permitted
```
strace works using the `ptrace` system call, so if `ptrace` isnt allowed, its definitely not gonna work! This is pretty easy to fix on my machine, this fixes it:
```
docker run --cap-add=SYS_PTRACE -it ubuntu:18.04 /bin/bash
```
But I wasnt interested in fixing it, I wanted to know why it happens. So why does strace not work, and why does `--cap-add=SYS_PTRACE` fix it?
### hypothesis 1: container processes are missing the `CAP_SYS_PTRACE` capability
I always thought the reason was that Docker container processes by default didnt have the `CAP_SYS_PTRACE` capability. This is consistent with it being fixed by `--cap-add=SYS_PTRACE`, right?
But this actually doesnt make sense for 2 reasons.
**Reason 1**: Experimentally, as a regular user, I can strace on any process run by my user. But if I check if my current process has the `CAP_SYS_PTRACE` capability, I dont:
```
$ getpcaps $$
Capabilities for `11589': =
```
**Reason 2**: `man capabilities` says this about `CAP_SYS_PTRACE`:
```
CAP_SYS_PTRACE
* Trace arbitrary processes using ptrace(2);
```
So the point of `CAP_SYS_PTRACE` is to let you ptrace **arbitrary** processes owned by any user, the way that root usually can. You shouldnt need it to just ptrace a regular process owned by your user.
And I tested this a third way I ran a Docker container with `docker run --cap-add=SYS_PTRACE -it ubuntu:18.04 /bin/bash`, dropped the `CAP_SYS_PTRACE` capability, and I could still strace processes even though I didnt have that capability anymore. What? Why?
### hypothesis 2: something about user namespaces???
My next (much less well-founded) hypothesis was something along the lines of “um, maybe the process is in a different user namespace and strace doesnt work because of… reasons?” This isnt really coherent but heres what happened when I looked into it.
Is the container process in a different user namespace? Well, in the container:
```
[email protected]:/# ls /proc/$$/ns/user -l
... /proc/1/ns/user -> 'user:[4026531837]'
```
On the host:
```
[email protected]:~$ ls /proc/$$/ns/user -l
... /proc/12177/ns/user -> 'user:[4026531837]'
```
Because the user namespace ID (`4026531837`) is the same, the root user in the container is the exact same user as the root user on the host. So theres definitely no reason it shouldnt be able to strace processes that it created!
This hypothesis doesnt make much sense but I hadnt realized that the root user in a Docker container is the same as the root user on the host, so I thought that was interesting.
### hypothesis 3: the ptrace system call is being blocked by a seccomp-bpf rule
I also knew that Docker uses seccomp-bpf to stop container processes from running a lot of system calls. And ptrace is in the [list of system calls blocked by Dockers default seccomp profile][2]! (actually the list of allowed system calls is a whitelist, so its just that ptrace is not in the default whitelist. But it comes out to the same thing.)
That easily explains why strace wouldnt work in a Docker container if the `ptrace` system call is totally blocked, then of course you cant call it at all and strace would fail.
Lets verify this hypothesis if we disable all seccomp rules, can we strace in a Docker container?
```
$ docker run --security-opt seccomp=unconfined -it ubuntu:18.04 /bin/bash
$ strace ls
execve("/bin/ls", ["ls"], 0x7ffc69a65580 /* 8 vars */) = 0
... it works fine ...
```
Yes! It works! Great. Mystery solved, except…
### why does `--cap-add=SYS_PTRACE` fix the problem?
What we still havent explained is: why does `--cap-add=SYS_PTRACE` would fix the problem?
The man page for `docker run` explains the `--cap-add` argument this way:
```
--cap-add=[]
Add Linux capabilities
```
That doesnt have anything to do with seccomp rules! Whats going on?
### lets look at the Docker source code.
When the documentation doesnt help, the only thing to do is go look at the source.
The nice thing about Go is, because dependencies are often vendored in a Go repository, you can just grep the repository to figure out where the code that does a thing is. So I cloned `github.com/moby/moby` and grepped for some things, like `rg CAP_SYS_PTRACE`.
Heres what I think is going on. In containerds seccomp implementation, in [contrib/seccomp/seccomp_default.go][3], theres a bunch of code that makes sure that if a process has a capability, then its also given access (through a seccomp rule) to use the system calls that go with that capability.
```
case "CAP_SYS_PTRACE":
s.Syscalls = append(s.Syscalls, specs.LinuxSyscall{
Names: []string{
"kcmp",
"process_vm_readv",
"process_vm_writev",
"ptrace",
},
Action: specs.ActAllow,
Args: []specs.LinuxSeccompArg{},
})
```
Theres some other code that seems to do something very similar in [profiles/seccomp/seccomp.go][4] in moby and the [default seccomp profile][5], so its possible that thats whats doing it instead.
So I think we have our answer!
### `--cap-add` in Docker does a little more than what it says
The upshot seems to be that `--cap-add` doesnt do exactly what it says it does in the man page, its more like `--cap-add-and-also-whitelist-some-extra-system-calls-if-required`. Which makes sense! If you have a capability like `CAP_SYS_PTRACE` which is supposed to let you use the `process_vm_readv` system call but that system call is blocked by a seccomp profile, thats not going to help you much!
So allowing the `process_vm_readv` and `ptrace` system calls when you give the container `CAP_SYS_PTRACE` seems like a reasonable choice.
### thats all!
This was a fun small thing to investigate, and I think its a nice example of how containers are made of lots of moving pieces that work together in not-completely-obvious ways.
--------------------------------------------------------------------------------
via: https://jvns.ca/blog/2020/04/29/why-strace-doesnt-work-in-docker/
作者:[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://wizardzines.com/zines/containers
[2]: https://docs.docker.com/engine/security/seccomp/
[3]: https://github.com/containerd/containerd/blob/4be98fa28b62e8a012491d655a4d6818ef87b080/contrib/seccomp/seccomp_default.go#L527-L537
[4]: https://github.com/moby/moby/blob/cc0dfb6e7b22ad120c60a9ce770ea15415767cf9/profiles/seccomp/seccomp.go#L126-L132
[5]: https://github.com/moby/moby/blob/master/profiles/seccomp/default.json#L723-L739

View File

@@ -0,0 +1,159 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Three Methods Boot CentOS/RHEL 7/8 Systems in Single User Mode)
[#]: via: (https://www.2daygeek.com/boot-centos-7-8-rhel-7-8-single-user-mode/)
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
Three Methods Boot CentOS/RHEL 7/8 Systems in Single User Mode
======
Single user mode, also referred to as maintenance mode, which allows a single super user to recover/repair system problems.
Generally, these problems cannot be solved in a multi-user environment. The system can boot but will not function properly or you will not be able to log in.
It uses `runlevel1.target` or `rescue.target` on **[Red Hat][1]** (RHEL) 7/8 based systems.
In this mode, the system mount all local file systems, but does not activate network interfaces.
It only enables certain services and minimal functionality to repair the system.
This method is mostly useful when you want to run fsck to fix corrupted file systems, or to reset a forgotten root password, or to fix a mount point issue on the system.
You can boot **[CentOS][2]**/**[RHEL][3]** 7/8 systems in single user mode using the below three methods.
* **Method-1:** Boot CentOS/RHEL 7/8 systems in single user mode by adding the “rd.break” parameter to the kernel
* **Method-2:** Boot CentOS/RHEL 7/8 systems in single user mode by replacing the “rhgb quiet” word with the “init=/bin/bash or init=/bin/sh” parameter in the kernel
* **Method-3:** Boot CentOS/RHEL 7/8 systems in single user mode by replacing the “ro” word with the “rw init=/sysroot/bin/sh” parameter in the kernel
### Method-1: Boot CentOS/RHEL 7/8 systems in single user mode by adding the “rd.break” parameter to the kernel
Reboot your system, on the GRUB2 boot screen, press the `"e"` key to edit the selected kernel. You need to select the first line, the first one is the latest kernel whereas you can select the different one if you would like to boot your system with the older kernel.
![][4]
Depending on your RHEL/CentOS version, find the word **“linux16”** or **“linux”**, press the “End” button on the keyboard, go to the end of the line, and add the keyword **“rd.break”** as shown below in the screenshot, then press **“Ctrl+x”** or **“F10”** to boot into single-user mode.
You need to find the word **`linux16`** for RHEL/CentOS 7 systems, while **`linux`** for RHEL/CentOS 8 systems.
![][4]
This change mount your root file system into **“read only (RO)”** mode. You can check this by running the command below. Also, the output below clearly shows that you are in **“Emergency Mode”**.
```
# mount | grep root
```
![][4]
To make changes to the **“sysroot”** file system you need to remount it with READ and WRITE (RW) mode.
```
# mount -o remount,rw /sysroot
```
Run the below command to change the environment, commonly known as “jailed directory” or “chroot jail”.
```
# chroot /sysroot
```
![][4]
Now, single-user mode is completely ready for use. Once you have fixed your problem to exit single user mode, perform the following steps.
CentOS/RHEL 7/8 uses SELinux by default, so create the following hidden file, which will automatically perform a relabel of all files on next boot.
```
# touch /.autorelabel
```
Finally, run the below command to restart the system. Alternatively, type “exit” command twice to restart your system.
```
# reboot -f
```
### Method-2: Boot CentOS/RHEL 7/8 systems in single user mode by replacing the “rhgb quiet” word with the “init=/bin/bash or init=/bin/sh” parameters in the kernel
Reboot your system, on the GRUB2 boot screen, press the `"e"` key to edit the selected kernel parameters.
![][4]
Find the word **“rhgb quiet”** and replace it with **“init=/bin/bash”** or **“init=/bin/sh”**, then press **“Ctrl+x”** or **“F10”** to boot in single user mode.
Screenshot for **`init=/bin/bash`**.
![][4]
Screenshot for **`init=/bin/sh`**.
![][4]
By default, this will mount your “/” partition in read-only (RO) mode, so you will need to remount the “/” file system with READ and WRITE (RW) mode to make changes.
```
# mount -o remount,rw /
```
![][4]
You can now perform any task that you want. When you are done, run the following command to enable SELinux relabeling on reboot.
```
# touch /.autorelabel
```
Finally reboot the system.
```
# exec /sbin/init 6
```
### Method-3: Boot CentOS/RHEL 7/8 systems in single user mode by replacing the “ro” word with the “rw init=/sysroot/bin/sh” parameter in the kernel
To interrupt the automatic boot, reboot your system and press any key on the GRUB2 splash screen.
This will display the list of kernels available on your system and select the latest kernel and press the **`"e"`** key to edit the selected kernel parameters.
Find the line that starts with the word **“linux”** or **“linux16”** and replace **“ro”** with **“rw init=/sysroot/bin/sh”**. When finished, press **“Ctrl+x”** or **“F10”** to boot in single user mode.
Change the environment to “chroot jail” by running the below command.
```
# chroot /sysroot
```
Make any necessary changes to the system. Once done, run the below command to enable SELinux relabeling on reboot.
```
# touch /.autorelabel
```
Finally reboot the system.
```
# reboot -f
```
--------------------------------------------------------------------------------
via: https://www.2daygeek.com/boot-centos-7-8-rhel-7-8-single-user-mode/
作者:[Magesh Maruthamuthu][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.2daygeek.com/author/magesh/
[b]: https://github.com/lujun9972
[1]: https://www.2daygeek.com/category/red-hat/
[2]: https://www.2daygeek.com/category/centos/
[3]: https://www.2daygeek.com/category/rhel/
[4]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7

View File

@@ -0,0 +1,197 @@
[#]: collector: (lujun9972)
[#]: translator: (robsean)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Configure SFTP Server with Chroot in Debian 10)
[#]: via: (https://www.linuxtechi.com/configure-sftp-chroot-debian10/)
[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/)
如何在 Debian 10 中使用 Chroot 配置 SFTP 服务
======
**SFTP** 代表安全文件传输协议 / SSH 文件传输协议它是最常用的一个方法用于通过ssh将文件从本地系统安全地传输到远程服务器反之亦然。sftp 的主要优点是,除 **openssh-server** 之外,我们不需要安装任何额外的软件包,在大多数的 Linux 发行版中openssh-server 软件包是默认安装的一部分。sftp 的另外一个好处是,我们可以允许用户使用 sftp ,而不允许使用 ssh 。
[![配置-sftp-debian10][1]][2]
当前 Debian 10 代号Buster已经发布在这篇文章中我们将演示如何在 Debian 10 系统中使用 Chroot Jail 类似的环境配置 sftp 。在这里Chroot Jail 类似环境意味着,用户不能超出各自的 home 目录,或者用户不能从各自的 home 目录更改目录。下面实验的详细情况:
* OS = Debian 10
* IP 地址 = 192.168.56.151
让我们跳转到 SFTP 配置步骤,
### 步骤:1) 为 sftp 使用 groupadd 命令创建一个组
打开终端,使用下面的 groupadd 命令创建一个名为的“**sftp_users**”组,
```
root@linuxtechi:~# groupadd sftp_users
```
### 步骤:2) 添加用户到组 sftp_users 并设置权限
假设你想创建新的用户,并且想添加该用户到 sftp_users 组中,那么运行下面的命令,
**语法:** # useradd -m -G sftp_users <user_name>
让我们假设用户名是 Jonathan
```
root@linuxtechi:~# useradd -m -G sftp_users jonathan
```
使用下面的 chpasswd 命令设置密码,
```
root@linuxtechi:~# echo "jonathan:<enter_password>" | chpasswd
```
假设你想添加现有的用户到 sftp_users 组中,那么运行下面的 usermod 命令,让我们假设已经存在的用户名称是 chris
```
root@linuxtechi:~# usermod -G sftp_users chris
```
现在设置用户所需的权限,
```
root@linuxtechi:~# chown root /home/jonathan /home/chris/
```
在各用户的 home 目录中都创建一个上传目录,并设置正确地所有权,
```
root@linuxtechi:~# mkdir /home/jonathan/upload
root@linuxtechi:~# mkdir /home/chris/upload
root@linuxtechi:~# chown jonathan /home/jonathan/upload
root@linuxtechi:~# chown chris /home/chris/upload
```
**注意:** 像 Jonathan 和 Chris 之类的用户可以从他们的本地系统上传文件和目录。
### 步骤:3) 编辑 sftp 配置文件 (/etc/ssh/sshd_config)
正如我们已经陈述的sftp 操作是通过 ssh 完成的,所以它的配置文件是 “**/etc/ssh/sshd_config**“, 在做任何更改前,我建议首先备份文件,然后再编辑该文件,接下来添加下面的内容,
```
root@linuxtechi:~# cp /etc/ssh/sshd_config /etc/ssh/sshd_config-org
root@linuxtechi:~# vim /etc/ssh/sshd_config
………
#Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem sftp internal-sftp
Match Group sftp_users
X11Forwarding no
AllowTcpForwarding no
ChrootDirectory %h
ForceCommand internal-sftp
…………
```
保存并退出文件。
为使上述更改生效,使用下面的 systemctl 命令来重新启动 ssh 服务
```
root@linuxtechi:~# systemctl restart sshd
```
在上面的 sshd_config 文件中,我们已经注释掉了以 “Subsystem”开头的行并添加了新的条目 “Subsystem sftp internal-sftp” 和新的行,像,
“**Match Group sftp_users”** > 它意味着如果用户是 sftp_users 组中的一员,那么将应用下面提到的规则到这个条目。
“**ChrootDierctory %h**” > 它意味着用户只能在他们自己各自的 home 目录中更改目录,而不能超出他们各自的 home 目录。或者换句话说,我们可以说用户是不允许更改目录的。他们将在他们的目录中获得 jai 类似环境,并且不能访问其他用户的目录和系统的目录。
“**ForceCommand internal-sftp**” > 它意味着用户仅被限制到 sftp 命令。
### 步骤:4) 测试和验证 sftp
登录到你的 sftp 服务器的同一个网络上的任何其它的 Linux 系统,然后通过我们在 sftp_users 组中映射的用户来尝试 ssh sftp 服务。
```
[root@linuxtechi ~]# ssh root@linuxtechi
root@linuxtechi's password:
Write failed: Broken pipe
[root@linuxtechi ~]# ssh root@linuxtechi
root@linuxtechi's password:
Write failed: Broken pipe
[root@linuxtechi ~]#
```
以上操作证实用户不允许 SSH ,现在使用下面的命令尝试 sftp
```
[root@linuxtechi ~]# sftp root@linuxtechi
root@linuxtechi's password:
Connected to 192.168.56.151.
sftp> ls -l
drwxr-xr-x 2 root 1001 4096 Sep 14 07:52 debian10-pkgs
-rw-r--r-- 1 root 1001 155 Sep 14 07:52 devops-actions.txt
drwxr-xr-x 2 1001 1002 4096 Sep 14 08:29 upload
```
让我们使用 sftp **get** 命令来尝试下载一个文件
```
sftp> get devops-actions.txt
Fetching /devops-actions.txt to devops-actions.txt
/devops-actions.txt 100% 155 0.2KB/s 00:00
sftp>
sftp> cd /etc
Couldn't stat remote file: No such file or directory
sftp> cd /root
Couldn't stat remote file: No such file or directory
sftp>
```
上面的输出证实我们能从我们的 sftp 服务器下载文件到本地机器,除此之外,我们也必需测试用户不能更改目录。
让我们在 **upload**”目录下尝试上传一个文件,
```
sftp> cd upload/
sftp> put metricbeat-7.3.1-amd64.deb
Uploading metricbeat-7.3.1-amd64.deb to /upload/metricbeat-7.3.1-amd64.deb
metricbeat-7.3.1-amd64.deb 100% 38MB 38.4MB/s 00:01
sftp> ls -l
-rw-r--r-- 1 1001 1002 40275654 Sep 14 09:18 metricbeat-7.3.1-amd64.deb
sftp>
```
这证实我们已经成功地从我们的本地系统上传一个文件到 sftp 服务中。
现在使用 winscp 工具来测试 SFTP 服务,输入 sftp 服务器 ip 地址和用户的凭证,
[![Winscp-sftp-debian10][1]][3]
在 Login 上单击,然后尝试下载和上传文件
[![下载-文件-winscp-debian10-sftp][1]][4]
现在,在 upload 文件夹中尝试上传文件,
[![使用-winscp-Debian10-sftp-上传-文件][1]][5]
上面的窗口证实上传是完好地工作的,这就是这篇文章的全部。如果这些步骤能帮助你在 Debian 10 中使用 chroot 环境配置 SFTP 服务器s那么请分享你的反馈和评论。
--------------------------------------------------------------------------------
via: https://www.linuxtechi.com/configure-sftp-chroot-debian10/
作者:[Pradeep Kumar][a]
选题:[lujun9972][b]
译者:[robsean](https://github.com/robsean)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.linuxtechi.com/author/pradeep/
[b]: https://github.com/lujun9972
[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
[2]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Configure-sftp-debian10.jpg
[3]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Winscp-sftp-debian10.jpg
[4]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Download-file-winscp-debian10-sftp.jpg
[5]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Upload-File-using-winscp-Debian10-sftp.jpg

View File

@@ -0,0 +1,107 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Create Stunning Pixel Art With Free and Open Source Editor Pixelorama)
[#]: via: (https://itsfoss.com/pixelorama/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
使用免费和开源编辑器 Pixelorama 创建令人惊叹的像素艺术
======
_**简介Pixelorama 是一个跨平台、免费和开源的 2D Sprite 编辑器。它在干净的用户界面中提供了创建像素艺术所有必要工具。**_
### Pixelorama开源 Sprite 编辑器
[Pixelorama][1] 是年轻游戏开发人员在 [Orama 互动][2]创建的工具。他们已经开发了一些 2D 游戏,其中一些使用了像素艺术。
虽然 Orama 主要投入游戏开发,但开发人员也在创建实用工具,帮助他们(和其他人)创建这些游戏。
免费开源的 Sprite 编辑器Pixelorama 是这样一个实用工具。它构建在 [Godot 引擎][3]之上,非常适合创作像素艺术。
![Pixelorama screenshot][4]
你在上面的截图中看到像素艺术了吗?它是使用 Pixelorama 创建的。此视频显示创建上面图像的延时视频。
### Pixelorama 的功能
以下是 Pixelorama 提供的主要功能:
* 多种工具,如铅笔,擦除,填充桶颜色选择器等
* 多层系统,你可以根据需要添加、删除、上下移动、克隆和合并尽可能多的层
* 支持 Spritesheets
* 导入图像并在 Pixelorama 中编辑它们
* 带有 [Onion Skinning][5] 的动画时间线
* 自定义画笔
* 以 Pixelorama 的自定义文件格式 .pxo 保存并打开你的项目
* 水平和垂直镜像绘图
* 用于图样创建的磁贴模式
* 拆分屏幕模式和迷你画布预览
* 使用鼠标滚轮缩放
* 无限撤消和重做
* 缩放、裁剪、翻转、旋转、颜色反转和去饱和图像
* 键盘快捷键
* 提供多种语言
* 支持 Linux、Windows 和 macOS
### 在 Linux 上安装 Pixelorama
Pixelorama 提供 Snap 应用,如果你使用的是 Ubuntu那么可以在软件中心找到它。
![Pixelorama is available in Ubuntu Software Center][6]
或者,如果你在 [Linux 发行版上启用了 Snap 支持][7],那么可以使用此命令安装它:
```
sudo snap install pixelorama
```
如果你不想使用 Snap不用担心。你可以从[他们的 GitHub 仓库]下载最新版本的 Pixelorama[解压 zip 文件][9],你会看到一个可执行文件。授予此文件执行权限,并双击它运行应用。
[下载 Pixelorama][10]
**总结**
![Pixelorama Welcome Screen][11]
在 Pixeloaram 的功能中,它说你可以导入图像并对其进行编辑。我想,这只是对某些类型的文件,因为当我尝试导入 PNG 或 JPEG 文件,程序崩溃了。
然而,我可以像一个 3 岁的孩子那样随意涂鸦并制作像素艺术。我并没有深入艺术,但我认为这是一个[在 Linux 上对数字艺术家有用的工具][12]。
我喜欢这样的想法:尽管是游戏开发人员,但他们创建的工具,可以帮助其他游戏开发人员和艺术家。这就是开源的精神。
如果你喜欢这个项目,并且会使用它,请考虑通过捐赠来支持他们。[FOSS 捐赠了][13] 25 美元,以感谢他们的努力。
[向 Pixelorama 捐赠(主要开发者的个人 Paypal 账户)][14]
你喜欢 Pixelorama 吗?你是否使用其他开源 Sprite 编辑器?请随时在评论栏分享你的观点。
--------------------------------------------------------------------------------
作者:[Abhishek Prakash][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/abhishek/
[b]: https://github.com/lujun9972
[1]: https://www.orama-interactive.com/pixelorama
[2]: https://www.orama-interactive.com/
[3]: https://godotengine.org/
[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/pixelorama-v6.jpg?ssl=1
[5]: https://en.wikipedia.org/wiki/Onion_skinning
[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/pixelorama-ubuntu-software-center.jpg?ssl=1
[7]: https://itsfoss.com/install-snap-linux/
[8]: https://github.com/Orama-Interactive/Pixelorama
[9]: https://itsfoss.com/unzip-linux/
[10]: https://github.com/Orama-Interactive/Pixelorama/releases
[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/pixelorama.jpg?ssl=1
[12]: https://itsfoss.com/best-linux-graphic-design-software/
[13]: https://itsfoss.com/donations-foss/
[14]: https://www.paypal.me/erevos