Compare two files and list common lines

You can use the awk command to compare two files and show the common ones. Compared to the Linux command “comm”, advantages of using “awk” is it will give output though the files are not sorted.
Syntax :

awk 'NR==FNR{a[$1]++;next} a[$1] ' file1 file2

Eg :

[root@test]# cat A
apple
orange
mango
grape

[root@test]# cat B
mango
banana
grape

[root@test]# awk 'NR==FNR{a[$1]++;next} a[$1] ' A B
mango
grape

Connect to serial console from Linux command line

The easiest way to connect to a serial console from Linux command line is using the screen command. In my example below, I will show you how to connect to a serial console of a server using the serial to usb cable.

[root@test ~]# screen /dev/ttyUSB0
******************************************
 Connected to *******
******************************************

Enjoy 🙂

Device eth0 does not seem to be present, delaying initialization.

You might have come across this headline, especially if you working with Oracle Virtual box machines, machines those are cloned from previous setups etc.

device

To resolve the issue, just remove the file /etc/udev/rules.d/70-persistent-net.rules and reboot the machine. This file contains the MAC address details associated with the machine. If you don’t want to reboot the machine, run the below command :

udevadm trigger --subsystem-match=net

This command will trigger the rules again.

Enjoy 🙂