mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-23 21:20:42 +08:00
parent
3fd409d1af
commit
b06f326f44
@ -0,0 +1,159 @@
|
||||
[#]: subject: "Linux Shells: Bash, Zsh, and Fish Explained"
|
||||
[#]: via: "https://www.debugpoint.com/linux-shells/"
|
||||
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "ChatGPT"
|
||||
[#]: reviewer: "wxy"
|
||||
[#]: publisher: "wxy"
|
||||
[#]: url: "https://linux.cn/article-16038-1.html"
|
||||
|
||||
Linux Shell 介绍:Bash、Zsh 和 Fish
|
||||
======
|
||||
|
||||
![][0]
|
||||
|
||||
> 关于著名的 Linux Shell - Bash、Zsh 和 Fish 的一些注释和特性。
|
||||
|
||||
Linux 之所以强大,是因为它提供了用于与系统进行交互的多功能的命令行界面。在这中情况下,Shell 扮演了用户和 Linux 内核之间的桥梁。本文将探讨三种流行的 Linux Shell - Bash、Zsh 和 Fish,并深入了解它们的独特特性和功能。
|
||||
|
||||
### 理解 Linux Shell
|
||||
|
||||
#### 什么是 Shell?
|
||||
|
||||
Shell 是一个命令行解释器,允许你通过文本命令与操作系统进行交互。它接收你的输入,处理它,并与 Linux 内核通信以执行所请求的操作。最后,它会给你一个输出。
|
||||
|
||||
(LCTT 译注:“Shell” 一词大约取自其“界面”、“外壳”的含义。)
|
||||
|
||||
Shell 在 Linux 中起着至关重要的作用,因为它们使用户能够执行各种任务,从简单的文件导航到复杂的系统管理任务。不同的 Shell 提供各种功能,因此选择适合你工作流程的 Shell 至关重要。
|
||||
|
||||
### Bash
|
||||
|
||||
[Bash][1],全称 “Bourne Again SHell”,是 Linux 发行版中最广泛使用的默认 Shell 之一。它以其简洁和兼容性而闻名,是初学者的优秀选择。
|
||||
|
||||
#### Bash 的特点
|
||||
|
||||
Bash 具有众多特性,包括:
|
||||
|
||||
- 命令历史:使用箭头键轻松访问先前执行的命令。
|
||||
- `Tab` 键补全:节省时间,让 Bash 为你自动完成文件名和命令。
|
||||
- 脚本编写:编写和运行 Shell 脚本以自动化重复任务。从这个角度来看,它也是一个程序。
|
||||
- Bash 在大多数 GNU/Linux 系统中默认安装。
|
||||
- 配置设置存储在家目录下的 `.bashrc` 文件中。
|
||||
|
||||
和其他 Shell 一样,Bash 有其优点和缺点。使用 Bash 的一些优势包括广泛的使用性、详尽的文档以及庞大的社区支持。然而,Bash 可能缺乏其他 Shell 中存在的一些现代化特性。
|
||||
|
||||
![Linux 中的 Bash shell][2]
|
||||
|
||||
#### 安装
|
||||
|
||||
- 在 Linux 发行版中打开终端。
|
||||
- 输入 `bash --version` 检查是否已安装 Bash。
|
||||
- 若尚未安装,使用软件包管理器安装 Bash。例如,在 Ubuntu 上,输入 `sudo apt-get install bash`。
|
||||
- 对于 Fedora 和基于 RPM 的 Linux,请使用 `sudo dnf install bash`。
|
||||
|
||||
### Zsh
|
||||
|
||||
[Zsh][3],全称 “Z Shell”,是一种强大且功能丰富的 Shell,深受经验丰富的用户欢迎。它吸取了 Bash 和其他 Shell 的优点,提升了用户体验。
|
||||
|
||||
#### Zsh 的优势
|
||||
|
||||
Zsh 提供了几个优势,包括:
|
||||
|
||||
- 高级自动补全:Zsh 在 Bash 的基础上提供了更多上下文感知的建议,超越了简单的 `Tab` 键补全。
|
||||
- 当你按下 `Tab` 键时,Zsh 会显示可能的值以供选择,同时进行自动补全。
|
||||
- 插件支持:通过社区中提供的各种插件,扩展 Zsh 的功能。
|
||||
- 这里有一个 [庞大的 Zsh 主题集合][4]。
|
||||
- 你还可以使用 [Oh My Zsh 脚本][5] 进行广泛的自定义。
|
||||
|
||||
![应用 powerlevel10k zsh 主题后的效果][6]
|
||||
|
||||
Zsh 的复杂性可能使新手感到不知所措,其丰富的配置选项可能会使初学者感到困惑。
|
||||
|
||||
以下是安装 Zsh 的方法:
|
||||
|
||||
- 在 Linux 发行版中打开终端。
|
||||
- 输入 `zsh --version` 检查是否已安装 Zsh。
|
||||
- 如果尚未安装,请使用软件包管理器安装 Zsh。
|
||||
- 例如,在 Ubuntu 上,输入 `sudo apt-get install zsh`。
|
||||
- 对于 Fedora 和基于 RPM 的发行版,输入 `sudo dnf install zsh`。
|
||||
|
||||
### Fish Shell
|
||||
|
||||
[Fish][7],全称 “Friendly Interactive SHell”,着重于用户友好性和易用性。它拥有现代、直观的界面,特别适合新的 Linux 用户。
|
||||
|
||||
#### Fish 的独特特性
|
||||
|
||||
Fish 的独特之处在于:
|
||||
|
||||
- 语法高亮:使用彩色标记文本来区分命令、选项和参数。
|
||||
- 自动建议:Fish 根据你的历史记录和当前输入智能地建议命令。
|
||||
- Fish 被设计为开箱即用的高效工具。但是,你可以通过创建 `~/.config/fish/config.fish` 文件并添加自定义配置来进一步个性化它。
|
||||
|
||||
虽然 Fish 在用户友好性方面表现出色,但其独特的设计可能并不适合所有人。一些高级用户可能会发现某些功能在高级使用方面有所限制。
|
||||
|
||||
![Fish Shell][8]
|
||||
|
||||
#### Fish Shell 的安装
|
||||
|
||||
- 在 Linux 发行版中打开终端。
|
||||
- 输入 `fish --version` 检查是否已安装 Fish。
|
||||
- 如果尚未安装,请使用软件包管理器安装 Fish。例如,在 Ubuntu 上,输入 `sudo apt-get install fish`。
|
||||
- 对于 Fedora 和其他基于 RPM 的发行版,输入 `sudo dnf install fish`。
|
||||
|
||||
### Bash、Zsh 和 Fish 的比较
|
||||
|
||||
为了帮助你决定哪种 Shell 适合你的需求,让我们从各个方面比较这三个流行选择:
|
||||
|
||||
#### 性能与速度
|
||||
|
||||
Bash 以其速度和高效性而闻名,适用于资源受限的系统。Zsh 虽然稍慢一些,但其广泛的功能和能力弥补了这一点。作为更具交互性的 Shell,Fish Shell 可能会略微降低性能,但提供了愉快的用户体验。
|
||||
|
||||
#### 用户界面和体验
|
||||
|
||||
Bash 的界面简单明了,非常适合初学者,而 Zsh 和 Fish 提供了更引人注目和交互式的界面。Zsh 的高级自动补全和 Fish 的语法高亮为用户创造了视觉上的吸引力。
|
||||
|
||||
#### 可定制性和插件
|
||||
|
||||
Zsh 在可定制性方面表现出色,允许用户对其 Shell 环境进行微调。通过庞大的插件集合,Zsh 提供了无与伦比的可扩展性。Fish 则采取了更有主见的方式,专注于开箱即用的可用性,这可能对某些用户有所限制。
|
||||
|
||||
### 选择合适的 Shell
|
||||
|
||||
选择合适的 Shell 与你的具体需求和经验水平密切相关。
|
||||
|
||||
如果你是 Linux 的新手并且更喜欢简单、无花俏的体验,Bash 是一个极好的起点。它的易用性和详尽的文档使其非常适合初学者。
|
||||
|
||||
对于希望更多掌握控制权并愿意花时间进行定制的经验丰富的用户来说,Zsh 强大的功能和插件提供了一个令人兴奋和动态的环境。
|
||||
|
||||
如果你对自动化任务和编写复杂的 Shell 脚本感兴趣,Bash 在 Linux 生态系统中的广泛应用和全面支持使其成为一个可靠的选择。
|
||||
|
||||
### 结论
|
||||
|
||||
Bash、Zsh 和 Fish 各有其优势,满足不同用户偏好。如果你刚接触 Linux,Bash 的简单性使其成为一个极好的起点。精通用户和那些寻求定制化的用户可能会觉得 Zsh 更吸引人,而 Fish 的用户友好设计则适合寻求直观界面的初学者。最终,选择权在你手中,探索这些 Shell 将带来更高效和愉悦的 Linux 使用体验。
|
||||
|
||||
你最喜欢的 Shell 是什么?在下方的评论框中告诉我。
|
||||
|
||||
*(题图:MJ/b6490b57-63bd-4fdd-bd3f-bf6d4aef1c4a)*
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.debugpoint.com/linux-shells/
|
||||
|
||||
作者:[Arindam][a]
|
||||
选题:[lkxed][b]
|
||||
译者:ChatGPT
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.debugpoint.com/author/admin1/
|
||||
[b]: https://github.com/lkxed/
|
||||
[1]: https://www.gnu.org/software/bash/
|
||||
[2]: https://www.debugpoint.com/wp-content/uploads/2023/07/Bash-shell-in-Linux.jpg
|
||||
[3]: https://www.zsh.org/
|
||||
[4]: https://github.com/unixorn/awesome-zsh-plugins
|
||||
[5]: https://www.debugpoint.com/oh-my-zsh-powerlevel10k/
|
||||
[6]: https://www.debugpoint.com/wp-content/uploads/2022/12/After-applying-settings-in-powerlevel10k-zsh-theme.jpg
|
||||
[7]: https://fishshell.com/
|
||||
[8]: https://www.debugpoint.com/wp-content/uploads/2023/07/Fish-Shell.jpg
|
||||
[9]: https://pixabay.com/users/julesroman-359800/
|
||||
[0]: https://img.linux.net.cn/data/attachment/album/202307/27/152721rd48wwn7xxfkngdw.jpg
|
@ -1,154 +0,0 @@
|
||||
[#]: subject: "Linux Shells: Bash, Zsh, and Fish Explained"
|
||||
[#]: via: "https://www.debugpoint.com/linux-shells/"
|
||||
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: " "
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
Linux Shells: Bash, Zsh, and Fish Explained
|
||||
======
|
||||
|
||||
**A few notes and features of famous Linux shells – Bash, Zsh and Fish.**
|
||||
|
||||
Linux is powerful because of its versatile command line interface to interact with the system. Central to this experience are the shells, which act as the bridge between users and the Linux kernel. This article will explore three popular Linux shells – Bash, Zsh, and Fish – and delve into their unique features and capabilities.
|
||||
|
||||
### Understanding Linux Shells
|
||||
|
||||
#### What is a Shell?
|
||||
|
||||
A shell is a command-line interpreter that allows you to interact with the OS through textual commands. It takes your input, processes it, and communicates with the Linux kernel to execute the requested actions. Finally, it gives you an output.
|
||||
|
||||
Shells play a crucial role in Linux because they enable users to perform various tasks, from simple file navigation to complex system administration tasks. Different shells offer various features, making it essential to choose the right one for your workflow.
|
||||
|
||||
### Bash
|
||||
|
||||
[Bash][1], short for “Bourne Again SHell,” is one of the most widely used and default shells in Linux distributions. It is known for its simplicity and compatibility, making it an excellent choice for beginners.
|
||||
|
||||
#### Features of Bash
|
||||
|
||||
Bash comes with a plethora of features, including:
|
||||
|
||||
- Command History: Easily access previously executed commands with the arrow keys.
|
||||
- Tab Completion: Save time by letting Bash complete filenames and commands for you.
|
||||
- Scripting: Write and run shell scripts to automate repetitive tasks. In that way, it’s also a program as well.
|
||||
- Bash is installed in most of the GNU/Linux systems by default.
|
||||
- Configuration settings are stored in `.bashrc` at your home directory.
|
||||
|
||||
Like any shell, Bash has its pros and cons. Some advantages of using Bash include its ubiquity, extensive documentation, and vast community support. However, Bash may lack some modern features found in other shells.
|
||||
|
||||
![Bash shell in Linux][2]
|
||||
|
||||
#### Installation
|
||||
|
||||
- Open the terminal in your Linux distribution.
|
||||
- Check if Bash is already installed by typing: `bash --version`.
|
||||
- If not installed, use your package manager to install Bash. For example, on Ubuntu, type: `sudo apt-get install bash`.
|
||||
- For Fedora and RPM-based Linux use `sudo dnf install bash`
|
||||
|
||||
### Zsh
|
||||
|
||||
[Zsh][3], short for “Z Shell,” is a robust, feature-rich shell popular among experienced users. It takes the best from Bash and other shells, enhancing the user experience.
|
||||
|
||||
#### Advantages of Zsh
|
||||
|
||||
Zsh offers several advantages, such as:
|
||||
|
||||
- Advanced Auto-Completion: Zsh goes beyond Bash’s tab completion, providing more context-aware suggestions.
|
||||
- When you press the tab, Zsh also shows you possible values alongside the auto-completion.
|
||||
- Plugin Support: Extend Zsh’s functionality through various plugins available in the community.
|
||||
- Here’s a list of a [vast collection of Zsh themes][4].
|
||||
- You can also enjoy extensive customizations using [Oh My Zsh script][5].
|
||||
|
||||
![After applying settings in powerlevel10k zsh theme][6]
|
||||
|
||||
Zsh’s complexity may overwhelm newcomers, and its extensive configuration options might confuse beginners.
|
||||
|
||||
Here’s how to install it.
|
||||
|
||||
- Open the terminal in your Linux distribution.
|
||||
- Check if Zsh is installed by typing: zsh –version.
|
||||
- If not installed, use your package manager to install Zsh.
|
||||
- For example, on Ubuntu, type: `sudo apt-get install zsh`.
|
||||
- For Fedora and RPM-based distributions, type: `sudo dnf install zsh`.
|
||||
|
||||
### Fish Shell
|
||||
|
||||
[Fish][7], the “Friendly Interactive SHell,” focuses on user-friendliness and discoverability. It has a modern, straightforward interface that appeals to new Linux users.
|
||||
|
||||
#### Unique Features of Fish
|
||||
|
||||
Fish stands out with its:
|
||||
|
||||
- Syntax Highlighting: Use colour-coded text to distinguish between commands, options, and arguments.
|
||||
- Autosuggestions: Fish intelligently suggests commands based on your history and current input.
|
||||
- Fish is designed to work efficiently out of the box. However, you can personalize it further by creating the `~/.config/fish/config.fish` file and adding custom configurations.
|
||||
|
||||
While Fish excels in user-friendliness, its unique approach might not suit everyone. Some power users might find certain features limiting for advanced use.
|
||||
|
||||
![Fish Shell][8]
|
||||
|
||||
#### Fish Shell Installation
|
||||
|
||||
- Open the terminal in your Linux distribution.
|
||||
- Check if Fish is installed by typing: `fish --version`.
|
||||
- If not installed, use your package manager to install Fish. For example, on Ubuntu, type: `sudo apt-get install fish`.
|
||||
- For Fedora and other RPM-based distributions type: `sudo dnf install fish`.
|
||||
|
||||
### Comparison of Bash, Zsh, and Fish
|
||||
|
||||
To help you decide which shell fits your needs, let’s compare these three popular choices in various aspects:
|
||||
|
||||
#### Performance and Speed
|
||||
|
||||
Bash is known for its speed and efficiency, making it an excellent choice for resource-constrained systems. Zsh, while slightly slower, makes up for it with its extensive features and capabilities. Being more interactive, Fish shell might have a slight performance overhead but provides a delightful user experience.
|
||||
|
||||
#### User Interface and Experience
|
||||
|
||||
Bash’s interface is simple and straightforward, ideal for beginners, while Zsh and Fish offer more eye-catching and interactive interfaces. Zsh’s advanced auto-completion and Fish’s syntax highlighting create a visually appealing experience.
|
||||
|
||||
#### Customizability and Plugins
|
||||
|
||||
Zsh shines in customizability, allowing users to fine-tune their shell environment. With a vast collection of plugins, Zsh offers unparalleled extensibility. Fish takes a more opinionated approach, focusing on out-of-the-box usability, which might be limiting for some users.
|
||||
|
||||
### Choosing the Right Shell
|
||||
|
||||
The choice of the right shell largely depends on your specific needs and level of experience.
|
||||
|
||||
Bash is an excellent starting point if you are new to Linux and prefer a straightforward, no-frills experience. Its ease of use and extensive documentation make it beginner-friendly.
|
||||
|
||||
For experienced users who want more control and are willing to invest time in customization, Zsh’s powerful features and plugins offer an exciting and dynamic environment.
|
||||
|
||||
If you’re interested in automating tasks and writing complex shell scripts, Bash’s wide adoption and extensive support in the Linux ecosystem make it a reliable choice.
|
||||
|
||||
### Conclusion
|
||||
|
||||
Bash, Zsh, and Fish each have their strengths and cater to different user preferences. If you’re new to Linux, Bash’s simplicity makes it an excellent starting point. Power users and those seeking customization may find Zsh more appealing, while Fish’s user-friendly design suits beginners looking for an intuitive interface. Ultimately, the choice is yours, and exploring these shells will lead to a more efficient and enjoyable Linux experience.
|
||||
|
||||
What is your favourite Shell? Let me know in the comment box below.
|
||||
|
||||
_Feature Image by [julia roman][9] from Pixabay._
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.debugpoint.com/linux-shells/
|
||||
|
||||
作者:[Arindam][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.debugpoint.com/author/admin1/
|
||||
[b]: https://github.com/lkxed/
|
||||
[1]: https://www.gnu.org/software/bash/
|
||||
[2]: https://www.debugpoint.com/wp-content/uploads/2023/07/Bash-shell-in-Linux.jpg
|
||||
[3]: https://www.zsh.org/
|
||||
[4]: https://github.com/unixorn/awesome-zsh-plugins
|
||||
[5]: https://www.debugpoint.com/oh-my-zsh-powerlevel10k/
|
||||
[6]: https://www.debugpoint.com/wp-content/uploads/2022/12/After-applying-settings-in-powerlevel10k-zsh-theme.jpg
|
||||
[7]: https://fishshell.com/
|
||||
[8]: https://www.debugpoint.com/wp-content/uploads/2023/07/Fish-Shell.jpg
|
||||
[9]: https://pixabay.com/users/julesroman-359800/
|
Loading…
Reference in New Issue
Block a user