实战命令行
# 前言
本文是记录在开发中遇到的一些小经验,持续更新。
# 后台执行命令
# app为程序
nohup ./app 2>&1 &
1
2
2
# curl
的使用
注意:在使用
curl
命令时,如果链接存在?
、#
等符号时,需要使用\
进行转义
# curl
基础请求
curl https://xingcxb.com
1
# curl
代理 http
请求
# 方式一
# 不带密码
curl -x "http://127.0.0.1:1234" "https://xingcxb.com"
# 带密码
curl -x "http://user:pwd@127.0.0.1:1234" "https://xingcxb.com"
# 方式二
curl --proxy "http://127.0.0.1:1234" "https://xingcxb.com"
curl --proxy "http://user:pwd@127.0.0.1:1234" "https://xingcxb.com"
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
# curl
代理 socks5
请求
# 方式一
# 不带密码
curl --socks5-hostname 127.0.0.1:56789 https://xingcxb.com
# 带密码
curl --socks5-hostname 127.0.0.1:56789 -U user:pwd https://xingcxb.com
# 方式二
curl -x socks5h://127.0.0.1:56789 https://xingcxb.com
curl -x socks5h://user:pwd@127.0.0.1:56789 https://xingcxb.com
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
# curl
请求显示消耗的时间
# 非代理
curl -w "Total time: %{time_total}s\nDNS time: %{time_namelookup}s\nConnect time: %{time_connect}s\nSSL handshake time: %{time_appconnect}s\nPretransfer time: %{time_pretransfer}s\nRedirect time: %{time_redirect}s\nStarttransfer time: %{time_starttransfer}s\n" -s https://xingcxb.com
# 代理
curl -w "Total time: %{time_total}s\nDNS time: %{time_namelookup}s\nConnect time: %{time_connect}s\nSSL handshake time: %{time_appconnect}s\nPretransfer time: %{time_pretransfer}s\nRedirect time: %{time_redirect}s\nStarttransfer time: %{time_starttransfer}s\n" -s -x "test.juliangip.com.cn:66683" https://xingcxb.com
1
2
3
4
2
3
4
# wget
的使用
# wget
基础请求
wget https://xingcxb.com/abc/123.txt
1
# wget
代理 http
请求
# 不带用户名和密码
wget -e https_proxy=127.0.0.1:56789 https://xingcxb.com/abc/123.txt
# 带用户名和密码
wget --user=username --password=password -e https_proxy=127.0.0.1:56789 "https://xingcxb.com/abc/123.txt"
1
2
3
4
2
3
4
# 查看远程端口是否开启命令
# ip和port之间不能使用 `:` ,要使用空格
nc -zv ip port
1
2
2
# 查看端口命令
netstat -nultp
查看所有端口netstat -anp |grep 82
查看82端口netstat -tpnl
查看系统网络状态和网络连接信息的命令
# 分割文件命令
假设文件位置为
/home/biglog.log
# 分割成100M的文件
split -b 100m /home/biglog.log
1
2
2
# 修改 Linux
的 DNS
常用DNS:
- 阿里DNS:
223.5.5.5
223.6.6.6
Google DNS
:8.8.8.8
6.6.6.6
Cloudflare DNS
:1.1.1.1
1.0.0.1
Microsoft DNS
:53.229.96.99
53.229.14.24
vi /etc/resolv.conf
1
# centos
中执行 yum install xxx
遭遇 Could not retrieve mirrorlist http://xxxx
重新换个源就能解决问题
sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# 替换为自己能用的
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sudo yum clean all
sudo yum makecache
1
2
3
4
5
2
3
4
5
# 如何查看 Linux
下的文件夹大小
du -sh 文件夹目录
1
更新时间: 2024/4/23 16:15:12