What is the meaning of 2 in 2> /dev/null

The N> syntax in Bash means to redirect a file descriptor to somewhere else. 2 is the file descriptor of stderr, and this example redirects it to /dev/null.

What this means in simple terms: ignore error output from the command. For example, if kill cannot stop a process because it doesn’t exist, or because the current user doesn’t have the permission to do that, it would print messages on stderr. By redirecting stderr to /dev/null, you effectively suppress these messages.

Leave a Comment