zoukankan      html  css  js  c++  java
  • 九、系统优化方法(基础优化)

    系统优化方法(基础优化)

    一、查看了解系统信息

    1、uname -a 查看内核信息
    2、cat /proc/version 查看内核信息
    3、cat /etc/redhat-release 查看系统版本
    4、cat /proc/cpuinfo 查看cpu信息
    5、hostname 查看计算机名称
    6、lsmod 查看内核模块
    7、free -h 查看内存使用情况
    8、df -h 查看各分区使用情况

    二、用户账号管理

    1、添加一个普通用户账号
    useradd tom 添加tom
    password tom 修改tom用户的密码
    2、切换用户
    su 切换用户名命
    su - tom 切换到tom用户
    3、id 查看信息
    4、whoami 查看当前身份

    三、操作系统优化---命令提示符优化

    01. 修改命令提示符的内容:
    vi /etc/profile 把export PS1='[u@H w]$ '追加到最后一行

    [root@localhost.localdomain ~]# tail -5 /etc/profile
    export PS1='[u@H w]$ '

    u --- 显示当前登录用户名称
    H --- 显示系统完整主机名称
    W --- 显示当前所在目录信息(目录结构的最后结尾信息)

    02. 命令提示符如何修改颜色:
    Linxu系统中如何给信息加颜色

    [e[F;Bm] 文字内容 e[m

    ”[[e[31;40m]ue[m @h W]$ “

    [root@oldboyedu ~]# tail -5 /etc/profile
    export PS1='[e[32;1m][u@h W]$ [e[0m]'

    设置颜色 内容 结束

    export PS1='[e[30;1m][u@h W]$ [e[0m]' -- 黑色提示符
    export PS1='[e[31;1m][u@h W]$ [e[0m]' -- 红色提示符
    export PS1='[e[32;1m][u@h W]$ [e[0m]' -- 绿色提示符
    export PS1='[e[33;1m][u@h W]$ [e[0m]' -- 黄色提示符
    export PS1='[e[34;1m][u@h W]$ [e[0m]' -- 蓝色提示符
    export PS1='[e[35;1m][u@h W]$ [e[0m]' -- 粉色
    export PS1='[e[36;1m][u@h W]$ [e[0m]' -- 浅蓝
    export PS1='[e[37;1m][u@h W]$ [e[0m]' -- 白色

    四、操作系统优化---yum下载源优化

    0、安装wget工具
    yum install wget -y
    1、首先备份/etc/yum.repos.d/CentOS-Base.repo
    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
    2、下载对应版本repo文件, 放入/etc/yum.repos.d/(操作前请做好相应备份)
    cd /etc/yum.repos.d/
    wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
    3、运行以下命令生成缓存
    yum clean all
    yum makecache
    4、检查可用的yum主机
    yum repolist


    国内比较好的源地址:
    https://developer.aliyun.com/mirror/
    http://mirrors.163.com/.help/centos.html

    5、安装常用工具:yum install -y vim tree wget net-tools nmap bash-completion sysstat

    6、查看己安装的工具
    rpm -aq -q表示查询 -a表提所有
    [root@localhost.localdomain /etc/yum.repos.d]# rpm -aq tree
    tree-1.6.0-10.el7.x86_64
    7、查看某个工具的安装目录
    rpm -aql -l列表显示

    [root@localhost.localdomain /etc/yum.repos.d]# rpm -aql tree
    /usr/bin/tree
    /usr/share/doc/tree-1.6.0
    /usr/share/doc/tree-1.6.0/LICENSE
    /usr/share/doc/tree-1.6.0/README
    /usr/share/man/man1/tree.1.gz

    8、查看某个目录属于哪个软件包
    rpm -qf

    [root@localhost.localdomain ~]# rpm -qf /usr/bin/ssh
    openssh-clients-7.4p1-16.el7.x86_64

    五、系统安全相关优化(将一些安全服务进行关闭)

    1、防火墙服务程序
    centos7 查看防火墙服务状态:systemctl status firewalld
    临时关闭防火墙:systemctl stop firewalld
    永久关闭防火墙:systemctl disable firewalld

    确认防火墙是否关闭:systemctl is-active firewalld
    systemctl status firewalld
    确认防火墙是否开机自启动: systemctl is-enabled firewalld

    2、 系统的selinux服务程序
    selinux服务对root用户权限进行控制
    getenforce 确认selinux服务时否开启还是关闭的

    临时开启或关闭selinux
    [root@localhost.localdomain ~]# setenforce ?
    setenforce [ Enforcing | Permissive | 1 | 0 ]
    Enforcing 或 1 ----临时开启selinux
    Permissive 或 0 ----临时关闭selinux

    永久关闭:
    enforcing - SELinux security policy is enforced.
    selinux服务处于正常开启状态
    permissive - SELinux prints warnings instead of enforcing.
    selinux服务被临时关闭了
    disabled - No SELinux policy is loaded.
    selinux服务彻底关闭
    vi /etc/selinux/config
    SELINUX=disabled
    PS: 如果想让selinux配置文件生效,重启系统

    六、系统中字符集编码设置方法

    centos7
    查看默认编码信息
    [root@localhost.localdomain ~]# echo $LANG
    en_US.UTF-8

    临时修改:
    [root@localhost.localdomain ~]# echo $LANG
    en_US.UTF-8
    [root@localhost.localdomain ~]# LANG=UTF-8

    永入修改:
    方法一: 更加有先
    [root@localhost.localdomain ~]# echo "export LANG='en_US.UTF-8'" >> /etc/profile
    [root@localhost.localdomain ~]# tail -5 /etc/profile
    unset i
    unset -f pathmunge
    export PS1='[u@H w]$ '
    export LANG='en_US.UTF-8'

    方法二:
    [root@localhost.localdomain ~]# echo "LANG="zh_CN.UTF-8"" >> /etc/locale.conf
    [root@localhost.localdomain ~]# cat /etc/locale.conf
    LANG="en_US.UTF-8"
    LANG="zh_CN.UTF-8"

    补充:一条命令即临时设置,又永久设置
    localectl set-locale LANG=zh_CN.GBK

    七. 使xshell软件远程连接速度加快

    第一个步骤:修改ssh服务配置文件
    vi /etc/ssh/sshd_config
    79 GSSAPIAuthentication no
    115 UseDNS no

    第二个步骤:修改hosts文件
    [root@mrxiong ~]# vi /etc/hosts
    10.0.0.200 mrxiong.com

    第三个步骤:重启ssh远程服务
    systemctl restart sshd

  • 相关阅读:
    Java基础知识强化之集合框架笔记20:数据结构之 栈 和 队列
    Java基础知识强化之集合框架笔记19:List集合迭代器使用之 并发修改异常的产生原因 以及 解决方案
    模块已加载,但对dllregisterServer的调用失败
    sql回滚
    BAT 批处理脚本 教程
    shell脚本小技巧
    shell if
    REDHAT4.8安装yum
    Linux中文显示乱码解决
    Nginx配置文件详细说明
  • 原文地址:https://www.cnblogs.com/mr-xiong/p/13708381.html
Copyright © 2011-2022 走看看