Silence Errors

The most common method of silencing an error in Linux is to redirect than error to /dev/null which is like the trash bucket of the system. We can do that by including 2> /dev/null to the end of a command.

Create Code That Will Produce Error

ls a_fake_directory/
ls: a_fake_directory/: No such file or directory

Silence Error

Notice that we aren’t silencing so much as redirecting into /dev/null. This is like sending the error into a black hole.

ls a_fake_directory/ 2> /dev/null