CentOS 初始化配置事项
1.配置命令提示符
[root@Centos7.9 ~]
[root@Centos7.9 profile.d]
\[\e[1;32m\][\u@\H \W]\$\[\e[0m\]
[root@Centos7.9 ~]
[root@Centos7.9 profile.d]
PS1='\[\e[1;32m\][\u@\H \W]\$\[\e[0m\]'
export HISTTIMEFORMAT='%F %T '
exit
2.定制vim的工作特性
全局:/etc/vimrc
个人:~/.vimrc
[root@Centos7.9 profile.d]
set ignorecase
set ts=4
set expandtab
autocmd BufNewFile *.sh exec ":call SetTitle()"
func SetTitle()
if expand("%:e") == 'sh'
call setline(1,"#!/bin/bash")
call setline(2,"#")
call setline(3,"#*******************************************************")
call setline(4,"#Author: xingyuyu")
call setline(5,"#Date: ".strftime("%Y-%m-%d"))
call setline(6,"#Filename: ".expand("%"))
call setline(7,"#Copyright (C): ".strftime("%Y")." All rights reserved")
call setline(8,"#********************************************************")
call setline(9,"")
endif
endfunc
autocmd BufNewFile * normal G
3.配置命令的子命令补全
[root@Centos7.9 profile.d]
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 bash-completion.noarch.1.2.1-8.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
=================================================================================================================================================================================================================
Package 架构 版本 源 大小
=================================================================================================================================================================================================================
正在安装:
bash-completion noarch 1:2.1-8.el7 base 87 k
事务概要
=================================================================================================================================================================================================================
安装 1 软件包
总下载量:87 k
安装大小:263 k
Downloading packages:
bash-completion-2.1-8.el7.noarch.rpm | 87 kB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : 1:bash-completion-2.1-8.el7.noarch 1/1
验证中 : 1:bash-completion-2.1-8.el7.noarch 1/1
已安装:
bash-completion.noarch 1:2.1-8.el7
完毕!
[root@Centos7.9 profile.d]
[root@Centos7.9 profile.d]
[root@Ubuntu ~]
4.创建登录提示文件
[root@Centos7.9 ~]
生成ASCII艺术字集:https://www.bootschool.net/ascii-art
例如:将下面拷贝到文件中,或者将文件下载下来直接替换
// _ooOoo_ //
// o8888888o //
// 88" . "88 //
// (| ^_^ |) //
// O\ = /O //
// ____/`---'\____ //
// .' \\| |// `. //
// / \\||| : |||// \ //
// / _||||| -:- |||||- \ //
// | | \\\ - /// | | //
// | \_| ''\---/'' | | //
// \ .-\__ `-` ___/-. / //
// ___`. .' /--.--\ `. . ___ //
// ."" '< `.___\_<|>_/___.' >'"". //
// | | : `- \`.;`\ _ /`;.`/ - ` : | | //
// \ \ `-. \_ __\ /__ _/ .-` / / //
// ========`-.____`-.___\_____/___.-`____.-'======== //
// `=---=' //
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
// 佛祖保佑 永不宕机 永无BUG //
5.设置alias
[root@Centos7.9 network-scripts]
alias vi='vim'
alias scandisk='echo '\''- - -'\'' > /sys/class/scsi_host/host0/scan;echo '\''- - -'\'' > /sys/class/scsi_host/host1/scan;echo '\''- - -'\'' > /sys/class/scsi_host/host2/scan'
alias nm='systemctl restart NetworkManager'
alias yy='yum -y install'
alias yr='yum remove'
alias lh='ls -lh --color=auto'
alias cdnet='cd /etc/sysconfig/network-scripts/'
alias cdrepo='cd /etc/yum.repos.d/'
alias viens160='vim /etc/sysconfig/network-scripts/ifcfg-ens160'
alias epel='sed -ri /enabled/s/enabled=0/enabled=1//etc/yum.repos.d/base.repo'
alias disepel='sed -ri /enabled/s/enabled=1/enabled=0//etc/yum.repos.d/base.repo'
alias rm='rm -i'
alias cdnet='cd /etc/sysconfig/network-scripts/'
alias editnet='vim /etc/sysconfig/network-scripts/ifcfg-eth0'
[root@Centos7.9 network-scripts]
[root@Centos7.9 network-scripts]
alias cdnet='cd /etc/sysconfig/network-scripts/'
alias cdrepo='cd /etc/yum.repos.d/'
alias cp='cp -i'
alias disepel='sed -ri /enabled/s/enabled=1/enabled=0//etc/yum.repos.d/base.repo'
alias editnet='vim /etc/sysconfig/network-scripts/ifcfg-eth0'
alias egrep='egrep --color=auto'
alias epel='sed -ri /enabled/s/enabled=0/enabled=1//etc/yum.repos.d/base.repo'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias lh='ls -lh --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias nm='systemctl restart NetworkManager'
alias rm='rm -i'
alias scandisk='echo '\''- - -'\'' > /sys/class/scsi_host/host0/scan;echo '\''- - -'\'' > /sys/class/scsi_host/host1/scan;echo '\''- - -'\'' > /sys/class/scsi_host/host2/scan'
alias vi='vim'
alias viens160='vim /etc/sysconfig/network-scripts/ifcfg-ens160'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
alias yr='yum remove'
alias yy='yum -y install'
6.修改网卡名变成传统的网卡(eth0)
[root@Centos7.9 ~]
[root@Centos7.9 ~]
[root@Centos7.9 ~]
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet net.ifnames=0"
GRUB_DISABLE_RECOVERY="true"
[root@Centos7.9 ~]
[root@Centos7.9 ~]
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-1160.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-9b4d5004256f4475a92c1e73d79fea17
Found initrd image: /boot/initramfs-0-rescue-9b4d5004256f4475a92c1e73d79fea17.img
done
[root@Centos7.9 ~]
[root@Centos7.9 ~]
[root@CentOS8 ~]
lrwxrwxrwx. 1 root root 22 11月 8 2021 /etc/grub2.cfg -> ../boot/grub2/grub.cfg
[root@Ubuntu ~]
[root@Centos7.9 ~]
[root@Centos7.9 ~]
[root@Centos7.9 network-scripts]
[root@Centos7.9 network-scripts]
[root@Centos7.9 network-scripts]
DEVICE=eth0
NAME=eth0
BOOTPROTO=static
IPADDR=10.0.0.108
NETMASK=255.255.255.0
GATEWAY=10.0.0.2
DNS1=10.0.0.2
[root@Centos7.9 network-scripts]
或者
[root@Centos7.9 network-scripts]
[root@Centos7.9 network-scripts]
7.修改当前系统的语言环境
export LANG=en_US.UTF-8
sudo vi /etc/sysconfig/i18n
LANG="zh_CN.UTF-8"
LANG="en_US.UTF-8"
export LANG=en_US.UTF-8
sudo vi /etc/locale.conf
LANG="zh_CN.UTF-8"
LANG="en_US.UTF-8"