You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

制作并安装Deb包后执行命令提示‘command not found’的问题求助

解决Debian包中testhello命令找不到的问题

出现testhello: command not found的核心原因是:你在bash里输入的命令是testhello,但实际安装的文件是testhello.py,系统无法自动匹配;另外脚本缺少必要的执行配置,以下是具体解决步骤:

步骤1:修改脚本名称与添加执行头

  1. 进入打包目录的bin文件夹:cd /testhello/usr/bin
  2. 将testhello.py重命名为testhello:mv testhello.py testhello
  3. 编辑testhello文件,在第一行添加shebang头(告诉系统用Python3执行):
    #!/usr/bin/env python3
    print("hello world")
    

步骤2:设置脚本可执行权限

给脚本添加执行权限,否则系统无法直接运行:

chmod +x /testhello/usr/bin/testhello

步骤3:重新打包并安装

  1. 回到打包根目录:cd /
  2. 重新生成deb包:dpkg -b testhello
  3. 重新安装包:sudo dpkg -i testhello.deb

可选:保留原文件名的替代方案

如果不想修改testhello.py的文件名,需要额外做两步:

  1. 给testhello.py添加shebang头并设置可执行权限(同步骤1、2)
  2. 在打包目录的/testhello/usr/bin下创建软链接:
    ln -s testhello.py testhello
    
    安装后,/usr/bin/testhello会指向testhello.py,输入testhello即可执行。

另外注意:你提到在/bin目录看到testhello.py,这不符合Debian打包规范,标准用户二进制文件应放在/usr/bin,打包时的testhello/usr/bin路径会被映射到系统的/usr/bin,请确认打包路径是否正确。

内容的提问来源于stack exchange,提问作者falsekein

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 09:45:31