Configurate Ubuntu

2019-03-21 08:00 CST

2019-12-22 15:33 CST

Install Ubuntu

Virtual machine on mac

Install virtualbox

brew cask install virtualbox

Download Ubuntu from Tsinghua Image

  • 18.04 is LTS now

Guest Additions CD Image

Device -> Insert Guest Additions CD Image

After installation and restart, turn on Shared Clipboard and Drag and Drop

Virtual machine on disk by mac

Install unetbootin and download Ubuntu 16.04 iso > Note that directly install Ubuntu 18.04 may cause inbuild monitor fail to work

Install refind on mac (need crsutil disable)

Make a boot USB. Start from it with option held, and install on my Disk. Divide the disk by four parts

  • EFI:
  • Swap:
  • Ext4:/
  • EXt4:/home

After installation complete, open ubuntu on Disk and upgrade it to 18.04

To run Ubuntu on mac, at least three external devices are needed:

  • keyboard
  • mouse
  • network card (for certain network inbuild one fails)

apt

sudo apt update && sudo apt upgrade
sudo apt install build-essential man gcc-doc git vim
sudo apt install libreadline-dev libsdl2-dev qemu-system-x86 # For hw
sudo apt install libc6-dev-i386 # For c -m32
sudo apt install g++-multilib # For c++ -m32
sudo apt install cmake
sudo apt install zsh tldr tree tmux ctags wget net-tools curl
sudo apt install texlive-full, linux-tools-common, linux-tools-generic, linux-tools-`uname -r`

If apt upgrade fails, try remove the mentioned lock

sudo rm /var/lib/apt/lists/lock

change source

sudo gedit /etc/apt/sources.list

写入如下内容 (以下是 18.04的,版本不符请上官网)

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

git

git config --global user.name "zhengzangw"
git config --global user.email "zhengzangw@163.com"
git config --global core.editor vim
git config --global core.excludesfile ~/.gitignore

Tmux

cd
git clone https://github.com/gpakosz/.tmux.git
ln -s -f .tmux/.tmux.conf
cp .tmux/.tmux.conf.local .

Vim

Install with lua

git clone https://github.com/vim/vim
cd vim/src
make distclean
./configure --with-features=huge \
            --enable-rubyinterp \
            --enable-largefile \
            --disable-netbeans \
            --enable-pythoninterp \
            --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu/ \
            --enable-python3interp \
            --with-python3-config-dir=/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu/ \
            --enable-perlinterp \
            --enable-luainterp \
            --with-luajit \
            --enable-fail-if-missing \
            --with-lua-prefix=/usr/include/lua5.1 \
            --enable-cscope \
            --enable-multibyte \
            --enable-gui=gtk2\
            --prefix=/usr
make
sudo make install

spf13

sh <(curl https://j.mp/spf13-vim3 -L)
(update: curl https://j.mp/spf13-vim3 -L -o - | sh)

sudo apt install fonts-inconsolata

In ~/.vimrc.local

let g:indent_guides_enable_on_vim_startup = 0
set wrap
set tags=./tags;/

Uninstall

sudo mkdir /usr/include/lua5.1/include
sudo cp /usr/include/lua5.1/*.h /usr/include/lua5.1/include/
sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-gui-common
sudo rm -rf /usr/local/share/vim
sudo rm /usr/bin/vim

zsh

prezto

Install

zsh
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"

Add the following content to ~/.zshrc

setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
  ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done

Then change shell (not use sudo, otherwise root shell is changed instead of current one)

chsh -s `which zsh`

After that, if some warning appears, change ~/.zshrc to

source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"

plugin

The plugin in ~/.zpreztorc

zstyle ':prezto:load' pmodule \
  'environment' \
  'terminal' \
  'editor' \
  'history' \
  'directory' \
  'spectrum' \
  'utility' \
  'completion' \
  'git'\
  'history-substring-search'\
  'autosuggestions'\
  'prompt'

update

cd $ZPREZTODIR
git pull
git submodule update --init --recursive

fzf

git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install

Cross Compilation

sudo apt install linux-libc-dev-mips-cross libc6-mips-cross libc6-dev-mips-cross binutils-mips-linux-gnu gcc-mips-linux-gnu g++-mips-linux-gnu

Python

sudo apt -y install python-dev python3-dev
sudo apt install python2.7 python2.7-dev python3.5 python3.5-dev

pip

mkdir .pip
vim .pip/pip.conf

Add following content to .pip/pip.conf

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

or use pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

pip install --upgrade pip

virtualenv

pip install virtualenv virtualenvwrapper
echo "export WORKON_HOME=~/.virtualenvs" >> .bashrc
echo "source /usr/local/bin/virtualenvwrapper.sh" >> .bashrc
exit
source .bashrc
mkvirtualenv ml --python=python3.5

ssh

sudo EDITOR=vim visudo
/etc/ssh/sshd_config PasswordAuthentication yes
/etc/init.d/ssh restart
config
(debian)mkdir .ssh
scp \*.pub $SVR:~/.ssh/\*.pub
cat *.pub >> authorized_key

vscode

Sync setting by plugin 'Setting Sync'

  • token: ***
  • gist: ***

Also change following settings:

  • titlebarstyle
  • menubarvisibility

ss

sudo apt install shadowsocks-libev libsodium-dev

The second one is for rc4-md5

Setting at /etc/shadowsocks-libev/config.json, run with nohup sudo ss-local -c /etc/shadowsocks-libev/config.json &

Install Chrome and SwitchyOmega, select sock5 and 127.0.0.1:port.

Language Input

Use fcitx and reboot.

Software

  • Vscode
  • Chrome
  • tweaks
    • sudo apt install gnome-shell-extension-autohidetopbar