ansible all -m yum -a
"state=present name=httpd"
ansible all -m service -a
'name=httpd state=started enabled=yes'
ansible
'*'
-m ping
ansible
'*'
-m
command
-a
'uptime'
ansible
'*'
-m script -a
'/root/test.sh'
ansible
'*'
-m shell -a
'ps aux|grep zabbix'
ansible
'*'
-m raw -a
"ps aux|grep zabbix|awk '{print \$2}'"
ansible
'*'
-m copy -a
"src=/etc/ansible/ansible.cfg dest=/tmp/ansible.cfg owner=root group=root mode=0644"
```sh
cat
[filename]
cat
-n textfile1 > textfile2
cat
/dev/null > /etc/test.txt
curl命令访问url
curl https://www.example.com
curl -A 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36' https://google.com
curl -A '' https://google.com
curl -b 'foo=bar' https://google.com
curl -b 'foo1=bar;foo2=bar2' https://google.com
curl -b cookies.txt https://www.google.com
curl -c cookies.txt https://www.google.com
curl -d'login=emma&password=123'-X POST https://google.com/login
curl -d 'login=emma' -d 'password=123' -X POST https://google.com/login
curl -d '@data.txt' https://google.com/login
curl --data-urlencode 'comment=hello world' https://google.com/login
curl -e 'https://google.com?q=example' https://www.example.com
curl -F 'file=@photo.png' https://google.com/profile
curl -F 'file=@photo.png;type=image/png' https://google.com/profile
curl -F 'file=@photo.png;filename=me.png' https://google.com/profile
curl -G -d 'q=kitties' -d 'count=20' https://google.com/search
curl -G --data-urlencode 'comment=hello world' https://www.example.com
curl -H 'Accept-Language: en-US' https://google.com
curl -H 'Accept-Language: en-US' -H 'Secret-Message: xyzzy' https://google.com
curl -d '{"login": "emma", "pass": "123"}' -H 'Content-Type: application/json' https://google.com/login
curl -i https://www.example.com
curl -I https://www.example.com
curl --head https://www.example.com
curl -k https://www.example.com
curl -L -d 'tweet=hi' https://api.twitter.com/tweet
curl --limit-rate 200k https://google.com
curl -o example.html https://www.example.com
curl -O https://www.example.com/foo/bar.html
curl -s https://www.example.com
curl -s -o /dev/null https://google.com
curl -S https://www.example.com
curl -u 'bob:12345' https://google.com/login
curl -v https://www.example.com
curl --trace - https://www.example.com
curl -x socks5://james:cats@myproxy.com:8080 https://www.example.com
curl -X POST https://www.example.com
curl查看服务器出口ip
curl cip.cc
date命令查看时间
df查看linux文件系统使用情况
df -h
echo清理linux缓存
echo 3 >/proc/sys/vm/drop_caches
echo清空文件
$ : > filename
$ > filename
$ echo "" > filename
$ echo > filename
$ cat /dev/null > filename
export导入环境变量,source生效环境变量
export PATH=$PATH:~/bin
source ~/.bashrc
grep查看日志里指定字符
grep '字符串' [filename]
grep -B 100 '字符串' [filename]
grep -A 100 '字符串' [filename]
history查看历史记录
history
history | grep '匹配字符串'
!number
export HISTTIMEFORMAT='%F %T '
jps查看当前java进程
jps -l
jps -lv
jps -lvm
jmap进行数据dump
jmap -dump:format=b,file=heap.hprof [pid]
kill命令
kill -9 pid
ll和ls展示目录
ll -h
lscpu查看CPU信息
lscpu
mkdir创建文件夹
mkdir [-p] directory
mv移动文件或文件夹或改名
mv source_file(文件) dest_file(文件)
mv filename newfilename
mycli连接数据库命令
mycli -h [ip] -u [username] -p [password]
mycli格式化显示查询出来的数据
select * from table \G
mysql相关操作
show databases;
use <数据库名>
select now();
create table <表名> ( <字段名1> <类型1> [,..<字段名n> <类型n>]);
insert into <表名> [( <字段名1>[,..<字段名n > ])] values ( 值1 )[, ( 值n )]
UPDATE [LOW_PRIORITY] [IGNORE] tbl_name SET col_name1=expr1 [, col_name2=expr2 ...] [WHERE where_definition] [ORDER BY ...] [LIMIT row_count]
rename table 原表名 to 新表名
mysql查看索引
show index from [tablename]
show keys from [tablename]
mysql添加索引
ALTER TABLE [tablename] ADD INDEX index_name (column_list)
ALTER TABLE [tablename] ADD UNIQUE (column_list)
ALTER TABLE [tablename] ADD PRIMARY KEY (column_list)
mysql创建索引
CREATE INDEX index_name ON table_name (column_list)
CREATE UNIQUE INDEX index_name ON table_name (column_list)
mysql查看表结构
desc [tablename]
show create table [tablename]
use information_schema;
select * from columns where table_name = [tablename]
mysql查看死锁
show engine innodb status
netstat查看time_wait命令
netstat -ae|grep "TIME_WAIT" |wc -l
netstat -ant |awk 'NR>2{print $6}'|sort|uniq -c|sort -rn
ps -ef | grep 进程关键字
ps -A
ps -u root
ps -ef
ps -aux
pwd查看当前位置
redis连接命令
redis-cli -h [ip] -p 6379 -a [password]
redis-cli -h [ip] -p 6379 -a [password] -raw
redis-cli -h [ip] -p 6379 -a [password] -n 13
reids删除指定token的缓存
redis-cli -h 172.31.62.240 -p 6379 -a D4VUuT8YH7 -n 13 keys "src.main.biz.accounts.web.SpCnapsBook:names" | xargs redis-cli -h 172.31.62.240 -p 6379 -a D4VUuT8YH7 -n 13 del
rm删除文件文件夹
rm -f [filename]
rm -rf [directory]
rz和sz上传下载文件
yum install lrzsz -y
sz [filename]
ssh切换服务器
ssh root@172.31.62.3
scp服务器之间拷贝资源
# 拷贝文件
scp file root@xxx.xxx.xxx.xxx:/目录
# 拷贝文件夹
scp -r directory root@xxx.xxx.xxx.xxx:/目录
tail查看日志
tail -f nohup.out
tail -100f nohup.out
top命令查看服务器信息
zip压缩文件
zip filename.zip 文件
zip -r filename.zip 目录(./*)
unzip解压文件
unzip -o -d /home/sunny myfile.zip
zip删除压缩文件中指定文件
zip -d filename.zip file
zip向压缩文件中myfile.zip中添加rpm_info.txt文件
zip -m myfile.zip ./rpm_info.txt
uptime查看系统平均负载
uptime
16:27:43 up 59 days, 7:24, 3 users, load average: 1.14, 1.96, 2.19
utpdate同步服务器时间
utpdate 时间服务器ip
以后有时间会同步这个文章