目次
Termux - Android用ターミナル & Linux環境
本家: Termux
ソースコード: termux/termux-app: Android terminal and Linux environment - app repository.
Wiki: Termux Wiki
Welcome to Termux! Wiki: https://wiki.termux.com Community forum: https://termux.com/community Gitter chat: https://gitter.im/termux/termux IRC channel: #termux on freenode Working with packages: * Search packages: pkg search <query> * Install a package: pkg install <package> * Upgrade packages: pkg upgrade Subscribing to additional repositories: * Root: pkg install root-repo * Unstable: pkg install unstable-repo * X11: pkg install x11-repo Report issues at https://termux.com/issues $
デバイスストレージのアクセス許可設定
ホームディレクトリ ~/ は /data/data/com.termux/files/home である。
$ pwd
/data/data/com.termux/files/home
$ termux-setup-storage $ ls -al
total 16 drwx------ 3 u0_a205 u0_a205 4096 Jul 6 10:06 . drwx------ 4 u0_a205 u0_a205 4096 Jul 6 09:48 .. -rw------- 1 u0_a205 u0_a205 79 Jul 6 10:06 .bash_history drwx------ 2 u0_a205 u0_a205 4096 Jul 6 10:06 storage
Vim
インストール
$ pkg install vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
vim-runtime
The following NEW packages will be installed:
vim vim-runtime
0 upgraded, 2 newly installed, 0 to remove and 8 not upgraded.
Need to get 5094 kB of archives.
After this operation, 25.8 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 https://dl.bintray.com/termux/termux-packages-24 stable/main aarch64 vim-runtime all 8.2.1000 [4165 kB]
Get:2 https://dl.bintray.com/termux/termux-packages-24 stable/main aarch64 vim aarch64 8.2.1000 [929 kB]
Fetched 5094 kB in 8s (622 kB/s)
Selecting previously unselected package vim-runtime.
(Reading database ... 4232 files and directories currently installed.)
Preparing to unpack .../vim-runtime_8.2.1000_all.deb ...
Unpacking vim-runtime (8.2.1000) ...
Selecting previously unselected package vim.
Preparing to unpack .../vim_8.2.1000_aarch64.deb ...
Unpacking vim (8.2.1000) ...
Setting up vim-runtime (8.2.1000) ...
Setting up vim (8.2.1000) ...
update-alternatives: using /data/data/com.termux/files/usr/bin/vim to provide /data/data/com.termux/files/usr/bin/editor (editor) in auto mode
OpenSSH
インストール
$ pkg install openssh
Ign:2 https://dl.bintray.com/grimler/game-packages-24 games InRelease Ign:3 https://dl.bintray.com/grimler/science-packages-24 science InRelease Ign:1 https://dl.bintray.com/termux/termux-packages-24 stable InRelease Get:5 https://dl.bintray.com/grimler/game-packages-24 games Release [5344 B] Hit:5 https://dl.bintray.com/grimler/game-packages-24 games Release Get:7 https://dl.bintray.com/grimler/science-packages-24 science Release [6191 B] Hit:7 https://dl.bintray.com/grimler/science-packages-24 science Release Get:4 https://dl.bintray.com/termux/termux-packages-24 stable Release [8255 B] Hit:4 https://dl.bintray.com/termux/termux-packages-24 stable Release Reading package lists... Done Building dependency tree... Done 8 packages can be upgraded. Run 'apt list --upgradable' to see them. Reading package lists... Done Building dependency tree... Done The following additional packages will be installed: krb5 ldns libdb libedit termux-auth The following NEW packages will be installed: krb5 ldns libdb libedit openssh termux-auth 0 upgraded, 6 newly installed, 0 to remove and 8 not upgraded. Need to get 2221 kB of archives. After this operation, 13.7 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 https://dl.bintray.com/termux/termux-packages-24 stable/main aarch64 libdb aarch64 18.1.40 [461 kB] Get:2 https://dl.bintray.com/termux/termux-packages-24 stable/main aarch64 krb5 aarch64 1.18.2-1 [832 kB] Get:3 https://dl.bintray.com/termux/termux-packages-24 stable/main aarch64 ldns aarch64 1.7.1-1 [260 kB] Get:4 https://dl.bintray.com/termux/termux-packages-24 stable/main aarch64 libedit aarch64 20191231-3.1-0 [71.6 kB] Get:5 https://dl.bintray.com/termux/termux-packages-24 stable/main aarch64 termux-auth aarch64 1.3 [5982 B] Get:6 https://dl.bintray.com/termux/termux-packages-24 stable/main aarch64 openssh aarch64 8.3p1 [591 kB] Fetched 2221 kB in 6s (358 kB/s) Selecting previously unselected package libdb. (Reading database ... 3434 files and directories currently installed.) Preparing to unpack .../0-libdb_18.1.40_aarch64.deb ... Unpacking libdb (18.1.40) ... Selecting previously unselected package krb5. Preparing to unpack .../1-krb5_1.18.2-1_aarch64.deb ... Unpacking krb5 (1.18.2-1) ... Selecting previously unselected package ldns. Preparing to unpack .../2-ldns_1.7.1-1_aarch64.deb ... Unpacking ldns (1.7.1-1) ... Selecting previously unselected package libedit. Preparing to unpack .../3-libedit_20191231-3.1-0_aarch64.deb ... Unpacking libedit (20191231-3.1-0) ... Selecting previously unselected package termux-auth. Preparing to unpack .../4-termux-auth_1.3_aarch64.deb ... Unpacking termux-auth (1.3) ... Selecting previously unselected package openssh. Preparing to unpack .../5-openssh_8.3p1_aarch64.deb ... Unpacking openssh (8.3p1) ... Setting up libedit (20191231-3.1-0) ... Setting up ldns (1.7.1-1) ... Setting up termux-auth (1.3) ... Setting up libdb (18.1.40) ... Setting up krb5 (1.18.2-1) ... Setting up openssh (8.3p1) ... Generating public/private rsa key pair. Your identification has been saved in /data/data/com.termux/files/usr/etc/ssh/ssh_host_rsa_key Your public key has been saved in /data/data/com.termux/files/usr/etc/ssh/ssh_host_rsa_key.pub The key fingerprint is: SHA256:2/Tl5jidpVyRRUpmLbR/x9G9ZolYngmJ4t/rioYRtUA u0_a205@localhost The key's randomart image is: +---[RSA 3072]----+ | .E .=o.| | . . . .+.o=| | o... o .oo=| | .... = +=+| | ..S .. =.=*| | . .+.. oo =| | o .....oo= | | . .. o+= | | .. .oo... | +----[SHA256]-----+ Generating public/private dsa key pair. Your identification has been saved in /data/data/com.termux/files/usr/etc/ssh/ssh_host_dsa_key Your public key has been saved in /data/data/com.termux/files/usr/etc/ssh/ssh_host_dsa_key.pub The key fingerprint is: SHA256:pam8zFpitPRKnj/znoshCWwFe/CzN5mmUBTZUJERY+I u0_a205@localhost The key's randomart image is: +---[DSA 1024]----+ | o =*B= | | B.oo. | | . E . | | . + o o + | | = + * S | | . = O o | | O * | | + Oo+ . | | =o*==. | +----[SHA256]-----+ Generating public/private ecdsa key pair. Your identification has been saved in /data/data/com.termux/files/usr/etc/ssh/ssh_host_ecdsa_key Your public key has been saved in /data/data/com.termux/files/usr/etc/ssh/ssh_host_ecdsa_key.pub The key fingerprint is: SHA256:RAfIbreWm+2F4kH7bh6k1IEKzfFlFxvCz7t3zEM81XE u0_a205@localhost The key's randomart image is: +---[ECDSA 256]---+ | ...oo= +. | | oo+ =.o o .E| | ..o + .o. +| | .oo.. .o o| | ...Soo .. .| | o++ .. + | | .=+o ...o.| | .o+oo. ..+| | .== . ..| +----[SHA256]-----+ Generating public/private ed25519 key pair. Your identification has been saved in /data/data/com.termux/files/usr/etc/ssh/ssh_host_ed25519_key Your public key has been saved in /data/data/com.termux/files/usr/etc/ssh/ssh_host_ed25519_key.pub The key fingerprint is: SHA256:4IRVzHLcB8/uOsSgByHgabgWg3Dx1/BZu8iiym+QcpE u0_a205@localhost The key's randomart image is: +--[ED25519 256]--+ |. +o o=..o. | |o+ o.oo+=o.+. | |oo+.o.+++ ..o | | oE +.o.. o | |.. o ooSo. . | |o + .... o. | | o .. . . . | | . .. .. | | oo. .. | +----[SHA256]-----+
現在のユーザーを調べる
$ id
uid=10205(u0_a205) gid=10205(u0_a205) groups=10205(u0_a205),3003(inet),9997(everybody),20205(u0_a205_cache),50205(all_a205)
パスワードの変更
$ passwd
New password:
Retype new password:
New password was successfully set.
Android の IP アドレスを調べる
$ ifconfig wlan0
以下の例では Android 側の IP アドレスは 192.168.43.235 である。
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.43.235 netmask 255.255.255.0 broadcast 192.168.43.255 inet6 fe80::e9d:92ff:fed9:b336 prefixlen 64 scopeid 0x20<link> unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 3000 (UNSPEC) RX packets 2 bytes 248 (248.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 15200979 bytes 2068367171 (1.9 GiB) TX errors 0 dropped 294 overruns 0 carrier 0 collisions 0
sshd の起動
$ sshd
$
PC 側から接続
$ ssh u0_a205@192.168.43.235 -p 8022
u0_a205@192.168.43.235's password: <- 設定したパスワードを入力 Welcome to Termux! Wiki: https://wiki.termux.com Community forum: https://termux.com/community Gitter chat: https://gitter.im/termux/termux IRC channel: #termux on freenode Working with packages: * Search packages: pkg search <query> * Install a package: pkg install <package> * Upgrade packages: pkg upgrade Subscribing to additional repositories: * Root: pkg install root-repo * Unstable: pkg install unstable-repo * X11: pkg install x11-repo Report issues at https://termux.com/issues $
bash の alias 設定
Fedora 風に bash の alias を設定する。
$ vi ~/.bashrc
- ~/.bashrc
alias diff='diff --color=auto' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias xzegrep='xzegrep --color=auto' alias xzfgrep='xzfgrep --color=auto' alias xzgrep='xzgrep --color=auto' alias zegrep='zegrep --color=auto' alias zfgrep='zfgrep --color=auto' alias zgrep='zgrep --color=auto'
.bashrc を読み込んで設定を反映する。
$ . ~/.bashrc $ alias
alias diff='diff --color=auto' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias xzegrep='xzegrep --color=auto' alias xzfgrep='xzfgrep --color=auto' alias xzgrep='xzgrep --color=auto' alias zegrep='zegrep --color=auto' alias zfgrep='zfgrep --color=auto' alias zgrep='zgrep --color=auto'
ll を実行する。
$ ll
total 4 drwx------ 2 u0_a205 u0_a205 4096 Jul 6 10:06 storage
gatling
gatling/stable 0.15 aarch64 A high performance http, ftp and smb server $ pkg install gatling Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: gatling 0 upgraded, 1 newly installed, 0 to remove and 51 not upgraded. Need to get 96.2 kB of archives. After this operation, 418 kB of additional disk space will be used. Get:1 https://dl.bintray.com/termux/termux-packages-24 stable/main aarch64 gatling aarch64 0.15 [96.2 kB] Fetched 96.2 kB in 2s (35.7 kB/s) Selecting previously unselected package gatling. (Reading database ... 5637 files and directories currently installed.) Preparing to unpack .../gatling_0.15_aarch64.deb ... Unpacking gatling (0.15) ... Setting up gatling (0.15) ...