Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang 2019-10-14 11:40:53 +08:00
commit fb3a2fc8db
11 changed files with 617 additions and 640 deletions

View File

@ -0,0 +1,221 @@
[#]: collector: (lujun9972)
[#]: translator: (wxy)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11456-1.html)
[#]: subject: (7 Bash history shortcuts you will actually use)
[#]: via: (https://opensource.com/article/19/10/bash-history-shortcuts)
[#]: author: (Ian Miell https://opensource.com/users/ianmiell)
7 个实用的操作 Bash 历史记录的快捷方式
======
> 这些必不可少的 Bash 快捷键可在命令行上节省时间。
![Command line prompt][1]
大多数介绍 Bash 历史记录的指南都详尽地列出了全部可用的快捷方式。这样做的问题是,你会对每个快捷方式都浅尝辄止,然后在尝试了那么多的快捷方式后就搞得目不暇接。而在开始工作时它们就全被丢在脑后,只记住了刚开始使用 Bash 时学到的 [!! 技巧][2]。这些技巧大多数从未进入记忆当中。
本文概述了我每天实际使用的快捷方式。它基于我的书《[Bash 学习,艰难之旅][3]》中的某些内容(你可以阅读其中的[样章][4]以了解更多信息)。
当人们看到我使用这些快捷方式时,他们经常问我:“你做了什么!?” 学习它们只需付出很少的精力或智力,但是要真正的学习它们,我建议每周用一天学一个,然后下次再继续学习一个。值得花时间让它们落在你的指尖下,因为从长远来看,节省的时间将很重要。
### 1、最后一个参数`!$`
如果你仅想从本文中学习一种快捷方式,那就是这个。它会将最后一个命令的最后一个参数替换到你的命令行中。
看看这种情况:
```
$ mv /path/to/wrongfile /some/other/place
mv: cannot stat '/path/to/wrongfile': No such file or directory
```
啊哈,我在命令中写了错误的文件名 “wrongfile”我应该用正确的文件名 “rightfile” 代替。
你可以重新键入上一个命令,并用 “rightfile” 完全替换 “wrongfile”。但是你也可以键入
```
$ mv /path/to/rightfile !$
mv /path/to/rightfile /some/other/place
```
这个命令也可以奏效。
在 Bash 中还有其他方法可以通过快捷方式实现相同的目的,但是重用上一个命令的最后一个参数的这种技巧是我最常使用的。
### 2、第 n 个参数:`!:2`
是不是干过像这样的事情:
```
$ tar -cvf afolder afolder.tar
tar: failed to open
```
像许多其他人一样,我也经常搞错 `tar`(和 `ln`)的参数顺序。
![xkcd comic][5]
当你搞混了参数,你可以这样:
```
$ !:0 !:1 !:3 !:2
tar -cvf afolder.tar afolder
```
这样就不会出丑了。
上一个命令的各个参数的索引是从零开始的,并且可以用 `!:` 之后跟上该索引数字代表各个参数。
显然,你也可以使用它来重用上一个命令中的特定参数,而不是所有参数。
### 3、全部参数`!:1-$`
假设我运行了类似这样的命令:
```
$ grep '(ping|pong)' afile
```
参数是正确的。然而,我想在文件中匹配 “ping” 或 “pong”但我使用的是 `grep` 而不是 `egrep`
我开始输入 `egrep`,但是我不想重新输入其他参数。因此,我可以使用 `!:1-$` 快捷方式来调取上一个命令的所有参数,从第二个(记住它们的索引从零开始,因此是 `1`)到最后一个(由 `$` 表示)。
```
$ egrep !:1-$
egrep '(ping|pong)' afile
ping
```
你不用必须用 `1-$` 选择全部参数;你也可以选择一个子集,例如 `1-2``3-9` (如果上一个命令中有那么多参数的话)。
### 4、倒数第 n 行的最后一个参数:`!-2:$`
当我输错之后马上就知道该如何更正我的命令时,上面的快捷键非常有用,但是我经常在原来的命令之后运行别的命令,这意味着上一个命令不再是我所要引用的命令。
例如,还是用之前的 `mv` 例子,如果我通过 `ls` 检查文件夹的内容来纠正我的错误:
```
$ mv /path/to/wrongfile /some/other/place
mv: cannot stat '/path/to/wrongfile': No such file or directory
$ ls /path/to/
rightfile
```
我就不能再使用 `!$` 快捷方式了。
在这些情况下,我可以在 `!` 之后插入 `-n`:(其中 `n` 是要在历史记录中回溯的命令条数),以从较旧的命令取得最后的参数:
```
$ mv /path/to/rightfile !-2:$
mv /path/to/rightfile /some/other/place
```
同样,一旦你学会了它,你可能会惊讶于你需要使用它的频率。
### 5、进入文件夹`!$:h`
从表面上看,这个看起来不太有用,但我每天要用它几十次。
想象一下,我运行的命令如下所示:
```
$ tar -cvf system.tar /etc/system
 tar: /etc/system: Cannot stat: No such file or directory
 tar: Error exit delayed from previous errors.
```
我可能要做的第一件事是转到 `/etc` 文件夹,查看其中的内容并找出我做错了什么。
我可以通过以下方法来做到这一点:
```
$ cd !$:h
cd /etc
```
这是说:“获取上一个命令的最后一个参数(`/etc/system`),并删除其最后的文件名部分,仅保留 `/ etc`。”
### 6、当前行`!#:1`
多年以来,在我最终找到并学会之前,我有时候想知道是否可以在当前行引用一个参数。我多希望我能早早学会这个快捷方式。我经常常使用它制作备份文件:
```
$ cp /path/to/some/file !#:1.bak
cp /path/to/some/file /path/to/some/file.bak
```
但当我学会之后,它很快就被下面的快捷方式替代了……
### 7、搜索并替换`!!:gs`
这将搜索所引用的命令,并将前两个 `/` 之间的字符替换为后两个 `/` 之间的字符。
假设我想告诉别人我的 `s` 键不起作用,而是输出了 `f`
```
$ echo my f key doef not work
my f key doef not work
```
然后我意识到这里出现的 `f` 键都是错的。要将所有 `f` 替换为 `s`,我可以输入:
```
$ !!:gs/f /s /
echo my s key does not work
my s key does not work
```
它不只对单个字符起作用。我也可以替换单词或句子:
```
$ !!:gs/does/did/
echo my s key did not work
my s key did not work
```
### 测试一下
为了向你展示如何组合这些快捷方式,你知道这些命令片段将输出什么吗?
```
$ ping !#:0:gs/i/o
$ vi /tmp/!:0.txt
$ ls !$:h
$ cd !-2:$:h
$ touch !$!-3:$ !! !$.txt
$ cat !:1-$
```
### 总结
对于日常的命令行用户Bash 可以作为快捷方式的优雅来源。虽然有成千上万的技巧要学习,但这些是我经常使用的最喜欢的技巧。
如果你想更深入地了解 Bash 可以教给你的全部知识,请买本我的书,《[Bash 学习,艰难之旅][3]》,或查看我的在线课程《[精通 Bash shell][7]》。
* * *
本文最初发布在 Ian 的博客 [Zwischenzugs.com][8] 上,并经允许重复发布。
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/10/bash-history-shortcuts
作者:[Ian Miell][a]
选题:[lujun9972][b]
译者:[wxy](https://github.com/wxy)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/ianmiell
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/command_line_prompt.png?itok=wbGiJ_yg (Command line prompt)
[2]: https://opensource.com/article/18/5/bash-tricks
[3]: https://leanpub.com/learnbashthehardway
[4]: https://leanpub.com/learnbashthehardway/read_sample
[5]: https://opensource.com/sites/default/files/uploads/tar_2x.png (xkcd comic)
[6]: https://xkcd.com/1168/
[7]: https://www.educative.io/courses/master-the-bash-shell
[8]: https://zwischenzugs.com/2019/08/25/seven-god-like-bash-history-shortcuts-you-will-actually-use/

View File

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

View File

@ -1,78 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (The lifecycle of Linux kernel testing)
[#]: via: (https://opensource.com/article/19/8/linux-kernel-testing)
[#]: author: (Major Hayden https://opensource.com/users/mhaydenhttps://opensource.com/users/mhaydenhttps://opensource.com/users/marcobravohttps://opensource.com/users/mhayden)
The lifecycle of Linux kernel testing
======
The Continuous Kernel Integration (CKI) project aims to prevent bugs
from entering the Linux kernel.
![arrows cycle symbol for failing faster][1]
In _[Continuous integration testing for the Linux kernel][2]_, I wrote about the [Continuous Kernel Integration][3] (CKI) project and its mission to change how kernel developers and maintainers work. This article is a deep dive into some of the more technical aspects of the project and how all the pieces fit together.
### It all starts with a change
Every exciting feature, improvement, and bug in the kernel starts with a change proposed by a developer. These changes appear on myriad mailing lists for different kernel repositories. Some repositories focus on certain subsystems in the kernel, such as storage or networking, while others focus on broad aspects of the kernel. The CKI project springs into action when developers propose a change, or patchset, to the kernel or when a maintainer makes changes in the repository itself.
The CKI project maintains triggers that monitor these patchsets and take action. Software projects such as [Patchwork][4] make this process much easier by collating multi-patch contributions into a single patch series. This series travels as a unit through the CKI system and allows for publishing a single report on the series.
Other triggers watch the repository for changes. This occurs when kernel maintainers merge patchsets, revert patches, or create new tags. Testing these critical changes ensures that developers always have a solid baseline to use as a foundation for writing new patches.
All of these changes make their way into a GitLab pipeline and pass through multiple stages and multiple systems.
### Prepare the build
Everything starts with getting the source ready for compile time. This requires cloning the repository, applying the patchset proposed by the developer, and generating a kernel config file. These config files have thousands of options that turn features on or off, and config files differ incredibly between different system architectures. For example, a fairly standard x86_64 system may have a ton of options available in its config file, but an s390x system (IBM zSeries mainframes) likely has much fewer options. Some options might make sense on that mainframe but they have no purpose on a consumer laptop.
The kernel moves forward and transforms into a source artifact. The artifact contains the entire repository, with patches applied, and all kernel configuration files required for compiling. Upstream kernels move on as a tarball, while Red Hat kernels become a source RPM for the next step.
### Piles of compiles
Compiling the kernel turns the source code into something that a computer can boot up and use. The config file describes what to build, scripts in the kernel describe how to build it, and tools on the system (like GCC and glibc) do the building. This process takes a while to complete, but the CKI project needs it done quickly for four architectures: aarch64 (64-bit ARM), ppc64le (POWER), s390x (IBM zSeries), and x86_64. It's important that we compile kernels quickly so that we keep our backlog manageable and developers receive prompt feedback.
Adding more CPUs provides plenty of speed improvements, but every system has its limits. The CKI project compiles kernels within containers in an OpenShift deployment; although OpenShift allows for tons of scalability, the deployment still has a finite number of CPUs available. The CKI team allocates 20 virtual CPUs for compiling each kernel. With four architectures involved, this balloons to 80 CPUs!
Another speed increase comes from a tool called [ccache][5]. Kernel development moves quickly, but a large amount of the kernel remains unchanged even between multiple releases. The ccache tool caches the built objects (small pieces of the overall kernel) during the compile on a disk. When another kernel compile comes along later, ccache looks for unchanged pieces of the kernel that it saw before. Ccache pulls the cached object from the disk and reuses it. This allows for faster compiles and lower overall CPU usage. Kernels that took 20 minutes to compile now race to the finish line in less than a few minutes.
### Testing time
The kernel moves onto its last step: testing on real hardware. Each kernel boots up on its native architecture using Beaker, and myriad tests begin poking it to find problems. Some tests look for simple problems, such as issues with containers or error messages on boot-up. Other tests dive deep into various kernel subsystems to find regressions in system calls, memory allocation, and threading.
Large testing frameworks, such as the [Linux Test Project][6] (LTP), contain tons of tests that look for troublesome regressions in the kernel. Some of these regressions could roll back critical security fixes, and there are tests to ensure those improvements remain in the kernel.
One critical step remains when tests finish: reporting. Kernel developers and maintainers need a concise report that tells them exactly what worked, what did not work, and how to get more information. Each CKI report contains details about the source code used, the compile parameters, and the testing output. That information helps developers know where to begin looking to fix an issue. Also, it helps maintainers know when a patchset needs to be held for another look before a bug makes its way into their kernel repository.
### Summary
The CKI project team strives to prevent bugs from entering the Linux kernel by providing timely, automated feedback to kernel developers and maintainers. This work makes their job easier by finding the low-hanging fruit that leads to kernel bugs, security issues, and performance problems.
* * *
_To learn more, you can attend the [CKI Hackfest][7] on September 12-13 following the [Linux Plumbers Conference][8] September 9-11 in Lisbon, Portugal._
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/8/linux-kernel-testing
作者:[Major Hayden][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/mhaydenhttps://opensource.com/users/mhaydenhttps://opensource.com/users/marcobravohttps://opensource.com/users/mhayden
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fail_progress_cycle_momentum_arrow.png?itok=q-ZFa_Eh (arrows cycle symbol for failing faster)
[2]: https://opensource.com/article/19/6/continuous-kernel-integration-linux
[3]: https://cki-project.org/
[4]: https://github.com/getpatchwork/patchwork
[5]: https://ccache.dev/
[6]: https://linux-test-project.github.io
[7]: https://cki-project.org/posts/hackfest-agenda/
[8]: https://www.linuxplumbersconf.org/

View File

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

View File

@ -1,236 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (7 Bash history shortcuts you will actually use)
[#]: via: (https://opensource.com/article/19/10/bash-history-shortcuts)
[#]: author: (Ian Miell https://opensource.com/users/ianmiell)
7 Bash history shortcuts you will actually use
======
Save time on the command line with these essential Bash shortcuts.
![Command line prompt][1]
Most guides to Bash history shortcuts exhaustively list every single one available. The problem with that is I would use a shortcut once, then glaze over as I tried out all the possibilities. Then I'd move onto my working day and completely forget them, retaining only the well-known [**!!** trick][2] I learned when I first started using Bash.
So most of them were never committed to memory.
This article outlines the shortcuts I _actually use_ every day. It is based on some of the contents of my book, [_Learn Bash the hard way_][3]; (you can read a [preview][4] of it to learn more).
When people see me use these shortcuts, they often ask me, "What did you do there!?" There's minimal effort or intelligence required, but to really learn them, I recommend using one each day for a week, then moving to the next one. It's worth taking your time to get them under your fingers, as the time you save will be significant in the long run.
### 1\. The "last argument" one: !$
If you only take one shortcut from this article, make it this one. It substitutes in the last argument of the last command into your line.
Consider this scenario:
```
$ mv /path/to/wrongfile /some/other/place
mv: cannot stat '/path/to/wrongfile': No such file or directory
```
Ach, I put the **wrongfile** filename in my command. I should have put **rightfile** instead.
You might decide to retype the last command and replace wrongfile with rightfile completely. Instead, you can type:
```
$ mv /path/to/rightfile !$
mv /path/to/rightfile /some/other/place
```
and the command will work.
There are other ways to achieve the same thing in Bash with shortcuts, but this trick of reusing the last argument of the last command is one I use the most.
### 2\. The "_n_th argument" one: !:2
Ever done anything like this?
```
$ tar -cvf afolder afolder.tar
tar: failed to open
```
Like many others, I get the arguments to **tar** (and **ln**) wrong more often than I would like to admit.
[![xkcd comic][5]][6]
When you mix up arguments like that, you can run:
```
$ !:0 !:1 !:3 !:2
tar -cvf afolder.tar afolder
```
and your reputation will be saved.
The last command's items are zero-indexed and can be substituted in with the number after the **!:**.
Obviously, you can also use this to reuse specific arguments from the last command rather than all of them.
### 3\. The "all the arguments" one: !:1-$
Imagine I run a command like:
```
`$ grep '(ping|pong)' afile`
```
The arguments are correct; however, I want to match **ping** or **pong** in a file, but I used **grep** rather than **egrep**.
I start typing **egrep**, but I don't want to retype the other arguments. So I can use the **!:1$** shortcut to ask for all the arguments to the previous command from the second one (remember theyre zero-indexed) to the last one (represented by the **$** sign).
```
$ egrep !:1-$
egrep '(ping|pong)' afile
ping
```
You don't need to pick **1-$**; you can pick a subset like **1-2** or **3-9** (if you had that many arguments in the previous command).
### 4\. The "last but _n_" one: !-2:$
The shortcuts above are great when I know immediately how to correct my last command, but often I run commands _after_ the original one, which means that the last command is no longer the one I want to reference.
For example, using the **mv** example from before, if I follow up my mistake with an **ls** check of the folder's contents:
```
$ mv /path/to/wrongfile /some/other/place
mv: cannot stat '/path/to/wrongfile': No such file or directory
$ ls /path/to/
rightfile
```
I can no longer use the **!$** shortcut.
In these cases, I can insert a **-_n_:** (where _**n**_ is the number of commands to go back in the history) after the **!** to grab the last argument from an older command:
```
$ mv /path/to/rightfile !-2:$
mv /path/to/rightfile /some/other/place
```
Again, once you learn it, you may be surprised at how often you need it.
### 5\. The "get me the folder" one: !$:h
This one looks less promising on the face of it, but I use it dozens of times daily.
Imagine I run a command like this:
```
$ tar -cvf system.tar /etc/system
 tar: /etc/system: Cannot stat: No such file or directory
 tar: Error exit delayed from previous errors.
```
The first thing I might want to do is go to the **/etc** folder to see what's in there and work out what I've done wrong.
I can do this at a stroke with:
```
$ cd !$:h
cd /etc
```
This one says: "Get the last argument to the last command (**/etc/system**) and take off its last filename component, leaving only the **/etc**."
### 6\. The "the current line" one: !#:1
For years, I occasionally wondered if I could reference an argument on the current line before finally looking it up and learning it. I wish I'd done so a long time ago. I most commonly use it to make backup files:
```
$ cp /path/to/some/file !#:1.bak
cp /path/to/some/file /path/to/some/file.bak
```
but once under the fingers, it can be a very quick alternative to …
### 7\. The "search and replace" one: !!:gs
This one searches across the referenced command and replaces what's in the first two **/** characters with what's in the second two.
Say I want to tell the world that my **s** key does not work and outputs **f** instead:
```
$ echo my f key doef not work
my f key doef not work
```
Then I realize that I was just hitting the **f** key by accident. To replace all the **f**s with **s**es, I can type:
```
$ !!:gs/f /s /
echo my s key does not work
my s key does not work
```
It doesn't work only on single characters; I can replace words or sentences, too:
```
$ !!:gs/does/did/
echo my s key did not work
my s key did not work
```
### Test them out
Just to show you how these shortcuts can be combined, can you work out what these toenail clippings will output?
```
$ ping !#:0:gs/i/o
$ vi /tmp/!:0.txt
$ ls !$:h
$ cd !-2:h
$ touch !$!-3:$ !! !$.txt
$ cat !:1-$
```
### **Conclusion**
Bash can be an elegant source of shortcuts for the day-to-day command-line user. While there are thousands of tips and tricks to learn, these are my favorites that I frequently put to use.
If you want to dive even deeper into all that Bash can teach you, pick up my book, [_Learn Bash the hard way_][3] or check out my online course, [Master the Bash shell][7].
* * *
_This article was originally posted on Ian's blog, [Zwischenzugs.com][8], and is reused with permission._
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/10/bash-history-shortcuts
作者:[Ian Miell][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/ianmiell
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/command_line_prompt.png?itok=wbGiJ_yg (Command line prompt)
[2]: https://opensource.com/article/18/5/bash-tricks
[3]: https://leanpub.com/learnbashthehardway
[4]: https://leanpub.com/learnbashthehardway/read_sample
[5]: https://opensource.com/sites/default/files/uploads/tar_2x.png (xkcd comic)
[6]: https://xkcd.com/1168/
[7]: https://www.educative.io/courses/master-the-bash-shell
[8]: https://zwischenzugs.com/2019/08/25/seven-god-like-bash-history-shortcuts-you-will-actually-use/

View File

@ -1,192 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Install and Configure VNC Server on Centos 8 / RHEL 8)
[#]: via: (https://www.linuxtechi.com/install-configure-vnc-server-centos8-rhel8/)
[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/)
How to Install and Configure VNC Server on Centos 8 / RHEL 8
======
A **VNC** (Virtual Network Computing) Server is a GUI based desktop sharing platform that allows you to access remote desktop machines. In **Centos 8** and **RHEL 8** systems, VNC servers are not installed by default and need to be installed manually. In this article, well look at how to install VNC Server on CentOS 8 / RHEL 8 systems with a simple step-by-step installation guide.
### Prerequisites to Install VNC Server on Centos 8 / RHEL 8
To install VNC Server in your system, make sure you have the following requirements readily available on your system:
* CentOS 8 / RHEL 8
* GNOME Desktop Environment
* Root access
* DNF / YUM Package repositories
### Step by Step Guide to Install VNC Server on Centos 8 / RHEL 8
### Step 1)  Install GNOME Desktop environment
Before installing VNC Server in your CentOS 8 / RHEL 8, make sure you have a desktop Environment (DE) installed. In case GNOME desktop is already installed or you have installed your server with gui option then you can skip this step.
In CentOS 8 / RHEL 8, GNOME is the default desktop environment. if you dont have it in your system, install it using the following command:
```
[root@linuxtechi ~]# dnf groupinstall "workstation"
Or
[root@linuxtechi ~]# dnf groupinstall "Server with GUI
```
Once the above packages are installed successfully then run the following command to enable the graphical mode
```
[root@linuxtechi ~]# systemctl set-default graphical
```
Now reboot the system so that we get GNOME login screen.
```
[root@linuxtechi ~]# reboot
```
Once the system is rebooted successfully uncomment the line “**WaylandEnable=false**” from the file “**/etc/gdm/custom.conf**” so that remote desktop session request via vnc is handled by xorg of GNOME desktop in place of wayland display manager.
**Note:** Wayland is the default display manager (GDM) in GNOME and it not is configured to handled remote rendering API like X.org
### Step 2) Install VNC Server (tigervnc-server)
Next well install the VNC Server, there are lot of VNC Servers available, and for installation purposes, well be installing **TigerVNC Server**. It is one of the most popular VNC Server and a high-performance and platform-independent VNC that allows users to interact with remote machines easily.
Now install TigerVNC Server using the following command:
```
[root@linuxtechi ~]# dnf install tigervnc-server tigervnc-server-module -y
```
### Step 3) Set VNC Password for Local User
Lets assume we want pkumar user to use VNC for remote desktop session, then switch to the user and set its password using vncpasswd command,
```
[root@linuxtechi ~]# su - pkumar
[root@linuxtechi ~]$ vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
[root@linuxtechi ~]$
[root@linuxtechi ~]$ exit
logout
[root@linuxtechi ~]#
```
### Step 4) Setup VNC Server Configuration File
Next step is to configure VNC Server Configuration file. Create a file “**/etc/systemd/system/[root@linuxtechi][1]**” with the following content so that tigervnc-servers service started for above local user “pkumar”.
```
[root@linuxtechi ~]# vim /etc/systemd/system/root@linuxtechi
[Unit]
Description=Remote Desktop VNC Service
After=syslog.target network.target
[Service]
Type=forking
WorkingDirectory=/home/pkumar
User=pkumar
Group=pkumar
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver -autokill %i
ExecStop=/usr/bin/vncserver -kill %i
[Install]
WantedBy=multi-user.target
```
Save and exit the file,
**Note:** Replace the user name in above file which suits to your setup.
By default, VNC server listen on tcp port 5900+n, where n is the display number, if the display number is “1” then VNC server will listen its request on TCP port 5901.
### Step 5) Start VNC Service and allow port in firewall
I am using display number as 1, so use the following commands to start and enable vnc service on display number “1”,
```
[root@linuxtechi ~]# systemctl daemon-reload
[root@linuxtechi ~]# systemctl start root@linuxtechi:1.service
[root@linuxtechi ~]# systemctl enable vnroot@linuxtechi:1.service
Created symlink /etc/systemd/system/multi-user.target.wants/root@linuxtechi:1.service → /etc/systemd/system/root@linuxtechi
[root@linuxtechi ~]#
```
Use below **netstat** or **ss** command to verify whether VNC server start listening its request on 5901,
```
[root@linuxtechi ~]# netstat -tunlp | grep 5901
tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 8169/Xvnc
tcp6 0 0 :::5901 :::* LISTEN 8169/Xvnc
[root@linuxtechi ~]# ss -tunlp | grep -i 5901
tcp LISTEN 0 5 0.0.0.0:5901 0.0.0.0:* users:(("Xvnc",pid=8169,fd=6))
tcp LISTEN 0 5 [::]:5901 [::]:* users:(("Xvnc",pid=8169,fd=7))
[root@linuxtechi ~]#
```
Use below systemctl command to verify the status of VNC server,
```
[root@linuxtechi ~]# systemctl status root@linuxtechi:1.service
```
![vncserver-status-centos8-rhel8][2]
Above commands output confirms that VNC is started successfully on port tcp port 5901. Use the following command allow VNC Server port “5901” in os firewall,
```
[root@linuxtechi ~]# firewall-cmd --permanent --add-port=5901/tcp
success
[root@linuxtechi ~]# firewall-cmd --reload
success
[root@linuxtechi ~]#
```
### Step 6) Connect to Remote Desktop Session
Now we are all set to see if the remote desktop connection is working. To access the remote desktop, Start the VNC Viewer from your Windows  / Linux workstation and enter your **VNC server IP Address** and **Port Number** and then hit enter
[![VNC-Viewer-Windows10][2]][3]
Next, it will ask for your VNC password. Enter the password that you have created earlier for your local user and click OK to continue
[![VNC-Viewer-Connect-CentOS8-RHEL8-VNC-Server][2]][4]
Now you can see the remote desktop,
[![VNC-Desktop-Screen-CentOS8][2]][5]
Thats it, youve successfully installed VNC Server in Centos 8 / RHEL 8.
**Conclusion**
Hope the step-by-step guide to install VNC server on Centos 8 / RHEL 8 has provided you with all the information to easily setup VNC Server and access remote desktops. Please provide your comments and suggestion in the feedback section below. See you in the next article…Until then a big THANK YOU and BYE for now!!!
--------------------------------------------------------------------------------
via: https://www.linuxtechi.com/install-configure-vnc-server-centos8-rhel8/
作者:[Pradeep Kumar][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.linuxtechi.com/author/pradeep/
[b]: https://github.com/lujun9972
[1]: https://www.linuxtechi.com/cdn-cgi/l/email-protection
[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
[3]: https://www.linuxtechi.com/wp-content/uploads/2019/10/VNC-Viewer-Windows10.jpg
[4]: https://www.linuxtechi.com/wp-content/uploads/2019/10/VNC-Viewer-Connect-CentOS8-RHEL8-VNC-Server.jpg
[5]: https://www.linuxtechi.com/wp-content/uploads/2019/10/VNC-Desktop-Screen-CentOS8.jpg

View File

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

View File

@ -1,131 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Unzip a Zip File in Linux [Beginners Tutorial])
[#]: via: (https://itsfoss.com/unzip-linux/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
How to Unzip a Zip File in Linux [Beginners Tutorial]
======
_**Brief: This quick tip shows you how to unzip a file in Ubuntu and other Linux distributions. Both terminal and GUI methods have been discussed.**_
[Zip][1] is one of the most common and most popular way to create compressed archive files. It is also one of the older archive file format that was created in 1989. Since it is widely used, youll regularly come across a zip file.
In an earlier tutorial, I showed [how to zip a folder in Linux][2]. In this quick tutorial for beginners, Ill show you how to unzip files in Linux.
**Prerequisite: Verify if you have unzip installed**
In order to unzip a zip archive file, you must have the unzip package installed in your system. Most modern Linux distributions come with uzip support but there is no harm in verifying it to avoid bad surprises later.
In [Ubuntu][3] and [Debian][4] based distributions, you can use the command below to install unzip. If its already installed, youll be notified about it.
```
sudo apt install unzip
```
Once you have made sure that your system has unzip support, its time to unzip a zip file in Linux.
You can use both command line and GUI for this purpose and Ill show you both methods.
* [Unzip files in Linux terminal][5]
* [Unzip files in Ubuntu via GUI][6]
### Unzip file in Linux command line
Using unzip command in Linux is absolutely simple. In the directory, where you have the zip file, use this command:
```
unzip zipped_file.zip
```
You can also provide the path to the zip file instead of going to the directory. Youll see extracted files in the output:
```
unzip metallic-container.zip -d my_zip
Archive: metallic-container.zip
inflating: my_zip/625993-PNZP34-678.jpg
inflating: my_zip/License free.txt
inflating: my_zip/License premium.txt
```
There is a slight problem with the above command. It will extract all the contents of the zip file in the current directory. Thats not a pretty thing to do because youll have a handful of files leaving the current directory unorganized.
#### Unzip to directory
A good practice is to unzip to directory in Linux command line. This way, all the extracted files are stored in the directory you specified. If the directory doesnt exist, it will create one.
```
unzip zipped_file.zip -d unzipped_directory
```
Now all the contents of the zipped_file.zip will be extracted to unzipped_directory.
Since we are discussing good practices, another tip you can use is to have a look at the content of the zip file without actually extracting it.
#### See the content of zip file without unzipping it
You can check the content of the zip file without even extracting it with the option -l.
```
unzip -l zipped_file.zip
```
Heres a sample output:
```
unzip -l metallic-container.zip
Archive: metallic-container.zip
Length Date Time Name
--------- ---------- ----- ----
6576010 2019-03-07 10:30 625993-PNZP34-678.jpg
1462 2019-03-07 13:39 License free.txt
1116 2019-03-07 13:39 License premium.txt
--------- -------
6578588 3 files
```
There are many other usage of the unzip command in Linux but I guess now you have enough knowledge to unzip files in Linux.
### Unzip files in Linux using GUI
You dont always have to go to the terminal if you are using desktop Linux. Lets see how to unzip in Ubuntu Linux graphically. I am using [GNOME desktop][7] here with Ubuntu 18.04 but the process is pretty much the same in other desktop Linux distributions.
Open the file manager and go to the folder where your zip file is stored. Right click the file and youll see the option “extract here”. Select this one.
![Unzip File in Ubuntu][8]
Unlike the unzip command, the extract here options create a folder of the same name as the zipped file and all the content of the zipped files are extracted to this newly created folder. I am glad that this is the default behavior instead of extracting everything in the current directory.
There is also the option of extract to and with that you can specify the folder where you want to extract the files.
Thats it. Now you know how to unzip a file in Linux. Perhaps you might also be interested in learning about [using 7zip in Linux][9].
If you have questions or suggestions, do let me know in the comment section.
--------------------------------------------------------------------------------
via: https://itsfoss.com/unzip-linux/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/abhishek/
[b]: https://github.com/lujun9972
[1]: https://en.wikipedia.org/wiki/Zip_(file_format)
[2]: https://itsfoss.com/linux-zip-folder/
[3]: https://ubuntu.com/
[4]: https://www.debian.org/
[5]: tmp.eqEocGssC8#terminal
[6]: tmp.eqEocGssC8#gui
[7]: https://gnome.org/
[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/unzip-files-ubuntu.jpg?ssl=1
[9]: https://itsfoss.com/use-7zip-ubuntu-linux/

View File

@ -0,0 +1,75 @@
[#]: collector: (lujun9972)
[#]: translator: (wxy)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (The lifecycle of Linux kernel testing)
[#]: via: (https://opensource.com/article/19/8/linux-kernel-testing)
[#]: author: (Major Hayden https://opensource.com/users/mhaydenhttps://opensource.com/users/mhaydenhttps://opensource.com/users/marcobravohttps://opensource.com/users/mhayden)
Linux 内核测试的生命周期
======
> 内核持续集成CKI项目旨在防止错误进入 Linux 内核。
![arrows cycle symbol for failing faster][1]
在 [Linux 内核的持续集成测试][2] 中,我介绍了 [内核持续集成][3]CKI项目及其改变内核开发人员和维护人员工作的使命。本文深入探讨了该项目的某些技术方面以及所有部分如何组合在一起。
### 一切始于更改
内核中每一项令人兴奋的功能、改进和错误都始于开发人员提出的更改。这些更改出现在各个内核存储库的大量邮件列表中。一些存储库关注内核中的某些子系统,例如存储或网络,而其它存储库关注内核的更多方面。 当开发人员向内核提出更改或补丁集时或者维护者在存储库本身中进行更改时CKI 项目就会付诸行动。
CKI 项目维护用于监视这些补丁集并采取措施的触发器。诸如 [Patchwork][4] 之类的软件项目通过将多个补丁贡献整合为单个补丁系列,使此过程变得更加容易。补丁系列作为一个整体通过 CKI 系统传播,并可以针对该系列发布单个报告。
其他触发器监视存储库中的更改。当内核维护人员合并补丁集、还原补丁或创建新标签时,就会发生这种情况。测试这些关键的更改可确保开发人员始终具有坚实的基线,可以用作编写新补丁的基础。
所有这些更改都进入了 GitLab CI 管道,并历经多个阶段和多个系统。
### 准备构建
首先要准备好要编译的源代码。这需要克隆存储库、打上开发人员建议的补丁集,并生成内核配置文件。这些配置文件具有成千上万个用于打开或关闭功能的选项,并且配置文件在不同的系统体系结构之间差异非常大。 例如,一个相当标准的 x86\_64 系统在其配置文件中可能有很多可用选项,但是 s390x 系统IBM zSeries 大型机)的选项可能要少得多。在该大型机上,某些选项可能有意义,但在消费类笔记本电脑上没有任何作用。
内核进一步转换为源代码工件。该工件包含整个存储库(已打上补丁)以及编译所需的所有内核配置文件。 上游内核会打包成压缩包,而 Red Hat 的内核生成下一步所用的源代码 RPM 包。
### 成堆的编译
编译内核会将源代码转换为计算机可以启动和使用的代码。配置文件描述了要构建的内容,内核中的脚本描述了如何构建它,系统上的工具(例如 GCC 和 glibc完成构建。此过程需要一段时间才能完成但是 CKI 项目需要针对四种体系结构快速完成aarch6464 位 ARM、ppc64lePOWER、s390xIBM zSeries和 x86\_64。重要的是我们必须快速编译内核以便使工作任务不会积压而开发人员可以及时收到反馈。
添加更多的 CPU 可以大大提高速度但是每个系统都有其局限性。CKI 项目在 OpenShift 的部署环境中的容器内编译内核;尽管 OpenShift 可以实现大量的可伸缩性,但部署环境中的可用 CPU 仍然是数量有限的。CKI 团队分配 20 个虚拟 CPU 来编译每个内核。涉及到四个体系结构,这就涨到看 80 个 CPU
另一个速度的提高来自称为 [ccache][5] 的工具。内核开发进展迅速但是即使在多个发布版本之间内核的大部分仍保持不变。ccache 工具进行编译期间会在磁盘上缓存已构建的对象整个内核的一小部分。稍后再进行另一个内核编译时ccache 会查找以前看到的内核的未更改部分。ccache 会从磁盘中提取缓存的对象并重新使用它。这样可以加快编译速度并降低总体 CPU 使用率。现在,耗时 20 分钟编译的内核在不到几分钟的时间内就完成了。
### 测试时间
内核进入最后一步:在真实硬件上进行测试。每个内核都使用 Beaker 在其原生体系结构上启动,并且开始无数次的测试以发现问题。一些测试会寻找简单的问题,例如容器问题或启动时的错误消息。其他测试则深入到各种内核子系统中,以查找系统调用、内存分配和线程中的回归问题。
大型测试框架,例如 [Linux Test Project][6]LTP包含了大量测试这些测试在内核中寻找麻烦的回归问题。其中一些回归问题可能会回滚关键的安全修复程序并且进行测试以确保这些改进仍保留在内核中。
测试完成后,关键的一步仍然是:报告。内核开发人员和维护人员需要一份简明的报告,准确地告诉他们哪些有效、哪些无效以及如何获取更多信息。每个 CKI 报告都包含所用源代码、编译参数和测试输出的详细信息。该信息可帮助开发人员知道从哪里开始寻找解决问题的方法。此外,它还可以帮助维护人员在漏洞进入内核存储库之前知道何时需要保留补丁集以进行其他的查看。
### 总结
CKI 项目团队通过向内核开发人员和维护人员提供及时、自动的反馈,努力防止错误进入 Linux 内核。这项工作通过发现导致内核错误、安全性问题和性能问题等易于找到的问题,使他们的工作更加轻松。
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/8/linux-kernel-testing
作者:[Major Hayden][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://opensource.com/users/mhaydenhttps://opensource.com/users/mhaydenhttps://opensource.com/users/marcobravohttps://opensource.com/users/mhayden
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fail_progress_cycle_momentum_arrow.png?itok=q-ZFa_Eh (arrows cycle symbol for failing faster)
[2]: https://opensource.com/article/19/6/continuous-kernel-integration-linux
[3]: https://cki-project.org/
[4]: https://github.com/getpatchwork/patchwork
[5]: https://ccache.dev/
[6]: https://linux-test-project.github.io
[7]: https://cki-project.org/posts/hackfest-agenda/
[8]: https://www.linuxplumbersconf.org/

View File

@ -0,0 +1,192 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Install and Configure VNC Server on Centos 8 / RHEL 8)
[#]: via: (https://www.linuxtechi.com/install-configure-vnc-server-centos8-rhel8/)
[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/)
如何在 Centos 8 / RHEL 8 上安装和配置 VNC 服务器
======
**VNC**(虚拟网络计算)服务器是基于 GUI 的桌面共享平台,它可让你访问远程桌面计算机。在 **Centos 8****RHEL 8** 系统中,默认未安装 VNC 服务器,它需要手动安装。在本文中,我们将通过简单的分步指南,介绍如何在 Centos 8 / RHEL 8 上安装 VNC 服务器。
### 在 Centos 8 / RHEL 8 上安装 VNC 服务器的先决要求
要在你的系统中安装 VNC 服务器,请确保你的系统满足以下要求:
* CentOS 8 / RHEL 8
* GNOME 桌面环境
* 根用户权限
* DNF / YUM 软件包仓库
### 在 Centos 8 / RHEL 8 上安装 VNC 服务器的分步指导
### 步骤 1安装 GNOME 桌面环境
在 CentOS 8 / RHEL 8 中安装 VNC 服务器之前,请确保已安装了桌面环境 DE。如果已经安装了 GNOME 桌面或安装了 GUI 支持,那么可以跳过此步骤。
在CentOS 8 / RHEL 8 中GNOME 是默认的桌面环境。如果你的系统中没有它,请使用以下命令进行安装:
```
[root@linuxtechi ~]# dnf groupinstall "workstation"
或者
[root@linuxtechi ~]# dnf groupinstall "Server with GUI
```
成功安装上面的包后,请运行以下命令启用图形模式
```
[root@linuxtechi ~]# systemctl set-default graphical
```
现在重启系统,进入 GNOME 登录页面。
```
[root@linuxtechi ~]# reboot
```
重启后,请取消注释 “**/etc/gdm/custom.conf**” 中的 “**WaylandEnable=false**”,以使通过 vnc 进行的远程桌面会话请求由 GNOME 桌面的 xorg 处理,来代替 Wayland 显示管理器。
**注意:** Wayland 是 GNOME 中的默认显示管理器 GDM并且未配置用于处理 X.org 等远程渲染的 API。
### 步骤 2安装 VNC 服务器tigervnc-server
接下来,我们将安装 VNC 服务器,有很多 VNC 服务器可以选择,出于安装目的,我们将安装 **TigerVNC 服务器**。它是最受欢迎的 VNC 服务器之一,并且高性能还独立于平台,它使用户可以轻松地与远程计算机进行交互。
现在,使用以下命令安装 TigerVNC 服务器:
```
[root@linuxtechi ~]# dnf install tigervnc-server tigervnc-server-module -y
```
### 步骤 3为本地用户设置 VNC 密码
假设我们希望用户 “pkumar” 使用 VNC 进行远程桌面会话,然后切换到该用户并使用 vncpasswd 命令设置其密码,
```
[root@linuxtechi ~]# su - pkumar
[root@linuxtechi ~]$ vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
[root@linuxtechi ~]$
[root@linuxtechi ~]$ exit
logout
[root@linuxtechi ~]#
```
### 步骤 4设置 VNC 服务器配置文件
下一步是配置 VNC 服务器配置文件。创建含以下内容的 “**/etc/systemd/system/[root@linuxtechi][1]**”,以便为上面的本地用户 “pkumar” 启动 tigervnc-server 的服务。
```
[root@linuxtechi ~]# vim /etc/systemd/system/root@linuxtechi
[Unit]
Description=Remote Desktop VNC Service
After=syslog.target network.target
[Service]
Type=forking
WorkingDirectory=/home/pkumar
User=pkumar
Group=pkumar
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver -autokill %i
ExecStop=/usr/bin/vncserver -kill %i
[Install]
WantedBy=multi-user.target
```
保存并退出文件,
**注意:**替换上面文件中的用户名为你自己的。
默认情况下VNC 服务器在 tcp 端口 5900+n 上监听,其中 n 是显示号,如果显示数字为“ 1”那么 VNC 服务器将在 TCP 端口 5901 上监听其请求。
### 步骤 5启动 VNC 服务并允许防火墙中的端口
我将显示号设置为 1因此请使用以下命令在显示号 “1” 上启动并启用 vnc 服务,
```
[root@linuxtechi ~]# systemctl daemon-reload
[root@linuxtechi ~]# systemctl start root@linuxtechi:1.service
[root@linuxtechi ~]# systemctl enable vnroot@linuxtechi:1.service
Created symlink /etc/systemd/system/multi-user.target.wants/root@linuxtechi:1.service → /etc/systemd/system/root@linuxtechi
[root@linuxtechi ~]#
```
使用下面的 **netstat****ss** 命令来验证 VNC 服务器是否开始监听 5901 上的请求,
```
[root@linuxtechi ~]# netstat -tunlp | grep 5901
tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 8169/Xvnc
tcp6 0 0 :::5901 :::* LISTEN 8169/Xvnc
[root@linuxtechi ~]# ss -tunlp | grep -i 5901
tcp LISTEN 0 5 0.0.0.0:5901 0.0.0.0:* users:(("Xvnc",pid=8169,fd=6))
tcp LISTEN 0 5 [::]:5901 [::]:* users:(("Xvnc",pid=8169,fd=7))
[root@linuxtechi ~]#
```
使用下面的 systemctl 命令验证 VNC 服务器的状态,
```
[root@linuxtechi ~]# systemctl status root@linuxtechi:1.service
```
![vncserver-status-centos8-rhel8][2]
上面命令的输出确认在 tcp 端口 5901 上成功启动了 VNC。使用以下命令在系统防火墙中允许 VNC 服务器端口 “5901”
```
[root@linuxtechi ~]# firewall-cmd --permanent --add-port=5901/tcp
success
[root@linuxtechi ~]# firewall-cmd --reload
success
[root@linuxtechi ~]#
```
### 步骤 6连接到远程桌面会话
现在,我们已经准备就绪,可以查看远程桌面连接是否正常工作。要访问远程桌面,请在 Windows / Linux 工作站中启动 VNC Viewer然后输入 **VNC 服务器 IP 地址**和**端口号**,然后按回车。
[![VNC-Viewer-Windows10][2]][3]
接下来,它将询问你的 VNC 密码。输入你先前为本地用户创建的密码,然后单击 “OK” 继续。
[![VNC-Viewer-Connect-CentOS8-RHEL8-VNC-Server][2]][4]
现在你可以看到远程桌面,
[![VNC-Desktop-Screen-CentOS8][2]][5]
就是这样,你已经在 Centos 8 / RHEL 8 中成功安装了 VNC 服务器。
**总结**
希望在 Centos 8 / RHEL 8 上安装 VNC 服务器的分步指南为你提供了轻松设置 VNC 服务器并访问远程桌面的所有信息。请在下面的评论栏中提供你的意见和建议。下篇文章再见。谢谢再见!!!
--------------------------------------------------------------------------------
via: https://www.linuxtechi.com/install-configure-vnc-server-centos8-rhel8/
作者:[Pradeep Kumar][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://www.linuxtechi.com/author/pradeep/
[b]: https://github.com/lujun9972
[1]: https://www.linuxtechi.com/cdn-cgi/l/email-protection
[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
[3]: https://www.linuxtechi.com/wp-content/uploads/2019/10/VNC-Viewer-Windows10.jpg
[4]: https://www.linuxtechi.com/wp-content/uploads/2019/10/VNC-Viewer-Connect-CentOS8-RHEL8-VNC-Server.jpg
[5]: https://www.linuxtechi.com/wp-content/uploads/2019/10/VNC-Desktop-Screen-CentOS8.jpg

View File

@ -0,0 +1,126 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Unzip a Zip File in Linux [Beginners Tutorial])
[#]: via: (https://itsfoss.com/unzip-linux/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
如何在 linux 下解压 Zip 文件
======
_**摘要: 将会向你展示如何在 ubuntu 和其他 linux 发行版本上解压文件 . 终端和图形界面的方法都会被讨论 **_
[Zip][1] 是一种最普通 , 最流行的方法来创建压缩存档文件 . 它也是一种古老的文件归档文件格式,创建于 1989 年 . 自从它被广泛的使用 , 你会经常遇见 zip 文件 .
在更早的一份教程 , 我展示了 [how to zip a folder in Linux][2] . 在这篇快速教程中 , 对于初学者我会展示如何在 linux 上解压文件 .
**先决条件: 检查你是否安装了 unzip**
为了解压 zip 归档文件 , 你必须解压安装包到你的系统 . 大多数现代的的 linux 发行版本提供解压 zip 文件的原生支持 . 校验它来避免以后出现坏的惊喜 .
以 [Unbutu][3] 和 [Debian][4] 为基础的发行版本 , 你能够使用下面的命令来安装 unzip. 如果你已经安装了, 你会被告知已经被安装 .
```
sudo apt install unzip
```
一旦你能够确认你的系统中安装了 unzip, 你就可以通过 unzip 来解压 zip 归档文件.
你也能够使用命令行或者图形工具来达到目的, 我会向你展示两种方法.
* [Unzip files in Linux terminal][5]
* [Unzip files in Ubuntu via GUI][6]
### 使用命令行解压文件
在 linux 下使用 unzip 命令是非常简单. 当你向解压 zip 文件, 用下面的命令:
```
unzip zipped_file.zip
```
你可以给 zip 文件提供解压路径而不是当前所在路径 . 你会在终端输出中看到提取的文件:
```
unzip metallic-container.zip -d my_zip
Archive: metallic-container.zip
inflating: my_zip/625993-PNZP34-678.jpg
inflating: my_zip/License free.txt
inflating: my_zip/License premium.txt
```
上面的命令有一个小问题. 它会提取 zip 文件中所有的内容到现在的文件夹 . 你会在当前文件夹下留下一堆没有组织的文件, 这不是一件很好的事情.
#### 解压到文件夹下
在 linux 命令行下, 对于把文件解压到一个文件夹下是一个好的做法. 这种方式下, 所有的提取文件都会被存储到你所指定的文件夹下. 如果文件夹不存在, 文件夹会被创建.
```
unzip zipped_file.zip -d unzipped_directory
```
现在 zipped_file.zip 中所有的内容都会被提取到 unzipped_directory 中.
从我们讨论好的做法, 另一个注意点, 我们可以查看压缩文件中的内容而不用真实的解压 .
#### 查看压缩文件中的内容而不解压压缩文件
```
unzip -l zipped_file.zip
```
下面是命令的输出:
```
unzip -l metallic-container.zip
Archive: metallic-container.zip
Length Date Time Name
--------- ---------- ----- ----
6576010 2019-03-07 10:30 625993-PNZP34-678.jpg
1462 2019-03-07 13:39 License free.txt
1116 2019-03-07 13:39 License premium.txt
--------- -------
6578588 3 files
```
在 linux 下, 这里还有些其他的 unzip 的用法, 你对在 linux 下使用解压文件有了足够的知识.
### 使用图形界面来解压文件
如果你使用桌面版 linux , 那你就不必总是使用终端. 在图形化的界面下,我们又要如何解压文件呢? 我使用 [GNOME desktop][7]. 和其他的桌面版 linux 发行版本相同 .
打开文件管理器,然后跳转到压缩文件所在的文件夹下. 点击鼠标右键, 你会在弹出的窗口中看到 "extract here",选择它.
![Unzip File in Ubuntu][8]
与 unzip 命令不同, 提取选项会创建一个和压缩文件名相同的文件夹,并且把压缩文件中的所有内容存储到创建的文件夹下. 相对于 unzip 命令的默认行为是将压缩文件提取到当前所在的文件下,图形界面的解压对于我来说是一件非常好的事情.
这里还有一个选项 "extract to", 你可以悬着特定的文件夹来存储提取文件.
你现在知道如何在 linux 解压文件. 你也许对学习有兴趣 [using 7zip in Linux][9] .
--------------------------------------------------------------------------------
via: https://itsfoss.com/unzip-linux/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[octopus](https://github.com/singledo)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/abhishek/
[b]: https://github.com/lujun9972
[1]: https://en.wikipedia.org/wiki/Zip_(file_format)
[2]: https://itsfoss.com/linux-zip-folder/
[3]: https://ubuntu.com/
[4]: https://www.debian.org/
[5]: tmp.eqEocGssC8#terminal
[6]: tmp.eqEocGssC8#gui
[7]: https://gnome.org/
[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/unzip-files-ubuntu.jpg?ssl=1
[9]: https://itsfoss.com/use-7zip-ubuntu-linux/