Networks, processes, scripts

Blog assignments

1. What is the OSI seven-tier model?

Physical Layer, Data Link Layer, Network Layer, Transport Layer, Session Layer, Representation Layer and Application Layer

2. Are there any terminal modes of switches? What are their functions?

Access type ports: can only belong to one VLAN, generally used to connect computer ports.
Trunk type ports: can allow multiple VLANs to pass, can receive and send multiple VLAN messages, commonly used for switch-related interfaces.
Hybrid Port: It allows multiple VLANs to pass through, receives and sends multiple VLAN messages, and can be used for connection between switches as well.
Connect the user computer.

3. Briefly describe the difference between Class and Class_routing protocols?

1. Classified routing does not recognize subnet information.
2. Classless routing protocols will not be identified according to class A B C, and network segments will be distinguished according to the length of subnet mask.
3. Classified routing protocols only transmit network prefixes (network addresses), but do not contain subnet masks. 4. Classless routing protocol transport network prefix (network)
Network address) also transmits subnet mask, so it supports VLSM.
From the perspective of management distance, classless routing protocols are generally used in subnets, so the distance is small.

4. Briefly describe the working principle of stp.

STP (Spanning Tree Protocol) is the abbreviation of Spanning Tree Protocol. This protocol can be applied to establish tree topology and eliminate network.
The two-tier loop can achieve path redundancy through certain methods, but it is not always possible to achieve path redundancy.
The principle is to determine the network topology by passing a special protocol message, the bridge protocol data unit, between switches.

5. Advantages and disadvantages of TCP protocol and udp protocol?

1. TCP is connection-oriented; UDP is connectionless, i.e. there is no need to establish a connection before sending data.
2. TCP provides reliable services. That is to say, data transmitted through TCP connection is error-free, lost, duplicated and arrived in sequence; UDP is the largest.
Efforts to deliver do not guarantee reliable delivery.
3. UDP has better real-time performance and higher work efficiency than TCP. It is suitable for high-speed transmission and real-time communication or broadcasting communication.
4. Each TCP connection can only be point-to-point; UDP supports one-to-one, one-to-many, many-to-one and many-to-many interactive communications.
5. TCP requires more system resources, UDP requires less system resources.
UDP replaces TCP in more and more scenarios because of its advantages of simplicity and fast transmission. (1) The improvement of network speed provides reliable network guarantee for the stability of UDP, and the packet loss rate is very low. If the application layer is used to retransmit, the reliability of transmission can be ensured.
(2) In order to realize the reliability of network communication, TCP uses complex congestion control algorithm and establishes a tedious handshake process. Because of the built-in system of TCP.
In protocol stack, it is very difficult to improve it.

6. Briefly describe the process of tcp three-time grip and four-time swing and the state of client and server in each process?

Three handshakes
 The client sends the SYN package to the server, and the client enters the SYN_SEND state.
The server receives the package sent by the client and returns the ACK+SYN package. The server enters the SYN_RECV state.
The client receives the returned package from the server and sends it back to the ACK package. The client enters the ESTABLISHED status, and the server receives the package and enters the ESTABLISHED status.
Status.
Four waves
 The client sends FIN packet to ask whether the server can disconnect and the client enters FIN_WAIT_1 state.
The server receives the package sent by the client and returns the ACK package. The server enters the CLOSE_WAIT state.
When the server is ready to disconnect, it sends FIN package to the client, and the server enters LAST_ACK state.
After receiving the package sent by the server, the client returns to the ACK package, the client enters the TIME_WAIT state, and the server enters the CLOSED state after receiving the package.

7. Network Card Name Modification

[root@magedu ~]# nmcli connection modify zhangsan connection.id ens34-office

8. Restore deleted files

lsof |grep /var/log/messages
rm -f /var/log/messages
lsof |grep /var/log/messages
cat /proc/653/fd/6
cat /proc/653/fd/6 > /var/log/messages

9. Bulk creation of households, options.

FILE=`cat /data/lianxi/name.txt`

if [ "$1" = '-c' ];then
    {
    for USER in $FILE ;do

        if id $USER &>/dev/null;then
            echo "$USER is exist!"
        else
            useradd $USER
            PASS=`cat /dev/random |tr -dc '0-9a-z'|head -c6`
            echo $USER:$PASS >> /data/pass.txt
            echo $PASS | passwd --stdin $USER &>/dev/null
            passwd -e $USER
            echo "$USER is created"
        fi

    done
    wait
}
elif [ "$1" = '-r' ];then
    for USER in $FILE;do
        userdel -r $USER &> /dev/null
        echo $USER is removed
    done
