I will summarize the settings made on Ubuntu of Windows Subsystem for Linux (WSL) as a memorandum.
Windows 10 version 2004 and above
Win + R
winver
and press ʻEnter`Run PowerShell as an administrator and execute the following command
PowerShell[Administrator]
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Run PowerShell as an administrator and execute the following command
PowerShell[Administrator]
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Please download and install from here.
PowerShell[Administrator]
wsl --set-default-version 2
Please obtain and install from the following. https://www.microsoft.com/ja-jp/p/ubuntu/9nblggh4msv6?
Press the Windows key to launch Ubuntu from the list of apps. First, set the user name. This time, it is user in the image, but it is OK if you decide as you like within the range of half-width alphanumeric characters. Then enter the password twice. It is not displayed even if I enter it, but it is entered properly. (Because I will use it many times after that, please do not forget it)
Reference https://docs.microsoft.com/ja-jp/windows/wsl/install-win10
Install the X-Window server to run GUI programs on Linux.
Download the installer from here.
Launch the downloaded installer and install according to the instructions.
Search for XLaunch in the start menu and launch
Click Next and write -ac
in the -Additional parameters for VcX srv
field on the third screen
.
If you save the configuration file in shell: startup
with save configuration
, VcXsrv will start automatically when Windows starts.
I'm using Windows Terminal. It is quite easy to use, so if you want to use it, please refer to the installation / setting method described in [below](installation setting of windows-terminal from # microsoft-store is optional).
Execute the following commands in order. I think it will take a few hours lightly.
bash
sudo apt update -y
sudo apt upgrade -y
sudo apt install -y language-pack-ja manpages-ja manpages-ja-dev nkf build-essential x11-apps emacs emacs-mozc fcitx-mozc dbus-x11 gtypist typespeed texlive-full evince gnome-terminal sox nodejs libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-net-dev libsdl2-ttf-dev libsdl2-gfx-dev libopencv-dev freeglut3-dev fonts-freefont-ttf fonts-ubuntu gdb python3-pip libreadline-dev libssl-dev
I will explain what you are doing
1st line: Update the package list (Be sure to execute it when adding / deleting repositories) 2nd line: Update package 3rd line: Installation of basic packages and deb files
Execute the following command to set the display.
bash
echo "export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0" >> ~/.profile
echo 'export LIBGL_ALWAYS_INDIRECT=1' >> ~/.profile
Execute the following command to set the location.
bash
sudo update-locale LANG=ja_JP.UTF-8
Next, as a setting for entering Japanese words, add the following contents to `~ / .profile``.
~/.profile
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
export DefaultIMModule=fcitx
if xset -r 49; then
fcitx-autostart >/dev/null 2>&1 &
else
echo "Start XLaunch and then Restart Ubuntu"
fi
Continue to set the time zone.
bash
sudo dpkg-reconfigure tzdata
And select ʻAsia →
Tokyo`.
If you have VS Code installed and Remort --WSL installed, you can open VS Code with the code
command, but you can't edit it with sudo (please tell me how to do it ...) Let's keep it.
VSCode Obtain and install from the following. https://code.visualstudio.com/download
Then install the extension from ctrl + shift + x
or the □ mark on the far left.
Remort - WSL
Japanese Language Pack for Visual Studio Code
Is mandatory. (* If you don't want to speak Japanese, just Remort --WSL is OK.)
After installing the extension, reload it and press ctrl + shift + p
to bring up the command palette.
Enter & select Configure Display Language
and change it to ja
to make it Japanese.
In addition, please install the extension function if you like.
Besides I Extensions that introduce Vim keybindings Color scheme Monokai Pro extension I have installed extensions such as, but I will omit it because my tastes are different.
You can open the setting from ctrl +,
or the lower left gear → Settings.
I think it is easy to understand because it is a GUI. (Editable with json)
Reference https://rfs.jp/sb/vsc/vsc-setting.html https://qiita.com/hi85/items/eaede5ebb509f21f27f5
If you use LaTeX, I wrote about it before, so Please refer to here) to set it.
Vim Write the settings in ~ / .vimrc. Also, the color scheme is not good at the beginning, so I have introduced the color scheme molokai.
Setting example
Download molokai
mkdir ~/.vim cd ~/.vim mkdir colors git clone https://github.com/tomasr/molokai mv molokai/colors/molokai.vim ~/.vim/colors/ vi ~/.vimrc
> ~ / .vimrc contents
>```vim:~/.vimrc
set fenc=utf-8 "UTF-Save in 8 formats
set title "Show the name of the file being edited
set showmatch "Display the corresponding parenthesis when entering parentheses
set number "Show line number
syntax on "Turn on code color coding
set smartindent "Set smart indent
set tabstop=2 "Set indent to 2 spaces
syntax on "Code color coding
set showcmd "Display the command you are typing
set virtualedit=onemore "Allows you to move the cursor to the end of a line
set clipboard=unnamedplus "Put it in the clipboard when yank
set ignorecase "If the search string is lowercase, the search is case insensitive.
set smartcase "If the search string contains uppercase letters, search separately
set incsearch "Hit the target character string in sequence when entering the search character string
set wrapscan "If you go to the end when searching, go back to the beginning
set hlsearch "Highlight search terms
nmap <Esc><Esc> :nohlsearch<CR><Esc> "ESC repeated hits to remove highlights
colorscheme molokai "Make the color scheme molokai
set t_Co=256 "Make vim compatible with 256 colors
emacs
Describe it in ~ / .emacs.d / init.el.
Initially I don't think there is a directory ~ / .emacs.d
bash
mkdir ~/.emacs.d
Create it with.
Setting example
;;Japanese input settings (require 'mozc) (set-language-environment "Japanese") (setq default-input-method "japanese-mozc") ;;Turn off the welcome screen on the initial screen (setq initial-scratch-message t) (setq initial-scrarch-message nil) ;;Show how many rows and columns you are in at the bottom bar of the screen (line-number-mode t) (column-number-mode t) ;;Make yes and no hit with y and n (defalias 'yes-or-no-p 'y-or-n-p) ;;Line number display (global-linum-mode) (setq linum-format "%4d ") ;;UTF text encoding-Set to 8 (set-default-coding-systems 'utf-8) (set-keyboard-coding-system 'utf-8) (set-terminal-coding-system 'utf-8) (set-buffer-file-coding-system 'utf-8) (prefer-coding-system 'utf-8)
## 5. Font settings
Makes Windows fonts available on WSL.
First, open `/etc/fonts/local.conf` with sudo.
vi can be emacs (code is not possible)
#### **`bash`**
```bash
sudo vi /etc/fonts/local.conf
Then paste the following content.
/etc/fonts/local.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir>/mnt/c/Windows/Fonts</dir>
</fontconfig>
After this,
bash
fc-cache -fv
Then you can use Windows fonts in WSL.
1.Python The default for Ubuntu 20.04 is 3.8.6, which is a little old, and it is convenient to be able to manage multiple versions.
bash
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
source ~/.bashrc
bash
pyenv install --list
You can see the list that can be installed with.
The latest version at the time of posting is 3.9.0, so I will install it. If you want to install another version, please read as appropriate.
bash
pyenv install 3.9.0
pyenv global 3.9.0
bash
pip3 install pandas numpy scipy xlrd matplotlib japanize-matplotlib Pillow opencv-python folium plotly requests beautifulsoup4 lxml Flask Flask-Bootstrap4 Django PyMySQL
2.Ruby on Rails
bash
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
~/.rbenv/bin/rbenv init
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
bash
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
bash
rbenv install -list
If you do
bash
2.5.8
2.6.6
2.7.2
jruby-9.2.13.0
maglev-1.0.0
mruby-2.1.2
rbx-5.0
truffleruby-20.2.0
truffleruby+graalvm-20.2.0
It comes out like. This time I will install 2.7.2. If you want to install another version, please read as appropriate.
bash
rbenv install 2.7.2
rbenv rehash
rbenv global 2.7.2
bash
gem install rails
bash
sudo apt install libsqlite3-dev
gem install sqlite3
gem install bundler
curl -o- -L https://yarnpkg.com/install.sh | bash
bash
rails new app
cd app
rails server
Go to 127.0.0.1:3000 in your browser and It's OK if something like this appears.
An alias is a command alias.
Write it in the form of addition
to ~ / .bashrc
.
Below are my settings, but I think there is no loss in adding them because all but the bottom two are basic.
Setting example
#(Abbreviation) #Please add alias ..='cd ..' alias ..2='cd ../..' alias ..3='cd ../../..' alias agi='sudo apt install' alias agr='sudo apt remove' alias agu='sudo apt update && sudo apt upgrade' alias agi='sudo apt install' alias ags='apt search' alias cp='cp -i' alias mv='mv -i' alias rm='rm -ri' alias g='git' alias ga='git add' alias gd='git diff' alias gs='git status' alias gp='git push' alias gb='git branch' alias gst='git status' alias gco='git checkout' alias gf='git fetch' alias gc='git commit' #Note that these two are a little radical... alias m='mkdir' alias p='python3
> Reference
https://qiita.com/reireias/items/d906ab086c3bc4c22147
# Symbolic link
Symbolic links are like shortcuts in Windows.
In WSL, the C drive of Windows is / mnt / c, so the Downloads folder is / mnt / c / User / (Windows user name) / Downloads.
Let's put a symbolic link here.
#### **`bash`**
```bash
ln -s /mnt/c/User/(Windows username)/Downloads
The symbolic link is pasted like this. Using symbolic links in this way makes it easier to link WSL with Windows on the host.
For the time being, I'm pasting this much.
Please obtain and install from the following. https://www.microsoft.com/ja-jp/p/windows-terminal/9n0dx20hk701
After installation, start it and select the setting from ∨ or open the setting with Ctrl +,
.
Let's specify the ubuntu profile guid in profiles as the globals defaultProfile.
Rearrange the order of the list to your liking.
I have ʻUbuntu,
Powershell,
cmd` in that order.
Then set the startingDirectory in your Ubuntu profile to // wsl $ / Ubuntu / home / (username)
.
The username here is ʻUbuntu username`.
For reference, in my case it is as follows.
settings.json
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"profiles": {
"defaults": {
},
"list": [
{
"guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"hidden": false,
"name": "Ubuntu",
"startingDirectory": "//wsl$/Ubuntu/home/user",
"source": "Windows.Terminal.Wsl"
},
{
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false
},
{
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "command prompt",
"commandline": "cmd.exe",
"hidden": false
},
//(Abbreviation)
]
},
//(The following is omitted)
}
I will omit the terminal color scheme and key binding settings. (Because the taste seems to be different)
Reference https://docs.microsoft.com/ja-jp/windows/terminal/get-started
Recommended Posts