ubuntu开发环境

系统下载安装

1、安装VirtualBox或者VMWare
2、前往http://releases.ubuntu.com/或者镜像网站下载对应版本的iso文件
3、安装ubuntu

VirtualBox设置共享文件夹

1、启动ubuntu,在VirtualBox设备菜单中安装增强功能,运行

# server版
sudo apt install build-essential
sudo mkdir /mnt/cdrom
sudo mount /dev/cdrom /mnt/cdrom
cd /mnt/cdrom
sudo ./VBoxLinuxAdditions.run

2、VirtualBox添加一个固定分配的共享文件夹share,不要选择自动挂载
3、创建挂载目录sudo mkdir /mnt/share
4、在/etc/fstab中添加一项share /mnt/share vboxsf defaults 0 0
5、重启后,df -h看一下share是不是已经挂载到/mnt/share了

常用命令

sysinfo

uname -a

cat /proc/version
cat /proc/cpuinfo
cat /proc/meminfo

cat /etc/environment
cat /etc/passwd
cat /etc/shells

env
fdisk -l
df -h
free -h
ps aux
pstree
top
ifconfig
netstat -atnp
vmstat

account

passwd root

groupadd hw
useradd hw -g hw -G sudo -m -s /bin/bash
passwd hw
su hw

apt

sudo cp /etc/apt/sources.list /etc/apt/souces.list.bak
vi /etc/apt/souces.list

# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

sudo apt update

etc

/etc/hostname
/etc/hosts
/etc/resolv.conf
/etc/profile
/etc/bash.bashrc

bash

# ~/.profile

if [ -n "$BASH_VERSION" ]; then
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

PATH="$HOME/bin:$PATH"
# ~/.bashrc

TERM=xterm-256color
case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi
# ~/.bash_aliases

# gc
trash()
{
    DATE=$(date +%Y%m%d)
    DIR=~/trash/$DATE
    if [ ! -e $DIR ]; then
        mkdir -p $DIR
    fi
    mv $@ $DIR
}
alias gc='trash'

# tmux
alias tmuxl='tmux list-sessions'
alias tmuxk='tmux kill-server'
alias tmux0='tmux attach-session -t 0'
alias tmux1='tmux attach-session -t 1'
alias tmux2='tmux attach-session -t 2'
alias tmux3='tmux attach-session -t 3'

devenv

sudo apt install build-essential autoconf automake libtool
sudo apt install llvm clang clang-format
sudo apt install python python3 python-pip python3-pip
sudo apt install tmux

sudo apt install git
git config --global user.name "XXX"
git config --global user.email "XXX"
git config --global core.editor editor

editor

sudo apt install lua
sudo apt install libtinfo-dev libncurses5-dev ctags cscope
git clone https://gitee.com/mirrors/vim.git
./configure --enable-cscope --enable-terminal --enable-multibyte --enable-pythoninterp=yes --enable-python3interp=yes --enable-luainterp=yes --with-python-command=python2 --with-python3-command=python3
make && sudo make install
sudo ln -sf /usr/local/bin/vim /etc/alternatives/editor

git clone https://gitee.com/ithewei/vimrc.git ~/.vim
cd ~/.vim
./install.sh
vim
:PluginInstall

sudo add-apt-repository ppa:adrozdoff/emacs
sudo apt install emacs25
git clone https://github.com/purcell/emacs.d.git ~/.emacs.d # 拷贝大牛的配置

中文输入法

sudo apt install ibus-pinyin
ibus-setup添加中文拼音输入
系统设置中添加输入法,并设置切换键位为Ctrl-Space
ibus-daemon -drx

ssh

sudo apt install openssh-server openssh-client

LAMP/LNMP

sudo add-apt-repository ppa:ondrej/php
sudo apt install apache2 nginx mysql-server mysql-client php7.0

x86
64位系统上运行32位二进制程序,需额外安装32位运行环境

sudo apt install libc6-i386 lib32stdc++6 lib32z1 lib32tinfo5 lib32ncurses5

mingw

sudo apt install mingw-w64

# mingw Thread model: posix | win32
sudo update-alternatives --config i686-w64-mingw32-gcc
sudo update-alternatives --config i686-w64-mingw32-g++
sudo update-alternatives --config x86_64-w64-mingw32-gcc
sudo update-alternatives --config x86_64-w64-mingw32-g++

golang

wget https://dl.google.com/go/go1.13.5.linux-amd64.tar.gz
sudo tar -xzf go1.13.5.linux-amd64.tar.gz -C /opt
cd /opt
sudo mv go go1.13.5

export GOROOT=/opt/go1.13.5
export GOPATH=~/golang
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

zlib

git clone https://gitee.com/mirrors/zlib
cd zlib
./configure && make && sudo make install

openssl

git clone https://gitee.com/mirrors/openssl
cd openssl
git checkout OpenSSL_1_1_1-stable
./config && make && sudo make install

curl

git clone https://gitee.com/mirrors/curl
cd curl
./buildconf && ./configure && make && sudo make install

cmake

git clone https://gitee.com/mirrors/CMake
cd CMake
./bootstrap && make && sudo make install

nginx

wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
tar -xzf pcre-8.43.tar.gz
cd pcre-8.43
./configure && make && sudo make install

git clone https://gitee.com/mirrors/nginx
git checkout release-1.16.0
auto/configure --with-http_ssl_module --with-http_v2_module
make && sudo make install

如需静态链接pcre、ssl、z库,修改objs/Makefile文件中链接库方式

Wl,-Bstatic -lpcre -lssl -lcrypto -lz \
Wl,-Bdynamic -ldl -lpthread -lcrypt \
Wl,-E

redis

git clone https://gitee.com/mirrors/redis.git
cd redis
git checkout 5.0.0
make && sudo make install
sudo cp redis.conf /etc/
cd deps/hiredis
sudo make install

leveldb

git clone https://gitee.com/mirrors/leveldb.git
cd leveldb
git checkout 1.22
mkdir -p build/linux-x86_64
cd build/linux-x86_64
cmake ../..
make
ithewei CSDN认证博客专家 c/c++ Qt libhv
编程之路,其路漫漫,吾将上下而求索
https://github.com/ithewei
https://hewei.blog.csdn.net
©️2020 CSDN 皮肤主题: 代码科技 设计师:Amelia_0503 返回首页