2020-08-12

启用Windows10的Linux子系统并安装图形界面

 

参考来自:https://www.cnblogs.com/oboth-zl/p/10315500.html

有些在我这里出问题,加了一些操作细节

安装Linux子系统

目前windows应用商店为win10 提供了多款Linux发行版本,包括Ubuntu、Debian、OpenSUSE等。

这里我安装的Ubuntu系统是bionic,18.04。

1、准备工作

    在控制面版中启用Linux子系统,在设置-更新和安全中-开发者选项中切换到开发人员模式

2、开始安装

在Windows应用商店安装一个Linux发行版本,选择的Ubuntu。安装完成后可以在开始菜单找到,点击即可打开。

第一次进入需等待安装完成。如果以前有安装过1804, 会出现错误,我这里重启一次就可以继续安装了。不重启的话始终存在一个错误,导致无法安装ubuntu子系统。

根据提示,设置用户名和密码。

 设置完成,进入系统。

 若需要使用root用户,可通过sudo passwd设置root的密码。

 接下来是把软件源修改为国内,因为默认官方源服务器在国外,访问太慢。当然你也可以选择跳过这一步,前提是你不嫌下载软件慢。

源的修改有两种方式:

  1. 通过修改源列表,即/etc/apt/sources.list。

      deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

      deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

      deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

      deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

      deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

      deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

      deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

      deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

      deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

      deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

也可以修改为清华大学或者阿里云的服务器源。

    apt-get update

3. 安装图形界面

    对于Linux来说使用shell命令行完全满足大部分场景的使用。但是某些情况还是需要图形界面,比如查看图片、视频,浏览网页,UI设计等,这也是我折腾图形界面的原因。

    1、安装必要软件包

    可以通过执行sudo dpkg-reconfigure locales 选择zh-CN.UTF-8将系统切换为中文环境。

   安装桌面、语言包、字体包、输入法等必要软件。


这里选择的是lxde轻量化桌面,个人比较推荐,当然也可以选择xfce,lxqt等其他桌面。使用下面的命令来装轻量级卓桌面

apt-get update

apt-get gedit

apt install fcitx fcitx-googlepinyin

apt install language-pack-gnome-zh-hans

apt install fonts-wqy-zenhei

apt install xorg

apt install lubuntu-core

apt install lxde


尽然鼓捣坏apt,鼓捣坏apt-get ,或者apt-get 出问题的解决办法:

 wget http://security.ubuntu.com/ubuntu/pool/main/a/apt/apt_1.9.4ubuntu0.1_amd64.deb

dpkg -i apt_1.9.4ubuntu0.1_amd64.deb


2、安装远程桌面软件(tigervnc)

    受限于Linux子系统实现原理,图形界面无法直接输出到显示器。

   这里选择vnc远程桌面来解决,当然你也可以选择其他远程桌面方案。

    1)首先下载安装程序:

      wget https://bintray.com/tigervnc/stable/download_file?file_path=tigervnc-1.9.0.x86_64.tar.gz

     ls

       tar -xf download_file?file_path=tigervnc-1.9.0.x86_64.tar.gz

      cd tigervnc-1.9.0.x86_64

      cd usr/bin/

      vncserver:0# 这里还无法启动,这是由于没有安装vnc4server

    2)安装vnc4server

        apt-get install vnc4server tightvncserver

        New 'X' desktop is DESKTOP-xxxxx:1

        Creating default startup script /root/.vnc/xstartup

        Starting applications specified in /root/.vnc/xstartup

        Log file is /root/.vnc/DESKTOP-写文章-CSDN博客.htm:1.log

        vim  /root/.vnc/xstartup

        加入startlxde&

        :wq保存并退出

        3)启动vnc4server

        # vnc4server

        root用户的桌面1和2

New 'DESKTOP-xxxx:2 (root)' desktop is DESKTOP-LP76EKU:2

Starting applications specified in /root/.vnc/xstartup

Log file is /root/.vnc/DESKTOP- xxxx :2.log

You will require a password to access your desktops.

Password:

Verify:

Passwords don't match - try again

Password:

Verify:

Password too long - only the first 8 characters will be used

xauth:  file /root/.Xauthority does not exist

New 'X' desktop is DESKTOP-LP76EKU:1

