SHELL a usage basis

 

1. SHELL introductory programming concepts
1) a complete Linux operating system (Linux kernel), the default user is not directly manipulate the Linux kernel, it needs third-party programs or software to operate, such as desktop tools, command-line tool (SHELL).
2) SHELL Linux operating system shell, SHELL program may be understood as middleware, a bridge located between the user and Kernel, SHELL mainly instructions for receiving user input, instruction parsing, and sent to the Linux kernel .
3) Linux kernel after receiving the instruction, will be processed, the data will be processed information back to the SHELL, SHELL eventually display the parsed data (return) to the user the user.
. 4) SHELL software systems similar to Windows command line CMD, SHELL as a command interpreter, the user inputs an instruction, the data returned by the final SHELL interpreter.
5) Most of the Linux operating system (Linux kernel), after the start, start the default SHELL program (interpreter), CentOS, RHEL, Ubuntu system SHELL program: / bin / bash, SHELL compare species range of different SHELL Integrated
Command is not the same, not the same user interface.
6) SHELL programming concepts?
 SHELL program is written in SHELL interpreter different instruction, different instructions according to a certain logic and sequence deposited in a text file (SHELL script), the final text file instruction to execute SHELL interpreter, a requirement to complete the whole process is called SHELL programming.
7) SHELL programming specification?
 SHELL program is the product of SHELL script;
 script name suffix to .sh ending;
 script name can use uppercase and lowercase letters, numbers, -, _ name, recommended
Lowercase script with content related keyword name;  script contents of the first line starts with #! Beginning, emphasis and identification, then followed by SHELL interpreter type;
 SHELL code programming time, as much as possible the use of notes and descriptions;
8) the significance SHELL programming?
2. SHELL programming combat Nginx WEB platform (v1 version)
1) Nginx Nginx official website to download the stable version of the package;
2) extracting the package & Nginx enters the source code directory;
3) install Linux basic library system, dependent files;
4) pre-compiled, check Linux systems GCC, libraries, will produce Makefile;
5) compile, execute, make the tool reads the Makefile, call the C compiler;
6) is mounted, will make the compiler generates a binary file copied to the specified directory;
7) Start the Nginx binary way to start the process, to provide services outside access;
#!/bin/bash
#2019 年 7 月 1 日 21:19:03#auto install nginx web.
#by author www.jfedu.net
#########################
yum install -y wget tar gzip make openssl-devel
yum install -y gcc pcre pcre-devel zlib-devel
wget -c http://nginx.org/download/nginx-1.16.0.tar.gz
tar -xzf nginx-1.16.0.tar.gz
cd nginx-1.16.0
useradd -s /sbin/nologin www -M
./configure --prefix=/usr/local/nginx --user=www
--group=www
make
make install
/usr/local/nginx/sbin/nginx
ps -ef|grep nginx
netstat -tnlp|grep 80
setenforce 0
systemctl stop firewalld.service
3. SHELL programming variable analysis (Nginx v2 version)
1) variable is a variable value, with a constant (fixed value) is opposed, the value of the random variable is modified, used = variable assignment, for example, A = www.jfedu.net, when the reference value of the variable, use $ A. The main variable is commonly used for temporary recording information,
Variable information stored in the memory buffer disappears, reboot the system variables.
2) When the variable information may be reduced subsequent to use, simple, reduce complexity, similar alias alias mechanism.
3) SHELL program variables divided into three types:
 user variables
User variables are called user-defined variables, local variables, temporary force,
E.g:
A=www.jfedu.net
WEB = www.baidu.com
X_M=1101011994
 System Variables
System variables are variables built Linux system, is the definition of a parameter, a reference, the determination result or the like, permanent, for example:
? $ Execute a command on the judging success or failure;
$ Given first position parameter when executing the script call 1;
 Environment Variables
4)
#!/bin/bash
#2019 年 7 月 1 日 21:19:03#auto install nginx web.
#by author www.jfedu.net
########################
NGX_VER="1.16.0"
NGX_YUM="yum install -y"
NGX_DIR="/usr/local/nginx"
NGX_SRC="nginx-$NGX_VER"
NGX_SOFT="nginx-${NGX_VER}.tar.gz"
NGX_ARGS="--user=www --group=www"
NGX_URL="http://nginx.org/download"
$NGX_YUM wget tar gzip make openssl-devel
$NGX_YUM gcc pcre pcre-devel zlib-devel
wget -c
$NGX_URL/$NGX_SOFT
tar -xzf $NGX_SOFT
cd $NGX_SRC
useradd -s /sbin/nologin www -M
./ configure --prefix = $ NGX_DIR $ NGX_ARGS 
$ NGX_DIR / sbin / nginxps -ef | grapefruit nginx
make
make install 
netstat -tnlp | grapefruit 80 
setenforce 0 
systemctl stop firewalld.service

Guess you like

Origin www.cnblogs.com/nsh123/p/12156829.html