
目录

小技巧
- 查看软件安装相关的文件
rpm -qal [软件名]
1. 包管理器
配置yum源
- 备份默认的yum源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
- 替换yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

- 添加epel源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
- 生成cache缓存
yum clean all && yum makecache
- 更新软件源
yum update -y
提示:
- 下载时由于已选择了阿里云仓库的CentOS镜像,所以可以不用设置yum源,即只需添加epel源
参阅:
配置IUS社区源
➢ IUS 社区是 CentOS 社区批准的第三方 RPM 源,为企业级 Linux (RHEL 和 CentOS) 5、 6 和 7 版本提供最新上游版本的 PHP、 Python、 MySQL 等软件包
➢ IUS 社区源依赖于 EPEL 源,故我们需要先安装 EPEL 源,然后再安装 IUS 社区源
第一种方式:官网源不推荐
- 先安装epel源
yum install epel-release
- 下载 IUS 社区源安装脚本
curl 'https://setup.ius.io/' -o setup-ius.sh
- 安装社区源
sh setup-ius.sh
第二种方式:国内源推荐
- 下载软件源配置文件
IUS国内源 | 下载命令(下载其中一个即可) |
---|---|
阿里 | wget https://mirrors.aliyun.com/ius/ius-7.repo -P /etc/yum.repos.d/ |
清华 | wget https://mirrors.tuna.tsinghua.edu.cn/ius/ius-7.repo -P /etc/yum.repos.d/ |
同济 | wget https://mirrors.tongji.edu.cn/ius/ius-7.repo -P /etc/yum.repos.d/ |
- 生成cache缓存
yum clean all && yum makecache
- 更新软件源
yum update -y
- 使用社区源安装软件
yum install --enablerepo=ius [软件名] -y
eg:
- 安装python3
搜索python3最新版yum search --disablerepo='*' --enablerepo=ius python3

==>可以看出IUS源中python3最新版为python36u
查看python36u的信息yum info --disablerepo='*' --enablerepo=ius python36u
安装python36uyum install --disablerepo='*' --enablerepo=ius python36u -y
参阅:
配置SCL源
➢ SCL 源目前由 CentOS SIG 维护,除了重新编译构建 Red Hat 的 Software Collections 外,还额外提供一些它们自己的软件包。
➢ 该源中包含不少程序的更高版本,可以在不改变原有旧版本程序包的情况下安装,使用时需要通过 scl 命令调用。
- 安装SCL源
yum install centos-release-scl -y
- 生成cache缓存
yum clean all && yum makecache
- 更新软件源
yum update -y
eg:
- 安装python3
搜索python3最新版yum search rh-python3

==>可以看出SCL源中python3最新版为python36
查看python36的信息yum info rh-python36
安装python36yum install rh-python36 -y
dnf包管理器
- 安装依赖
yum install epel-release -y
- 安装dnf
yum install dnf -y
常用命令 | 作用 |
---|---|
dnf --version |
查看dnf版本 |
repolist | |
dnf repolist |
显示系统中可用的 DNF 软件库 |
dnf repolist all |
显示系统中可用和不可用的所有的 DNF 软件库 |
list | |
dnf list |
列出用户系统上的所有来自软件库的可用软件包和所有已经安装在系统上的软件包 |
dnf list installed |
列出所有安装了的 RPM 包 |
dnf list available |
列出来自所有可用软件库的可供安装的软件包 |
其他 | |
dnf update |
更新软件库中的软件源和检查软件包是否可升级 |
dnf upgrade |
更新软件库中的 RPM 包 |
dnf install [rpm包名] |
安装软件库中的 RPM 包 |
dnf install git -y |
|
dnf search [rpm包名] |
搜索软件库中的 RPM 包 |
dnf search nano |
|
dnf provides [文件名] |
查找某一文件的提供者 |
dnf provides /bin/bash |
|
dnf info [rpm包名] |
在安装某一个软件包之前查看它的详细信息 |
dnf info nano |
参阅:
2. 安装oh-my-zsh
- 安装git、fonts-powerline字体和zsh
yum install git fonts-powerline zsh -y
- 安装oh-my-zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
- 更改主题
cd ~/.oh-my-zsh/themes
wget https://raw.githubusercontent.com/zakaziko99/agnosterzak-ohmyzsh-theme/master/agnosterzak.zsh-theme
vim ~/.zshrc
agnosterzak

source ~/.zshrc