Creating default startup script /root/.vnc/xstartup

Starting applications specified in /root/.vnc/xstartup

Log file is /root/.vnc/DESKTOP-xxxx:1.log

.vnc中的目录

root@DESKTOP-xxxx:~/.vnc# ls

DESKTOP-xxxx:1.log  DESKTOP-xxxx:1.pid  DESKTOP-xxxx:2.log  DESKTOP-xxxx:2.pid  passwd  xstartup

重启vnc4server

$ vnc4server -kill :1
$vnc4server

注意:“-kill”和“:1”之间有空格

一般用户的桌面,DESKTOP-xxxx:3

~$ vnc4server

You will require a password to access your desktops.

Password:

Verify:

Password too long - only the first 8 characters will be used

xauth:  file /home/xxxx/.Xauthority does not exist

New 'DESKTOP-xxxx:3 (oxxxx)' desktop is DESKTOP-xxxx:3

Creating default startup script /home/oxxxx/.vnc/xstartup

Starting applications specified in /home/oxxxx/.vnc/xstartup

Log file is /home/ocnzhao/.vnc/DESKTOP-xxxx:3.log

Xvnc Free Edition 4.1.1 - built Feb 25 2015 23:02:21

Copyright (C) 2002-2005 RealVNC Ltd.

See http://www.realvnc.com for information on VNC.

Underlying X server release 40300000, The XFree86 Project, Inc

Wed Aug 12 11:57:38 2020

 vncext:      VNC extension running!

 vncext:      Listening for VNC connections on port 5903

 vncext:      created VNC server for screen 0

error opening security policy file /etc/X11/xserver/SecurityPolicy

Could not init font path element /usr/X11R6/lib/X11/fonts/Type1/, removing from list!

Could not init font path element /usr/X11R6/lib/X11/fonts/Speedo/, removing from list!

Could not init font path element /usr/X11R6/lib/X11/fonts/misc/, removing from list!

Could not init font path element /usr/X11R6/lib/X11/fonts/75dpi/, removing from list!

Could not init font path element /usr/X11R6/lib/X11/fonts/100dpi/, removing from list!

Could not init font path element /usr/share/fonts/X11/75dpi/, removing from list!

Could not init font path element /usr/share/fonts/X11/100dpi/, removing from list!

Obt-Message: XKB extension is not present on the server or too old

Obt-Message: Xinerama extension is not present on the server

Xlib:  extension "XInputExtension" missing on display ":3".

# Failed to parse arguments: Unknown option --login

See vncserver and Xtightvnc manual pages for more information.

 vncserver :0不行

New 'X' desktop is DESKTOP-xxxx:0

Starting applications specified in /root/.vnc/xstartup

Log file is /root/.vnc/DESKTOP-写文章-CSDN博客.htm:0.log


win下的壁纸路径C:\Windows\Web\Wallpaper挑几张好的复制过去

cd /mnt/c/Windows/Web/Screen

cp *.* /etc/alternatives

然后在vnc中选择一张壁纸即可.


# cd .vnc

root@DESKTOP-xxxx:~/.vnc# ls

DESKTOP-xxxx:0.log  DESKTOP-xxxx:0.pid  DESKTOP-xxxx:1.log  DESKTOP-xxxx:2.log  passwd  xstartup

root@DESKTOP-xxxx:~/.vnc# vncserver  :1

New 'X' desktop is DESKTOP-LP76EKU:1

Starting applications specified in /root/.vnc/xstartup

Log file is /root/.vnc/DESKTOP-xxxx:1.log


apt-get install firefox


Anaconda3安装

oxxxx@DESKTOP-xxxx:/mnt/v$ sh ./Anaconda3-2020.07-Linux-x86_64.sh

# PREFIX=/home/oxxxx/anaconda3

Preparing transaction: done

Executing transaction: done

installation finished.

Do you wish the installer to initialize Anaconda3

by running conda init? [yes|no]

[no] >>> yes

