Search code examples
linuxcommand-line-interfacebackground-process

In Linux how do you make a command run in the background without it outputting to the screen?


I know this sounds like a silly question at first glance, but I've tried everything. I want to execute the command arpspoof in the Kali Linux terminal but I do not want to see the endless output.

First I try this:

arpspoof -t 10.1.1.1 10.1.1.2 >/dev/null

And it still outputs to the screen. Then I try this:

arpspoof -t 10.1.1.1 10.1.1.2 & >/dev/null

And it still outputs to the screen. Then I add another one at the end:

arpspoof -t 10.1.1.1 10.1.1.2 & >/dev/null &

And it still outputs to the freakin screen.


Solution

  • Try

    arpspoof -t 10.1.1.1 10.1.1.2 2>/dev/null 1>/dev/null &
    

    where:

    arpspoof -t 10.1.1.1 10.1.1.2 is your command

    2>/dev/null redirects standard error (STDERR) to the "bit bucket"

    1>/dev/null redirects standard out (STDOUT) to the "bit bucket"

    & sets the entire command line to run in the background

    This line of code is more verbose and perhaps clearer to understand.