Win10 子系统 Ubuntu 18.04 LTS 简单配置

root 账号

初始化系统先设置 root 密码

sudo passwd root

切到 root 账户权限

su

切换语言到中文

这个根据喜好可以做也可以不做,个人比较喜欢中文提示,详见

https://lance.moe/post-319.html

时区调整

dpkg-reconfigure tzdata

SSH 配置

备份原始配置

cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak

编辑配置

vim /etc/ssh/sshd_config

修改如下几行

Port 8022                    # (22 端口默认被占用,此处更换为 8022 端口)
ListenAddress 0.0.0.0        # (监听端口0.0.0.0,解除注释,去掉前面的 #)
PermitRootLogin yes          # (允许 root 登陆,修改为 yes)
#StrictModes yes             # (严格模式,注释掉,在前面加上 #)
PasswordAuthentication yes   # (允许使用密码登陆,原来是 no 改成 yes)

Tips:vim 的用法

键盘上点击「i」键后进入插入模式,可对文本进行编辑

编辑完毕后按「ESC」键退出插入模式

输入「:wq」保存并退出

启动 SSH

service ssh start

如果提示 sshd error: could not load host key 则需要重新生成 key

dpkg-reconfigure openssh-server

此时 SSH 已经启动,可以在 Xshell 等工具中尝试登陆了

更换源列表 & 更新软件包

备份源列表

cp /etc/apt/sources.list /etc/apt/sources.list.bak

编辑源列表

vim /etc/apt/sources.list

博主在日本,所以切换成在日本比较快的源,国内的朋友可以使用阿里云的源,具体列表可以到网上寻找

#

# deb cdrom:[Ubuntu-Server 18.04 LTS _Bionic Beaver_ - Release amd64 (20180426)]/ bionic main restricted

#deb cdrom:[Ubuntu-Server 18.04 LTS _Bionic Beaver_ - Release amd64 (20180426)]/ bionic main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://jp.archive.ubuntu.com/ubuntu/ bionic main restricted
# deb-src http://jp.archive.ubuntu.com/ubuntu/ bionic main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://jp.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
# deb-src http://jp.archive.ubuntu.com/ubuntu/ bionic-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://jp.archive.ubuntu.com/ubuntu/ bionic universe
# deb-src http://jp.archive.ubuntu.com/ubuntu/ bionic universe
deb http://jp.archive.ubuntu.com/ubuntu/ bionic-updates universe
# deb-src http://jp.archive.ubuntu.com/ubuntu/ bionic-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://jp.archive.ubuntu.com/ubuntu/ bionic multiverse
# deb-src http://jp.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://jp.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
# deb-src http://jp.archive.ubuntu.com/ubuntu/ bionic-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://jp.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src http://jp.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partner

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

更新源列表,使新源生效

apt update

更新所有软件包

apt upgrade

删除已经失效的软件包

apt autoremove

0 Comments (98 Views)

Leave a Reply

Your email address will not be published. Required fields are marked *