1,Win10安装Ubuntu

Win10需要用linux子系统WSL支持,WSL的开启方法如下:

PowerShell 下执行以下命令开启WSL功能:



Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux /all



普通命令行cmd下执行:



dism



在win10应用商店中可以直接搜索Ubuntu进行安装,如果没有应用商店,则需要手动安装。可以参考下方:


《手动下载适用于 Linux 的 Windows 子系统发行版包》docs.microsoft.com


ubuntu 22清华大学镜像 清华ubuntu源_ubuntu 修改home 目录


2, 给Ubuntu创建一个普通账户

由于路由器固件编译,不需要用到root账户,所以我们可以新建一个普通账户,Ubuntu中新建一个普通账户方法:

①创建一个名为admin的账户


sudo useradd -r -m -s /bin/bash admin


参数意义如下:
> -r:建立系统账号
-m:自动建立用户的登入目录
-s:指定用户登入后所使用的shell

输入 ls /home/ 可以看到用户目录被成功创建了。

②给admin账户创建密码为123456:


123456


③利用cat命令打开etc目录下面的passwd文件,可以在最后一行看到被新建的账户。


cat /etc/passwd


至此新建普通账户完成,使用su命令即可切换到admin账户登录


su admin


④修改用户权限

为admin这个账户添加sudo的权限,不然后面运行时会出现“xxx is not in the sudoers file.This incident will be reported” 的报错。

这里采用修改/etc/sudoers文件的方法分配用户权限。因为此文件只有r权限,在改动前需要增加w权限,改动后,再去掉w权限。


# 在 # User privilege specification下添加下方的配置语句


ubuntu 22清华大学镜像 清华ubuntu源_ubuntu 修改home 目录_02


3,更新Ubuntu软件源

由于Ubuntu的软件源更新是在国外,更新非常慢,所以需要将更新源替换为国内源。内有很多Ubuntu的镜像源,包括阿里的、网易的,还有很多教育网的源,比如:清华源、中科大源。

①首先备份软件源文件:


cp /etc/apt/sources.list /etc/apt/sources.list.bak_yyyymmdd


②使用vim命令修改源文件:

【vim的使用请参考:https://www.runoob.com/linux/linux-vim.htm


sudo vim /etc/apt/sources.list


打开/etc/apt/sources.list文件之后,按键盘上的 i 键进入编辑模式,在文件最前面添加以下条目:


#添加阿里源
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


添加完条目之后,按以下esc键退出编辑模式,并输入键盘上的 :键切换到底线命令模式,再输入wq保存并退出。

③进行源更新,输入以下两条命令:


sudo apt-get update
sudo apt-get upgrade


④其他国内的源:


##中科大源
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse


4,获取OpenWrt的源码

这里推荐两个大神的源码,一个是Lean,还有一个是ptpt52基于OpenWrt项目做了许多易用性改进的X-WRT。

Lean:

https://github.com/coolsnowwolf/ledegithub.com


X-WRT:

x-wrt/x-wrtgithub.com


ubuntu 22清华大学镜像 清华ubuntu源_ubuntu 修改home 目录_03


5,编译教程

上面两位大神都给出了编译的操作过程,经过前面的准备,接下来只要按照大神给出的代码就可以进行编译了。

这里先推荐X-WRT的编译教程,写的比较详细:

编译教程blog.x-wrt.com

ubuntu 22清华大学镜像 清华ubuntu源_ubuntu 修改home 目录_04


按照上面的链接进行编译,基本都会成功。如果不成功那就需要仔细检查哪里出了问题。如果上面的编译成功了,那就可以继续参考Lean的教程编译Lean的OpenWrt固件。

教程地址依然是:

coolsnowwolf/ledegithub.com

ubuntu 22清华大学镜像 清华ubuntu源_ubuntu 修改home 目录_05


如果还不清楚如何编译,那就参考下方由B站up主梦程MI上传的视频教程。

6,编译视频教程