Home  >  Article  >  System Tutorial  >  Linux Shell Battle: Features and Benefits of Five Popular Command Line Interfaces

Linux Shell Battle: Features and Benefits of Five Popular Command Line Interfaces

WBOY
WBOYforward
2024-02-11 12:50:12491browse

Linux shell is a command interpreter for executing other programs in the operating system. It is also a complete programming language with its own syntax and structure. Linux shell allows users to control and manage the system by entering text commands to achieve various functions and tasks. Linux has many different types of shells to choose from, each with their own pros and cons and suitable for different users and scenarios. This article will introduce you to the five most commonly used open source shells on Linux, which are:

  • Bash shell: A free version of the Bourne shell developed by the GNU Project and is the standard shell on all Linux distributions with powerful scripting capabilities and usability.
  • Zsh shell: An extended version of the Bourne shell, a highly customizable Linux shell with many new features and support for plugins and themes.
  • Fish shell: A modern command line interface with auto-suggestion, tab completion, and syntax highlighting for a smart and user-friendly Linux shell.
  • Ksh shell: A reimplementation of the Bourne shell developed by AT&T Bell Labs. It has command line editing, job control and other functions. It is a classic and stable Linux shell.
  • Tcsh shell: An enhanced version of the C shell using the vanilla C syntax model, with aliases, history, filename completion, and more, a Linux shell for C and C programmers.

1. Bash Shell

Brian Fox developed Bash for the GNU Project in 1988 as a free version of the Bourne shell. Bash is similar to the original version, but adds features such as command line editing.

Because Bash is the standard GNU shell, it has become the standard shell on all Linux distributions. Most modern Linux distributions now come with a Bash shell by default. This open source Linux shell is known in the community for its robust feature set and usability. The name is an acronym for "Bourne-Again SHell".

Linux shell 大比拼:五种流行的命令行界面的特点和优势

One of the reasons Bash is considered so powerful is because it is scriptable. Shell scripts are isolated lists of commands to optimize any task and be cost-effective, similar to other programming languages ​​with well-defined standards. You can enter anything into Bash manually, or you can list it in a plain text file and let Bash run it for you.

Learning Bash is very useful for performing automation. It is very powerful and has many features such as:

  • Directory operations
  • Job Control
  • Brace expansion
  • Tilde expansion
  • Alias
  • Command history
  • Command line editing
  • Keybinding
  • Integrated programming functions
  • Control structure
  • Dynamic loading of built-in plug-ins

Linus Torvalds, the creator of the Linux kernel, said that the first two programs he ran on the new kernel in 1991 were Bash and gcc, GNU's compiler.

2、Zsh Shell

Zsh (short for Z shell) is an extended version of the Bourne Shell with many new features and support for plugins and themes. It is a highly customizable Linux shell that includes some very powerful features such as tab completion, smart history, remote file expansion, and more. Zsh is a shell designed for interactive use, although it is also a powerful scripting language. Many useful features from Bash, Ksh, and Tcsh have been merged into and added to Zsh.

Linux shell 大比拼:五种流行的命令行界面的特点和优势

Zsh was developed by Paul Fastad in 1990. The name zsh comes from Yale University professor Zong Shao. It has become one of the most popular shells for Linux operating systems.

Some of the more important Zsh functions are:

  • Command autocomplete
  • Improved variable handling
  • Spelling correction
  • Sharing command history
  • Environment variable setting is simple
  • custom made

When you use Linux, most of your user time is spent in the terminal. If you want to customize your terminal and make it look professional, you can use Oh My Zsh to achieve this goal. It is a community-driven open source framework for managing Zsh configurations. There are other frameworks for Zsh, such as Prezto, Zgen, Antigen, etc. Currently Oh My Zsh can support 150 themes and 275 plug-ins.

Zsh and Bash both have similar and impressive features, but also have their own unique tools. If you are looking for extensibility, greater customization, and advanced features not found in bash, the zsh shell is a great choice. Additionally, Zsh is the default login and interactive shell in macOS Catalina, replacing Bash.

