Linux常用命令
基本命令

命令格式:

rm -f [文件名]
:强制删除,不会有确认询问
ls -l
:当前目录下详细的内容,除文件的名称外,同时显示文件型态(d表示目录,-表示文件),权限,拥有者,文件大小等信息。简写:ll
echo “内容” >> 文件
:将内容追加到文件中
目录类操作命令
进入指定目录:cd
用于切换当前工作目录,进入指定目录

显示文件内容:cat

分页形式显示内容:more

查看文件末尾:tail

创建目录:mkdir

删除空目录:rmdir

删除文件或目录:rm

拷贝移动命令
复制文件和目录:cp

移动文件目录命令:mv

打包压缩
对文件进行打包、解包、压缩、解压:tar

举例:

文件编辑命令
文件编辑命令:vi/vim

查找命令
指定目录下查找文件:find

指定文件中查找指定文本内容:grep

Linux软件安装
安装JDK

安装Tomcat


安装MySql






安装lrzsz

输入rz
:可以弹出文件上传窗口
项目部署
手工部署项目


java -jar name.jar


上线的项目,运行信息不展示到控制台,而是输出到日志中。


通过Shell脚本自动部署项目

在Linux中安装Git

使用Git克隆代码

在Linux中安装maven


bootStart.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| #!/bin/sh echo ================================= echo 自动化部署脚本启动 echo =================================
echo 停止原来运行中的工程 APP_NAME=helloworld #!运行项目的名称
tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'` if [ ${tpid} ]; then echo 'Stop Process...' kill -15 $tpid fi sleep 2 tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'` if [ ${tpid} ]; then echo 'Kill Process!' kill -9 $tpid else echo 'Stop Success!' fi
echo 准备从Git仓库拉取最新代码 cd /usr/local/helloworld
echo 开始从Git仓库拉取最新代码 git pull echo 代码拉取完成
echo 开始打包 output=`mvn clean package -Dmaven.test.skip=true`
cd target
echo 启动项目 nohup java -jar helloworld-1.0-SNAPSHOT.jar &> helloworld.log & echo 项目启动完成
|


通过Shell脚本自动部署项目
设置IP地址为静态的IP地址,如果是动态则,当断开连接的时候,再次连接有可能IP地址变化,就找不到了。

