本文最后更新于 795 天前,其中的信息可能已经有所发展或是发生改变。
Linux 命令笔记,方便查找。
系统硬件
1、内存 SWaP 查看:
free -m

2、系统内核查看:
uname -a

3、SELinux 关闭:
# 临时关闭
setenforce 0
修改 /etc/selinux/config 文件:
# 永久关闭
vi /etc/selinux/config
将 SELINUX=enforcing 修改为 SELINUX=disabled:
# SELINUX=enforcing
SELINUX=disabled
SSH 连接、文件相关
1、跨服务器文件传输:
scp $file user@host:$file_to
防火墙端口开启关闭
1、Firewalld 防火墙相关:
# 查看当前开放的所有端口
firewall-cmd --list-all
# $port 为你需要开放的端口
firewall-cmd --add-port=$port/tcp --permanent
# $port 为你需要关闭的端口
firewall-cmd --zone=public --remove-port=$port/tcp --permanent
# 加载防火墙配置
firewall-cmd --reload
# 彻底关闭
systemctl stop firewalld.service
systemctl disable firewalld.service
2、Iptables 防火墙相关:
# 查看当前防火墙规则
iptables -L -n
# 开放端口
iptables -A INPUT -p tcp --dport $port -j ACCEPT
iptables -A OUTPUT -p tcp --dport $port -j ACCEPT
# 存储防火墙配置
service iptables save
# 彻底关闭
systemctl stop iptables.service
systemctl disable iptables.service
chkconfig iptables off
代理相关
1、设置临时代理(只在当前终端中生效,SSH 断开后失效):
# HTTP 代理
export http_proxy=http://$username:$password@$host:$port
# SOCKS5 代理
export http_proxy=socks5://$username:$password@$host:$port
2、为 Git 设置代理(git clone
等操作会使用该代理):
# 设置 SOCKS5 代理
git config --global http.proxy socks5://$username:$password@$host:$port
git config --global https.proxy socks5://$username:$password@$host:$port
# 查看代理
git config --global --get http.proxy
git config --global --get https.proxy
# 取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy