zoukankan      html  css  js  c++  java
  • Linux运维命令笔记一

     1.Centos 无netstat 命令

    yum -y install net-tool
    netstat -tunp

     2.Centos防火墙

    systemctl stop firewalld.service #停止firewall

     3.yum 命令

    #更新升级

    yum -y update

    #模糊查找应用

    yum search net-tool
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirror.hostduplex.com
     * extras: repos.lax.quadranet.com
     * updates: repos.lax.quadranet.com
    ============================================================================== N/S matched: net-tool ===============================================================================
    net-tools.x86_64 : Basic networking tools
    
      Name and summary matches only, use "search all" for everything.
    [root@master2020 ~]# yum -y install net-tools.x86_64 

    #查看应用信息

    yum info nginx

    #卸载

    yum remove nginx

    #安装

    yum install ngin

    4.curl 命令

     #打印网页

    curl http://www.linux.com

    5.安装编译

    configue 运行configure脚本,就可产生出符合GNU规范的Makefile文件

    ./configure –prefix=/usr 
    #该软件安装在 /usr 下面,执行文件就会安装在 /usr/bin (而不是默认的 /usr/local/bin),资源文件就会安装在 /usr/share(而不是默认的/usr/local/share)

    make 编译

    make 过程中出现 error ,你就要记下错误代码(注意不仅仅是最后一行),然后你可以向开发者提交 bugreport(一般在 INSTALL 里有提交地址),或者你的系统少了一些依赖库等

    make insatll 安装

    有些软件需要先运行 make check 或 make test 来进行一些测试,这一步一般需要你有 root 权限

    make clean 删除临时文件

    清除编译产生的可执行文件及目标文件(object file,*.o)

    make distclean

    清除可执行文件和目标文件外,把configure所产生的Makefile也清除掉。

    6.防火墙

    CentOS 7

    关闭防火墙
    systemctl stop firewalld.service             #停止firewall
    systemctl disable firewalld.service        #禁止firewall开机启动
    
    开启端口
    firewall-cmd --zone=public --add-port=80/tcp --permanent
    --zone #作用域
    --add-port=80/tcp #添加端口,格式为:端口/通讯协议
    --permanent #永久生效,没有此参数重启后失效
    重启防火墙
    firewall-cmd --reload
    
    常用命令介绍
    firewall-cmd --state                           ##查看防火墙状态,是否是running
    firewall-cmd --reload                          ##重新载入配置,比如添加规则之后,需要执行此命令
    firewall-cmd --get-zones                       ##列出支持的zone
    firewall-cmd --get-services                    ##列出支持的服务,在列表中的服务是放行的
    firewall-cmd --query-service ftp               ##查看ftp服务是否支持,返回yes或者no
    firewall-cmd --add-service=ftp                 ##临时开放ftp服务
    firewall-cmd --add-service=ftp --permanent     ##永久开放ftp服务
    firewall-cmd --remove-service=ftp --permanent  ##永久移除ftp服务
    firewall-cmd --add-port=80/tcp --permanent     ##永久添加80端口 
    iptables -L -n                                 ##查看规则,这个命令是和iptables的相同的
    man firewall-cmd                               ##查看帮助

    7.修改ssh 端口(SELinux)

     #开通防火墙通道

     #SELinux 是否开启

    sestatus -v

    sshd 在 SELinux 中的端口

    #安装工具
    yum install policycoreutils-python semanage port -l | grep ssh

    #新端口加入

    semanage port -a -t ssh_port_t -p tcp 2222
    #删除端口
    semanage port -d -t ssh_port_t -p tcp 2222

    #修改ssh端口

    vi /etc/ssh/sshd_config

    #重启服务

    service sshd restart

    #查看更新的端口

    semanage port -l | grep ssh

     8.CPU数量

    # 总核数 = 物理CPU个数 X 每颗物理CPU的核数 
    # 总逻辑CPU数 = 物理CPU个数 X 每颗物理CPU的核数 X 超线程数
    
    # 查看物理CPU个数
    cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
    
    # 查看每个物理CPU中core的个数(即核数)
    cat /proc/cpuinfo| grep "cpu cores"| uniq
    
    # 查看逻辑CPU的个数
    cat /proc/cpuinfo| grep "processor"| wc -l

     9.修改时区

    #Centos
    ln
    -sf /usr/share/zoneinfo/Asia/Chongqing /etc/localtime

     

     

  • 相关阅读:
    jquery通过val()取不到textarea中的值
    form表单右边弹窗提示不能为空
    正则表达式
    layui表格的批量删除功能
    layui中table表格的操作列(删除,编辑)等按钮的操作
    layui动态渲染生成select的option值
    layui实现table表格的“关键字搜索”功能
    Python3基础 break while循环示例
    Python3基础 bool类型变量赋值
    Python3基础 assert 断言 确保程序的正确运行条件
  • 原文地址:https://www.cnblogs.com/aongao/p/12343390.html
Copyright © 2011-2022 走看看