• Linux(CentOS7) 常用命令(防火墙,用户组,MD5等)


    base

    # 获取函数返回值或者上一个命令的退出状态
    md5sum -c --status filename.md5
    echo $?
    
    # 获取结果的第 1 行,第 2ps -ef | grep tomcat | sed -n '1p' | awk '{print $2}'
    ps -ef | grep tomcat | awk 'NR==1' | awk '{print $2}'
    ps -ef | grep tomcat | grep -v 'grep.*color=auto' | awk '{print $2}'
    
    # 命令输出结果作为输入参数
    ps -ef | grep tomcat | grep -v 'grep.*color=auto' | awk '{print $2}' | xargs kill -9

    end

    shell 常用设置命令

    # 关闭防火墙
    systemctl stop firewalld.service
    systemctl disable firewalld.service
    
    # 替换阿里 yummv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
    curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
    yum makecache
    
    # 安装 vim
    yum -y install vim
    
    # 关闭连接 ssh 时的 DNS 查询
    sed -i 's/GSSAPIAuthentication yes/GSSAPIAuthentication no/g' /etc/ssh/sshd_config
    sed -i 's/#UseDNS yes/UseDNS no/g' /etc/ssh/sshd_config
    systemctl restart sshd
    
    # 关闭 selinux
    sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
    
    # 关闭系统提示音
    sed -i 's/#set bell-style none/set bell-style none/g' /etc/inputrc
    
    # 关闭 Vim 提示音
    # sed -i '$asetterm -blength 0' /etc/bashrc
    echo ':set vb t_vb=' > ~/.vimrc

    end

    用户,用户组

    # 修改文件或文件夹所属的用户和用户组
    chown -R jenkins:jenkins ./jenkins/
    
    # 修改文件或文件夹的权限
    chmod -R 0777 ./jdk1.8.0_251/
    
    # 查看所有用户
    # cat /etc/passwd | grep -v nologin | grep -v halt | grep -v shutdown | awk -F":" '{ print $1"|"$3"|"$4 }' | more
    cat /etc/passwd
    # jenkins:x:998:996:Jenkins Automation Server:/var/lib/jenkins:/bin/false
    
    # 修改用户目录
    usermod -d /opt/jenkins/ -u 998 jenkins
    # jenkins:x:998:996:Jenkins Automation Server:/opt/jenkins/:/bin/false

    end

    MD5

    # 查看文件 md5 值
    md5sum filename
    
    # 查看文件 sha1 值
    sha1sum filename
    
    # 查看文件 sha256 值
    sha256sum filename
    
    # 查看当前目录下所有文件的 md5 值
    md5sum *

    end

    C 环境

    yum install -y cmake gcc gcc-c++ gdb
    
    # 新版 cmake
    # 下载 https://cmake.org/download/
    # https://github.com/Kitware/CMake/releases
    wget -O /opt/cmake-3.17.3.tar.gz  https://github.com/Kitware/CMake/releases/download/v3.17.3/cmake-3.17.3.tar.gz
    cd /opt/
    tar -zxf cmake-3.17.3.tar.gz
    mv cmake-3.17.3 cmake-3.17.3-src
    cd cmake-3.17.3-src/
    # 或者 Install an OpenSSL development package
    vim CMakeLists.txt
    添加 set(CMAKE_USE_OPENSSL OFF)
    # 配置安装路径
    ./bootstrap --prefix=/opt/cmake-3.17.3
    # 编译安装
    make && make install
    
    # 新版本 gdb
    # 下载
    curl -o /opt/gdb-8.3.1.tar.gz  https://mirrors.ustc.edu.cn/gnu/gdb/gdb-8.3.1.tar.gz
    cd /opt/
    tar -zxf gdb-8.3.1.tar.gz
    mv gdb-8.3.1 gdb-8.3.1-src
    cd gdb-8.3.1-src/
    # 配置安装路径
    ./configure --prefix=/opt/gdb-8.3.1
    # 编译安装
    make && make install

    end


    https://www.cnblogs.com/jhxxb/p/10573957.html

  • 相关阅读:
    十四
    十三
    十二
    十一
    用Linq从一个集合选取几列得到一个新的集合-可改列名
    LINQ入门(完结篇)
    LINQ入门(下篇)
    LINQ入门(中篇)
    LINQ入门(上篇)
    MVC中View往Controllers传数据的方式-已发
  • 原文地址:https://www.cnblogs.com/jhxxb/p/12596244.html
Copyright © 2020-2023  润新知