CentOS system basic environment construction and configuration

CentOS system basic environment construction and configuration

One, the main distribution of Linux

1.1 GNU and Linux operating systems

​ After the Unix system was invented, everyone used it very well, but then it began to charge and commercialize. Richard Stallman publicly initiated the GNU project on September 27, 1983, with the goal of creating a completely free operating system. GNU is a recursive acronym for "GNU's Not Unix". In 1985, Richard Stallman founded the Free Software Foundation (Free Software Foundation) to provide technical, legal and financial support for the GNU project. By 1990, the software developed by the GNU Project included the powerful text editor Emacs, the C language compiler GCC, and most of the libraries and tools of the UNIX system. The only important component that has not yet been completed is the kernel of the operating system. (Called HURD). Linus Torvalds wrote a UNIX-compatible Linux operating system kernel in 1991 and released it under the terms of the GPL. In 1992, Linux was combined with other GNU software to form a completely free operating system.

​ Simply put, Linux is the operating system kernel, GNU provides applications, and the Linux kernel and GNU applications together constitute the Linux operating system in the open source world.

1.2 Major Linux distributions

​ On the http://futurist.se/gldt/ website, you can view the different distributions of Linux and the relationship between them.

image-20201123165038444

image-20201123165131942

​ Among them, the Debian family has the largest ethnic group, among which the famous branch is the Ubuntu series; the Slackware family, the famous branch is the Suse series; the RedHat family, the famous branch is the CentOS and Fedora series. Since the kernel and application software of the Linux system are in compliance with the GPL agreement, each distributor can tailor the kernel to change the software, and then release it. This has resulted in more and more Linux systems.

Two, install and configure Centos7.8 operating system

2.1 Download CentOS7.8 image

Visit https://developer.aliyun.com/mirror/, click OS mirror, and download the latest CentOS7 mirror.

image-20201123171146335

image-20201123171308143

2.2 Install the system in a virtual machine

image-20201123171424748

image-20201123171450531

image-20201123171511252

image-20201123171535520

image-20201123171744779

image-20201123171834602

image-20201123171941315

image-20201123172029465

image-20201123172203061

image-20201123172228924

image-20201123172245447

image-20201123172303637

image-20201123172331153

image-20201123172351599

image-20201123172409640

image-20201123172451730

image-20201123172508744

image-20201123172534905

image-20201123172614599

image-20201123172749364

image-20201123172922022

image-20201123173014061

image-20201123173044431

image-20201123173130996

image-20201123173304142

image-20201123173546993

image-20201123173610352

image-20201123173632617

image-20201123173757113

image-20201123173731309

image-20201123173847306

image-20201123173829100

image-20201123173906241

image-20201123173948881

image-20201123174019195

image-20201123174109658

image-20201123181204446

2.3 Basic configuration

After the installation is complete, log in to the system to check the system version and network conditions:

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)

ens33网卡没有获得ip,网络不通。

image-20201123190446915

2.3.1 Passive network

# cd /etc/sysconfig/network-scripts/
# vi ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=cff76671-d81a-499a-b66d-02b17715448e
DEVICE=ens33
ONBOOT=no   #更改成yes

# systemctl restart network

[root@localhost network-scripts]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:e5:86:86 brd ff:ff:ff:ff:ff:ff
    inet 172.20.200.131/24 brd 172.20.200.255 scope global noprefixroute dynamic ens33
       valid_lft 1549sec preferred_lft 1549sec
    inet6 fe80::fc7:1b7a:52b7:3359/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
[root@localhost network-scripts]#

2.3.2 Configure local yum source to install basic software

Because it is a Minimal Install, some software has not been installed, first set up the local yum source to facilitate the installation of basic tools.

image-20201123191847663

[root@localhost network-scripts]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  120G  0 disk
├─sda1   8:1    0    1G  0 part /boot
├─sda2   8:2    0    2G  0 part [SWAP]
└─sda3   8:3    0  117G  0 part /
sr0     11:0    1  9.6G  0 rom
[root@localhost network-scripts]# mount /dev/sr0 /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@localhost network-scripts]#
# cd /etc/yum.repos.d/
# vi CentOS-Base.repo
[base]
name=CentOS
baseurl=file:///mnt
gpgcheck=0

# yum clean all
# yum makecache

2.3.3 When implementing history, you can see the time to execute the command

# vim /etc/profile
HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
    export HISTCONTROL=ignoreboth
else
    export HISTCONTROL=ignoredups
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

export HISTTIMEFORMAT="%F %T `whoami` "  #增加此行

# source /etc/profile
# history
    1  2020-11-24 03:01:44 root ifconfig
    2  2020-11-24 03:01:44 root ip add l
    3  2020-11-24 03:01:44 root ifconfig
    4  2020-11-24 03:01:44 root cat /etc/os-release

Three, Linux command format

Take the lscommand as an example to explain the Linux command format:

# man ls
SYNOPSIS
       ls [OPTION]... [FILE]...

[OPTION] is a command option, different command options make the command show different functions. Command options have three modes: long options: GNU style options, such as --all; short options: UNIX style options, such as -a; BSD style options: a letter, such as options a, x, u, etc. of the ps command.

[FILE] is the command parameter, which is the operation object of the command.

In the man document, <> is a mandatory option, [] is an optional option, and the content of [] is optional.

Guess you like

Origin blog.51cto.com/12302225/2553720