[命令] Linux 命令 ls (显示文件或目录) (转载)

Linux ls命令

ls命令
1、 介绍
ls - list directory contents
ls命令是Linux中最常用的命令之一。ls是list的缩写
2、 命令格式
ls [选项] [文件名]
3、 命令功能
用来打印当前目录清单或者打印出指定目录下的文件及文件清单。ls命令在打印文件清单时,还可以查看文件权限、目录信息等等。
4、 命令参数
可以使用帮助命令查看详细命令参数:man ls或ls --help
-a, --all
do not ignore entries starting with .(列出目录下的所有文件,包括以.开头的隐含文件)

-A, --almost-all
do not list implied . and …(列出除了.及…以外的所有文件)

–author
with -l, print the author of each file(打印出每一个文件的作者)

-b, --escape
print octal escapes for nongraphic characters(不能输出的字符用反斜杠加字符编号的形式输出)

–block-size=SIZE
use SIZE-byte blocks.(使用SIZE-byte的大小的字节为单位)

-B, --ignore-backups
do not list implied entries ending with ~(不列出任何以波浪号结束的项目)

-c with -lt: sort by, and show, ctime (time of last modification of file status information) with -l: show ctime and sort by name otherwise: sort by ctime
(输出文件的ctime(文件状态最后更改的时间),并根据ctime排序)

-C list entries by columns(由上至下的列出项目)

–color[=WHEN]
colorize the output. WHEN defaults to ‘always’ or can be ‘never’ or ‘auto’. More info below(控制是否使用色彩分辨文件。WHEN可以是always、never或者auto其中一个)

-d, --directory
list directory entries instead of contents, and do not dereference symbolic links
(将目录像文件一样显示,而不显示目录下面的内容)

-D, --dired
generate output designed for Emacs’ dired mode(产生适合Emacs的dired模 式使用的结果)

-f do not sort, enable -aU, disable -ls --color(对输出的文件不进行排序,-aU选线生效,-ls选项失效)

-F, --classify
append indicator (one of /=>@|) to entries(加上文件类型的指示符号(/=@| 其中一个))

–file-type
likewise, except do not append ‘’(和-F一样,除了不追加“”)

–format=WORD
across -x, commas -m, horizontal -x, long -l, single-column -1, verbose -l, vertical -C(–format=关键之,关键字可以是“across -x, commas -m, horizontal -x, long -l, single-column -1, verbose -l, vertical -C”)

–full-time
like -l --time-style=full-iso(即 -l --time-style=full-iso)

-g like -l, but do not list owner(像-l,但是不列出所有者)

–group-directories-first
group directories before files.(组目录在文件目录之前)

augment with a --sort option, but any use of --sort=none (-U) disables grouping
(用-sort选项进行扩展,但任何使用-sort=none(-U)禁用组)

-G, --no-group
in a long listing, don’t print group names(不列出任何有关于组的信息)

-h, --human-readable
with -l, print sizes in human readable format (e.g., 1K 234M 2G)(类似于-l,以人容易理解的格式列出文件大小)

–si likewise, but use powers of 1000 not 1024(像-h,但是文件大小取1000而不是1024)

-H, --dereference-command-line
follow symbolic links listed on the command line(使用命令列中的符号链接指示的 真正目的地)

–dereference-command-line-symlink-to-dir
follow each command line symbolic link that points to a directory(遵循指向目录的 每个命令行符号链接)

–hide=PATTERN
do not list implied entries matching shell PATTERN (overridden by -a or -A)(不 要列出与shell模式匹配的隐含条目(由-a或-A重写))

–indicator-style=WORD
append indicator with style WORD to entry names: none (default), slash (- p), file-type (–file-type), classify (-F)(指定在每个项目名称后加上指示符号<方 式>:none (default), slash (-p), file-type (–file-type), classify (-F))

-i, --inode
print the index number of each file(输出每个文件的inode号)

-I, --ignore=PATTERN
do not list implied entries matching shell PATTERN(不列出任何符合sell万用字 符<样式>的项目)

-k like --block-size=1K(像 --block-size=1K,以k字节的形式表示文件的大小)

-l use a long listing format(使用长格式,即列出文件详细信息)

-L, --dereference
when showing file information for a symbolic link, show information for the file the link references rather than for the link itself(当显示符号连接的文件信息时,显示符号链接所指示的对象而并非符号链接本身的信息)

