Windows Command Line - 适用于 Linux 的 Windows 子系统

Windows Command Line - 适用于 Linux 的 Windows 子系统

Windows Terminal, Console and Command-Line, Windows Subsystem for Linux, WSL
https://devblogs.microsoft.com/commandline/

1. Getting started with Windows Subsystem for Linux (WSL)

sudo apt update
sudo apt upgrade
yongqiang@yongqiang:~$ sudo apt update
Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:3 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu bionic-security InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
yongqiang@yongqiang:~$
yongqiang@yongqiang:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
yongqiang@yongqiang:~$

2. Windows Subsystem for Linux (WSL) 文件系统与 Windows 本地文件系统

  1. Windows Subsystem for Linux (WSL) 文件系统访问 Windows 本地文件系统

/mnt 目录下 cdef 文件夹,分别表示本地的 C 盘、D 盘、E 盘、F 盘,可以 cd 到相应目录下。

yongqiang@yongqiang:~$ cd /
yongqiang@yongqiang:/$ ll
total 112
drwxr-xr-x  1 root root    512 Apr 30 17:51 ./
drwxr-xr-x  1 root root    512 Apr 30 17:51 ../
drwxr-xr-x  1 root root    512 May  2 08:20 bin/
drwxr-xr-x  1 root root    512 Apr 17 00:06 boot/
drwxr-xr-x  1 root root    512 May  2 08:15 dev/
drwxr-xr-x  1 root root    512 May  2 08:20 etc/
drwxr-xr-x  1 root root    512 Apr 30 17:52 home/
-rwxr-xr-x  1 root root 112600 Jan  1  1970 init*
drwxr-xr-x  1 root root    512 Apr 16 23:58 lib/
drwxr-xr-x  1 root root    512 Apr 16 23:52 lib64/
drwxr-xr-x  1 root root    512 Apr 16 23:52 media/
drwxr-xr-x  1 root root    512 Apr 30 17:51 mnt/
drwxr-xr-x  1 root root    512 Apr 16 23:52 opt/
dr-xr-xr-x  9 root root      0 May  2 08:15 proc/
drwx------  1 root root    512 Apr 16 23:59 root/
drwxr-xr-x  1 root root    512 May  2 08:15 run/
drwxr-xr-x  1 root root    512 May  2 08:20 sbin/
drwxr-xr-x  1 root root    512 Oct 30  2019 snap/
drwxr-xr-x  1 root root    512 Apr 16 23:52 srv/
dr-xr-xr-x 12 root root      0 May  2 08:15 sys/
drwxrwxrwt  1 root root    512 May  2 08:21 tmp/
drwxr-xr-x  1 root root    512 Apr 16 23:52 usr/
drwxr-xr-x  1 root root    512 Apr 16 23:59 var/
yongqiang@yongqiang:/$ cd /mnt/
yongqiang@yongqiang:/mnt$ ls
c  d  e  f
yongqiang@yongqiang:/mnt$ ll
total 0
drwxr-xr-x 1 root      root       512 Apr 30 17:51 ./
drwxr-xr-x 1 root      root       512 Apr 30 17:51 ../
drwxrwxrwx 1 yongqiang yongqiang  512 Apr 30 17:48 c/
drwxrwxrwx 1 yongqiang yongqiang 4096 Apr 29 16:57 d/
drwxrwxrwx 1 yongqiang yongqiang 4096 Apr 29 16:57 e/
drwxrwxrwx 1 root      root       512 Apr 30 17:51 f/
yongqiang@yongqiang:/mnt$
yongqiang@yongqiang:/mnt$ cd d/
yongqiang@yongqiang:/mnt/d$ ll
ls: 'System Volume Information': Permission denied
total 0
drwxrwxrwx 1 yongqiang yongqiang 4096 Apr 28 12:35 '$RECYCLE.BIN'/
drwxrwxrwx 1 yongqiang yongqiang 4096 Apr 29 16:57  ./
drwxr-xr-x 1 root      root       512 Apr 30 17:51  ../
drwxrwxrwx 1 yongqiang yongqiang 4096 Apr 29 12:34 'Program Files'/
drwxrwxrwx 1 yongqiang yongqiang 4096 Apr 29 16:58 'Program Files (x86)'/
d--x--x--x 1 yongqiang yongqiang 4096 Apr 29 15:43 'System Volume Information'/
drwxrwxrwx 1 yongqiang yongqiang 4096 Apr 29 16:53  visual_studio_workspace/
yongqiang@yongqiang:/mnt/d$
yongqiang@yongqiang:/mnt/d$ cd ~
yongqiang@yongqiang:~$
  1. Windows 本地文件系统访问 Windows Subsystem for Linux (WSL) 文件系统 - 不推荐使用

C:\Users\cheng\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs

在这里插入图片描述

3. Windows Terminal, Console and Command-Line

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

4. python3

yongqiang@yongqiang:~$ python

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.

yongqiang@yongqiang:~$
yongqiang@yongqiang:~$ python3
Python 3.6.9 (default, Apr 18 2020, 01:56:04)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
yongqiang@yongqiang:~$
原创文章 532 获赞 1931 访问量 130万+

猜你喜欢

转载自blog.csdn.net/chengyq116/article/details/105886216