Centos7 常用命令

Centos7 常用命令

查看正在运行状态的服务及端口:
netstat -tunpl

vsftp
systemctl restart vsftpd
find / -name ‘vsftpd’

杀死进程
ps -ef |grep nginx
kill -TERM PPID
kill -9 pid

创建自定义服务

自定义文件

sudo nano /etc/systemd/system/kestrel-helloapp.service
文件内容
[Unit]
Description=Example .NET Web API App running on Centos

[Service]
WorkingDirectory=/var/www/helloapp
ExecStart=/usr/bin/dotnet /var/www/helloapp/helloapp.dll
Restart=always

RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]

WantedBy=multi-user.target

启用服务
sudo systemctl enable myapi.service
开启
sudo systemctl start myapi.service
状态
sudo systemctl status myapi.service
日志
sudo journalctl -fu myapi.service

设置文件夹写入权限
chmod -R 777 dirPath

查看系统版本
lsb_release -a

查看用户
cut -d : -f 1 /etc/passwd

查看用户组
cut -d : -f 1 /etc/group

删除用户
userdel -r user

MySql
systemctl start mysql
systemctl stop mysql
systemctl restart mysql
systemctl status mysql
mysql -u root -p
update user set password=password(‘1qaz@wsx’) where user=’root’ and host=’localhost’;
flush privileges;
grant all privileges on . to ‘root’@’%’ identified by ‘1qaz@wsx’ with grant option

Nginx
nginx -s reload
systemctl status nginx
systemctl start nginx
systemctl stop nginx

Apache
find / -name ‘httpd’
apachectl -t
httpd -v
service httpd restart
service httpd start
service httpd stop
systemctl status httpd.service

Firewall–防火墙
firewall-cmd –state
firewall-cmd –reload
systemctl start firewalld
systemctl stop firewalld
firewall-cmd –list-all
firewall-cmd –zone=public –add-port=3306/tcp –permanent
firewall-cmd –zone=public –add-port=5000/tcp –permanent
firewall-cmd –zone=public –add-port=80/tcp –permanent
firewall-cmd –zone=public –add-port=81/tcp –permanent

NetworkManager–网络配置
ip addr
systemctl start NetworkManager
systemctl status network
systemctl start network

nmtui

chenj

发表评论