Skip to content

Commit bd1d58c

Browse files
daydaygojaywcjlove
authored andcommitted
完善自己平时积累的命令和使用示例
1 parent 4af9bdd commit bd1d58c

40 files changed

+933
-397
lines changed

command/ack.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ack
2+
===
3+
4+
比grep好用的文本搜索工具
5+
6+
## 示例
7+
8+
```
9+
# install
10+
apk install ack
11+
12+
# use
13+
ack
14+
```

command/apk.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
apk
2+
===
3+
4+
Alpine Linux 下的包管理工具
5+
6+
## quick start
7+
8+
```
9+
apk install xxx
10+
apk search xxx # 支持正则
11+
apk info xxx # 查看包的详细信息
12+
apk show # list local package
13+
```
14+
15+
## 笔记
16+
17+
还是蛮喜欢 alpine 的,简单纯粹
18+
19+
```
20+
apk add iproute2 # ss vs netstat
21+
ss -ptl
22+
apk add drill # drill vs nslookup&dig
23+
24+
crond # 开启 cron 服务
25+
crontab -l -e
26+
27+
apk add xxx
28+
apk search -v xxx
29+
apk info -a xxx
30+
apk info
31+
echo -e "http://mirrors.aliyun.com/alpine/v3.6/main\nhttp://mirrors.aliyun.com/alpine/v3.6/community" > /etc/apk/repositories
32+
apk update
33+
34+
# storage
35+
ibu # alpine local backup
36+
37+
# network
38+
echo "shortname" > /etc/hostname
39+
hostname -F /etc/hostname
40+
/etc/hosts
41+
/etc/resolv.conf # conig DNS
42+
modprobe ipv6 # enable ipv6
43+
echo "ipv6" >> /etc/modules
44+
iface # config interface
45+
apk add iptables ip6tables iptables-doc
46+
/etc/init.d/networking restart # activate change
47+
apke add iputils # IPv6 traceroute
48+
traceroute6 ipv6.google.com
49+
awall # alpine wall
50+
# setup a openvpn server
51+
52+
# post-install
53+
/etc/apk/repositories
54+
apk add cherokee --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
55+
apk search -v --description 'NTP' # show description and search from description
56+
apk info -a zlib
57+
apk info -vv|sort
58+
apk info -r -R # require / depency
59+
apk version -v -l '<' # show available updates
60+
apk upgrade -U -a
61+
apk add -u xxx # update xxx
62+
63+
/etc/runlevels # runlevel
64+
apk add openrc # use openrc for init system
65+
rc-update add xxx # set to start on
66+
rc-service xxx start # equal -> /etc/init.d/xxx start
67+
rc-status
68+
69+
adduser xxx
70+
passwd xxx
71+
72+
apk add ansible # server
73+
ssh-keygen
74+
/etc/ansible/hosts
75+
apk add python # node
76+
ssh-copy-id
77+
78+
apk add man man-pages mdocml-apropos less less-doc
79+
export PAGER=less
80+
/etc/rc.conf # /etc/rc.conf -> funny character
81+
apk add bash bash-doc bash-completion # bash
82+
apk add util-linux pciutils usbutils coreutils binutils findutils grep # grep / awk
83+
apk add build-base gcc abuild binutils binutils-doc gcc-doc # compile
84+
apk add cmake cmake-doc extra-cmake-modules extra-cmake-modules-doc
85+
apk add ccache ccache-doc
86+
87+
apk add docker # docker
88+
rc-update add docker boot
89+
rc-service docker start
90+
apk add py-pip
91+
pip install docker-compose
92+
ln -s /usr/bin/docker-compose /usr/bin/doc
93+
94+
# application
95+
apk add openssh # ssh
96+
rc-update add sshd
97+
/etc/init.d/sshd start
98+
/etc/sshd_config
99+
apk add dropbear # another openssh implementation
100+
```

command/cloc.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cloc
2+
===
3+
4+
代码行数统计
5+
6+
## quick start
7+
8+
```
9+
apk add cloc
10+
11+
cloc dir --exclude-dir # 代码行数统计
12+
```

command/curl.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ curl
77

88
**curl命令** 是一个利用URL规则在命令行下工作的文件传输工具。它支持文件的上传和下载,所以是综合传输工具,但按传统,习惯称curl为下载工具。作为一款强力工具,curl支持包括HTTP、HTTPS、ftp等众多协议,还支持POST、cookies、认证、从指定偏移处下载部分文件、用户代理字符串、限速、文件大小、进度条等特征。做网页处理流程和数据检索自动化,curl可以祝一臂之力。
99

10-
### 语法
10+
### 语法
1111

1212
```
1313
curl(选项)(参数)
1414
```
1515

16-
### 选项
16+
### 选项
1717

1818
<table border="0" cellpadding="0" cellspacing="0">
1919

@@ -119,9 +119,9 @@ curl(选项)(参数)
119119

120120
</table>
121121

122-
### 实例
122+
### 实例
123123

124-
**文件下载**
124+
**文件下载**
125125

126126
curl命令可以用来执行下载、发送各种HTTP请求,指定HTTP头部等操作。如果系统没有curl可以使用`yum install curl`安装,也可以下载安装。curl是将下载文件输出到stdout,将进度信息输出到stderr,不显示进度信息使用`--silent`选项。
127127

@@ -144,7 +144,7 @@ curl http://man.linuxde.net/test.iso -o filename.iso --progress
144144
######################################### 100.0%
145145
```
146146

147-
**断点续传**
147+
**断点续传**
148148

149149
curl能够从特定的文件偏移处继续下载,它可以通过指定一个便宜量来下载部分文件:
150150

@@ -155,7 +155,7 @@ curl URL/File -C 偏移量
155155
curl -C -URL
156156
```
157157

