Skip to content

Commit 426e34d

Browse files
committed
📝 Writing docs.
1 parent 4d8af02 commit 426e34d

9 files changed

Lines changed: 562 additions & 2348 deletions

File tree

docs/linux/README.md

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
# linux
22

3-
* [linux 系统目录结构](linux系统目录结构.md)
4-
* [linux 文件基本属性](linux文件基本属性.md)
5-
* [linux 监控](linux监控.md)
6-
* [linux 软件](软件/README.md)
7-
* [samba使用详解](软件/samba使用详解.md)
8-
* [linux 常用命令](commands/README.md)
9-
* [命令行的艺术(转载)](commands/命令行的艺术.md)
10-
* [linux 常用命令-文件目录管理](commands/文件目录管理/README.md)
11-
* [linux 常用命令-文件内容查看](commands/文件目录管理/文件内容查看.md)
12-
* [linux 常用命令-文件压缩与解压](commands/文件目录管理/文件压缩与解压.md)
13-
* [linux 常用命令-文件处理](commands/文件目录管理/文件处理.md)
14-
* [linux 常用命令-文件编辑](commands/文件目录管理/文件编辑.md)
15-
* [linux 常用命令-文件权限属性设置](commands/文件目录管理/文件权限属性设置.md)
16-
* [linux 常用命令-文件查找和比较](commands/文件目录管理/文件查找和比较.md)
17-
* [linux 常用命令-目录基本操作](commands/文件目录管理/目录基本操作.md)
18-
* [linux 常用命令-系统管理](commands/系统管理/README.md)
19-
* [linux 常用命令-系统操作](commands/系统管理/系统操作.md)
20-
* [linux 常用命令-系统设置](commands/系统管理/系统设置.md)
21-
* [linux 常用命令-用户和工作组管理](commands/系统管理/用户和工作组管理.md)
22-
* [linux 常用命令-进程和作业管理](commands/系统管理/进程和作业管理.md)
23-
* [linux 常用命令-系统性能管理](commands/系统管理/系统性能管理.md)
24-
* [linux 常用命令-网络管理](commands/网络管理/README.md)
25-
* [linux 常用命令-网络应用](commands/网络管理/网络应用.md)
26-
* [yum 命令](yum.md)
3+
- [linux 系统目录结构](linux系统目录结构.md)
4+
- [linux 文件基本属性](linux文件基本属性.md)
5+
- [linux 监控](linux监控.md)
6+
- [linux 软件](软件/README.md)
7+
- [samba 使用详解](软件/samba使用详解.md)
8+
- [linux 常用命令](commands/README.md)
9+
- [命令行的艺术(转载)](commands/命令行的艺术.md)
10+
- [Linux 帮助命令](commands/Linux帮助命令.md) - 关键词:`help`, `whatis`, `info`, `man`, `which`, `whereis`
11+
- [linux 常用命令-文件目录管理](commands/文件目录管理/README.md)
12+
- [linux 常用命令-文件内容查看](commands/文件目录管理/文件内容查看.md)
13+
- [linux 常用命令-文件压缩与解压](commands/文件目录管理/文件压缩与解压.md)
14+
- [linux 常用命令-文件处理](commands/文件目录管理/文件处理.md)
15+
- [linux 常用命令-文件编辑](commands/文件目录管理/文件编辑.md)
16+
- [linux 常用命令-文件权限属性设置](commands/文件目录管理/文件权限属性设置.md)
17+
- [linux 常用命令-文件查找和比较](commands/文件目录管理/文件查找和比较.md)
18+
- [linux 常用命令-目录基本操作](commands/文件目录管理/目录基本操作.md)
19+
- [linux 常用命令-系统管理](commands/系统管理/README.md)
20+
- [linux 常用命令-系统操作](commands/系统管理/系统操作.md)
21+
- [linux 常用命令-系统设置](commands/系统管理/系统设置.md)
22+
- [linux 常用命令-用户和工作组管理](commands/系统管理/用户和工作组管理.md)
23+
- [linux 常用命令-进程和作业管理](commands/系统管理/进程和作业管理.md)
24+
- [linux 常用命令-系统性能管理](commands/系统管理/系统性能管理.md)
25+
- [Linux 网络应用命令](commands/Linux网络应用命令.md) - 关键词:`curl`, `wget`, `telnet`, `ip`, `hostname`, `ifconfig`, `route`, `ssh`, `ssh-keygen`, `iptables`
26+
- [Linux 网络测试命令](commands/Linux网络测试命令.md) - 关键词:`host`, `nslookup`, `nc`/`netcat`, `dig`, `ping`, `traceroute`, `netstat`
27+
- [yum 命令](yum.md)
2728