参阅:
3. 更改语言为英文
echo "LANG=en_US.UTF-8" >/etc/locale.conf
source /etc/locale.conf

4. 修改问候语
- 安装figlet
yum install figlet -y
- 生成想要的字符并复制
figlet Ricsy
- 复制字符到motd里
vim /etc/motd

5. 配置Vim
- 增加最新版vim源
curl -L https://copr.fedorainfracloud.org/coprs/lantw44/vim-latest/repo/epel-7/lantw44-vim-latest-epel-7.repo -o /etc/yum.repos.d/vim-latest.repo
- 更新vim
yum update -y
- 验证vim
vim

-
在vim中输入命令
:echo $VIMRUNTIME
来查看Vim的运行目录 -
创建用户的.vim文件夹
mkdir ~/.vim
-
创建用户的.vimrc文件
touch ~/.vimrc
-
创建vim的主题文件夹
mkdir -p ~/.vim/colors
-
安装vim_runtime配置方案
git clone --depth=1 https://github.com/amix/vimrc.git ~/.vim_runtime
sh ~/.vim_runtime/install_awesome_vimrc.sh
vim ~/.vimrc
提示:
- 命令模式下,输入
:set paste
回车再复制
" F11快捷键激活/取消paste模式set pastetoggle=<F11>"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 1. 基本配置 """ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""set shortmess=atI " 启动的时候不显示那个援助乌干达儿童的提示set autoindent " Indent according to previous line.set expandtab " Use spaces instead of tabs.set softtabstop =4 " Tab key indents by 4 spaces.set shiftwidth =4 " >> indents by 4 spaces.set shiftround " >> indents to next multiple of 'shiftwidth'.set smartindent " 为C程序提供自动缩进set noeb " 去掉输入错误的提示声音set confirm " 在处理未保存或只读文件的时候,弹出确认set iskeyword+=_,$,@,%,#,- " 带有如下符号的单词不要被换行分割set smarttab " 在行和段开始处使用制表符set completeopt=preview,menu " 代码补全filetype plugin indent on " 打开文件类型检测, 加了这句才可以用智能补全set completeopt=longest,menu" 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)set mouse=a " 通过使用: commands命令,告诉我们文件的哪一行被改变过set report=0set hidden " Switch between buffers without having to save first.set display =lastline " Show as much as possible of the last line.set ttyfast " Faster redrawing.set lazyredraw " Only redraw when necessary.set splitbelow " Open new windows below the current window.set splitright " Open new windows right of the current window.set cursorline " Find the current line quickly.set wrapscan " Searches wrap around end-of-file.set report =0 " Always report changed lines.set synmaxcol =120 " Only highlight the first 200 columns.set list " Show non-printable characters.if has('multi_byte') && &encoding ==# 'utf-8' let &listchars = 'tab: ,extends:❯,precedes:❮,nbsp:±'else let &listchars = 'tab:> ,extends:>,precedes:<,nbsp:.'endif" Put all temporary files under the same directory.let s:vim_backup = expand("$HOME/.vim/files/backup/")if !isdirectory(s:vim_backup) silent! call mkdir(s:vim_backup, 'p')endiflet s:vim_swap = expand("$HOME/.vim/files/swap/")if !isdirectory(s:vim_swap) silent! call mkdir(s:vim_swap, 'p')endiflet s:vim_undo = expand("$HOME/.vim/files/undo/")if !isdirectory(s:vim_undo) silent! call mkdir(s:vim_undo, 'p')endiflet s:vim_info = expand("$HOME/.vim/files/info/")if !isdirectory(s:vim_info) silent! call mkdir(s:vim_info, 'p')endifset backupset backupdir =$HOME/.vim/files/backup/set backupext =-vimbackupset backupskip =set directory =$HOME/.vim/files/swap/set updatecount =100set undofileset undodir =$HOME/.vim/files/undo/set viminfo ='100,n$HOME/.vim/files/info/viminfo" 显示行号set number" 取消换行set nowrap " 为方便复制,用<F6>开启/关闭行号显示nnoremap <F6> :set nonumber!<CR>:set foldcolumn=0<CR>"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 2. C/C++运行与调试 """ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""C、C++ 的运行map <F5> :call CompileRunGcc()<CR>func! CompileRunGcc() exec "w" if &filetype == 'c' exec "!gcc % -o %<" exec "! ./%<" elseif &filetype == 'cpp' exec "!g++ % -o %<" exec "! ./%<" elseif &filetype == 'java' exec "!javac %" exec "!java %<" elseif &filetype == 'sh' :!./% endifendfunc" C、C++的调试map <F8> :call Rungdb()<CR>func! Rungdb() exec "w" exec "!g++ % -g -o %<" exec "!gdb ./%<" endfunc"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 3. 新文件标题 """ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 新建.c,.h,.sh,.java文件,自动插入文件头 autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()" "" 定义函数SetTitle,自动插入文件头 func SetTitle() "如果文件类型为.sh文件 if &filetype == 'sh' call setline(1,"\#########################################################################") call append(line("."), "\# @File Name: ".expand("%")) call append(line(".")+1, "\# @Author: Ricsy") call append(line(".")+2, "\# @Email: Ricsy45@163.com") call append(line(".")+3, "\# @Created Time: ".strftime("%c")) call append(line(".")+4, "\#########################################################################") call append(line(".")+5, "\#!/bin/bash") call append(line(".")+6, "") else call setline(1, "/*************************************************************************") call append(line("."), " > @File Name: ".expand("%")) call append(line(".")+1, " > @Author: Ricsy") call append(line(".")+2, " > @Email: Ricsy45@163.com") call append(line(".")+3, " > @Created Time: ".strftime("%c")) call append(line(".")+4, " ************************************************************************/") call append(line(".")+5, "") endif if &filetype == 'cpp' call append(line(".")+6, "#include <iostream>") call append(line(".")+7, "using namespace std;") call append(line(".")+8, "") endif if &filetype == 'c' call append(line(".")+6, "#include <stdio.h>") call append(line(".")+7, "#include <stdlib.h>") call append(line(".")+8, "") endif " if &filetype == 'java' " call append(line(".")+6,"public class ".expand("%")) " call append(line(".")+7,"") " endif "新建文件后,自动定位到文件末尾 autocmd BufNewFile * normal G endfunc set foldenable " 开始折叠 set foldmethod=syntax " 设置语法折叠 set foldcolumn=0 " 设置折叠区域的宽度 setlocal foldlevel=1 " 设置折叠层数为" Python 文件的一般设置,比如不要 tab 等 autocmd FileType python set tabstop=4 shiftwidth=4 expandtab autocmd FileType python map <F12> :!python %<CR>" 打开javascript折叠 let b:javascript_fold=1 " 打开javascript对dom、html和css的支持 let javascript_enable_domhtmlcss=1if filereadable("/etc/vim/vimrc.local") source /etc/vim/vimrc.localendif
- 验证vim
vim

6. 常用软件安装
- 安装常用小工具
yum install ag axel figlet glances -y
项目 | 描述 |
---|---|
ag |
比grep、ack更快的递归搜索文件内容(silversearcher-ag) |
axel |
自带——多线程下载工具,下载文件时可以替代curl、wget;各种网盘不限速下载 谁用谁知道 |
figlet |
将输入字符转换成艺术字体 |
glances |
动态提供更美观、更方便的进程监控工具 |
screen |
提供不间断会话服务 |
- 安装基础设施服务器和开发工具
yum grouplist
yum groupinstall "Basic Web Server" -y
yum groupinstall "Development Tools" -y

- 获取rpm包
下载插件yum install yum-plugin-downloadonly
用法格式:yum install [包名] --downloadonly --downloaddir=[文件路径]
eg(axel):yum install axel --downloadonly --downloaddir=/root
参阅:
- python3
参阅:
- pip
安装pipyum install python-pip
配置国内源mkdir ~/.pip -p
vim ~/.pip/pip.conf
[global]index-url = http://mirrors.aliyun.com/pypi/simple[install]trusted-host = mirrors.aliyun.com
国内源 | 地址 |
---|---|
阿里云 | http://mirrors.aliyun.com/pypi/simple/ |
豆瓣 | http://pypi.douban.com/simple/ |
清华大学 | https://pypi.tuna.tsinghua.edu.cn/simple/ |
中国科学技术大学 | http://pypi.mirrors.ustc.edu.cn/simple/ |
华中科技大学 | http://pypi.hustunique.com/ |
参阅:
- pip管理
命令 | 说明 |
---|---|
pip install [库名] |
安装某个python库 |
pip list [库名] |
查看python都安装了哪些库 |
pip uninstall [库名] |
卸载某个python库 |
pip show [库名] |
显示某个库的详细信息 |
参阅:
更新中......
原著是一个有趣的人,若有侵权,请通知删除
还没有人抢沙发呢~