安卓手机使用termux运行完整的linux环境

安装并运行完整Linux

  1. 下载termux…
  2. 将termux的软件源换成清华源(https://mirrors.tuna.tsinghua.edu.cn/help/termux/):
sed -i 's@^\(deb.*stable main\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/termux-packages-24 stable main@' $PREFIX/etc/apt/sources.list
sed -i 's@^\(deb.*games stable\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/game-packages-24 games stable@' $PREFIX/etc/apt/sources.list.d/game.list
sed -i 's@^\(deb.*science stable\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/science-packages-24 science stable@' $PREFIX/etc/apt/sources.list.d/science.list
apt update && apt upgrade
  1. 安装必要软件以模拟linux完整的文件系统环境:pkg i proot
    并开启模拟linux文件系统:termux-chroot
    (termux默认情况下并没有完整的linux文件环境,比如输入ls ~/..只能看到有 /home 和 /usr 两个文件夹,如果termux-chroot之后就能看到别的linux应该有的文件夹了)
  2. 安装atilo(项目地址:https://github.com/YadominJinta/atilo):
echo "deb [trusted=yes arch=all] https://yadominjinta.github.io/files/ termux extras" >> $PREFIX/etc/apt/sources.list.d/atilo.list
apt update && apt install atilo-cn
  1. 安装完整ubuntu镜像:atilo pull ubuntu
  2. 运行完整ubuntu镜像:atilo run ubuntu
  3. 将ubuntu的软件源换成清华源(https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu-ports/)
    使用清华源时使用HTTPS可有效避免国内运营商的缓存劫持,但需要事先安装 apt-transport-https:sudo apt install apt-transport-https
    操作前请做好相应备份
  4. 运行 sudo apt update更新索引以生效

安装openssh并使用电脑进行远程操作

  1. 进入termux为termux设置密码:passwd
  2. 为termux下载openssh:
pkg upgrade
pkg i openssh
  1. 开启ssh:sshd
  2. 在电脑端链接termux:ssh -P 8022 user@hostname_or_ip并按提示输入密码(termux的ssh-server默认使用8022端口)
    其中:user在termux中输入 whoami来查看
    hostname_or_ipip可在termux中输入 ifconfig来查看
  3. 可以愉快地玩耍了!
  • 3
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值