完善自己平时积累的命令和使用示例
This commit is contained in:
parent
4af9bdd324
commit
bd1d58c152
|
|
@ -0,0 +1,14 @@
|
|||
ack
|
||||
===
|
||||
|
||||
比grep好用的文本搜索工具
|
||||
|
||||
## 示例
|
||||
|
||||
```
|
||||
# install
|
||||
apk install ack
|
||||
|
||||
# use
|
||||
ack
|
||||
```
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
apk
|
||||
===
|
||||
|
||||
Alpine Linux 下的包管理工具
|
||||
|
||||
## quick start
|
||||
|
||||
```
|
||||
apk install xxx
|
||||
apk search xxx # 支持正则
|
||||
apk info xxx # 查看包的详细信息
|
||||
apk show # list local package
|
||||
```
|
||||
|
||||
## 笔记
|
||||
|
||||
还是蛮喜欢 alpine 的,简单纯粹
|
||||
|
||||
```
|
||||
apk add iproute2 # ss vs netstat
|
||||
ss -ptl
|
||||
apk add drill # drill vs nslookup&dig
|
||||
|
||||
crond # 开启 cron 服务
|
||||
crontab -l -e
|
||||
|
||||
apk add xxx
|
||||
apk search -v xxx
|
||||
apk info -a xxx
|
||||
apk info
|
||||
echo -e "http://mirrors.aliyun.com/alpine/v3.6/main\nhttp://mirrors.aliyun.com/alpine/v3.6/community" > /etc/apk/repositories
|
||||
apk update
|
||||
|
||||
# storage
|
||||
ibu # alpine local backup
|
||||
|
||||
# network
|
||||
echo "shortname" > /etc/hostname
|
||||
hostname -F /etc/hostname
|
||||
/etc/hosts
|
||||
/etc/resolv.conf # conig DNS
|
||||
modprobe ipv6 # enable ipv6
|
||||
echo "ipv6" >> /etc/modules
|
||||
iface # config interface
|
||||
apk add iptables ip6tables iptables-doc
|
||||
/etc/init.d/networking restart # activate change
|
||||
apke add iputils # IPv6 traceroute
|
||||
traceroute6 ipv6.google.com
|
||||
awall # alpine wall
|
||||
# setup a openvpn server
|
||||
|
||||
# post-install
|
||||
/etc/apk/repositories
|
||||
apk add cherokee --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
|
||||
apk search -v --description 'NTP' # show description and search from description
|
||||
apk info -a zlib
|
||||
apk info -vv|sort
|
||||
apk info -r -R # require / depency
|
||||
apk version -v -l '<' # show available updates
|
||||
apk upgrade -U -a
|
||||
apk add -u xxx # update xxx
|
||||
|
||||
/etc/runlevels # runlevel
|
||||
apk add openrc # use openrc for init system
|
||||
rc-update add xxx # set to start on
|
||||
rc-service xxx start # equal -> /etc/init.d/xxx start
|
||||
rc-status
|
||||
|
||||
adduser xxx
|
||||
passwd xxx
|
||||
|
||||
apk add ansible # server
|
||||
ssh-keygen
|
||||
/etc/ansible/hosts
|
||||
apk add python # node
|
||||
ssh-copy-id
|
||||
|
||||
apk add man man-pages mdocml-apropos less less-doc
|
||||
export PAGER=less
|
||||
/etc/rc.conf # /etc/rc.conf -> funny character
|
||||
apk add bash bash-doc bash-completion # bash
|
||||
apk add util-linux pciutils usbutils coreutils binutils findutils grep # grep / awk
|
||||
apk add build-base gcc abuild binutils binutils-doc gcc-doc # compile
|
||||
apk add cmake cmake-doc extra-cmake-modules extra-cmake-modules-doc
|
||||
apk add ccache ccache-doc
|
||||
|
||||
apk add docker # docker
|
||||
rc-update add docker boot
|
||||
rc-service docker start
|
||||
apk add py-pip
|
||||
pip install docker-compose
|
||||
ln -s /usr/bin/docker-compose /usr/bin/doc
|
||||
|
||||
# application
|
||||
apk add openssh # ssh
|
||||
rc-update add sshd
|
||||
/etc/init.d/sshd start
|
||||
/etc/sshd_config
|
||||
apk add dropbear # another openssh implementation
|
||||
```
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
cloc
|
||||
===
|
||||
|
||||
代码行数统计
|
||||
|
||||
## quick start
|
||||
|
||||
```
|
||||
apk add cloc
|
||||
|
||||
cloc dir --exclude-dir # 代码行数统计
|
||||
```
|
||||
|
|
@ -257,4 +257,10 @@ curl -d "param1=value1¶m2=value2" "http://www.wangchujiang.com"
|
|||
curl -l -H "Content-type: application/json" -X POST -d '{"phone":"13521389587","password":"test"}' http://wangchujiang.com/apis/users.json
|
||||
```
|
||||
|
||||
**获取本机外网ip**
|
||||
|
||||
```bash
|
||||
curl ipecho.net/plain
|
||||
```
|
||||
|
||||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|
||||
|
|
|
|||
|
|
@ -58,5 +58,10 @@ dos2unix -k -o file1 file2 file3
|
|||
dos2unix -k -n oldfile newfile
|
||||
```
|
||||
|
||||
转换当前目录下所有文件
|
||||
|
||||
```
|
||||
find -type f | xargs dos2unix
|
||||
```
|
||||
|
||||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|
||||
|
|
@ -98,5 +98,10 @@ root@localhost [test]# du
|
|||
1288 test
|
||||
```
|
||||
|
||||
显示总和的大小且易读:
|
||||
|
||||
```
|
||||
du -sh $dir
|
||||
```
|
||||
|
||||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|
||||
|
|
@ -373,5 +373,17 @@ find /data -owner bcotton
|
|||
find ~ -perm -o=r
|
||||
```
|
||||
|
||||
删除 mac 下自动生成的文件
|
||||
|
||||
```
|
||||
find ./ -name '__MACOSX' -depth -exec rm -rf {} \;
|
||||
```
|
||||
|
||||
统计代码行数
|
||||
|
||||
```
|
||||
find . -name "*.java"|xargs cat|grep -v ^$|wc -l # 代码行数统计, 排除空行
|
||||
```
|
||||
|
||||
|
||||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
# fishshell
|
||||
|
||||
比 bash 更好用的 shell
|
||||
|
||||
## quick start
|
||||
|
||||
> [fish-shell](http://fishshell.com):强烈推荐
|
||||
|
||||
配置文件: `fish_config`
|
||||
Running Commands: 兼容 bash 等shell的命令执行方式
|
||||
Getting Help: `help/man cmd -> browser/terminal`
|
||||
Syntax Highlighting: 实时检查命令是否正确
|
||||
Wildcards: 支持缩写 `*` 递归 匹配
|
||||
Pipes and Redirections: 使用 `^` 代表 stderr
|
||||
Autosuggestions: 自动建议, 可以使用 `Ctrl-f / ->` 来补全
|
||||
Tab Completions: 更强大的 tab 补全
|
||||
Variables: 使用 set 设置
|
||||
Exit Status: 使用 `echo $status` 替代 `$?`
|
||||
Exports (Shell Variables)
|
||||
Lists: all variables in fish are really lists
|
||||
Command Substitutions: 使用 `(cmd)` 来执行命令, 而不是 反引号、`$()`
|
||||
Combiners (And, Or, Not): 不支持使用符合来表示逻辑运算
|
||||
Functions:使用 `$argv` 替代 `$1`
|
||||
Conditionals (If, Else, Switch) / Functions / Loops: 更人性化的写法(参考 py)
|
||||
Prompt: `function fish_prompt` 实现
|
||||
Startup (Where's .bashrc?): `~/.config/fish/config.fish`,更好的方式是 autoloading-function、universal-variables
|
||||
Autoloading Functions: ` ~/.config/fish/functions/.`
|
||||
Universal Variables:a variable whose value is shared across all instances of fish
|
||||
|
||||
```
|
||||
set name 'czl' # 设置变量,替代 name=czl
|
||||
echo $name
|
||||
echo $status # exit status,替代 $?
|
||||
env # 环境变量
|
||||
set -x MyVariable SomeValue # 替代 export
|
||||
set -e MyVariable
|
||||
set PATH $PATH /usr/local/bin # 使用 lists 记录 PATH
|
||||
set -U fish_user_paths /usr/local/bin $fish_user_paths # 永久生效
|
||||
touch "testing_"(date +%s)".txt" # command subtitution,替代 `date +%s`
|
||||
cp file.txt file.txt.bak; and echo 'back success'; or echo 'back fail' # combiner
|
||||
functions # 列出 fish 下定义的函数
|
||||
```
|
||||
|
|
@ -457,5 +457,50 @@ eax 0xbffff6a4 -1073744220
|
|||
The program is running. exit anyway? (y or n)
|
||||
```
|
||||
|
||||
## 补充内容
|
||||
|
||||
> gdb 教程:[慕课网-Linux C语言指针与内存-第三章](http://www.imooc.com/learn/394)
|
||||
|
||||
如果删除源代码, 就无法显示行号等辅助信息了
|
||||
|
||||
```
|
||||
gcc -g gdb.c -o gdb.out # -g 支持gdb调试; -o 输出, 默认为 a.out
|
||||
|
||||
gdb gdb.out # 进入 gdb 调试环境
|
||||
enter # 继续执行上条命令
|
||||
l # 列出源代码, 默认 10 行, 按 l 继续
|
||||
|
||||
start # 开始单步调试, 默认 main() 第一行
|
||||
p a # 查看 a 变量的值
|
||||
n # 继续到下一行
|
||||
s # 进入子函数
|
||||
bt # 查看函数栈
|
||||
f 1 # 切换函数栈
|
||||
|
||||
q 退出调试
|
||||
```
|
||||
|
||||
```c
|
||||
# 测试用代码
|
||||
#include <stdio.h>
|
||||
|
||||
void change(int a, int b){
|
||||
int tmp=a;
|
||||
a=b; b=tmp;
|
||||
}
|
||||
|
||||
void change2(int *a, int *b){
|
||||
int tmp=*a;
|
||||
*a=*b; *b=tmp;
|
||||
}
|
||||
|
||||
int main(){
|
||||
int a=5,b=3;
|
||||
change(a,b);
|
||||
printf("change:\na=%d\nb=%d\n", a,b);
|
||||
change2(&a,&b);
|
||||
printf("change2:\na=%d\nb=%d\n", a,b);
|
||||
}
|
||||
```
|
||||
|
||||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|
||||
|
|
@ -63,4 +63,15 @@ n:打印最近的n条历史命令。
|
|||
[root@localhost ~]# history -c
|
||||
```
|
||||
|
||||
更多实例:
|
||||
|
||||
```
|
||||
history -cw
|
||||
`~/.bash_history`: 保存历史命令
|
||||
`/etc/profile` -> HISSIZE: 历史命令保存数量
|
||||
推荐添加 h -> history, hsi -> history|grep 别名
|
||||
`!n`: 执行第 n 条历史命令
|
||||
`!xxx`: 执行最后一条 xxx 开头的命令
|
||||
```
|
||||
|
||||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|
||||
|
|
|
|||
|
|
@ -34,6 +34,11 @@ hostname(选项)(参数)
|
|||
```
|
||||
[root@AY1307311912260196fcZ ~]# hostname
|
||||
AY1307311912260196fcZ
|
||||
|
||||
# change hostname
|
||||
hostname newname # for now
|
||||
vi /etc/hosts # forever
|
||||
reboot
|
||||
```
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -393,5 +393,126 @@ iptables -I INPUT -j DROP -p tcp -s 0.0.0.0/0 -m string --algo kmp --string "cmd
|
|||
iptables -A INPUT -p tcp --syn -m limit --limit 5/second -j ACCEPT
|
||||
```
|
||||
|
||||
## 更多实例
|
||||
> 用iptables搭建一套强大的安全防护盾 http://www.imooc.com/learn/389
|
||||
|
||||
iptables: linux 下应用层防火墙工具
|
||||
|
||||
iptables 5链: 对应 Hook point
|
||||
netfilter: linux 操作系统核心层内部的一个数据包处理模块
|
||||
Hook point: 数据包在 netfilter 中的挂载点; `PRE_ROUTING / INPUT / OUTPUT / FORWARD / POST_ROUTING`
|
||||
|
||||
iptables & netfilter
|
||||

|
||||
|
||||
iptables 4表5链
|
||||

|
||||
|
||||
iptables rules
|
||||

|
||||
|
||||
- 4表
|
||||
|
||||
**filter**: 访问控制 / 规则匹配
|
||||
**nat**: 地址转发
|
||||
mangle / raw
|
||||
|
||||
- 规则
|
||||
|
||||
数据访问控制: ACCEPT / DROP / REJECT
|
||||
数据包改写(nat -> 地址转换): snat / dnat
|
||||
信息记录: log
|
||||
|
||||
## 使用场景实例
|
||||
- 场景一
|
||||
|
||||
开放 tcp 10-22/80 端口
|
||||
开放 icmp
|
||||
其他未被允许的端口禁止访问
|
||||
|
||||
存在的问题: 本机无法访问本机; 本机无法访问其他主机
|
||||
|
||||
- 场景二
|
||||
|
||||
ftp: 默认被动模式(服务器产生随机端口告诉客户端, 客户端主动连接这个端口拉取数据)
|
||||
vsftpd: 使 ftp 支持主动模式(客户端产生随机端口通知服务器, 服务器主动连接这个端口发送数据)
|
||||
|
||||
- 场景三
|
||||
|
||||
允许外网访问:
|
||||
web
|
||||
http -> 80/tcp; https -> 443/tcp
|
||||
mail
|
||||
smtp -> 25/tcp; smtps -> 465/tcp
|
||||
pop3 -> 110/tcp; pop3s -> 995/tcp
|
||||
imap -> 143/tcp
|
||||
|
||||
内部使用:
|
||||
file
|
||||
nfs -> 123/udp
|
||||
samba -> 137/138/139/445/tcp
|
||||
ftp -> 20/21/tcp
|
||||
remote
|
||||
ssh -> 22/tcp
|
||||
sql
|
||||
mysql -> 3306/tcp
|
||||
oracle -> 1521/tcp
|
||||
|
||||
- 场景四
|
||||
|
||||
nat 转发
|
||||
|
||||
- 场景五
|
||||
|
||||
防CC攻击
|
||||
|
||||
```
|
||||
iptables -L -F -A -D # list flush append delete
|
||||
# 场景一
|
||||
iptables -I INPUT -p tcp --dport 80 -j ACCEPT # 允许 tcp 80 端口
|
||||
iptables -I INPUT -p tcp --dport 10:22 -j ACCEPT # 允许 tcp 10-22 端口
|
||||
iptables -I INPUT -p icmp -j ACCEPT # 允许 icmp
|
||||
iptables -A INPUT -j REJECT # 添加一条规则, 不允许所有
|
||||
|
||||
# 优化场景一
|
||||
iptables -I INPUT -i lo -j ACCEPT # 允许本机访问
|
||||
iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # 允许访问外网
|
||||
iptables -I INPUT -p tcp --dport 80 -s 10.10.188.233 -j ACCEPT # 只允许固定ip访问80
|
||||
|
||||
# 场景二
|
||||
vi /etc/vsftpd/vsftpd.conf # 使用 vsftpd 开启 ftp 主动模式
|
||||
port_enable=yes
|
||||
connect_from_port_20=YES
|
||||
iptables -I INPUT -p tcp --dport 21 -j ACCEPT
|
||||
|
||||
vi /etc/vsftpd/vsftpd.conf # 建议使用 ftp 被动模式
|
||||
pasv_min_port=50000
|
||||
pasv_max_port=60000
|
||||
iptables -I INPUT -p tcp --dport 21 -j ACCEPT
|
||||
iptables -I INPUT -p tcp --dport 50000:60000 -j ACCEPT
|
||||
|
||||
# 还可以使用 iptables 模块追踪来自动开发对应的端口
|
||||
|
||||
# 场景三
|
||||
iptables -I INPUT -i lo -j ACCEPT # 允许本机访问
|
||||
iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # 允许访问外网
|
||||
iptables -I INPUT -s 10.10.155.0/24 -j ACCEPT # 允许内网访问
|
||||
iptables -I INPUT -p tcp -m multiport --dports 80,1723 -j ACCEPT # 允许端口, 80 -> http, 1723 -> vpn
|
||||
iptables -A INPUT -j REJECT # 添加一条规则, 不允许所有
|
||||
|
||||
iptables-save # 保存设置到配置文件
|
||||
|
||||
# 场景四
|
||||
iptables -t nat -L # 查看 nat 配置
|
||||
|
||||
iptables -t nat -A POST_ROUTING -s 10.10.177.0/24 -j SNAT --to 10.10.188.232 # SNAT
|
||||
vi /etc/sysconfig/network # 配置网关
|
||||
|
||||
iptables -t nat -A POST_ROUTING -d 10.10.188.232 -p tcp --dport 80 -j DNAT --to 10.10.177.232:80 # DNAT
|
||||
|
||||
#场景五
|
||||
iptables -I INPUT -p tcp --syn --dport 80 -m connlimit --connlimit-above 100 -j REJECT # 限制并发连接访问数
|
||||
iptables -I INPUT -m limit --limit 3/hour --limit-burst 10 -j ACCEPT # limit模块; --limit-burst 默认为5
|
||||
```
|
||||
|
||||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ kill
|
|||
|
||||
```
|
||||
kill(选项)(参数)
|
||||
xkill # 图形化关闭程序
|
||||
```
|
||||
|
||||
### 选项
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
locate
|
||||
===
|
||||
|
||||
Apache服务器的性能测试工具
|
||||
比 find 好用的文件查找工具
|
||||
|
||||
## 补充说明
|
||||
|
||||
|
|
@ -13,7 +13,6 @@ locate指定用在搜寻符合条件的档案,它会去储存档案与目录
|
|||
|
||||
locate指令和find找寻档案的功能类似,但locate是透过update程序将硬盘中的所有档案和目录资料先建立一个索引数据库,在 执行loacte时直接找该索引,查询速度会较快,索引数据库一般是由操作系统管理,但也可以直接下达update强迫系统立即修改索引数据库。
|
||||
|
||||
|
||||
### 语法
|
||||
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
lsof
|
||||
===
|
||||
|
||||
显示Linux系统当前已打开的所有文件列表
|
||||
显示Linux系统当前已打开的所有文件列表 `lsof -p pid`
|
||||
|
||||
## 补充说明
|
||||
|
||||
|
|
@ -127,5 +127,10 @@ events/1 7 root cwd DIR 8,2 4096 2 /
|
|||
9. NODE:索引节点(文件在磁盘上的标识)
|
||||
10. NAME:打开文件的确切名称
|
||||
|
||||
列出指定进程号所打开的文件:
|
||||
|
||||
```
|
||||
lsof -p $pid
|
||||
```
|
||||
|
||||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
mtr
|
||||
===
|
||||
|
||||
比 traceroute 好用
|
||||
|
||||
## 实例
|
||||
|
||||
```
|
||||
apk add mtr # 安装
|
||||
|
||||
mtr -r www.baidu.com # 使用
|
||||
```
|
||||
|
|
@ -220,5 +220,13 @@ cert.pem为X.509证书文件,用私匙key,pem为mail.txt签名,证书被包
|
|||
# openssl smime -verify -in mail.sgn -out mail.txt
|
||||
```
|
||||
|
||||
更多实例:
|
||||
|
||||
```
|
||||
openssl version -a
|
||||
openssl help
|
||||
openssl genrsa -aes128 -out fd.key 2048 # pem format
|
||||
openssl rsa -text -in fd.key
|
||||
```
|
||||
|
||||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|
||||
|
|
|
|||
|
|
@ -106,5 +106,4 @@ rm -I file1 file2 file3
|
|||
rm -v [文件/目录]
|
||||
```
|
||||
|
||||
|
||||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|
||||
|
|
|
|||
|
|
@ -210,5 +210,33 @@ rpm -qf /usr/share/doc/proftpd-1.2.8/rfc/rfc0959.txt
|
|||
proftpd-1.2.8-1
|
||||
```
|
||||
|
||||
## 更多实例
|
||||
> 库依赖: http://rpmfind.net/
|
||||
|
||||
源码包 -> 编译 -> 二进制包(rpm 包 / 系统默认包)
|
||||
|
||||
rpm 命名规则: 软件(软件名, 软件版本) + 系统(os 版本, os 位数)
|
||||
rpm 校验: SM5DLUGT -> size modified(类型/权限) md5 device L(文件路径) user group time(modified time)
|
||||
|
||||
yum: 解决 rpm 依赖的问题
|
||||
|
||||
```
|
||||
# rpm
|
||||
mysql57-community-release-el6-8.noarch.rpm # 一个 rpm 包的例子
|
||||
/var/lib/rpm/ # 包全名 -> 包名 的数据库
|
||||
|
||||
rpm -Uivh --dodeps xxx # upgrade install verbose hash
|
||||
rpm -qilpfa|grep xxx # query info list(rpm包安装后的文件位置) package(rpm 包) file(文件属于哪个rpm文件) all
|
||||
rpm -e # erase
|
||||
rpm -V # verify
|
||||
rpm2cpio | cpio -idv
|
||||
|
||||
# rpm 默认安装位置
|
||||
/etc/ 配置文件
|
||||
/usr/bin/ 可执行文件
|
||||
/urs/lib/ 程序使用的函数库
|
||||
/usr/share/doc/ 使用手册
|
||||
/usr/share/man/ manual
|
||||
```
|
||||
|
||||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|
||||
|
|
@ -222,5 +222,4 @@ sent 258 bytes received 76 bytes 95.43 bytes/sec
|
|||
total size is 150995011 speedup is 452080.87
|
||||
```
|
||||
|
||||
|
||||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# rz
|
||||
|
||||
文件上传
|
||||
|
||||
## quick start
|
||||
|
||||
```
|
||||
apk add lrzsz
|
||||
|
||||
rz
|
||||
```
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
ss
|
||||
===
|
||||
|
||||
获取socket统计信息,iproute2 包附带的另一个工具,允许你查询 socket 的有关统计信息。
|
||||
比 netstat 好用的socket统计信息,iproute2 包附带的另一个工具,允许你查询 socket 的有关统计信息。
|
||||
|
||||
## 补充说明
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,12 @@ ssh(选项)(参数)
|
|||
ssh user1@172.24.210.101
|
||||
# 指定端口
|
||||
ssh -p 2211 root@140.206.185.170
|
||||
|
||||
# ssh 大家族
|
||||
ssh user@ip -p22 # 默认用户名为当前用户名,默认端口为 22
|
||||
ssh-keygen # 为当前用户生成 ssh 公钥 + 私钥
|
||||
ssh-keygen -f keyfile -i -m key_format -e -m key_format # key_format: RFC4716/SSH2(default) PKCS8 PEM
|
||||
ssh-copy-id user@ip:port # 将当前用户的公钥复制到需要 ssh 的服务器的 ~/.ssh/authorized_keys,之后可以免密登录
|
||||
```
|
||||
|
||||
### 背后故事
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
supervisord
|
||||
===
|
||||
|
||||
配置后台服务/常驻进程的工具
|
||||
|
||||
## 实例
|
||||
|
||||
```
|
||||
# supervisord
|
||||
apt-get install supervisor
|
||||
[program:app]
|
||||
command=/usr/bin/gunicorn -w 1 wsgiapp:application
|
||||
directory=/srv/www
|
||||
user=www-data
|
||||
|
||||
supervisord: 启动 supervisor 服务
|
||||
supervisorctl start app
|
||||
supervisorctl stop app
|
||||
supervisorctl reload # 修改/添加配置文件需要执行这个
|
||||
```
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
sz
|
||||
===
|
||||
|
||||
对话框式文件下载工具
|
||||
|
||||
## 实例
|
||||
|
||||
```
|
||||
apk add lrzsz # 安装
|
||||
|
||||
sz $file # 下载
|
||||
```
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
telnet
|
||||
===
|
||||
|
||||
登录远程主机和管理
|
||||
登录远程主机和管理(测试ip端口是否连通)
|
||||
|
||||
## 补充说明
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
tmux
|
||||
===
|
||||
|
||||
比 screen 好用的 ssh 窗口管理工具
|
||||
|
||||
## 实例
|
||||
|
||||
```
|
||||
apk add tmux # 安装
|
||||
|
||||
# tmux
|
||||
tmux # new session
|
||||
tmux a # attach session
|
||||
C-b-d # detach session
|
||||
C-b-c # new window
|
||||
C-b-num # ch window
|
||||
exit # exit window
|
||||
C-b "/% # split window
|
||||
C-b 方向键
|
||||
C-b ? # keymap
|
||||
no rz/sz
|
||||
```
|
||||
|
|
@ -59,5 +59,12 @@ usermod -L newuser1
|
|||
usermod -U newuser1
|
||||
```
|
||||
|
||||
增加用户到用户组中:
|
||||
|
||||
```
|
||||
apk add shadow # 安装 shadow 包, usermod 命令包含在 usermod 中
|
||||
|
||||
usermod -aG group user # 添加用户到用户组中
|
||||
```
|
||||
|
||||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|
||||
|
|
@ -102,5 +102,28 @@ yum clean headers #清除缓存目录下的 headers
|
|||
yum clean oldheaders #清除缓存目录下旧的 headers
|
||||
```
|
||||
|
||||
**更多实例**
|
||||
|
||||
```
|
||||
# yum
|
||||
/etc/yum.repos.d/ yum 源配置文件
|
||||
vi /etc/yum.repos.d/nginx.repo # 举个栗子: nginx yum源
|
||||
[nginx]
|
||||
name=nginx repo
|
||||
baseurl=http://nginx.org/packages/centos/6/$basearch/
|
||||
gpgcheck=0
|
||||
enabled=1
|
||||
|
||||
# yum mirror
|
||||
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
|
||||
wget https://mirror.tuna.tsinghua.edu.cn/help/centos/
|
||||
yum makecache
|
||||
|
||||
# 添加中文语言支持
|
||||
LANG=C # 原始语言
|
||||
LANG=zh_CN.utf8 # 切换到中文
|
||||
yum groupinstall "Chinese Support" # 添加中文语言支持
|
||||
```
|
||||
|
||||
|
||||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|
||||
|
|
|
|||
|
|
@ -77,6 +77,12 @@ zip -q -r html.zip html
|
|||
zip -q -r html.zip *
|
||||
```
|
||||
|
||||
压缩效率选择:
|
||||
|
||||
```
|
||||
zip -9 # 1-9 faster->better
|
||||
```
|
||||
|
||||
### 问题解决
|
||||
|
||||
CentOS7中命令找不到
|
||||
|
|
|
|||
Loading…
Reference in New Issue