0
点赞
收藏
分享

微信扫一扫

TCP协议的相关特性

殇感故事 2023-06-13 阅读 102
bashlinux

Linux基础知识 适合有Linux基础的人群进行复习。 禁止转载!

shell编程

shell第一行内容格式?

        #!bin/sh,#!bin/bash,#!/bin/csh,#!/bin/tcsh或#!/bin/ksh等

执行shell脚本的三种方式

      (1)为shell脚本直接加上可执行权限再执行,如:

        chmod 755 ljh.sh       //为shell脚本直接加上可执行权限

        ./ljh.sh                         //执行shell脚本ljh.sh

      (2)通过sh(或bash等)命令执行shell脚本,如:

        sh ./ljh.sh      或   bash ./ljh.sh

      (3)通过source命令(或点.命令)执行shell脚本,如:

      source ./ljh.sh  或 . ./ljh.sh  (两点之间有个空格且./可省略)

          注意:source命令也称为“点命令”,可以用点符号(“.”)代替。

shell的系统变量:$0,、$?、 $#、 $n、 $*等表示的含义

分支结构——test命令;

(1)整数:-lt(小于)、-le(小于或者等于)、-gt(大于)、-ge(大于或者等于)

eg1.判断3是否小于4

              test 3 -lt 4

              echo $?          //返回上次判断的结果,为0

eg2.判断3是否大于4

              test 3 -gt 4   或者   [ 3 -gt 4 ]

              echo $?          //返回上次判断的结果,为1

(2)字符串:=(等于) 和 !=(不等于)

       eg1.判断abc是否等于 abc

              x =”abc”

              test $x = “ abc ”

              echo $?

(3)文件:-f file ;      -d file;          -c file;

-z  str:  如果字符串str的长度为0,则测试条件为真

-n  str;

使用方括号表示测试条件的规则是:(test命令的等价命令)

        方括号两边必须有空格

eg1. 判断$SUM是不是在10和20之间

       [ “$SUM” -gt 10 -a “$SUM” -lt 20 ]

set 命令:

        设置参数值;

shell中单引号、双引号、倒引号

       单引号:将单引号里面的内容一模一样的输出。                强引用类型

       双引号:将双引号里面的内容输出,但对$等特殊字符特殊处理。                弱引用类型

       倒引号:用命令结果代替命令本身,然后用来操作。

              eg.

                #! /bin/bash

                describe="this is a demo"

                #单引号输出,特殊字符不处理

                echo 'I want to say $describe,\t  current path: `pwd`'

                #双引号输出,特殊字符处理

                echo "I want to say $describe,\t  current path: `pwd`"

执行结果:

分支结构——if语句、 for语句

注意要用fi 收尾

for ... do ... done

利用shift访问参数变量

echo命令---提示用户 : echo -ne

       参数n代表输出完毕不换行,e代表支持转义字符

read命令---接受用户输入

       eg. 将用户的输入信息的前8个字符读入给str

             read -n 8 –p  “Please input some words:” str

             # 显示  Please input some words: happy birthday

             echo $str

             # 显示str  happy bi

Linux网络基本配置与网络安全

网络配置命令:

        ifconfig、route命令设置网卡IP地址和网关

关闭/激活网卡eth0命令:

        ifconfig  eth0  down/up

主机访问控制文件hosts.deny和hosts.allow中添加相关规则

Linux系统下防火墙ufw的关闭、使能与端口开放/关闭命令

        ufw enable

        ufw disable

        ufw allow或deny 端口号

重新启动某个服务的命令(例如ftp服务器)   三种方法:

                   service  vsftpd  restart

          或      /etc/init.d/vsftpd restart

          或      systemctl  restart vsftpd

Web、Ftp、Samba与NFS服务器配置

软件包在线安装命令:

        apt-get install apache2 或

        apt-get install vsftpd 或

        apt-get install nfs

启动、停止、重启ftp服务、Web服务(apache2)的命令?

       ftp服务:  vsftpd                                   

/etc/init.d/vsftpd start 或 service apache2 start 或 systemctl start apache2

/etc/init.d/apache2 stop 或 service apache2 stop 或 systemctl stop apache2

/etc/init.d/apache2 restart 或 service apache2 restart 或 systemctl restart apache2

       Web服务(apache2)服务:  vsftpd

/etc/init.d/apache2 start 或 service apache2 start 或 systemctl start apache2

/etc/init.d/apache2 stop 或 service apache2 stop 或 systemctl stop apache2

/etc/init.d/apache2 restart 或 service apache2 restart 或 systemctl restart apache2

安全性地实现远程连接的服务器:

        Openssh

特定用户名+密码格式,以命令方式访问ftp服务器:

        ftp   abc:123456@10.64.131.110

举报

相关推荐

0 条评论