-m fill width with a comma separated list of entries(所有项目以逗号隔开,并填满整行行宽)

-n, --numeric-uid-gid
like -l, but list numeric user and group IDs(类似-l,用数字UID和GID代替名称)

-N, --literal
print raw entry names (don’t treat e.g. control characters specially)(印出未经处理 的项目名称,(例如不特别处理控制字符))

-o like -l, but do not list group information(类似-l,但是不现实组信息)

-p, --indicator-style=slash
append / indicator to directories(向目录追加/指示器)

-q, --hide-control-chars
print ? instead of non graphic characters(以?字符代替无法打印的字符)

–show-control-chars
show non graphic characters as-is (default unless program is ‘ls’ and output is a terminal)(直接显示无法打印的字符(这是默认方式,除非调用的程序名称时‘ls’而且在终端机画面输出结果))

-Q, --quote-name
enclose entry names in double quotes(将项目名称打上双引号)

–quoting-style=WORD
use quoting style WORD for entry names: literal, locale, shell, shell-always, c, escape(使用指定的quotin方式类型:literal, locale, shell, shell-always, c, escape)

-r, --reverse
reverse order while sorting(以相反次序排列)

-R, --recursive
list subdirectories recursively(同时列出所有子目录层)

-s, --size
print the allocated size of each file, in blocks(以块大小为单位列出所有文件的大小)

-S sort by file size(根据文件大小排序)

–sort=WORD
sort by WORD instead of name: none -U, extension -X, size -S, time -t, version -v(根据关键词代替名字排序:none -U, extension -X, size -S, time -t, version -v)

–time=WORD
with -l, show time as WORD instead of modification time: atime -u, access -u, use -u, ctime -c, or status-c; use specified time as sort key if --sort=time(类似于-l,根据关键词显示时间代替默认的修改时间:atime -u, access -u, use -u, ctime -c, or status)

–time-style=STYLE
with -l, show times using style STYLE: full-iso, long-iso, iso, locale, +FORMAT. FORMAT is interpreted like ‘date’; if FORMAT is FORMAT1FORMAT2, FORMAT1 applies to non-recent files and FORMAT2 to recent files; if STYLE is prefixed with ‘posix-’, STYLE takes effect only outside the POSIX locale(显示时间使用style:…………)

-t sort by modification time(以文件修改时间排序)

-T, --tabsize=COLS
assume tab stops at each COLS instead of 8(显示我文件或目录最后被访问的时间)

-u with -lt: sort by, and show, access time with -l: show access time and sort by name otherwise: sort by access time(-u配合-lt:显示访问时间而依访问时间排序;
配合-l:显示访问时间但根据名称排序;否则,根据访问时间排序)

-U do not sort; list entries in directory order(不进行排序,依系统原有的次序列出项目)

-v natural sort of (version) numbers within text(根据文件版本进行排序)

-w, --width=COLS
assume screen width instead of current value(自行指定屏幕的宽度而不使用目前的数值)

-x list entries by lines instead of by columns(逐行列出项目而不是逐栏列出)

-X sort alphabetically by entry extension(根据扩展名排序)

-1 list one file per line(每行只列出一个文件)

–help 显示此帮助信息并退出

-version 显示版本信息并退出

5、命令范例
由于ls选项过多,这里仅使用一些常用选项做举例
实例1:查看当前目录下的文件或目录
[root@lianxi tmp]# ls
1d 2d 3d 4d TEST

实例2:使用长清单模式,-l参数
[root@lianxi tmp]# ls -l
total 20
drwxr-xr-x. 2 root root 4096 Dec 8 00:44 1d
drwxr-xr-x. 2 root root 4096 Dec 8 00:44 2d
drwxr-xr-x. 2 root root 4096 Dec 8 00:44 3d
drwxr-xr-x. 2 root root 4096 Dec 8 00:44 4d
drwxr-xr-x. 6 root root 4096 Dec 8 00:46 TEST

注:第1列
第一个字母d意味着内容是目录或者文件。如果是’-‘(减号),这意味着它的内容是文件。当它是l(小写l字符),意味这内容是链接文件。
下面的9个字符是关于文件权限。前3个rwx字符是文件的拥有者的权限,第二组3rwx是文件的所有组的权限,最后的rwx是对其他人访问文件的权限。
第2列 这行告诉我们有多少链接指向这个文件。
第3列 这行告诉我们谁是这个文件/文件夹的所有者。
第4列 这行告诉我们谁是这个文件/文件夹的所有组。
第5列 这行告诉我们这个文件/文件夹的以字节为单位的大小。 目录的大小总是4096字节。
第6列 这告诉我们文件最后的修改时间。
第7列 这告诉我们文件名或者目录名。

实例3:显示文件大小
① 以便于人阅读的方式显示文件大小,-h参数
[root@lianxi tmp]# ls -lh
total 20K
drwxr-xr-x. 2 root root 4.0K Dec 8 00:44 1d
drwxr-xr-x. 2 root root 4.0K Dec 8 00:44 2d
drwxr-xr-x. 2 root root 4.0K Dec 8 00:44 3d
drwxr-xr-x. 2 root root 4.0K Dec 8 00:44 4d
drwxr-xr-x. 6 root root 4.0K Dec 8 00:46 TEST
② 使用–si参数,此参数和-h类似,但-si是以1000为单位,而-h是以1024为单位
[root@lianxi tmp]# ls -l --si
total 21k
drwxr-xr-x. 2 root root 4.1k Dec 8 00:44 1d
drwxr-xr-x. 2 root root 4.1k Dec 8 00:44 2d
drwxr-xr-x. 2 root root 4.1k Dec 8 00:44 3d
drwxr-xr-x. 2 root root 4.1k Dec 8 00:44 4d
drwxr-xr-x. 6 root root 4.1k Dec 8 00:46 TEST

实例4:排序文件大小,-S参数
[root@lianxi tmp]# ls -lhS /etc/
total 1.7M
-rw-r–r--. 1 root root 626K Oct 2 2013 services
-rw-r–r--. 1 root root 150K Dec 8 03:14 prelink.cache
-rw-r–r--. 1 root root 87K Dec 7 14:44 termcap
-rw-r–r--. 1 root root 43K Sep 23 2011 mime.types
drwxr-xr-x. 3 root root 4.0K Dec 7 14:43 abrt
drwxr-xr-x. 4 root root 4.0K Dec 7 14:44 acpi

实例5:测量大小,使用–block-size=key
ls可以通过使用–block-size=SIZE改单位大小。这里的SIZE是:
K = Kilobyte M = Megabyte G = Gigabyte T = Terabyte
P = Petabyte E = Exabyte Z = Zettabyte Y = Yottabyte
比如,我们希望使用KB作为单位大小。所以语法就会像这样:
[root@lianxi tmp]# ls -l --block-size=K /etc/
total 1680K
drwxr-xr-x. 3 root root 4K Dec 7 14:43 abrt
drwxr-xr-x. 4 root root 4K Dec 7 14:44 acpi
-rw-r–r--. 1 root root 1K Dec 7 23:31 adjtime
-rw-r–r--. 1 root root 2K Jan 12 2010 aliases
-rw-r–r--. 1 root root 12K Dec 7 14:45 aliases.db
drwxr-xr-x. 2 root root 4K Dec 7 14:44 alsa
drwxr-xr-x. 2 root root 4K Dec 7 14:43 alternatives

实例6:显示隐藏文件,即以.开头的文件,使用-a参数
[root@lianxi tmp]# ls -a
. … 1d 2d 3d 4d .ICE-unix TEST

实例7:只列出目录,使用-d参数
[root@lianxi etc]# ls -ld */
drwxr-xr-x. 3 root root 4096 Dec 7 14:43 abrt/
drwxr-xr-x. 4 root root 4096 Dec 7 14:44 acpi/
drwxr-xr-x. 2 root root 4096 Dec 7 14:44 alsa/
drwxr-xr-x. 2 root root 4096 Dec 7 14:43 alternatives/
drwxr-x—. 3 root root 4096 Dec 7 14:44 audisp/
drwxr-x—. 2 root root 4096 Dec 7 14:44 audit/
drwxr-xr-x. 2 root root 4096 Dec 7 14:44 bash_completion.d/
drwxr-xr-x. 2 root root 4096 Dec 7 14:45 blkid/

