User-Profile-Image
hankin
  • 5
  • centos7
  • docker
  • mysql
  • PostgreSQL
  • git/gitlab
  • ELK
  • python
    • python-Tornado
    • python-django
  • redis
  • nginx
  • kvm
  • proxmox
  • mongo
  • kubernetes
  • prometheus
  • GlusterFs
  • nfs
  • freeswitch
  • httpd
  • shell脚本
  • linux
  • fastdfs
  • nextcloud
  • openssl
  • openvpn
  • rabbitmq
  • sqlite
  • svn
  • java
  • ubuntu
  • vue2
  • wordpress
  • php
  • IOT物联网
  • 项目
  • 故障处理
  • 树莓派
  • 博客存档
  • 未分类
  • 杂项
  • #1742(无标题)
  • 新视野
  • 分类
    • 项目
    • 树莓派
    • 杂项
    • 未分类
    • 新视野
    • 故障处理
    • 博客存档
    • 交换机
    • wordpress
    • vue2
    • ubuntu
    • svn
    • sqlite
    • shell脚本
    • redis
    • rabbitmq
    • python-django
    • python
    • proxmox
    • prometheus
    • PostgreSQL
    • php
    • openvpn
    • openssl
    • nginx
    • nfs
    • nextcloud
    • mysql
    • mongo
    • linux
    • kvm
    • kubernetes
    • java
    • IOT物联网
    • httpd
    • GlusterFs
    • git/gitlab
    • freeswitch
    • fastdfs
    • ELK
    • docker
    • centos7
  • 页面
    • #1742(无标题)
  • 友链
      请到[后台->主题设置->友情链接]中设置。
Help?

Please contact us on our email for need any support

Support
    首页   ›   centos7   ›   正文
centos7

linux-centos7系统常用-操作配置

2022-10-28 23:33:32
680  0 0

centos7系统常用操作集合

linux定时删除N天前的文件(文件夹)参考自
    https://blog.51cto.com/lxw1844912514/3056603
    find /tmp -mtime +30 -type f -name "*" -exec rm -rf {} \;
    /tmp --设置查找的目录;
    -mtime +30 --设置修改时间为30天前;
    -type f --设置查找的类型为文件;其中f为文件,d则为文件夹
    -name "*" --设置文件名称,可以使用通配符;
    -exec rm -rf --查找完毕后执行删除操作;
     {} \; --固定写法
tar解压
    tar -xvf xx.tar
文件传输
    rsync -avR  -e 'ssh -p 1922' --remove-source-files --bwlimit=10000 root@10.252.252.2:/1.tar ./
查找空文件夹
    find -maxdepth 1 -type d -empty
查找空文件夹并删除
    find -type d -empty | xargs -n 1 rm -rf && find -type d -empty | xargs -n 1 rm -rf
关闭selinux
    临时关闭 setenforce 0
    永久关闭 vi /etc/selinux/config 将SELINUX=enforcing改为SELINUX=disabled
设置默认网关
    route add default gw 192.168.2.1
centos7启动选择
    通过systemctl get-default可获得默认启动的target

    通过systemctl set-default设置默认启动的target
    修改为多用户状态只需执行:
    systemctl set-default multi-user.target
    修改为图形界面执行:
    systemctl set-default graphical.target
删除多余内核
    1. 执行以下命令,查看所有的 Kernel。     
        rpm -qa | grep kernel   
    2. 执行以下命令,删除旧版本的内核。     
        yum remove kernel-old_kernel_version    
        例如:yum remove kernel-3.10.0-957.el7.x86_64  
开启 BBR
    1. 执行以下命令,编辑 /etc/sysctl.conf 文件。       
        vim /etc/sysctl.conf    
    2. 按 i 切换至编辑模式,添加如下内容。      
        net.core.default_qdisc=fq   
        net.ipv4.tcp_congestion_control=bbr 
    3. 按 Esc,输入 :wq,保存文件并返回。        
    4. 执行以下命令,从/etc/sysctl.conf配置文件中加载内核参数设置。       
        sysctl -p   
    5. 依次执行以下命令,验证是否成功开启了 BBR。      
        sysctl net.ipv4.tcp_congestion_control  
            # 显示如下内容即可:
            # net.ipv4.tcp_congestion_control = bbr
        sysctl net.ipv4.tcp_available_congestion_control    
            # 显示如下内容即可:
            # net.ipv4.tcp_available_congestion_control = reno cubic bbr
    6. 执行以下命令,查看内核模块是否加载。       
        lsmod | grep bbr    
设置语言环境
查看系统支持的语言环境                     
    localectl list-locales |egrep "zh_Cn|en_US"                 

设置语言环境                      
    localectl set-locale LANG="en_US.UTF-8"                 

查看语言配置全局文件                      
    cat /etc/locale.conf                    
配置日期时间地区
查看日期时间时区                        
    timedatectl                 

设置日期或时间                     
    timedatectl set-time 11:11:12                   
    timedatectl set-time 2018-8-1                   

查看系统支持的时区                       
    timedatectl list-timezone |grep Asia                    

更改时区,立即生效                       
    timedatectl set-timezone Asia/Shanghai                  

查看时区全局配置文件                      
    ls -l /etc/localtime                    

使用远程时间服务器同步本地时间                     
    yum install ntp                 
    timedatectl set-ntp yes                 
网络配置
    查看主机以太网接口                       
    dmesg |grep eth                 

    centos7 网络命名规则                      
    前缀                  
        en  以太网设备           
        wl  无线局域网           
        ww  无线广域网           
    随后三个字母区分硬件类型                    
        o   主板板载设备          
        s   热插拔插槽上          
        p   pci总线或usb接口上

    修改网卡配置
    vim /etc/sysconfig/network-scripts/ifcfg-*          

    ip命令                        
        ip -s 1 s eno111        显示指定接口传输统计          
        ip r s 或ip r        显示路由信息          

    ip命令修改ip                        
        ip addr add 192.168.2.2 dev eth1                    
        ip addr del 192.168.2.2 dev eth1                    

    ip命令设置静态路由                      
        添加删除到主机路由                   
            ip route add 192.168.1.1 via 10.0.0.1 dev eth0              
            ip route del 192.168.1.1 via 10.0.0.1 dev eth0              

    添加删除默认路由                    
        ip route add default  via 10.0.0.1 dev eth0             
        ip route del default  via 10.0.0.1 dev eth0             
设置同步时间centos7
    yum install ntp // 安装ntp服务                      
    systemctl enable ntpd // 开机启动服务                     
    systemctl start ntpd // 启动服务                        
    timedatectl set-timezone Asia/Shanghai // 更改时区                      
    timedatectl set-ntp yes // 启用ntp同步                      
    ntpq -p // 同步时间                     
设置同步时间centos8
    timedatectl set-timezone Asia/Shanghai #设置时区上海                      
    rpm -ivh http://mirrors.wlnmp.com/centos/wlnmp-release-centos.noarch.rpm                        
    yum install wntp                        
    ntpdate ntp1.aliyun.com                     
评论 (0)

点击这里取消回复。

欢迎您 游客  

Copyright © 2025 网站备案号 : 蜀ICP备2022017747号
smarty_hankin 主题. Designed by hankin
主页
页面
  • #1742(无标题)
博主
tang.show
tang.show 管理员
linux、centos、docker 、k8s、mysql等技术相关的总结文档
213 文章 2 评论 201648 浏览
测试
测试