← 返回命令列表

Linux command

nm-online 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Example

nm-online

Wait n seconds

nm-online --timeout [n]

说明

nm-online checks whether NetworkManager reports the network as connected. It waits for a network connection to become available, making it useful in scripts that need to ensure connectivity before proceeding. The command blocks until either a connection is established or the timeout is reached. Exit status indicates the result: 0 means connected, non-zero means no connection within the timeout period. This is commonly used in systemd service files or init scripts that depend on network availability, providing a reliable way to wait for NetworkManager to establish connectivity.

参数

-t, --timeout _seconds_
Time to wait for a connection (default: 30 seconds)
-q, --quiet
Don't print anything, only set exit status
-s, --wait-for-startup
Wait for NetworkManager to start if not running
-x, --exit
Exit immediately if NetworkManager is not running

FAQ

What is the nm-online command used for?

nm-online checks whether NetworkManager reports the network as connected. It waits for a network connection to become available, making it useful in scripts that need to ensure connectivity before proceeding. The command blocks until either a connection is established or the timeout is reached. Exit status indicates the result: 0 means connected, non-zero means no connection within the timeout period. This is commonly used in systemd service files or init scripts that depend on network availability, providing a reliable way to wait for NetworkManager to establish connectivity.

How do I run a basic nm-online example?

Run `nm-online` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -t, --timeout _seconds_ do in nm-online?

Time to wait for a connection (default: 30 seconds)