Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu.Wang 2019-05-12 11:30:13 +08:00
commit eba2977c30
3 changed files with 217 additions and 219 deletions

View File

@ -1,34 +1,30 @@
[#]: collector: (lujun9972)
[#]: translator: (bodhix)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-10844-1.html)
[#]: subject: (How To Enable (UP) And Disable (DOWN) A Network Interface Port (NIC) In Linux?)
[#]: via: (https://www.2daygeek.com/enable-disable-up-down-nic-network-interface-port-linux-using-ifconfig-ifdown-ifup-ip-nmcli-nmtui/)
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
Linux 中如何启用禁用网口
Linux 中如何启用和禁用网卡
======
你可能会根据你的需要执行以下命令。
你可能会根据你的需要执行以下命令。我会在这里列举一些你会用到这些命令的例子。
列举一些你会用到这些命令的例子
当你添加一个网卡或者从一个物理网卡创建出一个虚拟网卡的时候,你可能需要使用这些命令将新网卡启用起来。另外,如果你对网卡做了某些修改或者网卡本身没有启用,那么你也需要使用以下的某个命令将网卡启用起来
当你添加一个网卡或者从一个物理网口创建出一个虚拟网口的时候,你可能需要使用这些命令将新网口启用起来。另外,如果你对网口做了某些修改或者网口本身没有启用,那么你也需要使用以下的某个命令将网口启用起来
启用、禁用网卡有很多种方法。在这篇文章里,我们会介绍我们使用过的最好的 5 种方法
启用禁用网口有很多种方法。在这篇文章里,我们会介绍我们使用过的、最好的 5 种方法。
启用禁用网卡可以使用以下 5 个方法来完成:
启用禁用网口可以使用以下 5 个方法来完成:
* `ifconfig` 命令:用于配置网卡。它可以提供网卡的很多信息。
* `ifdown/up` 命令:`ifdown` 命令用于禁用网卡,`ifup` 命令用于启用网卡。
* `ip` 命令:用于管理网卡,用于替代老旧的、不推荐使用的 `ifconfig` 命令。它和 `ifconfig` 命令很相似,但是提供了很多 `ifconfig` 命令所不具有的强大的特性。
* `nmcli` 命令:是一个控制 NetworkManager 并报告网络状态的命令行工具。
* `nmtui` 命令:是一个与 NetworkManager 交互的、基于 curses 图形库的终端 UI 应用。
* **`ifconfig 命令:`** ifconfig 命令用于配置网口。 它可以提供网口的很多信息。
* **`ifdown/up 命令:`** ifdown 命令用于禁用网口ifup 命令用于启用网口。
* **`ip 命令:`** ip 命令用于管理网口,用于替代老旧的、不推荐使用的 ifconfig 命令。它和 ifconfig 命令很相似,但是提供了很多 ifconfig 命令不具有的强大的特性。
* **`nmcli 命令:`** nmcli 是一个控制 NetworkManager 并报告网络状态的命令行工具。
* **`nmtui 命令:`** nmtui 是一个与 NetworkManager 交互的、基于 curses 图形库的终端 UI 应用。
以下显示的是我的 Linux 系统中可用网口的信息。
以下显示的是我的 Linux 系统中可用网卡的信息。
```
# ip a
@ -52,24 +48,25 @@ Linux 中如何启用禁用网口?
valid_lft forever preferred_lft forever
```
### 1、如何使用 ifconfig 命令启用禁用网
### 1、如何使用 ifconfig 命令启用禁用网
ifconfig 命令用于配置网口
`ifconfig` 命令用于配置网卡
系统启动过程中如果需要启用网口,调用的命令就是 ifconfig。 ifconfig 可以提供很多网口的信息。不管我们想修改网口的什么配置,都可以使用该命令。
在系统启动过程中如果需要启用网卡,调用的命令就是 `ifconfig`。`ifconfig` 可以提供很多网卡的信息。不管我们想修改网卡的什么配置,都可以使用该命令。
ifconfig 的常用语法:
`ifconfig` 的常用语法:
```
# ifconfig [NIC_NAME] Down/Up
```
执行以下命令禁用 `enp0s3` 网口。注意,这里你需要输入你自己的网口名字。
执行以下命令禁用 `enp0s3` 网卡。注意,这里你需要输入你自己的网卡名字。
```
# ifconfig enp0s3 down
```
从以下输出结果可以看到网已经被禁用了。
从以下输出结果可以看到网已经被禁用了。
```
# ip a | grep -A 1 "enp0s3:"
@ -77,13 +74,13 @@ ifconfig 的常用语法:
link/ether 08:00:27:c2:e4:e8 brd ff:ff:ff:ff:ff:ff
```
执行以下命令启用 `enp0s3`
执行以下命令启用 `enp0s3`
```
# ifconfig enp0s3 up
```
从以下输出结果可以看到网已经启用了。
从以下输出结果可以看到网已经启用了。
```
# ip a | grep -A 5 "enp0s3:"
@ -95,27 +92,26 @@ ifconfig 的常用语法:
valid_lft forever preferred_lft forever
```
### 2、如何使用 ifdown/up 命令启用禁用网
### 2、如何使用 ifdown/up 命令启用禁用网
ifdown 命令用于禁用网口ifup 命令用于启用网口
`ifdown` 命令用于禁用网卡,`ifup` 命令用于启用网卡
**注意:** 这两个命令不支持以 `enpXXX` 命名的新的网络设备。
注意:这两个命令不支持以 `enpXXX` 命名的新的网络设备。
ifdown/ifup 的常用语法:
`ifdown`/`ifup` 的常用语法:
```
# ifdown [NIC_NAME]
# ifup [NIC_NAME]
```
执行以下命令禁用 `eth1`
执行以下命令禁用 `eth1`
```
# ifdown eth1
```
从以下输出结果可以看到网已经被禁用了。
从以下输出结果可以看到网已经被禁用了。
```
# ip a | grep -A 3 "eth1:"
@ -123,13 +119,13 @@ ifdown/ifup 的常用语法:
link/ether 08:00:27:d5:a0:18 brd ff:ff:ff:ff:ff:ff
```
执行以下命令启用 `eth1`
执行以下命令启用 `eth1`
```
# ifup eth1
```
从以下输出结果可以看到网已经启用了。
从以下输出结果可以看到网已经启用了。
```
# ip a | grep -A 5 "eth1:"
@ -140,32 +136,32 @@ ifdown/ifup 的常用语法:
valid_lft forever preferred_lft forever
```
ifup 和 ifdown 不支持以 `enpXXX` 命名的网口。当执行该命令时得到的结果如下:
`ifup``ifdown` 不支持以 `enpXXX` 命名的网卡。当执行该命令时得到的结果如下:
```
# ifdown enp0s8
Unknown interface enp0s8
```
### 3、如何使用 ip 命令启用禁用网
### 3、如何使用 ip 命令启用禁用网
ip 命令用于管理网口,用于替代老旧的、不推荐使用的 ifconfig 命令。
`ip` 命令用于管理网卡,用于替代老旧的、不推荐使用的 `ifconfig` 命令。
它和 ifconfig 命令很相似,但是提供了很多 ifconfig 命令不具有的强大的特性。
它和 `ifconfig` 命令很相似,但是提供了很多 `ifconfig` 命令不具有的强大的特性。
ip 的常用语法:
`ip` 的常用语法:
```
# ip link set Down/Up
```
执行以下命令禁用 `enp0s3`
执行以下命令禁用 `enp0s3`
```
# ip link set enp0s3 down
```
从以下输出结果可以看到网已经被禁用了。
从以下输出结果可以看到网已经被禁用了。
```
# ip a | grep -A 1 "enp0s3:"
@ -173,13 +169,13 @@ ip 的常用语法:
link/ether 08:00:27:c2:e4:e8 brd ff:ff:ff:ff:ff:ff
```
执行以下命令启用 `enp0s3`
执行以下命令启用 `enp0s3`
```
# ip link set enp0s3 up
```
从以下输出结果可以看到网已经启用了。
从以下输出结果可以看到网已经启用了。
```
# ip a | grep -A 5 "enp0s3:"
@ -191,13 +187,13 @@ ip 的常用语法:
valid_lft forever preferred_lft forever
```
### 4、如何使用 nmcli 命令启用禁用网
### 4、如何使用 nmcli 命令启用禁用网
nmcli 是一个控制 NetworkManager 并报告网络状态的命令行工具。
`nmcli` 是一个控制 NetworkManager 并报告网络状态的命令行工具。
nmcli 可以用做 nm-applet 或者其他图形化客户端的替代品。 它可以用于展示、创建、修改、删除、启用和停用网络连接。除此之后,它还可以用来管理和展示网络设备状态。
`nmcli` 可以用做 nm-applet 或者其他图形化客户端的替代品。它可以用于展示、创建、修改、删除、启用和停用网络连接。除此之后,它还可以用来管理和展示网络设备状态。
nmcli 命令大部分情况下都是使用`配置名称`工作而不是`设备名称`。所以,执行以下命令,获取网口对应的配置名称。【译者注:在使用 nmtui 或者 nmcli 管理网络连接的时候,可以为网络连接配置一个名称,就是这里提到的`配置名称Profile name`】
`nmcli` 命令大部分情况下都是使用“配置名称”工作而不是“设备名称”。所以执行以下命令获取网卡对应的配置名称。LCTT 译注:在使用 `nmtui` 或者 `nmcli` 管理网络连接的时候,可以为网络连接配置一个名称,就是这里提到的<ruby>配置名称<rt>Profile name</rt></ruby>`
```
# nmcli con show
@ -206,20 +202,20 @@ Wired connection 1 3d5afa0a-419a-3d1a-93e6-889ce9c6a18c ethernet enp0s3
Wired connection 2 a22154b7-4cc4-3756-9d8d-da5a4318e146 ethernet enp0s8
```
nmcli 的常用语法:
`nmcli` 的常用语法:
```
# nmcli con Down/Up
```
执行以下命令禁用 `enp0s3`口。 在禁用网口的时候,你需要使用`配置名称`而不是`设备名称`
执行以下命令禁用 `enp0s3`卡。在禁用网卡的时候,你需要使用配置名称而不是设备名称
```
# nmcli con down 'Wired connection 1'
Connection 'Wired connection 1' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
```
从以下输出结果可以看到网已经禁用了。
从以下输出结果可以看到网已经禁用了。
```
# nmcli dev status
@ -229,14 +225,14 @@ enp0s3 ethernet disconnected --
lo loopback unmanaged --
```
执行以下命令启用 `enp0s3`口。 同样的,这里你需要使用`配置名称`而不是`设备名称`
执行以下命令启用 `enp0s3`卡。同样的,这里你需要使用配置名称而不是设备名称
```
# nmcli con up 'Wired connection 1'
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
```
从以下输出结果可以看到网已经启用了。
从以下输出结果可以看到网已经启用了。
```
# nmcli dev status
@ -246,25 +242,27 @@ enp0s3 ethernet connected Wired connection 1
lo loopback unmanaged --
```
### 5、如何使用 nmtui 命令启用禁用网
### 5、如何使用 nmtui 命令启用禁用网
nmtui 是一个与 NetworkManager 交互的、基于 curses 图形库的终端 UI 应用。
`nmtui` 是一个与 NetworkManager 交互的、基于 curses 图形库的终端 UI 应用。
在启用 nmtui 的时候,如果第一个参数没有特别指定,它会引导用户选择对应的操作去执行。
在启用 `nmtui` 的时候,如果第一个参数没有特别指定,它会引导用户选择对应的操作去执行。
执行以下命令打开 mntui 界面。选择 “Active a connection” 然后点击 “OK”。
执行以下命令打开 `mntui` 界面。选择 “Active a connection” 然后点击 “OK”。
```
# nmtui
```
[![][1]![][1]][2]
![][2]
选择你要禁用的网口,然后点击 “Deactivate” 按钮,就可以将网口禁用。
[![][1]![][1]][3]
选择你要禁用的网卡,然后点击 “Deactivate” 按钮,就可以将网卡禁用。
如果要启用网口,使用上述同样的步骤即可。
[![][1]![][1]][4]
![][3]
如果要启用网卡,使用上述同样的步骤即可。
![][4]
--------------------------------------------------------------------------------
@ -273,7 +271,7 @@ via: https://www.2daygeek.com/enable-disable-up-down-nic-network-interface-port-
作者:[Magesh Maruthamuthu][a]
选题:[lujun9972][b]
译者:[bodhix](https://github.com/bodhix)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,156 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (robsean)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Kindd A Graphical Frontend To dd Command)
[#]: via: (https://www.ostechnix.com/kindd-a-graphical-frontend-to-dd-command/)
[#]: author: (sk https://www.ostechnix.com/author/sk/)
Kindd A Graphical Frontend To dd Command
======
![Kindd - A Graphical Frontend To dd Command][1]
A while ago we learned how to [**create bootable ISO using dd command**][2] in Unix-like systems. Please keep in mind that dd command is one of the dangerous and destructive command. If youre not sure what you are actually doing, you might accidentally wipe your hard drive in minutes. The dd command just takes bytes from **if** and writes them to **of**. It wont care what its overwriting, it wont care if theres a partition table in the way, or a boot sector, or a home folder, or anything important. It will simply do what it is told to do. If youre beginner, mostly try to avoid using dd command to do stuffs. Thankfully, there is a simple GUI utility for dd command. Say hello to **“Kindd”** , a graphical frontend to dd command. It is free, open source tool written in **Qt Quick**. This tool can be very helpful for the beginners and who are not comfortable with command line in general.
The developer created this tool mainly to provide,
1. a modern, simple and safe graphical user interface for dd command,
2. a graphical way to easily create bootable device without having to use Terminal.
### Installing Kindd
Kindd is available in [**AUR**][3]. So if youre a Arch user, install it using any AUR helper tools, for example [**Yay**][4].
To install Git version, run:
```
$ yay -S kindd-git
```
To install release version, run:
```
$ yay -S kindd
```
After installing, launch Kindd from the Menu or Application launcher.
For other distributions, you need to manually compile and install it from source as shown below.
Make sure you have installed the following prerequisites.
* git
* coreutils
* polkit
* qt5-base
* qt5-quickcontrols
* qt5-quickcontrols2
* qt5-graphicaleffects
Once all prerequisites installed, git clone the Kindd repository:
```
git clone https://github.com/LinArcX/Kindd/
```
Go to the directory where you just cloned Kindd and compile and install it:
```
cd Kindd
qmake
make
```
Finally run the following command to launch Kindd application:
```
./kindd
```
Kindd uses **pkexec** internally. The pkexec agent is installed by default in most most Desktop environments. But if you use **i3** (or maybe some other DE), you should install **polkit-gnome** first, and then paste the following line into i3 config file:
```
exec /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 &
```
### Create bootable ISO using Kindd
To create a bootable USB from an ISO, plug in the USB drive. Then, launch Kindd either from the Menu or Terminal.
This is how Kindd default interface looks like:
![][5]
Kindd interface
As you can see, Kindd interface is very simple and self-explanatory. There are just two sections namely **List Devices** which displays the list of available devices (hdd and Usb) on your system and **Create Bootable .iso**. You will be in “Create Bootable .iso” section by default.
Enter the block size in the first column, select the path of the ISO file in the second column and choose the correct device (USB drive path) in third column. Click **Convert/Copy** button to start creating bootable ISO.
![][6]
Once the process is completed, you will see successful message.
![][7]
Now, unplug the USB drive and boot your system with USB to check if it really works.
If you dont know the actual device name (target path), just click on the List devices and check the USB drive name.
![][8]
* * *
**Related read:**
* [**Etcher A Beautiful App To Create Bootable SD Cards Or USB Drives**][9]
* [**Bootiso Lets You Safely Create Bootable USB Drive**][10]
* * *
Kindd is in its early development stage. So, there would be bugs. If you find any bugs, please report them in its GitHub page given at the end of this guide.
And, thats all. Hope this was useful. More good stuffs to come. Stay tuned!
Cheers!
**Resource:**
* [**Kindd GitHub Repository**][11]
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/kindd-a-graphical-frontend-to-dd-command/
作者:[sk][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.ostechnix.com/author/sk/
[b]: https://github.com/lujun9972
[1]: https://www.ostechnix.com/wp-content/uploads/2019/04/kindd-720x340.png
[2]: https://www.ostechnix.com/how-to-create-bootable-usb-drive-using-dd-command/
[3]: https://aur.archlinux.org/packages/kindd-git/
[4]: https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/
[5]: http://www.ostechnix.com/wp-content/uploads/2019/04/kindd-interface.png
[6]: http://www.ostechnix.com/wp-content/uploads/2019/04/kindd-1.png
[7]: http://www.ostechnix.com/wp-content/uploads/2019/04/kindd-2.png
[8]: http://www.ostechnix.com/wp-content/uploads/2019/04/kindd-3.png
[9]: https://www.ostechnix.com/etcher-beauitiful-app-create-bootable-sd-cards-usb-drives/
[10]: https://www.ostechnix.com/bootiso-lets-you-safely-create-bootable-usb-drive/
[11]: https://github.com/LinArcX/Kindd

View File

@ -0,0 +1,156 @@
[#]: collector: (lujun9972)
[#]: translator: (robsean)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Kindd A Graphical Frontend To dd Command)
[#]: via: (https://www.ostechnix.com/kindd-a-graphical-frontend-to-dd-command/)
[#]: author: (sk https://www.ostechnix.com/author/sk/)
Kindd 一个图形化 dd 命令前端
======
![Kindd - A Graphical Frontend To dd Command][1]
前不久,我们已经学习如何在类 Unix 系统中 [**使用 dd 命令创建可启动的 ISO **][2] 。请记住dd 命令是危险的和破坏性的命令之一。如果你不确定你实际在做什么你可能会在几分钟内意外地擦除你的硬盘数据。dd 命令仅仅从 **if** 获取数据,并写入数据到 **of** 。它将不关心它正在覆盖什么,它将不关心是否在磁道上有一个分区表,或一个启动扇区,或者一个 home 文件夹,或者任何重要的东西。它将简单地做它被告诉去做的事。如果你是初学者,一般地尝试避免使用 dd 命令来做原料。幸好,这有一个支持 dd 命令的简单的 GUI 实用程序。向 **“Kindd”** 问好,一个属于 dd 命令的图形化前端。它是自由的,开放源码的用 **Qt Quick** 所写的工具。总的来说,这个工具对那些对命令行不舒适的初学者是非常有用的。
开发者创建这个工具主要是为了提供,
1. 一个用于 dd 命令的现代的,简单的和安全的图形化用户界面,
2. 一种图形化的方法来简单地创建可启动设备,而不必使用终端。
### 安装 Kindd
Kindd 在 [**AUR**][3] 中是可用的。所以,如果你是 Arch 用户,使用任一的 AUR helper 工具来安装它tools例如 [**Yay**][4] 。
为安装 Git 版本,运行:
```
$ yay -S kindd-git
```
为安装发布的版本,运行:
```
$ yay -S kindd
```
在安装后,从菜单或应用程序启动器启动 Kindd 。
对于其它的发行版,你需要从源文件手动编译和安装它,像下面所示。
确保你已经安装下面的必要条件。
* git
* coreutils
* polkit
* qt5-base
* qt5-quickcontrols
* qt5-quickcontrols2
* qt5-graphicaleffects
一旦所有必要条件安装git 克隆 Kindd 储存库:
```
git clone https://github.com/LinArcX/Kindd/
```
转到你刚刚克隆 Kindd 的目录,并编译和安装它:
```
cd Kindd
qmake
make
```
最后运行下面的命令来启动 Kindd 应用程序:
```
./kindd
```
Kindd 使用内部的 **pkexec** 。pkexec 代理被默认安装在大多数桌面环境中。但是,如果你使用 **i3** (或者可能一些其它的桌面环境),你应该首先安装 **polkit-gnome** ,然后粘贴下面的行到 i3 配置文件:
```
exec /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 &
```
### 使用 Kindd 创建可启动的 ISO
为从一个 ISO 创建一个可启动的 USB ,插入 USB 驱动器。然后,从菜单或终端启动 Kindd 。
这是 Kindd 默认界面的外观:
![][5]
Kindd 界面
正如你所能看到的Kindd 界面是非常简单的和明白易懂的。这里仅有两部分,即 **设备列表** ,它显示你的系统上的可用的设备( hdd 和 Usb ),并**创建可启动的 .iso** 。默认情况下,你将在“创建可启动 .iso”部分。
在第一列中输入块大小,在第二列中选择 ISO 文件的路径,并在第三列中选择正确的设备( USB 驱动器路径)。单击 **转换/复制** 按钮来开始创建可启动的 ISO 。
![][6]
一旦进程被完成,你将看到成功的信息。
![][7]
现在,拔出 USB 驱动器,并带有 USB 启动器启动你的系统,来检查它是否真地工作。
如果你不知道真实的设备名称(目标路径),仅在列出的设备上单击,并检查 USB 驱动器名称。
![][8]
* * *
**相关阅读:**
* [**Etcher 一个漂亮的来创建可启动 SD 卡或 USB 驱动器的应用程序**][9]
* [**Bootiso 让你安全地创建可启动的 USB 驱动器**][10]
* * *
Kindd 在早期开发阶段。因此,可能有错误。如果你找到一些错误,请在这篇的指南的结尾所给的 GitHub 页面报告它们。
这就是全部。希望这是有用的。更多的好东西将会来。敬请期待!
谢谢!
**资源:**
* [**Kindd GitHub 储存库**][11]
--------------------------------------------------------------------------------
通过: https://www.ostechnix.com/kindd-a-graphical-frontend-to-dd-command/
作者:[sk][a]
选题:[lujun9972][b]
译者:[robsean](https://github.com/robsean)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.ostechnix.com/author/sk/
[b]: https://github.com/lujun9972
[1]: https://www.ostechnix.com/wp-content/uploads/2019/04/kindd-720x340.png
[2]: https://www.ostechnix.com/how-to-create-bootable-usb-drive-using-dd-command/
[3]: https://aur.archlinux.org/packages/kindd-git/
[4]: https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/
[5]: http://www.ostechnix.com/wp-content/uploads/2019/04/kindd-interface.png
[6]: http://www.ostechnix.com/wp-content/uploads/2019/04/kindd-1.png
[7]: http://www.ostechnix.com/wp-content/uploads/2019/04/kindd-2.png
[8]: http://www.ostechnix.com/wp-content/uploads/2019/04/kindd-3.png
[9]: https://www.ostechnix.com/etcher-beauitiful-app-create-bootable-sd-cards-usb-drives/
[10]: https://www.ostechnix.com/bootiso-lets-you-safely-create-bootable-usb-drive/
[11]: https://github.com/LinArcX/Kindd