NM-ONLINE(1)

πŸ’… NM-ONLINE(1) β€” like, the whole manual, bestie

okay so this is nm-online, a page from the General Commands Manual section 1, and I'm gonna walk you through it like we're texting at 1am 🫢


✨ NAME ✨

nm-online β€” the girl whose whole job is asking NetworkManager "are we online rn or not" πŸ¦‹


✨ SYNOPSIS ✨

nm-online [OPTIONS...]

that's it. that's the whole vibe. options go in the brackets, periodt πŸ’…


✨ DESCRIPTION ✨

so nm-online is a utility to find out whether we are online. literally its one purpose. and the way it does this is by asking NetworkManager about its status β€” she doesn't guess, she asks πŸ‘‘

when you run it, nm-online waits until NetworkManager reports an active connection, or until the specified timeout expires. whichever comes first, no cap. and when it exits? you gotta check the returned status code (the return codes are down in EXIT STATUS, keep scrolling 🌸).

ngl, this tool is not very useful to call directly. like, it's not a main character you're supposed to hang out with. it is however used by NetworkManager-wait-online.service with the --wait-for-startup argument (peep NetworkManager-wait-online.service(8) for that one πŸŽ€).

okay now the important part, bestie, listen up: by default, connections have the ipv4.may-fail and ipv6.may-fail properties set to yes. what that means is NetworkManager waits for one of the two address families to complete configuration before considering the connection activated. so if you need a specific address family configured before network-online.target is reached, set the corresponding may-fail property to no. that's the whole trick πŸ’–


✨ OPTIONS ✨

  • -h, --help β€” print help information. the "what is this even" button πŸ’€
  • -q, --quiet β€” don't print anything. silence. not a peep. πŸ™ˆ
  • -s, --wait-for-startup β€” wait for NetworkManager startup to complete, rather than waiting for network connectivity specifically. startup is considered complete once NetworkManager has activated (or attempted to activate) every auto-activate connection which is available given the current network state. this corresponds to the moment when NetworkManager logs startup complete. ✨

this mode is generally only useful at boot time. after startup has completed, nm-online -s will just return immediately, regardless of the current network state. like she literally does not care anymore, she's done 🫠

there are various ways to affect when startup complete is reached. for details see NetworkManager-wait-online.service(8).

  • -t, --timeout seconds β€” time to wait for a connection, in seconds. if the option is not provided, the environment variable NM_ONLINE_TIMEOUT is honored. the default timeout is 30 seconds. clock's ticking bestie ⏰
  • -x, --exit β€” exit immediately if NetworkManager is not running or connecting. no waiting around, she leaves the group chat πŸšͺ

✨ EXIT STATUS ✨

nm-online exits with status 0 if it succeeds, and a value greater than 0 is returned if an error occurs. so like, always check. fr fr.

  • 0 β€” Success. already online, or connection established within the given timeout. slay πŸŽ‰
  • 1 β€” Offline, or not online within the given timeout. sad girl hours 😭
  • 2 β€” Unknown or unspecified error. the "idk what happened" of exit codes πŸ’€

✨ SEE ALSO ✨

go read these next, i'm obsessed with cross-referencing:


lowkey a reminder: that exit status is the whole point of this utility, so pls pls pls check it, don't just fire and forget πŸ™

and that's the page, bestie! 🌈 this was NetworkManager 1.58.0, brought to you with love, and the date on this beauty is the same as always β€” signing off, mwah πŸ’‹πŸ’œ

πŸ“¦ where this page comes from