Ubuntu 18.04 重装后的自用软件及相关配置

        自从装了虚拟机,感觉生活一下子提升了好几个档次。无奈电脑配置太渣,虚拟机经常就崩掉了。虚拟机嘛,不值钱,崩掉了再装就行了(也可以保存快照,但是文件太大又不好传输。有钱人花钱省时间,我这种穷鬼花时间省钱呗)。有些工具在重装时可能会忘掉,用的时候发现没有还需要重新安装就很麻烦,所以写文,每次重装直接复制走流程。

        Ubuntu  18.04,前面的系统安装直接跟着引导走。

1、基础配置

基础配件安装更新

sudo apt install gcc
sudo apt install build-essential
sudo apt update
sudo apt upgrade

vim相关

sudo apt install vim
vim .vimrc

vim基础配置

set smartindent     "设置智能缩进
set tabstop=4       "设置 tab 符长度为 4 个空格
set shiftwidth=4    "设置换行自动缩进长度为4个空格
set nu              "设置显示行号
colorscheme desert  "设置配色方案
set history=10000   "记录历史的行数
syntax on           "语法高亮显示
set whichwrap+=h,l,<,>  "允许 backspace 和光标键跨越行边界

"括号的自动补全
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {<CR>}<ESC>O
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap ] <c-r>=ClosePair(']')<CR>
function! ClosePair(char)
    if getline('.')[col('.') - 1] == a:char
        return "\<Right>"
    else
        return a:char
    endif
endfunction
filetype plugin indent on

if has("autocmd") "打开后自动跳到上次的光标位置
    au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif

git

sudo apt install git

2、oh my zsh

这部分建议放在anaconda之后,安装完anaconda之后将路径写入.bashrc,然后再安装zsh
在安装完zsh后将.bashrc中关于anaconda的部分复制入.zshrc
参考
过程:

sudo apt update
sudo apt install zsh

或者自动安装 oh my zsh

wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

查看版本信息(多余)

zsh --version
设置zsh为默认shell

找出zsh shell的路径

whereis zsh

一般路径为 /usr/bin/zsh
找到目录之后进行设置

sudo usermod -s /usr/bin/zsh $(whoami)

之后输入 reboot重启,重启之后打开终端,应该会有个模式选择,选2
安装「Powerline」和「Powerline 字体」

sudo apt install powerline fonts-powerline

Powerlevel9k 是个人比较喜欢的用于 ZSH 美化的一个非常酷的主题,安装并启用

sudo apt install zsh-theme-powerlevel9k
echo "source /usr/share/powerlevel9k/powerlevel9k.zsh-theme" >> ~/.zshrc

安装语法高亮显示插件并启用

sudo apt install zsh-syntax-highlighting
echo "source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ~/.zshrc

基本完成。更多可上网查询

3、一些软件

Python 3、pip3

安装python3及常用库(受限于网络等情况,可能出现pip3不能安装的情况,可加上sudo试试,或上网百度/Google其他方法,比如加源):

sudo apt install python3 python3-pip 
pip3 install virtualenv numpy tensorflow

如有特殊需要安装python2:

sudo apt  install python-minimal
sudo apt  install python-minimal python-tk

更新pip3:

pip3 install --upgrade pip
pip3 -V

pip3在20版本之后好像会报warning,用的时候看提示就行

如果查询版本号失败,则修改/usr/bin/文件夹下的pip3文件:

sudo vim /usr/bin/pip3

找到:

from pip import main

if __name__ == '__main__':

sys.exit(main())

修改为:

from pip import __main__

if __name__ == '__main__':

sys.exit(__main__._main())

有问题再上网查。

Anaconda3

(别的参考)
点击下载: Anaconda3
下载完成后进入下载文件夹bash对应的文件然后一路回车带yes

 bash Anaconda3-4.2.0-Linux-x86_64.sh

这里的bash后面的参数应该是下载的文件。随后添加环境变量

echo 'export PATH="~/anaconda3/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
//之前已经安装过zsh的话选择上面的,没有的话选择下面的
echo 'export PATH="~/anaconda3/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
//安装完zsh后将bashrc里的Anaconda3相关内容复制到zshrc保存
conda activate
conda update --all
//激活环境并更新所有的包

更新gdb到8.3

(安装过程中如果提示缺少组件错误请参考这篇文档)
下载过程中可能会出现wget的段错误,只要有下载好的压缩包就把这个问题忽略掉吧...

wget http://ftp.gnu.org/gnu/gdb/gdb-8.3.tar.xz
tar -xf gdb-8.3.tar.xz   
cd gdb-8.3/   
./configure
make
sudo cp gdb/gdb /usr/bin

4、美化

美化过程参考文章,包括新立得包管理器及UI界面的基本美化过程等。前面的软件都装完了之后可以参考这篇文章进行美化。

5、换源

(一般不做,直接用系统的默认配置或自动换源就很方便)。手动的话可选择换阿里源或清华源,给出阿里源的方法,个人要求不高,原来的也能用,也就是慢一点?滑稽
第一步:备份原来的源文件

cd /etc/apt/  
sudo cp sources.list sources.list.bak 

第二步:替换源

sudo gedit sources.list

打开文件,替换成阿里源文件即可。阿里源文件如下

   deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse  
    deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse  
    deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse  
    deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse  
    ##测试版源  
    deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse  
    # 源码  
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse  
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse  
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse  
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse  
    ##测试版源  
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse  
    # Canonical 合作伙伴和附加  
    deb http://archive.canonical.com/ubuntu/ xenial partner  
    deb http://extras.ubuntu.com/ubuntu/ xenial main  

替换并保存
第三步:更新源和软件

sudo apt-get update 
sudo apt-get upgrade
posted @ 2020-05-12 11:07  不用取昵称的一条咸鱼  阅读(148)  评论(0)    收藏  举报