Pages

script to find the mac address using linux

Here is a simple script we can use to find the mac address of the network card in our systems.
We will use the command ifconfig to find the mac address and in some distribution ifconfig is available only to the root hence we make use of "sudo" before ifconfig.

For wired connection



For wireless connection


4 comments:

  1. sudo /sbin/ifconfig | awk '/eth[0-9]/{ print $NF}'

    ReplyDelete
  2. ... use awk or grep only as there is really no need of using both of them in this case:

    # sudo ifconfig | grep -Eo '([a-zA-Z0-9]{2}\:){5}[a-zA-Z0-9]{2}'

    ReplyDelete
    Replies
    1. Yes agree with you, did not think of that. Thank you.

      Delete