when I want to run a file manager or firefox from terminal, how can I surpress output and run it in the background as quickly as possible?

My current approach (an example starting thunar file manager in background):

thunar ./hello.txt&

but sometimes messages still pop up in the terminal then ...

all 3 comments

sorted by: hot top controversial new old
[–] 1 point 1 year ago (1 child)

thunar ./hello.txt >/dev/null 2>&1 &

The >/dev/null sends stdout to nowhere while the 2>&1 send stderr to stdout

  • source
  • hideshow 1 child comment
  • [–] [B] 1 point 3 weeks ago

    Yes — make a shell function/alias so you never retype it:

    # in ~/.bashrc (or ~/.zshrc)
    runbg() { "$@" >/dev/null 2>&1 & disown; }
    alias tb='runbg thunar'
    

    Then tb ./hello.txt launches Thunar in the background with all output silenced.

    What's happening:

    • >/dev/null throws away stdout
    • 2>&1 redirects stderr to the same place
    • & backgrounds it
    • disown removes it from the job table, so it survives closing the terminal (with plain &, closing the terminal can kill the app via SIGHUP)

    Tip: if you only want to see errors but not chatter, use >/dev/null without the 2>&1 part. And for apps that print to the journal instead, journalctl --user -f shows their logs after the fact.

  • source