Shell introduction

xiaoxiao2021-03-06  110

Shell When we log in to Linux, the first contact is the shell. We must have a little awareness of it. I. Introduction to Shell. Linux system divided into three important part of the core Shell tool program It is quite low-order, the operator is not easy to communicate directly, so there must be a friendly interface, making it easier to operate, this interface is shell. In other words, shell is a core and operator A layer of user interface. So, why, why call it for shell? The meaning of shell is "shell" means! Yes, outside the core, cover a layer of housing, used to receive users Input instructions, then interpret the instruction into the core, pass to the core, then transfer the result back to the preset output perimeter. As shown: For example: Type the ls -l shell give you the following response : Focusing the case file size record size Recent revised class file permissions number owner group (Byte unit) Date and time file name DRWXR-XR-X 14 root root 1024 JUL 21 21:31. Drwxr-xr-x 17 root root 1024 APR 11 12:01 .. drwxr-xr-x 8 82 82 1024 Feb 25 19:23 Apache -rw-r - r - 1 root root 1335460 Feb 25 17:45 Apache_1_3_4.tar.gz drwxr -XR-x 6 root root 1024 AUG 31 1998 FTP DRWXR-XR-X 5 root root 1024 AUG 31 1998 httpd drwx ------ 2 James James 1024 APR 23 06:47 James DRWXR-XR-X 2 root root 12288 AUG 31 1998 Lost

Found DRWXR-XR-X 2 MSQL Nobody 1024 DEC 28 1998 MSQL DRWXR-XR-X 28 OLS3 OLS3 2048 JUL 19 21:38 OLS3 DRWXR-XR-X 3 1022 Nobody 1024 Jan 25 23:40 OLS3CGI DRWXRWR-X 3 Perl OLS3 1024 Feb 2 07:11 Perl -rw ------- 1 root root 2097152 jul 21 18:39 quota.group -rw ------- 1 root root 1278656 jul 21 18:39 quota.user drwxrwxr -x 2 root nobody 1024 May 11 1998 Samba DRWXR-XR-X 3 Apache Nobody 1024 Feb 25 16:58 Temp DRWXRWXR-X 2 Webadm Nobody 1024 Mar 14 16:34 Webadm is not just Linux has this layer shell, other homework The system is also available. For example, DOS Command.com, Windows GUI (Graphical User Interface), Mac's GUI. Shell can be divided into two categories: Text Base: Text Guide Graph Base: Type-oriented so-called "read users into the types"

It means: read the keypad, or read the self-scratch, other serial input, screen touch, etc. This is, the shell seems to be just the command direct translator ?! Well, this will be given by different OS. Shell's functional and selective freedom. In terms of DOS's command.com, it is a full command direct translator. In addition to a little bitch file, it does not have much function. Win platform GUI, is a diagram model command direct translator, and the interface is very friendly. However, these two OS do not allow you to freely choose the shell. (Former DOS has 4DOS optional) Linux's shell, in addition to being command translation In addition to the device, it is also a good programming. It is an important tool for system management maintenance. Due to the UNIX family, the SHELL is handled, and therefore, the type of shell is quite, more Free replacement (chsh). At present, popular Shell: Bourne Shell: SH c shell: CSH Korn shell: KSH (commercial Soft) TCSH (free) BOURNE AGAIN shell: Bash (gnu) The standard shell of Bash (GNU) Linux is Bash. It It is also the main object we have to learn. Second. The first important shell of the shell is a Bourne Shell (so naming to commemorate the inventor Steven Bourne, the first popular UNIX version 7 in 1979 I started using the Bourne Shell. Bourne Shell's primary file named SH, so people will be the main identification name of the Bourne Shell in the future. Although there are many kinds of shell on UNIX, the position of the Bourne Shell is still not changed. Many The Unix system still uses SH as an important management tool. (It works from boot to shutdown, almost all packaged) The first SHELL variant is C shell. C shell is mainly attached to the BSD version During UNIX system. Its author is the Bill Joy. C shell of the University of Berklai is mainly because of its grammar and C language. This makes the Unix system's programmaster, feel quite place. It is easy. The above two two major mainstreams forming the shell, and the subsequent migraries shell will draw the advantages of these two shells. Bash Shell is an important tool software of the GNU program, and the GNU job The standard shell in the system is compatible with the SH, so many early development Bourne Shells can continue to work in BASH. Now we have a installed redhat Linux completely use Bash. (/ Bin / sh ->

