华为麦芒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
相关推荐
碎梦归途4 小时前
思科网络设备配置命令大全,涵盖从交换机到路由器的核心配置命令
linux·运维·服务器·网络·网络协议·路由器·交换机
STCNXPARM5 小时前
Android camera之硬件架构
android·硬件架构·camera
小天源5 小时前
nginx在centos7上热升级步骤
linux·服务器·nginx
AZ996ZA5 小时前
自学linux第十八天:【Linux运维实战】系统性能优化与安全加固精要
linux·运维·安全·性能优化
大虾别跑6 小时前
OpenClaw已上线:我的电脑开始自己打工了
linux·ai·openclaw
2501_944525546 小时前
Flutter for OpenHarmony 个人理财管理App实战 - 支出分析页面
android·开发语言·前端·javascript·flutter
weixin_437044647 小时前
Netbox批量添加设备——堆叠设备
linux·网络·python
hhy_smile7 小时前
Ubuntu24.04 环境配置自动脚本
linux·ubuntu·自动化·bash
宴之敖者、7 小时前
Linux——\r,\n和缓冲区
linux·运维·服务器
LuDvei7 小时前
LINUX错误提示函数
linux·运维·服务器