Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu.Wang 2019-05-03 09:34:45 +08:00
commit 360ef50673
4 changed files with 31 additions and 372 deletions

View File

@ -1,16 +1,16 @@
[#]: collector: (lujun9972)
[#]: translator: (bodhix)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-10804-1.html)
[#]: subject: (How to Restart a Network in Ubuntu [Beginners Tip])
[#]: via: (https://itsfoss.com/restart-network-ubuntu)
[#]: author: (Sergiu https://itsfoss.com/author/sergiu/)
如何在 Ubuntu 中重启网络【新手提示】
Linux 初学者:如何在 Ubuntu 中重启网络
======
你[是否正在使用基于 Ubuntu 的系统,然后发现无法连接网络][1]?你一定会很惊讶,很多很多的问题都可以简单地通过重启服务解决。
你[是否正在使用基于 Ubuntu 的系统,然后发现无法连接网络][1]?你一定会很惊讶,很多的问题都可以简单地通过重启服务解决。
在这篇文章中,我会介绍在 Ubuntu 或者其他 Linux 发行版中重启网络的几种方法,你可以根据自身需要选择对应的方法。这些方法基本分为两类:
@ -18,11 +18,11 @@
### 通过命令行方式重启网络
如果你使用的 Ubuntu 服务器版,那么你已经在使用命令行终端了。如果你使用的是桌面版,那么你可以通过快捷键 Ctrl+Alt+T [Ubuntu 键盘快捷键][3] 打开命令行终端。
如果你使用的 Ubuntu 服务器版,那么你已经在使用命令行终端了。如果你使用的是桌面版,那么你可以通过快捷键 `Ctrl+Alt+T` [Ubuntu 键盘快捷键][3] 打开命令行终端。
在 Ubuntu 中,有多个命令可以重启网络。这些命令,一部分或者说大部分,也适用于在 Debian 或者其他的 Linux 发行版中重启网络。
#### 1\. network manager service
#### 1、network manager 服务
这是通过命令行方式重启网络最简单的方法。它相当于是通过图形化界面重启网络(重启 Network-Manager 服务)。
@ -32,17 +32,17 @@ sudo service network-manager restart
此时,网络图标会消失一会儿然后重新显示。
#### 2\. systemd
#### 2systemd
**service** 命令仅仅是该命令的一个封装(同样的还有 init.d 系列脚本和 Upstart 相关命令)。 **systemctl** 命令的功能远多于 **service** 命令。通常我更喜欢使用这个命令。
`service` 命令仅仅是这个方式的一个封装(同样的也是 init.d 系列脚本和 Upstart 相关命令的封装)。`systemctl` 命令的功能远多于 `service` 命令。通常我更喜欢使用这个命令。
```
sudo systemctl restart NetworkManager.service
```
这时,网络图标又会消失一会儿。 如果你想了解 **systemctl** 的其他选项, 可以参考 man 帮助文档。
这时,网络图标又会消失一会儿。 如果你想了解 `systemctl` 的其他选项, 可以参考 man 帮助文档。
#### 3\. nmcli
#### 3nmcli
这是 Linux 上可以管理网络的另一个工具。这是一个功能强大而且实用的工具。很多系统管理员都喜欢使用该工具,因为它非常容易使用。
@ -60,11 +60,11 @@ sudo nmcli networking on
你可以通过 man 帮助文档了解 nmcli 的更多用法。
#### 4\. ifup & ifdown
#### 4ifup & ifdown
这两个命令直接操作网口,切换网口是否可以收发包的状态。这是 [Linux 中最应该了解的网络命令][4] 之一。
使用 ifdown 关闭所有网口,再使用 ifup 重新启用网口。
使用 `ifdown` 关闭所有网口,再使用 `ifup` 重新启用网口。
通常推荐的做法是将这两个命令一起使用。
@ -72,9 +72,9 @@ sudo nmcli networking on
sudo ifdown -a && sudo ifup -a
```
**注意:** 这种方法不会让网络图标从系统托盘中消失,另外,你也无法进行网络连接
注意:这种方法不会让网络图标从系统托盘中消失,另外,各种网络连接也会断
**其他工具: nmtui (点击展开)**
#### 补充工具: nmtui
这是系统管理员们常用的另外一种方法。它是在命令行终端中管理网络的文本菜单工具。
@ -86,21 +86,21 @@ nmtui
![nmtui Menu][5]
**注意** 在 **nmtui** 中,可以通过 **up****down 方向键** 选择选项。
注意:在 nmtui 中,可以通过 `up``down` 方向键选择选项。
选择 **Activate a connection**
选择 “Activate a connection”
![nmtui Menu Select "Activate a connection"][6]
按下 **Enter** 键,打开 **connections** 菜单。
按下回车键,打开 “connections” 菜单。
![nmtui Connections Menu][7]
接下来,选择前面带 **星号 *** 的网络。在这个例子中,就是 MGEO72。
接下来,选择前面带星号(*)的网络。在这个例子中,就是 MGEO72。
![Select your connection in the nmtui connections menu.][8]
按下 **Enter** 键。 **关闭** 你的网络连接。
按下回车键。 这就将“停用”你的网络连接。
![nmtui Connections Menu with no active connection][9]
@ -108,19 +108,19 @@ nmtui
![Select the connection you want in the nmtui connections menu.][10]
按下 **Enter** 键。这样就重启了所选择的网络连接。
按下回车键。这样就重新激活了所选择的网络连接。
![nmtui Connections Menu][11]
双击 **Tab** 键,选择 **Back**
按下 `Tab` 键两次,选择 “Back”
![Select "Back" in the nmtui connections menu.][12]
按下 **Enter** 键,回到 **nmtui** 的主菜单。
按下回车键,回到 nmtui 的主菜单。
![nmtui Main Menu][13]
选择 **Quit**
选择 “Quit”
![nmtui Quit Main Menu][14]
@ -132,9 +132,9 @@ nmtui
显然,这是 Ubuntu 桌面版用户重启网络最简单的方法。如果这个方法不生效,你可以尝试使用前文提到的命令行方式重启网络。
NM 程序是 [NetworkManager][15] 的系统托盘程序标志。我们将使用它来重启网络。
NM 程序是 [NetworkManager][15] 的系统托盘程序标志。我们将使用它来重启网络。
首先,查看顶部状态栏。 你会在系统托盘找到一个网络图标 (因为我使用 Wi-Fi所以这里是一个 Wi-Fi 图标)。
首先,查看顶部状态栏。你会在系统托盘找到一个网络图标 (因为我使用 Wi-Fi所以这里是一个 Wi-Fi 图标)。
接下来,点击该图标(也可以点击音量图标或电池图标)。打开菜单。选择 “Turn Off” 关闭网络。
@ -160,7 +160,7 @@ Ubuntu 没有可以直接 “刷新 WiFi 网络” 的选项,它有点隐蔽
选择对应的网络修改你的 WiFi 连接。
你无法马上看到可用的无线网络列表。打开网络列表之后,大概需要 5 秒才会显示其可用的无线网络。
你无法马上看到可用的无线网络列表。打开网络列表之后,大概需要 5 秒才会显示其可用的无线网络。
![Select another wifi network in Ubuntu][19]
@ -168,7 +168,7 @@ Ubuntu 没有可以直接 “刷新 WiFi 网络” 的选项,它有点隐蔽
现在,你就可以选择你想要连接的网络,点击连接。这样就完成了。
**总结**
### 总结
重启网络连接是每个 Linux 用户在使用过程中必须经历的事情。
@ -184,7 +184,7 @@ via: https://itsfoss.com/restart-network-ubuntu
作者:[Sergiu][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,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (bodhix)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (MjSeven)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -1,341 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How To Monitor Disk I/O Activity Using iotop And iostat Commands In Linux?)
[#]: via: (https://www.2daygeek.com/monitor-disk-io-activity-using-iotop-iostat-command-in-linux/)
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
How To Monitor Disk I/O Activity Using iotop And iostat Commands In Linux?
======
Do you know what are the tools we can use for troubleshooting or monitoring real-time disk activity in Linux?
If **[Linux system performance][1]** gets slow down we may use **[top command][2]** to see the system performance.
It is used to check what are the processes are consuming high utilization on server.
Its common for most of the Linux administrator.
Its widely used by Linux administrator in the real world.
If you dont see much difference in the process output still you have an option to check other things.
I would like to advise you to check `wa` status in the top output because most of the time the server performance will be degraded due to high I/O Read and Write on hard disk.
If its high or fluctuation, it could be a cause. So, we need to check I/O activity on hard drive.
We can monitory disk I/O statistics for all disks and file system in Linux system using `iotop` and `iostat` commands.
### What Is iotop?
iotop is a top-like utility for displaying real-time disk activity.
iotop watches I/O usage information output by the Linux kernel and displays a table of current I/O usage by processes or threads on the system.
It displays the I/O bandwidth read and written by each process/thread. It also displays the percentage of time the thread/process spent while swapping in and while waiting on I/O.
Total DISK READ and Total DISK WRITE values represent total read and write bandwidth between processes and kernel threads on the one side and kernel block device subsystem on the other.
Actual DISK READ and Actual DISK WRITE values represent corresponding bandwidths for actual disk I/O between kernel block device subsystem and underlying hardware (HDD, SSD, etc.).
### How To Install iotop In Linux?
We can easily install it with help of package manager since the package is available in all the Linux distributions repository.
For **`Fedora`** system, use **[DNF Command][3]** to install iotop.
```
$ sudo dnf install iotop
```
For **`Debian/Ubuntu`** systems, use **[APT-GET Command][4]** or **[APT Command][5]** to install iotop.
```
$ sudo apt install iotop
```
For **`Arch Linux`** based systems, use **[Pacman Command][6]** to install iotop.
```
$ sudo pacman -S iotop
```
For **`RHEL/CentOS`** systems, use **[YUM Command][7]** to install iotop.
```
$ sudo yum install iotop
```
For **`openSUSE Leap`** system, use **[Zypper Command][8]** to install iotop.
```
$ sudo zypper install iotop
```
### How To Monitor Disk I/O Activity/Statistics In Linux Using iotop Command?
There are many options are available in iotop command to check varies statistics about disk I/O.
Run the iotop command without any arguments to see each process or thread current I/O usage.
```
# iotop
```
[![][9]![][9]][10]
If you would like to check which process are actually doing IO then run the iotop command with `-o` or `--only` option.
```
# iotop --only
```
[![][9]![][9]][11]
**Details:**
* **`IO:`** It shows I/O utilization for each process, which includes disk and swap.
* **`SWAPIN:`** It shows only the swap usage of each process.
### What Is iostat?
iostat is used to report Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions.
The iostat command is used for monitoring system input/output device loading by observing the time the devices are active in relation to their average transfer rates.
The iostat command generates reports that can be used to change system configuration to better balance the input/output load between physical disks.
All statistics are reported each time the iostat command is run. The report consists of a CPU header row followed by a row of CPU statistics.
On multiprocessor systems, CPU statistics are calculated system-wide as averages among all processors. A device header row is displayed followed by a line of statistics for each device that is configured.
The iostat command generates two types of reports, the CPU Utilization report and the Device Utilization report.
### How To Install iostat In Linux?
iostat tool is part of sysstat package so, We can easily install it with help of package manager since the package is available in all the Linux distributions repository.
For **`Fedora`** system, use **[DNF Command][3]** to install sysstat.
```
$ sudo dnf install sysstat
```
For **`Debian/Ubuntu`** systems, use **[APT-GET Command][4]** or **[APT Command][5]** to install sysstat.
```
$ sudo apt install sysstat
```
For **`Arch Linux`** based systems, use **[Pacman Command][6]** to install sysstat.
```
$ sudo pacman -S sysstat
```
For **`RHEL/CentOS`** systems, use **[YUM Command][7]** to install sysstat.
```
$ sudo yum install sysstat
```
For **`openSUSE Leap`** system, use **[Zypper Command][8]** to install sysstat.
```
$ sudo zypper install sysstat
```
### How To Monitor Disk I/O Activity/Statistics In Linux Using sysstat Command?
There are many options are available in iostat command to check varies statistics about disk I/O and CPU.
Run the iostat command without any arguments to see complete statistics of the system.
```
# iostat
Linux 4.19.32-1-MANJARO (daygeek-Y700) Thursday 18 April 2019 _x86_64_ (8 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
29.45 0.02 16.47 0.12 0.00 53.94
Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd
nvme0n1 6.68 126.95 124.97 0.00 58420014 57507206 0
sda 0.18 6.77 80.24 0.00 3115036 36924764 0
loop0 0.00 0.00 0.00 0.00 2160 0 0
loop1 0.00 0.00 0.00 0.00 1093 0 0
loop2 0.00 0.00 0.00 0.00 1077 0 0
```
Run the iostat command with `-d` option to see I/O statistics for all the devices
```
# iostat -d
Linux 4.19.32-1-MANJARO (daygeek-Y700) Thursday 18 April 2019 _x86_64_ (8 CPU)
Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd
nvme0n1 6.68 126.95 124.97 0.00 58420030 57509090 0
sda 0.18 6.77 80.24 0.00 3115292 36924764 0
loop0 0.00 0.00 0.00 0.00 2160 0 0
loop1 0.00 0.00 0.00 0.00 1093 0 0
loop2 0.00 0.00 0.00 0.00 1077 0 0
```
Run the iostat command with `-p` option to see I/O statistics for all the devices and their partitions.
```
# iostat -p
Linux 4.19.32-1-MANJARO (daygeek-Y700) Thursday 18 April 2019 _x86_64_ (8 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
29.42 0.02 16.45 0.12 0.00 53.99
Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd
nvme0n1 6.68 126.94 124.96 0.00 58420062 57512278 0
nvme0n1p1 6.40 124.46 118.36 0.00 57279753 54474898 0
nvme0n1p2 0.27 2.47 6.60 0.00 1138069 3037380 0
sda 0.18 6.77 80.23 0.00 3116060 36924764 0
sda1 0.00 0.01 0.00 0.00 3224 0 0
sda2 0.18 6.76 80.23 0.00 3111508 36924764 0
loop0 0.00 0.00 0.00 0.00 2160 0 0
loop1 0.00 0.00 0.00 0.00 1093 0 0
loop2 0.00 0.00 0.00 0.00 1077 0 0
```
Run the iostat command with `-x` option to see detailed I/O statistics for all the devices.
```
# iostat -x
Linux 4.19.32-1-MANJARO (daygeek-Y700) Thursday 18 April 2019 _x86_64_ (8 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
29.41 0.02 16.45 0.12 0.00 54.00
Device r/s rkB/s rrqm/s %rrqm r_await rareq-sz w/s wkB/s wrqm/s %wrqm w_await wareq-sz d/s dkB/s drqm/s %drqm d_await dareq-sz aqu-sz %util
nvme0n1 2.45 126.93 0.60 19.74 0.40 51.74 4.23 124.96 5.12 54.76 3.16 29.54 0.00 0.00 0.00 0.00 0.00 0.00 0.31 30.28
sda 0.06 6.77 0.00 0.00 8.34 119.20 0.12 80.23 19.94 99.40 31.84 670.73 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.13
loop0 0.00 0.00 0.00 0.00 0.08 19.64 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
loop1 0.00 0.00 0.00 0.00 0.40 12.86 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
loop2 0.00 0.00 0.00 0.00 0.38 19.58 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
```
Run the iostat command with `-d [Device_Name]` option to see I/O statistics of particular device and their partitions.
```
# iostat -p [Device_Name]
# iostat -p sda
Linux 4.19.32-1-MANJARO (daygeek-Y700) Thursday 18 April 2019 _x86_64_ (8 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
29.38 0.02 16.43 0.12 0.00 54.05
Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd
sda 0.18 6.77 80.21 0.00 3117468 36924764 0
sda2 0.18 6.76 80.21 0.00 3112916 36924764 0
sda1 0.00 0.01 0.00 0.00 3224 0 0
```
Run the iostat command with `-m` option to see I/O statistics with `MB` for all the devices instead of `KB`. By default it shows the output with KB.
```
# iostat -m
Linux 4.19.32-1-MANJARO (daygeek-Y700) Thursday 18 April 2019 _x86_64_ (8 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
29.36 0.02 16.41 0.12 0.00 54.09
Device tps MB_read/s MB_wrtn/s MB_dscd/s MB_read MB_wrtn MB_dscd
nvme0n1 6.68 0.12 0.12 0.00 57050 56176 0
sda 0.18 0.01 0.08 0.00 3045 36059 0
loop0 0.00 0.00 0.00 0.00 2 0 0
loop1 0.00 0.00 0.00 0.00 1 0 0
loop2 0.00 0.00 0.00 0.00 1 0 0
```
Run the iostat command with certain interval then use the following format. In this example, we are going to capture totally two reports at five seconds interval.
```
# iostat [Interval] [Number Of Reports]
# iostat 5 2
Linux 4.19.32-1-MANJARO (daygeek-Y700) Thursday 18 April 2019 _x86_64_ (8 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
29.35 0.02 16.41 0.12 0.00 54.10
Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd
nvme0n1 6.68 126.89 124.95 0.00 58420116 57525344 0
sda 0.18 6.77 80.20 0.00 3118492 36924764 0
loop0 0.00 0.00 0.00 0.00 2160 0 0
loop1 0.00 0.00 0.00 0.00 1093 0 0
loop2 0.00 0.00 0.00 0.00 1077 0 0
avg-cpu: %user %nice %system %iowait %steal %idle
3.71 0.00 2.51 0.05 0.00 93.73
Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscd
nvme0n1 19.00 0.20 311.40 0.00 1 1557 0
sda 0.20 25.60 0.00 0.00 128 0 0
loop0 0.00 0.00 0.00 0.00 0 0 0
loop1 0.00 0.00 0.00 0.00 0 0 0
loop2 0.00 0.00 0.00 0.00 0 0 0
```
Run the iostat command with `-N` option to see the LVM disk I/O statistics report.
```
# iostat -N
Linux 4.15.0-47-generic (Ubuntu18.2daygeek.com) Thursday 18 April 2019 _x86_64_ (2 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.38 0.07 0.18 0.26 0.00 99.12
Device tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda 3.60 57.07 69.06 968729 1172340
sdb 0.02 0.33 0.00 5680 0
sdc 0.01 0.12 0.00 2108 0
2g-2gvol1 0.00 0.07 0.00 1204 0
```
Run the nfsiostat command to see the I/O statistics for Network File System(NFS).
```
# nfsiostat
```
--------------------------------------------------------------------------------
via: https://www.2daygeek.com/monitor-disk-io-activity-using-iotop-iostat-command-in-linux/
作者:[Magesh Maruthamuthu][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.2daygeek.com/author/magesh/
[b]: https://github.com/lujun9972
[1]: https://www.2daygeek.com/category/monitoring-tools/
[2]: https://www.2daygeek.com/linux-top-command-linux-system-performance-monitoring-tool/
[3]: https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/
[4]: https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/
[5]: https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/
[6]: https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/
[7]: https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/
[8]: https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/
[9]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
[10]: https://www.2daygeek.com/wp-content/uploads/2015/03/monitor-disk-io-activity-using-iotop-iostat-command-in-linux-1.jpg
[11]: https://www.2daygeek.com/wp-content/uploads/2015/03/monitor-disk-io-activity-using-iotop-iostat-command-in-linux-2.jpg