加米谷大数据技术分享:CentOS7常用命令
1、目录切换命令:pushd and popd进入目录:
pushd /usr/src
pushd /etc/X11
pushd /boot/grub
popd 回退目录
2、环境变量配置:vi /etc/profile
#java
export JAVA_HOME=/usr/java/jdk1.8.0_60
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
#Scala
export SCALA_HOME=/usr/local/scala
export PATH=$PATH:$SCALA_HOME/bin:$SCALA_HOME/sbin
3、关于Systemctl命令
Systemctl接受服务(.service),挂载点(.mount),套接口(.socket)和设备(.device)作为单元。
使用systemctl命令杀死服务
systemctl kill httpd.service
systemctl status httpd.service
如何屏蔽(让它不能启动)或显示服务
systemctl mask httpd.service
systemctl unmask httpd.service
如何激活服务并在启动时启用或禁用服务(即系统启动时自动启动服务)
systemctl is-active httpd.service
systemctl enable httpd.service
systemctl disable httpd.service
如何启动、重启、停止、重载服务以及检查服务状态
systemctl start httpd.service
systemctl restart httpd.service
systemctl stop httpd.service
systemctl reload httpd.service
systemctl status httpd.service
列出所有可用单元
systemctl list-unit-files
列出所有运行中单元
systemctl list-units
列出所有失败单元
systemctl --failed
检查某个单元(如 httpd.service)是否启用
systemctl is-enabled httpd.service
检查某个单元或服务是否运行
systemctl status firewalld.service
4、Centos7根据文件内容查找
find /opt/ -type f|xargs grep "content xxx"
5、CentOS7关闭防火墙
停止firewall
systemctl stop firewalld.service
systemctl disable firewalld.service
firewall-cmd --state
查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
6、查看程序的安装位置
使用 whereis 命令查看程序的安装位置
如:whereis systemd
whereis mysql
whereis httpd
<code style="font-family: Monaco, Consolas, Courier, "Lucida Console", monospace; background-color: inherit;"><span style="background-color: inherit;"></span></code>
7、CentOS如何查看端口是被哪个应用进程占用
一、检查端口被哪个进程占用
代码如下 复制代码
netstat -lnp|grep 88 #88请换为你的apache需要的端口,如:80
SSH执行以上命令,可以查看到88端口正在被哪个进程使用。如下图,进程号为 1777 。
二、查看进程的详细信息
ps 1777
SSH执行以上命令。查看相应进程号的程序详细路径。
三、杀掉进程,重新启动apache
代码如下 复制代码
kill -9 1777
#杀掉编号为1777的进程
service httpd start #启动apache。
页:
[1]