centos7安装后,一些小优化

1.设置静态ip

vim /etc/sysconfig/network-scripts/ifcfg-ens33

  将BOOTPROTO=dhcp修改为BOOTPROTO=static

  ONBOOT=no修改为ONBOOT=yes

新增

  IPADDR=192.168.80.129
  PREFIX=24    #NETMASK=255.255.255.0
  GATEWAY=192.168.80.2
  DNS1=114.114.114.114
  DNS2=8.8.8.8

 

之后重启网络服务

systemctl restart network

2.关闭NetworkManager

systemctl status NetworkManager

systemctl stop NetworkManager

systemctl disable NetworkManager

3.关闭selinux

vim /etc/selinux/config

将SELINUX=enforcing注释掉,并添加SELINUX=disabled,之后重启电脑生效

4.修改主机名

hostnamectl set-hostname centos2

5.修改yum源为阿里云

cd /etc/yum.repos.d

wget http://mirrors.aliyun.com/repo/Centos-7.repo

mv CentOS-Base.repo CentOS-Base.repo.bak

mv Centos-7.repo CentOS-Base.repo

yum clean all

yum makecache

yum update

6.设置环境变量

 

cd /etc/profile.d/

 vim custom.sh  

    export PS1="\[\e[35;1m\][\u@\h \w]\\$\[\e[m\] "

    alias sudo='sudo '

    alias egrep='egrep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias grep='grep --color=auto'
    alias ls='ls --color=auto'
    alias l.='ls -d .* --color=auto'
    alias ll='ls -l --color=auto'
    alias l='ls -laF'

    alias cp='cp -i'
    alias mv='mv -i'
    alias rm='rm -i'

    alias now='date +%Y%m%d%H%M%S'

 source custom.sh

 7.ssh无密码登录

生成公钥私钥

ssh-keygen -t rsa

新建文件并添加主机公钥

touch authorized_keys

#vim authorized_keys

8.修改最大文件打开数

先查看默认最大文件打开数

ulimit -n

ulimit -a

修改配置文件 

vim /etc/security/limits.conf

在最后添加

* soft nofile 65535

* hard nofile 65535

 之后重启电脑生效

 

posted @ 2019-11-01 17:11  一窗明月半帘风  阅读(353)  评论(0编辑  收藏  举报