158-
**使用curl设置参照页字符串**
158+
**使用curl设置参照页字符串**
159159

160160
参照页是位于HTTP头部中的一个字符串,用来表示用户是从哪个页面到达当前页面的,如果用户点击网页A中的某个连接,那么用户就会跳转到B网页,网页B头部的参照页字符串就包含网页A的URL。
161161

@@ -165,7 +165,7 @@ curl -C -URL
165165
curl --referer http://www.google.com http://man.linuxde.net
166166
```
167167

168-
**用curl设置cookies**
168+
**用curl设置cookies**
169169

170170
使用`--cookie "COKKIES"`选项来指定cookie,多个cookie使用分号分隔:
171171

@@ -179,7 +179,7 @@ curl http://man.linuxde.net --cookie "user=root;pass=123456"
179179
curl URL --cookie-jar cookie_file
180180
```
181181

182-
**用curl设置用户代理字符串**
182+
**用curl设置用户代理字符串**
183183

184184
有些网站访问会提示只能使用IE浏览器来访问,这是因为这些网站设置了检查用户代理,可以使用curl把用户代理设置为IE,这样就可以访问了。使用`--user-agent`或者`-A`选项:
185185

@@ -194,7 +194,7 @@ curl URL -A "Mozilla/5.0"
194194
curl -H "Host:man.linuxde.net" -H "accept-language:zh-cn" URL
195195
```
196196

197-
**curl的带宽控制和下载配额**
197+
**curl的带宽控制和下载配额**
198198

199199
使用`--limit-rate`限制curl的下载速度:
200200

@@ -212,7 +212,7 @@ curl URL --max-filesize bytes
212212

213213
如果文件大小超出限制,命令则返回一个非0退出码,如果命令正常则返回0。
214214

215-
**用curl进行认证**
215+
**用curl进行认证**
216216

217217
使用curl选项 -u 可以完成HTTP或者FTP的认证,可以指定密码,也可以不指定密码在后续操作中输入密码:
218218

@@ -221,7 +221,7 @@ curl -u user:pwd http://man.linuxde.net
221221
curl -u user http://man.linuxde.net
222222
```
223223

224-
**只打印响应头部信息**
224+
**只打印响应头部信息**
225225

226226
通过`-I`或者`-head`可以只打印出HTTP头部信息:
227227

@@ -257,4 +257,10 @@ curl -d "param1=value1&param2=value2" "http://www.wangchujiang.com"
257257
curl -l -H "Content-type: application/json" -X POST -d '{"phone":"13521389587","password":"test"}' http://wangchujiang.com/apis/users.json
258258
```
259259

260+
**获取本机外网ip**
261+
262+
```bash
263+
curl ipecho.net/plain
264+
```
265+
260266
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->

command/dos2unix.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
dos2unix
22
===
3-
3+
44
将DOS格式文本文件转换成Unix格式
55

66
## 补充说明
77

88
**dos2unix命令** 用来将DOS格式的文本文件转换成UNIX格式的(DOS/MAC to UNIX text file format converter)。DOS下的文本文件是以`\r\n`作为断行标志的,表示成十六进制就是0D 0A。而Unix下的文本文件是以\n作为断行标志的,表示成十六进制就是0A。DOS格式的文本文件在Linux底下,用较低版本的vi打开时行尾会显示`^M`,而且很多命令都无法很好的处理这种格式的文件,如果是个shell脚本,。而Unix格式的文本文件在Windows下用Notepad打开时会拼在一起显示。因此产生了两种格式文件相互转换的需求,对应的将UNIX格式文本文件转成成DOS格式的是unix2dos命令。
99

10-
### 语法
10+
### 语法
1111

1212
```
1313
dos2unix [-hkqV] [-c convmode] [-o file ...] [-n infile outfile ...]
1414
```
1515

16-
### 选项
16+
### 选项
1717

1818
```
1919
-k:保持输出文件的日期不变
@@ -24,11 +24,11 @@ dos2unix [-hkqV] [-c convmode] [-o file ...] [-n infile outfile ...]
2424
-n:写入到新文件
2525
```
2626

27-
### 参数
27+
### 参数
2828

2929
参数:需要转换到文件。
3030

31-
### 实例
31+
### 实例
3232

3333
最简单的用法就是dos2unix直接跟上文件名:
3434

@@ -58,5 +58,10 @@ dos2unix -k -o file1 file2 file3
5858
dos2unix -k -n oldfile newfile
5959
```
6060

61+
转换当前目录下所有文件
62+
63+
```
64+
find -type f | xargs dos2unix
65+
```
6166

6267
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->

command/du.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
du
22
===
3-
3+
44
显示每个文件和目录的磁盘使用空间
55

66
## 补充说明
77

88
**du命令** 也是查看使用空间的,但是与df命令不同的是Linux du命令是对文件和目录磁盘使用的空间的查看,还是和df命令有一些区别的。
99

10-
### 语法
10+
### 语法
1111

1212
```
1313
du [选项][文件]
1414
```
1515

16-
### 选项
16+
### 选项
1717

1818
```
1919
-a或-all 显示目录中个别文件的大小。
@@ -33,7 +33,7 @@ du [选项][文件]
3333
-l或--count-links 重复计算硬件链接的文件。
3434
```
3535

36-
### 实例
36+
### 实例
3737

3838
显示目录或者文件所占空间:
3939

@@ -98,5 +98,10 @@ root@localhost [test]# du
9898
1288 test
9999
```
100100

101+
显示总和的大小且易读:
102+
103+
```
104+
du -sh $dir
105+
```
101106

102107
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->

0 commit comments

Comments
 (0)