From 21ce1a12cbfc0fcefe16cc9875f45dcfacd0ffee Mon Sep 17 00:00:00 2001 From: tiyn Date: Tue, 10 Jan 2023 01:41:51 +0100 Subject: [PATCH] shell: silencing and disowning commands added --- wiki/linux/shell.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/wiki/linux/shell.md b/wiki/linux/shell.md index 59921b0..de09679 100644 --- a/wiki/linux/shell.md +++ b/wiki/linux/shell.md @@ -15,3 +15,27 @@ dash. - `sudo ln -sfT /bin/dash /bin/sh` - link /bin/sh to dash - `sudo vim /usr/share/libalpm/hooks/bash-update.hook` - setup a hook to avoid bash resetting the symlink + +## Disown a Command + +This section is based on a guide by +[baeldung](https://www.baeldung.com/linux/detach-process-from-terminal). +Disowning a command removes it from the current shell. +Commands that are detached from a shell will not terminate upon its closure. +A command can be disowned simply by appending `& disown` at the end of it. +It will then provide the PID of the command that got disowned. + +## Silencing a Command + +This section is based on a guide by +[baeldung](https://www.baeldung.com/linux/silencing-bash-output). +If the output of a command is unwanted it can be silenced. +There are two parts that can be silenced independently. +Non-error outputs (stdout) can be silenced by appending `1> /dev/null` to the +command. +Due to the `1` being ommitable `> /dev/null` has the same effect. +Error outputs (stderr) can be silenced by appending `2> /dev/null`. +The complete output of both stderr and stdout can be silenced by appending +`> /dev/null 2>&1` to the command. +A shortened version of it not possible on all shells is `&> /dev/null`. +