Linux常用命令
Linux常用命令
1、Cnetos7使用yum安装nginx
-
查看gcc版本
gcc -v
-
gcc安装命令
yum -y install gcc
-
安装openssl
# openssl是web安全通信的基石,没有openssl,可以说我们的信息都是在裸奔。。。。。。 yum install -y openssl openssl-devel
-
安装nginx
yum install -y nginx
-
启动并设置开机自启
sudo systemctl start nginx sudo systemctl enable nginx
2、开放防火墙端口
-
开启防火墙
systemctl start firewalld.service
-
关闭防火墙
systemctl stop firewalld.service
-
重启防火墙
firewall-cmd --reload
-
开启端口
firewall-cmd --zone=public --add-port=80/tcp --permanent #重新加载 firewall-cmd --reload
-
查看已开放的端口
firewall-cmd --list-ports
3、安装jdk
-
解压jdk安装包
# 解压 tar -zxvf jdk-8u271-linux-x64.tar.gz # 修改解压后的文件名称为jdk1.8 mv xxx/ jdk1.8
-
配置环境变量
vim /etc/profile # 在最后边加 # JAVA环境变量 JAVA_HOME=/xxx/xxx/xxx PATH=$JAVA_HOME/bin:$PATH CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export JAVA_HOME export PATH export CLASSPATH
-
测试是否安装成功
[root@iZ2ze7jmwvt3iec793aif4Z java]# java -version java version "1.8.0_271" Java(TM) SE Runtime Environment (build 1.8.0_271-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode) [root@iZ2ze7jmwvt3iec793aif4Z java]# javac Usage: javac <options> <source files> where possible options include: -g Generate all debugging info -g:none Generate no debugging info -g:{lines,vars,source} Generate only some debugging info -nowarn Generate no warnings -verbose Output messages about what the compiler is doing -deprecation Output source locations where deprecated APIs are used -classpath <path> Specify where to find user class files and annotation processors -cp <path> Specify where to find user class files and annotation processors -sourcepath <path> Specify where to find input source files -bootclasspath <path> Override location of bootstrap class files -extdirs <dirs> Override location of installed extensions -endorseddirs <dirs> Override location of endorsed standards path -proc:{none,only} Control whether annotation processing and/or compilation is done. -processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process -processorpath <path> Specify where to find annotation processors -parameters Generate metadata for reflection on method parameters -d <directory> Specify where to place generated class files -s <directory> Specify where to place generated source files -h <directory> Specify where to place generated native header files -implicit:{none,class} Specify whether or not to generate class files for implicitly referenced files -encoding <encoding> Specify character encoding used by source files -source <release> Provide source compatibility with specified release -target <release> Generate class files for specific VM version -profile <profile> Check that API used is available in the specified profile -version Version information -help Print a synopsis of standard options -Akey[=value] Options to pass to annotation processors -X Print a synopsis of nonstandard options -J<flag> Pass <flag> directly to the runtime system -Werror Terminate compilation if warnings occur @<filename> Read options and filenames from file
4、Linux下创建用户
-
使用root用户登录,添加用户
# useradd -d /为此用户设置主目录 -m 用户名 useradd -d /xxx -m xxx
-
设置密码
[root@iZ2ze7jmwvt3iec793aif4Z shell]# passwd xxx Changing password for user xxx. New password: Retype new password: passwd: all authentication tokens updated successfully.
-
登录测试
5、netstat的用法
-
列出所有连接
netstat -a
-
只列出TCP或UDP协议的连接
#列出TCP协议的连接 netstat -at #列出UDP协议的连接 netstat -au
-
禁用反向域名解析,加快查询速度
# 默认情况下 netstat 会通过反向域名解析技术查找每个 IP 地址对应的主机名。这会降低查找速度。如果你觉得 IP 地址已经足够,而没有必要知道主机名,就使用 -n 选项禁用域名解析功能。 netstat -ant
-
只列出监听中的连接
netstat -tnl
-
获取进程名、进程号以及用户id
sudo netstat -nlpt
-
打印统计数据
# netstat 可以打印出网络统计数据,包括某个协议下的收发包数量 # 如果想只打印出 TCP 或 UDP 协议的统计数据,只要加上对应的选项(-t 和 -u)即可 netstat -s
-
打印active状态的连接
netstat -atnp | grep ESTA # 配合watch命令监视active状态的连接 watch -d -n0 "netstat -atnp | grep ESTA"