Linux shell脚本和常见服务

一、

1.Linux的shell种类众多,常见的有:Bourne Shell(/usr/bin/sh或/bin/sh)、Bourne Again Shell(/bin/bash)、C Shell(/usr/bin/csh)、K Shell(/usr/bin/ksh)、Shell for Root(/sbin/sh),等等。其中Bash是大多数Linux系统默认的Shell。脚本语言是不需要编译就能直接运行。

2.Shell实例执行:

(1)Shell Script是一种弱类型语言,是引用变量的时候无需首先声明其类型,也无需事先定义;

(2)Shell对变量取值的时候要在变量名前加$

Linux shell脚本和常见服务

3.Shell条件判断:

Linux shell脚本和常见服务

shell常见判断:

shell中赋值=两边有无空格是有区别的:等号两边没有空格是赋值;等号两边有空格是比较。

Linux shell脚本和常见服务Linux shell脚本和常见服务

Shell循环:

Linux shell脚本和常见服务

Shell参数:

$#:表示参数的个数;

$0:表示程序的名字;

$1:第一个参数 、$2:第二个参数

$*:表示所有参数

Linux shell脚本和常见服务

Linux shell脚本和常见服务

Linux shell脚本和常见服务Linux shell脚本和常见服务

Linux shell脚本和常见服务

用Shell添加用户:

Linux shell脚本和常见服务

Linux shell脚本和常见服务

Linux shell脚本和常见服务

Linux服务管理:

Linux shell脚本和常见服务

Linux shell脚本和常见服务

TCP端口类似打电话;UDP类似发信息。

linux下ftpd安装:

安装vsftpd

Linux shell脚本和常见服务

使能vsftpd

Linux shell脚本和常见服务

配置vsftpd

cd /etc/vsftpd/;

sudo vim vsftpd.conf

Linux shell脚本和常见服务

网站不能访问可能是防火墙的原因。

Linux shell脚本和常见服务关掉防火墙

ftp://192.168.229.129该网址就能访问了。

Linux shell脚本和常见服务

配置防火墙:

查看vsftpd的端口号

Linux shell脚本和常见服务

打开21号端口

Linux shell脚本和常见服务

Linux shell脚本和常见服务

reject-with icmp-host-prohibited这一句把防火墙的策略改掉了,删掉它,网页就可以访问了。

Linux shell脚本和常见服务

LNMP搭建:

下载一键安装包

Linux shell脚本和常见服务

执行install.sh脚本文件,选择安装版本,以及配置文件即可。

配置文件内容在nginx.conf里

Linux shell脚本和常见服务

服务器存放网页的存放位置:

Linux shell脚本和常见服务

静态网页实例:

Linux shell脚本和常见服务

Linux shell脚本和常见服务

服务器默认的端口:

Linux shell脚本和常见服务