centos7系统的初始环境配置
  OBCxRew8HiW1 2023年11月02日 31 0

(centos7系统的初始环境配置)

一、配置yum仓库

1.配置阿里的仓库源

[root@192 ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

2.检测yum仓库

[root@192 yum.repos.d]# yum repolist all |grep enable
base/7/x86_64               CentOS-7 - Base - mirrors.aliyun.com enabled: 10,072
extras/7/x86_64             CentOS-7 - Extras - mirrors.aliyun.c enabled:    512
updates/7/x86_64            CentOS-7 - Updates - mirrors.aliyun. enabled:  3,875

二、配置tab键补齐

1.安装bash-completion.noarch

yum -y install bash-completion.noarch

2.测试tab键补齐

需重启生效

[root@192 ~]# yum list a
all        available  
[root@192 ~]# yum list a

三、配置网络

[root@192 ~]# nmcli connection modify ens33 ipv4.addresses 192.168.3.201/24 ipv4.gateway 192.168.3.254 ipv4.dns 192.168.3.254 ipv4.method manual 
[root@192 ~]# nmcli con reload 
[root@192 ~]# nmcli con up ens33 

四、修改计算机名

[root@192 ~]# hostnamectl set-hostname node01

五、安装常用工具

1.安装wget

 yum -y install wget

2.安装netstat命令工具

 yum -y install net-tools-2.0-0.25.20131004git.el7.x86_64

3.安装git工具

yum -y install git

4.安装vim

[root@192 ~]# yum install -y vim

六 、配置git命令补全

1.下载git相关文件

[root@192 ~]# git clone https://github.com/markgandolfo/git-bash-completion.git

2.复制文件

mv git-completion.sh/git-completion.bash    ~/.git-completion.bash

3.修改~/.bashrc文件

[root@192 ~]# cat ~/.bashrc 
# .bashrc

# User specific aliases and functions

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

# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

if [ -f ~/.git-completion.bash ]; then
        . ~/.git-completion.bash
fi

4.使环境变量生效

[root@192 ~]# source ~/.bashrc 

5.测试git

[root@192 ~]# git co
column          commit          config          count-objects   
[root@192 ~]# git co

七、配置防火墙与selinux

1.关闭selinux

①查看当前的selinux

[root@192 ~]# getenforce 
Enforcing

②永久关闭selinux

[root@192 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

③临时关闭

[root@192 ~]# setenforce 0
[root@192 ~]# getenforce 
Permissive

2.防火墙配置

①配置防火墙放行服务

[root@192 ~]# firewall-cmd --permanent --add-port=80/tcp
success
[root@192 ~]# firewall-cmd --reload 
success

②.关闭防火墙

[root@192 ~]# systemctl stop firewalld.service 
[root@192 ~]# systemctl disable firewalld.service 
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

3.开启包转发功能

[root@192 ~]# sysctl -w net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1

八、检查系统磁盘空间状况

[root@192 ~]# fdisk -l

Disk /dev/sda: 128.8 GB, 128849018880 bytes, 251658240 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0009df2e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     4196351     2097152   83  Linux
/dev/sda2         4196352    29362175    12582912   83  Linux
/dev/sda3        29362176    37750783     4194304   83  Linux
/dev/sda4        37750784   251658239   106953728    5  Extended
/dev/sda5        37752832   251658239   106952704   83  Linux
[root@192 ~]# df  -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda5       102G  1.1G  101G   2% /
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           3.9G   12M  3.9G   1% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda2        12G   33M   12G   1% /home
/dev/sda3       4.0G  377M  3.7G  10% /var
/dev/sda1       2.0G  127M  1.9G   7% /boot
tmpfs           797M     0  797M   0% /run/user/0

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  6YY0QMPUXEwu   2023年12月10日   31   0   0 linux网卡
  nIt0XG0acU8j   2023年12月11日   32   0   0 linuxhtop
  nIt0XG0acU8j   2023年12月09日   34   0   0 linuxsort
OBCxRew8HiW1