linux常用命令总结

一.查找命令

1. find(指定目录查找)

2. locate(数据库中查找)

3. whereis(程序名查找)

4. which(环境变量中查找)

5. type

二.防火墙

1、开放端口

firewall-cmd --zone=public --add-port=5672/tcp --permanent   # 开放5672端口

firewall-cmd --zone=public --remove-port=5672/tcp --permanent  #关闭5672端口

firewall-cmd --reload   # 配置立即生效

systemctl start firewalld.service #开启防火墙

2、查看防火墙所有开放的端口

firewall-cmd --zone=public --list-ports

 

3.、关闭防火墙

如果要开放的端口太多,嫌麻烦,可以关闭防火墙,安全性自行评估

systemctl stop firewalld.service

 

4、查看防火墙状态

 firewall-cmd --state

 

三、查看监听的端口

netstat -lnpt

PS:centos7默认没有 netstat 命令,需要安装 net-tools 工具,yum install -y net-tools

 

 

四、检查端口被哪个进程占用

netstat -lnpt |grep 5672

 

五、查看进程的详细信息

ps 6832

 

六、中止进程

kill -9 6832

七.nginx命令

1.nginx启动,停止,状态

    systemctl start nginx.service
    systemctl stop nginx.service
    systemctl reload nginx.service
    systemctl status nginx.service

2.找到nginx的安装位置

whereis nginx

八.查看php.ini在哪

 php -i | grep "Loaded Configuration File"

或者查看phpinfo

 

九.FTP服务启动与关闭命令

查看FTP服务是否运行中:service vsftpd status

查看本地是否含有包含ftp的进程开启:ps -ef | grep ftp

FTP设置开机自动运行:chkconfig vsftpd on

关闭FTP开机自动运行:chkconfig vsftpd off

查看所有服务开启自动运行的情况:chkconfig --list

启动FTP服务:service vsftpd start

停止FTP服务:service vsftpd stop

重启FTP服务:service vsftpd restart

注:service vsftpd status 是红帽服务启动(start) 停止(stop) 状态(status) 的操作方式。 如果不是红帽可能无法执行

十.systemd使用

  • systemctl --version,查看版本。
  • whereis systemctl,查看位置。
  • systemctl list-unit-files,列出所有可用单元(服务)。
  • systemctl list-units,列出所有运行中的单元。
  • systemctl --failed,列出所有失败的单元。
  • systemctl list-unit-files | grep enable,查看自启动的软件。
  • systemctl is-enabled mysqld.service,查看某个单元是否开机启动。
  • systemctl status mysqld.service,查看某个单元的状态。
  • systemctl start mysqld.service,启动某个单元。
  • systemctl restart mysqld.service,重启某个单元。
  • systemctl stop mysqld.service,停止某个单元。
  • systemctl daemon-reload,修改了某个单元的配置文件后,重载配置文件。
  • systemctl reload mysqld.service,重载某个单元。
  • systemctl enable mysqld.service,设置开机自启动。
  • systemctl disable mysqld.service,关闭开机自启动。
  • systemctl kill mysqld,杀死单元。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值