华为麦芒5(安卓6)termux记录 使用ddns-go,alist

下载0.119bate1 安卓5和6版本,不能换源,其他源似乎都用不了,如果root可以直接用面具模块
https://github.com/termux/termux-app/releases/download/v0.119.0-beta.1/termux-app_v0.119.0-beta.1+apt-android-5-github-debug_arm64-v8a.apk

安装ssh(非必要)

bash 复制代码
pkg install openssh

开启ssh

bash 复制代码
sshd

如果连接ssh报错

bash 复制代码
Connection to 192.168.3.105 closed by remote host.
Connection to 192.168.3.105 closed.

关闭sulinux(或换旧版)

bash 复制代码
# 以下命令必须有root权限
su
# 查看selinux状态,Enforcing(强制,也就是开启),Permissive(宽容)
getenforce
# 设为宽容
setenforce 0
# 设为强制
setenforce 1

连接成功

安装vim

bash 复制代码
apt install vim

设置打开termux后ssh自启动

bash 复制代码
vim ~/.bashrc

如果报错

bash 复制代码
(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r /data/data/com.termux/files/home/.bashrc"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/data/data/com.termux/files/home/.bashrc.swp"
    to avoid this message.

删除导致报错的文件

bash 复制代码
rm -rf /data/data/com.termux/files/home/.bashrc.swp

在.bashrc文件中加入

bash 复制代码
"当前用户:"$(whoami)

if pgrep -x "sshd" >/dev/null
        then
         echo "sshd运行中..."
        else
        sshd
 echo "启动sshd"
fi

安装wget

bash 复制代码
apt install wget

下载ddns-go

bash 复制代码
wget https://github.com/jeessy2/ddns-go/releases/download/v6.7.7/ddns-go_6.7.7_android_arm64.tar.gz

新建文件夹

bash 复制代码
mkdir ddns-go

将压缩包解压进去

bash 复制代码
tar -zxvf ddns-go_6.7.7_android_arm64.tar.gz ddns-go

不能安装,可直接启动ddns-go

bash 复制代码
./ddns-go

填入api,映射ipv6到域名

成功

通过域名访问ddns-go后台

下载alist-android-arm64

官方文档:https://alist.nn.ci/zh/

解压

bash 复制代码
wget https://github.com/AlistGo/alist/releases/download/v3.41.0/alist-android-arm64.tar.gz
tar -vxzf alist-android-arm64.tar.gz

启动alist

./alist start

获取密码

bash 复制代码
./alist admin

设置新密码

bash 复制代码
./alist admin set 新密码

打开后台 手机ip:5244,登陆

挂载本机存储

播放本机存储的歌曲

如何复制文件夹到它的子目录

直接复制会报错

bash 复制代码
$ tsudo cp -r ~ adcx_home/
cp: cannot copy a directory, '/data/data/com.termux/files/home', into itself, 'adcx_home/home'
$

使用下方命令

bash 复制代码
ls | grep -v '^adcx_home$' | xargs cp -at adcx_home
bash 复制代码
ls:列出当前目录下的所有文件和目录。
grep -v '^adcx_home$':使用grep过滤输出,-v 选项表示反转匹配,即选择不匹配的行。这里,它将排除名为 adcx_home 的文件或目录。
xargs:将 grep 的输出作为参数传递给 cp 命令。
cp -at adcx_home:这是 xargs 传递给 cp 命令的命令行选项和参数。这里:
-a 表示归档模式,用于复制文件和目录及其属性(如权限和时间戳)。
-t 表示指定目标目录,即 -t adcx_home,这意味着将所有文件和目录复制到 adcx_home 目录下。

出现bug,chomod怎么弄都没权限,删除重下解决

后台运行程序

并且将标准输出到终端的内容重定向到home目录下tmp文件夹的log文件

bash 复制代码
ping baidu.com  &> ~/tmp/ping.log &


jobs命令查看后台,fg 序号 切回前台

bash 复制代码
$ jobs
[1]-  Running                 ~/ddns-go/ddns-go &> ~/tmp/ddns-go.log &
[2]+  Running                 ~/alist/alist server &
$ fg 2
~/alist/alist server
^CINFO[2024-12-27 06:03:24] Shutdown server...
INFO[2024-12-27 06:03:24] Server exit
$

有个缺点就是退出终端就停止运行了需要加上nohup

bash 复制代码
nohup ping baidu.com  &> ~/tmp/ping.log &

安装nano编辑器,修改.bashrc文件

bash 复制代码
pkg install nano
nano ~/.bashrc

导入

bash 复制代码
echo "用户:"$(whoami)

if pgrep -x "sshd" >/dev/null
  then
    echo "sshd运行中..."
  else
    sshd
    echo "ssh未运行,启动sshd"
fi


if pgrep -x "alist" >/dev/null
  then
    echo "alist运行中..."
  else
    ~/alist/alist stop
    nohup ~/alist/alist server &>~/tmp/alist.log &
    echo "alist未运行,重启alist,日志~/tmp/alist.log"
fi



if pgrep -x "ddns-go" >/dev/null
  then
    echo "ddns-go运行中..."
  else
    nohup ~/ddns-go/ddns-go &>~/tmp/ddns-go.log &
    echo "ddns-go未运行,启动ddns-go"
    cat ~/tmp/ddns-go.log
fi

登陆或切换用户

termux-api使用,需要下载app,等会测试

bash 复制代码
pkg install termux-api
bash 复制代码
termux-battery-status
无输出
bash 复制代码
termux-api start 
no found

安装python

bash 复制代码
pkg install python

查看版本

bash 复制代码
$ python --version
Python 3.8.0

新建一个文件放代码,新建一个test.py文件测试代码

bash 复制代码
mkdir python
cd python
touch test.py
nano test.py
bash 复制代码
import os
print('我在哪')
print(os.getcwd())
print('我是谁')
os.system('whoami')
bash 复制代码
python test.py
bash 复制代码
$ pythonno test.py
我在哪
/data/data/com.termux/files/home/python
我是谁
u0_a96
相关推荐
Android系统攻城狮2 小时前
Linux Gstreamer深度解析之gst_audio_ring_buffer_delay调用流程与实战(七十二)
linux·运维·服务器·gstreamer音视频·音视频进阶
快乐的韭菜根根3 小时前
ubuntu 安装slurm并配置
linux·运维·ubuntu
倒头就睡的小比特5 小时前
Linux基础指令3
linux·服务器
梦帮科技5 小时前
Kali Linux Scapy 畸形报文构造学——深度解剖非法 TCP Flags 与反常序列号
linux·爬虫·神经网络·算法·数学建模·系统架构·模拟退火算法
jack186896 小时前
安卓手机忘记锁屏密码怎么办? 无需密码也可解锁
android·智能手机
半杯咖啡半行码6 小时前
Linux 驱动开发入门:内核模块编程基础
linux·服务器·网络
别动我齐刘海7 小时前
Linux 系统调试学习2
linux·运维·c++·人工智能·学习·机器学习·机器人
龙虾电话7 小时前
语音机器人打断不进去:VAD 双阈值迟滞里一个共用的 bool,和它引发的连锁误判
linux
honsor7 小时前
机房IP化改造首选:以太网温湿度传感器,PoE供电+Modbus TCP一网搞定
linux·运维·服务器
默|笙8 小时前
【Linux网络】_udp_socket(认识)
linux·网络·udp