bash和zsh区别_Bash,Zsh和其他LinuxShell之间有什么区
busybox安装别?
bash和zsh区别
Most Linux distributions include the bash shell by default, but you could also switch to another shell . Zsh is a particularly popular alternative, and there are other shells, like ash, dash, fish, and tcsh. But what’s the difference, and why are there
so many?
⼤多数Linux发⾏版默认都包含bash shell,但是您也可以切换到另⼀个shell环境。 Zsh是⼀个特别受欢迎的替代⽅案,并且还有其他外壳,例如灰烬,破折号,鱼和tcsh。 但是有什么区别,为什么会有那么多呢?
贝壳做什么? (What Do Shells Do?)
When you sign in at the command line or launch a terminal window on Linux, the system launches the shell program. Shells offer a standard way of extending the command line environment. You can swap out the default shell for another one, if you like.
在Linux上通过命令⾏登录或启动终端窗⼝时,系统将启动Shell程序。 Shell提供了扩展命令⾏环境的标准⽅法。 如果愿意,可以将默认外壳换成另⼀个外壳。
The first shell environment was the Thompson Shell, developed at Bell Labs and released in 1971. Shell environments have been building on the concept ever since, adding a variety of new features, functionality, and speed improvements.
第⼀个外壳程序环境是由Bell Labs开发并于1971年发布的Thompson Shell。此后,外壳程序环境⼀直以此概念为基础,并增加了许多新功能,功能和速度⽅⾯的改进。
For example, Bash offers , , , configurable colors, command aliases, and a variety of other features that weren’t available back in 1971 when the first shell was released.
例如,Bash提供,,,可配置的颜⾊,命令别名以及其他各种功能,这些功能在1971年第⼀个Shell
发⾏时就不可⽤。
The shell is also used in the background by various system services. Linux distributions include many functions written as shell scripts. These scripts are commands and other advanced shell scripting functions run through the shell environment.
各种系统服务还在后台使⽤该Shell。 Linux发⾏版包含许多作为shell脚本编写的功能。 这些脚本是在外壳环境中运⾏的命令和其他⾼级外壳脚本功能。
导致Bash的Shell:sh,csh,tsh和ksh (Shells Leading Up to Bash: sh, csh, tsh, and ksh)
The most prominent progenitor of modern shells is the Bourne shell—also known as “sh”—which was named after its creator Stephen Bourne who worked at AT&T’s Bell Labs. Released in 1979, it became the default command-interpreter in because of its support for command substitution, piping, variables, condition testing, and looping, along with other features. It did not offer much customization for users, and didn’t support such modern niceties as aliases, command completion, and shell functions (though this last one was eventually added).
现代贝壳最著名的祖先是Bourne贝壳(也称为“ sh”),它是以在AT&T贝尔实验室⼯作的创造者Stephen
Bourne的名字命名的。 它于1979年发布,由于它⽀持命令替换,管道,变量,条件测试和循环以及其他功能,因此成为的默认命令解释器。 它没有为⽤户提供太多⾃定义功能,并且不⽀持诸如别名,命令完成和shell函数之类的现代功能(尽管最后添加了最后⼀个功能)。
The C shell, or “csh”, was developed in the late 1970s by Bill Joy at University of California, Berkley. It added a lot of interactive elements with which users could control their systems, like aliases (shortcuts for long commands), job management abilities, command history, and more. It was modeled off the C programming language, which the Unix operating system itself was written in. This also meant that users of the Bourne shell had to learn C so they could enter commands in it. In addition, csh had quite a few bugs that had to be hammered out by users and creators alike over a large period of time. People ended up using the Bourne shell for scripts because it handled non-interactive commands better, but stuck with the C shell for normal use.
C shell或“ csh”是1970年代后期由加州⼤学伯克利分校的Bill Joy开发的。 它添加了许多交互式元素,⽤户可以使⽤它们来控制系统,例如别名(长命令的快捷⽅式),作业管理能⼒,命令历史记录等等。 它是使⽤C语⾔编程的,该语⾔是Unix操作系统本⾝编写的。这也意味着Bourne shell的⽤户必须学习C语⾔,以便可以在其中输⼊命令。 另外,csh还有很多错误,在很长⼀段时间内,⽤户和创作者都必须解决这些错误。 ⼈们最终将Bourne shell⽤于脚本,因为它可以更好地处理⾮交互式命令,但在正
常使⽤时会停留在C shell中。
Over time, lots of people fixed bugs in and added features to the C shell, culminating in an improved version of csh known as “tcsh”. But csh was still the default in Unix-based computers, and had added some non-standard features. David Korn from Bell Labs worked on the KornShell, or “ksh”, which tried to improve the situation by being backwards-compatible with the Bourne shell’s language but adding many features from the csh shell. It was released in 1983, but under a proprietary license. It wasn’t free software until the 2000s, when it was released under various open-source licenses.
随着时间的流逝,许多⼈修复了C shell中的错误并为其添加了功能,最终导致了改进的csh版本,即“ tcsh”。 但是csh仍然是基于Unix 的计算机中的默认设置,并添加了⼀些⾮标准功能。 贝尔实验室的David Korn开发了KornShell或“ ksh”,该产品试图通过与Bourne Shell的语⾔向后兼容,但从csh shell添加了许多功能来改善这种情况。 它于1983年发布,但获得了专有许可。 直到2000年代,它才是免费软件,当时它是在各种开源许可证下发布的。
bash的诞⽣ (The Birth of bash)
The Portable Operating System Interface for Unix, or POSIX, was another response to the hectic proprietary csh implementations. It successfully created a standard for command interpretation (among other things) and eventually mirrored a lot of the features in the KornShell. At the same time, the GNU Project was attempting to create a free, Unix-compatible operating system. The GNU Project developed a free software shell to be part of its free operating system and named it the “Bourne Again Shell”, or “bash”.
Unix的便携式操作系统接⼝,即POSIX,是对忙碌的专有csh实现的另⼀种回应。 它成功创建了命令
解释标准(除其他外),并最终反映了KornShell中的许多功能。 同时,GNU⼯程正试图创建⼀个免费的,兼容Unix的操作系统。 GNU项⽬开发了⼀个免费软件外壳程序作为其免费操作系统的⼀部分,并将其命名为“ Bourne Again Shell”或“ bash”。
Bash has been improved in the decades since its first release in 1989, but it’s still the default shell on most Linux distributions today. It’s also the default shell on Apple’s macOS, and is .
⾃1989年⾸次发布以来,Bash在⼏⼗年中得到了改进,但是它仍然是当今⼤多数Linux发⾏版中的默认Shell。 它也是Apple macOS上的默认外壳,。
较新的外壳:灰,破折号,zsh和鱼 (Newer Shells: ash, dash, zsh, and fish)
While the Linux community has settled on Bash in the years since, developers didn’t stop creating new shells when Bash was first released 28 years ago.
从那以后,Linux社区就开始使⽤Bash了,但是当Bash在28年前⾸次发布时,开发⼈员并没有停⽌创建新的Shell。
Kenneth Almquist created a Bourne shell clone known as Almquish shell, A Shell, “ash”, or sometimes just “sh”. it was also POSIX compatible and became the default shell in , a different branc
h of Unix. The ash shell is more lightweight than bash, which makes it popular in embedded Linux systems. If you have a with BusyBox installed—or any other device with the BusyBox suite of software—it’s using code from ash.
肯尼斯·阿尔姆奎斯特(Kenneth Almquist)创建了⼀个伯恩(Bourne)壳克隆,称为阿尔姆奎什壳(Almquish shell),“壳”,“灰”或有时仅称为“ sh”。 它也与POSIX兼容,并成为 (Unix的另⼀个分⽀)中的默认Shell。 ash外壳⽐bash轻巧,这使其在嵌⼊式Linux系统中很受欢迎。 如果您有安装了BusyBox的-或安装了BusyBox软件套件的任何其他设备-则使⽤的是ash中的代码。
Debian developed a shell environment based on ash and called it “dash”. It’s designed to be POSIX-compliant and lightweight, so it’s faster than Bash, but won’t have all its features. Ubuntu uses the dash shell as its default shell for
non-interactive tasks, speeding up shell scripts and other tasks running in the background. Ubuntu still uses bash for interactive shells, however, so users still have the full-featured interactive environment.
Debian开发了基于ash的shell环境,并将其称为“破折号”。 它被设计为符合POSIX且轻巧,因此⽐Bash更快,但不会具有所有功能。Ubuntu使⽤破折号外壳作为⾮交互式任务的默认外壳,从⽽加快了外壳脚本和其他在后台运⾏的任务的速度。 Ubuntu仍将bash⽤于交互式shell,因此⽤户仍具有功能齐全的交互式环境。
One of the most popular newer shells is Z shell, or “zsh”. Created by Paul Falstad in 1990, zsh is a Bourne-style shell that contains the features you’ll find in bash, plus even more. For example, zsh has spell-checking, the ability to watch for
logins/logouts, some built-in programming features like bytecode, support for scientific notation in syntax, allows for floating-point arithmetic, and more features.
最受欢迎的较新外壳之⼀是Z外壳,即“ zsh”。 zsh由Paul Falstad在1990年创建,是⼀种Bourne风格的shell,它包含bash中的功能以及更多功能。 例如,zsh具有拼写检查,监视登录/注销的能⼒,⼀些内置的编程功能(例如字节码),对语法的科学表⽰法的⽀持,允许进⾏浮点算术等功能。
Another newer shell is the Friendly Interactive Shell, or “fish”, released in 2005. It has a unique command-line syntax that’s designed to be a bit easier to learn, but isn’t derived from either the Bourne shell or C shell. It’s an interesting idea, but what you learn through using fish won’t necessarily help you use bash and other Bourne-derived shells.
另⼀个较新的外壳是2005年发布的Friendly Interactive Shell(即“鱼”)。它具有独特的命令⾏语法,旨在使其更易于学习,但它并⾮源于Bourne Shell或C Shell。 这是⼀个有趣的想法,但是您通过使⽤鱼学到的知识不⼀定能帮助您使⽤bash和其他Bourne衍⽣的贝壳。
您应该选择哪⼀个? (以及为什么Zsh受欢迎) (Which Should You Choose? (and Why Zsh is Popular))
You don’t need to choose a shell. Your operating system chooses your default shell for you, and that choice is almost always bash. Sit down in front a Linux distribution—or even a Mac—and you’ll almo
st always have a bash shell environment. Bash has quite a few advanced features, but you probably won’t use them unless you program shell scripts.
您⽆需选择外壳。 您的操作系统将为您选择默认外壳程序,⽽该选择⼏乎总是bash。 坐在Linux发⾏版甚⾄Mac的前⾯,您⼏乎总是拥有bash shell环境。 Bash具有许多⾼级功能,但是除⾮您编写Shell脚本,否则您可能不会使⽤它们。
On embedded Linux systems or BSD systems, you’ll end up with the ash shell. But ash is a Bourne-based shell and is largely compatible with bash. Any knowledge you have from using bash will transfer to using an ash or dash shell, although some advanced scripting features are not available in this lightweight shell.
在嵌⼊式Linux系统或BSD系统上,您将获得ash shell。 但是ash是基于Bourne的shell,并且与bash基本上兼容。 您从使⽤bash所获得的所有知识都将转换为使⽤ash或dash外壳,尽管此轻量级外壳中不提供某些⾼级脚本功能。
Almost every shell you’ll encounter is Bourne-based and works similarly—including zsh.
⼏乎您将遇到的每个shell都是基于Bourne的,并且⼯作⽅式相似-包括zsh。
That’s why zsh is popular. This newer shell is compatible with bash, but includes more features. The zsh shell offers built-in spelling correction, improved command-line completion, loadable modules that act as plug-ins for your shell, global aliases that allow you to alias file names or anything else on the command line instead of just commands, and more theming support. It’s like bash, but with a lot of extras, additional features, and configurable options you might appreciate if you spend a lot of time at the command line.
这就是zsh受欢迎的原因。 此更新的外壳程序与bash兼容,但包含更多功能。 zsh shell提供了内置的拼写更正,改进的命令⾏完成功能,充当shell插件的可加载模块,允许您为⽂件名或命令⾏中的其他任何内容加上别名的全局别名,⽽不仅仅是命令,以及更多主题⽀持。 就像bash⼀样,但是如果您在命令⾏中花费⼤量时间,则可能会欣赏很多附加功能,附加功能和可配置选项。
If you’re familiar with bash, you can switch to zsh without learning a different syntax—you’ll just gain additional features. if you’re familiar with zsh, you can switch to bash without learning a different syntax—you just won’t have access to those features.
如果您熟悉bash,则可以切换到zsh,⽽⽆需学习其他语法-您将获得其他功能。 如果您熟悉zsh,则可以在不学习其他语法的情况下切换到bash-您将⽆法使⽤这些功能。
“” is a tool that helps you more easily enable zsh plug-ins and switch between premade themes, quickly customizing your zsh shell without spending hours tweaking things.
“ ”⼯具可帮助您更轻松地启⽤zsh插件并在预制主题之间切换,从⽽快速⾃定义zsh shell,⽽⽆需花费⼤量时间进⾏调整。
There are other shells, too. For example, the tcsh shell is still around and is still an option. FreeBSD
uses tsch as its default root shell and ash as its default interactive shell. If you use the C programming regularly, tsch might be a better fit for you.However, it’s nowhere near as commonly used as bash or zsh.
也有其他外壳。 例如,tcsh shell仍然存在并且仍然是⼀个选项。 FreeBSD使⽤tsch作为其默认的根shell,使⽤ash作为其默认的交互式shell。 如果您定期使⽤C编程,则tsch可能更适合您。 但是,它远不及bash或zsh常⽤。
如何在外壳之间切换 (How to Switch Between Shells)
It’s easy to switch to a new shell to try it out. Just install the shell from your Linux distribution’s package manager and type the command to launch the shell.
切换到新的外壳进⾏尝试很容易。 只需从Linux发⾏版的软件包管理器中安装Shell,然后键⼊命令以启动Shell。
For example, let’s say you want to try zsh on Ubuntu. You’d run the following commands to install and then launch it:例如,假设您要在Ubuntu上尝试zsh。 您将运⾏以下命令来安装然后启动它:
You’d then be sitting at a zsh shell. Type ” exit ” at the shell to leave it and return to your current shel
l.
然后,您将坐在zsh shell中。 在外壳上键⼊“ exit
”离开它并返回到您当前的外壳。
This is just temporary. Whenever you open a new terminal window or sign into your system at the command line, you’ll see your default shell. To change the shell you see when you sign in—known as your login shell—you can generally use the chsh , or “Change Shell”, command.
这只是暂时的。 每当您打开新的终端窗⼝或在命令⾏登录系统时,您都会看到默认的外壳程序。 要更改登录时看到的外壳(称为登录外壳),通常可以使⽤chsh 或“更改外壳”命令。
To use this command, you’ll first need to find the full path to your shell with the which command. For example, let’s say we wanted to change to the zsh shell. We’d run the following command:
要使⽤此命令,您⾸先需要使⽤which命令到您的shell的完整路径。 例如,假设我们要更改为zsh shell。 我们将运⾏以下命令:On Ubuntu, this tells us the zsh binary is stored at /usr/bin/zsh.
在Ubuntu上,这告诉我们zsh⼆进制⽂件存储在/ usr / bin / zsh中。
Run the following command, enter your password, and you’ll be prompted to choose a new login shell:
运⾏以下命令,输⼊密码,系统将提⽰您选择⼀个新的登录shell:
According to the above command, we’d enter /usr/bin/zsh . The zsh shell would then be our default until we ran the chsh command and changed it back.1
sudo apt install zsh 2 3zsh
which zsh
chsh
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论