Skip to content

Instantly share code, notes, and snippets.

@atiq1589
Last active December 17, 2023 22:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atiq1589/ad65cf78986372cf90b9bf8460e8fea9 to your computer and use it in GitHub Desktop.
Save atiq1589/ad65cf78986372cf90b9bf8460e8fea9 to your computer and use it in GitHub Desktop.
Ubuntu setup

Help Setup ubuntu

TOC


Install Git

sudo apt-get -y install git

Setup Git

  1. Name and Email
git config --global user.name "Md. Atiqul Islam"
git config --global user.email "atiqul.islam1589@gmail.com"
  1. Shortcut
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git config --global credential.https://github.com.username atiq1589

Setup SSH

SOURCE

  1. Generate ssh key

    • go to ~/.ssh
    cd ~/.ssh

    If you do not have .ssh folder create it

    mkdir ~/.ssh && cd $\_
    + run below command and follow the steps
    ssh-keygen -t rsa -b 4096 -C "atiqul.islam1589@gmail.com"
    
  2. turn on ssh-agent

    eval "$(ssh-agent -s)" 
    
  3. Add your SSH key to the ssh-agent

    ssh-add ~/.ssh/your_file_name
    
  4. Copy .pub content (xclip is not working by the time i write this document)

    cat ~/.ssh/your_file_name.pub
    

    with xclip

    xclip -sel clip < ~/.ssh/id_rsa.pub
    
  5. Go to github settings page and add this key

  6. test your ssh connection

    ssh -T git@github.com
    

    ***Hi atiq1589! You've successfully authenticated, but GitHub does not provide shell access.***

automatically add ssh key for win bash

SOURCE

  1. Add below command in ~/.bashrc file

    if [ -z "$SSH_AUTH_SOCK" ] ; then
        eval `ssh-agent -s`
        ssh-add
    fi
    
  2. install expect

    sudo apt-get -y install expect
    
  3. make a script

    #!/usr/bin/expect -f
    spawn ssh-add /home/user/.ssh/id_rsa
    expect "Enter passphrase for /home/user/.ssh/id_rsa:"
    send "passphrase\n";
    interact
    

    For my local pc: ./mnt/e/work/Resources/bash-command/add-ssh.sh


Install Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Add Suporting Packages

sudo apt install python3-dev python3-pip
sudo apt install libffi-dev
sudo apt install python3-tk
sudo apt install lzma
sudo apt install liblzma-dev
sudo apt install libbz2-dev
sudo apt install libreadline-dev
sudo apt install tk-dev
brew install nvm
brew install yarn
brew install pyenv
brew install pyenv-virtualenv
brew install poetry
brew install libffi
brew install rustup
rustup-init

Install Docker

SOURCE

echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list

Install Ruby

SOURCE

sudo apt-get install -y ruby

or

sudo apt-get install -y ruby-full

latest ruby

SOURCE

sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

rbenv install 2.3.1
rbenv global 2.3.1
ruby -v

Install LAMP

SOURCE

Install Apache

sudo apt-get install apache2

Install MySQL

sudo apt-get install mysql-server

Install PHP

sudo apt-get install php5 libapache2-mod-php5

Restart Server

sudo /etc/init.d/apache2 restart

or

sudo service apache2 {command [restart, start, stop]}

Check PHP

php -r 'echo "\n\nYour PHP installation is working fine.\n\n\n";'

Install xclip

sudo apt-get -y install xclip

Install NVM (Node Version Manager)

SOURCE

Curl

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash

Wget

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash

Test

nvm -v 

Use node version per folder

  1. Need to create .nvmrc file in that folder
  2. put version number on that file (.nvmrc)
$ echo "5.9" > .nvmrc

$ echo "lts/*" > .nvmrc # to default to the latest LTS version
  1. then run
nvm use
  1. Automatically load node version.
# place this after nvm initialization!
autoload -U add-zsh-hook
load-nvmrc() {
  local node_version="$(nvm version)"
  local nvmrc_path="$(nvm_find_nvmrc)"

  if [ -n "$nvmrc_path" ]; then
    local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")

    if [ "$nvmrc_node_version" = "N/A" ]; then
      nvm install
    elif [ "$nvmrc_node_version" != "$node_version" ]; then
      nvm use
    fi
  elif [ "$node_version" != "$(nvm version default)" ]; then
    echo "Reverting to nvm default version"
    nvm use default
  fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc

Install Node

SOURCE

  1. Install NVM
  2. Install Node
nvm install node 

or
nvm install #version

nvm install 6.9.1

Test

node -v

or
Check NPM

npm -v

Install Bower

SOURCE

 npm install -g bower

Install python

There is aleardy python2 installed

install pip

sudo apt-get install python-pip

Check pip

pip --version

install Coffee scripts

SOURCE

npm install -g coffee-script

Install Nonemon

SOURCE github

npm install -g nodemon

Install PostgreSQL

  1. Install postgresql
sudo apt-get install postgresql postgresql-contrib
  1. Change password
sudo -i -u postgres
psql
\password postgres

Follow instruction 3. quite

\q
  1. Restart
sudo service postgresql restart

Install Redis

SOURCE

wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
sudo ln -s path/to/redis-stable/src/redis-server /usr/bin

Install ZSH

sudo apt-get install zsh

Install oh-my-zsh

SOURCE Curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

wget

sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

Install Theme

SOURCE

Add ZSH_THEME="gnzh" in ~/.zshrc

or

match="robbyrussell"
sed -i -e 's/'$match'/gnzh/g' .zshrc

To Enable ZSH in windows 10 bash add

# Launch Zsh
if [ -t 1 ]; then
exec zsh
fi

in ~/.bashrc file
It has some problem to start other commands. Need to fix that first

Install plugin

  1. git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
  2. git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

add plugin in ~/.zshrc file plugins=(git zsh-autosuggestions zsh-syntax-highlighting)


Helpful Supporting package

  1. Dev package
sudo apt-get install libffi-dev
sudo apt-get install libssl-dev
sudo apt-get install python-dev

Helpful custom function

  1. To access drive directly add below command in ~/.bashrc file
drive(){
    cd /mnt/$1;
}

and run

source ~/.bashrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment