strings 命令报错时,原因通常和 命令不存在、参数写错、文件问题或环境不兼容 有关。下面按常见情况给你排查思路。
command not foundbash: strings: command not found
原因
binutilsPATH 中解决
Ubuntu / Debian
sudo apt update
sudo apt install binutils
CentOS / RHEL / Rocky
sudo yum install binutils
Arch
sudo pacman -S binutils
macOS
brew install binutils
macOS 自带
strings,但路径可能不同
检查是否存在:
which strings
strings: invalid option -- 'x'strings: invalid option -- 'x'
原因
解决
strings --help
strings file
strings -n 6 file
strings -a file
strings: file: No such file or directorystrings: test.bin: No such file or directory
原因
解决
ls -l file
strings "./my file.bin"
strings: file: File format not recognizedstrings: file: File format not recognized
原因
解决
strings -a file
file file
Permission deniedstrings: Permission denied
解决
chmod +r file
# 或
sudo strings file
macOS 的 strings 和 Linux 不完全一样。
建议
/usr/bin/strings file
或安装 GNU 版本:
brew install binutils
strings -a -n 6 filename
说明:
-a:扫描整个文件-n 6:只显示长度 ≥ 6 的字符串你可以把 完整报错信息 + 系统版本 + 命令 发给我,例如:
系统:Ubuntu 22.04
命令:strings test.bin
报错:strings: invalid option -- 't'
我可以直接帮你定位 ✅