Search code examples
androidlinuxadbtcpdump

/system/bin/sh: tcpdump: No such file or directory


I have generated a tcpdump file to run on an Android device using this guide. Instead of Fedora, I made this file on Ubuntu 12.04 .

Everything worked smoothly and tcpdump file was produced correctly. I copied tcpdump file at /system/bin/ on Nexus-5 and ran following commands.

> adb shell
# ln -s /system/bin/tcpdump /system/xbin/tcpdump
# chmod 06755 /system/xbin/tcpdump
# reboot

After restarting computer, when I run > adb shell tcpdump -h , I get following error:

/system/bin/sh: tcpdump: No such file or directory

Can someone help me figure out the problem? Thanks!

Edit1:

When I run "tcpdump -h" on my Ubuntu machine on Virtualbox, it shows me following result:

$ tcpdump -h
tcpdump version 4.2.1
libpcap version 1.1.1
Usage: tcpdump [-aAbdDefhHIKlLnNOpqRStuUvxX] [ -B size ] [ -c count ]
        [ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]
        [ -i interface ] [ -M secret ]
        [ -r file ] [ -s snaplen ] [ -T type ] [ -w file ]
        [ -W filecount ] [ -y datalinktype ] [ -z command ]
        [ -Z user ] [ expression ]

Then I copy this tcpdump file on Windows-7 host machine and copy it to the device.


Solution

  • It turns out that my tcpdump file was not statically compiled during the process.

    After static compilation to include all other files, I still use /system/xbin/tcpdump to make it work.

    You can also see comment section of the link above. I explained what went wrong exactly and how I fixed it.