2829
## 资料
2930

30-
* [awesome-linux](https://github.com/aleksandar-todorovic/awesome-linux)
31-
* [awesome-linux-software](https://github.com/LewisVo/Awesome-Linux-Software)
32-
* [linux-tutorial](https://github.com/judasn/Linux-Tutorial)
33-
* [菜鸟教程-Linux](http://www.runoob.com/linux/linux-tutorial.html)
31+
- [awesome-linux](https://github.com/aleksandar-todorovic/awesome-linux)
32+
- [awesome-linux-software](https://github.com/LewisVo/Awesome-Linux-Software)
33+
- [linux-tutorial](https://github.com/judasn/Linux-Tutorial)
34+
- [菜鸟教程-Linux](http://www.runoob.com/linux/linux-tutorial.html)
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: Linux 帮助命令
3+
date: 2018/09/26
4+
categories:
5+
- linux
6+
tags:
7+
- linux
8+
- command
9+
---
10+
11+
# Linux 帮助命令
12+
13+
> 关键词:`help`, `whatis`, `info`, `man`, `which`, `whereis`
14+
15+
<!-- TOC depthFrom:2 depthTo:2 -->
16+
17+
- [help](#help)
18+
- [whatis](#whatis)
19+
- [info](#info)
20+
- [man](#man)
21+
- [which](#which)
22+
- [whereis](#whereis)
23+
24+
<!-- /TOC -->
25+
26+
## help
27+
28+
> help 命令用于显示 Shell 内部命令的帮助信息。而对于外部命令的帮助信息只能使用 man 或者 info 命令查看。
29+
>
30+
> 参考:http://man.linuxde.net/help
31+
32+
## whatis
33+
34+
> whatis 用于查询一个命令执行什么功能。
35+
>
36+
> 参考:http://man.linuxde.net/whatis
37+
38+
## info
39+
40+
> info 是 Linux 下 info 格式的帮助指令。
41+
>
42+
> 参考:http://man.linuxde.net/info
43+
44+
## man
45+
46+
> man 命令是 Linux 下的帮助指令,通过 man 指令可以查看 Linux 中的指令帮助、配置文件帮助和编程帮助等信息。
47+
>
48+
> 参考:http://man.linuxde.net/man
49+
50+
## which
51+
52+
> which 命令用于查找并显示给定命令的绝对路径,环境变量 PATH 中保存了查找命令时需要遍历的目录。
53+
>
54+
> 参考:http://man.linuxde.net/which
55+
56+
示例:
57+
58+
```sh
59+
# which pwd
60+
/bin/pwd
61+
```
62+
63+
## whereis
64+
65+
> whereis 命令用来定位指令的二进制程序、源代码文件和 man 手册页等相关文件的路径。
66+
>
67+
> 参考:http://man.linuxde.net/whereis
68+
69+
示例:
70+
71+
```sh
72+
# whereis git
73+
git: /usr/bin/git /usr/share/man/man1/git.1.gz
74+
```
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Linux 文件目录管理
2+
3+
<!-- TOC depthFrom:2 depthTo:2 -->
4+
5+
6+
<!-- /TOC -->
Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
---
2+
title: Linux 网络应用命令
3+
date: 2018/02/27
4+
categories:
5+
- linux
6+
tags:
7+
- linux
8+
- command
9+
---
10+
11+
# Linux 网络应用命令
12+
13+
> 关键词:`curl`, `wget`, `telnet`, `ip`, `hostname`, `ifconfig`, `route`, `ssh`, `ssh-keygen`, `iptables`
14+
15+
<!-- TOC depthFrom:2 depthTo:2 -->
16+
17+
- [curl](#curl)
18+
- [wget](#wget)
19+
- [telnet](#telnet)
20+
- [ip](#ip)
21+
- [hostname](#hostname)
22+
- [ifconfig](#ifconfig)
23+
- [route](#route)
24+
- [ssh](#ssh)
25+
- [ssh-keygen](#ssh-keygen)
26+
- [iptables](#iptables)
27+
28+
<!-- /TOC -->
29+
30+
## curl
31+
32+
> curl 命令是一个利用 URL 规则在命令行下工作的文件传输工具。
33+
>
34+
> 参考:http://man.linuxde.net/curl
35+
36+
curl 命令支持文件的上传和下载,所以是综合传输工具,但按传统,习惯称 curl 为下载工具。作为一款强力工具,curl 支持包括 HTTP、HTTPS、ftp 等众多协议,还支持 POST、cookies、认证、从指定偏移处下载部分文件、用户代理字符串、限速、文件大小、进度条等特征。做网页处理流程和数据检索自动化,curl 可以祝一臂之力。
37+
38+
示例:
39+
40+
下载文件
41+
42+
```sh
43+
curl http://man.linuxde.net/text.iso --silent
44+
```
45+
46+
下载文件,指定下载路径,并显示进度
47+
48+
```sh
49+
curl http://man.linuxde.net/test.iso -o filename.iso --progress
50+
######################################### 100.0%
51+
```
52+
53+
## wget
54+
55+
> wget 命令用来从指定的 URL 下载文件。
56+
>
57+
> 参考:http://man.linuxde.net/wget
58+
59+
示例:
60+
61+
```sh
62+
# 使用 wget 下载单个文件
63+
wget http://www.linuxde.net/testfile.zip
64+
```
65+
66+
## telnet
67+
68+
> telnet 命令用于登录远程主机,对远程主机进行管理。
69+
>
70+
> 参考:http://man.linuxde.net/telnet
71+
72+
示例:
73+
74+
```sh
75+
telnet 192.168.2.10
76+
Trying 192.168.2.10...
77+
Connected to 192.168.2.10 (192.168.2.10).
78+
Escape character is '^]'.
79+
80+
localhost (Linux release 2.6.18-274.18.1.el5 #1 SMP Thu Feb 9 12:45:44 EST 2012) (1)
81+
82+
login: root
83+
Password:
84+
Login incorrect
85+
```
86+
87+
## ip
88+
89+
> ip 命令用来显示或操纵 Linux 主机的路由、网络设备、策略路由和隧道,是 Linux 下较新的功能强大的网络配置工具。
90+
>
91+
> 参考:http://man.linuxde.net/ip
92+
93+
示例:
94+
95+
```sh
96+
ip link show # 显示网络接口信息
97+
ip link set eth0 upi # 开启网卡
98+
ip link set eth0 down # 关闭网卡
99+
ip link set eth0 promisc on # 开启网卡的混合模式
100+
ip link set eth0 promisc offi # 关闭网卡的混个模式
101+
ip link set eth0 txqueuelen 1200 # 设置网卡队列长度
102+
ip link set eth0 mtu 1400 # 设置网卡最大传输单元
103+
ip addr show # 显示网卡IP信息
104+
ip addr add 192.168.0.1/24 dev eth0 # 设置eth0网卡IP地址192.168.0.1
105+
ip addr del 192.168.0.1/24 dev eth0 # 删除eth0网卡IP地址
106+
107+
ip route show # 显示系统路由
108+
ip route add default via 192.168.1.254 # 设置系统默认路由
109+
ip route list # 查看路由信息
110+
ip route add 192.168.4.0/24 via 192.168.0.254 dev eth0 # 设置192.168.4.0网段的网关为192.168.0.254,数据走eth0接口
111+
ip route add default via 192.168.0.254 dev eth0 # 设置默认网关为192.168.0.254
112+
ip route del 192.168.4.0/24 # 删除192.168.4.0网段的网关
113+
ip route del default # 删除默认路由
114+
ip route delete 192.168.1.0/24 dev eth0 # 删除路由
115+
```
116+
117+
## hostname
118+
119+
> hostname 命令用于显示和设置系统的主机名称。环境变量 HOSTNAME 也保存了当前的主机名。在使用 hostname 命令设置主机名后,系统并不会永久保存新的主机名,重新启动机器之后还是原来的主机名。如果需要永久修改主机名,需要同时修改 `/etc/hosts``/etc/sysconfig/network` 的相关内容。
120+
>
121+
> 参考:http://man.linuxde.net/hostname
122+
123+
示例:
124+
125+
```sh
126+
[root@AY1307311912260196fcZ ~]# hostname
127+
AY1307311912260196fcZ
128+
```
129+
130+
## ifconfig
131+
132+
> ifconfig 命令被用于配置和显示 Linux 内核中网络接口的网络参数。用 ifconfig 命令配置的网卡信息,在网卡重启后机器重启后,配置就不存在。要想将上述的配置信息永远的存的电脑里,那就要修改网卡的配置文件了。
133+
>
134+
> 参考:http://man.linuxde.net/ifconfig
135+
136+
示例:
137+
138+
```sh
139+
# 显示网络设备信息(激活状态的)
140+
[root@localhost ~]# ifconfig
141+
eth0 Link encap:Ethernet HWaddr 00:16:3E:00:1E:51
142+
inet addr:10.160.7.81 Bcast:10.160.15.255 Mask:255.255.240.0
143+
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
144+
RX packets:61430830 errors:0 dropped:0 overruns:0 frame:0
145+
TX packets:88534 errors:0 dropped:0 overruns:0 carrier:0
146+
collisions:0 txqueuelen:1000
147+
RX bytes:3607197869 (3.3 GiB) TX bytes:6115042 (5.8 MiB)
148+
149+
lo Link encap:Local Loopback
150+
inet addr:127.0.0.1 Mask:255.0.0.0
151+
UP LOOPBACK RUNNING MTU:16436 Metric:1
152+
RX packets:56103 errors:0 dropped:0 overruns:0 frame:0
153+
TX packets:56103 errors:0 dropped:0 overruns:0 carrier:0
154+
collisions:0 txqueuelen:0
155+
RX bytes:5079451 (4.8 MiB) TX bytes:5079451 (4.8 MiB)
156+
```
157+
158+
## route
159+
160+
> route 命令用来显示并设置 Linux 内核中的网络路由表,route 命令设置的路由主要是静态路由。要实现两个不同的子网之间的通信,需要一台连接两个网络的路由器,或者同时位于两个网络的网关来实现。
161+
>
162+
> 参考:http://man.linuxde.net/route
163+
164+
示例:
165+
166+
```sh
167+
# 显示当前路由
168+
route
169+
Kernel IP routing table
170+
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
171+
112.124.12.0    *               255.255.252.0   U     0      0        0 eth1
172+
10.160.0.0      *               255.255.240.0   U     0      0        0 eth0
173+
192.168.0.0     10.160.15.247   255.255.0.0     UG    0      0        0 eth0
174+
172.16.0.0      10.160.15.247   255.240.0.0     UG    0      0        0 eth0
175+
10.0.0.0        10.160.15.247   255.0.0.0       UG    0      0        0 eth0
176+
default         112.124.15.247  0.0.0.0         UG    0      0        0 eth1
177+
178+
route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0 # 添加网关/设置网关
179+
route add -net 224.0.0.0 netmask 240.0.0.0 reject # 屏蔽一条路由
180+
route del -net 224.0.0.0 netmask 240.0.0.0 # 删除路由记录
181+
route add default gw 192.168.120.240 # 添加默认网关
182+
route del default gw 192.168.120.240 # 删除默认网关
183+
```
184+
185+
## ssh
186+
187+
> ssh 命令是 openssh 套件中的客户端连接工具,可以给予 ssh 加密协议实现安全的远程登录服务器。
188+
>
189+
> 参考:http://man.linuxde.net/ssh
190+
191+
示例:
192+
193+
```bash
194+
# ssh 用户名@远程服务器地址
195+
ssh user1@172.24.210.101
196+
# 指定端口
197+
ssh -p 2211 root@140.206.185.170
198+
```
199+
200+
引申阅读:[ssh 背后的故事](https://linux.cn/article-8476-1.html)
201+
202+
## ssh-keygen
203+
204+
> ssh-keygen 命令用于为 ssh 生成、管理和转换认证密钥,它支持 RSA 和 DSA 两种认证密钥。
205+
>
206+
> 参考:http://man.linuxde.net/ssh-keygen
207+
208+
为 ssh 生成、管理和转换认证密钥
209+
210+
## iptables
211+
212+
> iptables 命令是 Linux 上常用的防火墙软件,是 netfilter 项目的一部分。可以直接配置,也可以通过许多前端和图形界面配置。
213+
>
214+
> 参考:http://man.linuxde.net/iptables
215+
216+
为 ssh 生成、管理和转换认证密钥
217+
218+
示例:
219+
220+
```sh
221+
# 开放指定的端口
222+
iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT #允许本地回环接口(即运行本机访问本机)
223+
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT #允许已建立的或相关连的通行
224+
iptables -A OUTPUT -j ACCEPT #允许所有本机向外的访问
225+
iptables -A INPUT -p tcp --dport 22 -j ACCEPT #允许访问22端口
226+
iptables -A INPUT -p tcp --dport 80 -j ACCEPT #允许访问80端口
227+
iptables -A INPUT -p tcp --dport 21 -j ACCEPT #允许ftp服务的21端口
228+
iptables -A INPUT -p tcp --dport 20 -j ACCEPT #允许FTP服务的20端口
229+
iptables -A INPUT -j reject #禁止其他未允许的规则访问
230+
iptables -A FORWARD -j REJECT #禁止其他未允许的规则访问
231+
232+
# 屏蔽IP
233+
iptables -I INPUT -s 123.45.6.7 -j DROP #屏蔽单个IP的命令
234+
iptables -I INPUT -s 123.0.0.0/8 -j DROP #封整个段即从123.0.0.1到123.255.255.254的命令
235+
iptables -I INPUT -s 124.45.0.0/16 -j DROP #封IP段即从123.45.0.1到123.45.255.254的命令
236+
iptables -I INPUT -s 123.45.6.0/24 -j DROP #封IP段即从123.45.6.1到123.45.6.254的命令是
237+
238+
# 查看已添加的iptables规则
239+
iptables -L -n -v
240+
Chain INPUT (policy DROP 48106 packets, 2690K bytes)
241+
pkts bytes target prot opt in out source destination
242+
5075 589K ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
243+
191K 90M ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
244+
1499K 133M ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
245+
4364K 6351M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
246+
6256 327K ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0
247+
248+
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
249+
pkts bytes target prot opt in out source destination
250+
251+
Chain OUTPUT (policy ACCEPT 3382K packets, 1819M bytes)
252+
pkts bytes target prot opt in out source destination
253+
5075 589K ACCEPT all -- * lo 0.0.0.0/0 0.0.0.0/0
254+
```

0 commit comments

Comments
 (0)