mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-21 02:10:11 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
dd63b574dc
@ -0,0 +1,100 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-12317-1.html)
|
||||
[#]: subject: (Using AppImage for Linux package management)
|
||||
[#]: via: (https://opensource.com/article/20/6/appimages)
|
||||
[#]: author: (David Clinton https://opensource.com/users/dbclinton)
|
||||
|
||||
使用 AppImage 进行 Linux 软件包管理
|
||||
======
|
||||
|
||||
> AppImage 在自足的环境中分发应用, 它适用于任何 Linux 发行版。
|
||||
|
||||

|
||||
|
||||
管理 Linux 机器(尤其是远程机器)的一个重要分就是管理和安装软件。当本地应用程序出现问题时,或者文件系统上的某些文件损坏需要修复时,你通常会希望推送更新,而不必走很多路坐在物理屏幕前。正如我在 Pluralsight 课程《[Linux 系统维护和故障排除][2]》中所解释的那样,许多问题当然可以通过 Bash 脚本解决,但是仍有很多情况下,除了老式的二进制文件外,没有其他选择。
|
||||
|
||||
想象一下,你的某些远程系统需要安装新的应用程序,这样使用这些计算机的团队成员就能够执行某些业务。能够利用 Debian 或 RPM 之类的主要 Linux 仓库系统的集成和自动化,可以使你的管理任务变得更加容易。
|
||||
|
||||
正如 Linus Torvalds 永不厌倦地提醒我们的那样,太多的 Linux 软件管理系统的问题是 [Linux 软件管理系统太多了][3]。多年来,应用开发甚至是 Linux 的采用都变得愈加复杂起来,因为你为了提供你的软件(比如,放到 Debian 仓库)而投入的所有时间和工作,对于你想让它们进入 RPM 系统并没有什么帮助,对于 SUSE 的 Zypper 管理器也一样,没有什么帮助。
|
||||
|
||||
解决软件孤岛问题的一种有前途的方案是分发具有自足环境的应用,它们可以在任何 Linux 发行版上运行。在这个年轻且不断发展的领域中,选择之一是 [AppImage][4]。
|
||||
|
||||
### 使用 AppImage
|
||||
|
||||
我全面投入到了 AppImage。就像我提到的其他软件包管理系统一样,如果你需要的话,有很多复杂的功能可以使用。但是,从本质上讲,AppImage 非常简单。AppImage 不像大多数其他包管理器一样通过仓库工作,它使用单个、独立的文件,可以直接发送或通过网站共享。
|
||||
|
||||
下面是个展示它的美妙之处的例子。当我在用 AppImage 时,我在一个技术论坛上看到了一个很老的讨论,它让我找到了一个同样久远且废弃的 GitHub 项目以及相关的 YAML 和配方文件。它们旨在自动构建准备生成 AppImage 包所需的相当复杂的基础架构。尽管该基础架构全部是在 5 年前的 Ubuntu 版本上构建的,但是当我将它们放在一起并运行 `appimagetool` 命令时,它创建了一个 AppImage 文件,它可在我当前的桌面上无缝运行。我不认为有很多有五年历史的 GitHub 复杂项目可以使用其他技术运行,而无需认真重做。
|
||||
|
||||
但是这里我我不会介绍这个案例。相反,我将用一个简单的 Hello World 程序向你展示它是如何工作的。首先,请确保本地已安装 AppStream 包。
|
||||
|
||||
对于基于 Debian 的系统,运行:
|
||||
|
||||
```
|
||||
$ sudo apt install appstream
|
||||
```
|
||||
|
||||
对于 RPM 系统,请使用:
|
||||
|
||||
```
|
||||
$ sudo dnf install appstream
|
||||
```
|
||||
|
||||
克隆[这篇文章][5]中提及的 Git 仓库,我会基于它示例:
|
||||
|
||||
```
|
||||
$ git clone <https://github.com/boolean-world/appimage-resources>
|
||||
$ cd appimage-resources
|
||||
$ ls hello-world-appimage
|
||||
```
|
||||
|
||||
接下来,使用 `cd` 进入 Git 新创建的目录。这里有两个目录。请使用 `hello-world-appimage`。另一个是更复杂的项目,你也应该考虑尝试一下。
|
||||
|
||||
Linux GUI 系统会读取 `helloworld.desktop` 文件来知道如何呈现桌面图标。事实证明,当前的这个文件会在以后给你带来点麻烦,因此请进行一些小修改:添加 `Categories=` 这行并为其赋予值 `GNOME`。不要忘记最后的分号:
|
||||
|
||||
|
||||
```
|
||||
$ nano hello-world-appimage/helloworld.desktop
|
||||
add Categories=GNOME;
|
||||
```
|
||||
|
||||
从 [AppImage GitHub 项目][6]下载 `appimagetool` 预编译的二进制文件。访问 GitHub 的原因之一:那里有很多出色的文档和资源。下载二进制文件后,使文件可执行,并将 `hello-world-appimage` 目录传给它。但是首先,你需要告诉它你想要的架构。由于某些原因,一个名字以 x86\_64 结尾的工具都不能自行确定是否该使用 x86\_64 来构建应用程序(我不知道这是怎么回事)。
|
||||
|
||||
```
|
||||
$ wget <https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage>
|
||||
$ chmod +x appimagetool-x86_64.AppImage
|
||||
$ ARCH=x86_64 ./appimagetool-x86_64.AppImage hello-world-appimage
|
||||
```
|
||||
|
||||
如果你没有看到任何错误消息,那么表示完成了,请运行:
|
||||
|
||||
```
|
||||
$ ls
|
||||
$ ./hello-world-appimage-x86_64.AppImage
|
||||
```
|
||||
|
||||
### 总结
|
||||
|
||||
AppImage 是软件包管理的非常有效的选择。当你探索它时,我想你会发现它是 Linux 发行版默认软件包系统的很好的替代品。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/6/appimages
|
||||
|
||||
作者:[David Clinton][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/dbclinton
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_gift_giveaway_box_520x292.png?itok=w1YQhNH1 (Gift box opens with colors coming out)
|
||||
[2]: https://pluralsight.pxf.io/VMKQj
|
||||
[3]: https://itsfoss.com/desktop-linux-torvalds/
|
||||
[4]: https://appimage.org/
|
||||
[5]: https://www.booleanworld.com/creating-linux-apps-run-anywhere-appimage/
|
||||
[6]: https://github.com/AppImage/AppImageKit/releases
|
@ -1,169 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Cockpit and the evolution of the Web User Interface)
|
||||
[#]: via: (https://fedoramagazine.org/cockpit-and-the-evolution-of-the-web-user-interface/)
|
||||
[#]: author: (Shaun Assam https://fedoramagazine.org/author/sassam/)
|
||||
|
||||
Cockpit and the evolution of the Web User Interface
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
Over 3 years ago the Fedora Magazine published an article entitled [Cockpit: an overview][2]. Since then, the interface has see some eye-catching changes. Today’s Cockpit is cleaner and the larger fonts makes better use of screen real-estate.
|
||||
|
||||
This article will go over some of the changes made to the UI. It will also explore some of the general tools available in the web interface to simplify those monotonous sysadmin tasks.
|
||||
|
||||
### Cockpit installation
|
||||
|
||||
Cockpit can be installed using the **dnf install cockpit** command. This provides a minimal setup providing the basic tools required to use the interface.
|
||||
|
||||
Another option is to install the Headless Management group. This will install additional packages used to extend the usability of Cockpit. It includes extensions for NetworkManager, software packages, disk, and SELinux management.
|
||||
|
||||
Run the following commands to enable the web service on boot and open the firewall port:
|
||||
|
||||
```
|
||||
$ sudo systemctl enable --now cockpit.socket
|
||||
Created symlink /etc/systemd/system/sockets.target.wants/cockpit.socket -> /usr/lib/systemd/system/cockpit.socket
|
||||
|
||||
$ sudo firewall-cmd --permanent --add-service cockpit
|
||||
success
|
||||
$ sudo firewall-cmd --reload
|
||||
success
|
||||
```
|
||||
|
||||
### Logging into the web interface
|
||||
|
||||
To access the web interface, open your favourite browser and enter the server’s domain name or IP in the address bar followed by the service port (9090). Because Cockpit uses HTTPS, the installation will create a self-signed certificate to encrypt passwords and other sensitive data. You can safely accept this certificate, or request a CA certificate from your sysadmin or a trusted source.
|
||||
|
||||
Once the certificate is accepted, the new and improved login screen will appear. Long-time users will notice the username and password fields have been moved to the top. In addition, the white background behind the credential fields immediately grabs the user’s attention.
|
||||
|
||||
![][3]
|
||||
|
||||
A feature added to the login screen since the previous article is logging in with **sudo** privileges — if your account is a member of the wheel group. Check the box beside _Reuse my password for privileged tasks_ to elevate your rights.
|
||||
|
||||
Another edition to the login screen is the option to connect to remote servers also running the Cockpit web service. Click _Other Options_ and enter the host name or IP address of the remote machine to manage it from your local browser.
|
||||
|
||||
### Home view
|
||||
|
||||
Right off the bat we get a basic overview of common system information. This includes the make and model of the machine, the operating system, if the system is up-to-date, and more.
|
||||
|
||||
![][4]
|
||||
|
||||
Clicking the make/model of the system displays hardware information such as the BIOS/Firmware. It also includes details about the components as seen with **lspci**.
|
||||
|
||||
![][5]
|
||||
|
||||
Clicking on any of the options to the right will display the details of that device. For example, the _% of CPU cores_ option reveals details on how much is used by the user and the kernel. In addition, the _Memory & Swap_ graph displays how much of the system’s memory is used, how much is cached, and how much of the swap partition active. The _Disk I/O_ and _Network Traffic_ graphs are linked to the Storage and Networking sections of Cockpit. These topics will be revisited in an upcoming article that explores the system tools in detail.
|
||||
|
||||
#### Secure Shell Keys and authentication
|
||||
|
||||
Because security is a key factor for sysadmins, Cockpit now has the option to view the machine’s MD5 and SHA256 key fingerprints. Clicking the **Show fingerprints** options reveals the server’s ECDSA, ED25519, and RSA fingerprint keys.
|
||||
|
||||
![][6]
|
||||
|
||||
You can also add your own keys by clicking on your username in the top-right corner and selecting **Authentication**. Click on **Add keys** to validate the machine on other systems. You can also revoke your privileges in the Cockpit web service by clicking on the **X** button to the right.
|
||||
|
||||
![][7]
|
||||
|
||||
#### Changing the host name and joining a domain
|
||||
|
||||
Changing the host name is a one-click solution from the home page. Click the host name currently displayed, and enter the new name in the _Change Host Name_ box. One of the latest features is the option to provide a _Pretty name_.
|
||||
|
||||
Another feature added to Cockpit is the ability to connect to a directory server. Click _Join a domain_ and a pop-up will appear requesting the domain address or name, organization unit (optional), and the domain admin’s credentials. The Domain Membership group provides all the packages required to join an LDAP server including FreeIPA, and the popular Active Directory.
|
||||
|
||||
To opt-out, click on the domain name followed by _Leave Domain_. A warning will appear explaining the changes that will occur once the system is no longer on the domain. To confirm click the red _Leave Domain_ button.
|
||||
|
||||
![][8]
|
||||
|
||||
#### Configuring NTP and system date and time
|
||||
|
||||
Using the command-line and editing config files definitely takes the cake when it comes to maximum tweaking. However, there are times when something more straightforward would suffice. With Cockpit, you have the option to set the system’s date and time manually or automatically using NTP. Once synchronized, the information icon on the right turns from red to blue. The icon will disappear if you manually set the date and time.
|
||||
|
||||
To change the timezone, type the continent and a list of cities will populate beneath.
|
||||
|
||||
![][9]
|
||||
|
||||
#### Shutting down and restarting
|
||||
|
||||
You can easily shutdown and restart the server right from home screen in Cockpit. You can also delay the shutdown/reboot and send a message to warn users.
|
||||
|
||||
![][10]
|
||||
|
||||
#### Configuring the performance profile
|
||||
|
||||
If the _tuned_ and _tuned-utils_ packages are installed, performance profiles can be changed from the main screen. By default it is set to a recommended profile. However, if the purpose of the server requires more performance, we can change the profile from Cockpit to suit those needs.
|
||||
|
||||
![][11]
|
||||
|
||||
### Terminal web console
|
||||
|
||||
A Linux sysadmin’s toolbox would be useless without access to a terminal. This allows admins to fine-tune the server beyond what’s available in Cockpit. With the addition of themes, admins can quickly adjust the text and background colours to suit their preference.
|
||||
|
||||
Also, if you type **exit** by mistake, click the _Reset_ button in the top-right corner*.* This will provide a fresh screen with a flashing cursor.
|
||||
|
||||
![][12]
|
||||
|
||||
### Adding a remote server and the Dashboard overlay
|
||||
|
||||
The Headless Management group includes the Dashboard module (**cockpit-dashboard**). This provides an overview the of the CPU, memory, network, and disk performance in a real-time graph. Remote servers can also be added and managed through the same interface.
|
||||
|
||||
For example, to add a remote computer in Dashboard, click the **+** button. Enter the name or IP address of the server and select the colour of your choice. This helps to differentiate the stats of the servers in the graph. To switch between servers, click on the host name (as seen in the screen-cast below). To remove a server from the list, click the check-mark icon, then click the red trash icon. The example below demonstrates how Cockpit manages a remote machine named _server02.local.lan_.
|
||||
|
||||
![][13]
|
||||
|
||||
### Documentation and finding help
|
||||
|
||||
As always, the _man_ pages are a great place to find documentation. A simple search in the command-line results with pages pertaining to different aspects of using and configuring the web service.
|
||||
|
||||
```
|
||||
$ man -k cockpit
|
||||
cockpit (1) - Cockpit
|
||||
cockpit-bridge (1) - Cockpit Host Bridge
|
||||
cockpit-desktop (1) - Cockpit Desktop integration
|
||||
cockpit-ws (8) - Cockpit web service
|
||||
cockpit.conf (5) - Cockpit configuration file
|
||||
```
|
||||
|
||||
The Fedora repository also has a package called **cockpit-doc**. The package’s description explains it best:
|
||||
|
||||
> The Cockpit Deployment and Developer Guide shows sysadmins how to deploy Cockpit on their machines as well as helps developers who want to embed or extend Cockpit.
|
||||
|
||||
For more documentation visit <https://cockpit-project.org/external/source/HACKING>
|
||||
|
||||
### Conclusion
|
||||
|
||||
This article only touches upon some of the main functions available in Cockpit. Managing storage devices, networking, user account, and software control will be covered in an upcoming article. In addition, optional extensions such as the 389 directory service, and the _cockpit-ostree_ module used to handle packages in Fedora Silverblue.
|
||||
|
||||
The options continue to grow as more users adopt Cockpit. The interface is ideal for admins who want a light-weight interface to control their server(s).
|
||||
|
||||
What do you think about Cockpit? Share your experience and ideas in the comments below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/cockpit-and-the-evolution-of-the-web-user-interface/
|
||||
|
||||
作者:[Shaun Assam][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/sassam/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-816x345.jpg
|
||||
[2]: https://fedoramagazine.org/cockpit-overview/
|
||||
[3]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-login-screen.png
|
||||
[4]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-home-screen.png
|
||||
[5]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-system-info.gif
|
||||
[6]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-ssh-key-fingerprints.png
|
||||
[7]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-authentication.png
|
||||
[8]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-hostname-domain.gif
|
||||
[9]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-date-time.png
|
||||
[10]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-power-options.gif
|
||||
[11]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-tuned.gif
|
||||
[12]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-terminal.gif
|
||||
[13]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-add-remote-servers.gif
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (HankChow)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -1,144 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Using pandas to plot data in Python)
|
||||
[#]: via: (https://opensource.com/article/20/6/pandas-python)
|
||||
[#]: author: (Shaun Taylor-Morgan https://opensource.com/users/shaun-taylor-morgan)
|
||||
|
||||
Using pandas to plot data in Python
|
||||
======
|
||||
Pandas is a hugely popular Python data manipulation library. Learn how
|
||||
to use its API to plot data.
|
||||
![Two pandas sitting in bamboo][1]
|
||||
|
||||
In this series of articles on Python-based plotting libraries, we're going to have a conceptual look at plots using pandas, the hugely popular Python data manipulation library. Pandas is a standard tool in Python for scalably transforming data, and it has also become a popular way to [import and export from CSV and Excel formats][2].
|
||||
|
||||
On top of all that, it also contains a very nice plotting API. This is extremely convenient—you already have your data in a pandas DataFrame, so why not use the same library to plot it?
|
||||
|
||||
In this series, we'll be making the same multi-bar plot in each library so we can compare how they work. The data we'll use is UK election results from 1966 to 2020:
|
||||
|
||||
![Matplotlib UK election results][3]
|
||||
|
||||
### Data that plots itself
|
||||
|
||||
Before we go further, note that you may need to tune your Python environment to get this code to run, including the following.
|
||||
|
||||
* Running a recent version of Python (instructions for [Linux][4], [Mac][5], and [Windows][6])
|
||||
* Verify you're running a version of Python that works with these libraries
|
||||
|
||||
|
||||
|
||||
The data is available online and can be imported using pandas:
|
||||
|
||||
|
||||
```
|
||||
import pandas as pd
|
||||
df = pd.read_csv('<https://anvil.works/blog/img/plotting-in-python/uk-election-results.csv>')
|
||||
```
|
||||
|
||||
Now we're ready to go. We've seen some impressively simple APIs in this series of articles, but pandas has to take the crown.
|
||||
|
||||
To plot a bar plot with a group for each party and `year` on the x-axis, I simply need to do this:
|
||||
|
||||
|
||||
```
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
ax = df.plot.bar(x='year')
|
||||
|
||||
plt.show()
|
||||
```
|
||||
|
||||
Four lines—definitely the tersest multi-bar plot we've created in this series.
|
||||
|
||||
I’m using my data in [wide form][7], meaning there’s one column per political party:
|
||||
|
||||
|
||||
```
|
||||
year conservative labour liberal others
|
||||
0 1966 253 364 12 1
|
||||
1 1970 330 287 6 7
|
||||
2 Feb 1974 297 301 14 18
|
||||
.. ... ... ... ... ...
|
||||
12 2015 330 232 8 80
|
||||
13 2017 317 262 12 59
|
||||
14 2019 365 202 11 72
|
||||
```
|
||||
|
||||
This means pandas automatically knows how I want my bars grouped, and if I wanted them grouped differently, pandas makes it easy to [restructure my DataFrame][8].
|
||||
|
||||
As with [Seaborn][9], pandas' plotting feature is an abstraction on top of Matplotlib, which is why you call Matplotlib's `plt.show()` function to actually produce the plot.
|
||||
|
||||
Here's what it looks like:
|
||||
|
||||
![pandas unstyled data plot][10]
|
||||
|
||||
Looks great, especially considering how easy it was! Let's style it to look just like the [Matplotlib][11] example.
|
||||
|
||||
#### Styling it
|
||||
|
||||
We can easily tweak the styling by accessing the underlying Matplotlib methods.
|
||||
|
||||
Firstly, we can color our bars by passing a Matplotlib colormap into the plotting function:
|
||||
|
||||
|
||||
```
|
||||
from matplotlib.colors import ListedColormap
|
||||
cmap = ListedColormap(['#0343df', '#e50000', '#ffff14', '#929591'])
|
||||
ax = df.plot.bar(x='year', colormap=cmap)
|
||||
```
|
||||
|
||||
And we can set up axis labels and titles using the return value of the plotting function—it's simply a [Matplotlib `Axis` object][12].
|
||||
|
||||
|
||||
```
|
||||
ax.set_xlabel(None)
|
||||
ax.set_ylabel('Seats')
|
||||
ax.set_title('UK election results')
|
||||
```
|
||||
|
||||
Here's what it looks like now:
|
||||
|
||||
![pandas styled plot][13]
|
||||
|
||||
That's pretty much identical to the Matplotlib version shown above but in 8 lines of code rather than 16! My inner [code golfer][14] is very pleased.
|
||||
|
||||
### Abstractions must be escapable
|
||||
|
||||
As with Seaborn, the ability to drop down and access Matplotlib APIs to do the detailed tweaking was really helpful. This is a great example of giving an abstraction [escape hatches][15] to make it powerful as well as simple.
|
||||
|
||||
* * *
|
||||
|
||||
_This article is based on [How to make plots using Pandas][16] on Anvil's blog and is reused with permission._
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/6/pandas-python
|
||||
|
||||
作者:[Shaun Taylor-Morgan][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/shaun-taylor-morgan
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/panda.png?itok=0lJlct7O (Two pandas sitting in bamboo)
|
||||
[2]: https://anvil.works/docs/data-tables/csv-and-excel
|
||||
[3]: https://opensource.com/sites/default/files/uploads/matplotlib_2.png (Matplotlib UK election results)
|
||||
[4]: https://opensource.com/article/20/4/install-python-linux
|
||||
[5]: https://opensource.com/article/19/5/python-3-default-mac
|
||||
[6]: https://opensource.com/article/19/8/how-install-python-windows
|
||||
[7]: https://anvil.works/blog/tidy-data
|
||||
[8]: https://anvil.works/blog/tidy-data#converting-between-long-and-wide-data-in-pandas
|
||||
[9]: https://anvil.works/blog/plotting-in-seaborn
|
||||
[10]: https://opensource.com/sites/default/files/uploads/pandas-unstyled.png (pandas unstyled data plot)
|
||||
[11]: https://opensource.com/article/20/5/matplotlib-python
|
||||
[12]: https://matplotlib.org/api/axis_api.html#axis-objects
|
||||
[13]: https://opensource.com/sites/default/files/uploads/pandas_3.png (pandas styled plot)
|
||||
[14]: https://en.wikipedia.org/wiki/Code_golf
|
||||
[15]: https://anvil.works/blog/escape-hatches-and-ejector-seats
|
||||
[16]: https://anvil.works/blog/plotting-in-pandas
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (lxbwolf)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
159
sources/tech/20200615 How to use Bash history commands.md
Normal file
159
sources/tech/20200615 How to use Bash history commands.md
Normal file
@ -0,0 +1,159 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to use Bash history commands)
|
||||
[#]: via: (https://opensource.com/article/20/6/bash-history-commands)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
How to use Bash history commands
|
||||
======
|
||||
Bash's history command surpasses all other Linux shell history
|
||||
interfaces in the number of features it offers.
|
||||
![Person typing on a 1980's computer][1]
|
||||
|
||||
Bash has a rich history. That is, it's an old shell with an even older ancestor (the Bourne shell), but it also has a great `history` command that surpasses all other shell history interfaces based on its number of features. The [Bash][2] version of `history` allows for reverse searches, quick recall, rewriting history, and more.
|
||||
|
||||
The `history` command isn't like many other commands. You might be used to commands being executable files placed in common system-level locations like `/usr/bin`, `/usr/local/bin`, or `~/bin`. The built-in `history` command isn't in your `PATH` and has no physical location:
|
||||
|
||||
|
||||
```
|
||||
$ which history
|
||||
|
||||
which: no history in [PATH]
|
||||
```
|
||||
|
||||
Instead, `history` is a built-in function of the shell itself:
|
||||
|
||||
|
||||
```
|
||||
$ type history
|
||||
history is a shell builtin
|
||||
$ help history
|
||||
history: history [-c] [-d offset] [n] or
|
||||
history -anrw [filename] or
|
||||
history -ps arg [arg...]
|
||||
|
||||
Display or manipulate the history list.
|
||||
[...]
|
||||
```
|
||||
|
||||
For that reason, the history function in each shell is unique, so what you use in Bash may not work in Tcsh or Fish or Dash, and what you use in those may not work in Bash. In some cases, knowing what Bash can do may inspire users of other shells to create interesting hacks to clone Bash behavior, and it may unlock Bash features that you never knew existed.
|
||||
|
||||
### View your Bash history
|
||||
|
||||
The most basic and frequent use of the `history` command is to view a history of your shell session:
|
||||
|
||||
|
||||
```
|
||||
$ echo "hello"
|
||||
hello
|
||||
$ echo "world"
|
||||
world
|
||||
$ history
|
||||
1 echo "hello"
|
||||
2 echo "world"
|
||||
3 history
|
||||
```
|
||||
|
||||
### Event designators
|
||||
|
||||
Event designators search through your history by event. An _event_ in this context is a command logged in your history, delineated by a newline character. In other words, it's one line, marked by an index number for reference.
|
||||
|
||||
Event designators mostly start with an exclamation point, sometimes also called a _bang_ (`!`).
|
||||
|
||||
To rerun a command from your history, use the exclamation point followed immediately (no spaces) by the index number of the command you want. For instance, assume line 1 contains the command `echo "hello"`, and you want to run it again:
|
||||
|
||||
|
||||
```
|
||||
$ !1
|
||||
echo "hello"
|
||||
hello
|
||||
```
|
||||
|
||||
You can use relative positioning by providing a negative number of lines back from your current position in history. For example, to go back three entries in history:
|
||||
|
||||
|
||||
```
|
||||
$ echo "foo"
|
||||
foo
|
||||
$ echo "bar"
|
||||
bar
|
||||
$ echo "baz"
|
||||
baz
|
||||
$ !-3
|
||||
echo "foo"
|
||||
foo
|
||||
```
|
||||
|
||||
If you're just going back one line, you can use the shorthand `!!` instead of `!-1`. That's a savings of one whole keystroke!
|
||||
|
||||
|
||||
```
|
||||
$ echo "foo"
|
||||
$ !!
|
||||
echo "foo"
|
||||
foo
|
||||
```
|
||||
|
||||
### String search
|
||||
|
||||
You can also search for a specific string through the entries, in reverse, for a command to run. To search for a command _starting_ with a specific string, use an exclamation point followed immediately (no space) by the string you want to search for:
|
||||
|
||||
|
||||
```
|
||||
$ echo "foo"
|
||||
$ true
|
||||
$ false
|
||||
$ !echo
|
||||
echo "foo"
|
||||
foo
|
||||
```
|
||||
|
||||
You can also search for a command containing a string in any position (not just at the start). To do that, use `!` plus the string you're searching for, as usual, but surround the string with question marks on either end. You may omit the trailing question mark if you know that the string is immediately followed by a newline character (meaning it's the last thing you typed before you pressed **Return**):
|
||||
|
||||
|
||||
```
|
||||
$ echo "foo"
|
||||
$ true
|
||||
$ false
|
||||
$ !?foo?
|
||||
echo "foo"
|
||||
foo
|
||||
```
|
||||
|
||||
### String substitution
|
||||
|
||||
Similar to searching for strings at the start of a line, you can search for a string and replace it with a new string, changing the command:
|
||||
|
||||
|
||||
```
|
||||
$ echo "hello"
|
||||
hello
|
||||
$ echo "world"
|
||||
world
|
||||
$ ^hello^foo
|
||||
echo "foo"
|
||||
foo
|
||||
```
|
||||
|
||||
### Make history useful
|
||||
|
||||
In Bash, the history command is capable of much more than what's been covered here, but this is a good start for getting used to _using_ your history instead of just treating it as a reference. Use the `history` command often, and see how much you can do without having to type commands. You might surprise yourself!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/6/bash-history-commands
|
||||
|
||||
作者:[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/1980s-computer-yearbook.png?itok=eGOYEKK- (Person typing on a 1980's computer)
|
||||
[2]: https://opensource.com/resources/what-bash
|
@ -0,0 +1,231 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Introduction to Homebrew: the painless way to install anything on a Mac)
|
||||
[#]: via: (https://opensource.com/article/20/6/homebrew-mac)
|
||||
[#]: author: (Matthew Broberg https://opensource.com/users/mbbroberg)
|
||||
|
||||
Introduction to Homebrew: the painless way to install anything on a Mac
|
||||
======
|
||||
The Homebrew package manager makes it easy to install and update
|
||||
applications and utilities on a Mac.
|
||||
![Gift box opens with colors coming out][1]
|
||||
|
||||
In my quest to "automate all the things," I have been on a journey to manage my Mac laptop as the code it inherently is. Instead of pointing and clicking to manually manage my applications and utilities, I prefer to use package management software to install, update, and remove unneeded software.
|
||||
|
||||
That's a challenge for Mac users. One place where the Mac operating system, macOS, has always been behind Linux is in package management. There is no default package manager for Mac users, while Linux users have many options—from the familiar `yum` and `apt` to the modern choice of [Flatpak][2]. But what about us?
|
||||
|
||||
This is where [Homebrew][3] comes in. Homebrew fills the void as the de facto package manager for macOS (and as another option for Linux). It provides an incredibly smooth and straightforward experience for anyone familiar with the command line, and it's a good way to learn the command line if you're new to it.
|
||||
|
||||
If you're on a Mac and don't already have Homebrew, you can install it with:
|
||||
|
||||
|
||||
```
|
||||
`$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"`
|
||||
```
|
||||
|
||||
This command executes the installer script provided by the Homebrew team. If you prefer to be more cautious, you can `curl` the file, then run it manually after reviewing it:
|
||||
|
||||
|
||||
```
|
||||
$ curl -fsSL <https://raw.githubusercontent.com/Homebrew/install/master/install.sh> \--output homebrew_installer.sh
|
||||
$ more homebrew_installer.sh # review the script until you feel comfortable
|
||||
$ bash homebrew_installer.sh
|
||||
```
|
||||
|
||||
### Manage your command-line utilities with brew
|
||||
|
||||
Homebrew boasts that it "installs the stuff you need that Apple (or your Linux system) didn't" install by default. Installation happens with the `brew` command, which gives us access to thousands of command-line utilities, but not more complex applications.
|
||||
|
||||
For us nerds, the utilities that fit into "the stuff you need" category include the handy `tree` command that shows directory structures and `pyenv`, which I use to [manage multiple versions of Python][4].
|
||||
|
||||
You can see all the "formulae" that are available from Homebrew using the `search` command, and I use the `wc` command shows how many formulae there are:
|
||||
|
||||
|
||||
```
|
||||
# -l counts the number of lines
|
||||
$ brew search | wc -l
|
||||
5013
|
||||
```
|
||||
|
||||
There are over 5,000 formulae, which is an incredible amount of software. So it's best to have an idea of what you want before searching that huge list. Thankfully, it is easy enough to browse. Formulae are codified and centralized into the core repositories that are split by operating system (Mac in [Homebrew Core][5] and Linux in [Linux Core][6]). They are also available through the Homebrew API and [listed on the website][7].
|
||||
|
||||
Word of mouth is another great method to find utilitites. With that in mind, here are some of my favorites if you're looking for inspiration:
|
||||
|
||||
* `pyenv`, `rbenv`, and `nodenv` to manage Python, Ruby, and Node.js versions (respectively)
|
||||
* `imagemagick` for scriptable image edits
|
||||
* `pandoc` for scriptable document conversions (I often switch from .docx to .md or .html)
|
||||
* `hub` for a [better Git experience][8] for GitHub users
|
||||
* `tldr` for examples of how to use a command-line utility
|
||||
|
||||
|
||||
|
||||
As an example, take a look at [tldr pages][9], a user-friendly alternative to scrolling through an application's man pages. You can confirm it's available by running `search` again:
|
||||
|
||||
|
||||
```
|
||||
$ brew search tldr
|
||||
==> Formulae
|
||||
tldr ✔
|
||||
```
|
||||
|
||||
Success! The checkmark lets you know it is available. Now you can install it:
|
||||
|
||||
|
||||
```
|
||||
$ brew install tldr
|
||||
==> Downloading <https://homebrew.bintray.com/bottles/tldr-1.3.0\_2.catalina.bottle.tar.gz>
|
||||
Already downloaded: /Users/mbbroberg/Library/Caches/Homebrew/downloads/901bc14594a9283e9ab20aec942dc5a9a2befb7e96e1b0fcccb4e3257918813c--tldr-1.3.0_2.catalina.bottle.tar.gz
|
||||
==> Installing tldr
|
||||
==> Pouring tldr-1.3.0_2.catalina.bottle.tar.gz
|
||||
🍺 /usr/local/Cellar/tldr/1.3.0_2: 6 files, 35.5KB
|
||||
```
|
||||
|
||||
Homebrew, thankfully, prebuilds the binaries, so you don't have to build from source code on your local machine. That saves a lot of time and CPU fan noise. Another thing I appreciate about Homebrew is that you can appreciate this feature without understanding exactly what it means.
|
||||
|
||||
But if you're into it, it can be fun to look at the complexity. Run `info` on `tldr`, and you can see all the dependency management, the source code, and even public analytics:
|
||||
|
||||
|
||||
```
|
||||
$ brew info tldr
|
||||
tldr: stable 1.3.0 (bottled), HEAD
|
||||
Simplified and community-driven man pages
|
||||
<https://tldr.sh/>
|
||||
Conflicts with:
|
||||
tealdeer (because both install `tldr` binaries)
|
||||
/usr/local/Cellar/tldr/1.3.0_2 (6 files, 35.5KB) *
|
||||
Poured from bottle on 2020-05-20 at 15:12:12
|
||||
From: <https://github.com/Homebrew/homebrew-core/blob/master/Formula/tldr.rb>
|
||||
==> Dependencies
|
||||
Build: pkg-config ✔
|
||||
Required: libzip ✔
|
||||
==> Options
|
||||
\--HEAD
|
||||
Install HEAD version
|
||||
==> Analytics
|
||||
install: 2,811 (30 days), 7,875 (90 days), 27,105 (365 days)
|
||||
install-on-request: 2,806 (30 days), 7,860 (90 days), 27,080 (365 days)
|
||||
build-error: 0 (30 days)
|
||||
```
|
||||
|
||||
Finally, as in any good package manager, Homebrew's `brew uninstall` is available to quickly clean and remove unused utilities.
|
||||
|
||||
### Manage your applications with brew casks
|
||||
|
||||
Command-line utilities are a blast, but what about full-blown applications? Homebrew keeps its standard commands simple and installs only single-file applications through its default `brew` command-line interface. Applications don't fit that structure. They have a more complex directory hierarchy that is much more than a single binary.
|
||||
|
||||
Fortunately, Homebrew on Mac includes a subcommand called "casks" for more complex multi-directory structures. What's especially nice is that `cask` uses a similar command structure to the standard `brew` commands, so you can use similar `search`, `install`, and `info` steps:
|
||||
|
||||
|
||||
```
|
||||
brew search --cask | wc -l
|
||||
4772
|
||||
```
|
||||
|
||||
Wow, there are nearly 5,000 more applications to browse, which are easier to peruse on [Homebrew's website][10].
|
||||
|
||||
I'll walk you through `cask` with one of my new favorite applications: [Meld][11] (which I [read about on Opensource.com][12]). It's a feature-rich editor that helps manage merge conflicts. There is a download on its website, and I could run through the installer and drag-and-drop it into my Applications folder, but I don't do that anymore. I use Homebrew.
|
||||
|
||||
First, I confirm it's available through a slightly different syntax:
|
||||
|
||||
|
||||
```
|
||||
$ brew search --casks meld
|
||||
==> Casks
|
||||
meld
|
||||
```
|
||||
|
||||
Then I use the `cask` sub-command to install it:
|
||||
|
||||
|
||||
```
|
||||
$ brew cask install meld
|
||||
==> Downloading <https://github.com/yousseb/meld/releases/download/osx-19/meldmerge.dmg>
|
||||
==> Downloading from <https://github-production-release-asset-2e65be.s3.amazonaws.com/28624006/66cb25>
|
||||
######################################################################## 100.0%
|
||||
==> Verifying SHA-256 checksum for Cask 'meld'.
|
||||
==> Installing Cask meld
|
||||
==> Moving App 'Meld.app' to '/Applications/Meld.app'.
|
||||
==> Linking Binary 'meld.wrapper.sh' to '/usr/local/bin/meld'.
|
||||
🍺 meld was successfully installed!
|
||||
```
|
||||
|
||||
Homebrew not only installs the application but also makes it available in my current path under `/usr/local/bin/`. Now I can run `meld` from the command line or launch the application from the Applications folder.
|
||||
|
||||
### Update everything with brew upgrade
|
||||
|
||||
The main reason I consistently use a package manager is so that I can consistently upgrade my software to avoid known security bugs and ensure I always have the latest features. If I install everything by hand, I have to keep an eye on each tool and application to know whether it has an auto-updater and, if not, pull down the latest releases myself.
|
||||
|
||||
Upgrades are where great package management shines. Since I don't have any special version requirements, I run only one command to update everything smoothly:
|
||||
|
||||
|
||||
```
|
||||
$ brew upgrade
|
||||
==> Upgrading 6 outdated packages:
|
||||
helm 3.2.1 -> 3.2.2
|
||||
python@3.8 3.8.2_4 -> 3.8.3
|
||||
ipython 7.14.0 -> 7.15.0
|
||||
go 1.14.2_1 -> 1.14.3
|
||||
libzip 1.6.1 -> 1.6.1_1
|
||||
sqlite 3.31.1 -> 3.32.1
|
||||
```
|
||||
|
||||
If you have more complex needs or want to keep an eye on upgrades before installing them, there are plenty of feature flags available. For instance, `-n` offers a "dry run" that lists available upgrades without installing them. You can also ["pin"][13] an application version to prevent upgrades.
|
||||
|
||||
### Back up your installation
|
||||
|
||||
The command-line utility and application management jumps to a whole new level when tools allow you to back up your installation like any other [dotfile in version control][14]. Homebrew has that kind of functionality available to use under the `dump` subcommand. It generates a `Brewfile`, which is a reusable list of all the currently installed tools. To generate one from your installation, go into your preferred folder and run:
|
||||
|
||||
|
||||
```
|
||||
$ cd ~/Development/dotfiles # This is my dotfile folder
|
||||
$ brew bundle dump
|
||||
```
|
||||
|
||||
When I change machines and want to install the same applications with Homebrew, I go to the folder with the Brewfile and run:
|
||||
|
||||
|
||||
```
|
||||
`$ brew bundle`
|
||||
```
|
||||
|
||||
It will install all the listed formulae and casks on my new machine.
|
||||
|
||||
### Go to Homebrew for package management
|
||||
|
||||
Homebrew is my go-to manager for command-line utilities and applications. It keeps me organized and up-to-date, and its design is a beautiful balance between ease of use and depth of functionality. Homebrew minimizes package management details to only what you need to know, and most users will benefit from that.
|
||||
|
||||
If you're already comfortable with Linux package managers, you may think Homebrew is too simple, but don't mistake Homebrew's ease of use for lack of features. Looking a little deeper reveals many advanced options that go far beyond what I showed you here. Adding `-h` to any `brew` subcommand shows the rich features available to upgrade, remove, troubleshoot, and even contribute new formulas using templates.
|
||||
|
||||
Overall, Homebrew makes being a command-line wielding Mac user a joy. In addition, it's open source, so you can [contribute back to the code][15] if you're so inclined. Give it a try, and let me know what you think by leaving a comment below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/6/homebrew-mac
|
||||
|
||||
作者:[Matthew Broberg][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/mbbroberg
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_gift_giveaway_box_520x292.png?itok=w1YQhNH1 (Gift box opens with colors coming out)
|
||||
[2]: https://opensource.com/article/19/10/how-build-flatpak-packaging
|
||||
[3]: https://brew.sh
|
||||
[4]: https://opensource.com/article/20/4/pyenv
|
||||
[5]: https://github.com/Homebrew/homebrew-core
|
||||
[6]: https://github.com/Homebrew/linuxbrew-core
|
||||
[7]: https://formulae.brew.sh/formula/
|
||||
[8]: https://opensource.com/article/20/3/github-hub
|
||||
[9]: https://github.com/tldr-pages/tldr
|
||||
[10]: https://formulae.brew.sh/cask/
|
||||
[11]: https://meldmerge.org/
|
||||
[12]: https://opensource.com/article/20/3/meld
|
||||
[13]: https://docs.brew.sh/FAQ#how-do-i-stop-certain-formulae-from-being-updated
|
||||
[14]: https://opensource.com/article/19/3/move-your-dotfiles-version-control
|
||||
[15]: https://github.com/Homebrew/brew
|
@ -0,0 +1,65 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (My Linux Story: remixing distributions at 17 years old)
|
||||
[#]: via: (https://opensource.com/article/20/6/linux-remix)
|
||||
[#]: author: (Kai Lyons https://opensource.com/users/kailikeslinux)
|
||||
|
||||
My Linux Story: remixing distributions at 17 years old
|
||||
======
|
||||
Open source and Linux create an environment ripe for hands-on learning
|
||||
and experimentation, and it's never too early to start.
|
||||
![Person programming on a laptop on a building][1]
|
||||
|
||||
The [Lumina desktop][2] was originally developed by iXSystems for TrueOS, which later became Project Trident. It's well-known as the BSD desktop environment but has been ported to Linux. It introduces desktop elements like a panel, system tray, and so on, to the Fluxbox window manager, and is highly portable. It's a good desktop, and while it's generally easy to install, there aren't many distributions offering it by default.
|
||||
|
||||
I'm the sole contributor and maintainer to the Ubuntu Lumina remix. My work on the Ubuntu Lumina project has been a lengthy process, and much of it has been learning along the way. As of this writing, I'm 17 years old, but I've been a technology enthusiast since age six when a friend of mine helped me write my first ever "Hello, world" script.
|
||||
|
||||
### My introduction to Linux
|
||||
|
||||
Although I am a distribution developer, I haven't been on Linux all that long. I didn't start using Linux until 2018 when I first got into Fedora 29. My original reason for installing Linux was to build an operating system, and Linux taught me an important lesson—in open source, you can build upon the successful work of others. You can learn the components of the existing scaffolding, which grants you a substantial headstart in reaching your ultimate goal.
|
||||
|
||||
My original plan was to write a custom kernel. Once I learned what a monumental task it was, I decided to redirect that enthusiasm to working with the Linux kernel for a while, since I ultimately wanted to make an operating system.
|
||||
|
||||
I got started on Fedora using the Gnome desktop. I still couldn't tell you for sure how I got it to fit on a 1GB flash drive, but that's why Fedora 29 was my pick—I fell in love with Gnome 3 immediately, and [Gnome Boxes][3] was the first virtual machine I ever used. I've found many other desktops to love, too—Pantheon, Cinnamon, LXQt, and others. After testing FreeBSD for the first time only a short three months after finding Linux, I found Lumina.
|
||||
|
||||
### My first operating system attempts
|
||||
|
||||
My initial attempts to design my own distribution with Lumina as the default environment were mostly exercises in experimenting with tools. The tool I used most at first was [Linux-Live][4]. I never thought of working on an operating system from anything but the live-system. It actually wouldn't be until Ubuntu Lumina that I would even try to do it with an installed system.
|
||||
|
||||
My first distribution had no name, and it was a [Linux From Scratch][5] (LFS) system. It taught me a lot, but in the end, it wasn't what I really wanted; it didn't even have a proper installer.
|
||||
|
||||
My second through seventh tries were random assortments of mashing software together, and only one of them ever got "shipped." I don't remember the name of it, or even whether it worked, but it was something that I had made myself, and it showed me what was possible. While the end results weren't what I ultimately wanted, I still loved the process of making them.
|
||||
|
||||
I spent time reading LFS, remixing Gentoo and Arch, made a couple of weird Debian tries, and finally decided to create an Ubuntu Cinnamon remix. I soon found out that Joshua Peisach had already made one. I didn't get far on my own remix; it never booted, so I abandoned the idea. With Joshua's encouragement, there were a few intermediate attempts at remixes (a failed attempt at Pantheon, and then i3) before I settled on concentrating on Lumina.
|
||||
|
||||
### Lumina desktop on Linux
|
||||
|
||||
My Lumina-based distribution is still in development, meaning it's usable but has several significant omissions. The goal of the project is to provide a comfortable and lightweight OS. The Lumina desktop environment doesn't have many tools compared to a full desktop environment, including those considered to be minimal, like LXQt. And while Lumina is a little clunky, it's about as lightweight as XFCE.
|
||||
|
||||
While it's true that I'm the only contributor to the project, I have gotten a lot of help along the way. Advice from Martin Wimpress, Joshua Peisach, Rik Mills, Thomas Castleman, and many other incredible distribution developers has guided me through many a twist and turn on what could have been a discouraging learning curve.
|
||||
|
||||
### Open source knowledge
|
||||
|
||||
This is what remixing, and indeed, open source itself, is all about—learning and helping one another while making better technology. My work builds upon the work of other distribution maintainers, packagers, a BSD desktop, an ISO-Builder developed for Budgie, and the entire Linux community. There's no question in my mind that I wouldn't have a bootable OS to call my own and to share with others without Linux and open source.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/6/linux-remix
|
||||
|
||||
作者:[Kai Lyons][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/kailikeslinux
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_code_programming_laptop.jpg?itok=ormv35tV (Person programming on a laptop on a building)
|
||||
[2]: https://opensource.com/article/19/12/linux-lumina-desktop
|
||||
[3]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization
|
||||
[4]: https://www.linuxliveusb.com/
|
||||
[5]: http://www.linuxfromscratch.org/
|
@ -0,0 +1,142 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Perform Common PDF Editing Tasks Like Merge, Split, Rotate With Free and Open Source PDF Mix Tool)
|
||||
[#]: via: (https://itsfoss.com/pdf-mix-tool/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
|
||||
Perform Common PDF Editing Tasks Like Merge, Split, Rotate With Free and Open Source PDF Mix Tool
|
||||
======
|
||||
|
||||
_**Brief: PDF Mix Tool is a simple, lightweight open-source PDF editing application that lets you extract pages from PDF, merge two PDFs, delete pages from PDF files among a few other things.**_
|
||||
|
||||
### PDF Mix Tool: A Simple Open Source PDF Editing Tool
|
||||
|
||||
![][1]
|
||||
|
||||
There are [several PDF editors available for Linux][2]. I usually categorize them in two categories:
|
||||
|
||||
* PDF editors that let you edit the content (annotate, highlight, change text, add/remove images etc)
|
||||
* PDF editors that let you modify the files by merging files, splitting files, extracting pages from files etc.
|
||||
|
||||
|
||||
|
||||
[PDF Mix Tool][3] falls in the second category. It is an open source software written in C++ and uses Qt5. It lets you merge two or more PDF files specifying a page set for each of them, rotate pages, add white pages, delete pages and extract pages from PDF files.
|
||||
|
||||
In this week’s open source software highlight, let’s take a look at using PDF Mix Tool.
|
||||
|
||||
### Using PDF Mix Tool for editing PDFs in Linux
|
||||
|
||||
![][4]
|
||||
|
||||
PDF Mix Tool does not boast a bunch of features but a handful of things that are incredibly important.
|
||||
|
||||
#### Merge PDF files
|
||||
|
||||
![][5]
|
||||
|
||||
You can easily merge multiple PDF files while specifying the exact pages as well. It gives you the ability to tweak the number of pages, rotation, and also the option to reverse the order of pages to merge with “**Alternate mix**“.
|
||||
|
||||
![][6]
|
||||
|
||||
You just need to click on “**Add PDF Fil**e” to add the files and then edit it with the options available (as shown in the image above) and finally generate the edited PDF.
|
||||
|
||||
#### Rotate pages
|
||||
|
||||
You can rotate pages of a PDF file while merging multiple files or when simply operating on a single PDF file.
|
||||
|
||||
For merging files, you can refer to the screenshots above — but when you select a single file, this is how it looks:
|
||||
|
||||
![][7]
|
||||
|
||||
You get a variety of options, but to rotate the pages, you need to select the “**Edit page layout**” option as shown in the screenshot above.
|
||||
|
||||
#### Add or delete pages
|
||||
|
||||
To add new pages from a different PDF file, it’s best to utilize the option.
|
||||
|
||||
But, if you want to add an empty page, you can do that when selecting a single file to process. Not just limited to the addition of empty pages — but you can delete specific pages as well. Here’s a screenshot that highlights the delete option:
|
||||
|
||||
![][8]
|
||||
|
||||
#### Extract pages from a PDF file
|
||||
|
||||
![][9]
|
||||
|
||||
In addition to all the other options, you can also extract a certain page (or all) from a given PDF file. You can then generate a new PDF file for all the extracted pages or make separate PDF files for every page you extract. It should come in handy in a lot of use-cases.
|
||||
|
||||
#### Other functionalities
|
||||
|
||||
With all the features mentioned above, you can generate an entirely new PDF of your choice, reverse the order, extract the pages, make separate PDF files, and so on.
|
||||
|
||||
It does not reduce size of the PDF file. You’ll have to use other tools for [compressing PDF files on Linux][10].
|
||||
|
||||
So, it’s a mixed bag of things when you combine and use the options available.
|
||||
|
||||
### Installing PDF Mix Tool on Linux
|
||||
|
||||
![PDF Mix Tool in Ubuntu Software Center][11]
|
||||
|
||||
PDF Mix Tool is available as Snap and [Flatpak packages][12]. This means _**you may find it in your distribution’s software manager**_ if it supports either of these packages.
|
||||
|
||||
Alternatively, if you have [Snap package support enabled][13], you can use the following command to install it:
|
||||
|
||||
```
|
||||
sudo snap install pdfmixtool
|
||||
```
|
||||
|
||||
If you want to [use Flatpak][14], you can use:
|
||||
|
||||
```
|
||||
flatpak install flathub eu.scarpetta.PDFMixTool
|
||||
```
|
||||
|
||||
In case you’re using Arch Linux, you can get it from the [community repository][15].
|
||||
|
||||
```
|
||||
sudo pacman -S pdfmixtool
|
||||
```
|
||||
|
||||
You can also choose to take a look at their [GitLab page][16] for its source code.
|
||||
|
||||
[Download Source Code for PDF Mix Tool][17]
|
||||
|
||||
**Wrapping Up**
|
||||
|
||||
It may not be the most feature-rich PDF editing tool — but considering it as a lightweight open-source tool, it is a very useful application to have installed. We have also covered a similar tool [PDF Arranger][18] in the past. You may want to take a look at that as well.
|
||||
|
||||
What do you think about it? Have you tried it yet? Let me know your thoughts in the comments below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/pdf-mix-tool/
|
||||
|
||||
作者:[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/06/pdf-mix-tool.png?ssl=1
|
||||
[2]: https://itsfoss.com/pdf-editors-linux/
|
||||
[3]: https://scarpetta.eu/pdfmixtool/
|
||||
[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/pdf-mix-tool-merge.png?ssl=1
|
||||
[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/pdf-mix-tool-edit.png?ssl=1
|
||||
[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/pdf-mix-tool-merge-edit.png?ssl=1
|
||||
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/pdf-mix-tool-layout.png?ssl=1
|
||||
[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/pdf-mix-tool-add-delete.png?ssl=1
|
||||
[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/pdf-mix-tool-extract.png?ssl=1
|
||||
[10]: https://itsfoss.com/compress-pdf-linux/
|
||||
[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/pdf-mix-tool-ubuntu.png?ssl=1
|
||||
[12]: https://flathub.org/apps/details/eu.scarpetta.PDFMixTool
|
||||
[13]: https://itsfoss.com/install-snap-linux/
|
||||
[14]: https://itsfoss.com/flatpak-guide/
|
||||
[15]: https://www.archlinux.org/packages/community/x86_64/pdfmixtool/
|
||||
[16]: https://gitlab.com/scarpetta/pdfmixtool
|
||||
[17]: https://www.scarpetta.eu/pdfmixtool/
|
||||
[18]: https://itsfoss.com/pdfarranger-app/
|
@ -0,0 +1,171 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Cockpit and the evolution of the Web User Interface)
|
||||
[#]: via: (https://fedoramagazine.org/cockpit-and-the-evolution-of-the-web-user-interface/)
|
||||
[#]: author: (Shaun Assam https://fedoramagazine.org/author/sassam/)
|
||||
|
||||
Cockpit 及其网页用户界面的演变
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
3 年多以前,Fedora 杂志发表了一篇题为《[Cockpit 概览][2]》的文章。从那时起,Cockit 的界面有了一些引人注目的变化。今天的 Cockpit 更加简洁,更大的字体更好地利用了屏幕的空间。
|
||||
|
||||
本文将介绍用户界面的一些变化。它还将探讨一些在网页界面中可用的通用工具,以简化那些单调的系统管理员任务。
|
||||
|
||||
### Cockpit 驾驶舱安装
|
||||
|
||||
Cockpit 可以使用 `dnf install cockpit` 命令安装。这提供了一个最小的设置,提供了使用界面所需的基本工具。
|
||||
|
||||
另一个选择是安装 “Headless Management” 组,这将安装用于扩展 Cockpit 可用性的附加包。它包括 NetworkManager、软件包、磁盘和 SELinux 管理的扩展。
|
||||
|
||||
运行以下命令,在启动时启用 Web 服务并打开防火墙端口:
|
||||
|
||||
```
|
||||
$ sudo systemctl enable --now cockpit.socket
|
||||
Created symlink /etc/systemd/system/sockets.target.wants/cockpit.socket -> /usr/lib/systemd/system/cockpit.socket
|
||||
|
||||
$ sudo firewall-cmd --permanent --add-service cockpit
|
||||
success
|
||||
$ sudo firewall-cmd --reload
|
||||
success
|
||||
```
|
||||
|
||||
### 登录网页界面
|
||||
|
||||
要访问网页界面,打开你最喜欢的浏览器,在地址栏中输入服务器的域名或 IP,然后输入服务端口(9090)。由于 Cockpit 使用 HTTPS,安装过程中会创建一个自签证书来加密密码和其他敏感数据。你可以安全地接受这个证书,或者向你的系统管理员或受信任的来源请求 CA 证书。
|
||||
|
||||
一旦证书被接受,新改进的登录屏幕就会出现。长期使用的用户会注意到用户名和密码字段已被移到顶部。此外,凭证字段后面的白色背景会立即吸引用户的注意力。
|
||||
|
||||
![][3]
|
||||
|
||||
自上一篇文章后,登录界面增加了一个功能,就是用 `sudo` 权限登录 —— 如果你的账号是 `wheel` 组的成员。勾选 “对于特权任务,重用我的密码” 旁边的方框,就可以提升你的权限。
|
||||
|
||||
登录界面的另一个版本是连接到同样运行 Cockpit Web 服务的远程服务器的选项。点击 “其他选项” 并输入远程机器的主机名或 IP 地址,从本地浏览器管理它。
|
||||
|
||||
### 主屏幕视图
|
||||
|
||||
一开始,我们就会得到常见系统信息的基本概述。这包括机器的品牌和型号、操作系统、系统是否是最新的,等等。
|
||||
|
||||
![][4]
|
||||
|
||||
点击系统的品牌/型号会显示硬件信息,如 BIOS/固件。它还包括与 `lspci` 有关的组件详情。
|
||||
|
||||
|
||||
![][5]
|
||||
|
||||
点击右边的任何一个选项都会显示该设备的详细信息。例如,“CPU 核心百分比” 选项显示了用户和内核使用了多少 CPU 核心的详细信息。此外,“内存和交换” 图表显示了系统内存的使用量、缓存量和交换分区的活动量。“磁盘 I/O” 和 “网络流量” 图连到了 Cockpit 的 “存储和网络” 部分。这些主题将在接下来的一篇详细探讨系统工具的文章中重新探讨。
|
||||
|
||||
#### SSH 密钥和认证
|
||||
|
||||
由于安全是系统管理员的关键因素,Cockpit 现在有了查看机器 MD5 和 SHA256 密钥指纹的选项。点击 “显示指纹” 选项可以显示服务器的 ECDSA、ED25519 和 RSA 指纹密钥。
|
||||
|
||||
![][6]
|
||||
|
||||
你也可以通过点击右上角的用户名,选择“验证”,添加自己的密钥。点击 “添加密钥”,可以在其他系统上验证机器。你也可以通过点击右侧的 “X” 按钮,撤销你在 Cockpit Web 服务中的权限。
|
||||
|
||||
![][7]
|
||||
|
||||
#### 更改主机名和加入域
|
||||
|
||||
更改主机名称是在主页上一键解决的。单击当前显示的主机名称,并在“更改主机名称”框中输入新名称。最新的功能之一是提供一个 “别名” 的选项。
|
||||
|
||||
Cockpit 增加的另一个功能是可以连接到目录服务器。点击 “加入域”,会出现一个弹窗,要求提供域地址或名称、组织单位(可选)和域管理员的凭证。“Domain Membership” 组提供了加入 LDAP 服务器所需的所有包,包括 FreeIPA,以及流行的 Active Directory。
|
||||
|
||||
要选择退出,请点击域名,然后点击 “离开域”。将会出现一个警告,解释一旦系统不再在域上将会发生的变化。要确认,点击红色的 “离开域” 按钮。
|
||||
|
||||
![][8]
|
||||
|
||||
#### 配置 NTP 和系统日期和时间
|
||||
|
||||
使用命令行和编辑配置文件绝对可以完成最大限度的调整。然而,有些时候,一些更直接的方法就足够了。通过 Cockpit,你可以选择手动设置或使用 NTP 自动设置系统的日期和时间。一旦同步,右边的信息图标就会由红色变成蓝色。如果你手动设置日期和时间,该图标将消失。
|
||||
|
||||
要更改时区,请输入洲,下面会弹出城市列表。
|
||||
|
||||
![][9]
|
||||
|
||||
#### 关机和重启
|
||||
|
||||
你可以在 Cockpit 的主屏幕上轻松关闭和重启服务器。你也可以延迟关机/重启,并发送消息警告用户。
|
||||
|
||||
![][10]
|
||||
|
||||
#### 设置性能配置文件
|
||||
|
||||
如果安装了 `tuned` 和 `tuned-utils` 包,可以在主屏幕上更改性能配置文件。默认情况下,它被设置为推荐的配置文件。然而,如果服务器的用途需要更多的性能,我们可以从 Cockpit 更改配置文件以满足这些需求。
|
||||
|
||||
![][11]
|
||||
|
||||
### 网页终端控制台
|
||||
|
||||
一个 Linux 系统管理员的工具箱如果不能访问终端,将毫无用处。这使得管理员可以对服务器进行微调,而不仅仅是 Cockpit 中的内容。随着主题的加入,管理员可以根据自己的喜好快速调整文字和背景颜色。
|
||||
|
||||
另外,如果你打错了 `exit`,点击右上角的 “重置” 按钮,会提供一个闪烁着光标的新屏幕。
|
||||
|
||||
![][12]
|
||||
|
||||
### 添加远程服务器和仪表板布局
|
||||
|
||||
“Headless Management” 组包括仪表盘模块(`cockpit-dashboard`)。它以实时图表的形式提供了 CPU、内存、网络和磁盘性能的概览。远程服务器也可以通过同一界面进行添加和管理。
|
||||
|
||||
例如,要在仪表盘中添加远程计算机,请单击 “+” 按钮。输入服务器的名称或 IP 地址,并选择你要的颜色。这有助于区分图中服务器的统计数据。要在服务器之间进行切换,请点击主机名称(如下面的屏幕动画所示)。要从列表中删除一个服务器,点击勾选标记图标,然后点击红色垃圾桶图标。下面的例子演示了 Cockpit 如何管理一台名为 `server02.local.lan` 的远程机器。
|
||||
|
||||
![][13]
|
||||
|
||||
### 文档和寻找帮助
|
||||
|
||||
一如既往,手册页是查找文档的好地方。在命令行结果中进行简单搜索即可找到与使用和配置该 Web 服务的不同方面有关的页面。
|
||||
|
||||
```
|
||||
$ man -k cockpit
|
||||
cockpit (1) - Cockpit
|
||||
cockpit-bridge (1) - Cockpit Host Bridge
|
||||
cockpit-desktop (1) - Cockpit Desktop integration
|
||||
cockpit-ws (8) - Cockpit web service
|
||||
cockpit.conf (5) - Cockpit configuration file
|
||||
```
|
||||
|
||||
Fedora 仓库中也有一个名为 `cockpit-doc` 的软件包。这个软件包的描述是最好的解释。
|
||||
|
||||
> 《Cockpit 部署和开发者指南》向系统管理员展示了如何在他们的机器上部署 Cockpit,并帮助开发者嵌入或扩展 Cockpit。
|
||||
|
||||
更多文档请访问 <https://cockpit-project.org/external/source/HACKING>。
|
||||
|
||||
### 结论
|
||||
|
||||
本文只涉及 Cockpit 中的一些主要功能。管理存储设备、网络、用户账户和软件控制将在下一篇文章中介绍。此外,可选的扩展,如 389 目录服务,以及用于处理 Fedora Silverblue 中的包的`cockpit-ostree` 模块。
|
||||
|
||||
随着越来越多的用户采用 Cockpit,选项会继续增加。这个界面对于想要一个轻量级界面来控制服务器的管理员来说是非常理想的。
|
||||
|
||||
你对 Cockpit 有什么看法?在下面的评论中分享你的经验和想法。
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/cockpit-and-the-evolution-of-the-web-user-interface/
|
||||
|
||||
作者:[Shaun Assam][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/sassam/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-816x345.jpg
|
||||
[2]: https://fedoramagazine.org/cockpit-overview/
|
||||
[3]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-login-screen.png
|
||||
[4]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-home-screen.png
|
||||
[5]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-system-info.gif
|
||||
[6]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-ssh-key-fingerprints.png
|
||||
[7]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-authentication.png
|
||||
[8]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-hostname-domain.gif
|
||||
[9]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-date-time.png
|
||||
[10]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-power-options.gif
|
||||
[11]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-tuned.gif
|
||||
[12]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-terminal.gif
|
||||
[13]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-add-remote-servers.gif
|
140
translated/tech/20200602 Using pandas to plot data in Python.md
Normal file
140
translated/tech/20200602 Using pandas to plot data in Python.md
Normal file
@ -0,0 +1,140 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Using pandas to plot data in Python)
|
||||
[#]: via: (https://opensource.com/article/20/6/pandas-python)
|
||||
[#]: author: (Shaun Taylor-Morgan https://opensource.com/users/shaun-taylor-morgan)
|
||||
|
||||
使用 pandas 在 Python 中绘制数据
|
||||
======
|
||||
Pandas 是一个非常流行的 Python 数据操作库。学习怎样使用它的 API 绘制数据。
|
||||
![Two pandas sitting in bamboo][1]
|
||||
|
||||
在有关基于 Python 的绘图库的系列文章中,我们将对使用 pandas(一种非常流行的 Python 数据操作库)绘图进行概念性研究。Pandas 是 Python 中用于可扩展转换数据的标准工具,它也已成为[从 CSV 和 Excel 格式导入和导出数据][2]的流行方法。
|
||||
|
||||
最重要的是,它还包含一个非常好的绘图 API。这非常方便,你已将数据存储在 pandas DataFrame 中,那么为什么不使用相同的库进行绘制呢?
|
||||
|
||||
在本系列中,我们将在每个库中制作相同的多柱状图,以便我们可以比较它们的工作方式。我们将使用的数据是 1966 年至 2020 年的英国大选结果:
|
||||
|
||||
![Matplotlib UK election results][3]
|
||||
|
||||
### 自行绘制的数据
|
||||
|
||||
在继续之前,请注意你可能需要调整 Python 环境来运行此代码,包括:
|
||||
|
||||
* 运行最新版本的 Python([Linux][4]、[Mac][5] 和 [Windows][6] 的说明)
|
||||
* 确认你运行的是与这些库兼容的 Python 版本
|
||||
|
||||
|
||||
|
||||
数据可在线获得,并可使用 pandas 导入:
|
||||
|
||||
```
|
||||
import pandas as pd
|
||||
df = pd.read_csv('<https://anvil.works/blog/img/plotting-in-python/uk-election-results.csv>')
|
||||
```
|
||||
|
||||
完成了。在本系列文章中,我们已经看到了一些令人印象深刻的简单 API,但是 pandas 一定能夺冠。
|
||||
|
||||
要在 x 轴上绘制按`年`和每个党派分组的柱状图,我只需要这样做:
|
||||
|
||||
|
||||
```
|
||||
import matplotlib.pyplot as plt
|
||||
ax = df.plot.bar(x='year')
|
||||
plt.show()
|
||||
```
|
||||
|
||||
只有四行,这绝对是我们在本系列中创建的最棒的多柱状图。
|
||||
|
||||
我以[宽格式][7]使用数据,这意味着每个党派都有一列:
|
||||
|
||||
|
||||
```
|
||||
year conservative labour liberal others
|
||||
0 1966 253 364 12 1
|
||||
1 1970 330 287 6 7
|
||||
2 Feb 1974 297 301 14 18
|
||||
.. ... ... ... ... ...
|
||||
12 2015 330 232 8 80
|
||||
13 2017 317 262 12 59
|
||||
14 2019 365 202 11 72
|
||||
```
|
||||
|
||||
这意味着 pandas 会自动知道我希望如何分组,如果我希望进行不同的分组,pandas 可以很容易地[重组 DataFrame][8]。
|
||||
|
||||
与 [Seaborn][9] 一样,pandas 的绘图功能是 Matplotlib 之上的抽象,这就是为什么要调用 Matplotlib 的 `plt.show()` 函数来实际生成绘图的原因。
|
||||
|
||||
看起来是这样的:
|
||||
|
||||
![pandas unstyled data plot][10]
|
||||
|
||||
看起来很棒,特别是它又这么简单!让我们对它进行样式设置,使其看起来像 [Matplotlib][11] 的例子。
|
||||
|
||||
#### 调整样式
|
||||
|
||||
我们可以通过访问底层的 Matplotlib 方法轻松地调整样式。
|
||||
|
||||
首先,我们可以通过将 Matplotlib 颜色表传递到绘图函数来为柱状图着色:
|
||||
|
||||
|
||||
```
|
||||
from matplotlib.colors import ListedColormap
|
||||
cmap = ListedColormap(['#0343df', '#e50000', '#ffff14', '#929591'])
|
||||
ax = df.plot.bar(x='year', colormap=cmap)
|
||||
```
|
||||
|
||||
我们可以使用绘图函数的返回值设置坐标轴标签和标题,它只是一个 [Matplotlib `Axis` 对象][12]。
|
||||
|
||||
|
||||
```
|
||||
ax.set_xlabel(None)
|
||||
ax.set_ylabel('Seats')
|
||||
ax.set_title('UK election results')
|
||||
```
|
||||
|
||||
这是现在的样子:
|
||||
|
||||
![pandas styled plot][13]
|
||||
|
||||
这与上面的 Matplotlib 版本几乎相同,但是只用了 8 行代码而不是 16 行!我内心的[代码高尔夫选手][14]非常高兴。
|
||||
|
||||
### 抽象必须是可转义的
|
||||
|
||||
与 Seaborn 一样,向下访问 Matplotlib API 进行细节调整的能力确实很有帮助。这是给出抽象[紧急出口][15]使其既强大又简单的一个很好的例子。
|
||||
|
||||
* * *
|
||||
|
||||
_本文基于 Anvil 博客上的[如何使用 Pandas 绘图][16],并获许可以重复使用。_
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/6/pandas-python
|
||||
|
||||
作者:[Shaun Taylor-Morgan][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/shaun-taylor-morgan
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/panda.png?itok=0lJlct7O (Two pandas sitting in bamboo)
|
||||
[2]: https://anvil.works/docs/data-tables/csv-and-excel
|
||||
[3]: https://opensource.com/sites/default/files/uploads/matplotlib_2.png (Matplotlib UK election results)
|
||||
[4]: https://opensource.com/article/20/4/install-python-linux
|
||||
[5]: https://opensource.com/article/19/5/python-3-default-mac
|
||||
[6]: https://opensource.com/article/19/8/how-install-python-windows
|
||||
[7]: https://anvil.works/blog/tidy-data
|
||||
[8]: https://anvil.works/blog/tidy-data#converting-between-long-and-wide-data-in-pandas
|
||||
[9]: https://anvil.works/blog/plotting-in-seaborn
|
||||
[10]: https://opensource.com/sites/default/files/uploads/pandas-unstyled.png (pandas unstyled data plot)
|
||||
[11]: https://opensource.com/article/20/5/matplotlib-python
|
||||
[12]: https://matplotlib.org/api/axis_api.html#axis-objects
|
||||
[13]: https://opensource.com/sites/default/files/uploads/pandas_3.png (pandas styled plot)
|
||||
[14]: https://en.wikipedia.org/wiki/Code_golf
|
||||
[15]: https://anvil.works/blog/escape-hatches-and-ejector-seats
|
||||
[16]: https://anvil.works/blog/plotting-in-pandas
|
@ -1,103 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Using AppImage for Linux package management)
|
||||
[#]: via: (https://opensource.com/article/20/6/appimages)
|
||||
[#]: author: (David Clinton https://opensource.com/users/dbclinton)
|
||||
|
||||
使用 AppImage 进行 Linux 软件包管理
|
||||
======
|
||||
AppImage 在独立环境中分发应用, 它适用于任何 Linux 发行版。
|
||||
![Gift box opens with colors coming out][1]
|
||||
|
||||
管理 Linux 机器(尤其是远程机器)的很大一部分是管理和安装软件。当本地应用出现问题时,或者文件系统上的某些文件损坏需要修复时,你通常会希望推送更新,而不必走很多路坐在屏幕前。正如我在 Pluralsight 课程 [Linux 系统维护和故障排除][2]中所解释的那样,可以通过 Bash 脚本解决许多问题,但是在很多情况下,没有什么可以替代传统的老式二进制文件了。
|
||||
|
||||
想象一下,你的某些远程系统需要安装新的应用,因此使用这些计算机的团队成员将能够做某些业务。能够利用 Debian 或 RPM 之类的主要 Linux 仓库系统之一的集成和自动化,可以使你的管理任务变得更加容易。
|
||||
|
||||
正如 Linus Torvalds 永不厌倦地提醒我们的那样,许多 Linux 软件管理系统的问题在于[太多的 Linux 软件管理系统][3]。多年来,由于你花费了大量的时间和精力来准备软件(例如 Debian 仓库),如果你想将它们引入 RPM 系统,那么对应用程序开发乃至 Linux 的采用都将变得复杂。SUSE 的 Zypper 管理器也没有帮助。
|
||||
|
||||
解决软件孤岛问题的一种有前途的方案是使用可以在任何 Linux 发行版上运行的独立的环境来发行应用。在这个年轻且不断发展的领域中,一种选择是 [AppImage][4]。
|
||||
|
||||
### 使用 AppImages
|
||||
|
||||
我全部投入 AppImage。就像我提到的其他软件包管理系统一样,如果你需要的话,会有很多的复杂性。但是,从本质上讲,AppImages 非常简单。AppImage 不像大多数其他包管理器一样通过仓库工作,它使用单个,独立的文件,可以直接发送或通过网站共享。
|
||||
|
||||
下面是个展示它美丽的例子。当我在用 AppImages 时,我在一个技术论坛上看到了一个非常久的讨论,我同时进入了一个同样久远且废弃的 GitHub 项目以及相关的 YAML 和配套文件。它们旨在自动构建准备生成 AppImage 包所需的相当复杂的基础架构。尽管该基础架构全部是在有 5 年历史 Ubuntu 版本上构建的,但是当我将它们放在一起并运行 `appimagetool` 命令时,它创建了一个 AppImage 文件,它可在当前桌面上无缝运行。我不认为有很多有五年历史的 GitHub 复杂项目可以无需认真重做的情况下使用其他技术。
|
||||
|
||||
但是我不会这么做。相反,我将向你展示它如何用一个简单的 Hello World 程序实现。首先,本地已安装请确保 AppStream 包。
|
||||
|
||||
对于基于 Debian 的系统,运行:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo apt install appstream`
|
||||
```
|
||||
|
||||
对于 RPM 系统,请使用:
|
||||
|
||||
|
||||
```
|
||||
`$ sudo dnf install appstream`
|
||||
```
|
||||
|
||||
克隆[这篇文章][5]中引用的 Git 仓库,我会基于它示例:
|
||||
|
||||
|
||||
```
|
||||
$ git clone <https://github.com/boolean-world/appimage-resources>
|
||||
$ cd appimage-resources
|
||||
$ ls hello-world-appimage
|
||||
```
|
||||
|
||||
接下来,使用 `cd` 进入 Git 新创建的目录。这里有两个目录。请使用 `hello-world-appimage`。另一个是更复杂的项目,你也应该考虑尝试一下。
|
||||
|
||||
Linux GUI 系统读取 `helloworld.desktop` 文件来知道如何呈现桌面图标。事实证明,当前的文件会在以后给你带来麻烦,因此请进行一些小修改:添加 `Categories=` 这行并为其赋予值 `GNOME`。不要忘记最后的分号:
|
||||
|
||||
|
||||
```
|
||||
$ nano hello-world-appimage/helloworld.desktop
|
||||
add Categories=GNOME;
|
||||
```
|
||||
|
||||
从 [AppImage GitHub 项目][6]下载 `appimagetool` 预编译的二进制文件。访问 GitHub 的原因之一:那里有很多出色的文档和资源。下载二进制文件后,使文件可执行,并指向 `hello-world-appimage` 目录。但是首先,你需要告诉它你想要的架构。由于某些原因,在选择是否使用 x86_64 构建应用时,以 `x86_64` 结尾的名为的工具会不稳定。(我不知道发生了什么)
|
||||
|
||||
|
||||
```
|
||||
$ wget <https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86\_64.AppImage>
|
||||
$ chmod +x appimagetool-x86_64.AppImage
|
||||
$ ARCH=x86_64 ./appimagetool-x86_64.AppImage hello-world-appimage
|
||||
```
|
||||
|
||||
如果你没有看到任何错误消息,那么表示完成了,请运行:
|
||||
|
||||
|
||||
```
|
||||
$ ls
|
||||
$ ./hello-world-appimage-x86_64.AppImage
|
||||
```
|
||||
|
||||
### 总结
|
||||
|
||||
AppImage 是软件包管理的非常有效的选择。当你探索它时,我想你会发现它是 Linux 发行版提供的默认替代品。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/6/appimages
|
||||
|
||||
作者:[David Clinton][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/dbclinton
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_gift_giveaway_box_520x292.png?itok=w1YQhNH1 (Gift box opens with colors coming out)
|
||||
[2]: https://pluralsight.pxf.io/VMKQj
|
||||
[3]: https://itsfoss.com/desktop-linux-torvalds/
|
||||
[4]: https://appimage.org/
|
||||
[5]: https://www.booleanworld.com/creating-linux-apps-run-anywhere-appimage/
|
||||
[6]: https://github.com/AppImage/AppImageKit/releases
|
Loading…
Reference in New Issue
Block a user