Article directory
foreword
The obstacle to learning Linux is often the first step is not having Linux. Of course, there are many methods, such as cloud server, virtual machine and other operations.
Here is a simple and practical method that requires very little configuration on the personal computer.
Windows Subsystem for Linux, WSLWindows Subsystem for Linux
environment settings
Developer Options
turn on开发人员模式
Turn Windows features on or off
confirm适用于Linux的Windows子系统
After confirming, you need to restart the computer
Enter the Microsoft application store to download
Enter the mall, search for ubunt and download a free one
Here I downloaded Ubuntu 18.04.6 LTS
The default is to download to the C drive. If you want to set it, you can set it in the settings of the mall. It will not be shown here.
Download completed
When the following icon appears in the application, it means that the download and installation is complete
turn on
- You can click the icon to open directly
bash
You can also enter commands on the command line
Note that I am win+R
operating directly on the desktop with the open cmd.
After entering linux, I found that the path is /mnt/c/Users/windows
The windows here is my pc login account.
That is to say, through WSL's linux, I can directly access my environment under win, and directly contribute paths and files.
PS: Check the running effect
Linux basic configuration
lack of environment
Some computers may not support the environment. According to the prompt in the command line, download a small software from the link in the prompt and install it.
If this problem does not occur, you can ignore it. Since the blogger did not have this problem when installing it on the second machine, there are no pictures to post here.
Register an account
Just start will ask to register a default account and password, follow the prompt process to set
Set root account password
The initial default root account has no password, so it needs to be set
# 设置root密码
sudo passwd root
# 进入root账户
su
# 退出root
exit
Installation in common environments
Here you can install it according to your needs
# 最好直接在root账户下安装,否则就用 sudo 提权
# 更新
apt-get update
# 常用编译环境
apt-get install gcc
apt-get install g++
apt-get install gdb
apt-get install cmake
# ssh
apt install openssh-server
apt install openssh-client
# 生成密钥
ssh-keygen -A
# 开启,关闭,重启
service ssh start
service ssh stop
service ssh restart
# ssh配置的路径 文件是:sshd_config
/etc/ssh
/etc/ssh/sshd_config
ssh partial configuration information
# 个人目前的配置,没输入的就是我当前sshd下的默认属性
# 默认端口22
PermitRootLogin yes
ChallengeResponseAuthentication no
UsePAM yes
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
VS Code connection
plug-in
Direct search ssh
and WSL
keywords can be
shortcut to connect
The left column has a dedicated远程资源管理器
打开远程窗口
There is also an icon in the lower left corner
Click here to perform basic configuration according to the prompts, such as ssh ip, account, password, etc.
The local_root here is Configure SSH Hosts
the information I am configuring
SSH Client Config File Example (goteleport.com)
# Read more about SSH config files: https://linux.die.net/man/5/ssh_config
# 这份配置的名称
Host local_root
# 本机回路地址
HostName 127.0.0.1
# 连接的账号
User root
# 连接端口
Port 22