Linux基础入门--Linux常用命令
小职 2021-11-10 来源 :「JavaEEJava」 阅读 751 评论 0

摘要:本篇主要介绍了Linux基础入门--Linux常用命令,通过具体的内容展现,希望对Linux开发的学习有一定的帮助。

本篇主要介绍了Linux基础入门--Linux常用命令,通过具体的内容展现,希望对Linux开发的学习有一定的帮助。

Linux基础入门--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"


我是小职,记得找我

✅ 解锁高薪工作

✅ 免费获取基础课程·答疑解惑·职业测评

Linux基础入门--Linux常用命令

本文由 @小职 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved

208小时内训课程