linux 常用命令
CPU 飙升排查
top
ps -mp pid -O THREAD,tid,time
常用命令
#链接远程服务器
ssh root@47.xxx.xxx.46
#从服务器上下载文件到本地
scp root@47.xxx.xxx.46:/www/wwwroot/xxxx.zip /Users/xxxx/work/
#上传
scp xxx.log root@192.168.0.1:/tmp/
#启动服务
php artisan serve --port=80
#后台运行
nohup ./bin/elasticsearch &
fg 退出到终端(ctrl+c后可结束进程)
docker常用命令
#删除所有的镜像
docker rmi -f $(docker images -aq)
#删除所有的容器
docker rm -f $(docker ps -aq)
#拉取镜像
docker pull 2233466866/lnmp
#启动容器
docker run -dit \
-p 80:80 \
-p 443:443 \
-p 3306:3306 \
-p 9000:9000 \
-v /Users/missapp/work/project/docker/www:/www \
-v /Users/missapp/work/project/docker/mysql:/data/mysql \
--privileged=true \
--name=lnmp \
2233466866/lnmp
#查看容器
docker images
# 进入容器,容器名称与上一步保持一致
docker exec -it lnmp /bin/bash
linux常用命令
tail -n 0 -f ./* &
tail -f /var/log/php-fpm/www-error.log & tail -n 0 -f /home/log/xxx-log/`date +%Y-%m-%d`/* &
#tail 从文件尾部开始读
tail -f test.php
#从文件头部读
head
#读取整个文件
cat
#分页读
more
#可控分页
less
#搜索关键字
grep
grep "111" test.php
grep -n "111" test.php
grep -n "111" test.php |wc -l
ps -ef |grep ssh
netstat -anpl |grep 'http'
netstat -apn|grep 8077
#查找文件
find
#统计个数
wc
lsof -i:80
php -i |grep ini
netstat -lptn
netstat -lntp | grep 9200
ss -ntlp
#查看占用端口
netstat -tunlp
#查看ip
ifconfig
ip addr
#绝对定位找到你的php.ini
php -i|grep php.ini
history 查看运行的命令记录
ping xxx.com
telnet 192.168.0.1 80
#重启服务
systemctl restart nginx
systemctl restart php-fpm.service
#更改目录权限
chmod -R 777 ./xxxx
#更改所属组
chown -R www:www ./xxx
#测并发
wrk -t5 -c10000 -d10s <http://127.0.0.1:9501/>
#服务器负载
du -sh ./*
服务器硬件资源信息
内存:free -m
硬盘:df -h
负载:w/top
#解压
tar -zcvf 压缩文件名 .tar.gz 被压缩文件名
tar -zxvf 压缩文件名.tar.gz
tar -tf xxx.tar 解压文件
tar -tvf xxx.tar 解压文件并展示信息
zip -r xx.zip ./xxx 压缩 unzip xx.zip 解压
#修改防火墙配置文件
vi /etc/sysconfig/iptables
#重启防火墙使配置生效
service iptables restart
xshell文件传输命令
#yum安装lrzsz工具
yum -y install lrzsz
#查看是否安装成功
rpm -qa|grep lrzsz
#上传文件
rz
# 下载
sz
Linux进程管理命令:nohup、&、jobs、fg、bg、ps、kill
启动 PHP 服务器
php -S localhost:8000
#打开您的 Web 浏览器,并在地址栏中输入 `http://localhost:8000/your_php_file.php`
php 安装
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.2 php8.2-cli php8.2-{bz2,curl,mbstring,intl}
缺啥扩展就 apt install php8.2-xxx 如 缺啥扩展就 apt install php8.2-swoole
sudo su 切换root
apt insta1 php8.2-xml
apt install php8.2-zip
apt install php8.2-redis
apt install php8.2-gd
apt install php8.2-bcmath
列出系统上已安装的PHP版本
update-alternatives --display php
切换到8.2
sudo update-alternatives --set php /usr/bin/php8.2
本作品采用《CC 协议》,转载必须注明作者和本文链接