zak*_*o42 6 command-line network-manager networking
取消选中“启用网络”(禁用网络)然后重新启用的命令行等效项是什么?
在我的环境中,有多个网络需要我物理移动我的网线。有时我的连接无法正确刷新,因此我禁用/重新启用网络以刷新我的连接。能够从命令行执行此操作对我来说效率更高。
我使用的是 12.04 LTS。
我会nmcli为此目的使用命令:
nmcli nm enable false && nmcli nm enable true
Run Code Online (Sandbox Code Playgroud)
手册页:
DESCRIPTION
nmcli is a command?line tool for controlling NetworkManager and report?
ing on its status. It is not meant as a full replacement for nm?applet
or other similar clients but as a complementary utility to those pro?
grams. The main usage for nmcli is on servers, headless machines or
for power users who prefer the command line.
[...]
nm NetworkManager
Use this object to inquire and change state of NetworkManager.
[...]
enable [true|false]
Get networking?enabled status or enable/disable network?
ing by NetworkManager. All interfaces managed by Net?
workManager are deactivated when networking has been dis?
abled.
Reference to D?Bus:
interface: org.freedesktop.NetworkManager
method: Enable
arguments: TRUE or FALSE
Run Code Online (Sandbox Code Playgroud)