Alternatively, you can also use device name in particular too, but you should know the names of network devices for that.
Learn Linux. Last Updated: March 3, Kiran Kumar Hi there!
I'm an avid Linux lover and enjoy hands-on with new promising distros. Currently, I'm using Ubuntu as a daily driver and run several other distros such as Fedora, Solus, Manjaro, Debian, and some new ones on my test PC and virtual machines. I have a day job as an Engineer, and this website is one of my favorite past time activities especially during Winter ;. Hope you enjoy using this website as much as I do writing for it.
Feedback from readers is something that inspires me to do more, and spread Linux love!. If you find a time, drop me an email or feedback from the 'Contact' page. Or simply leave a comment below if you found this article useful. Have a good day! Related Posts.
Linux. As the root user (or user with appropriate permissions); Type "ifconfig -a"; From The MAC Address will be displayed in the form of CB:8C Like with almost everything on the Linux command line, there is more than one way to find MAC address data. At the prompt, type ifconfig -a.
Terminal Tuts How to create and edit text files using command-line from Linux Terminal. In today's Terminal Tuts session, we shall show you several ways of creating and editing text files that can be done easily and quickly using the command line. Learn more. Asked 5 years, 5 months ago. Active 3 months ago. Viewed 80k times.
neybalcanu.tk For E. Pratham Pratham 1 1 gold badge 9 9 silver badges 23 23 bronze badges.
Add ; exit 0 after the print instead. Jayesh Bhoi Jayesh Bhoi Dave Dave 2, 22 22 silver badges 20 20 bronze badges. This should be the best answer! Elismar Luz Elismar Luz 3 3 silver badges 4 4 bronze badges.
Welcome to Stackoverflow. Please post more info on your answer. What is it doing and why.
Post as a guest Name. To get the MAC address of the interface, we use the following command: The mac address or the hardware address or the ethernet address of an interface is a 48 bit number that looks like this : c:c0:fee The mac address of an interface can be found given its name. Keep this document with your important papers. Asked 2 years, 8 months ago. Here are a few ways: grep. If that is the case for you, try: ip -a link. This command is handy to fish out network parameters of the Linux computer.
Best answer in my opinion. The others are either not working al the time or depend on a fixed interface name. Should be the accepted answer. IMHO what it does is quite straightforward, it doesn't need explanations. That said this solution is dependant on ip route output format.
MajorTom MajorTom 31 1 1 bronze badge. This also works on macOS. Just like the Awk in my answer, which does pretty much the same thing in a single process instead of a pipeline invoking multiple processes. Simply run: ifconfig grep ether cut -d " " -f10 OR ip a grep ether cut -d " " -f6 These two example commands will grep all lines with "ether" string and cut the mac address that we need following the number spaces specified in the -f option of the grepped portion.
Tested on different Linux flavors. Murdok Murdok 75 8 8 bronze badges.
But this works if you haven't renamed the device any tips on what I missed? Peter Peter 1, 1 1 gold badge 11 11 silver badges 17 17 bronze badges. Avoid the useless use of cat. Limited to Redhat derivatives.
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.
The Overflow Newsletter 3 — The 75 lines of code that changed history.