华为麦芒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
相关推荐
清风~徐~来1 分钟前
【Linux】网络层协议 IP
linux·网络·tcp/ip
vortex58 分钟前
探索 Shell 中的扩展通配符:从 Bash 到 Zsh
linux·运维·bash·shell·zsh
不爱学英文的码字机器12 分钟前
[操作系统] 进程间通信:system V共享内存
linux·服务器·ubuntu
‍。。。15 分钟前
Ubuntu 24.04 中文输入法安装
linux·运维·ubuntu
丁总学Java32 分钟前
如何用 nvm alias default 18.20.8 实现全局 Node.js 版本管理?一篇保姆级指南!!!
linux·node.js·vim
Yang三少喜欢撸铁1 小时前
【Linux部署DHCP服务】
linux·运维·服务器
API小爬虫1 小时前
利用 PHP 爬虫获取京东商品详情 API 返回值说明及代码示例
android·爬虫·php
程序员小软2 小时前
linux-添加开机自启动指定脚本
linux·运维
安於宿命2 小时前
【Linux】用C++实现UDP通信:详解socket编程流程
linux·c++·udp
_一条咸鱼_8 小时前
深入剖析 Android Hilt 框架的依赖生命周期管理模块(六)
android·kotlin·android jetpack