csdn备份,便于后续需要时查阅
查看防火墙状态
systemctl status firewalld
service iptables status
暂时关闭防火墙
systemctl stop firewalld
service iptables stop
重启防火墙
systemctl enable firewalld
service iptables restart
永久关闭防火墙
systemctl disable firewalld
chkconfig iptables off
查看物理磁盘
fdisk -l
查看磁盘使用情况
df -h
挂载磁盘
mount /dev/sda1 /test
取消挂载
umount /test
查看网络带宽使用
nload -m
iftop
查看TCP/UDP端口使用
netstat -tulnp
通过进程名查pid
ps -ef|grep xxx
杀进程
kill -9 pid
文件传输
scp -r <本地目录> root@ip:<远程目录>
抓包工具tcpdump
tcpdump -i <网卡名> port 8080 # 指定端口
tcpdump -i <网卡名> src ip # 指定源地址
增加可执行权限
chmod +x <filename>
移动文件或重命名
mv file1 file2
创建文件
touch <filename>
编辑文件
vim <filename>
i输入 o换行输入 gg回到首行 G最后一行 $当前行最后一个字符
查看长文件
more <filename>
空格翻页
实时查看日志
tail -f <filename>
重启网卡
service network restart
强制删除文件夹或文件
rm -rf <filename>
下载第三方软件源
yum install epel-release
清理buffer
echo 3 > /proc/sys/vm/drop_caches
添加路由
ip route add 192.168.2.0/24 via 192.168.2.100<下一跳网卡ip>
查看路由
route -n
查看ip
ifconfig
查看网卡物理带宽
ethtool <网卡名|eth0>
切换root用户
su root 回车后输入密码
查看内核版本
cat /proc/version
uname -a
查看系统版本
lsb_release -a
若无需要安装
yum install -y redhat-lsb
关机
shutdown -h now
重启
shutdown -r now
reboot
返回上一级目录
cd ..
创建目录
mkdir <dirname>
复制文件和目录
cp file1 file2
cp -r dir1 dir2
文件搜索
find / -name <filename>
解压文件
tar -zxvf *.tar.gz
unzip *.zip
unrar x *.rar
禁用\启动一个网卡
ifconfig <网卡名/eth0> down
ifconfig <网卡名/eth0> up
查看文件md5值
md5sum <filename>
查看进程cpu和内存使用
top -p pid
ps-aux | grep processname/pid