在CentOS系统中,可以使用以下命令来查看和管理进程:
ps命令
ps aux:显示所有进程的详细信息。ps -ef:类似于ps aux,但输出格式略有不同。ps -aux | grep [进程名]:查找特定名称的进程。top命令
P键按CPU使用率排序,按M键按内存使用率排序。htop命令
htop是top的增强版,提供更友好的用户界面和更多功能。sudo yum install htoppidof命令
pidof httpdpgrep命令
pgrep httpd启动进程
systemctl start [服务名]启动服务。systemctl start httpd停止进程
systemctl stop [服务名]停止服务。systemctl stop httpd重启进程
systemctl restart [服务名]重启服务。systemctl restart httpd查看进程状态
systemctl status [服务名]查看服务状态。systemctl status httpd杀死进程
kill [PID]杀死指定PID的进程。kill 1234kill -9 [PID]强制杀死。查看进程打开的文件
lsof -p [PID]查看指定PID的进程打开的文件。lsof -p 1234查看进程的网络连接
netstat -tunlp | grep [PID]查看指定PID的进程的网络连接。netstat -tunlp | grep 1234nice和renice:调整进程的优先级。
nice -n [优先级] [命令]:以指定优先级启动进程。renice [优先级] -p [PID]:调整已运行进程的优先级。nohup:在后台运行命令,即使终端关闭也不会终止。
nohup [命令] &:例如:nohup myscript.sh &通过这些命令,你可以有效地查看和管理CentOS系统中的进程。