How to connect two ubuntu computers with ethernet cable

Solution 1:

The addresses 192.168.1.2 and 192.168.2.1 cannot talk to each other if you use the subnet 255.255.255.0. Notice the third octet (number) of your IP addresses is different, in the answer you linked to they are they same.

You need to either change the subnet mask to 255.255.0.0 or change the IP address of the 192.168.2.1 machine to 192.168.1.1 so that the third octet matches (1). You will then be able to ping one computer from the other.

A crossover cable is not needed. Ethernet devices made in the last 10 or so years support auto MDI-X which eliminates the need for a crossover cable.