Three commands to find MAC address in Linux

Three commands to find MAC address in Linux

Reference:
https://www.howtouselinux.com/post/linux-command-get-mac-address-in-linux

MAC address (Media Access Control address) is the unique identifier of a network device (such as a computer, router or switch) in a local area network. In Linux systems, you can use a few simple commands to find the MAC address of a network interface. This article will introduce the three most commonly used commands to help you find the MAC address you need.

  1. ifconfig command :
    The ifconfig command is one of the most commonly used commands to view network interface information. It can display detailed information about all network interfaces on the system, including MAC addresses. To find the MAC address using the ifconfig command, open a terminal and enter the following command:

    ifconfig
    

    This will list information for all network interfaces, including the MAC address, usually next to the "HWaddr" field of the output.

  2. ip command :
    The ip command is a more modern and powerful network management tool, it can also be used to find the MAC address. To find the MAC address, run the following command in the terminal:

    ip link show
    

    This will display information for all network interfaces, including the MAC address, which is located after the "link/ether" field.

  3. cat command and /sys file system :
    Linux also provides a method to find the MAC address through the /sys file system. You can use the cat command to view the MAC address files of each network interface in the /sys/class/net directory. The following are sample commands:

    cat /sys/class/net/eth0/address
    

    This command will display the MAC address of the eth0 interface. You can replace "eth0" to find the MAC address of other interfaces.

With any of these three commands, you can easily find the MAC address of a network interface on your Linux system. These commands are useful for network troubleshooting, configuration, and management, helping you ensure that your network devices are functioning properly.

Learn more about Linux:
howtouseLinux.com is a free online platform dedicated to providing high-quality tutorials, guides and resources on the Linux operating system. Whether you're just starting to learn Linux or want to further develop your skills, our site has you covered.

Guess you like

Origin blog.csdn.net/linux_tcpdump/article/details/133184966