zoukankan      html  css  js  c++  java
  • linux服务一——系统优化

    1 查看Linux版本

    1.1 系统版本

    [root@iso-all ~]# cat /etc/redhat-release 
    CentOS Linux release 7.6.1810 (Core) 

    1.2 内核版本

    [root@iso-all ~]# uname -r 
    3.10.0-957.el7.x86_64

    1.3 系统架构

    [root@iso-all ~]# uname -m
    x86_64

    2 添加用户、设置密码

    2.1 添加用户

    [root@iso-all ~]# useradd yhh
    [root@iso-all ~]# 

    2.2 设置密码

    [root@iso-all ~]# passwd yhh 
    更改用户 yhh 的密码 。
    新的 密码:
    无效的密码: 密码少于 8 个字符
    重新输入新的 密码:
    passwd:所有的身份验证令牌已经成功更新。
    [root@iso-all ~]# 

    3 切换用户

    [root@iso-all ~]# su - yhh
    [yhh@iso-all ~]$ 

    4 su 与su- 的区别

    su只是切换了root身份,但Shell环境仍然是普通用户的Shell

    su-连用户和Shell环境一起切换成root身份了。

    只有切换了Shell环境才不会出现PATH环境变量错误。

    su切换成root用户以后,pwd一下,发现工作目录仍然是普通用户的工作目录;而用su -命令切换以后,工作目录变成root的工作目录了

    5 关闭selinux

    5.1 永久生效

    修改配置文件: /etc/selinux/config

    [root@iso-all ~]# vim /etc/selinux/config 

    /etc/selinux/config 文档内容含义:

    #enforcing     selinux默认状态 selinux已经开启,正在运行

    #permissive    selinux临时关闭,显示警告

    #disabled      selinux彻底关闭   

    使用sed命令对/etc/selinux/conifg 文件进行修改

    sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config

    让配置文件的修改生效,使用source命令

    source /etc/selinux/config 

    永久修改的配置生效需要重启服务器

    5.2 临时关闭

    [root@iso-all ~]# getenforce
    Enforcing
    [root@iso-all ~]# setenforce 0
    [root@iso-all ~]# getenforce
    Permissive

    6 关闭防火墙

    6.1 临时关闭

    [root@iso-all ~]# systemctl status firewalld
    ● firewalld.service - firewalld - dynamic firewall daemon
       Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
       Active: active (running) since 六 2020-09-19 11:46:00 CST; 8h ago
         Docs: man:firewalld(1)
     Main PID: 6438 (firewalld)
       CGroup: /system.slice/firewalld.service
               └─6438 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
    
    9月 19 11:45:58 iso-all systemd[1]: Starting firewalld - dynamic firewall daemon...
    9月 19 11:46:00 iso-all systemd[1]: Started firewalld - dynamic firewall daemon.
    [root@iso-all ~]# 
    [root@iso-all ~]# systemctl stop firewalld
    [root@iso-all ~]# systemctl status firewalld
    ● firewalld.service - firewalld - dynamic firewall daemon
       Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
       Active: inactive (dead) since 六 2020-09-19 19:47:31 CST; 2s ago
         Docs: man:firewalld(1)
      Process: 6438 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
     Main PID: 6438 (code=exited, status=0/SUCCESS)
    
    9月 19 11:45:58 iso-all systemd[1]: Starting firewalld - dynamic firewall daemon...
    9月 19 11:46:00 iso-all systemd[1]: Started firewalld - dynamic firewall daemon.
    9月 19 19:47:30 iso-all systemd[1]: Stopping firewalld - dynamic firewall daemon...
    9月 19 19:47:31 iso-all systemd[1]: Stopped firewalld - dynamic firewall daemon.

    6.2 永久关闭

    [root@iso-all ~]# systemctl disable  firewalld

    7 显示乱码解决

    7.1 查看linux系统字符集

    [root@iso-all ~]# echo $LANG
    zh_CN.UTF-8

    如果是en_US.utf8就会乱码

  • 相关阅读:
    随机数、无重复、冒泡排序
    今天是星期几
    Button
    2012/8/5为应用指定多个配置文件
    2012/8/4解决JSP显示中文乱码
    2012/8/4 struts2学习笔记
    2012/8/4Action中result的各种转发类型
    2012/8/4为Action属性注入值
    2012/8/3SVN小入门
    2012/8/3 Extjs使用TabPanel时需要注意的问题
  • 原文地址:https://www.cnblogs.com/huihuangyan/p/13698150.html
Copyright © 2011-2022 走看看