wsl notes

Some problems ubuntu system under wsl summary!

references:

WSL practice to enhance the productivity of Windows 10

Installation sshd Raiders .md in wsl

surroundings

win10 environment under wsl install ubuntu

Modify the update source

  1. backup file

    sudo cp /etc/apt/sources.list  /etc/apt/sources.list.old
  2. Use Ali source

    open a file:

    sudo vi /etc/apt/sources.list

    Replace the entire file into Ali Source:

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

    sudo apt-get update
    sudo apt-get upgrade

New User

Linux to create, delete and change user information - adduser useradd usermod deluser

linux user management (1) ---- create a user (adduser and useradd) and delete users (userdel)

  • adduser user1

    ubuntu user to build the best use adduser, adduser and useradd though is the same as in other linux system which, but when I use useradd, did not create the user's home directory with the same name in ubuntu.

    # 新建用户,会创建同名的用户主目录
    adduser user1
    # ubuntu查看用户列表
    cat /etc/passwd
    # 用linux代替想要删除的用户账户, -r 表示连同用户主目录一块删除
    userdel -r user1
    # 查看是否正确删除用户:
    id user1

Setting a supervisor

The initial password su ubuntu

sudo passwd

Environment Variables

  • Different user environment variables are not shared

    # 所有用户都生效
    sudo vim  /etc/profile 
    source /etc/profile

    There is no exit after entry into force of the terminal!

  • Not exit the terminal after the entry into force

    # 当前用户生效
    sudo vim  ~/.bashrc   
    ## 在每个用户的 ~/.bashrc 添加 source /etc/profile 共享全局的path

zsh beautify terminal

Installation oh-my-zsh (Win10 + WSL or Ubuntu)

Zsh as the default shell set

chsh -s /bin/zsh # 设置 bash 同理 

PATH environment variable

After using zsh, environment variables need to be defined in ~ / .zshrc configuration file, / etc / profile is not in force

Open ssh remote connection

ubuntu ssh service comes under the wsl problems need to uninstall reinstall it again ssh service

# 重装 openssh-server
sudo apt-get remove openssh-server
sudo apt-get install openssh-server

# 修改 shd_config文件
sudo vi /etc/ssh/sshd_config
# Port 22 #默认即可,如果有端口占用可以自己修改
# PasswordAuthentication yes # 允许用户名密码方式登录
# PermitRootLogin yes # 允许管理员ssh登录

# 重启ssh服务
sudo service ssh restart

apt commands and questions

[ Ubuntu's apt command Detailed ]

  1. Search software
sudo  apt-cache  search  package_name
  1. WSL Ubuntu appears to solve E: Could not read response to hello message from hook ... problem

    Execute the following command

    sudo rm -rf /etc/apt/apt.conf.d/20snapd.conf

windows and access files from each other wsl

  • Open the file wsl

    Use explorer.exe, wsl the users can not use the handover command. . .

    explorer.exe .
  • Access windows files, use way to mount / mnt /

    cd /mnt/c/Users/Ben/Documents/

wsl not boot from the start ssh

Need to manually run wsl know about it:

sudo service ssh start

Because it is wsl interior is similar docker run, no systemd service

Reinstall python

  1. Check the python path:

    # 方式一:
    type -a python
    
    # 方式二:
    ls -l /usr/bin/python
    ls -l /usr/bin/python*
    
    # 方式三:
    which python
  2. Installation python2, python3

    # 安装python2
    $ sudo apt-get install python
    # 安装python3
    $ sudo apt-get install python3
    

Guess you like

Origin www.cnblogs.com/jarvankuo/p/11955057.html