PDA

View Full Version : Linux command to output/show main network interface name



Fli
03-21-2016, 01:05 PM
Hello,

do You know any simple Linux command to output current server/omputer network interface name?

I came with this one, maybe someone can simpliffy and make it more universal:


ip link show|grep BROADCAST|head -n1|awk '{print $2}'|tr -d ":"

if this is added into the bash script one may need to use absolute path to ip binary. command "which ip" returns the path. ie: /sbin/ip link show|grep ..........

explanation of the command: show interfaces | filter out broadcast ones | use only first one (main ones appears to be on the top? | extract the part where is the iface name, trim away ":" character