混合使用Windows和Linux子系统的工具和命令

文章目录

    • 在Windows中运行Linux命令
    • 使用PowerShell混合使用Linux和Windows命令
      • 通过power shell在Windows混合使用Linux工具
      • 在Linux中混合使用Windows 工具
    • 推荐阅读

Windows和Linux的工具和命令可以通过WSL互换使用。
可以在Linux子系统中运行Windows命令,也可以在Windows中运行Linux子系统工具。

但是需要注意:Windows和Linux文件系统以不同的方式处理大小写—Windows是不区分大小写的,Linux是区分大小写的。

\\wsl$

通过Windows查看Ubuntu文件目录
在这里插入图片描述

在Windows中运行Linux命令

分别在Ubuntu和Windows运行ls -la 指令
Ubuntu:

ls -la

windows:

wsl ls -la

在Ubuntu中运行 ls -la可以看Ubuntu的文件目录,在Windows power shell中运行wsl ls -la则可以看到Windows文件目录。
在这里插入图片描述
我们在Ubuntu中安装了dig工具,那么除了可以在Ubuntu系统中使用,也可以通过power shell中执行:

wsl dig baidu.com 

直接比照Ubuntu中的指令用法,会有提示报错。

PS C:\Users\Administrator> dig baidu.com
dig : The term 'dig' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the s
pelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ dig baidu.com
+ ~~~
    + CategoryInfo          : ObjectNotFound: (dig:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Users\Administrator>

执行wsl dig baidu.com则可以正常执行,并输出结果:

PS C:\Users\Administrator> wsl dig baidu.com

; <<>> DiG 9.18.12-0ubuntu0.22.04.1-Ubuntu <<>> baidu.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47817
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;baidu.com.                     IN      A

;; ANSWER SECTION:
baidu.com.              429     IN      A       39.156.66.10
baidu.com.              429     IN      A       110.242.68.66

;; Query time: 47 msec
;; SERVER: 114.114.114.114#53(114.114.114.114) (UDP)
;; WHEN: Tue Nov 28 14:59:15 CST 2023
;; MSG SIZE  rcvd: 70

PS C:\Users\Administrator>

在Windows使用sudo更新Linux子系统

wsl sudo apt-get update

在这里插入图片描述

PS C:\Users\Administrator> wsl sudo apt-get update
[sudo] password for mirror:
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
Get:3 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Hit:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Get:5 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages [989 kB]
Get:6 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [1200 kB]
Get:7 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [1003 kB]
Get:8 http://security.ubuntu.com/ubuntu jammy-security/main Translation-en [192 kB]
Get:9 http://security.ubuntu.com/ubuntu jammy-security/restricted amd64 Packages [1143 kB]
Get:10 http://security.ubuntu.com/ubuntu jammy-security/restricted Translation-en [186 kB]
Get:11 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [799 kB]
Fetched 5741 kB in 28s (202 kB/s)
Reading package lists... Done
PS C:\Users\Administrator>

使用PowerShell混合使用Linux和Windows命令

通过power shell在Windows混合使用Linux工具

用Linux的指令ls -la 列出文件目录,再通过power shell的管道符 和findstr 指令找出目录中含有“Do”字符串的目录。

wsl ls -la | findstr "Do"
PS C:\Users\Administrator> wsl ls -la | findstr "Do"
drwxrwxrwx 1 mirror mirror    4096 Nov  9 10:59 Documents
drwxrwxrwx 1 mirror mirror    4096 Nov 21 16:01 Downloads
lrwxrwxrwx 1 mirror mirror      36 Mar 25  2022 My Documents -> /mnt/c/Users/Administrator/Documents
PS C:\Users\Administrator>

先通过dir 查看当前文件目录

PS C:\Users\Administrator> dir


    Directory: C:\Users\Administrator


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-r---        2022/3/25     13:23                3D Objects
d-r---        2022/3/25     13:23                Contacts
d-r---       2023/11/27     14:09                Desktop
d-r---        2023/11/9     10:59                Documents
d-r---       2023/11/21     16:01                Downloads
d-r---        2022/3/25     13:23                Favorites
d-r---        2022/3/25     13:23                Links
d-r---        2022/3/25     13:23                Music
d-r---        2022/3/25     13:24                OneDrive
d-r---        2022/3/25     13:23                Pictures
d-----        2023/2/15     17:20                PycharmProjects
d-r---        2022/3/25     13:23                Saved Games
d-r---        2022/3/25     13:23                Searches
d-r---        2023/6/13     13:24                Videos
d-----        2023/2/28     16:02                WebControlThird
-a----        2023/11/2     15:10           1014 res.bmp

接着运用Windows和Linux混合指令,找出含有“Do”字符串的目录

dir | wsl grep Do
PS C:\Users\Administrator> dir | wsl grep Do
d-r---        2023/11/9     10:59                Documents
d-r---       2023/11/21     16:01                Downloads
PS C:\Users\Administrator>

在Linux中混合使用Windows 工具

在Ubuntu中通过Windows ipconfig工具查看当前IP地址:

mirror@Ubuntu22:~$ ipconfig.exe

Windows IP Configuration


Ethernet adapter 以太网:

   Connection-specific DNS Suffix  . : domain.com
   Link-local IPv6 Address . . . . . : fe80::82b:d1c2:85c7:7798%10
   IPv4 Address. . . . . . . . . . . : 192.168.8.20
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.8.250

过滤IPv4地址:

 ipconfig.exe | grep IPv4
mirror@Ubuntu22:~$ ipconfig.exe | grep IPv4
   IPv4 Address. . . . . . . . . . . : 192.168.8.20
mirror@Ubuntu22:~$

再来一个Windows netsh工具的使用范例:

mirror@Ubuntu22:~$ netsh.exe
netsh>lan
netsh lan>show interface

There is 1 interface on the system:

    Name             : 以太网
    Description      : Intel(R) Ethernet Connection (11) I219-LM
    GUID             : 32da7e41-d361-47c1-99b0-77e1a1a069d9
    Physical Address : 88-88-88-88-88-87
    State            : Connected. Network does not support authentication.

netsh lan>    

推荐阅读

  • Ubuntu挂载NFS(Network File System) ,怎么解决权限不一致的问题?
  • Ubuntu镜像源cn.arichinve.ubuntu.com不可用原因分析和解决
  • Windows 11安装Ubuntu 实战教程
  • PowerShell无人参与安装最新版本SQL Server Management Studio (SSMS)
  • VRRP(虚拟路由器冗余协议)标准协议工作机制与优势介绍
  • Linux MTR(My TraceRoute)command

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/209341.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

redis主从复制模式和哨兵机制

目录 第一章、主从复制模式1.1&#xff09;Redis 主从复制模式介绍1.2&#xff09;Redis 主从复制实现、 第二章、哨兵机制2.1&#xff09;容灾处理之哨兵2.2&#xff09;Sentinel 配置 第一章、主从复制模式 1.1&#xff09;Redis 主从复制模式介绍 ①单点故障&#xff1a;数…

【C++】string类模拟实现过程中值得注意的点

&#x1f440;樊梓慕&#xff1a;个人主页 &#x1f3a5;个人专栏&#xff1a;《C语言》《数据结构》《蓝桥杯试题》《LeetCode刷题笔记》《实训项目》《C》《Linux》 &#x1f31d;每一个不曾起舞的日子&#xff0c;都是对生命的辜负 目录 前言 1.有关const的使用 &#x…

常用sql记录

备份一张表 PostgreSQL CREATE TABLE new_table AS SELECT * FROM old_table;-- 下面这个比上面好&#xff0c;这个复制表结构时&#xff0c;会把默认值、约束、注释都复制 CREATE TABLE new_table (LIKE old_table INCLUDING ALL) WITHOUT OIDS; INSERT INTO new_table SELE…

一进三出宿舍限电模块的改造升级

一进三出宿舍限电模块改造升级石家庄光大远通电气有限公司智能模块功能特点&#xff1a; 电能控制功能&#xff1a;可实施剩余电量管理&#xff0c;电量用完时将自动断电&#xff1b; 剩余电量可视报警提示功能&#xff1a;剩余电量可视&#xff0c;并当电量剩余5度时&#xff…

图解java.util.concurrent并发包源码系列——深入理解定时任务线程池ScheduledThreadPoolExecutor

深入理解定时任务线程池ScheduledThreadPoolExecutor ScheduledThreadPoolExecutor作用与用法ScheduledThreadPoolExecutor内部执行流程DelayedWorkQueueScheduledFutureTask源码分析任务提交ScheduledFutureTask的属性和方法delayedExecute(t) 任务执行ScheduledFutureTask.su…

Android Bitmap 使用Vukan、RenderEffect、GLSL实现模糊

文章目录 Android Bitmap 使用Vukan、RenderEffect、GLSL实现模糊使用 RenderEffect 模糊使用 Vukan 模糊使用 GLSL 模糊RS、Vukan、RenderEffect、GLSL 效率对比 Android Bitmap 使用Vukan、RenderEffect、GLSL实现模糊 本文首发地址 https://blog.csdn.net/CSqingchen/articl…

行内元素和块级元素分别有哪些?有何区别?怎样转换?

行内元素和块级元素分别有哪些&#xff1f; 常见的块级元素&#xff1a; p、div、form、ul、li、ol、table、h1、h2、h3、h4、h5、h6、dl、dt、dd 常见的行级元素&#xff1a; span、a、img、button、input、select 有何区别&#xff1f; 块级元素&#xff1a; 总是在新行上…

Centos7安装

想学Vmware安装可以看下下面链接,不想就算了 https://blog.csdn.net/weixin_43895362/article/details/134723073 选择第一项&#xff0c;安装直接CentOS 7&#xff0c;回车 稍等后出现进入下图,选择中文,这个只是安装时的语言 首先设置时间,时区选择上海&#xff0c;查看时…

JVM 类的加载

面试题&#xff1a; 简述 Java 类加载机制?&#xff08;百度&#xff09; JVM类加载机制 &#xff08;滴滴&#xff09; JVM中类加载机制&#xff0c;类加载过程&#xff0c;什么是双亲委派模型&#xff1f; &#xff08;腾讯&#xff09; JVM的类加…

【UE】射线检测与物品高亮显示

效果 步骤 1. 新建一个空白模板工程 2. 添加一个第一人称游戏内容包 3. 打开项目设置&#xff0c;创建一个新的通道检测 取消勾选“自动曝光” 4. 打开第一人称角色蓝图“BP_FirstPersonCharacter”&#xff0c;添加一个新图表&#xff0c;命名为“射线检测” 添加如下节点&a…

LeNet对MNIST 数据集中的图像进行分类--keras实现

我们将训练一个卷积神经网络来对 MNIST 数据库中的图像进行分类&#xff0c;可以与前面所提到的CNN实现对比CNN对 MNIST 数据库中的图像进行分类-CSDN博客 加载 MNIST 数据库 MNIST 是机器学习领域最著名的数据集之一。 它有 70,000 张手写数字图像 - 下载非常简单 - 图像尺…

CMMI认证含金量高吗

一、CMMI认证含金量解答 CMMI&#xff0c;即能力成熟度模型集成&#xff0c;是由美国卡内基梅隆大学软件工程研究所开发的一种评估企业软件开发过程成熟度的模型。CMMI认证的含金量究竟高不高呢&#xff1f;答案是肯定的。CMMI认证被誉为软件开发行业的“金牌标准”&#xff0…

vue循环v-for遍历图表

循环遍历图表 index.vue主页面 <view v-if"powerPage"><view v-for"(item, index) in powerDetailsData.addMap" :key"index"><PowerEChartsCity:echartData"powerDetailsData.addMap[index]"></PowerEChartsC…

经典神经网络——VGGNet模型论文详解及代码复现

论文地址&#xff1a;1409.1556.pdf。 (arxiv.org)&#xff1b;1409.1556.pdf (arxiv.org) 项目地址&#xff1a;Kaggle Code 一、背景 ImageNet Large Scale Visual Recognition Challenge 是李飞飞等人于2010年创办的图像识别挑战赛&#xff0c;自2010起连续举办8年&#xf…

Unity 关于SpriteRenderer 和正交相机缩放

float oldWidth 750f;float oldHeight 1334f;float newWidth Screen.width;float newHeight Screen.height;float oldAspect oldWidth / oldHeight;float newAspect newWidth / newHeight;//水平方向缩放float horizontalCompressionRatio newAspect / oldAspect;//垂直…

Python 中的 FileSystem Connector:打通文件系统的便捷通道

更多Python学习内容&#xff1a;ipengtao.com 大家好&#xff0c;我是涛哥&#xff0c;今天为大家分享 Python 中的 FileSystem Connector&#xff1a;打通文件系统的便捷通道&#xff0c;全文4100字&#xff0c;阅读大约11分钟。 在现代软件开发中&#xff0c;文件系统是不可或…

【Python表白系列】一起去看流星雨吧!(完整代码)

文章目录 流星雨环境需求完整代码详细分析系列文章流星雨 环境需求 python3.11.4PyCharm Community Edition 2023.2.5pyinstaller6.2.0(可选,这个库用于打包,使程序没有python环境也可以运行,如果想发给好朋友的话需要这个库哦~)【注】 python环境搭建请见:https://want5…

数据结构算法-选择排序算法

引言 说起排序算法&#xff0c;那可就多了去&#xff0c;首先了解什么叫排序 以B站为例&#xff1a; 蔡徐坤在B站很受欢迎呀&#xff0c;先来看一下综合排序 就是播放量和弹幕量&#xff0c;收藏量 一键三连 都很高这是通过一些排序算法 才能体现出综合排序 蔡徐坤鬼畜 按照播…

flutter-一个可以输入的数字增减器

效果 参考文章 代码 在参考文章上边&#xff0c;主要是改了一下样式&#xff0c;逻辑也比较清楚&#xff0c;对左右两边添加增减方法。 我在此基础上加了_numcontroller 输入框的监听。 加了数字输入框的控制 keyboardType: TextInputType.number, //设置键盘为数字 inputF…

异常处理啊

异常处理 异常 程序运行过程中&#xff0c;发生错误导致异常退出&#xff08;不是程序的语法问题&#xff0c;而是代码的逻辑问题&#xff0c;编译不出错&#xff09;。 e.g. string 字符串&#xff0c;使用 at 函数访问其中的字符元素时&#xff0c;如果越界&#xff0c;程…
最新文章