Linux Shell Getting Started instructions

Source: Internet
Author: User
Tags posix

Shell Introduction

The shell itself is a program written in C, which is a bridge for users to use Unix/linux, and most of their work is done through the shell. The shell is both a command language and a programming language. As a command language, it interprets and executes user-entered commands interactively, and as a programming language, it defines variables and parameters and provides many control structures in high-level languages, including loops and branches.

Although it is not part of the Unix/linux system kernel, it invokes most of the functionality of the system core to execute programs, create files, and coordinate the operation of individual programs in a parallel way. Therefore, for the user, the shell is the most important utility program, in-depth understanding and proficiency in the shell characteristics of the extremely use of the method is the key to good unix/linux system.
It can be said that the proficiency of the shell is a reflection of the user's proficiency in the use of unix/linux.
Note: There is no point in learning the Shell alone, please refer to the Unix/linux Getting Started tutorial to learn Unix/linux basics.
The shell has two ways of executing commands:
Interactive (Interactive): Explains the execution of a user's command, the user enters a command, and the shell interprets the execution of a single rule.
Batch: The user writes a shell script in advance, with a number of commands that allow the shell to execute the commands at once without having to hit the command one at a time.
Shell scripts are similar to programming languages, and there are variables and process control statements, but shell scripts are interpreted and do not need to be compiled, and the shell program reads and executes the commands from a single line of script, which is equivalent to a user knocking a line of commands from the script to the shell prompt for execution.
For Shell Beginners Please note that in a normal application, it is not recommended to run the shell with the root account. As a normal user, no matter whether you intentionally or unintentionally, can not destroy the system, but if it is root, it is different, as long as a few letters, can lead to disastrous consequences.
The difference between the Shell scripting language and the compiled language is that the programming language can be divided into two categories: compiled and interpreted languages
Compiled LanguagesMany of the traditional programming languages, such as Fortran, Ada, Pascal, C, C + +, and Java, are compiled languages. These languages require that the source code that we have written be converted into a target tag (object codes), and this process is called "compiling".
When you run the program, read the object code directly. Because the compiled object code is very close to the bottom of the computer, the execution is very efficient, which is the advantage of a compiled language.
However, since most of the compiled languages work on the ground floor, dealing with bytes, integers, floating-point numbers, or other machine-level objects, it is often necessary to implement a simple function that requires a lot of complex code. For example, in C + +, it's hard to do simple things like "copy all files from one directory to another."
interpreted LanguageInterpreted language is also known as the "scripting language". When executing such a program, The interpreter (interpreter) needs to read the source code that we wrote and convert it to the target (object), which is then run by the computer. Because each execution of the program is more than the compilation process, so efficiency has decreased.
The advantage of using scripting languages is that they are mostly run at a higher level than the compiled language and can easily handle objects such as files and directories, and the disadvantage is that they are often less efficient than compiled languages. However, the tradeoff is that scripting is usually worthwhile: a simple script that takes one hours to write, the same functionality written in C or C + +, can take up to two days, and, in general, the speed of the script execution is fast enough to let people ignore its performance problems. Examples of scripting languages are awk, Perl, Python, Ruby, and Shell.
When to use the shell because the shell appears to be a common feature between UNIX systems and is standardized by POSIX. As a result, shell scripts can be applied to many systems once they are "written attentively". Therefore, the reason to use shell scripts is based on:
Simplicity: The shell is a high-level language through which you can express complex operations succinctly.
Portability: Using POSIX-defined features, scripts can be executed on different systems without modification.
Easy to develop: a powerful and 妤 script can be completed in a short period of time.
However, given the command restrictions and efficiency of shell scripts, the following situations do not typically use the shell:
    •     Resource-intensive tasks, especially when you need to consider efficiency (such as sorting, hashing, and so on).
    •     Mathematical operations that need to handle large tasks, especially floating-point operations, precision operations, or complex arithmetic operations (typically handled using C + + or FORTRAN).
    •     have cross-platform (OS) porting requirements (typically C or Java).
    •     Complex applications where structured programming is necessary (requires type checking of variables, function prototypes, and so on).
    •     for mission-critical applications that affect the overall system.
    •     Tasks that are highly demanding for security, such as requiring a robust system to prevent intrusion, cracking, malicious destruction, and so on. The
    •     Project consists of a series of dependent parts.
    •     requires large-scale file operations.
    •     support for multidimensional arrays is required.
    •     requires support for data structures, such as linked lists or numbers.
    •     need to produce or manipulate graphical interface GUI.
    •     requires direct operating system hardware.
    •     requires an I/O or socket interface.
    •     interfaces that require the use of libraries or legacy old code.
    •     Private, closed-source applications (the shell script puts the code in a text file, as the world can see it).
If your app fits any of the above, consider a more powerful language-perhaps Perl, Tcl, Python, ruby--, or a higher-level compilation language such as C + + or java. Even so, you'll find that using the shell to prototype your application is also very useful in the development steps.
Several common shells mentioned above, the shell is a scripting language, then there must be an interpreter to execute these scripts.

The common shell scripting interpreters on Unix/linux include bash, sh, csh, Ksh, and so on, which are used to call them a shell. We often say that there are many kinds of shells, actually speaking of shell script interpreter.
Bash Bash is the default shell of the Linux standard,This tutorial is also based on bash. The bash was completed by Brian Fox and Chet Ramey, a bourneagain shell abbreviation with 40 internal commands.
Linux uses it as the default shell because it has features such as the following:
    • You can use the functions of doskey like DOS to view and quickly enter and modify commands with the arrow keys.
    • A command that begins with a string is automatically given by finding a match.
    • Contains its own Help function, you can just type help below the prompt to get related assistance.

Note: BASH is the acronym for the Bourne Again shell, the default shell for the Linux standard, which is based on the Bourne shell and absorbs some of the features of the C shell and Korn shell. Bash is fully compatible with SH,

In other words, a script written in SH can be executed without modification in bash.

SH sh, developed by Steve Bourne, is the abbreviation for the Bourne Shell, which is the default shell of the UNIX standard.
The ash ash shell was written by Kenneth Almquist, a small shell that occupies the least system resources in Linux, and it contains only 24 internal commands, making it inconvenient to use.
CSH CSH is a Linux-based kernel that consists of 47 authors, represented by William Joy, and has 52 internal commands. The shell is actually a shell that points to/bin/tcsh, which means that csh is actually tcsh.
Ksh Ksh is an abbreviation for the Korn shell, written by Eric Gisin, with a total of 42 internal commands. The biggest advantage of the shell is that it is almost completely compatible with the ksh of the commercial distribution, so you can try out the commercial version of the performance without having to pay for the commercial version.

Transferred from: http://c.biancheng.net/cpp/view/6994.html

Linux Shell Getting Started instructions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.