华为麦芒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
相关推荐
二流小码农9 分钟前
鸿蒙开发:wrapBuilder传递参数
android·ios·harmonyos
ljx14000525501 小时前
推荐一个基于Koin, Ktor & Paging等组件的KMM Compose Multiplatform项目
android·kotlin
若云止水1 小时前
Ubuntu 下 nginx-1.24.0 源码分析 - cycle->modules[i]->ctx
linux·nginx·ubuntu
亦世凡华、1 小时前
快速部署:在虚拟机上安装 CentOS 7 的详细步骤
linux·运维·经验分享·centos·安装教程
Elastic 中国社区官方博客2 小时前
使用 Elastic-Agent 或 Beats 将 Journald 中的 syslog 和 auth 日志导入 Elastic Stack
大数据·linux·服务器·elasticsearch·搜索引擎·信息可视化·debian
lrydnh2 小时前
数据库语句
android·数据库
星图辛某人2 小时前
《Linux命令行和shell脚本编程大全》第四章阅读笔记
linux·运维·笔记
去看全世界的云2 小时前
【Kotlin】Kotlin基础笔记
android·java·笔记·kotlin
tangweiguo030519872 小时前
Android打造易用的 WiFi 工具类:WifiUtils 封装实践
android·java·wifi