美文网首页
Linux 常用命令

Linux 常用命令

作者: 板栗炖牛肉 | 来源:发表于2021-01-27 17:17 被阅读0次

前言

Linux 常用命令集,只做随笔,会不断更新 (centos8.0)

解决方案

  • linux密码修改
    passwd root

  • 更换yum源(centos8.0,根据源镜像名称替换)
    cd /etc/yum.repos.d
    mv CentOS-Linux-BaseOS.repo CentOS-Linux-BaseOS.repo.backup
    mv /etc/yum.repos.d/CentOS-Linux-BaseOS.repo /etc/yum.repos.d/CentOS-Base.repo.backup
    yum makecache

  • 添加swap分区(docker虚拟机中无效)
    dd if=/dev/zero of=/swapfile bs=1M count=5096
    mkswap /swapfile --- 格式化为交换分区文件
    swapon /swapfile ---激活分区
    vim /etc/fstab 添加 /swapfile swap swap defaults 0 0 ---开机自动启动

  • 删除用户
    userdel -r 用户名

  • 新建用户
    adduser 用户名

  • 限制用户使用最大内存
    echo "用户名 hard rss 71680" >> /etc/security/limits.conf
    echo "#Sets up user limits according to /etc/security/limits.conf" >/etc/pam.d/login
    echo "session required pam_limits.so" > /etc/pam.d/login

  • 查看用户最大内存
    ulimit -a

  • 查看kill日志
    journalctl -xb | egrep -i 'killed process' -C 5

  • 进程后台
    command &
    nohup command > command.out &
    exit

  • 进程终止
    kill -9 8080

  • 开放端口
    firewall-cmd --zone=public --add-port=8080/tcp --permanent
    firewall-cmd --reload

  • 查看开放端口
    firewall-cmd --zone=public --list-ports

  • 检查端口占用程序
    netstat -lnpt |grep 8080

  • 关闭防火墙
    systemctl stop firewalld.service

  • 检查防火墙状态
    firewall-cmd --state

  • 查看本机Ip地址
    ifconfig -a

  • 添加写权限
    chmod u+w /目录

  • 用户权限目录
    /etc/sudoers

  • 修改系统服务文件
    vim .bash_profile

  • 添加环境变量
    vim /etc/profile

  • 查看tcp端口
    netstat -ntlp

  • 临时关闭selinux
    setenforce 0

  • 权限
    chown -R mysql:mysql /路径

  • 设置时间
    timedatectl set-timezone Asia/Shanghai

相关文章

网友评论

      本文标题:Linux 常用命令

      本文链接:https://www.haomeiwen.com/subject/dgdeaktx.html