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

    查看系统版本

    [root@luffy-01 /]# cat /etc/redhat-release 
    CentOS release 6.9 (Final)
    [root@luffy-01 /]# uname -m
    x86_64
    [root@luffy-01 /]# uname -r
    2.6.32-696.el6.x86_64
    [root@luffy-01 /]# uname -a
    Linux luffy-01 2.6.32-696.el6.x86_64 #1 SMP Tue Mar 21 19:29:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

    一般不使用 -a ,因为信息太长,不需要看这么多

    系统环境变量PS1

    查看系统环境变量 echo $PS1 
    #PS1 系统环境变量 ##一般都是大写的,在系统中任何的地方都可以使用。 
    [root@oldboyedu-01 ~]# echo $PS1 [u@h W]$ 
    [root@oldboyedu-01 ~]# #u=====当前用户名 whoami 
    [root@oldboyedu-01 ~]# #h 当前主机名 hostname 
    [root@oldboyedu-01 ~]# #W 当前的位置 pwd 
    [root@oldboyedu-01 ~]# PS1='[u@h W 	]$' 加了一个时间	,就会在命令行前面显示时间

    一、添加用户

    Linux用户分为两种,root用户和普通用户

    添加用户命令:useradd

    查看用户:id

    设置密码:passwd

    切换用户:su - 用户名

    思考:su   和su  -   的区别是什么?

    快捷键:   ctrl + d  退出当前用户(控制着使用,一不小心按多了,就坏了)

    二、关闭 SElinux

    SELinux 主要由美国国家安全局开发

    SElinux是限制root用户的权限的软件

    临时关闭-重启服务器失效

    [root@oldboyedu-01 ~]# #查询selinux状态
    [root@oldboyedu-01 ~]# getenforce 
    Enforcing
    
    # 共3种状态
    
    [root@oldboyedu-01 ~]# #enforcing   selinux正在运行
    [root@oldboyedu-01 ~]# #permissive  selinux临时关闭 还是提示警告
    [root@oldboyedu-01 ~]# #disabled    selinux彻底关闭
    
    #临时关闭
    
    [root@oldboyedu-01 ~]# setenforce
    usage:  setenforce [ Enforcing | Permissive | 1 | 0 ]
    [root@oldboyedu-01 ~]# setenforce 0
    [root@oldboyedu-01 ~]# getenforce 
    Permissive
    [root@oldboyedu-01 ~]# 重启服务器,又会开启

    永久关闭-重启服务器生效

    需要使用vim修改/etc/selinux/config中的文件内容

    [root@oldboyedu-01 ~]# vim /etc/selinux/config
    
    # 然后查看
    
    [root@oldboyedu-01 ~]# grep "=disabled" /etc/selinux/config 
    SELINUX=disabled
    [root@oldboyedu-01 ~]# grep "disabled" /etc/selinux/config 
    #     disabled - No SELinux policy is loaded.
    SELINUX=disabled

     

    三、关闭Iptables

    即关闭防火墙

     

    临时关闭

    # 查询防火墙是否在运行 
    /etc/init.d/iptables  status
    [root@oldboyedu-01 ~]# /etc/init.d/iptables  stop  临时关闭iptables
    iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
    iptables: Flushing firewall rules:                         [  OK  ]
    iptables: Unloading modules:                               [  OK  ]
    [root@oldboyedu-01 ~]# /etc/init.d/iptables  stop
    [root@oldboyedu-01 ~]# /etc/init.d/iptables  status 
    iptables: Firewall is not running.

     

    永久关闭

    临时关闭后,开机还会自动启动
    #如何让iptables在开机的时候 不自动启动
    命令:chkconfig 
    # 数字3 的状态是on 就表示开机启动 [root@oldboyedu
    -01 ~]# chkconfig |grep ipt 检查iptables 是否开机启动 iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@oldboyedu-01 ~]# chkconfig iptables off 关闭iptables的开机自启动 [root@oldboyedu-01 ~]# chkconfig |grep ipt iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off

     

    四、显示中文乱码的排查

    1.什么是字符集?
    ######表示字符 文字的方法
    UTF-8      万国码 系统默认的字符集
    GBK GB2312 
    2.如何查看系统的字符集
    [root@oldboyedu-01 ~]# echo $LANG
    en_US.UTF-8
    [root@oldboyedu-01 ~]# #语言.字符集
    3.如何修改字符集-临时
    [root@oldboyedu-01 ~]# export   LANG=zh_CN.UTF-8
    [root@oldboyedu-01 ~]# echo $LANG
    zh_CN.UTF-8
    4.如何修改字符集-永久
    [root@oldboyedu-01 ~]# cat /etc/sysconfig/i18n 
    LANG="en_US.UTF-8"
    SYSFONT="latarcyrheb-sun16"
    5.生效 
    [root@oldboyedu-01 ~]# source  /etc/sysconfig/i18n 
    [root@oldboyedu-01 ~]# echo $LANG
    en_US.UTF-8

    乱码之后如何排查

    #####1.查看中文乱码的原因******
    ####1)linux使用的字符集  echo $LANG
    ####2)远程连接工具使用的字符集 即Xshell中的(单击小地球就会显示,或者在文件-属性-终端中(最下面)会有显示)
    ####1) 与 2) 不同 就会导致乱码 

    #####2.排查 ####1)linux使用的字符集 ####2)远程连接工具使用的字符集

    #####3.解决 ####方法1 修改远程连接工具字符集 ####方法2 修改linux系统的字符集

    ####1.如何修改字符集-临时 ####2.如何修改字符集-永久 ####3.生效
  • 相关阅读:
    js验证及限制文本框输入
    在鼠标单击位置显示一个层,而不影响其它超级链接或按钮
    js创建弹出DIV层并锁定背景层
    SQLConvert(varchar(12),getdate(111))中的111,112,110
    C#提高的一些要点
    简洁纯js分页
    java排序集锦
    企业中vsftp虚拟用户高级配置实战
    MySQL的timeout那点事
    MYSQL管理之索引改造
  • 原文地址:https://www.cnblogs.com/yxiaodao/p/9790684.html
Copyright © 2011-2022 走看看