linux常用指令备份 java项目发版

1.两台服务器之间文件传输

# 文件传输 fileName--表示需要传输的文件完整路径
# root --表示需要传输的那台服务器用户账号
# 45.248.84.82 -- 表示需要传输的服务器ip
# /data/gf -- 表示需要保留传输文件的路径

scp fileName [email protected]:/data/gf

2.配置系统时间

#安装ntpdate
yum install ntpdate -y

#服务器配置系统时间同步网络时间  并且加到系统crontab里面执行 配置每隔10分钟执行一次  命令如下
/usr/sbin/ntpdate -u ntpdate time.nist.gov;hwclock -w

3.用户、组查看以及新增

#用户、组查看
cat /etc/passwd
cat /etc/group

#用户、组新增(新增名字为mysql组以及用户名为mysql的用户账号)
groupadd mysql
useradd -r -g mysql mysql

4.mysql导入数据库脚本

#xxxx.sql为需要导入的sql脚本名称
source /data/gf/xxxx.sql

5.mysql修改用户密码

#更新用户密码 
update user set password=password("123456") where user="root";

#执行事务
flush privilege

6.scp报错:not a regular file

#执行以下scp指令报错:xxx: not a regular file
scp xxx [email protected]:/data/webapps

#更换为以下指令,即可正常执行
scp -r xxx [email protected]:/data/webapps

7.执行service iptables restart重启防火墙报错:Redirecting to /bin/systemctl restart iptables.service
Failed to restart iptables.service: Unit not found.

#执行service iptables restart 重启防火墙报错
service iptables restart

#报错信息:Redirecting to /bin/systemctl restart iptables.service Failed to restart iptables.service: Unit not found.

#centos7开始,需要修改成以下指令打开对应的端口
firewall-cmd --permanent --add-port=1000-2000/tcp

8.unzip: command not found以及压缩文件解压

#安装unzip插件
yum install -y unzip zip

#解压 front表示解压的文件夹路径
unzip front2-game-trade.zip -d front

9.linux下上传或下载文件指令

#安装下载/上传工具
yum -y install lrzsz

#上传文件 服务器received file
rz

#下载文件
sz

10.执行某个脚本文件,出现权限问题:-bash: ./cleanandbuild.sh: Permission denied

#给脚本文件赋予权限
chmod u+x cleanandbuild.sh

11.linux关于.tar.gz文件解压与.tar.xz文件解压

#.tar.xz文件解压
#先解压成tar文件
xz -d node-v7.0.0-linux-x64.tar.xz

#解压tar文件
tar -xvf node-v7.0.0-linux-x64.tar

12.centos时间相关的插件以及修改语句

#安装ntpdate
yum install -y ntp

#更新时间
/usr/sbin/ntpdate -u ntpdate time.nist.gov;hwclock -w
发布了22 篇原创文章 · 获赞 5 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/funnychaos/article/details/88384771