How does one get ip addr show to only show links of a specific type, without using a secondary process like grep to do filtering?

According to man 8 ip-address, this should be possible using the following, but when I run these, I get no results:

ip addr show type "link/loopback"
ip addr show type "loopback"
  • According to the man page there is no type "loopback", you have to choose from the list of types: TYPE := [ bridge | bridge_slave | bond | bond_slave | can | dummy | hsr | ifb | ipoib | macvlan | macvtap | vcan | veth | vlan | vxlan | ip6tnl | ipip | sit | gre | gretap | erspan | ip6gre | ip6gretap | ip6erspan | vti | vrf | nlmon | ipvlan | lowpan | geneve | macsec ] – eblock Sep 25 '20 at 7:28
  • So there is no way to filter on loopback or ether. That's disappointing. – Gary van der Merwe Sep 25 '20 at 7:41
  • It appears so, yes. But I'm not the most linux experienced user so there may be something else I'm not aware of. – eblock Sep 25 '20 at 8:01
  • 1
    You can use the fact that loopback is usually named lo and filter on IFNAME instead, so ip addr show lo will work. Not sure if it is relevant for your use though. – Fiisch Sep 25 '20 at 11:16
  • @Fiisch I think OP wants to filter link/ether, link/loopback, etc. lines, instead of filtering an interface. – Quasímodo Sep 25 '20 at 11:56

The short and simple:

hostname -i

Usually, I'm not looking for loopback but the ip so

hostname -I 

And if you want both while reducing the textual noise and adding color

ip addr | grep inet 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.