Termux安卓上的Linux开发环境
⽬录
Termux 是⼀个 An d roid 下的终端模拟器,可以在⼿机上模拟 Linux 环境。它是⼀个⼿机 App,可以从应⽤商店直接下载安装,打开就能使⽤,它提供⼀个命令⾏界⾯,让⽤户与系统交互。它⽀持 apt 软件包管理,可以⼗分⽅便安装软件包,⽽且完美⽀持 Python、PHP、Ruby、Go、Nodejs、MySQL 等⼯具。
随着智能设备的普及和性能的不断提升,如今⼿机、平板等设备的硬件标准已经直逼⼊门级桌⾯计算机,使⽤ Ter m ux 完全可以把⼿机变成⼀个强⼤的⼩型服务器。
你甚⾄可以使⽤ Ter m ux 通过 Nmap、Sqlmap、BB S can、sub D o m ains B rute、Hy d ra、Router S ploit 等⼯具实现端⼝扫描、注⼊检测、⼦域名爆破、多协议弱⼝令爆破、路由器漏洞检测框架多种功能,把⼿机打造成⼀个随⾝携带的渗透神器,成为现实版的艾登·⽪尔斯。
1. 安装
Termux 是运⾏在 Android 上的 terminal。不需要root,运⾏于内部存储(不在SD卡上)。
⾃带了⼀个包管理器pkg,可以安装许多现代化的开发和系统维护⼯具。⽐如:
neovim
tmux
zsh
clang
gcc
python
weechat
irssi
注意:在Google和F-Droid上发布的安装包由于签名不同,并不能相互替换,尤其是在匹配其插件(如Termux-API)时,可能造成意外的错误。
插件列表:
API: ⽤于调⽤安卓的原⽣功能,如、拍照、GPS定位信息等
termux-share
termux-open-url
Termux:API
Access Android and Chrome hardware features.
Termux:Boot
Run script(s) when your device boots.
Termux:Float
Run Termux in a floating window.
Termux:Styling
Have color schemes and powerline-ready fonts customize the appearance of the Termux terminal.
Termux:Tasker
An easy way to call Termux executables from Tasker and compatible apps.
Termux:Widget
Start small scriptlets from the home screen.
2. 更新源
# The termux repository mirror from TUNA:
deb mirrors.tuna.tsinghua.edu/termux/termux-packages-24 stable main
# The termux repository mirror from TUNA:
deb mirrors.tuna.tsinghua.edu/termux/science-packages-24 science stable
# The termux repository mirror from TUNA:
deb mirrors.tuna.tsinghua.edu/termux/game-packages-24 games stable
然后执⾏pkg update,注意,提⽰更新系统命令时,选择n,否则会造成系统不稳定!
推荐安装以下软件:
pkg install openssh htop tsu proot git nano neofetch python
tsu:切换账户(root)
proot:⽆root权限执⾏需要root的命令
neofetch:查看系统信息
3. 系统配置
termux-setup-storage  # 获取对sdcard的读取权限
pkg install termux-services
pkg install termux-api
termux-wake-lock  # 息屏时保持Termux后台运⾏(否则cpu严重降速甚⾄ssh卡断)
4. 配置ssh
pkg install openssh
安装好之后,我们需要⼿⼯启动: sshd
需要指出的是, sshd 监听的是8022端⼝⽽不是22号端⼝,因此可以使⽤下⾯命令来验证ssh服务是否开启。ssh localhost -p 8022
若要查看sshd的⽇志,则可以在Termux上执⾏
logcat -s 'syslog:*'
为了⽅便,我们可以配置⼀下ssh client的配置⽂件,将下⾯内容加⼊到~/.ssh/config⽂件中:
Host termux
User u0_a171
HostName 192.168.31.145
Port 8022
这样只需要执⾏ ssh termux 就能登陆termx了。
5. Python库的安装
lxml:
pkg install libxml2 libxslt && pip install lxml
经测试,在0.73版本下,安装报错:
fatal error: 'iconv.h' file not found
解决⽅案:
pkg install libiconv
Pillow:
pkg install libjpeg-turbo && pip install pillow
经验证,还需要⼿动安装 zlib: pkg install zlib
numpy:
pip install numpy
pandas:
最新版本失败,但pip install pandas==1.0.5成功
6. 定制常⽤按键
在 Termux v0.66 的版本之后我们可以通过~/.termux/termux.properties⽂件来定制我们的常⽤功能按键,默认是不存在这个⽂件的,我们得⾃⼰配置创建⼀下这个⽂件。
下⾯做尝试简单配置⼀下这个⽂件:
extra-keys = [\
['CTRL','ALT','TAB','LEFT','RIGHT','|','/','UP','DOWN'],\
['ESC','SHIFT','HOME','END','DEL','PGUP','PGDN','BKSP']]
7. 默认程序
将运⾏脚本放于⽬录: ~/.shortcuts/
8. Termux:API
In Google Play Store, besides installing the Termux app, also install "Termux:API" app. This solves the hanging issue described below on Android 7.
To use Termux:API you also need to install the termux-api package.
pkg install termux-api
Current API implementations:
termux-battery-status
Get the status of the device battery.
termux-brightness
Set the screen brightness between 0 and 255.
termux-call-log
List call log history.
termux-camera-info
Get information about device camera(s).
termux-camera-photo
Take a photo and save it to a file in JPEG format.
termux-clipboard-get
Get the system clipboard text.
termux-clipboard-set
Set the system clipboard text.
termux-contact-list
List all contacts.
termux-dialog
Show a text entry dialog.
termux-download
Download a resource using the system download manager.
termux-fingerprint
Use fingerprint sensor on device to check for authentication.
termux-infrared-frequencies
Query the infrared transmitter's supported carrier frequencies.
termux-infrared-transmit
Transmit an infrared pattern.
termux-job-scheduler
Schedule a Termux script to run later, or periodically.
termux-location
Get the device location.
termux-media-player
Play media files.
termux-media-scan
MediaScanner interface, make file changes visible to Android Gallery
termux-microphone-record
Recording using microphone on your device.
termux-notification
Display a system notification.
termux-notification-remove
Remove a notification previously shown with termux-notification --id.
termux-sensor
Get information about types of sensors as well as live data.
termux-share
Share a file specified as argument or the text received on stdin.
termux-sms-list
List SMS messages.
termux-sms-send
Send a SMS message to the specified recipient number(s).
termux-storage-get
Request a file from the system and output it to the specified file.
termux-telephony-call
Call a telephony number.
termux-telephony-cellinfo
Get information about all observed cell information from all radios on the device including the primary and neighboring cells. termux-telephony-deviceinfo
Get information about the telephony device.
termux-toast
Show a transient popup notification.
termux-torch
Toggle LED Torch on device.
安卓软件签名工具termux-tts-engines
Get information about the available text-to-speech engines.
termux-tts-speak
Speak text with a system text-to-speech engine. termux-usb
List or access USB devices.
termux-vibrate
Vibrate the device.
termux-volume
Change volume of audio stream.
termux-wallpaper
Change wallpaper on your device.
termux-wifi-connectioninfo
Get information about the current wifi connection. termux-wifi-enable
Toggle Wi-Fi On/Off.
termux-wifi-scaninfo
Get information about the last wifi scan.

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。