Linux_基础优化

  
01.添加普通用户 命令:useradd
  设置用户密码:
  -交互方式:passwd oldbpoy
  -免交互方式:echo 123456|passwd -stdin oldboy
  切换用户信息:
  su -root :切换为root需要密码
  su -oldboy :切换为普通用户不需要密码
  用户信息查看 : whoami
  [root@zhq oldboy]# whoami
  root
  [root@zhq oldboy]# who a mi
  root pts/0 2019-10-14 09:15 (10.0.0.1)
  [root@zhq oldboy]# who
  zhq tty1 2019-10-12 13:44
  root pts/0 2019-10-14 09:15 (10.0.0.1)

02.命令提示信息优化
  echo $PAI:显示命令符提示格式信息变量
  【系统默认的大写方式书写变量】

  临时设置环境变量:
  export PS1='[\u@\h \w]\$ '
  永久设置环境变量:
  vim /etc/profile
  export PS1='[\u@\h \w]\$ '
  tail 1 /etc/profile
  source /etc/profile

03下载的源信息更新
  rpm yum 源码安装
04.系统安全相关优化

  关闭selinux(由美国国家安全局创建)安全服务功能:

  1>永久关闭selinux功能(重启系统生效)

  vim /etc/selinux/config

  功能永久开启:enforcing

  功能临时关闭:permissive

  功能永久关闭: disabled

  sed -i "s#SELINUX=123#SELINUX=disabled#g" /etc/selinux/config
  grep "=disabled" /etc/selinux/config

  【运维修改文件三部曲】:

  01:编辑文件进行备份

  02:编辑文件进行修改

  03: 编辑文件进行检查

  2>临时关闭selinux功能(设置立即生效)

  setenforce [ Enforcing | Permissive | 1 | 0 ]

  gerenforce 

  功能永久开启:enforcing |1

  功能临时关闭:permissive|0

  关闭iptables安全服务功能

  服务器防火墙运行状态建议

  开启:服务器可以被外界访问(公网/外网ip)

  关闭:服务器可以被内部访问(私网/内网ip)

     服务器处于高并发状态(公网/外网ip)

  Centos 7: 

  systemctl start firewalld.service 【开启】

  systemctl stop  firewalld.service 【关闭】

  systemctl status  firewalld.service 【查看状态】

  systemctl is-active  firewalld.service

  systemctl is-enabled firewalld.service 【查看服务自启动状态信息】

  systemctl enable firewald.service 【修改为开启自启动】

  systemctl disabled firewalld.service

  Centos 6:

  /etc/init.d/iptables start

  利用硬件防火墙进行规范

   /etc/init.d/iptables stop

   /etc/init.d/iptables status 

  chkconfig/chkconfig --list  【查看所有服务启动状态信息】

  chkconfig|grep "ipt" 【查看指定服务状态信息】

  chkconfig iptables off/on 【修改指定服务启动状态信息】

05.防止系统乱码优化

  出现乱码情况设置

  export LANG=en.US-gb2312

  echo $LANG  【查看系统当前使用字符集】

  解决乱码情况设置

  临时修改系统字符集信息

  Xshell/SecureCRT :查看系统连接软件字符集

  export LANG=en_US.utf8 :确保系统和连接软件一致

  永久修改系统字符集设置

  1.备份配置信息

  cp /etc/locale.conf /etc/locale.conf.bak

  2.编写配置文件

  echo 'LANG="zh_CN.UTF-8"' > /etc/locale.conf

  source /etc/locale.conf

  3.查看配位信息

  echo $LANG

  同时永久临时修改字符集

  localectl set-locale LANG=zh_CN.UTF-8

  source /etc/locale.conf

06 下载的源信息更新

  时区:可以有效设置的时间信息

  时间修改方式说明:

    RTC:系统硬件时间信息

    NTP: 网络时间同步协议

  timedatectl  查看时区信息

  修改时区方法:

  timedatectl list-timezones   列出所有时区

  timedatectl set-local-rtc 1 将硬件时钟调整为与本地时钟一致, 0 为设置为 UTC时间

  timedatectl set-timezone Asia/Shanghai 设置系统时区为上海

  时间同步设置

  yum -y  install ntp

  ntpdate ntp1.aliyum.com 

猜你喜欢

转载自www.cnblogs.com/zhanghongqi/p/11670759.html
今日推荐