Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install the Ubuntu subsystem in windows

2025-04-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this article "windows how to install the Ubuntu subsystem", so the editor summarizes the following contents, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "windows how to install the Ubuntu subsystem" article.

Windows installs Ubuntu subsystem and installs windows Terminal

Search to enable or disable the windows function, check the Windows subsystem for Linux, and restart the computer after confirming.

Search for Ubuntu and windows Terminal and install (windows Terminal may require a higher version of the win10 system, which is generally updated to the latest version)

After Ubuntu is installed, a user name and password will be required.

It is recommended to install the latest version of Ubuntu 20.04

After win10 has installed the ubuntu subsystem and oh my zsh, you can access the f disk under win10 or other disks through / mnt/f/. There is also the pwd effect above.

Install the vscode remote-wsl plug-in

Download and install vscode and install the remote-wsl plug-in.

Install oh my zsh

Briefly describe the installation method of oh my zshoh my zsh official website. Github ohmyzsh

The oh my zsh installation section applies to Ubuntu and mac systems.

Echo $SHELL# / bin/bash defaults to bash# to check which shellscat / etc/shells# are installed under zshsudo apt-get install zsh-y # View zsh version zsh-- version# 5.1." after installation, cat / etc/shells will have / bin/zsh / usr/bin/zsh# to zshchsh-s $(which zsh) # or this command # chsh-s / usr/bin/zsh# three installation options are available Option: # Via curl$ sh-c "$(curl-fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"# Via Wget$ sh-c" $(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh-O -) "# if the above two cases cannot be installed You can use the following methods. # via git clonegit clone https://github.com/ohmyzsh/ohmyzsh.git ~ / .oh-my-zshcp ~ / .oh-my-zsh/templates/zshrc.zsh-template ~ / .zshrcchsh-s $(which zsh) # opening a new terminal will apply the new zshrc configuration

If you can't install the above three methods, you can check the oh my zsh documentation.

After the installation is successful, the configuration information will be in ~ / .zshrc. You can use code ~ / .zshrc (if you don't have vscode installed, you can use vim ~ / .zshrc) to open and edit zsh configuration information, and you can see that the git plug-in Plugin:git is configured by default. In other words, it is easier to use some aliases related to git.

# for example, when `status` is used, you only need to enter `gst`. When `git pull`, you only need to enter `gl`. When you use `Push`, you only need to enter `gp` and so on.

Because there are these abbreviations in the configuration, there is more to see here oh my zsh plugin git.plugin.zsh document configuration, github oh my zsh plugin git.plugin.zsh file address. After the installation is successful, the folder of ~ / .oh-my-zsh will be created at the same time, which is actually the git repository master branch of .oh-my-zsh. You can find that there is a plugins folder in the folder with many plug-ins built in. You can customize the theme theme, as shown in example.zsh-theme. Related to custom customization. Plug-ins will be installed here. For more information, please see example.plugin.zsh

I temporarily installed these plug-ins.

Plugins= (# built-in plug-in, enable git cp mv # press the ESC key twice, record the history input zsh command with sudo permission sudo #, prompt automatically, quickly use the zsh-autosuggestions # zsh command to highlight zsh-syntax-highlighting)

By the way, install zsh-autosuggestions by the installation method of the next two plug-ins

Git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

Install zsh-syntax-highlighting

Git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

ZSH_CUSTOM is actually a variable that represents the path ~ / .oh-my-zsh/custom, which is installed in this directory. There are many efficient plug-ins, waiting for you to discover ~ oh my zsh official website, but if there are too many plug-ins installed, it will feel a little stuttered.

# each time the `.zshrc` configuration file is modified, it needs to be overloaded before it can take effect. Source .zshrc # can also be encapsulated as an abbreviated command aliasalias rl='source ~ / .zshrc'

You can also configure more alias in this configuration file.

# ~ / .zshrc # for example, jump to the working directory alias dgg='cd / mnt/f/git-source/github'# vscode to open the file or folder code blog you want to edit

That is not win10, but also want to set aliases to improve efficiency, is there no way, you can use git bash to set alias, install git, bring your own git bash.

Windows git bash sets aliases to improve efficiency

Windows desktop or any explorer location, right-click and select Git Bash Here, which opens the git bash command line. First set the theme, right-click and select options, Looks > theme > dracula. I chose the dracula theme, which looks more comfortable. You can also set fonts and so on.

# Jump to the root path cd ~ # to check whether there is a .bash _ profile file la# if there is no .bash _ profile file, you need to create a touch .bash _ profile# to open and edit (I have vscode installed here, so open the file directly with it) code .bash _ profile

Some aliases can be set up according to the modification. For example, our commonly used git status command can be encapsulated as gst. The clear screen clear command is encapsulated into cls.

Alias gst='git status'alias cls='clear'

Each time you modify this file, you need to type source ~ / .bash_profile to reload the file before it will take effect. Code ~ / .bash_profile, edit this configuration file with vscode and encapsulate it into a command. For example:

Alias rl='source / .bash_profile'alias bashconfig='code ~ / .bash_profile'

In this way, you only need to type rl after each change and save, and the reload will take effect. You can also encapsulate some working directories, and some of my projects are under the / f/git-source/github file.

# Project alias dgg='cd F:/git-source/github'# Weekly report on github related to alias dcwk='cd FRV

Every time you enter the project, dgg directly, you can jump to this directory, and then select the appropriate directory. For example, dgg enters the working directory, cd analyse-vue-cli enters the project directory, (enter anal and press tab)

# / f/git-source/github/analyse-vue-cli (dev) # View status git statusgst# opens this folder with vscode and starts editing ~ code. /

Related to git, give some examples of those that are commonly used.

Alias g='git'alias ga='git add'alias gaa='git add-all'alias gp='git push'alias gl='git pull'alias gcmsg='git commit-masked # Branch related alias gb='git branch'alias gbr='git branch-r'alias gba='git branch-asides # checkoutalias gco='git checkout'alias gcb='git checkout-baked # mergealias gm='git merge'# diffalias gd='git diff'alias gdw='git diff-- word-diff'

More can copy some commands of the oh my zsh plug-in, leaving alias-related, oh my zsh plugin git.plugin.zshPlugin:git wiki is equivalent to unlocking the git plug-in of oh my zsh. There are many plug-ins, such as npm click to view, node and so on, can be studied.

Git bash, is there any plug-in similar to oh my zsh? I haven't found it yet. If you know, please let me know. Directory-related operations, you can also set some aliases. For example:

# fall back to the next level, alias.. ='cd.. 'alias. =' cd.. /.. 'alias.. =' cd.. /.. /.. 'alias. =' cd.. /.. 'alias. =' cd.. /..'

For more aliases, you can customize the command line tool on windows and click to view the command line tool on the cmder official website using cmder. Although I installed it a few years ago, I found that git bash works more smoothly, maybe I'm not used to cmder yet. With regard to the configuration of cmder, here is an article by Lord Yoqing Youcaoxuan: "Cmder of essential artifacts under Win".

There is also cygwin, which is also a windows command line tool, and you can also install on my zsh.

Of course, git can also be aliased.

Git set alias, use tig artifact # git status = > git stgit config-global alias.st status above is about "windows how to install Ubuntu subsystem" this article, I believe we all have a certain understanding, I hope the content shared by the editor will be helpful to you, if you want to learn more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report