最后更新日期 12月 17th, 2021 at 12:09 下午
#改hostname
hostnamectl set-hostname localhost.localdomain
#启动监听
lsnrctl start
#停止监听
lsnrctl stop
#查看监听状态(是否开启)
lsnrctl status
#只允许某个IP访问流程:
vim /etc/hosts.allow
sshd:ip:allow
vim /etc/hosts.deny
sshd:ALL
service xinetd restart
#解压zip命令
unzip 压缩包全名
#把文件解压到某个目录里面
unzip 压缩包全名 -d /目录名字
#tar格式解压并移动到其他目录
tar -zxf 压缩包全名 -C /目录
#移动文件
mv 文件名 /路径
#文件夹改名
mv 文件名/ 名字
#查看防火墙状态
systemctl status firewalld
#永久关闭防火墙
systemctl stop firewalld.service
systemctl status firewalld.service
systemctl disable firewalld.service
#重启网卡服务
systemctl network restart
centos6:service network restart
#启动es服务
进入opt
source /etc/profile
./es793/bin/elasticsearch
./es793/bin/elasticsearch -d //后台运行服务
#启动eshead服务
进入eshead
npm run start
#启动kibana 进入kibana793
./bin/kibana
#启动logstash 进入bin
./logstash -f /opt/logstash793/config/logstash-sample.conf &
#启动filebeat 进入filebeat793
./filebeat -c filebeat.yml &
#ping不通域名但能ping通公网ip
修改dns配置文件
vim /etc/resolv.conf
nameserver:114.114.114.114
nameserver:8.8.8.8
#打开23端口
nc -lp 23 & //临时打开
nc -lk 23 & //持续打开,不会关闭
#关闭端口用
kill -9 PID
#查看端口及PID
netstat -antup | grep 端口号
#上传本地服务器文件到远程机器指定目录
scp /etc/gitlab/gitlab.rb root@远程机器IP:/etc/gitlab
scp /etc/gitlab/gitlab-secrets.json root@远程机器IP:/etc/gitlab
/var/opt/gitlab/backups备份路径 //
/root/gitlabDataBackup远程服务器备份路径 //
#文件以m大小显示
ls -alh
#添加定时任务
crontab -e
0 3 * * * /root/auto_backup_to_remote.sh //凌晨三点执行2.203IP,root目录中的auto_backup_to_remote.sh脚本
0 4 * * * /root/gitlabDataBackup/auto_remove_old_backup.sh
#查看已执行定时任务
crontab -l
#重启crontab
systemctl restart crond
#安装以及更新nodejs版本
yum -y install nodejs
npm install -g n //使用n管理包,安装指定的nodejs版本
n 10.16.0 stable //安装10.16.0版本
#/var/run/yum.pid被锁定
rm -f /var/run/yum.pid
#更换jenkins源
URL源:http://updates.jenkins-ci.org/download/plugins/
一键替换命令:sed -i ‘s/https:\/\/updates.jenkins.io\/download/http:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g’ /var/lib/jenkins/updates/default.json && sed -i ‘s/http:\/\/www.google.com/https:\/\/www.baidu.com/g’ /var/lib/jenkins/updates/default.json
重启服务:systemctl restart jenkins
#修改PS1变量值(显示主机名全程及全部目录)
echo $PS1
PS1=’W大写变小写’
#创建新会话
screen -S 会话名称
ctrl+A+D //退出新会话,但保留会话内容且不终止会话中前台进程
#查看会话列表
screen -list
#关闭screen中已dead的会话
screen -wipe
#进入会话
screen -r 会话名称
#linux后台运行命令详解
https://www.cnblogs.com/lwm-1988/archive/2011/08/20/2147299.html
#查看所有进程
ps aux
#查看当前用户的操作记录
history
//如果没有显示时间,就在/etc/bashrc中添加如下代码
HISTFILESIZE=2000
HISTSIZE=2000
HISTTIMEFORMAT=’%F %T ‘
export HISTTIMEFORMAT
//方法二
echo ‘export HISTTIMEFORMAT=”%F %T “‘ >> /etc/bashrc
source /etc/bashrc
#查看docker启动的应用
docker ps
#关闭/开启docker应用
docker stop CONTAINERID
docker start CONTAINERID
#启动docker服务
systemctl start docker
#守护进程重启
systemctl daemon-reload
#重启docker服务
systemctl restart docker
#关闭docker
systemctl stop docker
#重启docker服务
service docker restart
#关闭docker
service docker stop
#zip压缩文件命令
zip -q -r html.zip /home/html