Home >Operation and Maintenance >Linux Operation and Maintenance >What is the meaning of shell in linux

What is the meaning of shell in linux

小老鼠
小老鼠Original
2023-05-29 11:06:572465browse

The shell in Linux is the user interface of the system. It is actually a command interpreter. It provides an interface for users to interact with the kernel. It is used to receive commands entered by the user and send them to the kernel. to execute. Shell has its own programming language for editing commands, allowing users to write programs composed of shell commands. The Shell programming language has many features of ordinary programming languages, such as loop structures and branch control structures. Using this programming language The shell program written has the same effect as other applications.

What is the meaning of shell in linux

The operating environment of this tutorial: linux5.18.14 system, Dell G3 computer.

The meaning of linux shell

Shell is the user interface of the system, providing an interface for users to interact with the kernel. It receives commands entered by the user and sends them to the kernel for execution.

In fact, Shell is a command interpreter that interprets commands entered by the user and sends them to the kernel. Not only that, Shell has its own programming language for editing commands, which allows users to write programs composed of shell commands. Shell programming language has many features of ordinary programming languages, such as loop structures and branch control structures. Shell programs written in this programming language have the same effect as other applications.

Use of shell

No matter what kind of Shell it is, its most important function is to interpret the instructions entered by the user at the command line prompt. Shell syntax analyzes the command line and decomposes it into symbols (tokens) separated by whitespace. The whitespace includes the tab key (tab), whitespace and newline (New Line). If these words contain metacharacters, the shell will evaluate their correct usage. In addition, the shell also manages file input and output and background processing. After processing the command line, the shell looks for commands and starts executing them.

Another important function of Shell is to provide a personalized user environment, which is usually done in the shell's initialization file (.profile, .login, .cshrc, .tcshrc, etc.). These files include setting the characteristics of the terminal keyboard and defining windows; setting variables that define search paths, permissions, prompts, and terminal types; and setting variables required by specific applications, such as windows, word processing programs, and programming language libraries. The Korn shell and C shell have enhanced personalization capabilities: adding procedures, aliases, and built-in variable sets to prevent users from accidentally deleting files, inadvertently checking them out, and notifying users when work is completed.

Shell can also be used as an interpreted programming language. A shell program, usually called a command file, consists of commands listed in a file. This program is edited in an editor (although the program can also be written directly under the command line (online scripting)) and consists of UNIX commands and basic program structures, such as variable specification, test conditions, and loops. You do not need to compile the shell command file. The shell itself interprets each line in the command file as if entered from the keyboard. The shell is responsible for interpreting the commands, and the user must understand what the commands do. Listed below are some useful commands and how to use them.

Necessary basics for getting started

Building and running programs

What is a shell program? Simply put, a shell program is a shell program that contains several lines or Linux command file.

Like writing a high-level language program, writing a shell program requires a text editor. Such as VI, etc.

In a text editing environment, according to the grammatical rules of the shell , enter some shell/linux command lines to form a complete program file.

There are three ways to execute a shell program file

⑴#chmod x file (in /etc /profile, add export PATH=${PATH}:~/yourpath, you can run it directly from the command line, just like executing ordinary commands)

⑵#sh file

⑶# . file

⑷#source file

When writing a shell, the first line must indicate the kind of shell the system needs to interpret your shell program, such as: #!/bin/bash,# !/bin/csh,/bin/tcsh, or #!/bin/pdksh .

The above is the detailed content of What is the meaning of shell in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn