If you're looking for a more efficient way to gather network device information on your Linux system, Jack Wallen shows you how to do just that with the nmcli command.
System administrators--or sysadmins, for the cool kids--are always searching for information. After all, the "I" in IT does stand for information. Information is the cornerstone for knowing your systems and keeping them running well. That information applies to so many layers of computers and servers--from error logs to hardware statistics. But if your speciality is networking, one of the first bits of information you'll look for might be the details about a system's network connection.
If you administer the Windows platform, you are probably familiar with the command ipconfig /all. That command will report all of the interesting bits about a system network connection:
- TCP/IP network configuration values
- Dynamic Host Configuration Protocol (DHCP) information
- Domain Name System (DNS) settings
With the above information, you can launch your troubleshooting.
But what about Linux? If you're familiar enough with the platform, you know there are always multiple paths to a single solution. The same holds true with gaining network information. Add to that bit of confusion, there are commands, such as ifconfig, that have been deprecated yet are still found on certain distributions such as CentOS, Elementary OS, Ubuntu Server 16.04, and more, and you might find yourself a bit confused. Where do you turn? On newer distributions, you'll find the ip command. The problem with the newer ip command is that its output isn't always the most efficient to comb through (Figure A).
When you run a command to view network information, you don't want to have to dig through the output to find the information you need. Instead, you want a concise display that makes it quick and easy to find what you need.
A better option
Fortunately, there's a command for that--one that does a great job of giving you every single bit of information you'd need to start your troubleshooting process. That command is nmcli--Network Manager Command Line Interface. This particular command is actually meant to manage network devices, via the command line. However, it does have a particularly handy trick up its sleeve--displaying network information. For any distribution that uses Network Manager, this command is what you want to use.
The nmcli command should be found on most Linux distributions running a GUI interface. If you're working with a headless server, you might need to install the tool. I'll demonstrate installing the necessary package on Ubuntu Server 16.04. To do so, open a terminal and issue the command:
sudo apt install network-manager
The above command will install a number of dependencies. When it completes, you will need to start and enable network-manager with the following two commands:
sudo systemctl start network-manager sudo systemctl enable network-manager
The nmcli command is simple to use. To discover network information for all network interfaces, issue the command:
nmcli device show
The above command will output the complete list of information for your network devices (Figure B).
You can make that output even easier to read by using the -p (pretty) option, like so:
nmcli -p device show
The new output would better differentiate the information (Figure C).
There's more where that came from
Although that's only barely scratching the surface of what nmcli can do, this is all you need to know if you're looking for a more efficient means of mining information about your network connections. To find out more of what nmcli can do, fire off the command man nmcli and read through the man page, where you can learn how to create, display, edit, delete, activate, and deactivate network connections.
- How to enable TCP BBR to improve network speed on Linux (TechRepublic)
- How to speed up Apache with Varnish HTTP cache (TechRepublic)
- How to install and use Dockstation for easy container builds (TechRepublic)
- How to install OpenLDAP and phpLDAPadmin on Ubuntu 16.04 (TechRepublic)
- Video: How to pick a Linux distribution (TechRepublic Video)
- Linux Foundation seeks to bring rhyme and reason to open-source networking projects (ZDNet)