Related: https://www.linuxmi.com/ubuntu-20-04-zsh.html

3、Fish

Fish shell is a modern command line interface with auto-suggestion, tab completion and syntax highlighting. It is a smart and user-friendly command line shell for Linux and macOS. The shell provides users with powerful functionality and control without sacrificing speed or efficiency. It is designed to be used out of the box without extensive configuration.

Linux shell 大比拼:五种流行的命令行界面的特点和优势

History-based inline auto-suggestions for Fish come out of the box. Using your history, Fish suggests the next possibility for completing the command.

This shell is more colorful than the classic Bash shell. You'll quickly notice that Fish performs syntax highlighting as you type. These colors and more can be changed by running fish_config. This will open a web-based GUI where you can select a color theme and configure the appearance of the shell.

Another great feature is the availability of commands. For example, if you type /usr/bin/linuxiac, it will show the line in red, indicating that it is not a valid command, but if you type /usr/bin/ping it will look normal.

Fish shell features:

  • Inline auto-suggestions based on history
  • Excellent tag completion
  • Syntax Highlighting
  • Intuitive wildcard support
  • Network-based configuration
  • Sound script

For users of other shells such as zsh, bash, etc., if they want to try a new and advantageous shell, Fish is a very powerful and useful Linux shell.

Related: FISH: Linux shell for post-90s generation https://www.linuxmi.com/fish-linux-shell.html

4、Ksh shell

Ksh (short for Korn shell) was invented by David Korn of AT&T Bell Labs and came into public life in 1986. It is a reimplementation of the Bourne shell. The Ksh shell's command editor interface enables quick and easy correction of input errors, as well as easy recall and reuse of command history. It does not provide command completion, but it does provide filename completion. Ksh allows developers to create new shell commands when needed.

Linux shell 大比拼:五种流行的命令行界面的特点和优势

Ksh shell’s command line editing mode is the feature that tends to attract people to it in the first place. With command line editing, it's much easier to go back and fix errors. Another major Ksh feature aimed primarily at interactive users is job control.

Some of the more important Ksh functions are:

  • Job Control
  • Alias
  • Function
  • Command history
  • Command line editing
  • Integrated programming functions
  • Control structure
  • Debugging primitives
  • Commonly used expressions
  • Advanced I/O features

Ksh shell has been released in different versions such as pdksh, mksh, ksh88 and the latest ksh93.

5、Tcsh Shell

In the original days of Linux, the C and C programming languages ​​were very popular, and much of Linux itself was written in them. As expected, a new shell emerged, the C Shell using the vanilla C syntax model. Tcsh is an enhanced but fully compatible version of Berkeley UNIX csh (C Shell). It is a command language interpreter that can be used as an interactive login shell and a shell script command processor. Tcsh can be considered the next generation C shell.

Linux shell 大比拼:五种流行的命令行界面的特点和优势

Tcsh was developed by Ken Greer at Carnegie Mellon University in 1979. The "t" in tcsh comes from the "T" in TENEX, an operating system developed by BBN in 1969 for the PDP-10 family of mainframe computers.

Early versions of MacOS X shipped with tcsh as the default shell, but newer versions the default becomes Bash. tcsh is now FreeBSD's default root shell.

The main functions of Tcsh are programmable command completion and command line editing. It strikes a good balance between stark simplicity and basic functionality. All the documentation you need to use tcsh is in man tcsh, rather than scattered among various help programs.

Summarize

Through the introduction of this article, you should already have a comprehensive and in-depth understanding of these five Linux shells. They are all useful tools for executing commands and writing scripts on Linux, helping you to be more efficient and flexible. Of course, this is just a small selection of shells that we have carefully selected. There are many other excellent shells in the Linux software repository waiting for you to discover and try. We recommend that you explore and install more Linux shells based on your own needs and preferences to make your Linux command line interface more powerful and personalized.

The above is the detailed content of Linux Shell Battle: Features and Benefits of Five Popular Command Line Interfaces. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:lxlinux.net. If there is any infringement, please contact admin@php.cn delete