./Anaconda3-2020.07-Linux-x86_64.sh: 491: ./Anaconda3-2020.07-Linux-x86_64.sh: [[: not found

no change     /home/oxxxx/anaconda3/condabin/conda

no change     /home/oxxxx/anaconda3/bin/conda

no change     /home/oxxxx/anaconda3/bin/conda-env

no change     /home/oxxxx/anaconda3/bin/activate

no change     /home/oxxxx/anaconda3/bin/deactivate

no change     /home/oxxxx/anaconda3/etc/profile.d/conda.sh

no change     /home/oxxxx/anaconda3/etc/fish/conf.d/conda.fish

no change     /home/oxxxx/anaconda3/shell/condabin/Conda.psm1

no change     /home/oxxxx/anaconda3/shell/condabin/conda-hook.ps1

no change     /home/oxxxx/anaconda3/lib/python3.8/site-packages/xontrib/conda.xsh

no change     /home/oxxxx/anaconda3/etc/profile.d/conda.csh

modified      /home/oxxxx/.bashrc

==> For changes to take effect, close and re-open your current shell. <==

If you'd prefer that conda's base environment not be activated on startup,

   set the auto_activate_base parameter to false:

conda config --set auto_activate_base false

Thank you for installing Anaconda3!

===========================================================================

Working with Python and Jupyter notebooks is a breeze with PyCharm

Professional! Code completion, Notebook debugger, VCS support, SSH, Docker,

Databases, and more!

Get a free trial at: https://www.anaconda.com/pycharm


pycharm的安装

wget https://download.jetbrains.8686c.com/python/pycharm-community-2020.2.tar.gz

Unpack the PyCharm distribution archive that you downloaded

     where you wish to install the program. We will refer to this

     location as your {installation home}.

cd /mnt/v/pycharm-community-2020.2/bin

./pycharm.sh

     This will initialize various configuration files in the configuration directory:

     ~/.config/JetBrains/PyCharmCE2020.2.

  3. [OPTIONAL] Add "{installation home}/bin" to your PATH environment

     variable so that you can start PyCharm from any directory.

  4. [OPTIONAL] To adjust the value of the JVM heap size, create a file pycharm.vmoptions

     (or pycharm64.vmoptions if using a 64-bit JDK) in the configuration directory

     and set the -Xms and -Xmx parameters. To see how to do this,

     you can reference the vmoptions file under "{installation home}/bin" as a model

     but do not modify it, add your options to the new file.

  [OPTIONAL] Change the location of the "config" and "system" directories

  ------------------------------------------------------------------------------

  By default, PyCharm stores all your settings in the

  ~/.config/JetBrains/PyCharmCE2020.2 directory

  and uses ~/.local/share/JetBrains/PyCharmCE2020.2 as a data cache.

  To change the location of these directories:

  1. Open a console and cd into ~/.config/JetBrains/PyCharmCE2020.2

  2. Create a file idea.properties and set the idea.system.path and idea.config.path variables, for example:

     idea.system.path=~/custom/system

     idea.config.path=~/custom/config

  NOTE: Store the data cache ("system" directory) on a disk with at least 1 GB of free space.

Enjoy!

-PyCharm Development Team



分辨率调整

cvt 1680 900

apt install v86d  hwinfo

使用cvt命令生成 xorg.conf下的屏幕分辨率和刷新率(你的可以这样运行sudo cvt 1280 720 75)


远程屏幕大小设置
vim  /usr/bin/vncserver

$geometry="1280x1024"  --根据客户端电脑屏幕分辨率设置大小

#geometry="1400x900"

#geometry="1560x900" #还不够宽

#geometry="1680x900" # 这个差不多了

kill掉开启的远程

vncserver -kill :0

vncserver -kill :1

启动

vncserver :1

没使用xrandr调整VNC的分辨率,cvt处理出来也讲究能用了。


./pycharm.sh

任意路径打开pycharm.

在终端打开pycharm,然而,在终端打开还有一个问题,就是需要进入pycharm解压的文件夹下,进入bin目录,输入sh pycharm.sh才能打开,这就比较麻烦了。

所以我需要将这个路径也写到~/,bashrc里面,这样在任意路径下都可以直接输入pycharm.sh,就能打开pycharm了!

输入内容如下:

export PATH="/usr/local/bin:$PATH"

2020-08-12转存失败重新上传取消2020-08-12转存失败重新上传取消2020-08-12转存失败重新上传取消

上一篇:12C分库分表改造查询优化


下一篇:java Failed to determine a suitable driver class