zoukankan      html  css  js  c++  java
  • Windows上使用Linux命令

    WSL

    Windows Subsystem for Linux(简称WSL)是一个在Windows 10上能够运行原生Linux二进制可执行文件(ELF格式)的兼容层。它是由微软与Canonical公司合作开发,其目标是使纯正的Ubuntu 14.04 “Trusty Tahr”映像能下载和解压到用户的本地计算机,并且映像内的工具和实用工具能在此子系统上原生运行。

    可以理解为Windows下的Linux子系统

    第一步

    Win10设置——>windows更新与安全——>开发者选项——>勾选开发人员模式

    第二步

    控制面板——>程序和功能——>启用和关闭Windows功能——>勾选适用于Linux的Windows子系统

    过程中可能会提示你重启

    第三步

    下载

    方式一

    Micerossft Store——>bash——>Ubuntu16.04(自己用的)——>安装
    

    方式二
    通过命令下载查看官方文档

    查看是否成功 win+r 输入bash 就可以了

    win10下载Ubuntu16.04 后在win10下具体位置

    在文件资源管理输入

    方式一

    C:Users用户名AppDataLocalPackagesCanonicalGroupLimited.Ubuntu16.04onWindows_79rhkp1fndgscLocalState
    ootfs
    

    方式二

    wsl$Ubuntu-16.04
    
    

    换源

    Ubuntu16.04

    第一步

    先备份原来的源

    sudo  cp   /etc/apt/sources.list   /etc/apt/sources.list.bak
    

    第二步

    修改sources.list

    清除内容修改为

    阿里源

    deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
    

    清华源

    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
    

    更新软件列表和软件

    sudo apt update
    sudo apt upgrade
    

    更改外观

    由于 WSL 的会话窗口配色实际上取决于 CMD 属性里颜色标签里面的配色,默认的实在是太丑了,既没有高亮字符也不清晰,严重影响开发效率。

    这就需要用到一个开源的 CMD 配色工具:ColorTool

    管理终端bash

    通常 Linux 服务器上面默认使用的 SHELL 是 Bash。其实除了 Bash 之外,还有很多其他的 SHELL 程序,比如:ZSH、CSH、Fish 等等。

    在这里不一一说明了

    安装zsh参考文档

    Hyper(包含了外观和管理)

    我个人在用的是Hyper

    Hyper 是基于 Electron 的,所以它的插件、主题等等可拓展性都非常强大。几行简单的 Javascript、HTML、 CSS 代码,你就可以定制自己的插件。

    在Windows上它是集成在WSL上(高颜值跨平台的终端软件)

    去官网直接下载https://hyper.is

    如果你是 macOS 平台,你还可以通过 Homebrew 命令来快速完成安装

    $ brew cask install hyper
    
    

    Hyper 本身是支持插件系统的,在安装扩展插件前,你需要先安装 Hyper命令行程序。你可以点击菜单,选择 Plugin 选项,然后点击 Install Hyper CLI command in PATH。

    安装插件

    $ hyper i vermina
    

    Hyper 的官方主题地址:https://hyper.is/themes

    Hyper 的官方插件地址:https://hyper.is/plugins

    通常在使用 WSL (Windows Subsystem for Linux) 工作时,我们希望启动终端时就进入 WSL 的 SHELL 内部。但默认情况下我们需要在启动终端并输入 bash 命令后才能进入 WSL 终端。

    现在,你只需打开 Hyper 设置页面文件,从菜单 Edit -> Preferences进入,然后编辑 shell 和 shellArgs 参数即可。

    修改为

    shell: 'C:\Windows\System32\bash.exe',
    shellArgs: [],
    

    重新打开 Hyper,你会发现默认已经进入了 Bash 终端界面了。

  • 相关阅读:
    H3C无线配置2三层注册典型配置举例(集中转发)
    PHP 中 exec() 执行系统外部命令
    salesforce 从零开始(一)开始使用
    求和平均统计
    VS2012 如何进行远程调试
    H5跳转小程序的方法
    C#提取HTML中IMG标签的URL
    数据库链接字符串中的细节(integrated security=true;MultipleActiveResultSets=true)
    运行cmd状态下MySQL导入导出.sql文件
    sql server 2008 rownumber 分页sql语句
  • 原文地址:https://www.cnblogs.com/xinzaiyuan/p/12070772.html
Copyright © 2011-2022 走看看