cat /etc/redhat-release
mkdir 文件夹名
kill 7554
sudo fuser 80/tcp
rm -rf 文件名
tar -xzf 压缩包名.tar.gz
find / -name "*文件名.扩展名*"
useradd -m 用户名
passwd 用户名
userdel 用户名
cat /etc/passwd|cut -d: -f1
su - 用户名
sudo chmod 700 路径
sudo chown root:账户 路径
ls -ld 路径
注:700模式
,意味着该目录除了设置的用户能读写执行此目录以外,拒绝其他任何用户访问。777模式
意味着允许任何用户读写执行。600模式
,意味着该目录除了设置的用户能读写此目录以外,拒绝其他任何用户访问。
groups
reboot
df -h
注:size
一共多大,used
使用了多少,Avail
剩余多少。
sudo systemctl start hellow
sudo systemctl restart hellow
sudo systemctl reload hellow
sudo systemctl stop hellow
1.编辑当前用户的定时任务列表
sudo crontab -e
2. 在该文档中填写以下代码
0 */6 * * * systemctl restart reader
注:这条命令的意思是,在每小时的第0分钟(即整点),每过6小时执行一次 systemctl restart reader
命令。定时任务列表路径为/var/spool/cron/
。
3.键盘按下esc,:wq,回车,进行退出编辑并保存。
sudo systemctl enable hellow
sudo systemctl disable hellow
systemctl status hellow
journalctl -u hellow
注:hellow.service
为服务名。
ip addr
ip addr show ens33
netstat -tulpn | grep 80
注:80
为要查看的端口。
top -o %MEM
top -o %CPU
注:也可通过查询系统服务状态的方式查看对应服务运行所占内存,VIRT
进程占用的虚拟内存值,RES
进程占用的物理内存值。执行top
后按e
可切换显示单位。
yum install -y htop
htop
free -h
注:
used
:已使用内存
total
:内存总量
防火墙日志路径
:通常位于/var/log/firewalld
systemctl status firewalld
systemctl start firewalld
systemctl enable firewalld
firewall-cmd --reload
sudo firewall-cmd --list-ports
sudo firewall-cmd --zone=public --list-all
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address="123.1.1.1" drop'
firewall-cmd --permanent --remove-rich-rule='rule family=ipv4 source address="123.1.1.1" drop'
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address="116.255.0.0/16" drop'
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address="116.255.196.0/24" drop'
sudo firewall-cmd --permanent --add-port=2000/tcp
sudo firewall-cmd --permanent --remove-port=2000/tcp
注:这只是禁止外网及局域网访问2000端口
,服务器本地的项目依然可以访问2000端口
。
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="0.0.0.0/0" port protocol="tcp" port="2000" reject'
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.0.0/16" port port="2000" protocol="tcp" accept'
sudo firewall-cmd --zone=public --add-rich-rule='rule family="ipv4" source address="192.168.2.0/24" port port="22" protocol="tcp" accept' --permanent
firewall-cmd --permanent --remove-rich-rule='rule family="ipv4" source address="0.0.0.0/0" port protocol="tcp" port="2000" reject'
firewall-cmd --permanent --remove-rich-rule='rule family="ipv4" source address="192.168.0.0/16" port port="2000" protocol="tcp" accept'
1.第一次安装CentOS一定要选择最完整版,不要选择精简版!因为依赖关系问题更容易处理,功能也更全。
2.服务器配置主要看内存和带宽,因为价格低的服务器内存都很小,内存不够工具都不够装,带宽不够多来几个人访问项目就会很卡。