实例8:不打印所有者信息,使用-g参数
[root@lianxi etc]# ls -g
total 1680
drwxr-xr-x. 3 root 4096 Dec 7 14:43 abrt
drwxr-xr-x. 4 root 4096 Dec 7 14:44 acpi
-rw-r–r--. 1 root 46 Dec 7 23:31 adjtime
-rw-r–r--. 1 root 1512 Jan 12 2010 aliases
-rw-r–r--. 1 root 12288 Dec 7 14:45 aliases.db
drwxr-xr-x. 2 root 4096 Dec 7 14:44 alsa
drwxr-xr-x. 2 root 4096 Dec 7 14:43 alternatives
-rw-------. 1 root 541 Nov 23 2013 anacrontab
-rw-r–r--. 1 root 148 May 15 2009 asound.conf
-rw-r–r--. 1 root 1 Jan 30 2012 at.deny

实例9:不打印组信息,使用-G参数
[root@lianxi etc]# ls -lG
total 1680
drwxr-xr-x. 3 root 4096 Dec 7 14:43 abrt
drwxr-xr-x. 4 root 4096 Dec 7 14:44 acpi
-rw-r–r--. 1 root 46 Dec 7 23:31 adjtime
-rw-r–r--. 1 root 1512 Jan 12 2010 aliases
-rw-r–r--. 1 root 12288 Dec 7 14:45 aliases.db
drwxr-xr-x. 2 root 4096 Dec 7 14:44 alsa
drwxr-xr-x. 2 root 4096 Dec 7 14:43 alternatives
-rw-------. 1 root 541 Nov 23 2013 anacrontab
-rw-r–r--. 1 root 148 May 15 2009 asound.conf
-rw-r–r--. 1 root 1 Jan 30 2012 at.deny

实例10:打印UID和GID代替用户名和组名,使用-n参数
[root@lianxi etc]# ls -n
total 1680
drwxr-xr-x. 3 0 0 4096 Dec 7 14:43 abrt
drwxr-xr-x. 4 0 0 4096 Dec 7 14:44 acpi
-rw-r–r--. 1 0 0 46 Dec 7 23:31 adjtime
-rw-r–r--. 1 0 0 1512 Jan 12 2010 aliases
-rw-r–r--. 1 0 0 12288 Dec 7 14:45 aliases.db
drwxr-xr-x. 2 0 0 4096 Dec 7 14:44 alsa
drwxr-xr-x. 2 0 0 4096 Dec 7 14:43 alternatives
-rw-------. 1 0 0 541 Nov 23 2013 anacrontab
-rw-r–r--. 1 0 0 148 May 15 2009 asound.conf
-rw-r–r--. 1 0 0 1 Jan 30 2012 at.deny
drwxr-x—. 3 0 0 4096 Dec 7 14:44 audisp

实例11:不带颜色打印,使用–color=never参数
[root@lianxi etc]# ls -l --color=never
total 1680
drwxr-xr-x. 3 root root 4096 Dec 7 14:43 abrt
drwxr-xr-x. 4 root root 4096 Dec 7 14:44 acpi
-rw-r–r--. 1 root root 46 Dec 7 23:31 adjtime
-rw-r–r--. 1 root root 1512 Jan 12 2010 aliases
-rw-r–r--. 1 root root 12288 Dec 7 14:45 aliases.db
drwxr-xr-x. 2 root root 4096 Dec 7 14:44 alsa
drwxr-xr-x. 2 root root 4096 Dec 7 14:43 alternatives
-rw-------. 1 root root 541 Nov 23 2013 anacrontab
-rw-r–r--. 1 root root 148 May 15 2009 asound.conf
在这里插入图片描述
在这里插入图片描述

实例12:打印每个文件的索引号,使用-i参数
[root@lianxi etc]# ls -li
total 1680
918741 drwxr-xr-x. 3 root root 4096 Dec 7 14:43 abrt
791386 drwxr-xr-x. 4 root root 4096 Dec 7 14:44 acpi
790584 -rw-r–r--. 1 root root 46 Dec 7 23:31 adjtime
784914 -rw-r–r--. 1 root root 1512 Jan 12 2010 aliases
791636 -rw-r–r--. 1 root root 12288 Dec 7 14:45 aliases.db
791495 drwxr-xr-x. 2 root root 4096 Dec 7 14:44 alsa
785057 drwxr-xr-x. 2 root root 4096 Dec 7 14:43 alternatives
790861 -rw-------. 1 root root 541 Nov 23 2013 anacrontab
786368 -rw-r–r--. 1 root root 148 May 15 2009 asound.conf

