deploy
commit
e3e645a29a
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>LINUX-TUTORIAL</title>
|
||||
<meta name="generator" content="VuePress 1.8.2">
|
||||
<link rel="icon" href="/linux-tutorial/favicon.ico">
|
||||
<meta name="description" content="数据库教程">
|
||||
|
||||
<link rel="preload" href="/linux-tutorial/assets/css/0.styles.45d9d031.css" as="style"><link rel="preload" href="/linux-tutorial/assets/js/app.79a38eea.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/9.ebfa537e.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/5.cb43ecfb.js" as="script"><link rel="prefetch" href="/linux-tutorial/assets/js/10.7933187b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/11.b9b41530.js"><link rel="prefetch" href="/linux-tutorial/assets/js/12.70a5dba8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/13.857dcc43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/14.5a603a55.js"><link rel="prefetch" href="/linux-tutorial/assets/js/15.d217acb7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/16.ad565eae.js"><link rel="prefetch" href="/linux-tutorial/assets/js/17.d43e9f56.js"><link rel="prefetch" href="/linux-tutorial/assets/js/18.aa00ff43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/19.43ce44b3.js"><link rel="prefetch" href="/linux-tutorial/assets/js/20.5618e1ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/21.1c5a41d7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/22.fbe9fdf1.js"><link rel="prefetch" href="/linux-tutorial/assets/js/23.a4fb0e74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/24.e3a23b69.js"><link rel="prefetch" href="/linux-tutorial/assets/js/25.9896afe9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/26.96164082.js"><link rel="prefetch" href="/linux-tutorial/assets/js/27.391033bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/28.703f74c2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/29.02a952cb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/30.7e13628f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/31.c4652f75.js"><link rel="prefetch" href="/linux-tutorial/assets/js/32.05d2cbec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/33.3b265df8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/34.26330a03.js"><link rel="prefetch" href="/linux-tutorial/assets/js/35.417d706d.js"><link rel="prefetch" href="/linux-tutorial/assets/js/36.0ed775e0.js"><link rel="prefetch" href="/linux-tutorial/assets/js/37.34430c74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/38.87d5e0ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/39.7b648b3e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/4.fb6e0f89.js"><link rel="prefetch" href="/linux-tutorial/assets/js/40.3b7a219e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/41.e727eee9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/42.0134c187.js"><link rel="prefetch" href="/linux-tutorial/assets/js/43.175e982f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/44.72d90888.js"><link rel="prefetch" href="/linux-tutorial/assets/js/45.d49955bd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/46.a9c290ec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/47.cc639f04.js"><link rel="prefetch" href="/linux-tutorial/assets/js/48.98c78321.js"><link rel="prefetch" href="/linux-tutorial/assets/js/49.a7c3afed.js"><link rel="prefetch" href="/linux-tutorial/assets/js/50.22d8c542.js"><link rel="prefetch" href="/linux-tutorial/assets/js/51.28055fcd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/52.f8103df5.js"><link rel="prefetch" href="/linux-tutorial/assets/js/53.76541550.js"><link rel="prefetch" href="/linux-tutorial/assets/js/54.e78d2776.js"><link rel="prefetch" href="/linux-tutorial/assets/js/55.3ce3079c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/56.832958c9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/57.961ce896.js"><link rel="prefetch" href="/linux-tutorial/assets/js/58.6d6fbc82.js"><link rel="prefetch" href="/linux-tutorial/assets/js/59.d5e48112.js"><link rel="prefetch" href="/linux-tutorial/assets/js/6.c8f4721c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/60.7927b23b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/61.ee233f24.js"><link rel="prefetch" href="/linux-tutorial/assets/js/62.6ba50cc7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/63.9cbf9f2b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/64.0be148a4.js"><link rel="prefetch" href="/linux-tutorial/assets/js/65.c520257e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/66.f2335390.js"><link rel="prefetch" href="/linux-tutorial/assets/js/67.e5737218.js"><link rel="prefetch" href="/linux-tutorial/assets/js/68.46427a01.js"><link rel="prefetch" href="/linux-tutorial/assets/js/69.450417bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/7.046e5a1b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/70.072034d2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/8.77fb8967.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~flowchart.20a64d45.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~notification.ea176280.js">
|
||||
<link rel="stylesheet" href="/linux-tutorial/assets/css/0.styles.45d9d031.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app" data-server-rendered="true"><div class="theme-container"><div class="theme-default-content"><h1>404</h1> <blockquote>There's nothing here.</blockquote> <a href="/linux-tutorial/" class="router-link-active">
|
||||
Take me home.
|
||||
</a></div></div><div class="global-ui"><!----><!----></div></div>
|
||||
<script src="/linux-tutorial/assets/js/app.79a38eea.js" defer></script><script src="/linux-tutorial/assets/js/9.ebfa537e.js" defer></script><script src="/linux-tutorial/assets/js/5.cb43ecfb.js" defer></script>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="12" height="13"><g stroke-width="2" stroke="#aaa" fill="none"><path d="M11.29 11.71l-4-4"/><circle cx="5" cy="5" r="4"/></g></svg>
|
After Width: | Height: | Size: 216 B |
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
(window.webpackJsonp=window.webpackJsonp||[]).push([[11],{399:function(r,e,t){"use strict";t.r(e);var o=t(15),n=Object(o.a)({},(function(){var r=this,e=r.$createElement,t=r._self._c||e;return t("ContentSlotsDistributor",{attrs:{"slot-key":r.$parent.slotKey}},[t("h1",{attrs:{id:"docker-教程"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#docker-教程"}},[r._v("#")]),r._v(" Docker 教程")]),r._v(" "),t("h2",{attrs:{id:"📖-内容"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#📖-内容"}},[r._v("#")]),r._v(" 📖 内容")]),r._v(" "),t("ul",[t("li",[t("RouterLink",{attrs:{to:"/docker/docker/docker-quickstart.html"}},[r._v("Docker 快速入门")])],1),r._v(" "),t("li",[t("RouterLink",{attrs:{to:"/docker/docker/docker-dockerfile.html"}},[r._v("Dockerfile 最佳实践")])],1),r._v(" "),t("li",[t("RouterLink",{attrs:{to:"/docker/docker/docker-cheat-sheet.html"}},[r._v("Docker Cheat Sheet")])],1),r._v(" "),t("li",[t("RouterLink",{attrs:{to:"/docker/docker/kubernetes.html"}},[r._v("Kubernetes 应用指南")])],1)]),r._v(" "),t("h2",{attrs:{id:"📚-资料"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#📚-资料"}},[r._v("#")]),r._v(" 📚 资料")]),r._v(" "),t("ul",[t("li",[t("strong",[r._v("官方")]),r._v(" "),t("ul",[t("li",[t("a",{attrs:{href:"http://www.docker.com",target:"_blank",rel:"noopener noreferrer"}},[r._v("Docker 官网"),t("OutboundLink")],1)]),r._v(" "),t("li",[t("a",{attrs:{href:"https://docs.docker.com/",target:"_blank",rel:"noopener noreferrer"}},[r._v("Docker 官方文档"),t("OutboundLink")],1)]),r._v(" "),t("li",[t("a",{attrs:{href:"https://github.com/moby/moby",target:"_blank",rel:"noopener noreferrer"}},[r._v("Docker Github"),t("OutboundLink")],1)]),r._v(" "),t("li",[t("a",{attrs:{href:"https://github.com/docker/compose",target:"_blank",rel:"noopener noreferrer"}},[r._v("Docker Compose Github"),t("OutboundLink")],1)]),r._v(" "),t("li",[t("a",{attrs:{href:"https://hub.docker.com/",target:"_blank",rel:"noopener noreferrer"}},[r._v("Docker Hub"),t("OutboundLink")],1)]),r._v(" "),t("li",[t("a",{attrs:{href:"https://www.docker.com/community/open-source",target:"_blank",rel:"noopener noreferrer"}},[r._v("Docker 开源"),t("OutboundLink")],1)])])]),r._v(" "),t("li",[t("strong",[r._v("资源整理")]),r._v(" "),t("ul",[t("li",[t("a",{attrs:{href:"https://github.com/veggiemonk/awesome-docker",target:"_blank",rel:"noopener noreferrer"}},[r._v("Awesome Docker"),t("OutboundLink")],1)])])]),r._v(" "),t("li",[t("strong",[r._v("教程")]),r._v(" "),t("ul",[t("li",[t("a",{attrs:{href:"https://github.com/yeasy/docker_practice",target:"_blank",rel:"noopener noreferrer"}},[r._v("Docker — 从入门到实践"),t("OutboundLink")],1),r._v(" - 非常详尽的 Docker 中文教程")]),r._v(" "),t("li",[t("a",{attrs:{href:"https://www.docker-cn.com/",target:"_blank",rel:"noopener noreferrer"}},[r._v("Docker 中文网站"),t("OutboundLink")],1)]),r._v(" "),t("li",[t("a",{attrs:{href:"https://docs.docker-cn.com/engine/installation/",target:"_blank",rel:"noopener noreferrer"}},[r._v("Docker 安装手册"),t("OutboundLink")],1)])])]),r._v(" "),t("li",[t("strong",[r._v("镜像")]),r._v(" "),t("ul",[t("li",[t("a",{attrs:{href:"https://hub.tenxcloud.com/",target:"_blank",rel:"noopener noreferrer"}},[r._v("时速云镜像仓库"),t("OutboundLink")],1)]),r._v(" "),t("li",[t("a",{attrs:{href:"https://c.163.com/hub#/m/library/",target:"_blank",rel:"noopener noreferrer"}},[r._v("网易云镜像服务"),t("OutboundLink")],1)]),r._v(" "),t("li",[t("a",{attrs:{href:"https://hub.daocloud.io/",target:"_blank",rel:"noopener noreferrer"}},[r._v("DaoCloud 镜像市场"),t("OutboundLink")],1)]),r._v(" "),t("li",[t("a",{attrs:{href:"https://cr.console.aliyun.com/",target:"_blank",rel:"noopener noreferrer"}},[r._v("阿里云镜像库"),t("OutboundLink")],1)])])]),r._v(" "),t("li",[t("strong",[r._v("文章")]),r._v(" "),t("ul",[t("li",[t("a",{attrs:{href:"http://www.ruanyifeng.com/blog/2018/02/docker-tutorial.html",target:"_blank",rel:"noopener noreferrer"}},[r._v("Docker 入门教程"),t("OutboundLink")],1)]),r._v(" "),t("li",[t("a",{attrs:{href:"https://github.com/wsargent/docker-cheat-sheet/tree/master/zh-cn",target:"_blank",rel:"noopener noreferrer"}},[r._v("Docker Cheat Sheet"),t("OutboundLink")],1)])])])]),r._v(" "),t("h2",{attrs:{id:"🚪-传送门"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#🚪-传送门"}},[r._v("#")]),r._v(" 🚪 传送门")]),r._v(" "),t("p",[r._v("◾ 🏠 "),t("a",{attrs:{href:"https://github.com/dunwu/linux-tutorial",target:"_blank",rel:"noopener noreferrer"}},[r._v("DB-TUTORIAL 首页"),t("OutboundLink")],1),r._v(" ◾ 🎯 "),t("a",{attrs:{href:"https://github.com/dunwu/blog",target:"_blank",rel:"noopener noreferrer"}},[r._v("我的博客"),t("OutboundLink")],1),r._v(" ◾")])])}),[],!1,null,null,null);e.default=n.exports}}]);
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
(window.webpackJsonp=window.webpackJsonp||[]).push([[17],{405:function(t,a,s){"use strict";s.r(a);var e=s(15),n=Object(e.a)({},(function(){var t=this,a=t.$createElement,s=t._self._c||a;return s("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[s("h1",{attrs:{id:"docker-安装-mysql"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#docker-安装-mysql"}},[t._v("#")]),t._v(" Docker 安装 MySQL")]),t._v(" "),s("blockquote",[s("p",[t._v("实测环境:Centos")])]),t._v(" "),s("h2",{attrs:{id:"查看可下载镜像"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#查看可下载镜像"}},[t._v("#")]),t._v(" 查看可下载镜像")]),t._v(" "),s("div",{staticClass:"language-docker extra-class"},[s("pre",{pre:!0,attrs:{class:"language-docker"}},[s("code",[s("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# docker search mysql")]),t._v("\nINDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED\ndocker.io docker.io/mysql MySQL is a widely used"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" open"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v("source relati"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("...")]),t._v(" 5757 "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("OK"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v(" \ndocker.io docker.io/mariadb MariaDB is a community"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v("developed fork of M"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("...")]),t._v(" 1863 "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("OK"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v(" \ndocker.io docker.io/mysql/mysql"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v("server Optimized MySQL Server Docker images. Crea"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("...")]),t._v(" 397 "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("OK"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("...")]),t._v("\n")])])]),s("h2",{attrs:{id:"选择下载官方镜像"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#选择下载官方镜像"}},[t._v("#")]),t._v(" 选择下载官方镜像")]),t._v(" "),s("p",[t._v("比如,我想下载最新版本,则执行如下命令:")]),t._v(" "),s("div",{staticClass:"language-docker extra-class"},[s("pre",{pre:!0,attrs:{class:"language-docker"}},[s("code",[t._v("docker pull mysql\n")])])]),s("h2",{attrs:{id:"使用镜像"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#使用镜像"}},[t._v("#")]),t._v(" 使用镜像")]),t._v(" "),s("div",{staticClass:"language-docker extra-class"},[s("pre",{pre:!0,attrs:{class:"language-docker"}},[s("code",[t._v("docker run "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v("p 3306"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v("3306 "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v("name mysql "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v("v /opt/docker_v/mysql/conf"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v("/etc/mysql/conf.d "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v("e MYSQL_ROOT_PASSWORD=123456 "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v("d mysql\n")])])]),s("h2",{attrs:{id:"资源"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#资源"}},[t._v("#")]),t._v(" 资源")]),t._v(" "),s("ul",[s("li",[t._v("https://hub.docker.com/_/mysql/")])])])}),[],!1,null,null,null);a.default=n.exports}}]);
|
|
@ -0,0 +1 @@
|
|||
(window.webpackJsonp=window.webpackJsonp||[]).push([[18],{406:function(t,n,a){"use strict";a.r(n);var s=a(15),e=Object(s.a)({},(function(){var t=this,n=t.$createElement,a=t._self._c||n;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"docker-安装-nginx"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#docker-安装-nginx"}},[t._v("#")]),t._v(" Docker 安装 Nginx")]),t._v(" "),a("blockquote",[a("p",[t._v("实测环境:Centos")])]),t._v(" "),a("h2",{attrs:{id:"查看可用镜像"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#查看可用镜像"}},[t._v("#")]),t._v(" 查看可用镜像")]),t._v(" "),a("p",[t._v("执行 "),a("code",[t._v("docker search nginx")]),t._v(" 命令查看可用镜像:")]),t._v(" "),a("div",{staticClass:"language-docker extra-class"},[a("pre",{pre:!0,attrs:{class:"language-docker"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# docker search nginx")]),t._v("\nINDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED\ndocker.io docker.io/nginx Official build of Nginx. 8272 "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("OK"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v(" \ndocker.io docker.io/jwilder/nginx"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v("proxy Automated Nginx reverse proxy for docker c"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("...")]),t._v(" 1300 "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("OK"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\ndocker.io docker.io/richarvey/nginx"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v("php"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v("fpm Container running Nginx + PHP"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v("FPM capable "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("...")]),t._v(" 540 "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("OK"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\ndocker.io docker.io/jrcs/letsencrypt"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v("nginx"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v("proxy"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("-")]),t._v("companion LetsEncrypt container to use with nginx as"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("...")]),t._v(" 336 "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("OK"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("...")]),t._v("\n")])])]),a("h2",{attrs:{id:"选择下载镜像"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#选择下载镜像"}},[t._v("#")]),t._v(" 选择下载镜像")]),t._v(" "),a("p",[t._v("执行 "),a("code",[t._v("docker pull nginx")]),t._v(" 命令下载镜像")]),t._v(" "),a("h2",{attrs:{id:"运行镜像"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#运行镜像"}},[t._v("#")]),t._v(" 运行镜像")]),t._v(" "),a("div",{staticClass:"language- extra-class"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[t._v("docker run -p 80:80 --name mynginx -d nginx\n")])])])])}),[],!1,null,null,null);n.default=e.exports}}]);
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
(window.webpackJsonp=window.webpackJsonp||[]).push([[38],{426:function(t,r,n){"use strict";n.r(r);var o=n(15),s=Object(o.a)({},(function(){var t=this,r=t.$createElement,n=t._self._c||r;return n("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[n("h1",{attrs:{id:"linux-系统运维"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#linux-系统运维"}},[t._v("#")]),t._v(" Linux 系统运维")]),t._v(" "),n("h2",{attrs:{id:"📖-内容"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#📖-内容"}},[t._v("#")]),t._v(" 📖 内容")]),t._v(" "),n("ul",[n("li",[n("RouterLink",{attrs:{to:"/linux/ops/network-ops.html"}},[t._v("网络运维")])],1),t._v(" "),n("li",[n("RouterLink",{attrs:{to:"/linux/ops/samba.html"}},[t._v("Samba")])],1),t._v(" "),n("li",[n("RouterLink",{attrs:{to:"/linux/ops/ntp.html"}},[t._v("NTP")])],1),t._v(" "),n("li",[n("RouterLink",{attrs:{to:"/linux/ops/firewalld.html"}},[t._v("Firewalld")])],1),t._v(" "),n("li",[n("RouterLink",{attrs:{to:"/linux/ops/crontab.html"}},[t._v("Crontab")])],1),t._v(" "),n("li",[n("RouterLink",{attrs:{to:"/linux/ops/systemd.html"}},[t._v("Systemd")])],1),t._v(" "),n("li",[n("RouterLink",{attrs:{to:"/linux/ops/vim.html"}},[t._v("Vim")])],1),t._v(" "),n("li",[n("RouterLink",{attrs:{to:"/linux/ops/iptables.html"}},[t._v("Iptables")])],1),t._v(" "),n("li",[n("RouterLink",{attrs:{to:"/linux/ops/zsh.html"}},[t._v("oh-my-zsh")])],1)]),t._v(" "),n("h2",{attrs:{id:"🚪-传送门"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#🚪-传送门"}},[t._v("#")]),t._v(" 🚪 传送门")]),t._v(" "),n("p",[t._v("◾ 🏠 "),n("a",{attrs:{href:"https://github.com/dunwu/linux-tutorial",target:"_blank",rel:"noopener noreferrer"}},[t._v("DB-TUTORIAL 首页"),n("OutboundLink")],1),t._v(" ◾ 🎯 "),n("a",{attrs:{href:"https://github.com/dunwu/blog",target:"_blank",rel:"noopener noreferrer"}},[t._v("我的博客"),n("OutboundLink")],1),t._v(" ◾")])])}),[],!1,null,null,null);r.default=s.exports}}]);
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
(window.webpackJsonp=window.webpackJsonp||[]).push([[48],{436:function(t,r,n){"use strict";n.r(r);var o=n(15),e=Object(o.a)({},(function(){var t=this,r=t.$createElement,n=t._self._c||r;return n("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[n("h1",{attrs:{id:"软件安装配置"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#软件安装配置"}},[t._v("#")]),t._v(" 软件安装配置")]),t._v(" "),n("h2",{attrs:{id:"📖-内容"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#📖-内容"}},[t._v("#")]),t._v(" 📖 内容")]),t._v(" "),n("ul",[n("li",[t._v("开发环境\n"),n("ul",[n("li",[n("RouterLink",{attrs:{to:"/linux/soft/jdk-install.html"}},[t._v("JDK 安装")])],1),t._v(" "),n("li",[n("RouterLink",{attrs:{to:"/linux/soft/maven-install.html"}},[t._v("Maven 安装")])],1),t._v(" "),n("li",[n("RouterLink",{attrs:{to:"/linux/soft/nodejs-install.html"}},[t._v("Nodejs 安装")])],1)])]),t._v(" "),n("li",[t._v("开发工具\n"),n("ul",[n("li",[n("RouterLink",{attrs:{to:"/linux/soft/nexus-ops.html"}},[t._v("Nexus 运维")])],1),t._v(" "),n("li",[n("RouterLink",{attrs:{to:"/linux/soft/gitlab-ops.html"}},[t._v("Gitlab 运维")])],1),t._v(" "),n("li",[n("RouterLink",{attrs:{to:"/linux/soft/jenkins-ops.html"}},[t._v("Jenkins 运维")])],1),t._v(" "),n("li",[n("RouterLink",{attrs:{to:"/linux/soft/svn-ops.html"}},[t._v("Svn 运维")])],1),t._v(" "),n("li",[n("RouterLink",{attrs:{to:"/linux/soft/yapi-ops.html"}},[t._v("YApi 运维")])],1)])]),t._v(" "),n("li",[t._v("中间件服务\n"),n("ul",[n("li",[n("a",{attrs:{href:"elastic"}},[t._v("Elastic 运维")])]),t._v(" "),n("li",[n("RouterLink",{attrs:{to:"/linux/soft/rocketmq-install.html"}},[t._v("RocketMQ 运维")])],1),t._v(" "),n("li",[n("RouterLink",{attrs:{to:"/linux/soft/nacos-install.html"}},[t._v("Nacos 运维")])],1)])]),t._v(" "),n("li",[t._v("服务器\n"),n("ul",[n("li",[n("a",{attrs:{href:"https://github.com/dunwu/nginx-tutorial",target:"_blank",rel:"noopener noreferrer"}},[t._v("Nginx 教程"),n("OutboundLink")],1),t._v(" 📚")]),t._v(" "),n("li",[n("RouterLink",{attrs:{to:"/linux/soft/tomcat-install.html"}},[t._v("Tomcat 运维")])],1)])]),t._v(" "),n("li",[n("a",{attrs:{href:"https://github.com/dunwu/db-tutorial",target:"_blank",rel:"noopener noreferrer"}},[t._v("数据库"),n("OutboundLink")],1),t._v(" 📚\n"),n("ul",[n("li",[n("a",{attrs:{href:"https://github.com/dunwu/db-tutorial/blob/master/docs/sql/mysql/mysql-ops.md",target:"_blank",rel:"noopener noreferrer"}},[t._v("Mysql 运维"),n("OutboundLink")],1)]),t._v(" "),n("li",[n("a",{attrs:{href:"https://github.com/dunwu/db-tutorial/blob/master/docs/nosql/redis/redis-ops.md",target:"_blank",rel:"noopener noreferrer"}},[t._v("Redis 运维"),n("OutboundLink")],1)])])]),t._v(" "),n("li",[t._v("大数据服务\n"),n("ul",[n("li",[n("RouterLink",{attrs:{to:"/linux/soft/kafka-install.html"}},[t._v("Kafka 运维")])],1),t._v(" "),n("li",[n("a",{attrs:{href:"https://github.com/dunwu/javatech/blob/master/docs/technology/monitor/zookeeper-ops.md",target:"_blank",rel:"noopener noreferrer"}},[t._v("Zookeeper 运维"),n("OutboundLink")],1)])])])]),t._v(" "),n("h2",{attrs:{id:"🚪-传送门"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#🚪-传送门"}},[t._v("#")]),t._v(" 🚪 传送门")]),t._v(" "),n("p",[t._v("◾ 🏠 "),n("a",{attrs:{href:"https://github.com/dunwu/linux-tutorial",target:"_blank",rel:"noopener noreferrer"}},[t._v("DB-TUTORIAL 首页"),n("OutboundLink")],1),t._v(" ◾ 🎯 "),n("a",{attrs:{href:"https://github.com/dunwu/blog",target:"_blank",rel:"noopener noreferrer"}},[t._v("我的博客"),n("OutboundLink")],1),t._v(" ◾")])])}),[],!1,null,null,null);r.default=e.exports}}]);
|
|
@ -0,0 +1 @@
|
|||
(window.webpackJsonp=window.webpackJsonp||[]).push([[49],{437:function(t,o,l){"use strict";l.r(o);var a=l(15),e=Object(a.a)({},(function(){var t=this,o=t.$createElement,l=t._self._c||o;return l("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[l("h1",{attrs:{id:"apollo"}},[l("a",{staticClass:"header-anchor",attrs:{href:"#apollo"}},[t._v("#")]),t._v(" Apollo")]),t._v(" "),l("blockquote",[l("p",[t._v("Apollo(阿波罗)是携程框架部门研发的分布式配置中心,能够集中化管理应用不同环境、不同集群的配置,配置修改后能够实时推送到应用端,并且具备规范的权限、流程治理等特性,适用于微服务配置管理场景。")])]),t._v(" "),l("p",[t._v("官方 Github:https://github.com/ctripcorp/apollo")]),t._v(" "),l("p",[t._v("由于官方示例不能直接使用,所以我 Fork 后,略作修改:https://github.com/dunwu/apollo")])])}),[],!1,null,null,null);o.default=e.exports}}]);
|
|
@ -0,0 +1 @@
|
|||
(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{348:function(t,e,n){},379:function(t,e,n){"use strict";n(348)},394:function(t,e,n){"use strict";n.r(e);var o=n(32),a=n(0),u={"/":{message:"New content is available.",buttonText:"Refresh"},"/zh/":{message:"发现新内容可用",buttonText:"刷新"},"/ru/":{message:"Доступен новый контент.",buttonText:"Обновить"},"/uk/":{message:"Доступний новий контент.",buttonText:"Оновити"},"/ja/":{message:"新しいコンテンツがあります。",buttonText:"更新する"},"/es/":{message:"Hay nuevo contenido disponible.",buttonText:"Actualizar"}},s={name:"SWUpdatePopup",data:function(){return{rawPopupConfig:!0,updateEvent:null}},computed:{popupConfig:function(){return Object(a.g)(this,this.rawPopupConfig)},enabled:function(){return Boolean(this.popupConfig&&this.updateEvent)},message:function(){var t=this.popupConfig;return t&&t.message||u["/"].message},buttonText:function(){var t=this.popupConfig;return t&&t.buttonText||u["/"].buttonText}},created:function(){o.a.$on("sw-updated",this.onSWUpdated),this.rawPopupConfig=u},methods:{onSWUpdated:function(t){this.updateEvent=t},reload:function(){this.updateEvent&&(this.updateEvent.skipWaiting().then((function(){location.reload(!0)})),this.updateEvent=null)}}},i=(n(379),n(15)),p=Object(i.a)(s,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("transition",{attrs:{name:"sw-update-popup"}},[t._t("default",[t.enabled?n("div",{staticClass:"sw-update-popup"},[t._v("\n "+t._s(t.message)+"\n\n "),n("br"),t._v(" "),n("button",{on:{click:t.reload}},[t._v("\n "+t._s(t.buttonText)+"\n ")])]):t._e()],{reload:t.reload,enabled:t.enabled,message:t.message,buttonText:t.buttonText})],2)}),[],!1,null,"fec8b358",null);e.default=p.exports}}]);
|
|
@ -0,0 +1 @@
|
|||
(window.webpackJsonp=window.webpackJsonp||[]).push([[50],{438:function(t,e,r){"use strict";r.r(e);var a=r(15),s=Object(a.a)({},(function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[r("h1",{attrs:{id:"elastic-技术栈"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#elastic-技术栈"}},[t._v("#")]),t._v(" Elastic 技术栈")]),t._v(" "),r("blockquote",[r("p",[r("strong",[t._v("Elastic 技术栈通常被用来作为日志中心。")])]),t._v(" "),r("p",[t._v("ELK 是 elastic 公司旗下三款产品 "),r("a",{attrs:{href:"https://www.elastic.co/products/elasticsearch",target:"_blank",rel:"noopener noreferrer"}},[t._v("ElasticSearch"),r("OutboundLink")],1),t._v(" 、"),r("a",{attrs:{href:"https://www.elastic.co/products/logstash",target:"_blank",rel:"noopener noreferrer"}},[t._v("Logstash"),r("OutboundLink")],1),t._v(" 、"),r("a",{attrs:{href:"https://www.elastic.co/products/kibana",target:"_blank",rel:"noopener noreferrer"}},[t._v("Kibana"),r("OutboundLink")],1),t._v(" 的首字母组合。")]),t._v(" "),r("p",[r("a",{attrs:{href:"https://www.elastic.co/products/elasticsearch",target:"_blank",rel:"noopener noreferrer"}},[t._v("ElasticSearch"),r("OutboundLink")],1),t._v(" 是一个基于 "),r("a",{attrs:{href:"http://lucene.apache.org/core/documentation.html",target:"_blank",rel:"noopener noreferrer"}},[t._v("Lucene"),r("OutboundLink")],1),t._v(" 构建的开源,分布式,RESTful 搜索引擎。")]),t._v(" "),r("p",[r("a",{attrs:{href:"https://www.elastic.co/products/logstash",target:"_blank",rel:"noopener noreferrer"}},[t._v("Logstash"),r("OutboundLink")],1),t._v(" 传输和处理你的日志、事务或其他数据。")]),t._v(" "),r("p",[r("a",{attrs:{href:"https://www.elastic.co/products/kibana",target:"_blank",rel:"noopener noreferrer"}},[t._v("Kibana"),r("OutboundLink")],1),t._v(" 将 Elasticsearch 的数据分析并渲染为可视化的报表。")]),t._v(" "),r("p",[t._v("Elastic 技术栈,在 ELK 的基础上扩展了一些新的产品,如:"),r("a",{attrs:{href:"https://www.elastic.co/products/beats",target:"_blank",rel:"noopener noreferrer"}},[t._v("Beats"),r("OutboundLink")],1),t._v(" 、"),r("a",{attrs:{href:"https://www.elastic.co/products/x-pack",target:"_blank",rel:"noopener noreferrer"}},[t._v("X-Pack"),r("OutboundLink")],1),t._v(" 。")])]),t._v(" "),r("h2",{attrs:{id:"目录"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#目录"}},[t._v("#")]),t._v(" 目录")]),t._v(" "),r("p",[r("RouterLink",{attrs:{to:"/linux/soft/elastic/elastic-quickstart.html"}},[t._v("Elastic 技术栈之入门指南")])],1),t._v(" "),r("p",[r("RouterLink",{attrs:{to:"/linux/soft/elastic/elastic-logstash.html"}},[t._v("Elastic 技术栈之 Logstash 基础")])],1),t._v(" "),r("h2",{attrs:{id:"资源"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#资源"}},[t._v("#")]),t._v(" 资源")]),t._v(" "),r("p",[r("strong",[t._v("官方资源")])]),t._v(" "),r("p",[r("a",{attrs:{href:"https://www.elastic.co/guide/index.html",target:"_blank",rel:"noopener noreferrer"}},[t._v("Elastic 官方文档"),r("OutboundLink")],1)]),t._v(" "),r("p",[r("strong",[t._v("第三方工具")])]),t._v(" "),r("p",[r("a",{attrs:{href:"https://github.com/logstash/logstash-logback-encoder",target:"_blank",rel:"noopener noreferrer"}},[t._v("logstash-logback-encoder"),r("OutboundLink")],1)]),t._v(" "),r("p",[r("strong",[t._v("教程")])]),t._v(" "),r("p",[r("a",{attrs:{href:"https://es.xiaoleilu.com/index.html",target:"_blank",rel:"noopener noreferrer"}},[t._v("Elasticsearch 权威指南(中文版)"),r("OutboundLink")],1)]),t._v(" "),r("p",[r("a",{attrs:{href:"https://github.com/chenryn/logstash-best-practice-cn",target:"_blank",rel:"noopener noreferrer"}},[t._v("ELK Stack权威指南"),r("OutboundLink")],1)]),t._v(" "),r("p",[r("strong",[t._v("博文")])]),t._v(" "),r("p",[r("a",{attrs:{href:"https://www.cnblogs.com/xing901022/p/4704319.html",target:"_blank",rel:"noopener noreferrer"}},[t._v("Elasticsearch+Logstash+Kibana教程"),r("OutboundLink")],1)]),t._v(" "),r("p",[r("a",{attrs:{href:"https://github.com/judasn/Linux-Tutorial/blob/master/ELK-Install-And-Settings.md",target:"_blank",rel:"noopener noreferrer"}},[t._v("ELK(Elasticsearch、Logstash、Kibana)安装和配置"),r("OutboundLink")],1)])])}),[],!1,null,null,null);e.default=s.exports}}]);
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
(window.webpackJsonp=window.webpackJsonp||[]).push([[6],{345:function(t,e,n){},376:function(t,e,n){"use strict";n(345)},458:function(t,e,n){"use strict";n.r(e);var i={functional:!0,props:{type:{type:String,default:"tip"},text:String,vertical:{type:String,default:"top"}},render:function(t,e){var n=e.props,i=e.slots;return t("span",{class:["badge",n.type],style:{verticalAlign:n.vertical}},n.text||i().default)}},r=(n(376),n(15)),p=Object(r.a)(i,void 0,void 0,!1,null,"15b7b770",null);e.default=p.exports}}]);
|
|
@ -0,0 +1 @@
|
|||
(window.webpackJsonp=window.webpackJsonp||[]).push([[60],{445:function(t,e,a){"use strict";a.r(e);var v=a(15),r=Object(v.a)({},(function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"maven-安装"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#maven-安装"}},[t._v("#")]),t._v(" Maven 安装")]),t._v(" "),a("blockquote",[a("p",[t._v("环境要求:")]),t._v(" "),a("ul",[a("li",[t._v("JDK")])])]),t._v(" "),a("ul",[a("li",[a("a",{attrs:{href:"#%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95"}},[t._v("安装方法")])]),t._v(" "),a("li",[a("a",{attrs:{href:"#%E8%84%9A%E6%9C%AC"}},[t._v("脚本")])])]),t._v(" "),a("h2",{attrs:{id:"安装方法"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#安装方法"}},[t._v("#")]),t._v(" 安装方法")]),t._v(" "),a("p",[t._v("安装步骤如下:")]),t._v(" "),a("p",[t._v("(1)下载")]),t._v(" "),a("p",[t._v("进入官网下载地址:https://maven.apache.org/download.cgi ,选择合适的版本下载。")]),t._v(" "),a("p",[t._v("我选择的是最新 Maven3 版本:http://mirrors.hust.edu.cn/apache/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz")]),t._v(" "),a("p",[t._v("(2)解压到本地")]),t._v(" "),a("p",[t._v("我个人喜欢存放在:"),a("code",[t._v("/opt/maven")])]),t._v(" "),a("p",[t._v("(3)设置环境变量")]),t._v(" "),a("p",[t._v("输入 "),a("code",[t._v("vi /etc/profile")]),t._v(" ,添加环境变量如下:")]),t._v(" "),a("div",{staticClass:"language- extra-class"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[t._v("# MAVEN 的根路径\nexport MAVEN_HOME=/opt/maven/apache-maven-3.5.2\nexport PATH=\\$MAVEN_HOME/bin:\\$PATH\n")])])]),a("p",[t._v("执行 "),a("code",[t._v("source /etc/profile")]),t._v(" ,立即生效")]),t._v(" "),a("p",[t._v("(4)检验是否安装成功,执行 "),a("code",[t._v("mvn -v")]),t._v(" 命令")]),t._v(" "),a("h2",{attrs:{id:"脚本"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#脚本"}},[t._v("#")]),t._v(" 脚本")]),t._v(" "),a("p",[t._v("以上两种安装方式,我都写了脚本去执行:")]),t._v(" "),a("p",[t._v("| "),a("a",{attrs:{href:"https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft",target:"_blank",rel:"noopener noreferrer"}},[t._v("安装脚本"),a("OutboundLink")],1),t._v(" |")])])}),[],!1,null,null,null);e.default=r.exports}}]);
|
|
@ -0,0 +1 @@
|
|||
(window.webpackJsonp=window.webpackJsonp||[]).push([[61],{446:function(t,a,o){"use strict";o.r(a);var n=o(15),s=Object(n.a)({},(function(){var t=this,a=t.$createElement,o=t._self._c||a;return o("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[o("h1",{attrs:{id:"mongodb-安装"}},[o("a",{staticClass:"header-anchor",attrs:{href:"#mongodb-安装"}},[t._v("#")]),t._v(" Mongodb 安装")]),t._v(" "),o("ul",[o("li",[o("a",{attrs:{href:"#%E5%AE%89%E8%A3%85"}},[t._v("安装")])]),t._v(" "),o("li",[o("a",{attrs:{href:"#%E5%90%AF%E5%8A%A8"}},[t._v("启动")])]),t._v(" "),o("li",[o("a",{attrs:{href:"#%E8%84%9A%E6%9C%AC"}},[t._v("脚本")])])]),t._v(" "),o("h2",{attrs:{id:"安装"}},[o("a",{staticClass:"header-anchor",attrs:{href:"#安装"}},[t._v("#")]),t._v(" 安装")]),t._v(" "),o("p",[t._v("安装步骤如下:")]),t._v(" "),o("p",[t._v("(1)下载并解压到本地")]),t._v(" "),o("p",[t._v("进入官网下载地址:https://www.mongodb.com/download-center#community ,选择合适的版本下载。")]),t._v(" "),o("p",[t._v("我选择的是最新稳定版本 3.6.3:https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.3.tgz")]),t._v(" "),o("p",[t._v("我个人喜欢存放在:"),o("code",[t._v("/opt/mongodb")])]),t._v(" "),o("div",{staticClass:"language- extra-class"},[o("pre",{pre:!0,attrs:{class:"language-text"}},[o("code",[t._v("wget -O /opt/mongodb/mongodb-linux-x86_64-3.6.3.tgz https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.3.tgz\ncd /opt/mongodb\ntar zxvf mongodb-linux-x86_64-3.6.3.tgz\nmv mongodb-linux-x86_64-3.6.3 mongodb-3.6.3\nmkdir -p /data/db\n")])])]),o("h2",{attrs:{id:"启动"}},[o("a",{staticClass:"header-anchor",attrs:{href:"#启动"}},[t._v("#")]),t._v(" 启动")]),t._v(" "),o("p",[o("strong",[t._v("启动 mongodb 服务")])]),t._v(" "),o("div",{staticClass:"language- extra-class"},[o("pre",{pre:!0,attrs:{class:"language-text"}},[o("code",[t._v("cd /opt/mongodb/mongodb-3.6.3/bin\n./mongod --dbpath=/data/db\n")])])]),o("p",[o("strong",[t._v("启动 mongodb 客户端")])]),t._v(" "),o("div",{staticClass:"language- extra-class"},[o("pre",{pre:!0,attrs:{class:"language-text"}},[o("code",[t._v("cd /opt/mongodb/mongodb-3.6.3/bin\n./mongo\n")])])]),o("h2",{attrs:{id:"脚本"}},[o("a",{staticClass:"header-anchor",attrs:{href:"#脚本"}},[t._v("#")]),t._v(" 脚本")]),t._v(" "),o("p",[t._v("| "),o("a",{attrs:{href:"https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft",target:"_blank",rel:"noopener noreferrer"}},[t._v("安装脚本"),o("OutboundLink")],1),t._v(" |")])])}),[],!1,null,null,null);a.default=s.exports}}]);
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
(window.webpackJsonp=window.webpackJsonp||[]).push([[64],{449:function(t,a,e){"use strict";e.r(a);var s=e(15),r=Object(s.a)({},(function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[e("h1",{attrs:{id:"nodejs-安装"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#nodejs-安装"}},[t._v("#")]),t._v(" Nodejs 安装")]),t._v(" "),e("ul",[e("li",[e("a",{attrs:{href:"#%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95"}},[t._v("安装方法")]),t._v(" "),e("ul",[e("li",[e("a",{attrs:{href:"#%E5%85%88%E5%AE%89%E8%A3%85-nvm"}},[t._v("先安装 nvm")])]),t._v(" "),e("li",[e("a",{attrs:{href:"#%E5%AE%89%E8%A3%85-nodejs"}},[t._v("安装 Nodejs")])])])]),t._v(" "),e("li",[e("a",{attrs:{href:"#%E8%84%9A%E6%9C%AC"}},[t._v("脚本")])])]),t._v(" "),e("h2",{attrs:{id:"安装方法"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#安装方法"}},[t._v("#")]),t._v(" 安装方法")]),t._v(" "),e("h3",{attrs:{id:"先安装-nvm"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#先安装-nvm"}},[t._v("#")]),t._v(" 先安装 nvm")]),t._v(" "),e("p",[t._v("推荐安装 nvm(Node Version Manager) ,来管理 node.js 版本。")]),t._v(" "),e("p",[t._v("安装步骤如下:")]),t._v(" "),e("p",[t._v("(1)执行安装脚本")]),t._v(" "),e("div",{staticClass:"language- extra-class"},[e("pre",{pre:!0,attrs:{class:"language-text"}},[e("code",[t._v("rm -rf ~/.nvm\ncurl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash\n. ~/.nvm/nvm.sh\n")])])]),e("p",[t._v("(2)检验是否安装成功")]),t._v(" "),e("p",[t._v("执行 "),e("code",[t._v("nvm --version")]),t._v(" 命令。")]),t._v(" "),e("p",[t._v("注意:如果出现 "),e("code",[t._v("nvm: command not found")]),t._v(" ,关闭终端,然后再打开终端试试。")]),t._v(" "),e("h3",{attrs:{id:"安装-nodejs"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#安装-nodejs"}},[t._v("#")]),t._v(" 安装 Nodejs")]),t._v(" "),e("p",[t._v("安装步骤如下:")]),t._v(" "),e("p",[t._v("(1)使用 nvm 安装 nodejs 指定版本")]),t._v(" "),e("p",[t._v("执行以下命令:")]),t._v(" "),e("div",{staticClass:"language- extra-class"},[e("pre",{pre:!0,attrs:{class:"language-text"}},[e("code",[t._v("nvm install 8.9.4\nnvm use 8.9.4\n")])])]),e("p",[t._v("(2)检验是否安装成功")]),t._v(" "),e("p",[t._v("执行 "),e("code",[t._v("node --version")]),t._v(" 命令。")]),t._v(" "),e("p",[t._v("注意:如果出现 "),e("code",[t._v("node: command not found")]),t._v(" ,关闭终端,然后再打开终端试试。")]),t._v(" "),e("h2",{attrs:{id:"脚本"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#脚本"}},[t._v("#")]),t._v(" 脚本")]),t._v(" "),e("p",[t._v("| "),e("a",{attrs:{href:"https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft",target:"_blank",rel:"noopener noreferrer"}},[t._v("安装脚本"),e("OutboundLink")],1),t._v(" |")]),t._v(" "),e("h2",{attrs:{id:"更多内容"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#更多内容"}},[t._v("#")]),t._v(" 更多内容")]),t._v(" "),e("ul",[e("li",[e("strong",[t._v("引申")]),t._v(" "),e("ul",[e("li",[e("a",{attrs:{href:"https://github.com/dunwu/OS",target:"_blank",rel:"noopener noreferrer"}},[t._v("操作系统、运维部署总结系列"),e("OutboundLink")],1)])])])])])}),[],!1,null,null,null);a.default=r.exports}}]);
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
(window.webpackJsonp=window.webpackJsonp||[]).push([[67],{452:function(t,a,r){"use strict";r.r(a);var e=r(15),s=Object(e.a)({},(function(){var t=this,a=t.$createElement,r=t._self._c||a;return r("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[r("h1",{attrs:{id:"tomcat-安装"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#tomcat-安装"}},[t._v("#")]),t._v(" Tomcat 安装")]),t._v(" "),r("ul",[r("li",[r("a",{attrs:{href:"#%E5%AE%89%E8%A3%85"}},[t._v("安装")])]),t._v(" "),r("li",[r("a",{attrs:{href:"#%E5%90%AF%E5%8A%A8"}},[t._v("启动")])]),t._v(" "),r("li",[r("a",{attrs:{href:"#%E8%84%9A%E6%9C%AC"}},[t._v("脚本")])])]),t._v(" "),r("h2",{attrs:{id:"安装"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#安装"}},[t._v("#")]),t._v(" 安装")]),t._v(" "),r("p",[t._v("安装步骤如下:")]),t._v(" "),r("p",[t._v("(1)下载并解压到本地")]),t._v(" "),r("p",[t._v("进入官网下载地址:https://tomcat.apache.org/download-80.cgi ,选择合适的版本下载。")]),t._v(" "),r("p",[t._v("我选择的是最新稳定版本 8.5.28:http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.28/bin/apache-tomcat-8.5.28.tar.gz")]),t._v(" "),r("p",[t._v("我个人喜欢存放在:"),r("code",[t._v("/opt/tomcat")])]),t._v(" "),r("div",{staticClass:"language- extra-class"},[r("pre",{pre:!0,attrs:{class:"language-text"}},[r("code",[t._v("wget -O /opt/tomcat/apache-tomcat-8.5.28.tar.gz http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.28/bin/apache-tomcat-8.5.28.tar.gz\ncd /opt/tomcat\ntar zxvf apache-tomcat-8.5.28.tar.gz\n")])])]),r("h2",{attrs:{id:"启动"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#启动"}},[t._v("#")]),t._v(" 启动")]),t._v(" "),r("p",[r("strong",[t._v("启动 tomcat 服务")])]),t._v(" "),r("div",{staticClass:"language- extra-class"},[r("pre",{pre:!0,attrs:{class:"language-text"}},[r("code",[t._v("cd /opt/tomcat/apache-tomcat-8.5.28/bin\n./catalina.sh start\n")])])]),r("p",[r("strong",[t._v("停止 tomcat 服务")])]),t._v(" "),r("div",{staticClass:"language- extra-class"},[r("pre",{pre:!0,attrs:{class:"language-text"}},[r("code",[t._v("cd /opt/tomcat/apache-tomcat-8.5.28/bin\n./catalina.sh stop\n")])])]),r("h2",{attrs:{id:"脚本"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#脚本"}},[t._v("#")]),t._v(" 脚本")]),t._v(" "),r("p",[t._v("| "),r("a",{attrs:{href:"https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft",target:"_blank",rel:"noopener noreferrer"}},[t._v("安装脚本"),r("OutboundLink")],1),t._v(" |")]),t._v(" "),r("h2",{attrs:{id:"更多内容"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#更多内容"}},[t._v("#")]),t._v(" 更多内容")]),t._v(" "),r("ul",[r("li",[r("strong",[t._v("引申")]),t._v(" "),r("ul",[r("li",[r("a",{attrs:{href:"https://github.com/dunwu/OS",target:"_blank",rel:"noopener noreferrer"}},[t._v("操作系统、运维部署总结系列"),r("OutboundLink")],1)])])])])])}),[],!1,null,null,null);a.default=s.exports}}]);
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
(window.webpackJsonp=window.webpackJsonp||[]).push([[7],{346:function(t,e,a){},377:function(t,e,a){"use strict";a(346)},396:function(t,e,a){"use strict";a.r(e);var n={name:"CodeBlock",props:{title:{type:String,required:!0},active:{type:Boolean,default:!1}},mounted:function(){this.$parent&&this.$parent.loadTabs&&this.$parent.loadTabs()}},i=(a(377),a(15)),s=Object(i.a)(n,(function(){var t=this.$createElement;return(this._self._c||t)("div",{staticClass:"theme-code-block",class:{"theme-code-block__active":this.active}},[this._t("default")],2)}),[],!1,null,"759a7d02",null);e.default=s.exports}}]);
|
|
@ -0,0 +1 @@
|
|||
(window.webpackJsonp=window.webpackJsonp||[]).push([[70],{391:function(n,e,t){"use strict";t.r(e),t.d(e,"register",(function(){return o})),t.d(e,"unregister",(function(){return c}));var r;function o(n,e){void 0===e&&(e={});var t=e.registrationOptions;void 0===t&&(t={}),delete e.registrationOptions;var o=function(n){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];e&&e[n]&&e[n].apply(e,t)};"serviceWorker"in navigator&&r.then((function(){Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/))?(!function(n,e,t){fetch(n).then((function(r){404===r.status?(e("error",new Error("Service worker not found at "+n)),c()):-1===r.headers.get("content-type").indexOf("javascript")?(e("error",new Error("Expected "+n+" to have javascript content-type, but received "+r.headers.get("content-type"))),c()):a(n,e,t)})).catch((function(n){return i(e,n)}))}(n,o,t),navigator.serviceWorker.ready.then((function(n){o("ready",n)})).catch((function(n){return i(o,n)}))):(a(n,o,t),navigator.serviceWorker.ready.then((function(n){o("ready",n)})).catch((function(n){return i(o,n)})))}))}function i(n,e){navigator.onLine||n("offline"),n("error",e)}function a(n,e,t){navigator.serviceWorker.register(n,t).then((function(n){e("registered",n),n.waiting?e("updated",n):n.onupdatefound=function(){e("updatefound",n);var t=n.installing;t.onstatechange=function(){"installed"===t.state&&(navigator.serviceWorker.controller?e("updated",n):e("cached",n))}}})).catch((function(n){return i(e,n)}))}function c(){"serviceWorker"in navigator&&navigator.serviceWorker.ready.then((function(n){n.unregister()})).catch((function(n){return i(emit,n)}))}"undefined"!=typeof window&&(r="undefined"!=typeof Promise?new Promise((function(n){return window.addEventListener("load",n)})):{then:function(n){return window.addEventListener("load",n)}})}}]);
|
|
@ -0,0 +1 @@
|
|||
(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{347:function(e,t,a){},378:function(e,t,a){"use strict";a(347)},397:function(e,t,a){"use strict";a.r(t);a(74),a(33),a(102),a(103);var o={name:"CodeGroup",data:function(){return{codeTabs:[],activeCodeTabIndex:-1}},watch:{activeCodeTabIndex:function(e){this.activateCodeTab(e)}},mounted:function(){this.loadTabs()},methods:{changeCodeTab:function(e){this.activeCodeTabIndex=e},loadTabs:function(){var e=this;this.codeTabs=(this.$slots.default||[]).filter((function(e){return Boolean(e.componentOptions)})).map((function(t,a){return""===t.componentOptions.propsData.active&&(e.activeCodeTabIndex=a),{title:t.componentOptions.propsData.title,elm:t.elm}})),-1===this.activeCodeTabIndex&&this.codeTabs.length>0&&(this.activeCodeTabIndex=0),this.activateCodeTab(0)},activateCodeTab:function(e){this.codeTabs.forEach((function(e){e.elm&&e.elm.classList.remove("theme-code-block__active")})),this.codeTabs[e].elm&&this.codeTabs[e].elm.classList.add("theme-code-block__active")}}},n=(a(378),a(15)),c=Object(n.a)(o,(function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("ClientOnly",[a("div",{staticClass:"theme-code-group"},[a("div",{staticClass:"theme-code-group__nav"},[a("ul",{staticClass:"theme-code-group__ul"},e._l(e.codeTabs,(function(t,o){return a("li",{key:t.title,staticClass:"theme-code-group__li"},[a("button",{staticClass:"theme-code-group__nav-tab",class:{"theme-code-group__nav-tab-active":o===e.activeCodeTabIndex},on:{click:function(t){return e.changeCodeTab(o)}}},[e._v("\n "+e._s(t.title)+"\n ")])])})),0)]),e._v(" "),e._t("default"),e._v(" "),e.codeTabs.length<1?a("pre",{staticClass:"pre-blank"},[e._v("// Make sure to add code blocks to your code group")]):e._e()],2)])}),[],!1,null,"deefee04",null);t.default=c.exports}}]);
|
|
@ -0,0 +1 @@
|
|||
(window.webpackJsonp=window.webpackJsonp||[]).push([[9],{395:function(t,e,s){"use strict";s.r(e);var n=["There's nothing here.","How did we get here?","That's a Four-Oh-Four.","Looks like we've got some broken links."],o={methods:{getMsg:function(){return n[Math.floor(Math.random()*n.length)]}}},i=s(15),h=Object(i.a)(o,(function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"theme-container"},[e("div",{staticClass:"theme-default-content"},[e("h1",[this._v("404")]),this._v(" "),e("blockquote",[this._v(this._s(this.getMsg()))]),this._v(" "),e("RouterLink",{attrs:{to:"/"}},[this._v("\n Take me home.\n ")])],1)])}),[],!1,null,null,null);e.default=h.exports}}]);
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Docker 安装 MySQL | LINUX-TUTORIAL</title>
|
||||
<meta name="generator" content="VuePress 1.8.2">
|
||||
<link rel="icon" href="/linux-tutorial/favicon.ico">
|
||||
<meta name="description" content="数据库教程">
|
||||
|
||||
<link rel="preload" href="/linux-tutorial/assets/css/0.styles.45d9d031.css" as="style"><link rel="preload" href="/linux-tutorial/assets/js/app.79a38eea.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/4.fb6e0f89.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/17.d43e9f56.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/5.cb43ecfb.js" as="script"><link rel="prefetch" href="/linux-tutorial/assets/js/10.7933187b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/11.b9b41530.js"><link rel="prefetch" href="/linux-tutorial/assets/js/12.70a5dba8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/13.857dcc43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/14.5a603a55.js"><link rel="prefetch" href="/linux-tutorial/assets/js/15.d217acb7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/16.ad565eae.js"><link rel="prefetch" href="/linux-tutorial/assets/js/18.aa00ff43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/19.43ce44b3.js"><link rel="prefetch" href="/linux-tutorial/assets/js/20.5618e1ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/21.1c5a41d7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/22.fbe9fdf1.js"><link rel="prefetch" href="/linux-tutorial/assets/js/23.a4fb0e74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/24.e3a23b69.js"><link rel="prefetch" href="/linux-tutorial/assets/js/25.9896afe9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/26.96164082.js"><link rel="prefetch" href="/linux-tutorial/assets/js/27.391033bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/28.703f74c2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/29.02a952cb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/30.7e13628f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/31.c4652f75.js"><link rel="prefetch" href="/linux-tutorial/assets/js/32.05d2cbec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/33.3b265df8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/34.26330a03.js"><link rel="prefetch" href="/linux-tutorial/assets/js/35.417d706d.js"><link rel="prefetch" href="/linux-tutorial/assets/js/36.0ed775e0.js"><link rel="prefetch" href="/linux-tutorial/assets/js/37.34430c74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/38.87d5e0ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/39.7b648b3e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/40.3b7a219e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/41.e727eee9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/42.0134c187.js"><link rel="prefetch" href="/linux-tutorial/assets/js/43.175e982f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/44.72d90888.js"><link rel="prefetch" href="/linux-tutorial/assets/js/45.d49955bd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/46.a9c290ec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/47.cc639f04.js"><link rel="prefetch" href="/linux-tutorial/assets/js/48.98c78321.js"><link rel="prefetch" href="/linux-tutorial/assets/js/49.a7c3afed.js"><link rel="prefetch" href="/linux-tutorial/assets/js/50.22d8c542.js"><link rel="prefetch" href="/linux-tutorial/assets/js/51.28055fcd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/52.f8103df5.js"><link rel="prefetch" href="/linux-tutorial/assets/js/53.76541550.js"><link rel="prefetch" href="/linux-tutorial/assets/js/54.e78d2776.js"><link rel="prefetch" href="/linux-tutorial/assets/js/55.3ce3079c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/56.832958c9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/57.961ce896.js"><link rel="prefetch" href="/linux-tutorial/assets/js/58.6d6fbc82.js"><link rel="prefetch" href="/linux-tutorial/assets/js/59.d5e48112.js"><link rel="prefetch" href="/linux-tutorial/assets/js/6.c8f4721c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/60.7927b23b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/61.ee233f24.js"><link rel="prefetch" href="/linux-tutorial/assets/js/62.6ba50cc7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/63.9cbf9f2b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/64.0be148a4.js"><link rel="prefetch" href="/linux-tutorial/assets/js/65.c520257e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/66.f2335390.js"><link rel="prefetch" href="/linux-tutorial/assets/js/67.e5737218.js"><link rel="prefetch" href="/linux-tutorial/assets/js/68.46427a01.js"><link rel="prefetch" href="/linux-tutorial/assets/js/69.450417bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/7.046e5a1b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/70.072034d2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/8.77fb8967.js"><link rel="prefetch" href="/linux-tutorial/assets/js/9.ebfa537e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~flowchart.20a64d45.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~notification.ea176280.js">
|
||||
<link rel="stylesheet" href="/linux-tutorial/assets/css/0.styles.45d9d031.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/linux-tutorial/" class="home-link router-link-active"><img src="images/dunwu-logo-100.png" alt="LINUX-TUTORIAL" class="logo"> <span class="site-name can-hide">LINUX-TUTORIAL</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link router-link-active">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link router-link-active">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Docker 安装 MySQL</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/linux-tutorial/docker/service/docker-install-mysql.html#查看可下载镜像" class="sidebar-link">查看可下载镜像</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/linux-tutorial/docker/service/docker-install-mysql.html#选择下载官方镜像" class="sidebar-link">选择下载官方镜像</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/linux-tutorial/docker/service/docker-install-mysql.html#使用镜像" class="sidebar-link">使用镜像</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/linux-tutorial/docker/service/docker-install-mysql.html#资源" class="sidebar-link">资源</a><ul class="sidebar-sub-headers"></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="docker-安装-mysql"><a href="#docker-安装-mysql" class="header-anchor">#</a> Docker 安装 MySQL</h1> <blockquote><p>实测环境:Centos</p></blockquote> <h2 id="查看可下载镜像"><a href="#查看可下载镜像" class="header-anchor">#</a> 查看可下载镜像</h2> <div class="language-docker extra-class"><pre class="language-docker"><code><span class="token comment"># docker search mysql</span>
|
||||
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
|
||||
docker.io docker.io/mysql MySQL is a widely used<span class="token punctuation">,</span> open<span class="token punctuation">-</span>source relati<span class="token punctuation">...</span> 5757 <span class="token punctuation">[</span>OK<span class="token punctuation">]</span>
|
||||
docker.io docker.io/mariadb MariaDB is a community<span class="token punctuation">-</span>developed fork of M<span class="token punctuation">...</span> 1863 <span class="token punctuation">[</span>OK<span class="token punctuation">]</span>
|
||||
docker.io docker.io/mysql/mysql<span class="token punctuation">-</span>server Optimized MySQL Server Docker images. Crea<span class="token punctuation">...</span> 397 <span class="token punctuation">[</span>OK<span class="token punctuation">]</span>
|
||||
<span class="token punctuation">...</span>
|
||||
</code></pre></div><h2 id="选择下载官方镜像"><a href="#选择下载官方镜像" class="header-anchor">#</a> 选择下载官方镜像</h2> <p>比如,我想下载最新版本,则执行如下命令:</p> <div class="language-docker extra-class"><pre class="language-docker"><code>docker pull mysql
|
||||
</code></pre></div><h2 id="使用镜像"><a href="#使用镜像" class="header-anchor">#</a> 使用镜像</h2> <div class="language-docker extra-class"><pre class="language-docker"><code>docker run <span class="token punctuation">-</span>p 3306<span class="token punctuation">:</span>3306 <span class="token punctuation">-</span><span class="token punctuation">-</span>name mysql <span class="token punctuation">-</span>v /opt/docker_v/mysql/conf<span class="token punctuation">:</span>/etc/mysql/conf.d <span class="token punctuation">-</span>e MYSQL_ROOT_PASSWORD=123456 <span class="token punctuation">-</span>d mysql
|
||||
</code></pre></div><h2 id="资源"><a href="#资源" class="header-anchor">#</a> 资源</h2> <ul><li>https://hub.docker.com/_/mysql/</li></ul></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/dunwu/linux-tutorial/edit/master/docs/docker/service/docker-install-mysql.md" target="_blank" rel="noopener noreferrer">帮助我们改善此页面!</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">a year ago</span></div></footer> <!----> </main></div><div class="global-ui"><!----><!----></div></div>
|
||||
<script src="/linux-tutorial/assets/js/app.79a38eea.js" defer></script><script src="/linux-tutorial/assets/js/4.fb6e0f89.js" defer></script><script src="/linux-tutorial/assets/js/17.d43e9f56.js" defer></script><script src="/linux-tutorial/assets/js/5.cb43ecfb.js" defer></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Docker 安装 Nginx | LINUX-TUTORIAL</title>
|
||||
<meta name="generator" content="VuePress 1.8.2">
|
||||
<link rel="icon" href="/linux-tutorial/favicon.ico">
|
||||
<meta name="description" content="数据库教程">
|
||||
|
||||
<link rel="preload" href="/linux-tutorial/assets/css/0.styles.45d9d031.css" as="style"><link rel="preload" href="/linux-tutorial/assets/js/app.79a38eea.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/4.fb6e0f89.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/18.aa00ff43.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/5.cb43ecfb.js" as="script"><link rel="prefetch" href="/linux-tutorial/assets/js/10.7933187b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/11.b9b41530.js"><link rel="prefetch" href="/linux-tutorial/assets/js/12.70a5dba8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/13.857dcc43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/14.5a603a55.js"><link rel="prefetch" href="/linux-tutorial/assets/js/15.d217acb7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/16.ad565eae.js"><link rel="prefetch" href="/linux-tutorial/assets/js/17.d43e9f56.js"><link rel="prefetch" href="/linux-tutorial/assets/js/19.43ce44b3.js"><link rel="prefetch" href="/linux-tutorial/assets/js/20.5618e1ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/21.1c5a41d7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/22.fbe9fdf1.js"><link rel="prefetch" href="/linux-tutorial/assets/js/23.a4fb0e74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/24.e3a23b69.js"><link rel="prefetch" href="/linux-tutorial/assets/js/25.9896afe9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/26.96164082.js"><link rel="prefetch" href="/linux-tutorial/assets/js/27.391033bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/28.703f74c2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/29.02a952cb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/30.7e13628f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/31.c4652f75.js"><link rel="prefetch" href="/linux-tutorial/assets/js/32.05d2cbec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/33.3b265df8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/34.26330a03.js"><link rel="prefetch" href="/linux-tutorial/assets/js/35.417d706d.js"><link rel="prefetch" href="/linux-tutorial/assets/js/36.0ed775e0.js"><link rel="prefetch" href="/linux-tutorial/assets/js/37.34430c74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/38.87d5e0ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/39.7b648b3e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/40.3b7a219e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/41.e727eee9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/42.0134c187.js"><link rel="prefetch" href="/linux-tutorial/assets/js/43.175e982f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/44.72d90888.js"><link rel="prefetch" href="/linux-tutorial/assets/js/45.d49955bd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/46.a9c290ec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/47.cc639f04.js"><link rel="prefetch" href="/linux-tutorial/assets/js/48.98c78321.js"><link rel="prefetch" href="/linux-tutorial/assets/js/49.a7c3afed.js"><link rel="prefetch" href="/linux-tutorial/assets/js/50.22d8c542.js"><link rel="prefetch" href="/linux-tutorial/assets/js/51.28055fcd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/52.f8103df5.js"><link rel="prefetch" href="/linux-tutorial/assets/js/53.76541550.js"><link rel="prefetch" href="/linux-tutorial/assets/js/54.e78d2776.js"><link rel="prefetch" href="/linux-tutorial/assets/js/55.3ce3079c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/56.832958c9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/57.961ce896.js"><link rel="prefetch" href="/linux-tutorial/assets/js/58.6d6fbc82.js"><link rel="prefetch" href="/linux-tutorial/assets/js/59.d5e48112.js"><link rel="prefetch" href="/linux-tutorial/assets/js/6.c8f4721c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/60.7927b23b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/61.ee233f24.js"><link rel="prefetch" href="/linux-tutorial/assets/js/62.6ba50cc7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/63.9cbf9f2b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/64.0be148a4.js"><link rel="prefetch" href="/linux-tutorial/assets/js/65.c520257e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/66.f2335390.js"><link rel="prefetch" href="/linux-tutorial/assets/js/67.e5737218.js"><link rel="prefetch" href="/linux-tutorial/assets/js/68.46427a01.js"><link rel="prefetch" href="/linux-tutorial/assets/js/69.450417bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/7.046e5a1b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/70.072034d2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/8.77fb8967.js"><link rel="prefetch" href="/linux-tutorial/assets/js/9.ebfa537e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~flowchart.20a64d45.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~notification.ea176280.js">
|
||||
<link rel="stylesheet" href="/linux-tutorial/assets/css/0.styles.45d9d031.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/linux-tutorial/" class="home-link router-link-active"><img src="images/dunwu-logo-100.png" alt="LINUX-TUTORIAL" class="logo"> <span class="site-name can-hide">LINUX-TUTORIAL</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link router-link-active">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link router-link-active">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Docker 安装 Nginx</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/linux-tutorial/docker/service/docker-install-nginx.html#查看可用镜像" class="sidebar-link">查看可用镜像</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/linux-tutorial/docker/service/docker-install-nginx.html#选择下载镜像" class="sidebar-link">选择下载镜像</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/linux-tutorial/docker/service/docker-install-nginx.html#运行镜像" class="sidebar-link">运行镜像</a><ul class="sidebar-sub-headers"></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="docker-安装-nginx"><a href="#docker-安装-nginx" class="header-anchor">#</a> Docker 安装 Nginx</h1> <blockquote><p>实测环境:Centos</p></blockquote> <h2 id="查看可用镜像"><a href="#查看可用镜像" class="header-anchor">#</a> 查看可用镜像</h2> <p>执行 <code>docker search nginx</code> 命令查看可用镜像:</p> <div class="language-docker extra-class"><pre class="language-docker"><code><span class="token comment"># docker search nginx</span>
|
||||
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
|
||||
docker.io docker.io/nginx Official build of Nginx. 8272 <span class="token punctuation">[</span>OK<span class="token punctuation">]</span>
|
||||
docker.io docker.io/jwilder/nginx<span class="token punctuation">-</span>proxy Automated Nginx reverse proxy for docker c<span class="token punctuation">...</span> 1300 <span class="token punctuation">[</span>OK<span class="token punctuation">]</span>
|
||||
docker.io docker.io/richarvey/nginx<span class="token punctuation">-</span>php<span class="token punctuation">-</span>fpm Container running Nginx + PHP<span class="token punctuation">-</span>FPM capable <span class="token punctuation">...</span> 540 <span class="token punctuation">[</span>OK<span class="token punctuation">]</span>
|
||||
docker.io docker.io/jrcs/letsencrypt<span class="token punctuation">-</span>nginx<span class="token punctuation">-</span>proxy<span class="token punctuation">-</span>companion LetsEncrypt container to use with nginx as<span class="token punctuation">...</span> 336 <span class="token punctuation">[</span>OK<span class="token punctuation">]</span>
|
||||
<span class="token punctuation">...</span>
|
||||
</code></pre></div><h2 id="选择下载镜像"><a href="#选择下载镜像" class="header-anchor">#</a> 选择下载镜像</h2> <p>执行 <code>docker pull nginx</code> 命令下载镜像</p> <h2 id="运行镜像"><a href="#运行镜像" class="header-anchor">#</a> 运行镜像</h2> <div class="language- extra-class"><pre class="language-text"><code>docker run -p 80:80 --name mynginx -d nginx
|
||||
</code></pre></div></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/dunwu/linux-tutorial/edit/master/docs/docker/service/docker-install-nginx.md" target="_blank" rel="noopener noreferrer">帮助我们改善此页面!</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">a year ago</span></div></footer> <!----> </main></div><div class="global-ui"><!----><!----></div></div>
|
||||
<script src="/linux-tutorial/assets/js/app.79a38eea.js" defer></script><script src="/linux-tutorial/assets/js/4.fb6e0f89.js" defer></script><script src="/linux-tutorial/assets/js/18.aa00ff43.js" defer></script><script src="/linux-tutorial/assets/js/5.cb43ecfb.js" defer></script>
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,115 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>free | LINUX-TUTORIAL</title>
|
||||
<meta name="generator" content="VuePress 1.8.2">
|
||||
<link rel="icon" href="/linux-tutorial/favicon.ico">
|
||||
<meta name="description" content="数据库教程">
|
||||
|
||||
<link rel="preload" href="/linux-tutorial/assets/css/0.styles.45d9d031.css" as="style"><link rel="preload" href="/linux-tutorial/assets/js/app.79a38eea.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/4.fb6e0f89.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/20.5618e1ff.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/5.cb43ecfb.js" as="script"><link rel="prefetch" href="/linux-tutorial/assets/js/10.7933187b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/11.b9b41530.js"><link rel="prefetch" href="/linux-tutorial/assets/js/12.70a5dba8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/13.857dcc43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/14.5a603a55.js"><link rel="prefetch" href="/linux-tutorial/assets/js/15.d217acb7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/16.ad565eae.js"><link rel="prefetch" href="/linux-tutorial/assets/js/17.d43e9f56.js"><link rel="prefetch" href="/linux-tutorial/assets/js/18.aa00ff43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/19.43ce44b3.js"><link rel="prefetch" href="/linux-tutorial/assets/js/21.1c5a41d7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/22.fbe9fdf1.js"><link rel="prefetch" href="/linux-tutorial/assets/js/23.a4fb0e74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/24.e3a23b69.js"><link rel="prefetch" href="/linux-tutorial/assets/js/25.9896afe9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/26.96164082.js"><link rel="prefetch" href="/linux-tutorial/assets/js/27.391033bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/28.703f74c2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/29.02a952cb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/30.7e13628f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/31.c4652f75.js"><link rel="prefetch" href="/linux-tutorial/assets/js/32.05d2cbec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/33.3b265df8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/34.26330a03.js"><link rel="prefetch" href="/linux-tutorial/assets/js/35.417d706d.js"><link rel="prefetch" href="/linux-tutorial/assets/js/36.0ed775e0.js"><link rel="prefetch" href="/linux-tutorial/assets/js/37.34430c74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/38.87d5e0ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/39.7b648b3e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/40.3b7a219e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/41.e727eee9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/42.0134c187.js"><link rel="prefetch" href="/linux-tutorial/assets/js/43.175e982f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/44.72d90888.js"><link rel="prefetch" href="/linux-tutorial/assets/js/45.d49955bd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/46.a9c290ec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/47.cc639f04.js"><link rel="prefetch" href="/linux-tutorial/assets/js/48.98c78321.js"><link rel="prefetch" href="/linux-tutorial/assets/js/49.a7c3afed.js"><link rel="prefetch" href="/linux-tutorial/assets/js/50.22d8c542.js"><link rel="prefetch" href="/linux-tutorial/assets/js/51.28055fcd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/52.f8103df5.js"><link rel="prefetch" href="/linux-tutorial/assets/js/53.76541550.js"><link rel="prefetch" href="/linux-tutorial/assets/js/54.e78d2776.js"><link rel="prefetch" href="/linux-tutorial/assets/js/55.3ce3079c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/56.832958c9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/57.961ce896.js"><link rel="prefetch" href="/linux-tutorial/assets/js/58.6d6fbc82.js"><link rel="prefetch" href="/linux-tutorial/assets/js/59.d5e48112.js"><link rel="prefetch" href="/linux-tutorial/assets/js/6.c8f4721c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/60.7927b23b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/61.ee233f24.js"><link rel="prefetch" href="/linux-tutorial/assets/js/62.6ba50cc7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/63.9cbf9f2b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/64.0be148a4.js"><link rel="prefetch" href="/linux-tutorial/assets/js/65.c520257e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/66.f2335390.js"><link rel="prefetch" href="/linux-tutorial/assets/js/67.e5737218.js"><link rel="prefetch" href="/linux-tutorial/assets/js/68.46427a01.js"><link rel="prefetch" href="/linux-tutorial/assets/js/69.450417bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/7.046e5a1b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/70.072034d2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/8.77fb8967.js"><link rel="prefetch" href="/linux-tutorial/assets/js/9.ebfa537e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~flowchart.20a64d45.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~notification.ea176280.js">
|
||||
<link rel="stylesheet" href="/linux-tutorial/assets/css/0.styles.45d9d031.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/linux-tutorial/" class="home-link router-link-active"><img src="images/dunwu-logo-100.png" alt="LINUX-TUTORIAL" class="logo"> <span class="site-name can-hide">LINUX-TUTORIAL</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link router-link-active">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link router-link-active">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>free</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/linux-tutorial/linux/cli/free.html#补充说明" class="sidebar-link">补充说明</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/free.html#语法" class="sidebar-link">语法</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/free.html#选项" class="sidebar-link">选项</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/free.html#实例" class="sidebar-link">实例</a></li></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="free"><a href="#free" class="header-anchor">#</a> free</h1> <p>显示内存的使用情况</p> <h2 id="补充说明"><a href="#补充说明" class="header-anchor">#</a> 补充说明</h2> <p><strong>free 命令</strong> 可以显示当前系统未使用的和已使用的内存数目,还可以显示被内核使用的内存缓冲区。</p> <h3 id="语法"><a href="#语法" class="header-anchor">#</a> 语法</h3> <div class="language-shell extra-class"><pre class="language-shell"><code>free<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
</code></pre></div><h3 id="选项"><a href="#选项" class="header-anchor">#</a> 选项</h3> <div class="language-shell extra-class"><pre class="language-shell"><code>-b <span class="token comment"># 以Byte为单位显示内存使用情况;</span>
|
||||
-k <span class="token comment"># 以KB为单位显示内存使用情况;</span>
|
||||
-m <span class="token comment"># 以MB为单位显示内存使用情况;</span>
|
||||
-g <span class="token comment"># 以GB为单位显示内存使用情况。</span>
|
||||
-o <span class="token comment"># 不显示缓冲区调节列;</span>
|
||||
-s<span class="token operator"><</span>间隔秒数<span class="token operator">></span> <span class="token comment"># 持续观察内存使用状况;</span>
|
||||
-t <span class="token comment"># 显示内存总和列;</span>
|
||||
-V <span class="token comment"># 显示版本信息。</span>
|
||||
</code></pre></div><h3 id="实例"><a href="#实例" class="header-anchor">#</a> 实例</h3> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">free</span> -t <span class="token comment"># 以总和的形式显示内存的使用信息</span>
|
||||
<span class="token function">free</span> -s <span class="token number">10</span> <span class="token comment"># 周期性的查询内存使用信息,每10s 执行一次命令</span>
|
||||
</code></pre></div><p>显示内存使用情况</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">free</span> -m
|
||||
total used <span class="token function">free</span> shared buffers cached
|
||||
Mem: <span class="token number">2016</span> <span class="token number">1973</span> <span class="token number">42</span> <span class="token number">0</span> <span class="token number">163</span> <span class="token number">1497</span>
|
||||
-/+ buffers/cache: <span class="token number">312</span> <span class="token number">1703</span>
|
||||
Swap: <span class="token number">4094</span> <span class="token number">0</span> <span class="token number">4094</span>
|
||||
</code></pre></div><p><strong>第一部分 Mem 行解释:</strong></p> <div class="language-shell extra-class"><pre class="language-shell"><code>total:内存总数;
|
||||
used:已经使用的内存数;
|
||||
free:空闲的内存数;
|
||||
shared:当前已经废弃不用;
|
||||
buffers Buffer:缓存内存数;
|
||||
cached Page:缓存内存数。
|
||||
</code></pre></div><p>关系:total = used + free</p> <p><strong>第二部分(-/+ buffers/cache)解释:</strong></p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token punctuation">(</span>-buffers/cache<span class="token punctuation">)</span> used内存数:第一部分Mem行中的 used – buffers – cached
|
||||
<span class="token punctuation">(</span>+buffers/cache<span class="token punctuation">)</span> free内存数: 第一部分Mem行中的 <span class="token function">free</span> + buffers + cached
|
||||
</code></pre></div><p>可见-buffers/cache 反映的是被程序实实在在吃掉的内存,而+buffers/cache 反映的是可以挪用的内存总数。</p> <p>第三部分是指交换分区。</p> <p>输出结果的第四行是交换分区 SWAP 的,也就是我们通常所说的虚拟内存。
|
||||
区别:第二行(mem)的 used/free 与第三行(-/+ buffers/cache) used/free 的区别。 这两个的区别在于使用的角度来看,第一行是从 OS 的角度来看,因为对于 OS,buffers/cached 都是属于被使用,所以他的可用内存是 2098428KB,已用内存是 30841684KB,其中包括,内核(OS)使用+Application(X, oracle,etc)使用的+buffers+cached.</p> <p>第三行所指的是从应用程序角度来看,对于应用程序来说,buffers/cached 是等于可用的,因为 buffer/cached 是为了提高文件读取的性能,当应用程序需在用到内存的时候,buffer/cached 会很快地被回收。</p> <p>所以从应用程序的角度来说,可用内存=系统 free memory+buffers+cached。
|
||||
如本机情况的可用内存为:</p> <p>18007156=2098428KB+4545340KB+11363424KB</p> <p>接下来解释什么时候内存会被交换,以及按什么方交换。</p> <p>当可用内存少于额定值的时候,就会开会进行交换。如何看额定值:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">cat</span> /proc/meminfo
|
||||
|
||||
MemTotal: <span class="token number">16140816</span> kB
|
||||
MemFree: <span class="token number">816004</span> kB
|
||||
MemAvailable: <span class="token number">2913824</span> kB
|
||||
Buffers: <span class="token number">17912</span> kB
|
||||
Cached: <span class="token number">2239076</span> kB
|
||||
SwapCached: <span class="token number">0</span> kB
|
||||
Active: <span class="token number">12774804</span> kB
|
||||
Inactive: <span class="token number">1594328</span> kB
|
||||
Active<span class="token punctuation">(</span>anon<span class="token punctuation">)</span>: <span class="token number">12085544</span> kB
|
||||
Inactive<span class="token punctuation">(</span>anon<span class="token punctuation">)</span>: <span class="token number">94572</span> kB
|
||||
Active<span class="token punctuation">(</span>file<span class="token punctuation">)</span>: <span class="token number">689260</span> kB
|
||||
Inactive<span class="token punctuation">(</span>file<span class="token punctuation">)</span>: <span class="token number">1499756</span> kB
|
||||
Unevictable: <span class="token number">116888</span> kB
|
||||
Mlocked: <span class="token number">116888</span> kB
|
||||
SwapTotal: <span class="token number">8191996</span> kB
|
||||
SwapFree: <span class="token number">8191996</span> kB
|
||||
Dirty: <span class="token number">56</span> kB
|
||||
Writeback: <span class="token number">0</span> kB
|
||||
AnonPages: <span class="token number">12229228</span> kB
|
||||
Mapped: <span class="token number">117136</span> kB
|
||||
Shmem: <span class="token number">58736</span> kB
|
||||
Slab: <span class="token number">395568</span> kB
|
||||
SReclaimable: <span class="token number">246700</span> kB
|
||||
SUnreclaim: <span class="token number">148868</span> kB
|
||||
KernelStack: <span class="token number">30496</span> kB
|
||||
PageTables: <span class="token number">165104</span> kB
|
||||
NFS_Unstable: <span class="token number">0</span> kB
|
||||
Bounce: <span class="token number">0</span> kB
|
||||
WritebackTmp: <span class="token number">0</span> kB
|
||||
CommitLimit: <span class="token number">16262404</span> kB
|
||||
Committed_AS: <span class="token number">27698600</span> kB
|
||||
VmallocTotal: <span class="token number">34359738367</span> kB
|
||||
VmallocUsed: <span class="token number">311072</span> kB
|
||||
VmallocChunk: <span class="token number">34350899200</span> kB
|
||||
HardwareCorrupted: <span class="token number">0</span> kB
|
||||
AnonHugePages: <span class="token number">3104768</span> kB
|
||||
HugePages_Total: <span class="token number">0</span>
|
||||
HugePages_Free: <span class="token number">0</span>
|
||||
HugePages_Rsvd: <span class="token number">0</span>
|
||||
HugePages_Surp: <span class="token number">0</span>
|
||||
Hugepagesize: <span class="token number">2048</span> kB
|
||||
DirectMap4k: <span class="token number">225536</span> kB
|
||||
DirectMap2M: <span class="token number">13279232</span> kB
|
||||
DirectMap1G: <span class="token number">5242880</span> kB
|
||||
</code></pre></div><p>交换将通过三个途径来减少系统中使用的物理页面的个数:</p> <ol><li>减少缓冲与页面 cache 的大小,</li> <li>将系统 V 类型的内存页面交换出去,</li> <li>换出或者丢弃页面。(Application 占用的内存页,也就是物理内存不足)。</li></ol> <p>事实上,少量地使用 swap 是不是影响到系统性能的。</p> <p>那 buffers 和 cached 都是缓存,两者有什么区别呢?</p> <p>为了提高磁盘存取效率, Linux 做了一些精心的设计, 除了对 dentry 进行缓存(用于 VFS,加速文件路径名到 inode 的转换), 还采取了两种主要 Cache 方式:</p> <p>Buffer Cache 和 Page Cache。前者针对磁盘块的读写,后者针对文件 inode 的读写。这些 Cache 有效缩短了 I/O 系统调用(比如 read,write,getdents)的时间。
|
||||
磁盘的操作有逻辑级(文件系统)和物理级(磁盘块),这两种 Cache 就是分别缓存逻辑和物理级数据的。</p> <p>Page cache 实际上是针对文件系统的,是文件的缓存,在文件层面上的数据会缓存到 page cache。文件的逻辑层需要映射到实际的物理磁盘,这种映射关系由文件系统来完成。当 page cache 的数据需要刷新时,page cache 中的数据交给 buffer cache,因为 Buffer Cache 就是缓存磁盘块的。但是这种处理在 2.6 版本的内核之后就变的很简单了,没有真正意义上的 cache 操作。</p> <p>Buffer cache 是针对磁盘块的缓存,也就是在没有文件系统的情况下,直接对磁盘进行操作的数据会缓存到 buffer cache 中,例如,文件系统的元数据都会缓存到 buffer cache 中。</p> <p>简单说来,page cache 用来缓存文件数据,buffer cache 用来缓存磁盘数据。在有文件系统的情况下,对文件操作,那么数据会缓存到 page cache,如果直接采用 dd 等工具对磁盘进行读写,那么数据会缓存到 buffer cache。</p> <p>所以我们看 linux,只要不用 swap 的交换空间,就不用担心自己的内存太少.如果常常 swap 用很多,可能你就要考虑加物理内存了.这也是 linux 看内存是否够用的标准.</p> <p>如果是应用服务器的话,一般只看第二行,+buffers/cache,即对应用程序来说 free 的内存太少了,也是该考虑优化程序或加内存了。</p></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/dunwu/linux-tutorial/edit/master/docs/linux/cli/free.md" target="_blank" rel="noopener noreferrer">帮助我们改善此页面!</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">a year ago</span></div></footer> <!----> </main></div><div class="global-ui"><!----><!----></div></div>
|
||||
<script src="/linux-tutorial/assets/js/app.79a38eea.js" defer></script><script src="/linux-tutorial/assets/js/4.fb6e0f89.js" defer></script><script src="/linux-tutorial/assets/js/20.5618e1ff.js" defer></script><script src="/linux-tutorial/assets/js/5.cb43ecfb.js" defer></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,176 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>grep | LINUX-TUTORIAL</title>
|
||||
<meta name="generator" content="VuePress 1.8.2">
|
||||
<link rel="icon" href="/linux-tutorial/favicon.ico">
|
||||
<meta name="description" content="数据库教程">
|
||||
|
||||
<link rel="preload" href="/linux-tutorial/assets/css/0.styles.45d9d031.css" as="style"><link rel="preload" href="/linux-tutorial/assets/js/app.79a38eea.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/4.fb6e0f89.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/21.1c5a41d7.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/5.cb43ecfb.js" as="script"><link rel="prefetch" href="/linux-tutorial/assets/js/10.7933187b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/11.b9b41530.js"><link rel="prefetch" href="/linux-tutorial/assets/js/12.70a5dba8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/13.857dcc43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/14.5a603a55.js"><link rel="prefetch" href="/linux-tutorial/assets/js/15.d217acb7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/16.ad565eae.js"><link rel="prefetch" href="/linux-tutorial/assets/js/17.d43e9f56.js"><link rel="prefetch" href="/linux-tutorial/assets/js/18.aa00ff43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/19.43ce44b3.js"><link rel="prefetch" href="/linux-tutorial/assets/js/20.5618e1ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/22.fbe9fdf1.js"><link rel="prefetch" href="/linux-tutorial/assets/js/23.a4fb0e74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/24.e3a23b69.js"><link rel="prefetch" href="/linux-tutorial/assets/js/25.9896afe9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/26.96164082.js"><link rel="prefetch" href="/linux-tutorial/assets/js/27.391033bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/28.703f74c2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/29.02a952cb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/30.7e13628f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/31.c4652f75.js"><link rel="prefetch" href="/linux-tutorial/assets/js/32.05d2cbec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/33.3b265df8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/34.26330a03.js"><link rel="prefetch" href="/linux-tutorial/assets/js/35.417d706d.js"><link rel="prefetch" href="/linux-tutorial/assets/js/36.0ed775e0.js"><link rel="prefetch" href="/linux-tutorial/assets/js/37.34430c74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/38.87d5e0ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/39.7b648b3e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/40.3b7a219e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/41.e727eee9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/42.0134c187.js"><link rel="prefetch" href="/linux-tutorial/assets/js/43.175e982f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/44.72d90888.js"><link rel="prefetch" href="/linux-tutorial/assets/js/45.d49955bd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/46.a9c290ec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/47.cc639f04.js"><link rel="prefetch" href="/linux-tutorial/assets/js/48.98c78321.js"><link rel="prefetch" href="/linux-tutorial/assets/js/49.a7c3afed.js"><link rel="prefetch" href="/linux-tutorial/assets/js/50.22d8c542.js"><link rel="prefetch" href="/linux-tutorial/assets/js/51.28055fcd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/52.f8103df5.js"><link rel="prefetch" href="/linux-tutorial/assets/js/53.76541550.js"><link rel="prefetch" href="/linux-tutorial/assets/js/54.e78d2776.js"><link rel="prefetch" href="/linux-tutorial/assets/js/55.3ce3079c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/56.832958c9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/57.961ce896.js"><link rel="prefetch" href="/linux-tutorial/assets/js/58.6d6fbc82.js"><link rel="prefetch" href="/linux-tutorial/assets/js/59.d5e48112.js"><link rel="prefetch" href="/linux-tutorial/assets/js/6.c8f4721c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/60.7927b23b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/61.ee233f24.js"><link rel="prefetch" href="/linux-tutorial/assets/js/62.6ba50cc7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/63.9cbf9f2b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/64.0be148a4.js"><link rel="prefetch" href="/linux-tutorial/assets/js/65.c520257e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/66.f2335390.js"><link rel="prefetch" href="/linux-tutorial/assets/js/67.e5737218.js"><link rel="prefetch" href="/linux-tutorial/assets/js/68.46427a01.js"><link rel="prefetch" href="/linux-tutorial/assets/js/69.450417bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/7.046e5a1b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/70.072034d2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/8.77fb8967.js"><link rel="prefetch" href="/linux-tutorial/assets/js/9.ebfa537e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~flowchart.20a64d45.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~notification.ea176280.js">
|
||||
<link rel="stylesheet" href="/linux-tutorial/assets/css/0.styles.45d9d031.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/linux-tutorial/" class="home-link router-link-active"><img src="images/dunwu-logo-100.png" alt="LINUX-TUTORIAL" class="logo"> <span class="site-name can-hide">LINUX-TUTORIAL</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link router-link-active">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link router-link-active">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>grep</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/linux-tutorial/linux/cli/grep.html#补充说明" class="sidebar-link">补充说明</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/grep.html#选项" class="sidebar-link">选项</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/grep.html#规则表达式" class="sidebar-link">规则表达式</a></li></ul></li><li><a href="/linux-tutorial/linux/cli/grep.html#grep-命令常见用法" class="sidebar-link">grep 命令常见用法</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/grep.html#grep-递归搜索文件" class="sidebar-link">grep 递归搜索文件</a></li></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="grep"><a href="#grep" class="header-anchor">#</a> grep</h1> <p>强大的文本搜索工具</p> <h2 id="补充说明"><a href="#补充说明" class="header-anchor">#</a> 补充说明</h2> <p><strong>grep</strong> (global search regular expression(RE) and print out the line,全面搜索正则表达式并把行打印出来)是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来。用于过滤/搜索的特定字符。可使用正则表达式能多种命令配合使用,使用上十分灵活。</p> <h3 id="选项"><a href="#选项" class="header-anchor">#</a> 选项</h3> <div class="language-shell extra-class"><pre class="language-shell"><code>-a --text <span class="token comment"># 不要忽略二进制数据。</span>
|
||||
-A <span class="token operator"><</span>显示行数<span class="token operator">></span> --after-context<span class="token operator">=</span><span class="token operator"><</span>显示行数<span class="token operator">></span> <span class="token comment"># 除了显示符合范本样式的那一行之外,并显示该行之后的内容。</span>
|
||||
-b --byte-offset <span class="token comment"># 在显示符合范本样式的那一行之外,并显示该行之前的内容。</span>
|
||||
-B<span class="token operator"><</span>显示行数<span class="token operator">></span> --before-context<span class="token operator">=</span><span class="token operator"><</span>显示行数<span class="token operator">></span> <span class="token comment"># 除了显示符合样式的那一行之外,并显示该行之前的内容。</span>
|
||||
-c --count <span class="token comment"># 计算符合范本样式的列数。</span>
|
||||
-C<span class="token operator"><</span>显示行数<span class="token operator">></span> --context<span class="token operator">=</span><span class="token operator"><</span>显示行数<span class="token operator">></span>或-<span class="token operator"><</span>显示行数<span class="token operator">></span> <span class="token comment"># 除了显示符合范本样式的那一列之外,并显示该列之前后的内容。</span>
|
||||
-d<span class="token operator"><</span>进行动作<span class="token operator">></span> --directories<span class="token operator">=</span><span class="token operator"><</span>动作<span class="token operator">></span> <span class="token comment"># 当指定要查找的是目录而非文件时,必须使用这项参数,否则grep命令将回报信息并停止动作。</span>
|
||||
-e<span class="token operator"><</span>范本样式<span class="token operator">></span> --regexp<span class="token operator">=</span><span class="token operator"><</span>范本样式<span class="token operator">></span> <span class="token comment"># 指定字符串作为查找文件内容的范本样式。</span>
|
||||
-E --extended-regexp <span class="token comment"># 将范本样式为延伸的普通表示法来使用,意味着使用能使用扩展正则表达式。</span>
|
||||
-f<span class="token operator"><</span>范本文件<span class="token operator">></span> --file<span class="token operator">=</span><span class="token operator"><</span>规则文件<span class="token operator">></span> <span class="token comment"># 指定范本文件,其内容有一个或多个范本样式,让grep查找符合范本条件的文件内容,格式为每一列的范本样式。</span>
|
||||
-F --fixed-regexp <span class="token comment"># 将范本样式视为固定字符串的列表。</span>
|
||||
-G --basic-regexp <span class="token comment"># 将范本样式视为普通的表示法来使用。</span>
|
||||
-h --no-filename <span class="token comment"># 在显示符合范本样式的那一列之前,不标示该列所属的文件名称。</span>
|
||||
-H --with-filename <span class="token comment"># 在显示符合范本样式的那一列之前,标示该列的文件名称。</span>
|
||||
-i --ignore-case <span class="token comment"># 忽略字符大小写的差别。</span>
|
||||
-l --file-with-matches <span class="token comment"># 列出文件内容符合指定的范本样式的文件名称。</span>
|
||||
-L --files-without-match <span class="token comment"># 列出文件内容不符合指定的范本样式的文件名称。</span>
|
||||
-n --line-number <span class="token comment"># 在显示符合范本样式的那一列之前,标示出该列的编号。</span>
|
||||
-P --perl-regexp <span class="token comment"># PATTERN 是一个 Perl 正则表达式</span>
|
||||
-q --quiet或--silent <span class="token comment"># 不显示任何信息。</span>
|
||||
-R/-r --recursive <span class="token comment"># 此参数的效果和指定“-d recurse”参数相同。</span>
|
||||
-s --no-messages <span class="token comment"># 不显示错误信息。</span>
|
||||
-v --revert-match <span class="token comment"># 反转查找。</span>
|
||||
-V --version <span class="token comment"># 显示版本信息。</span>
|
||||
-w --word-regexp <span class="token comment"># 只显示全字符合的列。</span>
|
||||
-x --line-regexp <span class="token comment"># 只显示全列符合的列。</span>
|
||||
-y <span class="token comment"># 此参数效果跟“-i”相同。</span>
|
||||
-o <span class="token comment"># 只输出文件中匹配到的部分。</span>
|
||||
-m <span class="token operator"><</span>num<span class="token operator">></span> --max-count<span class="token operator">=</span><span class="token operator"><</span>num<span class="token operator">></span> <span class="token comment"># 找到num行结果后停止查找,用来限制匹配行数</span>
|
||||
</code></pre></div><h3 id="规则表达式"><a href="#规则表达式" class="header-anchor">#</a> 规则表达式</h3> <div class="language-shell extra-class"><pre class="language-shell"><code>^ <span class="token comment"># 锚定行的开始 如:'^grep'匹配所有以grep开头的行。</span>
|
||||
$ <span class="token comment"># 锚定行的结束 如:'grep$' 匹配所有以grep结尾的行。</span>
|
||||
<span class="token builtin class-name">.</span> <span class="token comment"># 匹配一个非换行符的字符 如:'gr.p'匹配gr后接一个任意字符,然后是p。</span>
|
||||
* <span class="token comment"># 匹配零个或多个先前字符 如:'*grep'匹配所有一个或多个空格后紧跟grep的行。</span>
|
||||
.* <span class="token comment"># 一起用代表任意字符。</span>
|
||||
<span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token comment"># 匹配一个指定范围内的字符,如'[Gg]rep'匹配Grep和grep。</span>
|
||||
<span class="token punctuation">[</span>^<span class="token punctuation">]</span> <span class="token comment"># 匹配一个不在指定范围内的字符,如:'[^A-FH-Z]rep'匹配不包含A-R和T-Z的一个字母开头,紧跟rep的行。</span>
|
||||
<span class="token punctuation">\</span><span class="token punctuation">(</span><span class="token punctuation">..</span><span class="token punctuation">\</span><span class="token punctuation">)</span> <span class="token comment"># 标记匹配字符,如'\(love\)',love被标记为1。</span>
|
||||
<span class="token punctuation">\</span><span class="token operator"><</span> <span class="token comment"># 锚定单词的开始,如:'\<grep'匹配包含以grep开头的单词的行。</span>
|
||||
<span class="token punctuation">\</span><span class="token operator">></span> <span class="token comment"># 锚定单词的结束,如'grep\>'匹配包含以grep结尾的单词的行。</span>
|
||||
x<span class="token punctuation">\</span><span class="token punctuation">{</span>m<span class="token punctuation">\</span><span class="token punctuation">}</span> <span class="token comment"># 重复字符x,m次,如:'0\{5\}'匹配包含5个o的行。</span>
|
||||
x<span class="token punctuation">\</span><span class="token punctuation">{</span>m,<span class="token punctuation">\</span><span class="token punctuation">}</span> <span class="token comment"># 重复字符x,至少m次,如:'o\{5,\}'匹配至少有5个o的行。</span>
|
||||
x<span class="token punctuation">\</span><span class="token punctuation">{</span>m,n<span class="token punctuation">\</span><span class="token punctuation">}</span> <span class="token comment"># 重复字符x,至少m次,不多于n次,如:'o\{5,10\}'匹配5--10个o的行。</span>
|
||||
<span class="token punctuation">\</span>w <span class="token comment"># 匹配文字和数字字符,也就是[A-Za-z0-9],如:'G\w*p'匹配以G后跟零个或多个文字或数字字符,然后是p。</span>
|
||||
<span class="token punctuation">\</span>W <span class="token comment"># \w的反置形式,匹配一个或多个非单词字符,如点号句号等。</span>
|
||||
<span class="token punctuation">\</span>b <span class="token comment"># 单词锁定符,如: '\bgrep\b'只匹配grep。</span>
|
||||
</code></pre></div><h2 id="grep-命令常见用法"><a href="#grep-命令常见用法" class="header-anchor">#</a> grep 命令常见用法</h2> <p>在文件中搜索一个单词,命令会返回一个包含 <strong>“match_pattern”</strong> 的文本行:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">grep</span> match_pattern file_name
|
||||
<span class="token function">grep</span> <span class="token string">"match_pattern"</span> file_name
|
||||
</code></pre></div><p>在多个文件中查找:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">grep</span> <span class="token string">"match_pattern"</span> file_1 file_2 file_3 <span class="token punctuation">..</span>.
|
||||
</code></pre></div><p>输出除之外的所有行 <strong>-v</strong> 选项:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">grep</span> -v <span class="token string">"match_pattern"</span> file_name
|
||||
</code></pre></div><p>标记匹配颜色 <strong>--color=auto</strong> 选项:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">grep</span> <span class="token string">"match_pattern"</span> file_name --color<span class="token operator">=</span>auto
|
||||
</code></pre></div><p>使用正则表达式 <strong>-E</strong> 选项:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">grep</span> -E <span class="token string">"[1-9]+"</span>
|
||||
<span class="token comment"># 或</span>
|
||||
<span class="token function">egrep</span> <span class="token string">"[1-9]+"</span>
|
||||
</code></pre></div><p>使用正则表达式 <strong>-P</strong> 选项:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">grep</span> -P <span class="token string">"(\d{3}\-){2}\d{4}"</span> file_name
|
||||
</code></pre></div><p>只输出文件中匹配到的部分 <strong>-o</strong> 选项:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token builtin class-name">echo</span> this is a <span class="token builtin class-name">test</span> line. <span class="token operator">|</span> <span class="token function">grep</span> -o -E <span class="token string">"[a-z]+\."</span>
|
||||
line.
|
||||
|
||||
<span class="token builtin class-name">echo</span> this is a <span class="token builtin class-name">test</span> line. <span class="token operator">|</span> <span class="token function">egrep</span> -o <span class="token string">"[a-z]+\."</span>
|
||||
line.
|
||||
</code></pre></div><p>统计文件或者文本中包含匹配字符串的行数 <strong>-c</strong> 选项:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">grep</span> -c <span class="token string">"text"</span> file_name
|
||||
</code></pre></div><p>输出包含匹配字符串的行数 <strong>-n</strong> 选项:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">grep</span> <span class="token string">"text"</span> -n file_name
|
||||
<span class="token comment"># 或</span>
|
||||
<span class="token function">cat</span> file_name <span class="token operator">|</span> <span class="token function">grep</span> <span class="token string">"text"</span> -n
|
||||
|
||||
<span class="token comment">#多个文件</span>
|
||||
<span class="token function">grep</span> <span class="token string">"text"</span> -n file_1 file_2
|
||||
</code></pre></div><p>打印样式匹配所位于的字符或字节偏移:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token builtin class-name">echo</span> gun is not unix <span class="token operator">|</span> <span class="token function">grep</span> -b -o <span class="token string">"not"</span>
|
||||
<span class="token number">7</span>:not
|
||||
<span class="token comment">#一行中字符串的字符便宜是从该行的第一个字符开始计算,起始值为0。选项 **-b -o** 一般总是配合使用。</span>
|
||||
</code></pre></div><p>搜索多个文件并查找匹配文本在哪些文件中:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">grep</span> -l <span class="token string">"text"</span> file1 file2 file3<span class="token punctuation">..</span>.
|
||||
</code></pre></div><h3 id="grep-递归搜索文件"><a href="#grep-递归搜索文件" class="header-anchor">#</a> grep 递归搜索文件</h3> <p>在多级目录中对文本进行递归搜索:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">grep</span> <span class="token string">"text"</span> <span class="token builtin class-name">.</span> -r -n
|
||||
<span class="token comment"># .表示当前目录。</span>
|
||||
</code></pre></div><p>忽略匹配样式中的字符大小写:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token builtin class-name">echo</span> <span class="token string">"hello world"</span> <span class="token operator">|</span> <span class="token function">grep</span> -i <span class="token string">"HELLO"</span>
|
||||
<span class="token comment"># hello</span>
|
||||
</code></pre></div><p>选项 <strong>-e</strong> 制动多个匹配样式:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token builtin class-name">echo</span> this is a text line <span class="token operator">|</span> <span class="token function">grep</span> -e <span class="token string">"is"</span> -e <span class="token string">"line"</span> -o
|
||||
is
|
||||
line
|
||||
|
||||
<span class="token comment">#也可以使用 **-f** 选项来匹配多个样式,在样式文件中逐行写出需要匹配的字符。</span>
|
||||
<span class="token function">cat</span> patfile
|
||||
aaa
|
||||
bbb
|
||||
|
||||
<span class="token builtin class-name">echo</span> aaa bbb ccc ddd eee <span class="token operator">|</span> <span class="token function">grep</span> -f patfile -o
|
||||
</code></pre></div><p>在 grep 搜索结果中包括或者排除指定文件:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 只在目录中所有的.php和.html文件中递归搜索字符"main()"</span>
|
||||
<span class="token function">grep</span> <span class="token string">"main()"</span> <span class="token builtin class-name">.</span> -r --include *.<span class="token punctuation">{</span>php,html<span class="token punctuation">}</span>
|
||||
|
||||
<span class="token comment"># 在搜索结果中排除所有README文件</span>
|
||||
<span class="token function">grep</span> <span class="token string">"main()"</span> <span class="token builtin class-name">.</span> -r --exclude <span class="token string">"README"</span>
|
||||
|
||||
<span class="token comment"># 在搜索结果中排除filelist文件列表里的文件</span>
|
||||
<span class="token function">grep</span> <span class="token string">"main()"</span> <span class="token builtin class-name">.</span> -r --exclude-from filelist
|
||||
|
||||
</code></pre></div><p>使用 0 值字节后缀的 grep 与 xargs:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 测试文件:</span>
|
||||
<span class="token builtin class-name">echo</span> <span class="token string">"aaa"</span> <span class="token operator">></span> file1
|
||||
<span class="token builtin class-name">echo</span> <span class="token string">"bbb"</span> <span class="token operator">></span> file2
|
||||
<span class="token builtin class-name">echo</span> <span class="token string">"aaa"</span> <span class="token operator">></span> file3
|
||||
|
||||
<span class="token function">grep</span> <span class="token string">"aaa"</span> file* -lZ <span class="token operator">|</span> <span class="token function">xargs</span> -0 <span class="token function">rm</span>
|
||||
|
||||
<span class="token comment"># 执行后会删除file1和file3,grep输出用-Z选项来指定以0值字节作为终结符文件名(\0),xargs -0 读取输入并用0值字节终结符分隔文件名,然后删除匹配文件,-Z通常和-l结合使用。</span>
|
||||
</code></pre></div><p>grep 静默输出:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">grep</span> -q <span class="token string">"test"</span> filename
|
||||
<span class="token comment"># 不会输出任何信息,如果命令运行成功返回0,失败则返回非0值。一般用于条件测试。</span>
|
||||
</code></pre></div><p>打印出匹配文本之前或者之后的行:</p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token comment"># 显示匹配某个结果之后的3行,使用 -A 选项:</span>
|
||||
<span class="token function">seq</span> <span class="token number">10</span> <span class="token operator">|</span> <span class="token function">grep</span> <span class="token string">"5"</span> -A <span class="token number">3</span>
|
||||
<span class="token number">5</span>
|
||||
<span class="token number">6</span>
|
||||
<span class="token number">7</span>
|
||||
<span class="token number">8</span>
|
||||
|
||||
<span class="token comment"># 显示匹配某个结果之前的3行,使用 -B 选项:</span>
|
||||
<span class="token function">seq</span> <span class="token number">10</span> <span class="token operator">|</span> <span class="token function">grep</span> <span class="token string">"5"</span> -B <span class="token number">3</span>
|
||||
<span class="token number">2</span>
|
||||
<span class="token number">3</span>
|
||||
<span class="token number">4</span>
|
||||
<span class="token number">5</span>
|
||||
|
||||
<span class="token comment"># 显示匹配某个结果的前三行和后三行,使用 -C 选项:</span>
|
||||
<span class="token function">seq</span> <span class="token number">10</span> <span class="token operator">|</span> <span class="token function">grep</span> <span class="token string">"5"</span> -C <span class="token number">3</span>
|
||||
<span class="token number">2</span>
|
||||
<span class="token number">3</span>
|
||||
<span class="token number">4</span>
|
||||
<span class="token number">5</span>
|
||||
<span class="token number">6</span>
|
||||
<span class="token number">7</span>
|
||||
<span class="token number">8</span>
|
||||
|
||||
<span class="token comment"># 如果匹配结果有多个,会用“--”作为各匹配结果之间的分隔符:</span>
|
||||
<span class="token builtin class-name">echo</span> -e <span class="token string">"a<span class="token entity" title="\n">\n</span>b<span class="token entity" title="\n">\n</span>c<span class="token entity" title="\n">\n</span>a<span class="token entity" title="\n">\n</span>b<span class="token entity" title="\n">\n</span>c"</span> <span class="token operator">|</span> <span class="token function">grep</span> a -A <span class="token number">1</span>
|
||||
a
|
||||
b
|
||||
--
|
||||
a
|
||||
b
|
||||
</code></pre></div></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/dunwu/linux-tutorial/edit/master/docs/linux/cli/grep.md" target="_blank" rel="noopener noreferrer">帮助我们改善此页面!</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">a year ago</span></div></footer> <!----> </main></div><div class="global-ui"><!----><!----></div></div>
|
||||
<script src="/linux-tutorial/assets/js/app.79a38eea.js" defer></script><script src="/linux-tutorial/assets/js/4.fb6e0f89.js" defer></script><script src="/linux-tutorial/assets/js/21.1c5a41d7.js" defer></script><script src="/linux-tutorial/assets/js/5.cb43ecfb.js" defer></script>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,64 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>iostat | LINUX-TUTORIAL</title>
|
||||
<meta name="generator" content="VuePress 1.8.2">
|
||||
<link rel="icon" href="/linux-tutorial/favicon.ico">
|
||||
<meta name="description" content="数据库教程">
|
||||
|
||||
<link rel="preload" href="/linux-tutorial/assets/css/0.styles.45d9d031.css" as="style"><link rel="preload" href="/linux-tutorial/assets/js/app.79a38eea.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/4.fb6e0f89.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/22.fbe9fdf1.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/5.cb43ecfb.js" as="script"><link rel="prefetch" href="/linux-tutorial/assets/js/10.7933187b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/11.b9b41530.js"><link rel="prefetch" href="/linux-tutorial/assets/js/12.70a5dba8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/13.857dcc43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/14.5a603a55.js"><link rel="prefetch" href="/linux-tutorial/assets/js/15.d217acb7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/16.ad565eae.js"><link rel="prefetch" href="/linux-tutorial/assets/js/17.d43e9f56.js"><link rel="prefetch" href="/linux-tutorial/assets/js/18.aa00ff43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/19.43ce44b3.js"><link rel="prefetch" href="/linux-tutorial/assets/js/20.5618e1ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/21.1c5a41d7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/23.a4fb0e74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/24.e3a23b69.js"><link rel="prefetch" href="/linux-tutorial/assets/js/25.9896afe9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/26.96164082.js"><link rel="prefetch" href="/linux-tutorial/assets/js/27.391033bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/28.703f74c2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/29.02a952cb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/30.7e13628f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/31.c4652f75.js"><link rel="prefetch" href="/linux-tutorial/assets/js/32.05d2cbec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/33.3b265df8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/34.26330a03.js"><link rel="prefetch" href="/linux-tutorial/assets/js/35.417d706d.js"><link rel="prefetch" href="/linux-tutorial/assets/js/36.0ed775e0.js"><link rel="prefetch" href="/linux-tutorial/assets/js/37.34430c74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/38.87d5e0ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/39.7b648b3e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/40.3b7a219e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/41.e727eee9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/42.0134c187.js"><link rel="prefetch" href="/linux-tutorial/assets/js/43.175e982f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/44.72d90888.js"><link rel="prefetch" href="/linux-tutorial/assets/js/45.d49955bd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/46.a9c290ec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/47.cc639f04.js"><link rel="prefetch" href="/linux-tutorial/assets/js/48.98c78321.js"><link rel="prefetch" href="/linux-tutorial/assets/js/49.a7c3afed.js"><link rel="prefetch" href="/linux-tutorial/assets/js/50.22d8c542.js"><link rel="prefetch" href="/linux-tutorial/assets/js/51.28055fcd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/52.f8103df5.js"><link rel="prefetch" href="/linux-tutorial/assets/js/53.76541550.js"><link rel="prefetch" href="/linux-tutorial/assets/js/54.e78d2776.js"><link rel="prefetch" href="/linux-tutorial/assets/js/55.3ce3079c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/56.832958c9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/57.961ce896.js"><link rel="prefetch" href="/linux-tutorial/assets/js/58.6d6fbc82.js"><link rel="prefetch" href="/linux-tutorial/assets/js/59.d5e48112.js"><link rel="prefetch" href="/linux-tutorial/assets/js/6.c8f4721c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/60.7927b23b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/61.ee233f24.js"><link rel="prefetch" href="/linux-tutorial/assets/js/62.6ba50cc7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/63.9cbf9f2b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/64.0be148a4.js"><link rel="prefetch" href="/linux-tutorial/assets/js/65.c520257e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/66.f2335390.js"><link rel="prefetch" href="/linux-tutorial/assets/js/67.e5737218.js"><link rel="prefetch" href="/linux-tutorial/assets/js/68.46427a01.js"><link rel="prefetch" href="/linux-tutorial/assets/js/69.450417bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/7.046e5a1b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/70.072034d2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/8.77fb8967.js"><link rel="prefetch" href="/linux-tutorial/assets/js/9.ebfa537e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~flowchart.20a64d45.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~notification.ea176280.js">
|
||||
<link rel="stylesheet" href="/linux-tutorial/assets/css/0.styles.45d9d031.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/linux-tutorial/" class="home-link router-link-active"><img src="images/dunwu-logo-100.png" alt="LINUX-TUTORIAL" class="logo"> <span class="site-name can-hide">LINUX-TUTORIAL</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link router-link-active">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link router-link-active">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>iostat</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/linux-tutorial/linux/cli/iostat.html#补充说明" class="sidebar-link">补充说明</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/iostat.html#语法" class="sidebar-link">语法</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/iostat.html#选项" class="sidebar-link">选项</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/iostat.html#参数" class="sidebar-link">参数</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/iostat.html#实例" class="sidebar-link">实例</a></li></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="iostat"><a href="#iostat" class="header-anchor">#</a> iostat</h1> <p>监视系统输入输出设备和 CPU 的使用情况</p> <h2 id="补充说明"><a href="#补充说明" class="header-anchor">#</a> 补充说明</h2> <p><strong>iostat 命令</strong> 被用于监视系统输入输出设备和 CPU 的使用情况。它的特点是汇报磁盘活动统计情况,同时也会汇报出 CPU 使用情况。同 vmstat 一样,iostat 也有一个弱点,就是它不能对某个进程进行深入分析,仅对系统的整体情况进行分析。</p> <h3 id="语法"><a href="#语法" class="header-anchor">#</a> 语法</h3> <div class="language-shell extra-class"><pre class="language-shell"><code>iostat<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre></div><h3 id="选项"><a href="#选项" class="header-anchor">#</a> 选项</h3> <div class="language-shell extra-class"><pre class="language-shell"><code>-c:仅显示CPU使用情况;
|
||||
-d:仅显示设备利用率;
|
||||
-k:显示状态以千字节每秒为单位,而不使用块每秒;
|
||||
-m:显示状态以兆字节每秒为单位;
|
||||
-p:仅显示块设备和所有被使用的其他分区的状态;
|
||||
-t:显示每个报告产生时的时间;
|
||||
-V:显示版号并退出;
|
||||
-x:显示扩展状态。
|
||||
</code></pre></div><h3 id="参数"><a href="#参数" class="header-anchor">#</a> 参数</h3> <ul><li>间隔时间:每次报告的间隔时间(秒);</li> <li>次数:显示报告的次数。</li></ul> <h3 id="实例"><a href="#实例" class="header-anchor">#</a> 实例</h3> <p>用<code>iostat -x /dev/sda1</code>来观看磁盘 I/O 的详细情况:</p> <div class="language-shell extra-class"><pre class="language-shell"><code>iostat -x /dev/sda1
|
||||
Linux <span class="token number">2.6</span>.18-164.el5xen <span class="token punctuation">(</span>localhost.localdomain<span class="token punctuation">)</span>
|
||||
<span class="token number">2010</span>年03月26日
|
||||
|
||||
avg-cpu: %user %nice %system %iowait
|
||||
%steal %idle
|
||||
<span class="token number">0.11</span> <span class="token number">0.02</span> <span class="token number">0.18</span> <span class="token number">0.35</span>
|
||||
<span class="token number">0.03</span> <span class="token number">99.31</span>
|
||||
|
||||
Device: tps Blk_read/s Blk_wrtn/s
|
||||
Blk_read Blk_wrtn
|
||||
sda1 <span class="token number">0.02</span> <span class="token number">0.08</span>
|
||||
<span class="token number">0.00</span> <span class="token number">2014</span> <span class="token number">4</span>
|
||||
</code></pre></div><p>详细说明:第二行是系统信息和监测时间,第三行和第四行显示 CPU 使用情况(具体内容和 mpstat 命令相同)。这里主要关注后面 I/O 输出的信息,如下所示:</p> <table><thead><tr><th>标示</th> <th>说明</th></tr></thead> <tbody><tr><td>Device</td> <td>监测设备名称</td></tr> <tr><td>rrqm/s</td> <td>每秒需要读取需求的数量</td></tr> <tr><td>wrqm/s</td> <td>每秒需要写入需求的数量</td></tr> <tr><td>r/s</td> <td>每秒实际读取需求的数量</td></tr> <tr><td>w/s</td> <td>每秒实际写入需求的数量</td></tr> <tr><td>rsec/s</td> <td>每秒读取区段的数量</td></tr> <tr><td>wsec/s</td> <td>每秒写入区段的数量</td></tr> <tr><td>rkB/s</td> <td>每秒实际读取的大小,单位为 KB</td></tr> <tr><td>wkB/s</td> <td>每秒实际写入的大小,单位为 KB</td></tr> <tr><td>avgrq-sz</td> <td>需求的平均大小区段</td></tr> <tr><td>avgqu-sz</td> <td>需求的平均队列长度</td></tr> <tr><td>await</td> <td>等待 I/O 平均的时间(milliseconds)</td></tr> <tr><td>svctm</td> <td>I/O 需求完成的平均时间</td></tr> <tr><td>%util</td> <td>被 I/O 需求消耗的 CPU 百分比</td></tr></tbody></table></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/dunwu/linux-tutorial/edit/master/docs/linux/cli/iostat.md" target="_blank" rel="noopener noreferrer">帮助我们改善此页面!</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">a year ago</span></div></footer> <!----> </main></div><div class="global-ui"><!----><!----></div></div>
|
||||
<script src="/linux-tutorial/assets/js/app.79a38eea.js" defer></script><script src="/linux-tutorial/assets/js/4.fb6e0f89.js" defer></script><script src="/linux-tutorial/assets/js/22.fbe9fdf1.js" defer></script><script src="/linux-tutorial/assets/js/5.cb43ecfb.js" defer></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,69 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>iotop | LINUX-TUTORIAL</title>
|
||||
<meta name="generator" content="VuePress 1.8.2">
|
||||
<link rel="icon" href="/linux-tutorial/favicon.ico">
|
||||
<meta name="description" content="数据库教程">
|
||||
|
||||
<link rel="preload" href="/linux-tutorial/assets/css/0.styles.45d9d031.css" as="style"><link rel="preload" href="/linux-tutorial/assets/js/app.79a38eea.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/4.fb6e0f89.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/23.a4fb0e74.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/5.cb43ecfb.js" as="script"><link rel="prefetch" href="/linux-tutorial/assets/js/10.7933187b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/11.b9b41530.js"><link rel="prefetch" href="/linux-tutorial/assets/js/12.70a5dba8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/13.857dcc43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/14.5a603a55.js"><link rel="prefetch" href="/linux-tutorial/assets/js/15.d217acb7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/16.ad565eae.js"><link rel="prefetch" href="/linux-tutorial/assets/js/17.d43e9f56.js"><link rel="prefetch" href="/linux-tutorial/assets/js/18.aa00ff43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/19.43ce44b3.js"><link rel="prefetch" href="/linux-tutorial/assets/js/20.5618e1ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/21.1c5a41d7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/22.fbe9fdf1.js"><link rel="prefetch" href="/linux-tutorial/assets/js/24.e3a23b69.js"><link rel="prefetch" href="/linux-tutorial/assets/js/25.9896afe9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/26.96164082.js"><link rel="prefetch" href="/linux-tutorial/assets/js/27.391033bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/28.703f74c2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/29.02a952cb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/30.7e13628f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/31.c4652f75.js"><link rel="prefetch" href="/linux-tutorial/assets/js/32.05d2cbec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/33.3b265df8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/34.26330a03.js"><link rel="prefetch" href="/linux-tutorial/assets/js/35.417d706d.js"><link rel="prefetch" href="/linux-tutorial/assets/js/36.0ed775e0.js"><link rel="prefetch" href="/linux-tutorial/assets/js/37.34430c74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/38.87d5e0ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/39.7b648b3e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/40.3b7a219e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/41.e727eee9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/42.0134c187.js"><link rel="prefetch" href="/linux-tutorial/assets/js/43.175e982f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/44.72d90888.js"><link rel="prefetch" href="/linux-tutorial/assets/js/45.d49955bd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/46.a9c290ec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/47.cc639f04.js"><link rel="prefetch" href="/linux-tutorial/assets/js/48.98c78321.js"><link rel="prefetch" href="/linux-tutorial/assets/js/49.a7c3afed.js"><link rel="prefetch" href="/linux-tutorial/assets/js/50.22d8c542.js"><link rel="prefetch" href="/linux-tutorial/assets/js/51.28055fcd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/52.f8103df5.js"><link rel="prefetch" href="/linux-tutorial/assets/js/53.76541550.js"><link rel="prefetch" href="/linux-tutorial/assets/js/54.e78d2776.js"><link rel="prefetch" href="/linux-tutorial/assets/js/55.3ce3079c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/56.832958c9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/57.961ce896.js"><link rel="prefetch" href="/linux-tutorial/assets/js/58.6d6fbc82.js"><link rel="prefetch" href="/linux-tutorial/assets/js/59.d5e48112.js"><link rel="prefetch" href="/linux-tutorial/assets/js/6.c8f4721c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/60.7927b23b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/61.ee233f24.js"><link rel="prefetch" href="/linux-tutorial/assets/js/62.6ba50cc7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/63.9cbf9f2b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/64.0be148a4.js"><link rel="prefetch" href="/linux-tutorial/assets/js/65.c520257e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/66.f2335390.js"><link rel="prefetch" href="/linux-tutorial/assets/js/67.e5737218.js"><link rel="prefetch" href="/linux-tutorial/assets/js/68.46427a01.js"><link rel="prefetch" href="/linux-tutorial/assets/js/69.450417bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/7.046e5a1b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/70.072034d2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/8.77fb8967.js"><link rel="prefetch" href="/linux-tutorial/assets/js/9.ebfa537e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~flowchart.20a64d45.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~notification.ea176280.js">
|
||||
<link rel="stylesheet" href="/linux-tutorial/assets/css/0.styles.45d9d031.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/linux-tutorial/" class="home-link router-link-active"><img src="images/dunwu-logo-100.png" alt="LINUX-TUTORIAL" class="logo"> <span class="site-name can-hide">LINUX-TUTORIAL</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link router-link-active">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link router-link-active">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>iotop</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/linux-tutorial/linux/cli/iotop.html#补充说明" class="sidebar-link">补充说明</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/iotop.html#安装" class="sidebar-link">安装</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/iotop.html#语法" class="sidebar-link">语法</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/iotop.html#选项" class="sidebar-link">选项</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/iotop.html#实例" class="sidebar-link">实例</a></li></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="iotop"><a href="#iotop" class="header-anchor">#</a> iotop</h1> <p>用来监视磁盘 I/O 使用状况的工具</p> <h2 id="补充说明"><a href="#补充说明" class="header-anchor">#</a> 补充说明</h2> <p><strong>iotop 命令</strong> 是一个用来监视磁盘 I/O 使用状况的 top 类工具。iotop 具有与 top 相似的 UI,其中包括 PID、用户、I/O、进程等相关信息。Linux 下的 IO 统计工具如 iostat,nmon 等大多数是只能统计到 per 设备的读写情况,如果你想知道每个进程是如何使用 IO 的就比较麻烦,使用 iotop 命令可以很方便的查看。</p> <p>iotop 使用 Python 语言编写而成,要求 Python2.5(及以上版本)和 Linux kernel2.6.20(及以上版本)。iotop 提供有源代码及 rpm 包,可从其官方主页下载。</p> <h3 id="安装"><a href="#安装" class="header-anchor">#</a> 安装</h3> <p><strong>Ubuntu</strong></p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">apt-get</span> <span class="token function">install</span> iotop
|
||||
</code></pre></div><p><strong>CentOS</strong></p> <div class="language-shell extra-class"><pre class="language-shell"><code>yum <span class="token function">install</span> iotop
|
||||
</code></pre></div><p><strong>编译安装</strong></p> <div class="language-shell extra-class"><pre class="language-shell"><code><span class="token function">wget</span> http://guichaz.free.fr/iotop/files/iotop-0.4.4.tar.gz
|
||||
<span class="token function">tar</span> zxf iotop-0.4.4.tar.gz
|
||||
python setup.py build
|
||||
python setup.py <span class="token function">install</span>
|
||||
</code></pre></div><h3 id="语法"><a href="#语法" class="header-anchor">#</a> 语法</h3> <div class="language-shell extra-class"><pre class="language-shell"><code>iotop(选项)
|
||||
</code></pre></div><h3 id="选项"><a href="#选项" class="header-anchor">#</a> 选项</h3> <div class="language-shell extra-class"><pre class="language-shell"><code>-o:只显示有io操作的进程
|
||||
-b:批量显示,无交互,主要用作记录到文件。
|
||||
-n NUM:显示NUM次,主要用于非交互式模式。
|
||||
-d SEC:间隔SEC秒显示一次。
|
||||
-p PID:监控的进程pid。
|
||||
-u <span class="token environment constant">USER</span>:监控的进程用户。
|
||||
</code></pre></div><p><strong>iotop 常用快捷键:</strong></p> <ol><li>左右箭头:改变排序方式,默认是按 IO 排序。</li> <li>r:改变排序顺序。</li> <li>o:只显示有 IO 输出的进程。</li> <li>p:进程/线程的显示方式的切换。</li> <li>a:显示累积使用量。</li> <li>q:退出。</li></ol> <h3 id="实例"><a href="#实例" class="header-anchor">#</a> 实例</h3> <p>直接执行 iotop 就可以看到效果了:</p> <div class="language-shell extra-class"><pre class="language-shell"><code>Total DISK read: <span class="token number">0.00</span> B/s <span class="token operator">|</span> Total DISK write: <span class="token number">0.00</span> B/s
|
||||
TID PRIO <span class="token environment constant">USER</span> DISK READ DISK WRITE SWAPIN IO<span class="token operator">></span> <span class="token builtin class-name">command</span>
|
||||
<span class="token number">1</span> be/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % init <span class="token punctuation">[</span><span class="token number">3</span><span class="token punctuation">]</span>
|
||||
<span class="token number">2</span> be/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>kthreadd<span class="token punctuation">]</span>
|
||||
<span class="token number">3</span> rt/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>migration/0<span class="token punctuation">]</span>
|
||||
<span class="token number">4</span> be/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>ksoftirqd/0<span class="token punctuation">]</span>
|
||||
<span class="token number">5</span> rt/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>watchdog/0<span class="token punctuation">]</span>
|
||||
<span class="token number">6</span> rt/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>migration/1<span class="token punctuation">]</span>
|
||||
<span class="token number">7</span> be/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>ksoftirqd/1<span class="token punctuation">]</span>
|
||||
<span class="token number">8</span> rt/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>watchdog/1<span class="token punctuation">]</span>
|
||||
<span class="token number">9</span> be/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>events/0<span class="token punctuation">]</span>
|
||||
<span class="token number">10</span> be/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>events/1<span class="token punctuation">]</span>
|
||||
<span class="token number">11</span> be/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>khelper<span class="token punctuation">]</span>
|
||||
<span class="token number">2572</span> be/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>bluetooth<span class="token punctuation">]</span>
|
||||
</code></pre></div></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/dunwu/linux-tutorial/edit/master/docs/linux/cli/iotop.md" target="_blank" rel="noopener noreferrer">帮助我们改善此页面!</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">a year ago</span></div></footer> <!----> </main></div><div class="global-ui"><!----><!----></div></div>
|
||||
<script src="/linux-tutorial/assets/js/app.79a38eea.js" defer></script><script src="/linux-tutorial/assets/js/4.fb6e0f89.js" defer></script><script src="/linux-tutorial/assets/js/23.a4fb0e74.js" defer></script><script src="/linux-tutorial/assets/js/5.cb43ecfb.js" defer></script>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,61 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Linux 文件压缩和解压 | LINUX-TUTORIAL</title>
|
||||
<meta name="generator" content="VuePress 1.8.2">
|
||||
<link rel="icon" href="/linux-tutorial/favicon.ico">
|
||||
<meta name="description" content="数据库教程">
|
||||
|
||||
<link rel="preload" href="/linux-tutorial/assets/css/0.styles.45d9d031.css" as="style"><link rel="preload" href="/linux-tutorial/assets/js/app.79a38eea.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/4.fb6e0f89.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/25.9896afe9.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/5.cb43ecfb.js" as="script"><link rel="prefetch" href="/linux-tutorial/assets/js/10.7933187b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/11.b9b41530.js"><link rel="prefetch" href="/linux-tutorial/assets/js/12.70a5dba8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/13.857dcc43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/14.5a603a55.js"><link rel="prefetch" href="/linux-tutorial/assets/js/15.d217acb7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/16.ad565eae.js"><link rel="prefetch" href="/linux-tutorial/assets/js/17.d43e9f56.js"><link rel="prefetch" href="/linux-tutorial/assets/js/18.aa00ff43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/19.43ce44b3.js"><link rel="prefetch" href="/linux-tutorial/assets/js/20.5618e1ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/21.1c5a41d7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/22.fbe9fdf1.js"><link rel="prefetch" href="/linux-tutorial/assets/js/23.a4fb0e74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/24.e3a23b69.js"><link rel="prefetch" href="/linux-tutorial/assets/js/26.96164082.js"><link rel="prefetch" href="/linux-tutorial/assets/js/27.391033bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/28.703f74c2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/29.02a952cb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/30.7e13628f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/31.c4652f75.js"><link rel="prefetch" href="/linux-tutorial/assets/js/32.05d2cbec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/33.3b265df8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/34.26330a03.js"><link rel="prefetch" href="/linux-tutorial/assets/js/35.417d706d.js"><link rel="prefetch" href="/linux-tutorial/assets/js/36.0ed775e0.js"><link rel="prefetch" href="/linux-tutorial/assets/js/37.34430c74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/38.87d5e0ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/39.7b648b3e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/40.3b7a219e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/41.e727eee9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/42.0134c187.js"><link rel="prefetch" href="/linux-tutorial/assets/js/43.175e982f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/44.72d90888.js"><link rel="prefetch" href="/linux-tutorial/assets/js/45.d49955bd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/46.a9c290ec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/47.cc639f04.js"><link rel="prefetch" href="/linux-tutorial/assets/js/48.98c78321.js"><link rel="prefetch" href="/linux-tutorial/assets/js/49.a7c3afed.js"><link rel="prefetch" href="/linux-tutorial/assets/js/50.22d8c542.js"><link rel="prefetch" href="/linux-tutorial/assets/js/51.28055fcd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/52.f8103df5.js"><link rel="prefetch" href="/linux-tutorial/assets/js/53.76541550.js"><link rel="prefetch" href="/linux-tutorial/assets/js/54.e78d2776.js"><link rel="prefetch" href="/linux-tutorial/assets/js/55.3ce3079c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/56.832958c9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/57.961ce896.js"><link rel="prefetch" href="/linux-tutorial/assets/js/58.6d6fbc82.js"><link rel="prefetch" href="/linux-tutorial/assets/js/59.d5e48112.js"><link rel="prefetch" href="/linux-tutorial/assets/js/6.c8f4721c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/60.7927b23b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/61.ee233f24.js"><link rel="prefetch" href="/linux-tutorial/assets/js/62.6ba50cc7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/63.9cbf9f2b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/64.0be148a4.js"><link rel="prefetch" href="/linux-tutorial/assets/js/65.c520257e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/66.f2335390.js"><link rel="prefetch" href="/linux-tutorial/assets/js/67.e5737218.js"><link rel="prefetch" href="/linux-tutorial/assets/js/68.46427a01.js"><link rel="prefetch" href="/linux-tutorial/assets/js/69.450417bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/7.046e5a1b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/70.072034d2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/8.77fb8967.js"><link rel="prefetch" href="/linux-tutorial/assets/js/9.ebfa537e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~flowchart.20a64d45.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~notification.ea176280.js">
|
||||
<link rel="stylesheet" href="/linux-tutorial/assets/css/0.styles.45d9d031.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/linux-tutorial/" class="home-link router-link-active"><img src="images/dunwu-logo-100.png" alt="LINUX-TUTORIAL" class="logo"> <span class="site-name can-hide">LINUX-TUTORIAL</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link router-link-active">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link router-link-active">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Linux 文件压缩和解压</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/linux-tutorial/linux/cli/linux-cli-file-compress.html#_1-linux-文件压缩和解压要点" class="sidebar-link">1. Linux 文件压缩和解压要点</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/linux-tutorial/linux/cli/linux-cli-file-compress.html#_2-命令常见用法" class="sidebar-link">2. 命令常见用法</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-file-compress.html#_2-1-tar" class="sidebar-link">2.1. tar</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-file-compress.html#_2-2-gzip" class="sidebar-link">2.2. gzip</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-file-compress.html#_2-3-zip" class="sidebar-link">2.3. zip</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-file-compress.html#_2-4-unzip" class="sidebar-link">2.4. unzip</a></li></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="linux-文件压缩和解压"><a href="#linux-文件压缩和解压" class="header-anchor">#</a> Linux 文件压缩和解压</h1> <blockquote><p>关键词:<code>tar</code>, <code>gzip</code>, <code>zip</code>, <code>unzip</code></p></blockquote> <h2 id="_1-linux-文件压缩和解压要点"><a href="#_1-linux-文件压缩和解压要点" class="header-anchor">#</a> 1. Linux 文件压缩和解压要点</h2> <ul><li>压缩和解压 tar 文件 - 使用 <a href="#tar">tar</a></li> <li>压缩和解压 gz 文件 - 使用 <a href="#gzip">gzip</a></li> <li>压缩和解压 zip 文件 - 分别使用 <a href="#zip">zip</a>、<a href="#unzip">unzip</a></li></ul> <h2 id="_2-命令常见用法"><a href="#_2-命令常见用法" class="header-anchor">#</a> 2. 命令常见用法</h2> <h3 id="_2-1-tar"><a href="#_2-1-tar" class="header-anchor">#</a> 2.1. tar</h3> <blockquote><p>tar 命令可以为 linux 的文件和目录创建档案。利用 tar,可以为某一特定文件创建档案(备份文件),也可以在档案中改变文件,或者向档案中加入新的文件。tar 最初被用来在磁带上创建档案,现在,用户可以在任何设备上创建档案。利用 tar 命令,可以把一大堆的文件和目录全部打包成一个文件,这对于备份文件或将几个文件组合成为一个文件以便于网络传输是非常有用的。</p> <p>参考:http://man.linuxde.net/tar</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">tar</span> -cvf log.tar log2012.log <span class="token comment"># 仅打包,不压缩</span>
|
||||
<span class="token function">tar</span> -zcvf log.tar.gz log2012.log <span class="token comment"># 打包后,以 gzip 压缩</span>
|
||||
<span class="token function">tar</span> -jcvf log.tar.bz2 log2012.log <span class="token comment"># 打包后,以 bzip2 压缩</span>
|
||||
|
||||
<span class="token function">tar</span> -ztvf log.tar.gz <span class="token comment"># 查阅上述 tar 包内有哪些文件</span>
|
||||
<span class="token function">tar</span> -zxvf log.tar.gz <span class="token comment"># 将 tar 包解压缩</span>
|
||||
<span class="token function">tar</span> -zxvf log30.tar.gz log2013.log <span class="token comment"># 只将 tar 内的部分文件解压出来</span>
|
||||
</code></pre></div><h3 id="_2-2-gzip"><a href="#_2-2-gzip" class="header-anchor">#</a> 2.2. gzip</h3> <blockquote><p>gzip 命令用来压缩文件。gzip 是个使用广泛的压缩程序,文件经它压缩过后,其名称后面会多出“.gz”扩展名。</p> <p>gzip 是在 Linux 系统中经常使用的一个对文件进行压缩和解压缩的命令,既方便又好用。gzip 不仅可以用来压缩大的、较少使用的文件以节省磁盘空间,还可以和 tar 命令一起构成 Linux 操作系统中比较流行的压缩文件格式。据统计,gzip 命令对文本文件有 60%~ 70%的压缩率。减少文件大小有两个明显的好处,一是可以减少存储空间,二是通过网络传输文件时,可以减少传输的时间。</p> <p>参考:http://man.linuxde.net/gzip</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">gzip</span> * <span class="token comment"># 将所有文件压缩成 .gz 文件</span>
|
||||
<span class="token function">gzip</span> -l * <span class="token comment"># 详细显示压缩文件的信息,并不解压</span>
|
||||
<span class="token function">gzip</span> -dv * <span class="token comment"># 解压上例中的所有压缩文件,并列出详细的信息</span>
|
||||
<span class="token function">gzip</span> -r log.tar <span class="token comment"># 压缩一个 tar 备份文件,此时压缩文件的扩展名为.tar.gz</span>
|
||||
<span class="token function">gzip</span> -rv test/ <span class="token comment"># 递归的压缩目录</span>
|
||||
<span class="token function">gzip</span> -dr test/ <span class="token comment"># 递归地解压目录</span>
|
||||
</code></pre></div><h3 id="_2-3-zip"><a href="#_2-3-zip" class="header-anchor">#</a> 2.3. zip</h3> <blockquote><p>zip 命令可以用来解压缩文件,或者对文件进行打包操作。zip 是个使用广泛的压缩程序,文件经它压缩后会另外产生具有“.zip”扩展名的压缩文件。</p> <p>参考:http://man.linuxde.net/zip</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 将 /home/Blinux/html/ 这个目录下所有文件和文件夹打包为当前目录下的 html.zip</span>
|
||||
<span class="token function">zip</span> -q -r html.zip /home/Blinux/html
|
||||
</code></pre></div><h3 id="_2-4-unzip"><a href="#_2-4-unzip" class="header-anchor">#</a> 2.4. unzip</h3> <blockquote><p>unzip 命令用于解压缩由 zip 命令压缩的“.zip”压缩包。</p> <p>参考:http://man.linuxde.net/unzip</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">unzip</span> test.zip <span class="token comment"># 解压 zip 文件</span>
|
||||
<span class="token function">unzip</span> -n test.zip -d /tmp/ <span class="token comment"># 在指定目录下解压缩</span>
|
||||
<span class="token function">unzip</span> -o test.zip -d /tmp/ <span class="token comment"># 在指定目录下解压缩,如果有相同文件存在则覆盖</span>
|
||||
<span class="token function">unzip</span> -v test.zip <span class="token comment"># 查看压缩文件目录,但不解压</span>
|
||||
</code></pre></div></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/dunwu/linux-tutorial/edit/master/docs/linux/cli/linux-cli-file-compress.md" target="_blank" rel="noopener noreferrer">帮助我们改善此页面!</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">a year ago</span></div></footer> <!----> </main></div><div class="global-ui"><!----><!----></div></div>
|
||||
<script src="/linux-tutorial/assets/js/app.79a38eea.js" defer></script><script src="/linux-tutorial/assets/js/4.fb6e0f89.js" defer></script><script src="/linux-tutorial/assets/js/25.9896afe9.js" defer></script><script src="/linux-tutorial/assets/js/5.cb43ecfb.js" defer></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,97 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Linux 文件内容查看编辑 | LINUX-TUTORIAL</title>
|
||||
<meta name="generator" content="VuePress 1.8.2">
|
||||
<link rel="icon" href="/linux-tutorial/favicon.ico">
|
||||
<meta name="description" content="数据库教程">
|
||||
|
||||
<link rel="preload" href="/linux-tutorial/assets/css/0.styles.45d9d031.css" as="style"><link rel="preload" href="/linux-tutorial/assets/js/app.79a38eea.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/4.fb6e0f89.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/26.96164082.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/5.cb43ecfb.js" as="script"><link rel="prefetch" href="/linux-tutorial/assets/js/10.7933187b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/11.b9b41530.js"><link rel="prefetch" href="/linux-tutorial/assets/js/12.70a5dba8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/13.857dcc43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/14.5a603a55.js"><link rel="prefetch" href="/linux-tutorial/assets/js/15.d217acb7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/16.ad565eae.js"><link rel="prefetch" href="/linux-tutorial/assets/js/17.d43e9f56.js"><link rel="prefetch" href="/linux-tutorial/assets/js/18.aa00ff43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/19.43ce44b3.js"><link rel="prefetch" href="/linux-tutorial/assets/js/20.5618e1ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/21.1c5a41d7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/22.fbe9fdf1.js"><link rel="prefetch" href="/linux-tutorial/assets/js/23.a4fb0e74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/24.e3a23b69.js"><link rel="prefetch" href="/linux-tutorial/assets/js/25.9896afe9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/27.391033bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/28.703f74c2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/29.02a952cb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/30.7e13628f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/31.c4652f75.js"><link rel="prefetch" href="/linux-tutorial/assets/js/32.05d2cbec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/33.3b265df8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/34.26330a03.js"><link rel="prefetch" href="/linux-tutorial/assets/js/35.417d706d.js"><link rel="prefetch" href="/linux-tutorial/assets/js/36.0ed775e0.js"><link rel="prefetch" href="/linux-tutorial/assets/js/37.34430c74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/38.87d5e0ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/39.7b648b3e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/40.3b7a219e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/41.e727eee9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/42.0134c187.js"><link rel="prefetch" href="/linux-tutorial/assets/js/43.175e982f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/44.72d90888.js"><link rel="prefetch" href="/linux-tutorial/assets/js/45.d49955bd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/46.a9c290ec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/47.cc639f04.js"><link rel="prefetch" href="/linux-tutorial/assets/js/48.98c78321.js"><link rel="prefetch" href="/linux-tutorial/assets/js/49.a7c3afed.js"><link rel="prefetch" href="/linux-tutorial/assets/js/50.22d8c542.js"><link rel="prefetch" href="/linux-tutorial/assets/js/51.28055fcd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/52.f8103df5.js"><link rel="prefetch" href="/linux-tutorial/assets/js/53.76541550.js"><link rel="prefetch" href="/linux-tutorial/assets/js/54.e78d2776.js"><link rel="prefetch" href="/linux-tutorial/assets/js/55.3ce3079c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/56.832958c9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/57.961ce896.js"><link rel="prefetch" href="/linux-tutorial/assets/js/58.6d6fbc82.js"><link rel="prefetch" href="/linux-tutorial/assets/js/59.d5e48112.js"><link rel="prefetch" href="/linux-tutorial/assets/js/6.c8f4721c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/60.7927b23b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/61.ee233f24.js"><link rel="prefetch" href="/linux-tutorial/assets/js/62.6ba50cc7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/63.9cbf9f2b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/64.0be148a4.js"><link rel="prefetch" href="/linux-tutorial/assets/js/65.c520257e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/66.f2335390.js"><link rel="prefetch" href="/linux-tutorial/assets/js/67.e5737218.js"><link rel="prefetch" href="/linux-tutorial/assets/js/68.46427a01.js"><link rel="prefetch" href="/linux-tutorial/assets/js/69.450417bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/7.046e5a1b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/70.072034d2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/8.77fb8967.js"><link rel="prefetch" href="/linux-tutorial/assets/js/9.ebfa537e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~flowchart.20a64d45.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~notification.ea176280.js">
|
||||
<link rel="stylesheet" href="/linux-tutorial/assets/css/0.styles.45d9d031.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/linux-tutorial/" class="home-link router-link-active"><img src="images/dunwu-logo-100.png" alt="LINUX-TUTORIAL" class="logo"> <span class="site-name can-hide">LINUX-TUTORIAL</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link router-link-active">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link router-link-active">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Linux 文件内容查看编辑</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/linux-tutorial/linux/cli/linux-cli-file.html#_1-linux-文件内容查看编辑要点" class="sidebar-link">1. Linux 文件内容查看编辑要点</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/linux-tutorial/linux/cli/linux-cli-file.html#_2-命令常见用法" class="sidebar-link">2. 命令常见用法</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-file.html#_2-1-cat" class="sidebar-link">2.1. cat</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-file.html#_2-2-head" class="sidebar-link">2.2. head</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-file.html#_2-3-tail" class="sidebar-link">2.3. tail</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-file.html#_2-4-more" class="sidebar-link">2.4. more</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-file.html#_2-5-less" class="sidebar-link">2.5. less</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-file.html#_2-6-sed" class="sidebar-link">2.6. sed</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-file.html#_2-7-vi" class="sidebar-link">2.7. vi</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-file.html#_2-8-grep" class="sidebar-link">2.8. grep</a></li></ul></li><li><a href="/linux-tutorial/linux/cli/linux-cli-file.html#_3-参考资料" class="sidebar-link">3. 参考资料</a><ul class="sidebar-sub-headers"></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="linux-文件内容查看编辑"><a href="#linux-文件内容查看编辑" class="header-anchor">#</a> Linux 文件内容查看编辑</h1> <blockquote><p>关键词:<code>cat</code>, <code>head</code>, <code>tail</code>, <code>more</code>, <code>less</code>, <code>sed</code>, <code>vi</code>, <code>grep</code></p></blockquote> <h2 id="_1-linux-文件内容查看编辑要点"><a href="#_1-linux-文件内容查看编辑要点" class="header-anchor">#</a> 1. Linux 文件内容查看编辑要点</h2> <ul><li>连接文件并打印到标准输出设备 - 使用 <a href="#cat">cat</a></li> <li>显示指定文件的开头若干行 - 使用 <a href="#head">head</a></li> <li>显示指定文件的末尾若干行,常用于实时打印日志文件内容 - 使用 <a href="#tail">tail</a></li> <li>显示文件内容,每次显示一屏 - 使用 <a href="#more">more</a></li> <li>显示文件内容,每次显示一屏 - 使用 <a href="#less">less</a></li> <li>自动编辑一个或多个文件;简化对文件的反复操作;编写转换程序等 - 使用 <a href="#sed">sed</a></li> <li>文本编辑器 - 使用 <a href="#vi">vi</a></li> <li>使用正则表达式搜索文本,并把匹配的行打印出来 - 使用 <a href="#grep">grep</a></li></ul> <h2 id="_2-命令常见用法"><a href="#_2-命令常见用法" class="header-anchor">#</a> 2. 命令常见用法</h2> <h3 id="_2-1-cat"><a href="#_2-1-cat" class="header-anchor">#</a> 2.1. cat</h3> <blockquote><p>cat 命令用于连接文件并打印到标准输出设备上。</p> <p>参考:http://man.linuxde.net/cat</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">cat</span> m1 <span class="token comment"># 在屏幕上显示文件 ml 的内容</span>
|
||||
<span class="token function">cat</span> m1 m2 <span class="token comment"># 同时显示文件 ml 和 m2 的内容</span>
|
||||
<span class="token function">cat</span> m1 m2 <span class="token operator">></span> <span class="token function">file</span> <span class="token comment"># 将文件 ml 和 m2 合并后放入文件 file 中</span>
|
||||
</code></pre></div><h3 id="_2-2-head"><a href="#_2-2-head" class="header-anchor">#</a> 2.2. head</h3> <blockquote><p>head 命令用于显示文件的开头内容。在默认情况下,head 命令显示文件的头部 10 行内容。</p> <p>参考:http://man.linuxde.net/head</p></blockquote> <h3 id="_2-3-tail"><a href="#_2-3-tail" class="header-anchor">#</a> 2.3. tail</h3> <blockquote><p>tail 命令用于显示文件的尾部内容。在默认情况下,tail 命令显示文件的尾部 10 行内容。如果给定的文件不止一个,则在显示的每个文件前面加一个文件名标题。如果没有指定文件或者文件名为“-”,则读取标准输入。</p> <p>参考:http://man.linuxde.net/tail</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">tail</span> <span class="token function">file</span> <span class="token comment"># 显示文件file的最后10行</span>
|
||||
<span class="token function">tail</span> -n +20 <span class="token function">file</span> <span class="token comment"># 显示文件file的内容,从第20行至文件末尾</span>
|
||||
<span class="token function">tail</span> -c <span class="token number">10</span> <span class="token function">file</span> <span class="token comment"># 显示文件file的最后10个字符</span>
|
||||
</code></pre></div><h3 id="_2-4-more"><a href="#_2-4-more" class="header-anchor">#</a> 2.4. more</h3> <blockquote><p>more 命令是一个基于 vi 编辑器文本过滤器,它以全屏幕的方式按页显示文本文件的内容,支持 vi 中的关键字定位操作。more 名单中内置了若干快捷键,常用的有 H(获得帮助信息),Enter(向下翻滚一行),空格(向下滚动一屏),Q(退出命令)。</p> <p>该命令一次显示一屏文本,满屏后停下来,并且在屏幕的底部出现一个提示信息,给出至今己显示的该文件的百分比:--More--(XX%)可以用下列不同的方法对提示做出回答:</p> <ul><li>按 Space 键:显示文本的下一屏内容。</li> <li>按 Enier 键:只显示文本的下一行内容。</li> <li>按斜线符|:接着输入一个模式,可以在文本中寻找下一个相匹配的模式。</li> <li>按 H 键:显示帮助屏,该屏上有相关的帮助信息。</li> <li>按 B 键:显示上一屏内容。</li> <li>按 Q 键:退出 rnore 命令。</li></ul> <p>参考:http://man.linuxde.net/more</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 显示文件 file 的内容,但在显示之前先清屏,并且在屏幕的最下方显示完核的百分比。</span>
|
||||
<span class="token function">more</span> -dc <span class="token function">file</span>
|
||||
|
||||
<span class="token comment"># 显示文件 file 的内容,每 10 行显示一次,而且在显示之前先清屏。</span>
|
||||
<span class="token function">more</span> -c -10 <span class="token function">file</span>
|
||||
</code></pre></div><h3 id="_2-5-less"><a href="#_2-5-less" class="header-anchor">#</a> 2.5. less</h3> <p>less 命令的作用与 more 十分相似,都可以用来浏览文字档案的内容,不同的是 less 命令允许用户向前或向后浏览文件,而 more 命令只能向前浏览。用 less 命令显示文件时,用 PageUp 键向上翻页,用 PageDown 键向下翻页。要退出 less 程序,应按 Q 键。</p> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">less</span> /var/log/shadowsocks.log
|
||||
</code></pre></div><h3 id="_2-6-sed"><a href="#_2-6-sed" class="header-anchor">#</a> 2.6. sed</h3> <blockquote><p>sed 是一种流编辑器,它是文本处理工具,能够完美的配合正则表达式使用,功能不同凡响。处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用 sed 命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。接着处理下一行,这样不断重复,直到文件末尾。文件内容并没有改变,除非你使用重定向存储输出。Sed 主要用来自动编辑一个或多个文件;简化对文件的反复操作;编写转换程序等。</p> <p>参考:http://man.linuxde.net/sed</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 替换文本中的字符串</span>
|
||||
<span class="token function">sed</span> <span class="token string">'s/book/books/'</span> <span class="token function">file</span>
|
||||
|
||||
<span class="token comment"># -n 选项 和 p 命令 一起使用表示只打印那些发生替换的行</span>
|
||||
<span class="token function">sed</span> -n <span class="token string">'s/test/TEST/p'</span> <span class="token function">file</span>
|
||||
|
||||
<span class="token comment"># 直接编辑文件选项 -i ,会匹配 file 文件中每一行的第一个 book 替换为 books</span>
|
||||
<span class="token function">sed</span> -i <span class="token string">'s/book/books/g'</span> <span class="token function">file</span>
|
||||
|
||||
<span class="token comment"># 使用后缀 /g 标记会替换每一行中的所有匹配</span>
|
||||
<span class="token function">sed</span> <span class="token string">'s/book/books/g'</span> <span class="token function">file</span>
|
||||
|
||||
<span class="token comment"># 删除空白行</span>
|
||||
<span class="token function">sed</span> <span class="token string">'/^$/d'</span> <span class="token function">file</span>
|
||||
|
||||
<span class="token comment"># 删除文件的第2行</span>
|
||||
<span class="token function">sed</span> <span class="token string">'2d'</span> <span class="token function">file</span>
|
||||
|
||||
<span class="token comment"># 删除文件的第2行到末尾所有行</span>
|
||||
<span class="token function">sed</span> <span class="token string">'2,<span class="token variable">$d</span>'</span> <span class="token function">file</span>
|
||||
|
||||
<span class="token comment"># 删除文件最后一行</span>
|
||||
<span class="token function">sed</span> <span class="token string">'<span class="token variable">$d</span>'</span> <span class="token function">file</span>
|
||||
|
||||
<span class="token comment"># 删除文件中所有开头是test的行</span>
|
||||
<span class="token function">sed</span> <span class="token string">'/^test/'</span>d <span class="token function">file</span>
|
||||
</code></pre></div><h3 id="_2-7-vi"><a href="#_2-7-vi" class="header-anchor">#</a> 2.7. vi</h3> <blockquote><p>vi 命令是 UNIX 操作系统和类 UNIX 操作系统中最通用的全屏幕纯文本编辑器。Linux 中的 vi 编辑器叫 vim,它是 vi 的增强版(vi Improved),与 vi 编辑器完全兼容,而且实现了很多增强功能。</p> <p>参考:http://man.linuxde.net/vi</p> <p>引申阅读:<a href="https://github.com/dunwu/OS/blob/master/docs/vim.md" target="_blank" rel="noopener noreferrer">Vim 入门指南<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></blockquote> <h3 id="_2-8-grep"><a href="#_2-8-grep" class="header-anchor">#</a> 2.8. grep</h3> <blockquote><p>grep(global search regular expression(RE) and print out the line,全面搜索正则表达式并把行打印出来)是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来。</p> <p>参考:http://man.linuxde.net/grep</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 在多级目录中对文本递归搜索(程序员搜代码的最爱):</span>
|
||||
$ <span class="token function">grep</span> <span class="token string">"class"</span> <span class="token builtin class-name">.</span> -R -n
|
||||
|
||||
<span class="token comment"># 忽略匹配样式中的字符大小写</span>
|
||||
$ <span class="token builtin class-name">echo</span> <span class="token string">"hello world"</span> <span class="token operator">|</span> <span class="token function">grep</span> -i <span class="token string">"HELLO"</span>
|
||||
|
||||
<span class="token comment"># 匹配多个模式:</span>
|
||||
$ <span class="token function">grep</span> -e <span class="token string">"class"</span> -e <span class="token string">"vitural"</span> <span class="token function">file</span>
|
||||
|
||||
<span class="token comment"># 只在目录中所有的.php和.html文件中递归搜索字符"main()"</span>
|
||||
$ <span class="token function">grep</span> <span class="token string">"main()"</span> <span class="token builtin class-name">.</span> -r --include *.<span class="token punctuation">{</span>php,html<span class="token punctuation">}</span>
|
||||
|
||||
<span class="token comment"># 在搜索结果中排除所有README文件</span>
|
||||
$ <span class="token function">grep</span> <span class="token string">"main()"</span> <span class="token builtin class-name">.</span> -r --exclude <span class="token string">"README"</span>
|
||||
|
||||
<span class="token comment"># 在搜索结果中排除filelist文件列表里的文件</span>
|
||||
$ <span class="token function">grep</span> <span class="token string">"main()"</span> <span class="token builtin class-name">.</span> -r --exclude-from filelist
|
||||
</code></pre></div><h2 id="_3-参考资料"><a href="#_3-参考资料" class="header-anchor">#</a> 3. 参考资料</h2> <ul><li><a href="http://man.linuxde.net/" target="_blank" rel="noopener noreferrer">Linux 命令大全<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/dunwu/linux-tutorial/edit/master/docs/linux/cli/linux-cli-file.md" target="_blank" rel="noopener noreferrer">帮助我们改善此页面!</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">a year ago</span></div></footer> <!----> </main></div><div class="global-ui"><!----><!----></div></div>
|
||||
<script src="/linux-tutorial/assets/js/app.79a38eea.js" defer></script><script src="/linux-tutorial/assets/js/4.fb6e0f89.js" defer></script><script src="/linux-tutorial/assets/js/26.96164082.js" defer></script><script src="/linux-tutorial/assets/js/5.cb43ecfb.js" defer></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,134 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Linux 硬件管理 | LINUX-TUTORIAL</title>
|
||||
<meta name="generator" content="VuePress 1.8.2">
|
||||
<link rel="icon" href="/linux-tutorial/favicon.ico">
|
||||
<meta name="description" content="数据库教程">
|
||||
|
||||
<link rel="preload" href="/linux-tutorial/assets/css/0.styles.45d9d031.css" as="style"><link rel="preload" href="/linux-tutorial/assets/js/app.79a38eea.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/4.fb6e0f89.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/27.391033bb.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/5.cb43ecfb.js" as="script"><link rel="prefetch" href="/linux-tutorial/assets/js/10.7933187b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/11.b9b41530.js"><link rel="prefetch" href="/linux-tutorial/assets/js/12.70a5dba8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/13.857dcc43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/14.5a603a55.js"><link rel="prefetch" href="/linux-tutorial/assets/js/15.d217acb7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/16.ad565eae.js"><link rel="prefetch" href="/linux-tutorial/assets/js/17.d43e9f56.js"><link rel="prefetch" href="/linux-tutorial/assets/js/18.aa00ff43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/19.43ce44b3.js"><link rel="prefetch" href="/linux-tutorial/assets/js/20.5618e1ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/21.1c5a41d7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/22.fbe9fdf1.js"><link rel="prefetch" href="/linux-tutorial/assets/js/23.a4fb0e74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/24.e3a23b69.js"><link rel="prefetch" href="/linux-tutorial/assets/js/25.9896afe9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/26.96164082.js"><link rel="prefetch" href="/linux-tutorial/assets/js/28.703f74c2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/29.02a952cb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/30.7e13628f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/31.c4652f75.js"><link rel="prefetch" href="/linux-tutorial/assets/js/32.05d2cbec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/33.3b265df8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/34.26330a03.js"><link rel="prefetch" href="/linux-tutorial/assets/js/35.417d706d.js"><link rel="prefetch" href="/linux-tutorial/assets/js/36.0ed775e0.js"><link rel="prefetch" href="/linux-tutorial/assets/js/37.34430c74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/38.87d5e0ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/39.7b648b3e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/40.3b7a219e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/41.e727eee9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/42.0134c187.js"><link rel="prefetch" href="/linux-tutorial/assets/js/43.175e982f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/44.72d90888.js"><link rel="prefetch" href="/linux-tutorial/assets/js/45.d49955bd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/46.a9c290ec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/47.cc639f04.js"><link rel="prefetch" href="/linux-tutorial/assets/js/48.98c78321.js"><link rel="prefetch" href="/linux-tutorial/assets/js/49.a7c3afed.js"><link rel="prefetch" href="/linux-tutorial/assets/js/50.22d8c542.js"><link rel="prefetch" href="/linux-tutorial/assets/js/51.28055fcd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/52.f8103df5.js"><link rel="prefetch" href="/linux-tutorial/assets/js/53.76541550.js"><link rel="prefetch" href="/linux-tutorial/assets/js/54.e78d2776.js"><link rel="prefetch" href="/linux-tutorial/assets/js/55.3ce3079c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/56.832958c9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/57.961ce896.js"><link rel="prefetch" href="/linux-tutorial/assets/js/58.6d6fbc82.js"><link rel="prefetch" href="/linux-tutorial/assets/js/59.d5e48112.js"><link rel="prefetch" href="/linux-tutorial/assets/js/6.c8f4721c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/60.7927b23b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/61.ee233f24.js"><link rel="prefetch" href="/linux-tutorial/assets/js/62.6ba50cc7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/63.9cbf9f2b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/64.0be148a4.js"><link rel="prefetch" href="/linux-tutorial/assets/js/65.c520257e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/66.f2335390.js"><link rel="prefetch" href="/linux-tutorial/assets/js/67.e5737218.js"><link rel="prefetch" href="/linux-tutorial/assets/js/68.46427a01.js"><link rel="prefetch" href="/linux-tutorial/assets/js/69.450417bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/7.046e5a1b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/70.072034d2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/8.77fb8967.js"><link rel="prefetch" href="/linux-tutorial/assets/js/9.ebfa537e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~flowchart.20a64d45.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~notification.ea176280.js">
|
||||
<link rel="stylesheet" href="/linux-tutorial/assets/css/0.styles.45d9d031.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/linux-tutorial/" class="home-link router-link-active"><img src="images/dunwu-logo-100.png" alt="LINUX-TUTORIAL" class="logo"> <span class="site-name can-hide">LINUX-TUTORIAL</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link router-link-active">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link router-link-active">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Linux 硬件管理</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/linux-tutorial/linux/cli/linux-cli-hardware.html#_1-linux-硬件管理要点" class="sidebar-link">1. Linux 硬件管理要点</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/linux-tutorial/linux/cli/linux-cli-hardware.html#_2-命令常见用法" class="sidebar-link">2. 命令常见用法</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-hardware.html#_2-1-df" class="sidebar-link">2.1. df</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-hardware.html#_2-2-du" class="sidebar-link">2.2. du</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-hardware.html#_2-3-top" class="sidebar-link">2.3. top</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-hardware.html#_2-4-free" class="sidebar-link">2.4. free</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-hardware.html#_2-5-iotop" class="sidebar-link">2.5. iotop</a></li></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="linux-硬件管理"><a href="#linux-硬件管理" class="header-anchor">#</a> Linux 硬件管理</h1> <blockquote><p>关键词:<code>df</code>, <code>du</code>, <code>top</code>, <code>free</code>, <code>iotop</code></p></blockquote> <h2 id="_1-linux-硬件管理要点"><a href="#_1-linux-硬件管理要点" class="header-anchor">#</a> 1. Linux 硬件管理要点</h2> <ul><li>查看磁盘空间 - 使用 <a href="#df">df</a></li> <li>查看文件或目录的磁盘空间 - 使用 <a href="#du">du</a></li> <li>实时查看系统整体运行状态(如:CPU、内存) - 使用 <a href="#top">top</a></li> <li>查看已使用和未使用的内存 - 使用 <a href="#free">free</a></li> <li>查看磁盘 I/O 使用状况 - 使用 <a href="#iotop">iotop</a></li></ul> <h2 id="_2-命令常见用法"><a href="#_2-命令常见用法" class="header-anchor">#</a> 2. 命令常见用法</h2> <h3 id="_2-1-df"><a href="#_2-1-df" class="header-anchor">#</a> 2.1. df</h3> <blockquote><p>df 命令用于显示磁盘分区上的可使用的磁盘空间。默认显示单位为 KB。可以利用该命令来获取硬盘被占用了多少空间,目前还剩下多少空间等信息。</p> <p>参考:http://man.linuxde.net/df</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 查看系统磁盘设备,默认是 KB 为单位</span>
|
||||
<span class="token punctuation">[</span>root@LinServ-1 ~<span class="token punctuation">]</span><span class="token comment"># df</span>
|
||||
文件系统 1K-块 已用 可用 已用% 挂载点
|
||||
/dev/sda2 <span class="token number">146294492</span> <span class="token number">28244432</span> <span class="token number">110498708</span> <span class="token number">21</span>% /
|
||||
/dev/sda1 <span class="token number">1019208</span> <span class="token number">62360</span> <span class="token number">904240</span> <span class="token number">7</span>% /boot
|
||||
tmpfs <span class="token number">1032204</span> <span class="token number">0</span> <span class="token number">1032204</span> <span class="token number">0</span>% /dev/shm
|
||||
/dev/sdb1 <span class="token number">2884284108</span> <span class="token number">218826068</span> <span class="token number">2518944764</span> <span class="token number">8</span>% /data1
|
||||
|
||||
<span class="token comment"># 使用 -h 选项以 KB 以上的单位来显示,可读性高</span>
|
||||
<span class="token punctuation">[</span>root@LinServ-1 ~<span class="token punctuation">]</span><span class="token comment"># df -h</span>
|
||||
文件系统 容量 已用 可用 已用% 挂载点
|
||||
/dev/sda2 140G 27G 106G <span class="token number">21</span>% /
|
||||
/dev/sda1 996M 61M 884M <span class="token number">7</span>% /boot
|
||||
tmpfs 1009M <span class="token number">0</span> 1009M <span class="token number">0</span>% /dev/shm
|
||||
/dev/sdb1 <span class="token number">2</span>.7T 209G <span class="token number">2</span>.4T <span class="token number">8</span>% /data1
|
||||
|
||||
<span class="token comment"># 查看全部文件系统</span>
|
||||
<span class="token punctuation">[</span>root@LinServ-1 ~<span class="token punctuation">]</span><span class="token comment"># df -a</span>
|
||||
文件系统 1K-块 已用 可用 已用% 挂载点
|
||||
/dev/sda2 <span class="token number">146294492</span> <span class="token number">28244432</span> <span class="token number">110498708</span> <span class="token number">21</span>% /
|
||||
proc <span class="token number">0</span> <span class="token number">0</span> <span class="token number">0</span> - /proc
|
||||
sysfs <span class="token number">0</span> <span class="token number">0</span> <span class="token number">0</span> - /sys
|
||||
devpts <span class="token number">0</span> <span class="token number">0</span> <span class="token number">0</span> - /dev/pts
|
||||
/dev/sda1 <span class="token number">1019208</span> <span class="token number">62360</span> <span class="token number">904240</span> <span class="token number">7</span>% /boot
|
||||
tmpfs <span class="token number">1032204</span> <span class="token number">0</span> <span class="token number">1032204</span> <span class="token number">0</span>% /dev/shm
|
||||
/dev/sdb1 <span class="token number">2884284108</span> <span class="token number">218826068</span> <span class="token number">2518944764</span> <span class="token number">8</span>% /data1
|
||||
none <span class="token number">0</span> <span class="token number">0</span> <span class="token number">0</span> - /proc/sys/fs/binfmt_misc
|
||||
</code></pre></div><h3 id="_2-2-du"><a href="#_2-2-du" class="header-anchor">#</a> 2.2. du</h3> <blockquote><p>du 命令也是查看使用空间的,但是与 df 命令不同的是:du 命令是对文件和目录磁盘使用的空间的查看,还是和 df 命令有一些区别的。</p> <p>参考:http://man.linuxde.net/du</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 显示目录或者文件所占空间</span>
|
||||
root@localhost <span class="token punctuation">[</span>test<span class="token punctuation">]</span><span class="token comment"># du</span>
|
||||
<span class="token number">608</span> ./test6
|
||||
<span class="token number">308</span> ./test4
|
||||
<span class="token number">4</span> ./scf/lib
|
||||
<span class="token number">4</span> ./scf/service/deploy/product
|
||||
<span class="token number">4</span> ./scf/service/deploy/info
|
||||
<span class="token number">12</span> ./scf/service/deploy
|
||||
<span class="token number">16</span> ./scf/service
|
||||
<span class="token number">4</span> ./scf/doc
|
||||
<span class="token number">4</span> ./scf/bin
|
||||
<span class="token number">32</span> ./scf
|
||||
<span class="token number">8</span> ./test3
|
||||
<span class="token number">1288</span> <span class="token builtin class-name">.</span>
|
||||
|
||||
<span class="token comment"># 显示指定文件所占空间</span>
|
||||
<span class="token punctuation">[</span>root@localhost test<span class="token punctuation">]</span><span class="token comment"># du log2012.log</span>
|
||||
<span class="token number">300</span> log2012.log
|
||||
|
||||
<span class="token comment"># 查看指定目录的所占空间</span>
|
||||
<span class="token punctuation">[</span>root@localhost test<span class="token punctuation">]</span><span class="token comment"># du scf</span>
|
||||
<span class="token number">4</span> scf/lib
|
||||
<span class="token number">4</span> scf/service/deploy/product
|
||||
<span class="token number">4</span> scf/service/deploy/info
|
||||
<span class="token number">12</span> scf/service/deploy
|
||||
<span class="token number">16</span> scf/service
|
||||
<span class="token number">4</span> scf/doc
|
||||
<span class="token number">4</span> scf/bin
|
||||
<span class="token number">32</span> scf
|
||||
|
||||
<span class="token comment"># 显示多个文件所占空间</span>
|
||||
<span class="token punctuation">[</span>root@localhost test<span class="token punctuation">]</span><span class="token comment"># du log30.tar.gz log31.tar.gz</span>
|
||||
<span class="token number">4</span> log30.tar.gz
|
||||
<span class="token number">4</span> log31.tar.gz
|
||||
|
||||
<span class="token comment"># 只显示总和的大小</span>
|
||||
<span class="token punctuation">[</span>root@localhost test<span class="token punctuation">]</span><span class="token comment"># du -s</span>
|
||||
<span class="token number">1288</span> <span class="token builtin class-name">.</span>
|
||||
|
||||
<span class="token punctuation">[</span>root@localhost test<span class="token punctuation">]</span><span class="token comment"># du -s scf</span>
|
||||
<span class="token number">32</span> scf
|
||||
</code></pre></div><h3 id="_2-3-top"><a href="#_2-3-top" class="header-anchor">#</a> 2.3. top</h3> <blockquote><p>top 命令可以实时动态地查看系统的整体运行情况,是一个综合了多方信息监测系统性能和运行信息的实用工具。通过 top 命令所提供的互动式界面,用热键可以管理。</p> <p>参考:http://man.linuxde.net/top</p></blockquote> <h3 id="_2-4-free"><a href="#_2-4-free" class="header-anchor">#</a> 2.4. free</h3> <blockquote><p>free 命令可以显示当前系统未使用的和已使用的内存数目,还可以显示被内核使用的内存缓冲区。</p> <p>参考:http://man.linuxde.net/free</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">free</span> -t <span class="token comment"># 以总和的形式显示内存的使用信息</span>
|
||||
<span class="token function">free</span> -s <span class="token number">10</span> <span class="token comment"># 周期性的查询内存使用信息,每10s 执行一次命令</span>
|
||||
|
||||
<span class="token comment"># 显示内存使用情况</span>
|
||||
|
||||
<span class="token function">free</span> -m
|
||||
total used <span class="token function">free</span> shared buffers cached
|
||||
Mem: <span class="token number">2016</span> <span class="token number">1973</span> <span class="token number">42</span> <span class="token number">0</span> <span class="token number">163</span> <span class="token number">1497</span>
|
||||
-/+ buffers/cache: <span class="token number">312</span> <span class="token number">1703</span>
|
||||
Swap: <span class="token number">4094</span> <span class="token number">0</span> <span class="token number">4094</span>
|
||||
</code></pre></div><h3 id="_2-5-iotop"><a href="#_2-5-iotop" class="header-anchor">#</a> 2.5. iotop</h3> <blockquote><p>iotop 命令是一个用来监视磁盘 I/O 使用状况的 top 类工具。iotop 具有与 top 相似的 UI,其中包括 PID、用户、I/O、进程等相关信息。Linux 下的 IO 统计工具如 iostat,nmon 等大多数是只能统计到 per 设备的读写情况,如果你想知道每个进程是如何使用 IO 的就比较麻烦,使用 iotop 命令可以很方便的查看。</p> <p>参考:http://man.linuxde.net/iotop</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code>Total DISK read: <span class="token number">0.00</span> B/s <span class="token operator">|</span> Total DISK write: <span class="token number">0.00</span> B/s
|
||||
TID PRIO <span class="token environment constant">USER</span> DISK READ DISK WRITE SWAPIN IO<span class="token operator">></span> <span class="token builtin class-name">command</span>
|
||||
<span class="token number">1</span> be/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % init <span class="token punctuation">[</span><span class="token number">3</span><span class="token punctuation">]</span>
|
||||
<span class="token number">2</span> be/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>kthreadd<span class="token punctuation">]</span>
|
||||
<span class="token number">3</span> rt/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>migration/0<span class="token punctuation">]</span>
|
||||
<span class="token number">4</span> be/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>ksoftirqd/0<span class="token punctuation">]</span>
|
||||
<span class="token number">5</span> rt/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>watchdog/0<span class="token punctuation">]</span>
|
||||
<span class="token number">6</span> rt/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>migration/1<span class="token punctuation">]</span>
|
||||
<span class="token number">7</span> be/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>ksoftirqd/1<span class="token punctuation">]</span>
|
||||
<span class="token number">8</span> rt/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>watchdog/1<span class="token punctuation">]</span>
|
||||
<span class="token number">9</span> be/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>events/0<span class="token punctuation">]</span>
|
||||
<span class="token number">10</span> be/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>events/1<span class="token punctuation">]</span>
|
||||
<span class="token number">11</span> be/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>khelper<span class="token punctuation">]</span>
|
||||
<span class="token number">2572</span> be/4 root <span class="token number">0.00</span> B/s <span class="token number">0.00</span> B/s <span class="token number">0.00</span> % <span class="token number">0.00</span> % <span class="token punctuation">[</span>bluetooth<span class="token punctuation">]</span>
|
||||
</code></pre></div></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/dunwu/linux-tutorial/edit/master/docs/linux/cli/linux-cli-hardware.md" target="_blank" rel="noopener noreferrer">帮助我们改善此页面!</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">a year ago</span></div></footer> <!----> </main></div><div class="global-ui"><!----><!----></div></div>
|
||||
<script src="/linux-tutorial/assets/js/app.79a38eea.js" defer></script><script src="/linux-tutorial/assets/js/4.fb6e0f89.js" defer></script><script src="/linux-tutorial/assets/js/27.391033bb.js" defer></script><script src="/linux-tutorial/assets/js/5.cb43ecfb.js" defer></script>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,107 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Linux 软件管理 | LINUX-TUTORIAL</title>
|
||||
<meta name="generator" content="VuePress 1.8.2">
|
||||
<link rel="icon" href="/linux-tutorial/favicon.ico">
|
||||
<meta name="description" content="数据库教程">
|
||||
|
||||
<link rel="preload" href="/linux-tutorial/assets/css/0.styles.45d9d031.css" as="style"><link rel="preload" href="/linux-tutorial/assets/js/app.79a38eea.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/4.fb6e0f89.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/30.7e13628f.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/5.cb43ecfb.js" as="script"><link rel="prefetch" href="/linux-tutorial/assets/js/10.7933187b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/11.b9b41530.js"><link rel="prefetch" href="/linux-tutorial/assets/js/12.70a5dba8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/13.857dcc43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/14.5a603a55.js"><link rel="prefetch" href="/linux-tutorial/assets/js/15.d217acb7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/16.ad565eae.js"><link rel="prefetch" href="/linux-tutorial/assets/js/17.d43e9f56.js"><link rel="prefetch" href="/linux-tutorial/assets/js/18.aa00ff43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/19.43ce44b3.js"><link rel="prefetch" href="/linux-tutorial/assets/js/20.5618e1ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/21.1c5a41d7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/22.fbe9fdf1.js"><link rel="prefetch" href="/linux-tutorial/assets/js/23.a4fb0e74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/24.e3a23b69.js"><link rel="prefetch" href="/linux-tutorial/assets/js/25.9896afe9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/26.96164082.js"><link rel="prefetch" href="/linux-tutorial/assets/js/27.391033bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/28.703f74c2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/29.02a952cb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/31.c4652f75.js"><link rel="prefetch" href="/linux-tutorial/assets/js/32.05d2cbec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/33.3b265df8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/34.26330a03.js"><link rel="prefetch" href="/linux-tutorial/assets/js/35.417d706d.js"><link rel="prefetch" href="/linux-tutorial/assets/js/36.0ed775e0.js"><link rel="prefetch" href="/linux-tutorial/assets/js/37.34430c74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/38.87d5e0ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/39.7b648b3e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/40.3b7a219e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/41.e727eee9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/42.0134c187.js"><link rel="prefetch" href="/linux-tutorial/assets/js/43.175e982f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/44.72d90888.js"><link rel="prefetch" href="/linux-tutorial/assets/js/45.d49955bd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/46.a9c290ec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/47.cc639f04.js"><link rel="prefetch" href="/linux-tutorial/assets/js/48.98c78321.js"><link rel="prefetch" href="/linux-tutorial/assets/js/49.a7c3afed.js"><link rel="prefetch" href="/linux-tutorial/assets/js/50.22d8c542.js"><link rel="prefetch" href="/linux-tutorial/assets/js/51.28055fcd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/52.f8103df5.js"><link rel="prefetch" href="/linux-tutorial/assets/js/53.76541550.js"><link rel="prefetch" href="/linux-tutorial/assets/js/54.e78d2776.js"><link rel="prefetch" href="/linux-tutorial/assets/js/55.3ce3079c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/56.832958c9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/57.961ce896.js"><link rel="prefetch" href="/linux-tutorial/assets/js/58.6d6fbc82.js"><link rel="prefetch" href="/linux-tutorial/assets/js/59.d5e48112.js"><link rel="prefetch" href="/linux-tutorial/assets/js/6.c8f4721c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/60.7927b23b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/61.ee233f24.js"><link rel="prefetch" href="/linux-tutorial/assets/js/62.6ba50cc7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/63.9cbf9f2b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/64.0be148a4.js"><link rel="prefetch" href="/linux-tutorial/assets/js/65.c520257e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/66.f2335390.js"><link rel="prefetch" href="/linux-tutorial/assets/js/67.e5737218.js"><link rel="prefetch" href="/linux-tutorial/assets/js/68.46427a01.js"><link rel="prefetch" href="/linux-tutorial/assets/js/69.450417bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/7.046e5a1b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/70.072034d2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/8.77fb8967.js"><link rel="prefetch" href="/linux-tutorial/assets/js/9.ebfa537e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~flowchart.20a64d45.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~notification.ea176280.js">
|
||||
<link rel="stylesheet" href="/linux-tutorial/assets/css/0.styles.45d9d031.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/linux-tutorial/" class="home-link router-link-active"><img src="images/dunwu-logo-100.png" alt="LINUX-TUTORIAL" class="logo"> <span class="site-name can-hide">LINUX-TUTORIAL</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link router-link-active">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link router-link-active">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Linux 软件管理</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/linux-tutorial/linux/cli/linux-cli-software.html#_1-rpm" class="sidebar-link">1. rpm</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/linux-tutorial/linux/cli/linux-cli-software.html#_2-yum" class="sidebar-link">2. yum</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-software.html#_2-1-yum-源" class="sidebar-link">2.1. yum 源</a></li></ul></li><li><a href="/linux-tutorial/linux/cli/linux-cli-software.html#_3-apt-get" class="sidebar-link">3. apt-get</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/linux-tutorial/linux/cli/linux-cli-software.html#_4-参考资料" class="sidebar-link">4. 参考资料</a><ul class="sidebar-sub-headers"></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="linux-软件管理"><a href="#linux-软件管理" class="header-anchor">#</a> Linux 软件管理</h1> <blockquote><p>关键词:<code>rpm</code>, <code>yum</code>, <code>apt-get</code></p></blockquote> <h2 id="_1-rpm"><a href="#_1-rpm" class="header-anchor">#</a> 1. rpm</h2> <blockquote><p>rpm 命令是 RPM 软件包的管理工具。rpm 原本是 Red Hat Linux 发行版专门用来管理 Linux 各项套件的程序,由于它遵循 GPL 规则且功能强大方便,因而广受欢迎。逐渐受到其他发行版的采用。RPM 套件管理方式的出现,让 Linux 易于安装,升级,间接提升了 Linux 的适用度。</p> <p>参考:http://man.linuxde.net/rpm</p></blockquote> <p>示例:</p> <p>(1)安装 rpm 包</p> <div class="language- extra-class"><pre class="language-text"><code>rpm -ivh xxx.rpm
|
||||
</code></pre></div><p>(2)安装.src.rpm 软件包</p> <p>这类软件包是包含了源代码的 rpm 包,在安装时需要进行编译</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">rpm</span> -i xxx.src.rpm
|
||||
<span class="token builtin class-name">cd</span> /usr/src/redhat/SPECS
|
||||
rpmbuild -bp xxx.specs <span class="token comment">#一个和你的软件包同名的specs文件</span>
|
||||
<span class="token builtin class-name">cd</span> /usr/src/redhat/BUILD/xxx/ <span class="token comment">#一个和你的软件包同名的目录</span>
|
||||
./configure <span class="token comment">#这一步和编译普通的源码软件一样,可以加上参数</span>
|
||||
<span class="token function">make</span>
|
||||
<span class="token function">make</span> <span class="token function">install</span>
|
||||
</code></pre></div><p>(3)卸载 rpm 软件包</p> <p>使用命令 <code>rpm -e 包名</code>,包名可以包含版本号等信息,但是不可以有后缀.rpm,比如卸载软件包 proftpd-1.2.8-1,可以使用下列格式:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">rpm</span> -e proftpd-1.2.8-1
|
||||
<span class="token function">rpm</span> -e proftpd-1.2.8
|
||||
<span class="token function">rpm</span> -e proftpd-
|
||||
<span class="token function">rpm</span> -e proftpd
|
||||
</code></pre></div><p>不可以是下列格式:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">rpm</span> -e proftpd-1.2.8-1.i386.rpm
|
||||
<span class="token function">rpm</span> -e proftpd-1.2.8-1.i386
|
||||
<span class="token function">rpm</span> -e proftpd-1.2
|
||||
<span class="token function">rpm</span> -e proftpd-1
|
||||
</code></pre></div><p>有时会出现一些错误或者警告:</p> <div class="language- extra-class"><pre class="language-text"><code>... is needed by ...
|
||||
</code></pre></div><p>这说明这个软件被其他软件需要,不能随便卸载,可以用 rpm -e --nodeps 强制卸载</p> <p>(4)查看与 rpm 包相关的文件和其他信息</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">rpm</span> -qa <span class="token comment"># 列出所有安装过的包</span>
|
||||
</code></pre></div><h2 id="_2-yum"><a href="#_2-yum" class="header-anchor">#</a> 2. yum</h2> <blockquote><p>yum 命令是在 Fedora 和 RedHat 以及 SUSE 中基于 rpm 的软件包管理器,它可以使系统管理人员交互和自动化地更细与管理 RPM 软件包,能够从指定的服务器自动下载 RPM 包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软体包,无须繁琐地一次次下载、安装。</p> <p>参考:http://man.linuxde.net/yum</p></blockquote> <p>示例:</p> <p>部分常用的命令包括:</p> <ul><li>自动搜索最快镜像插件:<code>yum install yum-fastestmirror</code></li> <li>安装 yum 图形窗口插件:<code>yum install yumex</code></li> <li>查看可能批量安装的列表:<code>yum grouplist</code></li></ul> <p><strong>安装</strong></p> <div class="language- extra-class"><pre class="language-text"><code>yum install #全部安装
|
||||
yum install package1 #安装指定的安装包package1
|
||||
yum groupinsall group1 #安装程序组group1
|
||||
</code></pre></div><p><strong>更新和升级</strong></p> <div class="language- extra-class"><pre class="language-text"><code>yum update #全部更新
|
||||
yum update package1 #更新指定程序包package1
|
||||
yum check-update #检查可更新的程序
|
||||
yum upgrade package1 #升级指定程序包package1
|
||||
yum groupupdate group1 #升级程序组group1
|
||||
</code></pre></div><p><strong>查找和显示</strong></p> <div class="language- extra-class"><pre class="language-text"><code>yum info package1 #显示安装包信息package1
|
||||
yum list #显示所有已经安装和可以安装的程序包
|
||||
yum list package1 #显示指定程序包安装情况package1
|
||||
yum groupinfo group1 #显示程序组group1信息yum search string 根据关键字string查找安装包
|
||||
yum search <keyword> #查找软件包
|
||||
</code></pre></div><p><strong>删除程序</strong></p> <div class="language- extra-class"><pre class="language-text"><code>yum remove <package_name> #删除程序包package_name
|
||||
yum groupremove group1 #删除程序组group1
|
||||
yum deplist package1 #查看程序package1依赖情况
|
||||
</code></pre></div><p><strong>清除缓存</strong></p> <div class="language- extra-class"><pre class="language-text"><code>yum clean packages #清除缓存目录下的软件包
|
||||
yum clean headers #清除缓存目录下的 headers
|
||||
yum clean oldheaders #清除缓存目录下旧的 headers
|
||||
</code></pre></div><h3 id="_2-1-yum-源"><a href="#_2-1-yum-源" class="header-anchor">#</a> 2.1. yum 源</h3> <p>yum 的默认源是国外的,下载速度比较慢,所以最好替换为一个国内的 yum 源。</p> <table><thead><tr><th>推荐 yum 国内源</th> <th>源地址</th></tr></thead> <tbody><tr><td><a href="http://mirrors.163.com/" target="_blank" rel="noopener noreferrer">http://mirrors.163.com/<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></td> <td>Centos6:http://mirrors.aliyun.com/repo/Centos-6.repo<br>Centos7:http://mirrors.aliyun.com/repo/Centos-7.repo</td></tr> <tr><td><a href="http://mirrors.aliyun.com/" target="_blank" rel="noopener noreferrer">http://mirrors.aliyun.com/<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></td> <td>Centos6:http://mirrors.163.com/.help/CentOS6-Base-163.repo<br>Centos7:http://mirrors.163.com/.help/CentOS7-Base-163.repo</td></tr></tbody></table> <blockquote><p>🔔 注意:Cento5 已废弃,只能使用 http://vault.centos.org/ 替换,但由于是国外镜像,速度较慢。</p></blockquote> <p>替换方法,以 aliyun CentOS7 为例:</p> <div class="language- extra-class"><pre class="language-text"><code>cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
|
||||
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
|
||||
yum clean all
|
||||
yum makecache
|
||||
</code></pre></div><h2 id="_3-apt-get"><a href="#_3-apt-get" class="header-anchor">#</a> 3. apt-get</h2> <blockquote><p>apt-get 命令是 Debian Linux 发行版中的 APT 软件包管理工具。所有基于 Debian 的发行都使用这个包管理系统。deb 包可以把一个应用的文件包在一起,大体就如同 Windows 上的安装文件。</p> <p>参考:http://man.linuxde.net/apt-get</p></blockquote> <p>示例:</p> <p>使用 apt-get 命令的第一步就是引入必需的软件库,Debian 的软件库也就是所有 Debian 软件包的集合,它们存在互联网上的一些公共站点上。把它们的地址加入,apt-get 就能搜索到我们想要的软件。/etc/apt/sources.list 是存放这些地址列表的配置文件,其格式如下:</p> <p>deb [web 或 ftp 地址][发行版名字] [main/contrib/non-free]
|
||||
我们常用的 Ubuntu 就是一个基于 Debian 的发行,我们使用 apt-get 命令获取这个列表,以下是我整理的常用命令:</p> <p>在修改 /etc/apt/sources.list 或者 /etc/apt/preferences 之后运行该命令。</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 更新 apt-get</span>
|
||||
<span class="token function">apt-get</span> update
|
||||
|
||||
<span class="token comment"># 安装一个软件包</span>
|
||||
<span class="token function">apt-get</span> <span class="token function">install</span> packagename
|
||||
|
||||
<span class="token comment"># 卸载一个已安装的软件包(保留配置文件)</span>
|
||||
<span class="token function">apt-get</span> remove packagename
|
||||
|
||||
<span class="token comment"># 卸载一个已安装的软件包(删除配置文件)</span>
|
||||
<span class="token function">apt-get</span> –purge remove packagename
|
||||
|
||||
<span class="token comment"># 如果需要空间的话,可以让这个命令来删除你已经删掉的软件</span>
|
||||
<span class="token function">apt-get</span> autoclean <span class="token function">apt</span>
|
||||
|
||||
<span class="token comment"># 把安装的软件的备份也删除,不过这样不会影响软件的使用的</span>
|
||||
<span class="token function">apt-get</span> clean
|
||||
|
||||
<span class="token comment"># 更新所有已安装的软件包</span>
|
||||
<span class="token function">apt-get</span> upgrade
|
||||
|
||||
<span class="token comment"># 将系统升级到新版本</span>
|
||||
<span class="token function">apt-get</span> dist-upgrade
|
||||
</code></pre></div><h2 id="_4-参考资料"><a href="#_4-参考资料" class="header-anchor">#</a> 4. 参考资料</h2> <ul><li>http://man.linuxde.net/rpm</li> <li>http://man.linuxde.net/yum</li> <li>http://man.linuxde.net/apt-get</li> <li>http://www.runoob.com/linux/linux-yum.html</li></ul></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/dunwu/linux-tutorial/edit/master/docs/linux/cli/linux-cli-software.md" target="_blank" rel="noopener noreferrer">帮助我们改善此页面!</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">a year ago</span></div></footer> <!----> </main></div><div class="global-ui"><!----><!----></div></div>
|
||||
<script src="/linux-tutorial/assets/js/app.79a38eea.js" defer></script><script src="/linux-tutorial/assets/js/4.fb6e0f89.js" defer></script><script src="/linux-tutorial/assets/js/30.7e13628f.js" defer></script><script src="/linux-tutorial/assets/js/5.cb43ecfb.js" defer></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,256 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Linux 系统管理 | LINUX-TUTORIAL</title>
|
||||
<meta name="generator" content="VuePress 1.8.2">
|
||||
<link rel="icon" href="/linux-tutorial/favicon.ico">
|
||||
<meta name="description" content="数据库教程">
|
||||
|
||||
<link rel="preload" href="/linux-tutorial/assets/css/0.styles.45d9d031.css" as="style"><link rel="preload" href="/linux-tutorial/assets/js/app.79a38eea.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/4.fb6e0f89.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/31.c4652f75.js" as="script"><link rel="preload" href="/linux-tutorial/assets/js/5.cb43ecfb.js" as="script"><link rel="prefetch" href="/linux-tutorial/assets/js/10.7933187b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/11.b9b41530.js"><link rel="prefetch" href="/linux-tutorial/assets/js/12.70a5dba8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/13.857dcc43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/14.5a603a55.js"><link rel="prefetch" href="/linux-tutorial/assets/js/15.d217acb7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/16.ad565eae.js"><link rel="prefetch" href="/linux-tutorial/assets/js/17.d43e9f56.js"><link rel="prefetch" href="/linux-tutorial/assets/js/18.aa00ff43.js"><link rel="prefetch" href="/linux-tutorial/assets/js/19.43ce44b3.js"><link rel="prefetch" href="/linux-tutorial/assets/js/20.5618e1ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/21.1c5a41d7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/22.fbe9fdf1.js"><link rel="prefetch" href="/linux-tutorial/assets/js/23.a4fb0e74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/24.e3a23b69.js"><link rel="prefetch" href="/linux-tutorial/assets/js/25.9896afe9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/26.96164082.js"><link rel="prefetch" href="/linux-tutorial/assets/js/27.391033bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/28.703f74c2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/29.02a952cb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/30.7e13628f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/32.05d2cbec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/33.3b265df8.js"><link rel="prefetch" href="/linux-tutorial/assets/js/34.26330a03.js"><link rel="prefetch" href="/linux-tutorial/assets/js/35.417d706d.js"><link rel="prefetch" href="/linux-tutorial/assets/js/36.0ed775e0.js"><link rel="prefetch" href="/linux-tutorial/assets/js/37.34430c74.js"><link rel="prefetch" href="/linux-tutorial/assets/js/38.87d5e0ff.js"><link rel="prefetch" href="/linux-tutorial/assets/js/39.7b648b3e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/40.3b7a219e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/41.e727eee9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/42.0134c187.js"><link rel="prefetch" href="/linux-tutorial/assets/js/43.175e982f.js"><link rel="prefetch" href="/linux-tutorial/assets/js/44.72d90888.js"><link rel="prefetch" href="/linux-tutorial/assets/js/45.d49955bd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/46.a9c290ec.js"><link rel="prefetch" href="/linux-tutorial/assets/js/47.cc639f04.js"><link rel="prefetch" href="/linux-tutorial/assets/js/48.98c78321.js"><link rel="prefetch" href="/linux-tutorial/assets/js/49.a7c3afed.js"><link rel="prefetch" href="/linux-tutorial/assets/js/50.22d8c542.js"><link rel="prefetch" href="/linux-tutorial/assets/js/51.28055fcd.js"><link rel="prefetch" href="/linux-tutorial/assets/js/52.f8103df5.js"><link rel="prefetch" href="/linux-tutorial/assets/js/53.76541550.js"><link rel="prefetch" href="/linux-tutorial/assets/js/54.e78d2776.js"><link rel="prefetch" href="/linux-tutorial/assets/js/55.3ce3079c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/56.832958c9.js"><link rel="prefetch" href="/linux-tutorial/assets/js/57.961ce896.js"><link rel="prefetch" href="/linux-tutorial/assets/js/58.6d6fbc82.js"><link rel="prefetch" href="/linux-tutorial/assets/js/59.d5e48112.js"><link rel="prefetch" href="/linux-tutorial/assets/js/6.c8f4721c.js"><link rel="prefetch" href="/linux-tutorial/assets/js/60.7927b23b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/61.ee233f24.js"><link rel="prefetch" href="/linux-tutorial/assets/js/62.6ba50cc7.js"><link rel="prefetch" href="/linux-tutorial/assets/js/63.9cbf9f2b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/64.0be148a4.js"><link rel="prefetch" href="/linux-tutorial/assets/js/65.c520257e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/66.f2335390.js"><link rel="prefetch" href="/linux-tutorial/assets/js/67.e5737218.js"><link rel="prefetch" href="/linux-tutorial/assets/js/68.46427a01.js"><link rel="prefetch" href="/linux-tutorial/assets/js/69.450417bb.js"><link rel="prefetch" href="/linux-tutorial/assets/js/7.046e5a1b.js"><link rel="prefetch" href="/linux-tutorial/assets/js/70.072034d2.js"><link rel="prefetch" href="/linux-tutorial/assets/js/8.77fb8967.js"><link rel="prefetch" href="/linux-tutorial/assets/js/9.ebfa537e.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~flowchart.20a64d45.js"><link rel="prefetch" href="/linux-tutorial/assets/js/vendors~notification.ea176280.js">
|
||||
<link rel="stylesheet" href="/linux-tutorial/assets/css/0.styles.45d9d031.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/linux-tutorial/" class="home-link router-link-active"><img src="images/dunwu-logo-100.png" alt="LINUX-TUTORIAL" class="logo"> <span class="site-name can-hide">LINUX-TUTORIAL</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link router-link-active">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/linux-tutorial/linux/cli/" class="nav-link router-link-active">
|
||||
Linux 命令
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/ops/" class="nav-link">
|
||||
Linux 运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/linux/soft/" class="nav-link">
|
||||
Linux 软件运维
|
||||
</a></div><div class="nav-item"><a href="/linux-tutorial/docker/" class="nav-link">
|
||||
Docker 教程
|
||||
</a></div><div class="nav-item"><a href="https://github.com/dunwu/blog" target="_blank" rel="noopener noreferrer" class="nav-link external">
|
||||
🎯 博客
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/dunwu/linux-tutorial" target="_blank" rel="noopener noreferrer" class="repo-link">
|
||||
Github
|
||||
<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Linux 系统管理</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/linux-tutorial/linux/cli/linux-cli-system.html#_1-linux-系统管理要点" class="sidebar-link">1. Linux 系统管理要点</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/linux-tutorial/linux/cli/linux-cli-system.html#_2-命令常见用法" class="sidebar-link">2. 命令常见用法</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-system.html#_2-1-lsb-release" class="sidebar-link">2.1. lsb_release</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-system.html#_2-2-reboot" class="sidebar-link">2.2. reboot</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-system.html#_2-3-exit" class="sidebar-link">2.3. exit</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-system.html#_2-4-shutdown" class="sidebar-link">2.4. shutdown</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-system.html#_2-5-date" class="sidebar-link">2.5. date</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-system.html#_2-6-mount" class="sidebar-link">2.6. mount</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-system.html#_2-7-umount" class="sidebar-link">2.7. umount</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-system.html#_2-8-ps" class="sidebar-link">2.8. ps</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-system.html#_2-9-kill" class="sidebar-link">2.9. kill</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-system.html#_2-10-systemctl" class="sidebar-link">2.10. systemctl</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-system.html#_2-11-service" class="sidebar-link">2.11. service</a></li><li class="sidebar-sub-header"><a href="/linux-tutorial/linux/cli/linux-cli-system.html#_2-12-crontab" class="sidebar-link">2.12. crontab</a></li></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="linux-系统管理"><a href="#linux-系统管理" class="header-anchor">#</a> Linux 系统管理</h1> <blockquote><p>关键词:<code>lsb_release</code>, <code>reboot</code>, <code>exit</code>, <code>shutdown</code>, <code>date</code>, <code>mount</code>, <code>umount</code>, <code>ps</code>, <code>kill</code>, <code>systemctl</code>, <code>service</code>, <code>crontab</code></p></blockquote> <h2 id="_1-linux-系统管理要点"><a href="#_1-linux-系统管理要点" class="header-anchor">#</a> 1. Linux 系统管理要点</h2> <ul><li>查看 Linux 系统发行版本
|
||||
<ul><li>使用 <a href="#lsb_release">lsb_release</a>(此命令适用于所有的 Linux 发行版本)</li> <li>使用 <code>cat /etc/redhat-release</code>(此方法只适合 Redhat 系的 Linux)</li></ul></li> <li>查看 CPU 信息 - 使用 <code>cat /proc/cpuinfo</code></li> <li>重新启动 Linux 操作系统 - 使用 <a href="#reboot">reboot</a></li> <li>退出 shell,并返回给定值 - 使用 <a href="#exit">exit</a></li> <li>关闭系统 - 使用 <a href="#shutdown">shutdown</a></li> <li>查看或设置系统时间与日期 - 使用 <a href="#date">date</a></li> <li>挂载文件系统 - 使用 <a href="#mount">mount</a></li> <li>取消挂载文件系统 - 使用 <a href="#umount">umount</a></li> <li>查看系统当前进程状态 - 使用 <a href="#ps">ps</a></li> <li>删除当前正在运行的进程 - 使用 <a href="#kill">kill</a></li> <li>启动、停止、重启、关闭、显示系统服务(Centos7),使用 <a href="#systemctl">systemctl</a></li> <li>启动、停止、重启、关闭、显示系统服务(Centos7 以前),使用 <a href="#service">service</a></li> <li>管理需要周期性执行的任务,使用 <a href="#crontab">crontab</a></li></ul> <h2 id="_2-命令常见用法"><a href="#_2-命令常见用法" class="header-anchor">#</a> 2. 命令常见用法</h2> <h3 id="_2-1-lsb-release"><a href="#_2-1-lsb-release" class="header-anchor">#</a> 2.1. lsb_release</h3> <p>lsb_release 不是 bash 默认命令,如果要使用,需要先安装。</p> <p>安装方法:</p> <ol><li>执行 <code>yum provides lsb_release</code>,查看支持 lsb_release 命令的包。</li> <li>选择合适版本,执行类似这样的安装命令:<code>yum install -y redhat-lsb-core-4.1-27.el7.centos.1.x86_64</code></li></ol> <h3 id="_2-2-reboot"><a href="#_2-2-reboot" class="header-anchor">#</a> 2.2. reboot</h3> <blockquote><p>reboot 命令用来重新启动正在运行的 Linux 操作系统。</p> <p>参考:http://man.linuxde.net/reboot</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">reboot</span> <span class="token comment"># 重开机。</span>
|
||||
<span class="token function">reboot</span> -w <span class="token comment"># 做个重开机的模拟(只有纪录并不会真的重开机)。</span>
|
||||
</code></pre></div><h3 id="_2-3-exit"><a href="#_2-3-exit" class="header-anchor">#</a> 2.3. exit</h3> <blockquote><p>exit 命令同于退出 shell,并返回给定值。在 shell 脚本中可以终止当前脚本执行。执行 exit 可使 shell 以指定的状态值退出。若不设置状态值参数,则 shell 以预设值退出。状态值 0 代表执行成功,其他值代表执行失败。</p> <p>参考:http://man.linuxde.net/exit</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 退出当前 shell</span>
|
||||
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># exit</span>
|
||||
<span class="token builtin class-name">logout</span>
|
||||
|
||||
<span class="token comment"># 在脚本中,进入脚本所在目录,否则退出</span>
|
||||
<span class="token builtin class-name">cd</span> <span class="token variable"><span class="token variable">$(</span><span class="token function">dirname</span> $0<span class="token variable">)</span></span> <span class="token operator">||</span> <span class="token builtin class-name">exit</span> <span class="token number">1</span>
|
||||
|
||||
<span class="token comment"># 在脚本中,判断参数数量,不匹配就打印使用方式,退出</span>
|
||||
<span class="token keyword">if</span> <span class="token punctuation">[</span> <span class="token string">"<span class="token variable">$#</span>"</span> -ne <span class="token string">"2"</span> <span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token keyword">then</span>
|
||||
<span class="token builtin class-name">echo</span> <span class="token string">"usage: <span class="token variable">$0</span> <area> <hours>"</span>
|
||||
<span class="token builtin class-name">exit</span> <span class="token number">2</span>
|
||||
<span class="token keyword">fi</span>
|
||||
|
||||
<span class="token comment"># 在脚本中,退出时删除临时文件</span>
|
||||
<span class="token builtin class-name">trap</span> <span class="token string">"rm -f tmpfile; echo Bye."</span> EXIT
|
||||
|
||||
<span class="token comment"># 检查上一命令的退出码</span>
|
||||
./mycommand.sh
|
||||
<span class="token assign-left variable">EXCODE</span><span class="token operator">=</span><span class="token variable">$?</span>
|
||||
<span class="token keyword">if</span> <span class="token punctuation">[</span> <span class="token string">"<span class="token variable">$EXCODE</span>"</span> <span class="token operator">==</span> <span class="token string">"0"</span> <span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token keyword">then</span>
|
||||
<span class="token builtin class-name">echo</span> <span class="token string">"O.K"</span>
|
||||
<span class="token keyword">fi</span>
|
||||
</code></pre></div><h3 id="_2-4-shutdown"><a href="#_2-4-shutdown" class="header-anchor">#</a> 2.4. shutdown</h3> <blockquote><p>shutdown 命令用来系统关机命令。shutdown 指令可以关闭所有程序,并依用户的需要,进行重新开机或关机的动作。</p> <p>参考:http://man.linuxde.net/shutdown</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 指定现在立即关机</span>
|
||||
<span class="token function">shutdown</span> -h now
|
||||
|
||||
<span class="token comment"># 指定 5 分钟后关机,同时送出警告信息给登入用户</span>
|
||||
<span class="token function">shutdown</span> +5 <span class="token string">"System will shutdown after 5 minutes"</span>
|
||||
</code></pre></div><h3 id="_2-5-date"><a href="#_2-5-date" class="header-anchor">#</a> 2.5. date</h3> <blockquote><p>date 命令是显示或设置系统时间与日期。</p> <p>参考:http://man.linuxde.net/date</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 格式化输出</span>
|
||||
<span class="token function">date</span> +<span class="token string">"%Y-%m-%d"</span>
|
||||
<span class="token number">2009</span>-12-07
|
||||
|
||||
<span class="token comment"># 输出昨天日期</span>
|
||||
<span class="token function">date</span> -d <span class="token string">"1 day ago"</span> +<span class="token string">"%Y-%m-%d"</span>
|
||||
<span class="token number">2012</span>-11-19
|
||||
|
||||
<span class="token comment"># 2 秒后输出</span>
|
||||
<span class="token function">date</span> -d <span class="token string">"2 second"</span> +<span class="token string">"%Y-%m-%d %H:%M.%S"</span>
|
||||
<span class="token number">2012</span>-11-20 <span class="token number">14</span>:21.31
|
||||
|
||||
<span class="token comment"># 传说中的 1234567890 秒</span>
|
||||
<span class="token function">date</span> -d <span class="token string">"1970-01-01 1234567890 seconds"</span> +<span class="token string">"%Y-%m-%d %H:%m:%S"</span>
|
||||
<span class="token number">2009</span>-02-13 <span class="token number">23</span>:02:30
|
||||
|
||||
<span class="token comment"># 普通转格式</span>
|
||||
<span class="token function">date</span> -d <span class="token string">"2009-12-12"</span> +<span class="token string">"%Y/%m/%d %H:%M.%S"</span>
|
||||
<span class="token number">2009</span>/12/12 00:00.00
|
||||
|
||||
<span class="token comment"># apache 格式转换</span>
|
||||
<span class="token function">date</span> -d <span class="token string">"Dec 5, 2009 12:00:37 AM"</span> +<span class="token string">"%Y-%m-%d %H:%M.%S"</span>
|
||||
<span class="token number">2009</span>-12-05 00:00.37
|
||||
|
||||
<span class="token comment"># 格式转换后时间游走</span>
|
||||
<span class="token function">date</span> -d <span class="token string">"Dec 5, 2009 12:00:37 AM 2 year ago"</span> +<span class="token string">"%Y-%m-%d %H:%M.%S"</span>
|
||||
<span class="token number">2007</span>-12-05 00:00.37
|
||||
|
||||
<span class="token comment"># 加减操作</span>
|
||||
<span class="token function">date</span> +%Y%m%d <span class="token comment"># 显示前天年月日</span>
|
||||
<span class="token function">date</span> -d <span class="token string">"+1 day"</span> +%Y%m%d <span class="token comment"># 显示前一天的日期</span>
|
||||
<span class="token function">date</span> -d <span class="token string">"-1 day"</span> +%Y%m%d <span class="token comment"># 显示后一天的日期</span>
|
||||
<span class="token function">date</span> -d <span class="token string">"-1 month"</span> +%Y%m%d <span class="token comment"># 显示上一月的日期</span>
|
||||
<span class="token function">date</span> -d <span class="token string">"+1 month"</span> +%Y%m%d <span class="token comment"># 显示下一月的日期</span>
|
||||
<span class="token function">date</span> -d <span class="token string">"-1 year"</span> +%Y%m%d <span class="token comment"># 显示前一年的日期</span>
|
||||
<span class="token function">date</span> -d <span class="token string">"+1 year"</span> +%Y%m%d <span class="token comment"># 显示下一年的日期</span>
|
||||
|
||||
<span class="token comment"># 设定时间</span>
|
||||
<span class="token function">date</span> -s <span class="token comment"># 设置当前时间,只有root权限才能设置,其他只能查看</span>
|
||||
<span class="token function">date</span> -s <span class="token number">20120523</span> <span class="token comment"># 设置成20120523,这样会把具体时间设置成空00:00:00</span>
|
||||
<span class="token function">date</span> -s 01:01:01 <span class="token comment"># 设置具体时间,不会对日期做更改</span>
|
||||
<span class="token function">date</span> -s <span class="token string">"01:01:01 2012-05-23"</span> <span class="token comment"># 这样可以设置全部时间</span>
|
||||
<span class="token function">date</span> -s <span class="token string">"01:01:01 20120523"</span> <span class="token comment"># 这样可以设置全部时间</span>
|
||||
<span class="token function">date</span> -s <span class="token string">"2012-05-23 01:01:01"</span> <span class="token comment"># 这样可以设置全部时间</span>
|
||||
<span class="token function">date</span> -s <span class="token string">"20120523 01:01:01"</span> <span class="token comment"># 这样可以设置全部时间</span>
|
||||
|
||||
<span class="token comment"># 有时需要检查一组命令花费的时间</span>
|
||||
<span class="token comment">#!/bin/bash</span>
|
||||
|
||||
<span class="token assign-left variable">start</span><span class="token operator">=</span><span class="token variable"><span class="token variable">$(</span><span class="token function">date</span> +%s<span class="token variable">)</span></span>
|
||||
nmap man.linuxde.net <span class="token operator">&></span> /dev/null
|
||||
|
||||
<span class="token assign-left variable">end</span><span class="token operator">=</span><span class="token variable"><span class="token variable">$(</span><span class="token function">date</span> +%s<span class="token variable">)</span></span>
|
||||
<span class="token assign-left variable">difference</span><span class="token operator">=</span><span class="token variable"><span class="token variable">$((</span> end <span class="token operator">-</span> start <span class="token variable">))</span></span>
|
||||
<span class="token builtin class-name">echo</span> <span class="token variable">$difference</span> seconds.
|
||||
</code></pre></div><h3 id="_2-6-mount"><a href="#_2-6-mount" class="header-anchor">#</a> 2.6. mount</h3> <blockquote><p>mount 命令用于挂载文件系统到指定的挂载点。此命令的最常用于挂载 cdrom,使我们可以访问 cdrom 中的数据,因为你将光盘插入 cdrom 中,Linux 并不会自动挂载,必须使用 Linux mount 命令来手动完成挂载。</p> <p>参考:http://man.linuxde.net/mount > https://blog.csdn.net/weishujie000/article/details/76531924</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 将 /dev/hda1 挂在 /mnt 之下</span>
|
||||
<span class="token function">mount</span> /dev/hda1 /mnt
|
||||
|
||||
<span class="token comment"># 将 /dev/hda1 用唯读模式挂在 /mnt 之下</span>
|
||||
<span class="token function">mount</span> -o ro /dev/hda1 /mnt
|
||||
|
||||
<span class="token comment"># 将 /tmp/image.iso 这个光碟的 image 档使用 loop 模式挂在 /mnt/cdrom 之下</span>
|
||||
<span class="token comment"># 用这种方法可以将一般网络上可以找到的 Linux ISO 在不烧录成光碟的情况下检视其内容</span>
|
||||
<span class="token function">mount</span> -o loop /tmp/image.iso /mnt/cdrom
|
||||
</code></pre></div><h3 id="_2-7-umount"><a href="#_2-7-umount" class="header-anchor">#</a> 2.7. umount</h3> <blockquote><p>umount 命令用于卸载已经挂载的文件系统。利用设备名或挂载点都能 umount 文件系统,不过最好还是通过挂载点卸载,以免使用绑定挂载(一个设备,多个挂载点)时产生混乱。</p> <p>参考:http://man.linuxde.net/umount</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 通过设备名卸载</span>
|
||||
<span class="token function">umount</span> -v /dev/sda1
|
||||
/dev/sda1 umounted
|
||||
|
||||
<span class="token comment"># 通过挂载点卸载</span>
|
||||
<span class="token function">umount</span> -v /mnt/mymount/
|
||||
/tmp/diskboot.img umounted
|
||||
</code></pre></div><h3 id="_2-8-ps"><a href="#_2-8-ps" class="header-anchor">#</a> 2.8. ps</h3> <blockquote><p>ps 命令用于报告当前系统的进程状态。可以搭配 kill 指令随时中断、删除不必要的程序。ps 命令是最基本同时也是非常强大的进程查看命令,使用该命令可以确定有哪些进程正在运行和运行的状态、进程是否结束、进程有没有僵死、哪些进程占用了过多的资源等等,总之大部分信息都是可以通过执行该命令得到的。</p> <p>参考:http://man.linuxde.net/ps</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 按内存资源的使用量对进程进行排序</span>
|
||||
<span class="token function">ps</span> aux <span class="token operator">|</span> <span class="token function">sort</span> -rnk <span class="token number">4</span>
|
||||
|
||||
<span class="token comment"># 按 CPU 资源的使用量对进程进行排序</span>
|
||||
<span class="token function">ps</span> aux <span class="token operator">|</span> <span class="token function">sort</span> -nk <span class="token number">3</span>
|
||||
</code></pre></div><h3 id="_2-9-kill"><a href="#_2-9-kill" class="header-anchor">#</a> 2.9. kill</h3> <blockquote><p>kill 命令用来删除执行中的程序或工作。kill 可将指定的信息送至程序。预设的信息为 SIGTERM(15),可将指定程序终止。若仍无法终止该程序,可使用 SIGKILL(9) 信息尝试强制删除程序。程序或工作的编号可利用 ps 指令或 job 指令查看。</p> <p>参考:http://man.linuxde.net/kill</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 列出所有信号名称</span>
|
||||
<span class="token function">kill</span> -l
|
||||
<span class="token number">1</span><span class="token punctuation">)</span> SIGHUP <span class="token number">2</span><span class="token punctuation">)</span> SIGINT <span class="token number">3</span><span class="token punctuation">)</span> SIGQUIT <span class="token number">4</span><span class="token punctuation">)</span> SIGILL
|
||||
<span class="token number">5</span><span class="token punctuation">)</span> SIGTRAP <span class="token number">6</span><span class="token punctuation">)</span> SIGABRT <span class="token number">7</span><span class="token punctuation">)</span> SIGBUS <span class="token number">8</span><span class="token punctuation">)</span> SIGFPE
|
||||
<span class="token number">9</span><span class="token punctuation">)</span> SIGKILL <span class="token number">10</span><span class="token punctuation">)</span> SIGUSR1 <span class="token number">11</span><span class="token punctuation">)</span> SIGSEGV <span class="token number">12</span><span class="token punctuation">)</span> SIGUSR2
|
||||
<span class="token number">13</span><span class="token punctuation">)</span> SIGPIPE <span class="token number">14</span><span class="token punctuation">)</span> SIGALRM <span class="token number">15</span><span class="token punctuation">)</span> SIGTERM <span class="token number">16</span><span class="token punctuation">)</span> SIGSTKFLT
|
||||
<span class="token number">17</span><span class="token punctuation">)</span> SIGCHLD <span class="token number">18</span><span class="token punctuation">)</span> SIGCONT <span class="token number">19</span><span class="token punctuation">)</span> SIGSTOP <span class="token number">20</span><span class="token punctuation">)</span> SIGTSTP
|
||||
<span class="token number">21</span><span class="token punctuation">)</span> SIGTTIN <span class="token number">22</span><span class="token punctuation">)</span> SIGTTOU <span class="token number">23</span><span class="token punctuation">)</span> SIGURG <span class="token number">24</span><span class="token punctuation">)</span> SIGXCPU
|
||||
<span class="token number">25</span><span class="token punctuation">)</span> SIGXFSZ <span class="token number">26</span><span class="token punctuation">)</span> SIGVTALRM <span class="token number">27</span><span class="token punctuation">)</span> SIGPROF <span class="token number">28</span><span class="token punctuation">)</span> SIGWINCH
|
||||
<span class="token number">29</span><span class="token punctuation">)</span> SIGIO <span class="token number">30</span><span class="token punctuation">)</span> SIGPWR <span class="token number">31</span><span class="token punctuation">)</span> SIGSYS <span class="token number">34</span><span class="token punctuation">)</span> SIGRTMIN
|
||||
<span class="token number">35</span><span class="token punctuation">)</span> SIGRTMIN+1 <span class="token number">36</span><span class="token punctuation">)</span> SIGRTMIN+2 <span class="token number">37</span><span class="token punctuation">)</span> SIGRTMIN+3 <span class="token number">38</span><span class="token punctuation">)</span> SIGRTMIN+4
|
||||
<span class="token number">39</span><span class="token punctuation">)</span> SIGRTMIN+5 <span class="token number">40</span><span class="token punctuation">)</span> SIGRTMIN+6 <span class="token number">41</span><span class="token punctuation">)</span> SIGRTMIN+7 <span class="token number">42</span><span class="token punctuation">)</span> SIGRTMIN+8
|
||||
<span class="token number">43</span><span class="token punctuation">)</span> SIGRTMIN+9 <span class="token number">44</span><span class="token punctuation">)</span> SIGRTMIN+10 <span class="token number">45</span><span class="token punctuation">)</span> SIGRTMIN+11 <span class="token number">46</span><span class="token punctuation">)</span> SIGRTMIN+12
|
||||
<span class="token number">47</span><span class="token punctuation">)</span> SIGRTMIN+13 <span class="token number">48</span><span class="token punctuation">)</span> SIGRTMIN+14 <span class="token number">49</span><span class="token punctuation">)</span> SIGRTMIN+15 <span class="token number">50</span><span class="token punctuation">)</span> SIGRTMAX-14
|
||||
<span class="token number">51</span><span class="token punctuation">)</span> SIGRTMAX-13 <span class="token number">52</span><span class="token punctuation">)</span> SIGRTMAX-12 <span class="token number">53</span><span class="token punctuation">)</span> SIGRTMAX-11 <span class="token number">54</span><span class="token punctuation">)</span> SIGRTMAX-10
|
||||
<span class="token number">55</span><span class="token punctuation">)</span> SIGRTMAX-9 <span class="token number">56</span><span class="token punctuation">)</span> SIGRTMAX-8 <span class="token number">57</span><span class="token punctuation">)</span> SIGRTMAX-7 <span class="token number">58</span><span class="token punctuation">)</span> SIGRTMAX-6
|
||||
<span class="token number">59</span><span class="token punctuation">)</span> SIGRTMAX-5 <span class="token number">60</span><span class="token punctuation">)</span> SIGRTMAX-4 <span class="token number">61</span><span class="token punctuation">)</span> SIGRTMAX-3 <span class="token number">62</span><span class="token punctuation">)</span> SIGRTMAX-2
|
||||
<span class="token number">63</span><span class="token punctuation">)</span> SIGRTMAX-1 <span class="token number">64</span><span class="token punctuation">)</span> SIGRTMAX
|
||||
|
||||
<span class="token comment"># 先用 ps 查找进程,然后用 kill 杀掉</span>
|
||||
<span class="token function">ps</span> -ef <span class="token operator">|</span> <span class="token function">grep</span> <span class="token function">vim</span>
|
||||
root <span class="token number">3268</span> <span class="token number">2884</span> <span class="token number">0</span> <span class="token number">16</span>:21 pts/1 00:00:00 <span class="token function">vim</span> install.log
|
||||
root <span class="token number">3370</span> <span class="token number">2822</span> <span class="token number">0</span> <span class="token number">16</span>:21 pts/0 00:00:00 <span class="token function">grep</span> <span class="token function">vim</span>
|
||||
|
||||
<span class="token function">kill</span> <span class="token number">3268</span>
|
||||
<span class="token function">kill</span> <span class="token number">3268</span>
|
||||
-bash: kill: <span class="token punctuation">(</span><span class="token number">3268</span><span class="token punctuation">)</span> - 没有那个进程
|
||||
</code></pre></div><h3 id="_2-10-systemctl"><a href="#_2-10-systemctl" class="header-anchor">#</a> 2.10. systemctl</h3> <blockquote><p>systemctl 命令是系统服务管理器指令,它实际上将 service 和 chkconfig 这两个命令组合到一起。</p> <p>参考:http://man.linuxde.net/systemctl</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 1.启动 nfs 服务</span>
|
||||
systemctl start nfs-server.service
|
||||
|
||||
<span class="token comment"># 2.设置开机自启动</span>
|
||||
systemctl <span class="token builtin class-name">enable</span> nfs-server.service
|
||||
|
||||
<span class="token comment"># 3.停止开机自启动</span>
|
||||
systemctl disable nfs-server.service
|
||||
|
||||
<span class="token comment"># 4.查看服务当前状态</span>
|
||||
systemctl status nfs-server.service
|
||||
|
||||
<span class="token comment"># 5.重新启动某服务</span>
|
||||
systemctl restart nfs-server.service
|
||||
|
||||
<span class="token comment"># 6.查看所有已启动的服务</span>
|
||||
systemctl list -units --type<span class="token operator">=</span>service
|
||||
|
||||
<span class="token comment"># 7. 开启防火墙 22 端口</span>
|
||||
iptables -I INPUT -p tcp --dport <span class="token number">22</span> -j accept
|
||||
|
||||
<span class="token comment"># 8. 彻底关闭防火墙</span>
|
||||
<span class="token function">sudo</span> systemctl status firewalld.service
|
||||
<span class="token function">sudo</span> systemctl stop firewalld.service
|
||||
<span class="token function">sudo</span> systemctl disable firewalld.service
|
||||
</code></pre></div><h3 id="_2-11-service"><a href="#_2-11-service" class="header-anchor">#</a> 2.11. service</h3> <blockquote><p>service 命令是 Redhat Linux 兼容的发行版中用来控制系统服务的实用工具,它以启动、停止、重新启动和关闭系统服务,还可以显示所有系统服务的当前状态。</p> <p>参考:http://man.linuxde.net/service</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">service</span> network status
|
||||
配置设备:
|
||||
lo eth0
|
||||
当前的活跃设备:
|
||||
lo eth0
|
||||
|
||||
<span class="token function">service</span> network restart
|
||||
正在关闭接口 eth0: <span class="token punctuation">[</span> 确定 <span class="token punctuation">]</span>
|
||||
关闭环回接口: <span class="token punctuation">[</span> 确定 <span class="token punctuation">]</span>
|
||||
设置网络参数: <span class="token punctuation">[</span> 确定 <span class="token punctuation">]</span>
|
||||
弹出环回接口: <span class="token punctuation">[</span> 确定 <span class="token punctuation">]</span>
|
||||
弹出界面 eth0: <span class="token punctuation">[</span> 确定 <span class="token punctuation">]</span>
|
||||
</code></pre></div><h3 id="_2-12-crontab"><a href="#_2-12-crontab" class="header-anchor">#</a> 2.12. crontab</h3> <blockquote><p>crontab 命令被用来提交和管理用户的需要周期性执行的任务,与 windows 下的计划任务类似,当安装完成操作系统后,默认会安装此服务工具,并且会自动启动 crond 进程,crond 进程每分钟会定期检查是否有要执行的任务,如果有要执行的任务,则自动执行该任务。</p> <p>参考:http://man.linuxde.net/crontab</p></blockquote> <p>示例:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 每 1 分钟执行一次 command</span>
|
||||
* * * * * <span class="token builtin class-name">command</span>
|
||||
|
||||
<span class="token comment"># 每小时的第 3 和第 15 分钟执行</span>
|
||||
<span class="token number">3,15</span> * * * * <span class="token builtin class-name">command</span>
|
||||
|
||||
<span class="token comment"># 在上午 8 点到 11 点的第 3 和第 15 分钟执行</span>
|
||||
<span class="token number">3,15</span> <span class="token number">8</span>-11 * * * <span class="token builtin class-name">command</span>
|
||||
|
||||
<span class="token comment"># 每隔两天的上午 8 点到 11 点的第 3 和第 15 分钟执行</span>
|
||||
<span class="token number">3,15</span> <span class="token number">8</span>-11 */2 * * <span class="token builtin class-name">command</span>
|
||||
|
||||
<span class="token comment"># 每个星期一的上午 8 点到 11 点的第 3 和第 15 分钟执行</span>
|
||||
<span class="token number">3,15</span> <span class="token number">8</span>-11 * * <span class="token number">1</span> <span class="token builtin class-name">command</span>
|
||||
|
||||
<span class="token comment"># 每晚的 21:30 重启 smb</span>
|
||||
<span class="token number">30</span> <span class="token number">21</span> * * * /etc/init.d/smb restart
|
||||
|
||||
<span class="token comment"># 每月 1、10、22 日的 4 : 45 重启 smb</span>
|
||||
<span class="token number">45</span> <span class="token number">4</span> <span class="token number">1,10</span>,22 * * /etc/init.d/smb restart
|
||||
|
||||
<span class="token comment"># 每周六、周日的 1:10 重启 smb</span>
|
||||
<span class="token number">10</span> <span class="token number">1</span> * * <span class="token number">6,0</span> /etc/init.d/smb restart
|
||||
|
||||
<span class="token comment"># 每天 18 : 00 至 23 : 00 之间每隔 30 分钟重启 smb</span>
|
||||
<span class="token number">0,30</span> <span class="token number">18</span>-23 * * * /etc/init.d/smb restart
|
||||
|
||||
<span class="token comment"># 每星期六的晚上 11:00 pm 重启 smb</span>
|
||||
<span class="token number">0</span> <span class="token number">23</span> * * <span class="token number">6</span> /etc/init.d/smb restart
|
||||
|
||||
<span class="token comment"># 每一小时重启 smb</span>
|
||||
* */1 * * * /etc/init.d/smb restart
|
||||
|
||||
<span class="token comment"># 晚上 11 点到早上 7 点之间,每隔一小时重启 smb</span>
|
||||
* <span class="token number">23</span>-7/1 * * * /etc/init.d/smb restart
|
||||
|
||||
<span class="token comment"># 每月的 4 号与每周一到周三的 11 点重启 smb</span>
|
||||
<span class="token number">0</span> <span class="token number">11</span> <span class="token number">4</span> * mon-wed /etc/init.d/smb restart
|
||||
|
||||
<span class="token comment"># 一月一号的 4 点重启 smb</span>
|
||||
<span class="token number">0</span> <span class="token number">4</span> <span class="token number">1</span> jan * /etc/init.d/smb restart
|
||||
|
||||
<span class="token comment"># 每小时执行`/etc/cron.hourly`目录内的脚本</span>
|
||||
01 * * * * root run-parts /etc/cron.hourly
|
||||
</code></pre></div></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/dunwu/linux-tutorial/edit/master/docs/linux/cli/linux-cli-system.md" target="_blank" rel="noopener noreferrer">帮助我们改善此页面!</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">a year ago</span></div></footer> <!----> </main></div><div class="global-ui"><!----><!----></div></div>
|
||||
<script src="/linux-tutorial/assets/js/app.79a38eea.js" defer></script><script src="/linux-tutorial/assets/js/4.fb6e0f89.js" defer></script><script src="/linux-tutorial/assets/js/31.c4652f75.js" defer></script><script src="/linux-tutorial/assets/js/5.cb43ecfb.js" defer></script>
|
||||
</body>
|
||||
</html>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue