lisz-works

プログラミングと興味を貴方に

TermuxにUbuntuを入れてAndroidでUbuntuする!

【スポンサーリンク】

Termux

こんにちは、lisです!

Android端末でターミナルがいじれちゃうTermux。

こいつにUbuntuをセットアップしてみました!

ubuntu-in-termuxのインストール手順

こちらのInstallation stepsに従います。

  1. Update termux: apt-get update && apt-get upgrade -y
  2. Install wget: apt-get install wget -y
  3. Install proot: apt-get install proot -y
  4. Install git: apt-get install git -y
  5. Go to HOME folder: cd ~
  6. Download script: git clone https://github.com/MFDGaming/ubuntu-in-termux.git
  7. Go to script folder: cd ubuntu-in-termux
  8. Give execution permission: chmod +x ubuntu.sh
  9. Run the script: ./ubuntu.sh -y
  10. Now just start ubuntu: ./startubuntu.sh

Ubuntuのセットアップ

$ apt update && apt -y upgrade
$ apt install -y wget proot git
$ cd ~
$ git clone https://github.com/MFDGaming/ubuntu-in-termux.git
$ cd ubuntu-in-termux
$ ls
README.md  startubuntu.sh  ubuntu-binds  ubuntu-fs  ubuntu.sh
$ chmod +x ubuntu.sh
$ ./ubuntu.sh -y
[02:56:24 PM] [Installer thread/INFO]:  Downloading the ubuntu rootfs, please wait...
[02:56:24 PM] [Installer thread/INFO]:  Download complete!
[02:56:24 PM] [Installer thread/INFO]:  Decompressing the ubuntu rootfs, please wait...
tar: usr/bin/bzcat: Cannot hard link to ‘usr/bin/bunzip2’: Permission denied
tar: usr/bin/bzip2: Cannot hard link to ‘usr/bin/bunzip2’: Permission denied
tar: usr/bin/perl5.30.0: Cannot hard link to ‘usr/bin/perl’: Permission denied
tar: usr/bin/uncompress: Cannot hard link to ‘usr/bin/gunzip’: Permission denied
tar: Exiting with failure status due to previous errors
[02:56:24 PM] [Installer thread/INFO]:  The ubuntu rootfs have been successfully decompressed!
[02:56:24 PM] [Installer thread/INFO]:  Fixing the resolv.conf, so that you have access to the internet
[02:56:24 PM] [Installer thread/INFO]:  Writing stubs, please wait...
[02:56:24 PM] [Installer thread/INFO]:  Successfully wrote stubs!
[02:56:24 PM] [Installer thread/INFO]:  Creating the start script, please wait...
[02:56:24 PM] [Installer thread/INFO]:  The start script has been successfully created!
[02:56:24 PM] [Installer thread/INFO]:  Fixing shebang of startubuntu.sh, please wait...
[02:56:24 PM] [Installer thread/INFO]:  Successfully fixed shebang of startubuntu.sh!
[02:56:24 PM] [Installer thread/INFO]:  Making startubuntu.sh executable please wait...
[02:56:24 PM] [Installer thread/INFO]:  Successfully made startubuntu.sh executable
[02:56:24 PM] [Installer thread/INFO]:  Cleaning up please wait...
[02:56:24 PM] [Installer thread/INFO]:  Successfully cleaned up!
[02:56:24 PM] [Installer thread/INFO]:  The installation has been completed! You can now launch Ubuntu with ./startubuntu.sh
$ ./startubuntu.sh
root@localhost:~#

Ubuntuのバージョン確認

# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

.bashrcにUbuntu起動設定

Termuxの~/.bashrcにこれを追加。

~/ubuntu-in-termux/startubuntu.sh

Termuxから見たUbuntuのディレクトリ配置

インストール時に配置していたubuntu-in-termuxがありますね。

この中のubuntu-fsが、Ubuntuからみたルートディレクトリ(/相当)となります。

次にホームディレクトリについて。

~/ubuntu-in-termux/startubuntu.shでUbuntuに入った場合、rootユーザになっています。

なので、temuxから見ると~/ubuntu-in-termux/ubuntu-fs/rootがUbuntuのホームディレクトリです。

参考

コチラを参考にしました。ありがとうございました!

github.com

zenn.dev

あとがき

TermuxにUbuntuを入れてAndroidでUbuntuするでした!

最近スマホを買い替えたので前のスマホ Xperia XZ Premiumにセットアップしてみました!

お遊び用端末となったこいつで遊んでやるぜ……

www.lisz-works.com

www.lisz-works.com

www.lisz-works.com