How to know the network name
Little Girl
littlergirl at gmail.com
Sat Oct 23 18:45:59 UTC 2021
Hey there,
Jerry Geis wrote:
>I need to know the correct ens4 type network name so when the
>machine reboots and tries to install Ubuntu 20.04 with a static
>address - all is correct. How do I get that name?
Here's another that uses the route instead of the address to do
something similar:
ip route | grep kernel | cut -f2 -d'/' | cut -f3 -d' '
How the command works:
* The ip address command gets your network routing table and
passes it to the grep command.
* The grep command searches for kernel and finds a line of
content containing the search term. It passes its findings
to the first cut command.
* The first cut command splits the input at forward
slashes and removes all but the second field, which
contains data that is space-separated. It passes its result
to the next cut command.
* The next cut command splits the input at spaces and removes
all but the third field, which is your iface.
It looks like I like to do two cuts. Ah, well. Either of these will
get the job done and maybe someone will come up with a more elegant
one in the meanwhile.
--
Little Girl
There is no spoon.
More information about the ubuntu-users
mailing list