显示所有已启动的服务
systemctl list-units --type=service
安装一个软件时
yum -y install redis
卸载一个软件时
yum -y remove redis
检查服务状态
systemctl status httpd.service
使某服务自动启动
systemctl enable httpd.service
使某服务不自动启动
systemctl disable httpd.service
启动某服务
systemctl start httpd.service
停止某服务
systemctl stop httpd.service
重启某服务
systemctl restart httpd.service
压缩解压 命令
压缩:
- 绝对路径压缩
zip -r html.zip /home/html
-r 指代递归,压缩文件夹下面的所有文件和文件夹
解压
-
解压缩到当前目录
unzip html.zip -
解压缩到指定目录但不覆盖
unzip -n html.zip -d /usr
启动进程:
- 前台启动
filebeat启动命令
./filebeat -e -c filebeat.yml
- 后台启动 不输出日志/输出日志
nohup ./filebeat -e -c filebeat.yml >/dev/null 2>&1 &
nohup ./filebeat -e -c filebeat.yml > filebeat.log &
"2>&1 &"含义
2>&1 是将标准出错重定向到标准输出,这里的标准输出已经重定向到了/dev/null,即将标准出错也输出到/dev/null 。最后一个& , 是让该命令在后台执行。
- 查看端口是否开启
telnet 10.168.1.44 8082
后台下载
wget -b + url
有几种方法可以查看:
tail -f wget-log
查找文件
find / -name mysql
查找相关文件
whereis nginx
Centos7禁用密码登录方法:
vim /etc/ssh/sshd_config
将PasswordAuthentication参数值修改为no: PasswordAuthentication no
重启ssh服务:systemctl restart sshd.service
centos 查看有哪些用户
用户列表文件:/etc/passwd
用户组列表文件:/etc/group
查看系统中有哪些用户:cut -d : -f 1 /etc/passwd
查看可以登录系统的用户:cat /etc/passwd | grep -v /sbin/nologin | cut -d : -f 1
查看用户操作:w命令(需要root权限)
查看某一用户:w 用户名
查看登录用户:who
查看用户登录历史记录:last
目录分配用户及权限:
1.更改目录所有者命令:
chown -R 用户名称 目录名称
chown -R oracle /opt/oracle/
其中,参数`-R`表示启动递归处理
2.更改目录权限命令:
chmod -R 755 目录名称
chown -R 755 /opt/oracle/
其中,参数`-R`表示启动递归处理
注:表示将整个/opt/oracle/目录与其中的文件和子目录的权限都设置为rwxr-xr-x
几种常用权限实例:
-rw------- (600) 只有所有者才有读和写的权限
-rw-r--r-- (644) 只有所有者才有读和写的权限,组群和其他人只有读的权限
-rwx------ (700) 只有所有者才有读,写,执行的权限
-rwxr-xr-x (755) 只有所有者才有读,写,执行的权限,组群和其他人只有读和执行的权限
-rwx--x--x (711) 只有所有者才有读,写,执行的权限,组群和其他人只有执行的权限
-rw-rw-rw- (666) 每个人都有读写的权限
-rwxrwxrwx (777) 每个人都有读写和执行的权限
参考: