centos7常见操作

本文涉及的产品
云防火墙,500元 1000GB
简介: centos7常见操作

1. 防火墙操作

(1)查看防火墙是否开启

firewall-cmd --state

(2)查看防火墙所开放的端口

firewall-cmd --list-ports

(3)开放指定端口

sudo firewall-cmd --add-port=5000/tcp --permanent

(4)关闭指定端口

sudo firewall-cmd --remove-port=5000/tcp --permanent

(5)重启防火墙

修改配置后(如开放了新的端口)要重启防火墙

firewall-cmd  --reload

(6)开启防火墙

systemctl start firewalld

(7)设置防火墙开机自启动

systemctl enable firewalld

(8)关闭防火墙

systemctl stop firewalld

(9)禁止防火墙自启动

systemctl disable firewalld

2. systemctl操作

systemctl是用于管理系统服务的命令行工具

(1)启动服务

systemctl start <service_name>

(2)停止服务

systemctl stop <service_name>

(3)重启服务

systemctl restart <service_name>

(4)查看服务状态

systemctl status <service_name>

(5)查看所有服务状态

输出内容太多,指令使用的不多

systemctl list-units --type=service

(6)设置服务开机自启

systemctl enable <service_name>

(7)禁用服务开机自启

systemctl disable <service_name>

(8)查看服务日志

systemctl -u <service_name>

(9)查看服务是否自动

systemctl is-enabled <service_name>

返回结果:

  • enabled:表示该服务已经设置为开机自启动
  • disabled:表示该服务没有设置为开机自启动
  • static:表示该服务虽然没有显示设置为开机自启动,但是它的启动状态由其他依赖服务决定

(10)查看所以设置自启动的服务

systemctl list-unit-files --type=service --state=enabled

--type=service指定要列出的是服务单元,--state=enabled指定要列出的是状态为已启用的服务

3. 查看服务占用的进程和端口

1、

ps aux | grep mongo

2、

ps -ef | grep mongo

3、查看端口

netstat -lanp | grep 27017

4、查看端口

lsof -i:27017

4. Linux设置root密码和登录root

1、设置root用户的密码:

sudo passwd root

2、切换到root用户权限

su

3、切换回个人用户权限

exit

参考博客:

https://blog.csdn.net/cuicui_ruirui/article/details/107151112

目录
相关文章
|
19天前
|
Linux
CentOS如何修改SEMMNI
【6月更文挑战第18天】CentOS如何修改SEMMNI
51 1
|
2月前
|
Linux
CentOS7.8和CentOS7.9的区别
【4月更文挑战第14天】CentOS7.8和CentOS7.9的区别
225 2
|
2月前
|
Linux
Centos 常见的命令
Centos 常见的命令
23 0
|
2月前
|
监控 网络协议 Linux
centos常见的命令
【5月更文挑战第8天】了解和掌握基本的CentOS命令对于服务器管理至关重要。本文介绍了19个常用命令,包括`ls`、`cd`、`mkdir`、`rm`、`grep`、`find`、`sudo`、`vi/vim`、`cp/mv`、`du/df`、`history`、`top/htop`、`ps`、`netstat/ss`、`yum/dnf`、`ssh`、`iptables`、`journalctl`、`crontab`和`systemctl`。每个命令都提到了常见问题、使用技巧和避免错误的方法,帮助用户更好地管理和维护CentOS系统。
44 0
|
8月前
|
存储 缓存 安全
centos命令3
centos命令3
48 0
|
8月前
|
Linux Shell 开发工具
Centos7命令4
Centos7命令4
33 0
|
12月前
|
Linux 网络安全 开发工具
关于centos7的操作及一些功能的实现(上)
关于centos7的操作及一些功能的实现(上)
188 1
|
12月前
|
缓存 网络协议 安全
关于centos7的操作及一些功能的实现(下)
关于centos7的操作及一些功能的实现(下)
120 0
|
12月前
|
缓存 网络协议 安全
关于centos7的操作及一些功能的实现
CentOS 7 是一个免费的开源操作系统,它是 Red Hat Enterprise Linux 7 的一个社区版本。
178 0
|
Linux 网络安全 开发工具