else 
    echo "Usage: `basename $0` -c | -r "
fi

10. Scanning address segments

NET=114.112

for SUBNET in {1..254};do

    {
    for HOST in {1..254};do
        ping -c1 -w1 $NET.$SUBNET.$HOST &> /dev/null && echo $NET.$SUBNET.$HOST is up  |tee -a /data/lianxi/hostlist.txt 

    done
    wait

}&  
done
wait

11. Stars, random flashes.

BEGIN='\033[1;5;'
END='\033[0m'
read -p "Line: " line
read -p "Col: " col
for i in `seq $line`;do
    for j in `seq $col`;do
        COL=$[RANDOM%7+31]m
        echo -e "${BEGIN}${COL}*$END\c"
    done
    echo     
done

12. Random Numbers, the Most Fundamental, the Most Fundamental

for((i=0;i<10;i++));do
    N=$RANDOM
    echo -e "$N \c"
    if [ $i -eq 0 ];then
    MAX=$N
    MIN=$N
    else

    [ $N -ge $MAX ] && MAX=$N

    [ $N -le $MIN ] && MIN=$N

    fi
done
echo 
echo MAX=$MAX,MIN=$MIN
for((i=0;i<10;i++));do
    N=$RANDOM
    echo -e "$N \c"
     if [ $i -eq 0 ];then
        MAX=$N
        MIN=$N
     else
        if              
        [ $N -ge $MAX ] ;then
        MAX=$N
        fi                  
        if                      
        [ $N -le $MIN ] ;then MIN=$N
        fi

    fi
 done
                                    echo 
                                    echo MAX=$MAX,MIN=$MIN

13. Multiplication Table

i=1
while [ $i -le 9 ];do
    j=1
    while [ $j -le $i ];do
        let sum=${i}*${j}

        echo -e "${i}x${j}=$sum\t\c"
        let j++
    done
    echo
    let i++

done
for ((i=9;i>0;i--));do
    for((j=9;j>=i;j--));do

        echo -e  "${i}x${j}=$[i*j] \t\c"
        done
    echo
done

14. Chess

BEGIN='\033[1;'
RED=41m
YELLOW=43m
END='\e[0m'
i=1
while [ $i -le 8 ];do
        j=1
        while [ $j -le 4 ];do
                if [ $[i%2] -eq 0 ];then
                        echo -e "${BEGIN}${RED}  ${BEGIN}${YELLOW}  ${END}\c"
                else
                        echo -e "${BEGIN}${YELLOW}  ${BEGIN}${RED}  ${END}\c"                                                                     
                fi
                let j++
        done

15.vim enters paste mode with the following commands:
:set paste
1
After entering paste mode, press i to enter insert mode, and then copy and paste is normal.
In command mode, enter
:set nopaste
1
Remove paste mode.

#chkconfig:- 96 07
#description

chkconfig --add `basename $0`

 start(){
        touch /var/lock/subsys/`basename $0`
        . /etc/init.d/functions
        action "`basename $0` start successful!" true
}

 stop(){
        rm /var/lock/subsys/`basename $0`
        . /etc/init.d/functions
        action "`basename $0` is stopped!" true
}

 restart (){
         stop
         start
}
 status(){
        if [ -f /var/lock/subsys/`basename $0` ];then
        . /etc/init.d/functions
        action "`basename $0` is running" true
        else
        action "`basename $0` is stopped" true
        fi
}

case $1 in
start)
        if [ -f /var/lock/subsys/`basename $0` ];then
                echo "`basename $0` is running"
        else
                start
        fi      
                ;;
stop)
        if [ -f /var/lock/subsys/`basename $0` ];then
                stop
        else
                echo "`basename $0` has been stopped before"
        fi
                ;;
restart)
        if [ -f /var/lock/subsys/`basename $0` ];then
                stop
                start
        else
                start
        fi      
                ;;
status) 
        status
                ;;
esac
Black screen, just a cursor
[root@centos6 data]#rm -rf /boot/initramfs-2.6.32-754.el6.x86_64.img
[root@centos6 data]#mkinitrd /boot/initramfs-`uname -r`.img `uname -r`

Tags: Linux network lsof Session less

Posted on Sun, 25 Aug 2019 05:11:19 -0400 by stefharley