win10下安装Debain Linux子系统

安装Linux子系统到指定文件夹下

描述:

  将Linux子系统安装到指定文件夹下。

方案:
  1. 在官网下载Debain;
  2. Debain.appx 改成Debain.zip,并解压此文件到指定文件夹;
  3. 在解压后的文件夹中执行debain.exe;
  4. 输入用户名和密码,即可完成安装。

使用Powershell命令请参考: How-to: Installing WSL manually on a non-system drive

修改颜色

描述:

  使用非系统盘安装Linux子系统,使用root登录,[root@DESKTOP]没有颜色,但是非root(admin)用户有颜色
  显示文件夹和文件颜色

截图:

win10下安装Debain Linux子系统_第1张图片

方案:
sudo su
cd ~    # cd /root  # 进入root家目录   
mv .bashrc .bashrc.bak #备份原来的文件
mv /home/admin/.bashrc .  # 将admin用户下的.bashrc拷贝到root用户下
source .bashrc  # 立即生效
vi .bashrc # 添加alias重命名
    #common alias  (设置文件夹颜色)
	export LS_OPTIONS='--color=auto'
	eval "`dircolors`"
	alias ls='ls $LS_OPTIONS'
	alias ll='ls -la'
	alias l='ls -lA'
	alias rm='rm -i'
	alias cp='cp -i'
	alias mv='mv -i'

.bashrc文件(主要是这些代码的作用)

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

添加右键菜单

描述:

  在右键菜单上添加一个Debain Bash Here (若写中文,请把文件保存成unicode编码格式,可以使用Notepadd++中的UTF-8-BOM编码)

截图:

win10下安装Debain Linux子系统_第2张图片

方案:

  注册表脚本(保存为DebianBash.reg)

Windows Registry Editor Version 5.00

; 删除此项
; [-HKEY_CLASSES_ROOT\Directory\Background\shell\OpenDebianHere]  

[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenDebianHere]
@="Debian Bash Here"
"Icon"="D:\\SubSystem\\Debian\\debian.exe"
;"Extended"=""    ; 按Shift键显示

[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenDebianHere\command]
@="D:\\SubSystem\\Debian\\debian.exe run"

查看安装位置

  1. 找到注册表HKEY_USERS\xxx\Software\Microsoft\Windows\CurrentVersion\Lxss 位置
  2. 查看 BasePath 即为安装路径
    win10下安装Debain Linux子系统_第3张图片

xxx为你当前用户在注册表中的代号:

  • S-1-5-18:代表SYSTEM
  • S-1-5-19:代表LocalService
  • S-1-5-20:代表NetworkService
  • S-1-5-21-…:代表当前用户

你可能感兴趣的:(Linux)