实例13:增加/(斜线)标记目录,-p参数
[root@lianxi etc]# ls -lp
total 1680
drwxr-xr-x. 3 root root 4096 Dec 7 14:43 abrt/
drwxr-xr-x. 4 root root 4096 Dec 7 14:44 acpi/
-rw-r–r--. 1 root root 46 Dec 7 23:31 adjtime
-rw-r–r--. 1 root root 1512 Jan 12 2010 aliases
-rw-r–r--. 1 root root 12288 Dec 7 14:45 aliases.db
drwxr-xr-x. 2 root root 4096 Dec 7 14:44 alsa/
drwxr-xr-x. 2 root root 4096 Dec 7 14:43 alternatives/
-rw-------. 1 root root 541 Nov 23 2013 anacrontab
-rw-r–r--. 1 root root 148 May 15 2009 asound.conf

实例14:排序时反转顺序,使用-r参数
[root@lianxi etc]# ls -lr
total 1680
drwxr-xr-x. 2 root root 4096 Dec 7 14:43 yum.repos.d
-rw-r–r--. 1 root root 969 Feb 22 2013 yum.conf
drwxr-xr-x. 5 root root 4096 Dec 7 14:43 yum
drwxr-xr-x. 2 root root 4096 Dec 7 14:43 xinetd.d
drwxr-xr-x. 3 root root 4096 Dec 7 14:42 xdg
drwxr-xr-x. 4 root root 4096 Dec 7 14:43 X11
-rw-r–r--. 1 root root 0 Dec 7 14:47 wvdial.conf
-rw-r–r--. 1 root root 4479 Oct 10 2012 wgetrc
-rw-r–r--. 1 root root 3008 Nov 22 2013 warnquota.conf
-rw-r–r--. 1 root root 1962 Feb 17 2012 virc

实例15:递归列出子目录,使用-R参数
[root@lianxi etc]# ls -R /tmp/
/tmp/:
1d 2d 3d 4d TEST
/tmp/1d:
/tmp/2d:
/tmp/3d:
/tmp/4d:
/tmp/TEST:

实例16:扩展名排序,使用-X参数或者–sort=extension
[root@lianxi etc]# ls -lrX
total 1680
drwxr-xr-x. 2 root root 4096 Sep 27 2011 cron.weekly
-rw-r–r--. 1 root root 1112 Mar 31 2003 minicom.users
-rw-r–r--. 1 root root 43591 Sep 23 2011 mime.types
lrwxrwxrwx. 1 root root 15 Dec 7 14:43 rc.sysinit -> rc.d/rc.sysinit
-rw-r–r--. 1 root root 1 Dec 7 23:23 resolv.conf.save
-rw-r–r--. 1 root root 1909 Aug 1 2013 mail.rc
lrwxrwxrwx. 1 root root 56 Dec 7 14:42 favicon.png -> /usr/share/icons/hicolor/16x16/apps/system-logo-icon.png
-rw-r–r--. 1 root root 46 Nov 27 2013 issue.net
drwxr-xr-x. 2 root root 4096 Dec 7 14:44 cron.monthly

实例17:通过修改时间列出,比较新的会在前面,使用-t参数
[root@lianxi etc]# ls -lt
total 1680
-rw-r–r--. 1 root root 152927 Dec 8 03:14 prelink.cache
-rw-r–r--. 1 root root 264 Dec 7 23:31 mtab
-rw-r–r--. 2 root root 53 Dec 7 23:31 resolv.conf
-rw-r–r--. 1 root root 46 Dec 7 23:31 adjtime
drwxr-xr-x. 7 root root 4096 Dec 7 23:29 sysconfig
-rw-r–r--. 2 root root 165 Dec 7 23:28 hosts
-rw-r–r--. 1 root root 1 Dec 7 23:23 resolv.conf.save

实例18:列出主目录
[root@lianxi etc]# ls ~
anaconda-ks.cfg install.log install.log.syslog

实例19:列出父目录
[root@lianxi etc]# ls …/
bin boot data dev etc home lib lib64 lost+found media mnt opt proc root sbin selinux srv sys tmp usr var

实例20:打印ls命令版本
[root@lianxi etc]# ls --version
ls (GNU coreutils) 8.4
Copyright © 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Richard M. Stallman and David MacKenzie.
————————————————
版权声明:本文为CSDN博主「micjlxx」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/micjlxx/article/details/84889322

注明:所有转载内容皆直接从被转载文章网页的标题和内容的文本中复制而来

CC 4.0 BY-SA 版权协议网址:https://creativecommons.org/licenses/by-sa/4.0/deed.z

[命令] Linux 命令 iostat (显示硬盘读写和处理器占用状况) (转载)

iostat 介绍

iostat用于查看存储设备的IO负载情况,输出信息是指定间隔时间内的平均数据,可以持续输出观察。
通过iostat --help通常看不到直观的信息

[root@master ~]# iostat --help
Usage: iostat [ options ] [ <interval> [ <count> ] ]
Options are:
[ -c ] [ -d ] [ -N ] [ -n ] [ -h ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -y ] [ -z ]
[ -j { ID | LABEL | PATH | UUID | ... } [ <device> [...] | ALL ] ]
[ <device> [...] | ALL ] [ -p [ <device> [,...] | ALL ] ]

    1
    2
    3
    4
    5
    6

可以通过man iostat来查看该命令的具体解释
man iostat|cat > iostat_help.txt

1.常用的选项

OPTIONS
       -c     展示CPU使用情况
       -d     展示存储设备使用情况
       -h     使输出信息更易看。
       -k     使某些使用block为单位的列强制使用k为单位显示统计信息
       -m     使某些使用block为单位的列强制使用m为单位显示统计信息
       -N     显示任何已注册设备映射器名称, 用于查看LVM2统计
       -n     展示NFS使用情况
       -p [ { device [,...] | ALL } ]
              显示设备块及其分区统计信息,可以单独指定特定的设备
       -t     打印显示的每个报表的时间, 时间戳格式可能取决于S_TIME_FORMAT环境变量
       -V     显示iostat版本
       -x     显示扩展统计信息
       -y     如果指定了持续输出,那么忽略默认显示的第一次统计信息,即从系统启动直到执行命令的平均信息。
       -z     省略在采样期间没有活动的任何设备的输出.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15

2.执行样例

       iostat
              展示从系统启动到执行命令期间的CPU和存储设备平均统计信息
       iostat -d 2
              以2秒间隔展示存储设备统计信息
       iostat -d 2 6
              以2秒间隔展示存储设备统计信息,共展示6次
       iostat -x hda hdb 2 6
              以2秒间隔展示存储设备hda和hdb的拓展统计信息,共展示6次
       iostat -p sda 2 6
              以2秒间隔展示存储设备sda及其分区的统计信息,共展示6次

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10

3.输出信息解析

# iostat -x -d -m -y -c 2 10
Linux 3.10.0-229.el7.x86_64 (KYL-DB-MYSQL-SLAVE01)      05/09/2019      _x86_64_        (24 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.40    0.00    0.38    4.13    0.00   95.10

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
sda               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
sdb               0.00     0.00   14.00  563.00     0.07    19.51    69.49     1.40    2.46    9.89    2.28   0.88  50.90
dm-0              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
dm-1              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
dm-2              0.00     0.00   13.50  562.50     0.07    19.50    69.58     1.41    2.47   10.26    2.28   0.88  50.95

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12

1.CPU信息
%user:用户态CPU使用率
%nice:优先级变化占用CPU的使用率
%system:内核态CPU使用率
%iowait:CPU等待IO的占比
%steal:虚拟CPU等待实际CPU的时间的百分比
%idle:CPU空闲率

2.存储设备信息
rrqm/s:每秒对该设备的读请求的合并次数
wrqm/s:每秒对该设备的写请求的合并次数
r/s:每秒读取的次数
w/s:每秒写入的次数
rMB/s:以m为单位计算每秒读取量
wMB/s:以m为单位计算每秒写入量
avgrq-sz:平均每次IO操作的数据量(扇区数为单位),包括读和写
avgqu-sz:平均等待处理的IO请求队列长度
await:平均IO等待时间(milliseconds),包括排队时间和IO执行时间
r_await:平均读取等待时间(milliseconds),包括排队时间和IO执行时间
w_await:平均写入等待时间(milliseconds),包括排队时间和IO执行时间
svctm:平均IO服务时间(milliseconds),不准确
%util:统计时间内,CPU处理IO的时间对于间隔时间的占比,例如间隔2秒,CPU处理IO占了1秒,那么就是50%,可以体现存储设备的繁忙程度
————————————————
版权声明:本文为CSDN博主「灯火觅阑珊」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_39004901/article/details/90022623

注明:所有转载内容皆直接从被转载文章网页的标题和内容的文本中复制而来

CC 4.0 BY-SA 版权协议网址:https://creativecommons.org/licenses/by-sa/4.0/deed.z

[实验] NFS 远程共享服务的搭建 (openSUSE Leap 15 版)

纪念:站主于 2020 年 1 月完成了此开源实验,并将过程中的所有命令经过整理和注释以后,形成以下教程

步骤目录:

步骤一:规划拓扑
1.1 服务器列表
1.2 服务器列表简介

步骤二:系统环境要求

步骤三:所有服务器安装 NFS 服务
3.1 所有服务器安装 NFS 服务
3.2 设置所有服务器开机自启 NFS 服务
3.3 所有服务器启动 NFS 服务

步骤四:配置 NFS 服务
4.1 创建用于 NFS 服务的目录
4.1.1 创建被 NFS 服务共享的目录
4.1.2 创建用于挂载 NFS 服务分享目录的目录
4.2 配置服务端的 NFS 服务配置文件
4.2.1 在服务端上添加可被 NFS 服务挂载的选项
4.2.2 让刚刚修改的 NFS 服务配置文件生效
4.3 配置客户端的 NFS 服务挂载文件
4.3.1 在客户端上添加开机挂载 NFS 服务的选项
4.3.2 让刚刚修改的 NFS 服务挂载文件

步骤五:确认 NFS 服务是否搭建成功

具体的操作步骤:

具体的操作步骤:
步骤一:规划拓扑
1.1 服务器列表

服务端 192.168.1.20
客户端 192.168.1.21

1.2 服务器列表简介

1) 服务器提供 NFS 服务将自己的目录分享
2) 客户端挂载和使用 NFS 服务将服务端分享的目录挂载在自己的目录上

