0

how to check mac address of our system through terminal in ubuntu 10.04LTS

ipconfig/all

Andrea Corbellini
  • 15,616
  • 2
  • 64
  • 81
Bey
  • 11
  • 1
  • 2
  • 3
  • MAC address of _what_? Of a network card? – terdon Aug 22 '14 at 15:00
  • 1
    Close-voters: This is *not* off-topic as EoL. [10.04 remains supported on servers installations (running just core packages) through April 2015](https://wiki.ubuntu.com/Releases), to which this question is of considerable significance. – Eliah Kagan Aug 22 '14 at 22:55
  • 2
    Other than what @EliahKagan just said, I must add that this question isn't version specific and answers may be relevant for future releases too. – Andrea Corbellini Aug 23 '14 at 14:07

2 Answers2

3

For wired / wireless adapters

ifconfig |grep HWaddr 

For bluetooth adapters:

hciconfig
JJW
  • 131
  • 1
  • 3
  • can u tell me how to put put special character that u have mentioned in first command – Bey Aug 22 '14 at 16:29
  • @user3592872 If you're asking about the `|` character, it's called a "pipe" and how to make it may depend on your keyboard layout. If you're using a US/English keyboard layout, you make that character by pressing the backslash key (`\ `) while holding down shift. **Or just run `ifconfig` by itself to see its whole output.** – Eliah Kagan Aug 22 '14 at 22:50
  • 1
    to print the exact string `ifconfig | grep -oP '.*HWaddr.*?\K[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}'` – Avinash Raj Aug 23 '14 at 16:24
3

An alternative to ifconfig is the ip command. You can use ip addr to list all your network interfaces with their IP and MAC addresses:

ek@Ilex:~$ ip addr
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:5a:35:6d brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.107/24 brd 192.168.1.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe5a:356d/64 scope link 
       valid_lft forever preferred_lft forever

I often use ifconfig myself, but ip seems to be the way of the future (on Linux-based OSes, such as Ubuntu).

Eliah Kagan
  • 116,445
  • 54
  • 318
  • 493
  • 1
    to parse out the mac address `ip addr | sed -nr '/^\s*link\//s~.* ([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}) .*~\1~p'` – Avinash Raj Aug 23 '14 at 16:18
  • 1
    and the one through grep `ip addr | grep -oP '^\s*link\/.*? \K([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})(?= )'` – Avinash Raj Aug 23 '14 at 16:22
  • @AvinashRaj You might want to post a new answer suggesting that. I don't think your answer would be too similar to mine: besides that your answer would include these beneficial and nontrivial sed and grep commands that aren't in mine, my answer is really focused on presenting `ip addr` as an alternative to `ifconfig`, giving its basic use case, and linking to documentation and information as to why `ip addr` may be considered preferable. I think an answer focusing on matching mac addresses in `ip addr` output would be both welcome and helpful! It would have my vote. – Eliah Kagan Aug 23 '14 at 16:24
  • it's just a suggestion. Credit goes to you only :-) – Avinash Raj Aug 23 '14 at 16:26