forked from jaywcjlove/linux-command
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
911ff5c
commit b3f2252
Showing
189 changed files
with
12,896 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
alias | ||
=== | ||
|
||
用来设置指令的别名 | ||
|
||
## 补充说明 | ||
|
||
**alias命** 用来设置指令的别名。我们可以使用该命令可以将一些较长的命令进行简化。使用alias时,用户必须使用单引号`''`将原来的命令引起来,防止特殊字符导致错误。 | ||
|
||
alias命令的作用只局限于该次登入的操作。若要每次登入都能够使用这些命令别名,则可将相应的alias命令存放到bash的初始化文件`/etc/bashrc`中。 | ||
|
||
### 语法 | ||
|
||
``` | ||
alias(选项)(参数) | ||
``` | ||
|
||
### 选项 | ||
|
||
``` | ||
-p:打印已经设置的命令别名。 | ||
``` | ||
|
||
### 参数 | ||
|
||
命令别名设置:定义命令别名,格式为“命令别名=‘实际命令’”。 | ||
|
||
### 实例 | ||
|
||
**alias 的基本使用方法为:** | ||
|
||
``` | ||
alias 新的命令='原命令 -选项/参数' | ||
``` | ||
|
||
例如:`alias l=‘ls -lsh'`将重新定义ls命令,现在只需输入l就可以列目录了。直接输入 alias 命令会列出当前系统中所有已经定义的命令别名。 | ||
|
||
要删除一个别名,可以使用 unalias 命令,如 unalias l。 | ||
|
||
**查看系统已经设置的别名:** | ||
|
||
``` | ||
alias -p | ||
alias cp='cp -i' | ||
alias l.='ls -d .* --color=tty' | ||
alias ll='ls -l --color=tty' | ||
alias ls='ls --color=tty' | ||
alias mv='mv -i' | ||
alias rm='rm -i' | ||
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apachectl | ||
=== | ||
|
||
Apache服务器前端控制工具 | ||
|
||
## 补充说明 | ||
|
||
**apachectl命** 是Apache的Web服务器前端控制工具,用以启动、关闭和重新启动Web服务器进程。 | ||
|
||
### 语法 | ||
|
||
``` | ||
apachectl(参数) | ||
``` | ||
|
||
### 参数 | ||
|
||
* configtest:检查设置文件中的语法是否正确; | ||
* fullstatus:显示服务器完整的状态信息; | ||
* graceful:重新启动Apache服务器,但不会中断原有的连接; | ||
* help:显示帮助信息; | ||
* restart:重新启动Apache服务器; | ||
* start:启动Apache服务器; | ||
* status:显示服务器摘要的状态信息; | ||
* stop:停止Apache服务器。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
arch | ||
=== | ||
|
||
显示当前主机的硬件架构类型 | ||
|
||
## 补充说明 | ||
|
||
**arch命** 用于显示当前主机的硬件架构类型。arch命令等同于`命令name -m`在当前的Linux系统下,arch命令输出结果有:i386、i486、i586、alpha、sparc、arm、m68k、mips、ppc、i686等 | ||
|
||
### 语法 | ||
|
||
``` | ||
arch | ||
``` | ||
|
||
### 实例 | ||
|
||
``` | ||
arch | ||
x86_64 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
arpwatch | ||
=== | ||
|
||
监听网络上ARP的记录 | ||
|
||
## 补充说明 | ||
|
||
**arpwatch命** 用来监听网络上arp的记录。 | ||
|
||
### 语法 | ||
|
||
``` | ||
arpwatch(选项) | ||
``` | ||
|
||
### 选项 | ||
|
||
``` | ||
-d:启动排错模式; | ||
-f<记录文件>:设置存储ARP记录的文件,预设为/var/arpwatch/arp.dat; | ||
-i<接口>:指定监听ARP的接口,预设的接口为eth0; | ||
-r<记录文件>:从指定的文件中读取ARP记录,而不是从网络上监听。 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
badblocks | ||
=== | ||
|
||
查找磁盘中损坏的区块 | ||
|
||
## 补充说明 | ||
|
||
**badblock命** 用于查找磁盘中损坏的区块。 硬盘是一个损耗设备,当使用一段时间后可能会出现坏道等物理故障。电脑硬盘出现坏道后,如果不及时更换或进行技术处理,坏道就会越来越多,并会造成频繁死机和数据丢失。最好的处理方式是更换磁盘,但在临时的情况下,应及时屏蔽坏道部分的扇区,不要触动它们。badblocks就是一个很好的检查坏道位置的工具。 | ||
|
||
### 语法 | ||
|
||
``` | ||
badblock(选项)(参数) | ||
``` | ||
|
||
### 选项 | ||
|
||
``` | ||
-b<区块大小>:指定磁盘的区块大小,单位为字节; | ||
-o<输出文件>:将检查的结果写入指定的输出文件; | ||
-s:在检查时显示进度; | ||
-v:执行时显示详细的信息; | ||
-w:在检查时,执行写入测试。 | ||
``` | ||
|
||
### 参数 | ||
|
||
* 磁盘装置:指定要检查的磁盘装置; | ||
* 磁盘区块数:指定磁盘装置的区块总数; | ||
* 启始区块:指定要从哪个区块开始检查。 | ||
|
||
### 实例 | ||
|
||
badblocks以4096的一个block,每一个block检查16次,将结果输出到“hda-badblocks-list”文件里。 | ||
|
||
``` | ||
badblocks -b 4096 -c 16 /dev/hda1 -o hda-badblocks-list | ||
``` | ||
|
||
hda-badblocks-list是个文本文件,内容如下: | ||
|
||
``` | ||
cat hda-badblocks-list | ||
51249 | ||
51250 | ||
51251 | ||
51253 | ||
51254 | ||
…… | ||
61245 | ||
…… | ||
``` | ||
|
||
可以针对可疑的区块多做几次操作。下面,badblocks以4096字节为一个“block”,每一个“block”检查1次, 将结果输出到“hda-badblocks-list.1”文件中,由第51000 block开始,到63000 block结束。 | ||
|
||
``` | ||
badblocks -b 4096 -c 1 /dev/hda1 -o hda-badblocks-list.1 63000 51000 | ||
``` | ||
|
||
这次花费的时间比较短,硬盘在指定的情况下在很短的时间就产生“嘎嘎嘎嘎”的响声。由于检查条件的不同,其输出的结果也不完全是相同的。重复几次同样的操作,因条件多少都有些不同,所以结果也有所不同。进行多次操作后,直到产生最后的hda-badblock-list.final文件。 | ||
|
||
### 其他 | ||
|
||
**1、fsck使用badblocks的信息** | ||
|
||
badblocks只会在日志文件中标记出坏道的信息,但若希望在检测磁盘时也能跳过这些坏块不检测,可以使用fsck的-l参数: | ||
|
||
``` | ||
fsck.ext3 -l /tmp/hda-badblock-list.final /dev/hda1 | ||
``` | ||
|
||
**2、在创建文件系统前检测坏道** | ||
|
||
badblocks可以随e2fsck和mke2fs的-c删除一起运行(对ext3文件系统也一样),在创建文件系统前就先检测坏道信息: | ||
|
||
``` | ||
mkfs.ext3 -c /dev/hda1 | ||
``` | ||
|
||
代码表示使用-c在创建文件系统前检查坏道的硬盘。 | ||
|
||
这个操作已经很清楚地告知我们可以采用`mkfs.ext3 -c`选项用`read-only`方式检查硬盘。这个命令会在格式化硬盘时检查硬盘,并标出错误的硬盘“block”。用这个方法格式化硬盘,需要有相当大的耐心,因为命令运行后,会一个个用读的方式检查硬盘。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
bind | ||
=== | ||
|
||
显示或设置键盘按键与其相关的功能 | ||
|
||
## 补充说明 | ||
|
||
**bind命** 用于显示和设置命令行的键盘序列绑定功能。通过这一命令,可以提高命令行中操作效率。您可以利用bind命令了解有哪些按键组合与其功能,也可以自行指定要用哪些按键组合。 | ||
|
||
### 语法 | ||
|
||
``` | ||
bind(选项) | ||
``` | ||
|
||
### 选项 | ||
|
||
``` | ||
-d:显示按键配置的内容; | ||
-f<按键配置文件>:载入指定的按键配置文件; | ||
-l:列出所有的功能; | ||
-m<按键配置>:指定按键配置; | ||
-q<功能>:显示指定功能的按键; | ||
-v:列出目前的按键配置与其功能。 | ||
``` | ||
|
||
### 实例 | ||
|
||
``` | ||
bind -x '"\C-l":ls -l' #直接按 CTRL+L 就列出目录 | ||
``` | ||
|
||
其中keyseq可以使用`showkey -a`命令来获取: | ||
|
||
``` | ||
[root@localhost ~]# showkey -a | ||
Press any keys - Ctrl-D will terminate this program | ||
^[[A 27 0033 0x1b 上 | ||
91 0133 0x5b | ||
65 0101 0x41 | ||
^[[B 27 0033 0x1b 下 | ||
91 0133 0x5b | ||
66 0102 0x42 | ||
^[[D 27 0033 0x1b 左 | ||
91 0133 0x5b | ||
68 0104 0x44 | ||
^[[C 27 0033 0x1b 右 | ||
91 0133 0x5b | ||
67 0103 0x43 | ||
32 0040 0x20 | ||
^M 13 0015 0x0d 字母M | ||
^C 3 0003 0x03 Ctrl-C | ||
^D 4 0004 0x04 Ctrl-D 退出 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
bunzip2 | ||
=== | ||
|
||
创一个bz2文件压缩包 | ||
|
||
## 补充说明 | ||
|
||
**bunzip2命** 解压缩由bzip2指令创建的”.bz2"压缩包。对文件进行压缩与解压缩。此命令类似于“gzip/gunzip”命令,只能对文件进行压缩。对于目录只能压缩目录下的所有文件,压缩完成后,在目录下生成以“.bz2”为后缀的压缩包。bunzip2其实是bzip2的符号链接,即软链接,因此压缩解压都可以通过bzip2实现。 | ||
|
||
### 语法 | ||
|
||
``` | ||
bunzip2(选项)(参数) | ||
``` | ||
|
||
### 选项 | ||
|
||
``` | ||
-f或--force:解压缩时,若输出的文件与现有文件同名时,预设不会覆盖现有的文件; | ||
-k或——keep:在解压缩后,预设会删除原来的压缩文件。若要保留压缩文件,请使用此参数; | ||
-s或——small:降低程序执行时,内存的使用量; | ||
-v或——verbose:解压缩文件时,显示详细的信息; | ||
-l,--license,-V或——version:显示版本信息。 | ||
``` | ||
|
||
### 参数 | ||
|
||
.bz2压缩包:指定需要解压缩的.bz2压缩包。 | ||
|
||
### 实例 | ||
|
||
将`/opt`目录下的etc.zip、var.zip和backup.zip进行压缩,设置压缩率为最高,同时在压缩完毕后不删除原始文件,显示压缩过程的详细信息。 | ||
|
||
``` | ||
bzip2 -9vk /opt/etc.zip /opt/var.zip /opt/backup.zip | ||
``` | ||
|
||
压缩完毕后,在`/opt`下就会生成相应的etc.zip.bz2、var.zip.bz2和backup.zip.bz2文件。 |
Oops, something went wrong.