-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatom.xml
209 lines (209 loc) · 12 KB
/
atom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<id>https://Robotzeroo.github.io</id>
<title>Just enjoy</title>
<updated>2020-06-04T01:45:52.054Z</updated>
<generator>https://github.com/jpmonette/feed</generator>
<link rel="alternate" href="https://Robotzeroo.github.io"/>
<link rel="self" href="https://Robotzeroo.github.io/atom.xml"/>
<subtitle>han's blog</subtitle>
<logo>https://Robotzeroo.github.io/images/avatar.png</logo>
<icon>https://Robotzeroo.github.io/favicon.ico</icon>
<rights>All rights reserved 2020, Just enjoy</rights>
<entry>
<title type="html"><![CDATA[认识与学习BASH]]></title>
<id>https://Robotzeroo.github.io/post/ren-shi-yu-xue-xi-bash/</id>
<link href="https://Robotzeroo.github.io/post/ren-shi-yu-xue-xi-bash/">
</link>
<updated>2020-05-30T09:09:17.000Z</updated>
<summary type="html"><![CDATA[<p>2020/5/30</p>
]]></summary>
<content type="html"><![CDATA[<p>2020/5/30</p>
<!-- more -->
<h1 id="认识shell">认识shell</h1>
<ol>
<li>用户--->shell--->应用程序--->内核--->硬件</li>
<li>shell的种类分为:Bourne shell(sh)、C shell、K shell、TCSH、Bourne Again SHell(BASH)。其中BASH是sh的升级版。</li>
<li>在我们登录系统的时候,系统会给我一个shell来工作,而这个登录所取得的shell就记录在/etc/passwd这个文件夹内。</li>
<li>Bash shell的功能:
<ol>
<li>历史命令:记录在家目录内的 .bash_history中,不过~/.bash_history 记录的是前一次登陆以前所执行过的命令,至于当前所执行的命令都被缓存在内存中,当你成功的注销系统后,该命令才会记录到 .bash_history中。</li>
<li>命令别名设置功能(alias):例如 alias lm='ls -al' //用 lm 代替 ls -al</li>
<li>任务管理、前台、后台控制</li>
<li>程序化脚本</li>
<li>通配符:例如想知道/usr/bin下有多少以X为开头的文件 ls -l /usr/bin/X*</li>
</ol>
</li>
<li>查询命令是否为BASH shell 的内置命令:type<br>
file: 外部命令<br>
alias: 别名所设置的命令<br>
builtin: 内置命令</li>
</ol>
<h1 id="shell-的变量功能">Shell 的变量功能</h1>
<ol>
<li>利用 echo 命令读出变量,需要在变量前加上‘$’符号如:echo $PATH</li>
<li>双引号内的特殊字符如 '$' 可以保持原本的特性,单引号内的特殊字符则仅为一般字符(纯文本)</li>
<li>若该变量需要在子程序执行,则需要以”export 变量“来使变量成为环境变量。</li>
<li>取消变量的方法:unset 变量</li>
<li>反单引号“ ` ”,在一串命令中反单引号内的命令将会被先执行。</li>
<li>查看环境变量:env<br>
查看BASH内的所有变量:set</li>
<li>美元符号’$’本身也是一个变量,代表目前这个 shell 的进程号,即所谓的PID(process ID),用‘echo $$’查看PID号码。</li>
<li>?:也是一个变量,是上一个执行的命令所返回的值,0代表成功,非0为失败。</li>
</ol>
<h1 id="变量键盘读取-数组-声明">变量键盘读取、数组、声明</h1>
<ol>
<li>要与用户交互或读取来自键盘输入的变量使用:read [-pt] variable<br>
-p:接提示字符<br>
-t:接等待的秒数<br>
variable:输入值赋给variable变量</li>
<li>声明变量的类型:declare [-aixr] variable<br>
-a :将后面的变量定义为数组类型<br>
-i :将后边的变量定义为整数类型<br>
-x :将后边的变量编程环境变量<br>
-r :将变量设置为只读类型,不可修改,也不能unset,需要注销在登陆才能恢复该变量的类型。</li>
<li>数组的设置方式:<br>
var[index]=content</li>
</ol>
<h1 id="使用ulimit">使用ulimit:</h1>
<p>bash可以通过ulimit命令限制用户的某些系统资源,包括可以开启的文件数量, 可以使用的CPU时间,可以使用的内存总量等。</p>
<h1 id="bash从操作环境">bash从操作环境</h1>
<ol>
<li>路径与命令查找顺序:以相对/绝对路径执行命令---->由alias找到该命令来执行----->由bash内置的builtin命令来执行------->通过$PATH这个变量的顺序找到的第一个命令来执行。可以通过type -a [命令]查找。</li>
<li>bash的登录与欢迎信息存在/etc/issue和/etc/motd里,其中/etc/motd存储所有用户都能看到的信息。</li>
</ol>
<h1 id="bash的环境文件配置">bash的环境文件配置</h1>
<figure data-type="image" tabindex="1"><img src="https://Robotzeroo.github.io/post-images/1591235025209.PNG" alt="" loading="lazy"></figure>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Linux文件系统与磁盘]]></title>
<id>https://Robotzeroo.github.io/post/linux-wen-jian-xi-tong-yu-ci-pan/</id>
<link href="https://Robotzeroo.github.io/post/linux-wen-jian-xi-tong-yu-ci-pan/">
</link>
<updated>2020-05-26T09:57:09.000Z</updated>
<summary type="html"><![CDATA[<p>2020/5/26</p>
]]></summary>
<content type="html"><![CDATA[<p>2020/5/26</p>
<!-- more -->
<p>基于centos7.x,文件系统为xfs。xfs是一个日志文件系统,分为三个部分,一个数据区、一个文本系统活动登陆区(日志区)以及一个实时运行区。数据区分为多个存储区群组来分别放置文件系统所需要的数据:</p>
<table>
<thead>
<tr>
<th>boot sector</th>
<th>allocation groups1</th>
<th>allocation groups2</th>
<th>....</th>
<th>allocation groupsN</th>
</tr>
</thead>
<tbody></tbody>
</table>
<p>每个存储区群组结构大致如下:</p>
<table>
<thead>
<tr>
<th>super block</th>
<th>文件系统描述</th>
<th>区块对应表</th>
<th>inode对应表</th>
<th>inode table</th>
<th>data block</th>
</tr>
</thead>
<tbody></tbody>
</table>
<p>一个文件分配1个inode,文件内容由inode来指向,而一个inode可以指定多个data block,每个data block为4kb。要想读取该文件,必须要经过目录记录的文件名来只想到正确的inode号码才能读取。</p>
<h2 id="相关命令"><strong>相关命令</strong></h2>
<h3 id="xfs_info-查看super-block区块内容"><strong>xfs_info 查看super block区块内容</strong></h3>
<h3 id="df-列出文件系统的整体磁盘使用量"><strong>df 列出文件系统的整体磁盘使用量</strong></h3>
<h3 id="du-查看文件系统的磁盘使用量查看目录所占磁盘空间"><strong>du 查看文件系统的磁盘使用量(查看目录所占磁盘空间)</strong></h3>
<h3 id="ln-硬链接和符号链接"><strong>ln 硬链接和符号链接</strong></h3>
<p>-s为符号链接,不加为硬链接。硬链接只是在某个目录下新增一条文件名连接到某个inode号码的关联记录而已。符号链接相当于Windows里的快捷方式。</p>
<h2 id="磁盘的分区-格式化-检验与挂载"><strong>磁盘的分区、格式化、检验与挂载</strong></h2>
<p>当在系统里加一块磁盘需要进行一下四步:</p>
<ol>
<li>对磁盘划分,建立可用的硬盘分区(GPT)</li>
<li>对硬盘分区格式化,建立系统可用的<strong>文件系统</strong></li>
<li>(可选)对文件系统进行检验与修复</li>
<li>建立挂载点(目录),并将它挂载上来</li>
</ol>
<h3 id="观察磁盘状态"><strong>观察磁盘状态</strong></h3>
<p>lsblk 列出系统上所有磁盘列表<br>
blkid 列出设备的UUID等参数,输出每一行代表一个文件系统</p>
<h3 id="磁盘分区"><strong>磁盘分区</strong></h3>
<p>fdisk 用于MBR分区<br>
gdisk 用于GPT分区,“last sector”选项设置分区大小,“hex code”选项设置分区格式(xfs,ext4...),分区之后用命令:partprobe 更新linux内核的分区表,不用重启。</p>
<h3 id="磁盘格式化"><strong>磁盘格式化</strong></h3>
<p>mkfs.xfs 用于格式化磁盘为xfs文件系统<br>
mkfs.ext4 用于格式化磁盘为ext4文件系统<br>
mkfs -t [] [] 格式化磁盘为其他格式</p>
<h3 id="文件系统检验"><strong>文件系统检验</strong></h3>
<p>xfs_repair 检查修复xfs文件系统<br>
fsck.ext4 检查修复ext4文件系统<br>
被检查修复的硬盘分区必不挂在到系统上,必须是卸载状态</p>
<h3 id="文件系统挂载与卸载"><strong>文件系统挂载与卸载</strong></h3>
<p>要作为挂载点的目录,理论上应该是空目录才可<br>
挂载命令:<br>
mount [LABEL=''] [挂载点]<br>
mount [UUID=''] [挂载点]<br>
mount [设备文件名] [挂载点]<br>
卸载命令:(若进行卸载必须将工作目录移到挂载点之外)<br>
umount [-fln] 设备文件名或挂载点</p>
<h3 id="重新挂载根目录与挂载不特定目录"><strong>重新挂载根目录与挂载不特定目录</strong></h3>
<p>当你的挂载参数要改变或根目录出现只读(ro)状态时,需要重新挂载根目录<br>
mount -o remount,rw,auto/<br>
将目录挂载到目录,也可以用符号链接ln来搞定,从此进入挂载目录等于进入被挂载目录<br>
mount --bind [] []</p>
<h3 id="文件系统磁盘参数自定义"><strong>文件系统/磁盘参数自定义</strong></h3>
<p>linux下面的所有设备都以文件来表示,文件通过major与minor数值来表示<br>
mknod 设备文件名 [-bcp] [major] [minor]<br>
b:设置设备名称为外接存储设备,磁盘..<br>
c:..........................为外界输入设备,鼠标键盘...<br>
p:.........................为FIFO文件<br>
xfs_admin 修改xfs文件系统的UUID和label name<br>
tune2fs 修改ext4的label name 和UUID<br>
uuidgen 产生新的UUID</p>
<h2 id="设置启动挂载"><strong>设置启动挂载</strong></h2>
<p>编辑etc/fstab 配置文件内容,可以设置启动挂载:<br>
添加[UUID/设备名] [挂载点] [文件系统] [文件系统参数] [dump] [fsck]</p>
<h2 id="特殊设备loop挂载"><strong>特殊设备loop挂载</strong></h2>
<p>如果当初在分区时,你只有划分出一个根目录,假设你已经没有多余的容量可以进行额外的分区,但是根目录的容量还很大。此时你可以制作出一个大文件,将这个文件挂载,如此一来感觉是就多了一个分区,用途广泛。<br>
例如在/srv下建立一个512MB的大文件,将这个大文件格式化并挂载到/data/file<br>
dd if=/dev/zero of=/srv/loopdev bs=1M count=512<br>
//bs-block size count-block number<br>
mkfs.xfs -f /srv/loopdev<br>
blkid /srv/loopdev<br>
mount -o loop UUID='xxxx' /data/file<br>
nano /etc/fstab<br>
: /srv/loopdev /data/file xfs defaults,loop 0 0<br>
mkdir /data/file<br>
mount -a</p>
<h2 id="内存交换区swap创建"><strong>内存交换区swap创建</strong></h2>
<p>意义:当计算机内存不足时,可以将内存中的数据拿到硬盘中暂时存放的地方叫做内存交换分区。</p>
<ol>
<li>使用物理分区创建内存交换分区<br>
分区gdisk-->格式化mkswap--->将swap设备启动[swapon 设备文件名]---->观察free, swapon -s 两个命令观察内存使用量。</li>
<li>使用文件创建内存交换文件<br>
使用dd命令创建文件--->使用mkswap将/tmp/swap 这个文件格式化为内存交换文件的文件格式---->使用swapon命令启动文件---->使用swapoff可以关闭swap file------>设置自启动[/[swap文件] swap swap defaults 0 0]</li>
</ol>
<h2 id="重点回顾"><strong>重点回顾</strong></h2>
<p>一个可以被挂载的数据通常称为【文件系统,filesystem】,而不是硬盘分区(partition)</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[公告]]></title>
<id>https://Robotzeroo.github.io/post/gong-gao/</id>
<link href="https://Robotzeroo.github.io/post/gong-gao/">
</link>
<updated>2020-05-21T10:20:22.000Z</updated>
<summary type="html"><![CDATA[<p>2020/5/21</p>
]]></summary>
<content type="html"><![CDATA[<p>2020/5/21</p>
<!-- more -->
<p>欢迎大家关注本站<br>
本网站最终解释权归屁屁人先生所有<br>
<img src="https://Robotzeroo.github.io/post-images/1590056789332.jpg" alt="" loading="lazy"></p>
]]></content>
</entry>
</feed>