更新国内源

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

pkg update -y
pkg upgrade -y

安装ssh访问

pkg install openssh termux-auth -y
# 设置密码
passwd
# 启动ssh
sshd
ssh user@host -p 8022
# 杀死ssh
pkill sshd

映射文件

pkg install -y termux-tools
termux-setup-storage

定制按钮

mkdir ~/.termux
echo "extra-keys = [ \\" >> ~/.termux/termux.properties
echo " ['ESC','|','/','HOME','UP','END','PGUP','DEL'], \\" >> ~/.termux/termux.properties
echo " ['TAB','CTRL','ALT','LEFT','DOWN','RIGHT','PGDN','BKSP'] \\" >> ~/.termux/termux.properties
echo "]" >> ~/.termux/termux.properties

支持蓝牙键盘输入

echo "enforce-char-based-input = true" >> ~/.termux/termux.properties

备份与恢复

# 备份termux
termux-setup-storage
cd /data/data/com.termux/files
tar -zcf /sdcard/termux-backup.tar.gz home usr
# 恢复termux
termux-setup-storage
cd /data/data/com.termux/files
tar -zxf /sdcard/termux-backup.tar.gz --recursive-unlink --preserve-permissions

修改问候语

# 安装logo工具
pkg install figlet
# 查看支持的logo类型
ls $PREFIX/share/figlet
# 这里输入类型 和 自定义的名称
figlet -f shadow 'UNIHOU'
# 修改问候语
vim $PREFIX/etc/motd
 |   |  \  |_ _| |   |  _ \  |   | 
 |   |   \ |  |  |   | |   | |   | 
 |   | |\  |  |  ___ | |   | |   | 
\___/ _| \_|___|_|  _|\___/ \___/  

模拟root环境

pkg install -y proot
termux-chroot

安装自动补全插件

# 安装 zsh
pkg install zsh -y
# 安装 oh-my-zsh,这里提供了两种方法,注释掉的为自动安装
# sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
git clone git://github.com/ohmyzsh/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
chsh -s zsh
# 安装自动补全插件
git clone git://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/plugins/zsh-autosuggestions
vim ~/.zshrc
	plugins=(其他的插件 zsh-autosuggestions)

安装常用工具

pkg install vim curl wget git tree nmap zip -y

vim相关

# 解决中文乱码
echo "set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1" >> ~/.vimrc
echo "set enc=utf8" >> ~/.vimrc
echo "set fencs=utf8,gbk,gb2312,gb18030" >> ~/.vimrc
# 显示行号
echo "set number" >> ~/.vimrc
source ~/.vimrc

# vim 粘贴不自动换行 
set paste
set nopaste

安装adb

cd ~/
git clone https://github.com/Magisk-Modules-Repo/adb-ndk.git
cd ./adb-ndk/bin/
mv -f adb.bin adb
chmod +x ./*
mv -f ./* /data/data/com.termux/files/usr/bin/
cd ~/
rm -rf adb-ndk/

安装开发环境

# 安装c
pkg install clang make -y
# 安装python
pkg install python -y
# 升级 pip3 -i 手动指定国内清华 pip 源 提高下载速度
python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
# 安装iPython 依赖clang
pip install ipython -i https://pypi.tuna.tsinghua.edu.cn/simple
# 安装 jupyter
pkg install libzmq -y
# pip install pyzmq -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install jupyter -i https://pypi.tuna.tsinghua.edu.cn/simple
# 安装 jupyterlab
pip install jupyterlab -i https://pypi.tuna.tsinghua.edu.cn/simple

# jupyter远程登录与设置密码
# jupyter notebook password


# python
# from notebook.auth import passwd
# passwd()

jupyter notebook --generate-config
vim .jupyter/jupyter_notebook_config.py
	# c.NotebookApp.password = '通过passwd()生成的密码'
	c.NotebookApp.allow_remote_access = True
	c.NotebookApp.ip='*'
	c.NotebookApp.open_browser = False
	# c.NotebookApp.port = 8888
	# c.NotebookApp.notebook_dir = "启动路径"

# 启动 notebook
nohup jupyter notebook >/dev/null 2>&1 &

# 安装numpy scipy
wget https://its-pointless.github.io/setup-pointless-repo.sh
bash setup-pointless-repo.sh
# numpy scipy 直接从这个仓库里装,很方便
pkg install numpy scipy

pip install pandas

# Pillow库依赖
export LDFLAGS="-L/system/lib64"
pkg install libjpeg-turbo libpng
pkg install zlib 
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pillow
# matplotlib库依赖
pkg install cmake freetype
pip install wheel
pip install kiwisolver cycler pyparsing python-dateutil 
# 安装matplotlib
pip install matplotlib==3.2.0

# 安装node
pkg install nodejs
# 切换镜像仓库
npm install -g nrm --registry=https://registry.npm.taobao.org
nrm ls
nrm use taobao

安装liunx

 pkg install proot-distro 
 proot-distro list
 proot-distro install <alias> 

安装 uiautomator2

pkg install libxml2 libxslt libjpeg-turbo -y
pip install --pre uiautomator2

安装qemu

pkg install x11-repo
pkg install qemu-common qemu-system-x86_64 qemu-utils
# 启动qemu
#qemu-img create -f raw hd0.img 10G
#qemu-system-x86_64 -hda hd0.img -cdrom /sdcard/BaiduNetdisk/winxp.iso -m 2048 -netdev user,id=user.0 -device rtl8139,netdev=user.0 -vga vmware -display vnc=:10
qemu-system-x86_64 -hda /sdcard/BaiduNetdisk/winxp.img -m 4096 -netdev user,id=user.0 -device rtl8139,netdev=user.0 -vga vmware -display vnc=:10

注:本文termux:0.117;手机小米10
本文参考了以下文章,感谢作者!
Termux 高级终端安装使用配置教程
使用Termux安装opencv
用termux安装adb和fastboot的教程,部分功能可以免root
Termux安装Matplotlib、Jupyter、Pandas、pyzmq

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