> ~/.termux/termux.p_termux换dns">
赞
踩
之前termux手册未下载完整版Linux,导致部分python功能用不了,比如opencv,折腾了好久都不成功。这里安装了一个只有31M的ubuntu,再安装opencv,so easy。配置如下:
# 映射文件 termux-setup-storage # 这里在termux home里建一个快捷方式 mkdir /sdcard/termux ln -s /sdcard/termux ~/data # 模拟root环境 # termux-chroot # 更换国内源 termux-change-repo apt update -y apt upgrade -y # 定制按钮 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 # 修改问候语 vim $PREFIX/etc/motd
pkg install openssh -y
# 设置密码
passwd
# 启动ssh
sshd
ssh user@host -p 8022
# 杀死ssh
pkill sshd
# 安装常用工具 apt install vim git curl wget tree nmap zip -y # 安装 zsh apt 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 git clone git://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/plugins/zsh-autosuggestions vim /data/data/com.termux/files/home/.oh-my-zsh/templates/zshrc.zsh-template export TERMUX_HOME=/data/data/com.termux/files export PATH=$PATH:$TERMUX_HOME/usr/bin:. export ZSH=$TERMUX_HOME/home/.oh-my-zsh plugins=(其他的插件 zsh-autosuggestions) # 启用oh-my-zsh cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc chsh -s zsh
# 安装ubuntu apt install proot-distro -y proot-distro install ubuntu # 登录 ubuntu proot-distro login ubuntu # 配置oh-my-zsh, 复制上面配置配置好的即可 cp /data/data/com.termux/files/home/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc chsh -s /data/data/com.termux/files/usr/bin/zsh # 修改dns echo 'nameserver 114.114.114.114' > /etc/resolv.conf echo 'nameserver 8.8.8.8' >> /etc/resolv.conf # 更换源 # https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu-ports/ cp /etc/apt/sources.list /etc/apt/sources.list.bak echo 'deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ hirsute main restricted universe multiverse' > /etc/apt/sources.list apt update -y # 安装ca-certificates,以使用https apt install ca-certificates -y echo 'deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ hirsute main restricted universe multiverse' > /etc/apt/sources.list echo 'deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ hirsute-updates main restricted universe multiverse' >> /etc/apt/sources.list echo 'deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ hirsute-backports main restricted universe multiverse' >> /etc/apt/sources.list echo 'deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ hirsute-security main restricted universe multiverse' >> /etc/apt/sources.list apt update -y apt upgrade -y
apt install python3 python3-pip -y python3 -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple pip install ipython -i https://pypi.tuna.tsinghua.edu.cn/simple # 安装 jupyter pip install jupyter -i https://pypi.tuna.tsinghua.edu.cn/simple pip install jupyterlab -i https://pypi.tuna.tsinghua.edu.cn/simple # 设置jupyter远程登录密码 # 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 --allow-root>/dev/null 2>&1 & # 其他模块 pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple pip install scipy -i https://pypi.tuna.tsinghua.edu.cn/simple pip install pandas -i https://pypi.tuna.tsinghua.edu.cn/simple pip install pillow -i https://pypi.tuna.tsinghua.edu.cn/simple pip install matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple # opencv依赖 apt install libgl1-mesa-glx -y pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple
# 解决中文乱码
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/ # 安装 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 # 安装logo工具 pkg install figlet ls $PREFIX/share/figlet figlet -f shadow 'UNIHOU' | | \ |_ _| | | _ \ | | | | \ | | | | | | | | | | |\ | | ___ | | | | | \___/ _| \_|___|_| _|\___/ \___/
# 备份termux
cd /data/data/com.termux/files
tar -zcf /sdcard/termux/termux-backup.tar.gz home usr
# 恢复termux
termux-setup-storage
cd /data/data/com.termux/files
tar -zxf /sdcard/termux/termux-backup.tar.gz --recursive-unlink --preserve-permissions
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。