linux常用命令(个人整理)

查看网卡和IP
ip addr show


设置自动获取IP
vim /etc/sysconfig/network-scripts/ifcfg-ens33

ONBOOT=NO改为yes

service network restart

 

防火墙
关闭防火墙
systemctl stop firewalld


查看防火墙状态
systemctl status firewalld

 

运行java包

nohup java -jar /data/www/player/player-1.0-SNAPSHOT.jar &

 

授权目录

chmod -R 777 xxxxxxxxx

chown 用户名 文件路径

 

拼命令(5次后自动停止)

ping -c 5 www.baidu.com

 

修改网络IP

cd /etc/sysconfig/network-scripts
vi ifcfg-eno1
service network restart

 

用户

创建用户testuser
useradd testuser

给已创建的用户testuser设置密码
passwd testuser

说明:新创建的用户会在/home下创建一个用户目录testuser

修改用户这个命令的相关参数
usermod --help
删除用户testuser
userdel testuser
删除用户testuser所在目录
rm -rf testuser

上面的几个命令只有root账号才可以使用

 

 通信

往localhost:7788端口推送一条udp消息

echo test > /dev/udp/localhost/7788

 

发送post请求

提交post data-form数据:

curl -d "phone=12345678962&checkCode=1234" "http://192.168.1.10:8080/test/webapi/account/login"

wget –post-data "phone=12345678962&checkCode=1234" "http://192.168.1.10:8080/test/webapi/account/login" 

 提交post json数据:
curl -H "Content-type: application/json" -X POST -d '{"phone":"12345678962","checkCode":"1234"}' http://192.168.1.10:8080/test/webapi/account/login

nginx

查看nginx配置文件所在目录

/usr/sbin/nginx -t

重启nginx

nginx -s reload

 

硬盘

查看硬盘

df -h

查看硬盘(精确到KB)

df

 

日志搜索

搜到之后直接输出

cat -n nohup.out | grep "key"

搜到之后输出到文件(关键词向下取10行)

cat -n nohup.out | grep -A 10 "manager_message" > out2.txt

 

实时输出匹配行以及下面5行
tail -f nohup.out |grep -A 5 "key"

实时输出匹配行以及上面5行
tail -f nohup.out |grep -B 5 "key"

实时输出匹配行以及上下5行
tail -f nohup.out |grep -C 5 "key"

 

 

端口

lsof -i:8086 查看某一端口的占用情况

netstat -tunlp |grep 端口号,用于查看指定的端口号的进程情况

 

复制文件

cp a* abc

 复制a开头的所有文件到abc目录下

 

查看系统版本信息

hostnamectl

 

posted @ 2020-09-18 10:54  java12345_com  阅读(148)  评论(0编辑  收藏  举报