步骤二:系统环境要求

1) 所有服务器的系统都需要是 openSUSE 15.1 版本
2) 所有服务器都要关闭防火墙
3) 所有服务器系统都要配置好可用的软件源(最好是软件数量最多的官方版本)
4) 需要按照拓扑图给对应的服务器配置好 IP 地址和主机名
5) 所有服务器都要可以相互 ping 通自己和对方的 IP 地址和主机名

步骤三:所有服务器安装 NFS 服务
3.1 所有服务器安装 NFS 服务

(分别在服务端和客户端上执行以下步骤)

# zypper install nfs-kernel-server
# zypper install nfs-client

3.2 设置所有服务器开机自启 NFS 服务

(分别在服务端和客户端上执行以下步骤)

# systemctl enable rpcbind
# systemctl enable nfsserver

3.3 所有服务器启动 NFS 服务

(分别在服务端和客户端上执行以下步骤)

# systemctl start rpcbind
# systemctl start nfsserver

步骤四:配置 NFS 服务
4.1 创建用于 NFS 服务的目录
4.1.1 创建被 NFS 服务共享的目录

(只在服务端上执行以下步骤)

# mkdir /nfsserver

4.1.2 创建用于挂载 NFS 服务分享目录的目录

(只在客户端上执行以下步骤)

# mkdir /nfsclient

4.2 配置服务端的 NFS 服务配置文件
4.2.1 在服务端上添加可被 NFS 服务挂载的选项

(只在服务端上执行以下步骤)

# vi /etc/exports

添加以下内容:

......
/nfsserver 192.168.1.21(rw,no_root_squash,no_subtree_check)

(补充:这里的 192.168.1.21 是客户端的 IP 地址)

4.2.2 让刚刚修改的 NFS 服务配置文件生效

(只在服务端上执行以下步骤)

# exportfs -a

4.3 配置客户端的 NFS 服务挂载文件
4.3.1 在客户端上添加开机挂载 NFS 的选项

(只在客户端上执行以下步骤)

# vi /etc/fstab

添加以下内容:

......
192.168.1.20:/nfsserver /nfsclient nfs  timeo=120,rw,soft,nolock  0 0

4.3.2 让刚刚修改的 NFS 服务挂载文件生效

(只在客户端上执行以下步骤)

# mount -a

步骤五:确认 NFS 服务是否搭建成功

(只在客户端上执行以下步骤)

# df -h | grep 192.168.1.20

(补充:如果出现了类似 “192.168.1.20:/nfsserver 38G 5.5G 31G 16% /nfsclient”,则代表 NFS 搭建成功了)