Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang 2020-10-16 19:56:18 +08:00
commit 90bda4cc15
8 changed files with 796 additions and 120 deletions

View File

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

View File

@ -0,0 +1,171 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Reduce/Shrink LVMs (Logical Volume Resize) in Linux)
[#]: via: (https://www.2daygeek.com/reduce-shrink-decrease-resize-lvm-logical-volume-in-linux/)
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
How to Reduce/Shrink LVMs (Logical Volume Resize) in Linux
======
Reducing/Shrinking the logical volume is the highest risk of data corruption.
So try to avoid this kind of situation if possible, but go ahead if you have no other options.
It is always recommended to make a backup before shrinking an LVM.
When you are running out of disk space in LVM, you can make some free space on the volume group by reducing the exsisting LVM that no longer uses the full size, instead of adding a new physical disk.
**Make a note:** Shrinking is not supported on a `GFS2` or `XFS` file system.
If you are new to Logical Volume Management (LVM), I suggest you start with our previous article.
* **Part-1: [How to Create/Configure LVM (Logical Volume Management) in Linux][1]**
* **Part-2: [How to Extend/Increase LVMs (Logical Volume Resize) in Linux][2]**
![][3]
Reducing the logical volume involves the below steps.
* Unmount the file system.
* Check the file system for any errors.
* Shrink the file system size.
* Reduce the logical volume size.
* Re-check the file system for errors (Optional).
* Mount the file system
* Check the reduced file system size
**For instance;** You have a **100GB** LVM that no longer uses the full size, you want to reduce it to **80GB** so **20GB** can be used for other purposes.
```
# df -h /testlvm1
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg01-lv002 100G 15G 85G 12% /testlvm1
```
### 1) Unmount the file system
Use the umount command to unmount the file system.
```
# umount /testlvm1
```
### 2) Check the file system for any Errors
Check the file system for any errors using the e2fsck command.
```
# e2fsck -f /dev/mapper/vg01-lv002
e2fsck 1.42.9 (28-Dec-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/vg01-lv002: 13/6553600 files (0.0% non-contiguous), 12231854/26212352 blocks
```
### 3) Shrink the file system.
The below command will reduce the **“testlvm1”** file system from **100GB** to **80GB**.
**Common syntax for file system resize (resize2fs).**
```
resize2fs [Existing Logical Volume Name] [New Size of File System]
```
The actual command is as follows.
```
# resize2fs /dev/mapper/vg01-lv002 80G
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/mapper/vg01-lv002 to 28321400 (4k) blocks.
The filesystem on /dev/mapper/vg01-lv002 is now 28321400 blocks long.
```
### 4) Reduce the Logical Volume (LVM)
Now reduce the logical volume (LVM) size using the lvreduce command. The below command **“/dev/mapper/vg01-lv002”** will shrink the Logical volume (LVM) from 100GB to 80GB.
**Common syntax for LVM Reduce (lvreduce)**
```
lvreduce [New Size of LVM] [Existing Logical Volume Name]
```
The actual command is as follows.
```
# lvreduce -L 80G /dev/mapper/vg01-lv002
WARNING: Reducing active logical volume to 80.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv002? [y/n]: y
Reducing logical volume lv002 to 80.00 GiB
Logical volume lv002 successfully resized
```
### 5) Optional: Check the file system for any Errors
Check the file system again if there are any errors after LVM has been reduced.
```
# e2fsck -f /dev/mapper/vg01-lv002
e2fsck 1.42.9 (28-Dec-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/vg01-lv002: 13/4853600 files (0.0% non-contiguous), 1023185/2021235 blocks
```
### 6) Mount the file system and check the reduced size
Finally mount the file system and check the reduced file system size.
Use the mount command to **[mount the logical volume][4]**.
```
# mount /testlvm1
```
Check the newly mounted volume using the **[df command][5]**.
```
# df -h /testlvm1
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg01-lv002 80G 15G 65G 18% /testlvm1
```
--------------------------------------------------------------------------------
via: https://www.2daygeek.com/reduce-shrink-decrease-resize-lvm-logical-volume-in-linux/
作者:[Magesh Maruthamuthu][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.2daygeek.com/author/magesh/
[b]: https://github.com/lujun9972
[1]: https://www.2daygeek.com/create-lvm-storage-logical-volume-manager-in-linux/
[2]: https://www.2daygeek.com/extend-increase-resize-lvm-logical-volume-in-linux/
[3]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
[4]: https://www.2daygeek.com/mount-unmount-file-system-partition-in-linux/
[5]: https://www.2daygeek.com/linux-check-disk-space-usage-df-command/

View File

@ -1,118 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Install MariaDB or MySQL on Linux)
[#]: via: (https://opensource.com/article/20/10/mariadb-mysql-linux)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Install MariaDB or MySQL on Linux
======
Get started using an open source SQL database on your Linux system.
![Person standing in front of a giant computer screen with numbers, data][1]
Both [MariaDB][2] and [MySQL][3] are open source databases that use SQL and share the same original codebase. MariaDB is a drop-in replacement for MySQL, so much so that you use the same command (`mysql`) to interact with MySQL and MariaDB databases. This article, therefore, applies equally to MariaDB and MySQL.
### Install MariaDB
You can install MariaDB using your Linux distribution's package manager. On most distributions, MariaDB is split into a server package and a client package. The server package provides the database "engine," the part of MariaDB that runs (usually on a physical server) in the background, listening for data input or requests for data output. The client package provides the command `mysql`, which you can use to communicate with the server.
On RHEL, Fedora, CentOS, or similar:
```
`$ sudo dnf install mariadb mariadb-server`
```
On Debian, Ubuntu, Elementary, or similar:
```
`$ sudo apt install mariadb-client mariadb-server`
```
Other systems may package MariaDB differently systems, so you may need to search your software repository to learn how your distribution's maintainers provide it.
### Start MariaDB
Because MariaDB is designed to function, in part, as a database server, it can run on one computer and be administered from another. As long as you have access to the computer running it, you can use the `mysql` command to administer the database. I ran MariaDB on my local computer when writing this article, but it's just as likely that you'll interact with a MariaDB database hosted on a remote system.
Before starting MariaDB, you must create an initial database. You should define the user you want MariaDB to use when initializing its file structure. By default, MariaDB uses the current user, but you probably want it to use a dedicated user account. Your package manager probably configured a system user and group for you. Use `grep` to find out whether there's a `mysql` group:
```
$ grep mysql /etc/group
mysql❌27:
```
You can also look in `/etc/passwd` for a dedicated user, but usually, where there's a group, there's also a user. If there isn't a dedicated `mysql` user and group, look through `/etc/group` for an obvious alternative (such as `mariadb`). Failing that, read your distribution's documentation to learn how MariaDB runs.
Assuming your install uses `mysql`, initialize the database environment:
```
$ sudo mysql_install_db --user=mysql
Installing MariaDB/MySQL system tables in '/var/lib/mysql'...
OK
[...]
```
The result of this step reveals the next tasks you must perform to configure MariaDB:
```
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h $(hostname) password 'new-password'
Alternatively you can run:
'/usr/bin/mysql_secure_installation'
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
```
Start MariaDB using your distribution's init system:
```
`$ sudo systemctl start mariadb`
```
To enable the MariaDB server to start upon boot:
```
`$ sudo systemctl enable --now mariadb`
```
Now that you have a MariaDB server to communicate with, set a password for it:
```
mysqladmin -u root password 'myreallysecurepassphrase'
mysqladmin -u root -h $(hostname) password 'myreallysecurepassphrase'
```
Finally, if you intend to use this installation on a production server, run the `mysql_secure_installation` command before going live.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/10/mariadb-mysql-linux
作者:[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/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data)
[2]: https://mariadb.org/
[3]: https://www.mysql.com/

View File

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

View File

@ -0,0 +1,212 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Teach a virtual class with Moodle on Linux)
[#]: via: (https://opensource.com/article/20/10/moodle)
[#]: author: (Don Watkins https://opensource.com/users/don-watkins)
Teach a virtual class with Moodle on Linux
======
Teach school remotely with the Moodle learning management system on
Linux.
![Digital images of a computer desktop][1]
The pandemic has created a greater need for remote education than ever before. This makes a learning management system (LMS) like [Moodle][2] more important than ever for ensuring that education stays on track as more and more schooling is delivered virtually.
Moodle is a free LMS written in PHP and distributed under the open source [GNU Public License][3] (GPL). It was developed by [Martin Dougiamas][4] and has been under continuous development since its release in 2002. Moodle can be used for blended learning, distance learning, flipped classrooms, and other forms of e-learning. There are currently over [190 million users][5] and 145,000 registered Moodle sites worldwide.
I have used Moodle as an administrator, teacher, and student, and in this article, I'll show you how to set it up and get started using it.
### Install Moodle on Linux
Moodle's [system requirements][6] are modest, and there is plenty of documentation to help you. My favorite installation method is by downloading it as an ISO from [Turnkey Linux][7] and installing a Moodle site in VirtualBox.
First, download the [Moodle ISO][8] and save it to your computer.
Next, install VirtualBox from the Linux command line with
```
$ sudo apt install virtualbox
```
or
```
$ sudo dnf install virtualbox
```
Once the download completes, start VirtualBox and select the **New** button on the console.
![Create a new VirtualBox][9]
(Don Watkins, [CC BY-SA 4.0][10])
Choose a name for your virtual machine, your operating system (Linux), and the type of Linux you're using (e.g., Debian 64-bit).
![Naming the VirtualBox VM][11]
(Don Watkins, [CC BY-SA 4.0][10])
Next, set your virtual machine (VM) memory size—use the default 1024MB. Then, choose a **dynamically allocated** virtual disk and attach the Moodle.iso to your virtual machine.
![Attaching Moodle.iso to VM][12]
(Don Watkins, [CC BY-SA 4.0][10])
Change your network settings from NAT to **Bridged adapter**. Then start the machine and install the ISO to create the Moodle virtual machine. During installation, you will be prompted to create passwords for the root account, MySQL, and Moodle. The Moodle password must include at least eight characters, one upper case letter, and one special character.
Reboot the virtual machine. When the installation finishes, be sure to record your Moodle appliance settings somewhere safe. (After the installation, you can delete the ISO file if you want.)
![Moodle appliance settings][13]
(Don Watkins, [CC BY-SA 4.0][10])
It's important to note that your Moodle instance isn't visible by anyone on the Internet yet. It only exists in your local network: only people in your building who are connected to the same router or wifi access point as you can access your site right now. The worldwide Internet can't get to it because you're behind a firewall (embedded in your router, and possibly also in your computer). For more information on configuring your network, read Seth Kenlon's article on [opening ports and routing traffic through your firewall.][14]
### Start using Moodle
Now you are ready to log into your Moodle machine and get familiar with the software. Log into Moodle using the default login username, **admin**, and the password you set when you created the Moodle VM.
![Moodle login screen][15]
(Don Watkins, [CC BY-SA 4.0][10])
After logging in for the first time, you'll see your new Moodle site's main Dashboard. 
![Moodle admin dashboard][16]
(Don Watkins, [CC BY-SA 4.0][10])
The default appliance name is **Turnkey Moodle**, but it's easy to change it to suit your school, classroom, or other needs and preferences. To personalize your Moodle site, in the menu on the left-hand side of the user interface, select **Site home**. Then click on the **Settings** icon on the right side of the display, and choose **Edit settings**.
![Moodle settings][17]
(Don Watkins, [CC BY-SA 4.0][10])
You can change your site's name and add a short name and site description if you'd like.
![Name Moodle site][18]
(Don Watkins, [CC BY-SA 4.0][10])
Be sure to scroll to the bottom and save your changes. Now your site is personalized.
![Moodle changes saved][19]
(Don Watkins, [CC BY-SA 4.0][10])
The default category is Miscellaneous, which won't help people identify your site's purpose. To add a category, return to the main Dashboard and select **Site administration** from the left-hand menu. Under **Courses**, select **Add a category **and enter details about your site.
![Add category option in Moodle][20]
(Don Watkins, [CC BY-SA 4.0][10])
To add a course, return to **Site administration**, and click **Add a new course**. You will see a series of options, such as naming your course, providing a short name, assigning a category, and setting the course start and end dates. You can also set options for the course's format, such as social, weekly, and topic, as well as its appearance, file upload size, completion tracking, and more.
![Add course option in Moodle][21]
(Don Watkins, [CC BY-SA 4.0][10])
### Add and manage users
Now that you have set up a course, you can add users. There are a variety of ways to do this. Manual entry is a good place to start if you are a homeschooler. Moodle supports email-based registration, [LDAP][22], [Shibboleth][23], and many others. School districts and other larger installations can upload users with a comma-delimited file. Passwords can be added in bulk, too, with a forced password change at first login. For more information, be sure to consult Moodle's [documentation][24].
Moodle is a very granular, permission-oriented environment. It is easy to assign policies and roles to users and enforce those assignments using Moodle's menus.
There are many roles within Moodle, and each has specific privileges and permissions. The default roles are manager, course creator, teacher, non-editing teacher, student, guest, and authenticated user, but you can add other ones.
### Add content to your course
Once you have your Moodle site and a course set up, you can add content to the course. Moodle has all the tools you need to create great content, and it's built on solid pedagogy that emphasizes a [social constructionist][25] view.
I created a sample course called Code with [Mu][26]. It is in the **Programming** category and **Python** subcategory.
![Moodle course list][27]
(Don Watkins, [CC BY-SA 4.0][10])
I chose a weekly format for my course with the default of four weeks. Using the editing tools, I hid all but the first week of the course. This ensures my students stay focused on the material.
As the teacher or Moodle administrator, I can add activities to each week's instruction by clicking **Add an activity** **or resource**.
![Add activity in Moodle][28]
(Don Watkins, [CC BY-SA 4.0][10])
I get a pop-up window with a variety of activities I can assign to my students.
![Moodle activities menu][29]
(Don Watkins, [CC BY-SA 4.0][10])
Moodle's tools and activities make it easy for me to create learning materials and cap off the week with a short quiz.
![Moodle activities checklist][30]
(Don Watkins, [CC BY-SA 4.0][10])
There are more than 1,600 plugins you can use to extend Moodle with new activities, question types, integrations with other systems, and more. For example, the [BigBlueButton][31] plugin supports slide sharing, a whiteboard, audio and video chat, and breakout rooms. Others to consider include the [Jitsi][32] plugin for videoconferencing, a [plagiarism checker][33], and an [Open Badge Factory][34] for awarding badges.
### Keep exploring Moodle
Moodle is a powerful LMS, and I hope this introduction whets your appetite to learn more. There are excellent [tutorials][35] to help you improve your skills, and you can see Moodle in action on its [demonstration site][36] or access [Moodle's source code][37] if you want to see what's under the hood or [contribute][38] to development. Moodle also has a great [mobile app][39] for iOS and Android, if you like to work on the go. Follow Moodle on [Twitter][40], [Facebook][41], and [LinkedIn][42] to stay up to date on what's new.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/10/moodle
作者:[Don Watkins][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/don-watkins
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_desk_home_laptop_browser.png?itok=Y3UVpY0l (Digital images of a computer desktop)
[2]: https://moodle.org/
[3]: https://docs.moodle.org/19/en/GNU_General_Public_License
[4]: https://dougiamas.com/about/
[5]: https://docs.moodle.org/39/en/History
[6]: https://docs.moodle.org/39/en/Installation_quick_guide#Basic_Requirements
[7]: https://www.turnkeylinux.org/
[8]: https://www.turnkeylinux.org/download?file=turnkey-moodle-16.0-buster-amd64.iso
[9]: https://opensource.com/sites/default/files/uploads/virtualbox_new.png (Create a new VirtualBox)
[10]: https://creativecommons.org/licenses/by-sa/4.0/
[11]: https://opensource.com/sites/default/files/uploads/virtualbox_namevm.png (Naming the VirtualBox VM)
[12]: https://opensource.com/sites/default/files/uploads/virtualbox_attach-iso.png (Attaching Moodle.iso to VM)
[13]: https://opensource.com/sites/default/files/uploads/moodle_appliance.png (Moodle appliance settings)
[14]: https://opensource.com/article/20/9/firewall
[15]: https://opensource.com/sites/default/files/uploads/moodle_login.png (Moodle login screen)
[16]: https://opensource.com/sites/default/files/uploads/moodle_dashboard.png (Moodle admin dashboard)
[17]: https://opensource.com/sites/default/files/uploads/moodle_settings.png (Moodle settings)
[18]: https://opensource.com/sites/default/files/uploads/moodle_name-site.png (Name Moodle site)
[19]: https://opensource.com/sites/default/files/uploads/moodle_saved.png (Moodle changes saved)
[20]: https://opensource.com/sites/default/files/uploads/moodle_addcategory.png (Add category option in Moodle)
[21]: https://opensource.com/sites/default/files/uploads/moodle_addcourse.png (Add course option in Moodle)
[22]: https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol
[23]: https://www.shibboleth.net/
[24]: https://docs.moodle.org/39/en/Main_page
[25]: https://docs.moodle.org/39/en/Pedagogy#How_Moodle_tries_to_support_a_Social_Constructionist_view
[26]: https://opensource.com/article/20/9/teach-python-mu
[27]: https://opensource.com/sites/default/files/uploads/moodle_choosecourse.png (Moodle course list)
[28]: https://opensource.com/sites/default/files/uploads/moodle_addactivity_0.png (Add activity in Moodle)
[29]: https://opensource.com/sites/default/files/uploads/moodle_activitiesmenu.png (Moodle activities menu)
[30]: https://opensource.com/sites/default/files/uploads/moodle_activitieschecklist.png (Moodle activities checklist)
[31]: https://moodle.org/plugins/mod_bigbluebuttonbn
[32]: https://moodle.org/plugins/mod_jitsi
[33]: https://moodle.org/plugins/plagiarism_unicheck
[34]: https://moodle.org/plugins/local_obf
[35]: https://learn.moodle.org/
[36]: https://school.moodledemo.net/
[37]: https://git.in.moodle.com/moodle/moodle
[38]: https://git.in.moodle.com/moodle/moodle/-/blob/master/CONTRIBUTING.txt
[39]: https://download.moodle.org/mobile/
[40]: https://twitter.com/moodle
[41]: https://www.facebook.com/moodle
[42]: https://www.linkedin.com/company/moodle/

View File

@ -0,0 +1,99 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Try Linux on any computer with this bootable USB tool)
[#]: via: (https://opensource.com/article/20/10/fedora-media-writer)
[#]: author: (Sumantro Mukherjee https://opensource.com/users/sumantro)
Try Linux on any computer with this bootable USB tool
======
Fedora Media Writer is a hassle-free way to create a live USB to give
Linux a try.
![Multiple USB plugs in different colors][1]
[Fedora Media Writer][2] is a small, lightweight, comprehensive tool that simplifies the Linux getting-started experience. It downloads and writes Fedora Workstation or Server onto a USB drive that can boot up on any system, making it accessible for you to try Fedora Linux without having to install it to your hard drive.
The Media Writer tool can be used to create a live, bootable USB. After installing the Fedora Media Writer application on your platform, you can download and flash the latest stable version of Fedora Workstation or Server, or you can choose any other image you've downloaded. And it isn't limited to Intel 64-bit devices. It's also available for ARM devices, [such as the Raspberry Pi][3], which are becoming more powerful and useful every day.
![Fedora Media Writer main screen][4]
(Sumantro Mukherjee, [CC BY-SA 4.0][5])
### Install Fedora Media Writer
You have several options for [installing Fedora Media Writer][6]. You can [build it from source][7] on GitHub, download it for macOS or Windows, use an RPM with **dnf** or **yum**, or get it as a Flatpak.
On Fedora:
```
`$ sudo dnf install mediawriter`
```
See the [Releases][8] section of the GitHub repo for the latest version.
### Prepare your media
The first thing you need is a USB drive for your Linux OS to be installed onto. This is what Fedora Media Writer will flash. This drive must be either blank or expendable because **all data on the USB drive will be erased.** If there's any data—even just one file—that you don't want to lose, then you must back it up before continuing!
Once you've got a USB drive that you've confirmed is expendable, plug it into your computer and launch Fedora Media Writer.
### Use Fedora Media Writer
When you launch Fedora Media Writer, you're presented with a screen that prompts you to acquire a bootable image from the Internet, or to load a custom image from your hard drive. The first selections are the latest releases of Fedora: Workstation for desktops and laptops, and Server for virtualization, rack servers, or anything you want to run as a server.
Should you select one of the Fedora images, Media Writer downloads a disc image (usually called an "iso", after its filename extension of **.iso**) and saves it to your `Downloads` folder so you can reuse it to flash another drive if you want.
![Select your image][9]
Also available are Fedora Spins, which are images from the Fedora community meant to satisfy niche interests. For instance, if you're a fan of the [MATE desktop][10], then you'll be pleased to find a MATE "spin" available from Media Writer. There are many to choose from, so scroll through to see them all. If you're new to Linux, don't be overwhelmed or confused: the extra options are intended for longtime users who have developed preferences aside from the defaults, so it's safe for you to just use the Workstation or Server option depending on whether you want to run Fedora as a desktop or as a server OS.
If you need an image for a different CPU than the one you're currently using, select the CPU architecture from the drop-down menu in the upper-right corner of the window.
If you have an image saved to your hard drive already, select the **Custom Image** option and select the **.iso** file of the distribution you want to flash to USB.
### Writing to a USB drive
Once you've downloaded or selected an image, you must confirm that you want to write the image to your drive.
The drive selection drop-down menu only shows external drives, so there's no chance of you accidentally overwriting your own hard drive. This is an important feature of Fedora Media Writer, and one that makes it much safer than many manual instructions you might see elsewhere online. However, if you have more than one external drive attached to your computer, you should remove them all except the one you want to overwrite, just for added safety.
Select the drive you want the image to be installed onto, and click the **Write to Disk** button.
![Media write][11]
 
Wait a while for the image to be written to your drive, and then check out Don Watkins' excellent overview of [how to boot to Linux from a USB drive][12] .
### Get started with Linux
Fedora Media Writer is a way to flash Fedora Workstation or Server, or any Linux distribution, to a USB drive so you can try it out before you install it on your device. Give it a try, and share your experience and questions in the comments.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/10/fedora-media-writer
作者:[Sumantro Mukherjee][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/sumantro
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/usb-hardware.png?itok=ROPtNZ5V (Multiple USB plugs in different colors)
[2]: https://github.com/FedoraQt/MediaWriter
[3]: https://fedoraproject.org/wiki/Architectures/ARM/Raspberry_Pi
[4]: https://opensource.com/sites/default/files/uploads/fmw_mainscreen.png (Fedora Media Writer main screen)
[5]: https://creativecommons.org/licenses/by-sa/4.0/
[6]: https://docs.fedoraproject.org/en-US/fedora/f32/install-guide/install/Preparing_for_Installation/#_fedora_media_writer
[7]: https://github.com/FedoraQt/MediaWriter#building
[8]: https://github.com/FedoraQt/MediaWriter/releases
[9]: https://opensource.com/sites/default/files/mediawriter-image.png
[10]: https://opensource.com/article/19/12/mate-linux-desktop
[11]: https://opensource.com/sites/default/files/mediawriter-write.png (Media write)
[12]: https://opensource.com/article/20/4/first-linux-computer

View File

@ -0,0 +1,195 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Learn Python by creating a video game)
[#]: via: (https://opensource.com/article/20/10/learn-python-ebook)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Learn Python by creating a video game
======
Get to know Python the fun way using the step-by-step instructions in
our new eBook.
![Arcade games][1]
Python is one of the most popular programming languages out there. Whether you want to learn it for work or for fun, it's a powerful and useful language for any purpose. You can create applications to help you with daily tasks, fun games you and your friends can play, scripts to process data, applications to generate or parse information, and much more.
No matter what you intend to do with a programming language, we think it's more fun to learn by creating a game than by crunching numbers or transforming strings. And if you're completely new to programming, it's a lot easier to understand why you have to do something in code when you can see the code working in a familiar setting like a video game.
You may not select [Python][2] as the best programming language available (everyone has their own answer for that), but it is a relatively non-intimidating one. Python can use a lot of words (such as `is` and `is not`) instead of symbols (such as `=` and `!=`). It also manages many low-level tasks so that you usually don't have to worry about things like data types and garbage collection. This generally means you can get started coding without the upfront frustration that a complex language like [C][3] or [Java][4] presents.
To help you learn Python, we wrote an eBook showing how to create a platformer video game with it. Step through the lessons to learn Python while building a video game. As an additional benefit, you'll also learn about programming logic, syntax, operators, and more. You can see immediate results as you learn, so everything you learn is promptly reinforced.
### Python in a minute
Python is a general-purpose language, meaning it (like most languages) provides functions to do simple "tricks" with numbers and letters. Linux users already have Python installed. Mac users have an old version of Python, but you can [install the latest version][5] from the Python.org website. Windows users can learn to install Python from this [install Python on Windows][6] article.
Once installed, you can start an interactive Python shell and do math:
```
$ python3
>>> 5+6
11
>>> 11/2
5.5
>>> 11//2
5
>>> 11%2
1
```
As you can see from this sample, there's some special notation required, but it's mostly familiar to anyone comfortable with math. Maybe you're not a numbers person and prefer letters:
```
$ python3
>>> string = "hello world"
>>> print(string)
hello world
>>> print(string.upper())
HELLO WORLD
>>> print(string[0])
h
>>> print(string[1])
e
>>> print(string[2])
l
>>> print(string[3])
l
>>> print(string[4])
o
```
Again, there's special notation for relatively basic tasks, but even without an explanation, you probably already detected that the `[0]` and `[1]` notation enables you to "slice" data and `print` presents data on your screen.
### Pygame in five minutes
If you want to create a video game or anything beyond a basic calculator with Python alone, it could take a lot of study, work, and time. Luckily, Python's been around for a couple of decades, so people have developed libraries of code to help you perform typical programming feats with (comparatively) very little effort. [Pygame][7] is a set of code modules designed for creating video games. It's [not the only such library][8], but it's the oldest (for better and for worse), so there's a lot of documentation and examples online.
Start by learning the [recommended Python virtual environment workflow][9]:
```
$ python3 -m venv mycode/venv
$ cd mycode
$ source ./venv/bin/activate
(venv)$
```
Once you're in a virtual environment, you can safely install Pygame into your project folder:
```
(venv)$ echo "pygame" >> requirements.txt
(venv)$ python -m pip install -r requirements.txt
[...] Installing collected packages: pygame
Successfully installed pygame-x.y.z
```
Now that you have Pygame installed, you can create a simple demo application. It's easier than you think. Python can do what's called _object-oriented programming_ (OOP), which is a fancy computer science term to describe when code is structured as if you were creating physical objects with code. Programmers aren't deluded, though. They know they're not really making physical objects when they code, but it can help to imagine it that way because then you understand the limits of your programmed world.
For instance, if you were stranded on a desert island and wanted a coffee cup to appear, you'd have to harvest some clay, fashion a cup, and bake it. If you were very clever, you'll create a mold first so that whenever you want another cup, you can quickly create a new one from your template. Even though each cup came from the same template, they would be physically independent: should one break, you still have others. And you could make each coffee cup appear unique by adding color or etchings.
In Pygame, and in many programming tasks, you use similar logic. A thing can't appear in your programmed world until you define it. Here's how to make a coffee cup appear in a Python and Pygame program.
#### Object-oriented programming with Pygame
Create a new file called `main.py` and enter this code to initiate the Pygame module and to use a Pygame template to create a window:
```
import pygame
pygame.init()
screen = pygame.display.set_mode((960,720))
```
Just as you might use a template to create an object in real life, you use a template provided by Pygame to create a _sprite_ (which is Pygame's term for a visual game object). In object-oriented programming, a _class_ represents a template for an object. Type this code into your document:
```
class Cup(pygame.sprite.Sprite):
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)
        # image
        img = pygame.image.load('coffeecup.png').convert()
        self.image = img
        # volume
        self.rect = self.image.get_rect()
        self.rect.x = 10
        self.rect.y = 10
```
This code block uses Pygame's `sprite` template to design a coffee cup sprite. Your coffee cup sprite has an image because of `self.image`, while `self.rect` gives it volume (width and height). These are attributes Pygame expects a sprite to possess, but if you were creating a playable video game, you could give it any other attribute you want, such as health points and a score.
All you've done so far is create a window and the _template_ for a coffee cup. Your game doesn't actually _make_ a cup yet.
The last part of your code must use your template to generate a cup and add it to your game world. As you may know, computers are very fast, so technically, the code you've created so far would only run for a millisecond or so. When writing a graphical computer application, you must force the computer to remain open whether or not it thinks it has completed the prescribed tasks. Programmers do this with an _infinite loop_, which in Python is represented by the instruction `while True` (True is always true, so the loop never ends).
An infinite loop ensures your application stays open long enough for the computer user to see and use the application:
```
cup = Cup()
while True:
    pygame.display.update()
    screen.blit(cup.image, cup.rect)
```
This code sample creates a cup from your template `Cup` and then updates the display using a Pygame function. Finally, it draws the cup's image within its bounding box using Pygame's `blit` function.
#### Get a graphic
Before you can run the code successfully, you need a graphic for your coffee cup. You can find lots of [Creative Commons][10] coffee cup graphics on [FreeSVG.org][11]. I used [this one][12]. Save the graphic in your project directory, and call it `coffeecup.png`.
#### Run the game
Launch your application:
```
`(venv)$ python ./main.py`
```
![Coffee cup in Pygame][13]
(Seth Kenlon, [CC BY-SA 4.0][14])
### [Download the Python gaming eBook][15]
Pygame is a powerful framework, and there's a lot more you can do with it than just draw coffee cups on your screen. [Download our free eBook][15] to get to know Pygame—and Python itself—better.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/10/learn-python-ebook
作者:[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/arcade_game_gaming.jpg?itok=84Rjk_32 (Arcade games)
[2]: https://www.python.org/
[3]: https://opensource.com/article/20/8/c-programming-cheat-sheet
[4]: https://opensource.com/resources/java
[5]: https://www.python.org/downloads/mac-osx
[6]: https://opensource.com/article/19/8/how-install-python-windows
[7]: https://www.pygame.org/news
[8]: https://opensource.com/article/18/4/easy-2d-game-creation-python-and-arcade
[9]: https://opensource.com/article/20/9/venv-python
[10]: https://opensource.com/article/20/1/what-creative-commons
[11]: http://freesvg.org
[12]: https://freesvg.org/1548870028
[13]: https://opensource.com/sites/default/files/uploads/pygame-cup.jpg (Coffee cup in Pygame)
[14]: https://creativecommons.org/licenses/by-sa/4.0/
[15]: https://opensource.com/downloads/python-gaming-ebook

View File

@ -0,0 +1,117 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Install MariaDB or MySQL on Linux)
[#]: via: (https://opensource.com/article/20/10/mariadb-mysql-linux)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
在 Linux 上安装 MariaDB 或 MySQL
======
开始在 Linux 系统上使用开源的 SQL 数据库。
![Person standing in front of a giant computer screen with numbers, data][1]
[MariaDB][2] 和 [MySQL][3] 都是使用 SQL 的开源数据库并且共享相同的原始代码库。MariaDB 是 MySQL 的替代品,因此你可以使用相同的命令 `mysql` 与 MySQL 和 MariaDB 数据库进行交互。因此,本文同时适用于 MariaDB 和 MySQL。
### 安装 MariaDB
你可以使用你的 Linux 发行版的包管理器安装 MariaDB。在大多数发行版上MariaDB 分为服务器包和客户端包。服务器包提供了数据库”引擎“,即 MariaDB 在后台运行(通常在物理服务器上)的部分,它监听数据输入或数据输出请求。客户端包提供了 `mysql` 命令,你可以用它来与服务器通信。
在 RHEL、Fedora、CentOS 或类似的发行版上:
```
`$ sudo dnf install mariadb mariadb-server`
```
在 Debian、Ubuntu、Elementary 或类似的发行版上:
```
`$ sudo apt install mariadb-client mariadb-server`
```
其他系统可能会以不同的系统打包 MariaDB所以你可能需要搜索你的软件仓库来了解你的发行版的维护者是如何提供它的。
### 启动 MariaDB
因为 MariaDB 被设计成一部分作为数据库服务器的功能,它可以在一台计算机上运行,并从另一台计算机上进行管理。只要你能访问运行它的计算机,你就可以使用 `mysql` 命令来管理数据库。在写这篇文章时,我在本地计算机上运行了 MariaDB但你同样可能会与远程系统上托管的 MariaDB 数据库进行交互。
在启动 MariaDB 之前,你必须创建一个初始数据库。在初始化其文件结构时,你应该定义你希望 MariaDB 使用的用户。默认情况下MariaDB 使用当前用户,但你可能希望它使用一个专用的用户帐户。你的包管理器可能为你配置了一个系统用户和组。使用 `grep` 查找是否有一个 `mysql` 组:
```
$ grep mysql /etc/group
mysql❌27:
```
你也可以在 `/etc/passwd` 中寻找这个专门的用户,但通常情况下,有组的地方就有用户。如果没有专门的 `mysql` 用户和组,可以在 `/etc/group` 中寻找一个明显的替代(比如 `mariadb`)。如果没有,请阅读你的发行版文档来了解 MariaDB 是如何运行的。
假设你的安装使用 `mysql`,初始化数据库环境:
```
$ sudo mysql_install_db --user=mysql
Installing MariaDB/MySQL system tables in '/var/lib/mysql'...
OK
[...]
```
这一步的结果显示了接下来你必须执行的配置 MariaDB 的任务:
```
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h $(hostname) password 'new-password'
Alternatively you can run:
'/usr/bin/mysql_secure_installation'
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
```
使用你的发行版的 init 系统启动 MariaDB
```
`$ sudo systemctl start mariadb`
```
在启动时启用 MariaDB 服务器:
```
`$ sudo systemctl enable --now mariadb`
```
现在你已经有了一个 MariaDB 服务器,为它设置一个密码:
```
mysqladmin -u root password 'myreallysecurepassphrase'
mysqladmin -u root -h $(hostname) password 'myreallysecurepassphrase'
```
最后,如果你打算在生产服务器上使用它,请在上线前运行 `mysql_secure_installation` 命令。
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/10/mariadb-mysql-linux
作者:[Seth Kenlon][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/seth
[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://mariadb.org/
[3]: https://www.mysql.com/