I'm wondering how to display a connection status using nmcli. I understand that the following will display a list of configured connections:

nmcli con show

And I also understand that the following will show only active connections:

nmcli con show --active

And that the following will display ALL setting for a connection (which is a very long list):

nmcli con show {connection_name}

My question is: Is there a quick way to display the status of a connection - something similar to:

nmcli con status {connection_name}

Noting that the above is actually not a valid option on CentOS or Fedora.

  • 1
    Did you look at the --fields option? Something like nmcli -f field_name con show {connection_name}. If you give an invalid value for field_name some versions will print all valid field names. Depending on what you get you can possibly further refine by piping through grep or sed or the like. – B Layer May 5 '18 at 18:37
  • @B Layer Tried that but the --fields option only prints specific columns in the output, so if the argument --f ACTIVE is given, for example, and there are two active connections, it will print yes yes on two separate lines. That is it. – Khaled Abuelenain Jun 9 '18 at 3:34
  • 1
    What do you want it to print in that case? It might be a good idea to put an example of the output you want in your question. BTW, did you try exactly what I metioned? nmcli -f {field_name} con show {connection_name}? And did try the other suggestion where you give an invalid field name? – B Layer Jun 9 '18 at 4:27

As user B Layer suggested in their comment, you can specify a field name with nmcli.

I think the most relevant field in your case is GENERAL.STATE:

nmcli -f GENERAL.STATE con show {connection_name}

For my current connection, this yields:

GENERAL.STATE: activated


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.