🖥️exec

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the exec command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#  ███████╗██╗  ██╗███████╗ ██████╗
#  ██╔════╝╚██╗██╔╝██╔════╝██╔════╝
#  █████╗   ╚███╔╝ █████╗  ██║
#  ██╔══╝   ██╔██╗ ██╔══╝  ██║
#  ███████╗██╔╝ ██╗███████╗╚██████╗
#  ╚══════╝╚═╝  ╚═╝╚══════╝ ╚═════╝

# Shell builtin command
# It can start a new process to replace the shell, without a new process creation.
# It can make redirections take effect in the current shell

# Redirect the output of an entire shell script within the script itself
# Only stdout:
exec > foo.log

# Redirect the output of an entire shell script within the script itself
# Stdout and stderr:
exec > foo.log 2>&1

# Copy output to a log file
exec >  >(tee -ia foo.log)
exec 2> >(tee -ia foo.log >&2)

# Disable suspend on lid close until current shell exits - Useful for running long commands with the laptop lid closed and screen off. Also see Gnome extension Caffeine. https://extensions.gnome.org/extension/517/caffeine/
exec systemd-inhibit --what=handle-lid-switch --mode=block bash

exec -a vim nethack
# Now if your boss runs ps aux on your system, they will think you are working, not playing a game.

#==============================##==============================#
# CMD EXEC						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░