以centos v7.3 64位为例。
一、常用命令
1、yum
yum update
//全部更新
yum list
//显示所有已经安装和可以安装的程序包
2、wget
wget http://example.com/file.iso
//下载单个文件
wget -O another.iso http://example.com/file.iso
//下载并以不同的文件名保存
3、rpm
rpm -ivh jdk-8u144-linux-x64.rpm
:安装显示安装进度--install--verbose--hash
4、find
$ find <指定目录> <指定条件> <指定动作>
find . -name "my*" -ls
// 搜索当前目录中,所有文件名以my开头的文件,并显示它们的详细信息。
find . -type f -mmin -10
// 搜索当前目录中,所有过去10分钟中更新过的普通文件。如果不加-type f参数,则搜索普通文件+特殊文件+目录。
find / -name "tomcat*" -type d -print
// 搜索根目录下名称为tomcat*的目录
5、locate
locate /etc/sh
// 搜索etc目录下所有以sh开头的文件
locate -i ~/m
// 搜索用户主目录下,所有以m开头的文件,并且忽略大小写。
6、whereis
只能用于程序名的搜索
eg: whereis grep
7、which
在PATH变量指定的路径中,搜索某个系统命令的位置,并且返回第一个搜索结果)
eg: which grep
8、type
用来区分某个命令到底是由shell自带的,还是由shell外部的独立二进制文件提供的
type grep
9、useradd
-d
//指定用户登入时的主目录
-g
//指定用户所属的群组
-M
//不自动建立用户的登入目录
-s
//指定用户登入后所使用的 Shell。默认值为 /bin/bash
sudo useradd -M -s /bin/nologin -g tomcat -d /opt/tomcat tomcat
10、tar
-v
//显示所有过程
-x
//解压
-f
//指定文件
-C
//切换到指定目录
tar xvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1
11、chgrp
-R 处理指定目录以及其子目录下的所有文件
chgrp -R tomcat /opt/tomcat
12、chmod
-R
//对目前目录下的所有档案与子目录进行相同的权限变更(即以递回的方式逐个变更)
g
//表示”同组(group)用户”,即与文件属主有相同组ID的所有用户
chmod -R g+r conf
二、常用快捷键
1、vim
dd
:删除光标所在整行,同时被删除内容存于剪贴板上
三、常用开发环境准备
1、安装JDK 8
1)下载
wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.rpm"
2)安装
rpm -ivh jdk-8u144-linux-x64.rpm
3)环境变量
vim ~/.bash_profile
export JAVA_HOME=/usr/java
export JRE_HOME=/usr/java/jre1.8.0_60
export CLASSPATH=$JRE_HOME/lib/rt.jar:$JRE_HOME/lib/ext
export PATH=$PATH:$JRE_HOME/bin
source ~/.bash_profile
2、安装tomcat
1)基于安全原因,设置tomcat用户组和用户组,并且在这个用户下运行tomcat
groupadd tomcat
useradd -M -s /bin/nologin -g tomcat -d /var/tomcat tomcat
2)下载安装
wget http://mirror.csclub.uwaterloo.ca/apache/tomcat/tomcat-8/v8.5.20/bin/apache-tomcat-8.5.20.tar.gz
mkdir /opt/tomcat
tar xvf apache-tomcat-8.5.20.tar.gz -C /opt/tomcat --strip-components=1
3)权限控制
chgrp -R tomcat /opt/tomcat
sudo chmod -R g+r conf
sudo chmod g+x conf
sudo chown -R tomcat webapps/ work/ temp/ logs/
4)使用 systemctl 管理 tomcat
3、安装MySQL
CentOS 7 prefers MariaDB, a fork of MySQL managed by the original MySQL developers and designed as a replacement for MySQL. If you run yum install mysql on CentOS 7, it is MariaDB that is installed rather than MySQL.
网友评论