/ bin / bash) Bash born in 1988, the initial author is Brian Fox, Chet Ramey to join in 1989. Now the official official maintainer is Chet Ramey, his work is to continue to enhance Bash's function. 1995 ~ 1996 During the period, Bash 2.0, before this, the wide-use version is 1.14.x, which adds many new features, and better compatibility. Of course, Bash is completely free, it is a member of Open Source All the original code is all open. II. Bash features. BASH has the following functions: Compaminated Bourne Shell (SH) contains the best features in C shell and Korn Shell. With the ability to make a column remember (you remember DOS before DOS DOSKEY?) The ability to work control (Job Control), can control the ability of the foreground and background program shell design, allowing you to keep the shell and design program, management system. Third. Where is the new version of Bash crawled? If you want to grab the new version of Bash, you can go to http://www.gnu.org or its Mirror Station. The Sino-research Institute FTP is also a good choice. Ftp://ftp.sinica.edu.tw or ftp: //linux.sinica .edu.tw III. Start using Bash When you log into the Linux host, start with BASH interact, until you logout host (lower exit, logout, or press ^ D). Bash's prompt symbol $ (Representative Identity Users) When you have root permissions, the prompt symbol changes to #. When prompted symbols, you can start typing the operation command column. The command can be divided into two categories: BASH built The instruction program is responsible for responding by the BASH shell; if it is a program, the shell will find the program, then give the control to the core, execute the program, after execution, will then control The right is handed back to shell. How do you know that the instruction is built in Bash, those are the program? Usually use "Which Directive", if there is no response, it is a built-in instruction (unless the instruction is wrong, there is no existence, or The program is not within the preset search path), such as the following: [OLS3 @ ols3 / ols3] $ Which ech o [No response, expressed as built-in instruction] [OLS3 @ OLS3 / OLS3] $ which ls / bin / ls 4. The format of the command column is usually composed of several strings, the intermediate blank or Tab key is separated. As shown below: Command Options Arguments (or parameters) Command Option parameter rm -rf / home / ols3 In addition to the blank and Tab keys, each part, we call Token, such as the above example, There are three token: rm, -rf, / home / OLS3. When you type this command, the shell first breaks it into individual token, and then determines that the built-in instruction, or a program, and then press it before Way to execute. How do you know a command or program? Is there any options and parameters? Usually the mana will get the instruction, for example: Man RM In addition, multi-line instructions can also be written in the same command column. As long as the intermediate; separate, such as: ls; mkdir test;

Clear 5. Current directory and self-director. The current directory refers to the location of you now, also known as a working directory (Working Directory). Do you know the current directory? Home Directory means that when root sets your account for you, you are specified to give you a private directory, which is also the first place to enter the system. To know your own directory, you can use the following way: CD (then press ENTER) CD ~ (~ represent your own directory) CAT / etc / passwd | grep Your account related tips CD ./myway (enter the Myway directory in current directory) CD .. Layer Directory) CD - (Go back to the previous directory) 6. Wanli-by-element. If the parameter of the command is included, the Wildcards can bring a very convenient action. (But if used Improper, the beginning of the nightmare) If you have experienced DOS, you should still remember the meaning of * and what you represent? The following is the multi-purpose character used in Bash:? Represents any single word (Character) ) * Represents any string (note: 0 or more characters, examples: * YES will include Yes or Yes-OR-NOT) [By combination] The characters in the middle brackets are in line with, such as: [AZ] Representing all lowercase letters [! By combination] The characters in the middle brackets are all in line with, such as: [! 0-9] represents the non-figures of the characters, all in line with seven. Input and output and restructive. When the Linux system is completed After booting, there is three files, and the three files are used as input, output, and display errors. We call: standard input: usually the keyboard, file code is 0 standard output: usually It is the screen, the archive code is 1 standard error: usually the same standard output is the same (that is, the screen), the archive code is 2 although the system has helped you set these three files, but we can still change the input, output timely. And errors these three to different places. This change of the standard output, we call "I / O render" (I / o redIction). For example: ls -la> myfile is the result of the query Redirect to myfile (originally should appear on the screen) Cat Myfile can see the result of LS -LA. Cat < MyFile> YouFile is to copy myFile content to youfile.> The mechanism that turns the output to

转载请注明原文地址:https://www.9cbs.com/read-126728.html

New Post(0)