Setting up a new server

October 30, 2022

These are things I always forget but need to be really comfortable working in a remote server. I try to be distro-agnostic when I can.

  1. Set up history options in .bashrc:
    HISTCONTROL=ignoreboth:erasedups
    HISTSIZE=100000
    HISTFILESIZE=100000
    shopt -s histappend
    shopt -s checkwinsize
    PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
    
    case "$TERM" in
        xterm-color|*-256color) color_prompt=yes;;
    esac
    
    alias ls='ls --color=auto'
    alias ll='ls -alF'
    alias la='ls -A'
    alias l='ls -CF'
    
    alias ag=rg
    
  2. Install cargo and all the Rust tools I love:
    curl https://sh.rustup.rs -sSf | sh
    cargo install ripgrep fd-find procs du-dust
    
  3. Install build-essential or the equivalent:
    sudo apt-get install build-essential git # for Ubuntu
    
    sudo yum groupinstall "Development Tools" # for AWS Linux
    sudo yum install git
    
  4. Setup pyenv:
    git clone https://github.com/pyenv/pyenv.git ~/.pyenv
    cd ~/.pyenv && src/configure && make -C src
    echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
    echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
    echo 'eval "$(pyenv init -)"' >> ~/.bashrc
    exec "$SHELL"
    
    # install build requirements
    sudo apt update; sudo apt install make build-essential libssl-dev zlib1g-dev \
    libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
    libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
    
    # install an example python version
    pyenv install 3.10.6
    
    git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
    echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
    exec "$SHELL"
    
    pyenv virtualenv 3.10.6 prod