Monday, August 8, 2016

Normal TCP termination sequence

We have two peers: A and B

    A calls close()
        A sends FIN to B
        A goes into FIN_WAIT_1 state
    B receives FIN
        B sends ACK to A
        B goes into CLOSE_WAIT state
    A receives ACK
        A goes into FIN_WAIT_2 state
    B calls close()
        B sends FIN to A
        B goes into LAST_ACK state
    A receives FIN
        A sends ACK to B
        A goes into TIME_WAIT state
    B receives ACK
        B goes to CLOSED state – i.e. is removed from the socket tables

Thursday, July 7, 2016

Bring the network interface up or down in linux

It is possible to bring up or bring down the network interface with following command
To bring down eth1
ifdown eth1
To bring up eth1
ifup eth1

How to disable root SSH login


[root@root ~]# vi /etc/ssh/sshd_config
Change this line:
#PermitRootLogin yes
Edit to this:
PermitRootLogin no
Restart ssh service to change the setting
service ssh restart

Thursday, February 25, 2016

Using VI editor to replace text

To perform a global search and replace in vi, use the search and replace command in command mode:
:%s/search_string/replacement_string/g
The % is a shortcut that tells vi to search all lines of the file for search_string and change it to replacement_string. The global (g) flag at the end of the command tells vi to continue searching for other occurrences of search_string. To confirm each replacement, add the confirm (c) flag after the global flag.