Difference between ip link eth down and ip link dev eth down

Nico asked:

What’s the difference between ip link set eth0 down and ip link set dev eth0 down ?

The difference between the commands does not appear to be documented anywhere.

My answer:

There’s no difference; dev is optional provided the device name can’t be mistaken for another keyword that the ip command understands. For instance, if you had an interface named bridge then you would have to use dev as bridge is also a keyword that ip uses.

This is undocumented behavior, but it certainly appears to work.

You’ll know if you ran afoul of ip‘s option parser if you get a (slightly grammatically incorrect) message like:

either "dev" is duplicate, or "bridge" is a garbage.

For things that absolutely must be 100% working all the time, like network configuration scripts, you should include dev just to be sure.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.