zoukankan      html  css  js  c++  java
  • Linux系统优化

    1.1 查看Linux版本

    1.1.1 系统版本

    [root@znix ~]# cat /etc/redhat-release
    CentOS release 6.9 (Final)

    1.1.2 内核版本

    [root@znix ~]# uname -r
    2.6.32-696.el6.x86_64

    1.1.3 系统架构

    [root@znix ~]# uname -m
    x86_64

    1.2 添加用户、设置密码

    1.2.1 添加用户

    [root@znix ~]# useradd clsn

    1.2.2 设置密码

    [root@znix ~]# passwd clsn
    Changing password for user clsn. ###修改clsn用户密码
    New password:
    BAD PASSWORD: it is too simplistic/systematic
    BAD PASSWORD: is too simple  ###密码太简单
    Retype new password:
    passwd: all authentication tokens updated successfully(成功).

    1.3 切换用户

    1.3.1 使用这个用户 切换用户

    [root@znix ~]# su - clsn

    1.3.2 显示你是谁?

    [clsn@znix ~]$ whoami
    clsn

    1.4 su su- 的区别

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

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

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

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

    1.5 关闭selinux

    1.5.1 永久生效

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

    [root@znix ~]# 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命令

    [root@znix ~]# source /etc/selinux/config

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

    使用的服务器不可以随意重启!

    1.5.2 临时关闭

    使用getenforce 命令查看selinux

    [root@znix ~]# getenforce
    Enforcing(正在运行)

    使用setenforce 命令修改selinux配置临时关闭selinux

    [root@znix ~]# setenforce
    usage:  setenforce [ Enforcing | Permissive | 1 | 0 ]
    
    [root@znix ~]# setenforce 0
    [root@znix ~]# getenforce
    Permissive(临时关闭)

    1.6 关闭防火墙

    1.6.1 临时关闭

    1)         查询防火墙是否正在运行

    [root@znix ~]# /etc/init.d/iptables status

    2)         关闭防火墙

    a)      一般需要关两次,确保完全关闭。

    [root@znix ~]# /etc/init.d/iptables stop
    iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
    iptables: Flushing firewall rules:                         [  OK  ]
    iptables: Unloading modules:                            [  OK  ]
    
    [root@znix ~]# /etc/init.d/iptables stop

    3)         检查一下是否关闭

    [root@znix ~]# /etc/init.d/iptables status
    iptables: Firewall is not running.

    1.6.2 永久关闭

    确保开机防火墙不再启动

    chkconfig中查找iptables 的行,看他的状态。on是开,off是关。

    [root@znix ~]# chkconfig|grep "ipta"
    iptables         0:off      1:off      2:on       3:on       4:on       5:on       6:off

    使用chkconfig的命令关闭iptables

    [root@znix ~]# chkconfig iptables off

    检查一下是否关闭了。

    [root@znix ~]# chkconfig|grep "ipta"
    iptables         0:off      1:off      2:off      3:off      4:off      5:off      6:off

    1.7 显示乱码解决

    1.7.1 查看linux系统字符集

    [root@znix ~]# echo $LANG
    en_US.UTF-8

    1.7.2 查看远程软件的字符集

    连接软件的字符集是否与系统的一致 

    1.7.3 乱码解决办法

    1)         linux系统字符集修改

    a)      使用export 对变量进行修改

    [root@znix ~]# export LANG=en_US.utf8
    [root@znix ~]# echo $LANG
    en_US.utf8

          b)修改配置文件,将/etc/sysconfig/i18n修改为utf-8字符集。

    [root@znix ~]# cat /etc/sysconfig/i18n
    LANG="en_US.UTF-8"
    SYSFONT="latarcyrheb-sun16"

          c)使用source. /etc/sysconfig/i18n  让配置生效

    [root@znix ~]# source /etc/sysconfig/i18n
    [root@znix ~]# . /etc/sysconfig/i18n
  • 相关阅读:
    MySQL查询优化程序
    mysql主从:主键冲突问题
    Cacti 'graph_xport.php' SQL注入漏洞
    Nginx SPDY缓冲区溢出漏洞
    Zend Framework XML外部实体和安全绕过漏洞
    WordPress 3.8.1 /xmlrpc.php拒绝服务漏洞
    OpenSSH 'child_set_env()'函数安全绕过漏洞
    PHP "gdImageCreateFromXpm()"空指针间接引用漏洞
    Apache HTTP Server多个拒绝服务漏洞
    Samba 安全漏洞
  • 原文地址:https://www.cnblogs.com/clsn/p/7514524.html
Copyright © 2011-2022 走看看