Facebook
From someone, 2 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 203
  1. # Setup WSL
  2.  
  3. ## 1. __Update packages__
  4.  
  5. Update package manager
  6. ```
  7. sudo apt-get upgrade -y && sudo apt-get update -y
  8. sudo apt-get install git
  9. ```
  10.  
  11. Install additional libs
  12. ```
  13. sudo apt-get install build-essential libssl-dev libffi-dev python3-dev python3-pip libsasl2-dev libldap2-dev default-libmysqlclient-dev libsqlite3-dev liblzma-dev tk-dev libreadline-dev libbz2-dev libncurses-dev
  14. ```
  15.  
  16. ## 2. __Install zsh and oh-my-zsh__
  17.  
  18. Install zsh and set zsh as default shell
  19. ```
  20. sudo apt install zsh -y
  21. chsh -s $(which zsh)
  22. ```
  23. Reopen shell, create empty file .zshrc
  24.  
  25. Install oh-my-zsh and its plugins
  26. ```
  27. sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
  28.  
  29. git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
  30. git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
  31. git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
  32. ```
  33.  
  34. Set ZSH_THEME="powerlevel10k/powerlevel10k" in ~/.zshrc
  35.  
  36. Add plugin to .zshrc
  37. ```
  38. plugins=(git zsh-autosuggestions web-search zsh-syntax-highlighting)
  39. ```
  40.  
  41. Remove backgorund color of dircolor
  42. ```
  43. dircolors -p | sed 's/;42/;01/' > ~/.dircolors
  44. ```
  45.  
  46. Add following lines to ~/.zshrc
  47. ```
  48. if [ -x /usr/bin/dircolors ]; then
  49.     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
  50.     alias ls='ls --color=auto'
  51.     #alias dir='dir --color=auto'
  52.     #alias vdir='vdir --color=auto'
  53.  
  54.     alias grep='grep --color=auto'
  55.     alias fgrep='fgrep --color=auto'
  56.     alias egrep='egrep --color=auto'
  57. fi
  58. ```
  59.  
  60. In order to get rid of underline of zsh-syntax-highlighting, add this to ~/.zshrc
  61. ```
  62. ZSH_HIGHLIGHT_STYLES[path]=none
  63. ZSH_HIGHLIGHT_STYLES[path_prefix]=none
  64. ```
  65.  
  66. ## 3. __Copy ssh keys__
  67.  
  68. Copy Windows ssh key to wsl
  69. ```
  70. cp -r /mnt/c/Users/<username>/.ssh/* ~/.ssh
  71. ```
  72.  
  73. Fix permission & known_hosts
  74. ```
  75. chmod 600 ~/.ssh/id_rsa
  76. rm known_hosts
  77. ```
  78.  
  79. ## 4. __Python__
  80.  
  81. Place the following line to ~/.zshrc
  82. ```
  83. alias python=python3
  84. ```
  85.  
  86. Install pip
  87. ```
  88. sudo apt install python3-pip
  89. ```
  90.  
  91. Install pipenv
  92. ```
  93. pip install pipenv
  94. ```
  95.  
  96. Install pyenv
  97. ```
  98. curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
  99.  
  100. ```
  101.  
  102. Add pyenv to PATH
  103. ```
  104. echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
  105. echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
  106. echo 'eval "$(pyenv init -)"' >> ~/.zshrc
  107. ```
  108.  
  109. ## 5. __Kubernetes__
  110.  
  111. Install kubectl
  112. ```
  113. sudo curl -fsSLo /etc/apt/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
  114. echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
  115. sudo apt-get update
  116. sudo apt-get install -y kubectl
  117. ```
  118.  
  119. Install k9s
  120. ```
  121. curl -sS https://webinstall.dev/k9s | bash
  122. source ~/.config/envman/PATH.env
  123. ```
  124.  
  125. ## 6. __Docker__
  126.  
  127. Create volumn for mysql
  128. ```
  129. sudo docker volume create mysql-data
  130. ```
  131.  
  132. Create a container run mysql
  133. ```
  134. sudo docker run --name=mysql-docker -p 3306:3306 -v mysql-data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_USER=usrname -e MYSQL_PASSWORD=123456 -d mysql/mysql-server:latest
  135. ```
  136.  
  137. By default, MySQL restricts connection other than the local machine for security reasons. To connect from the other machines, you have to change the connection restriction:
  138. ```
  139. docker exec -it mysql-docker bash
  140. # Connect to mysql server
  141. mysql -u root -p
  142.  
  143. # Allow access from all hosts
  144. UPDATE mysql.user SET host = ‘%’;
  145. GRANT ALL PRIVILEGES ON *.* TO 'usrname'@'%';
  146. FLUSH PRIVILEGES;
  147. ```
  148.  
  149. Start a redis instance
  150. ```
  151. sudo docker run --name redis-docker -p 6379:6379 -d redis
  152. ```