Shell

unset

Remove variables or functions from the shell environment.

Synopsis

syntax
unset [OPTION]... NAME...

Examples

Remove an environment variable
unset MY_VAR
Remove a shell function
unset -f my_function
Stop recording command history
unset HISTFILE

Common options

FlagDescription
-vUnset variable (default)
-fUnset function

About unset

The `unset` command remove variables or functions from the shell environment. Shell commands configure your interactive environment — variables, aliases, history, and shell options.

The shell is your primary interface with Linux, and customizing it improves productivity. These commands work across bash, zsh, and other POSIX-compatible shells with minor differences.

The command accepts 2 commonly used flags shown above, though the full set of options is available in the man page (`man unset`). The 3 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.

Related commands

More Shell Commands

Other commands in the Shell category

Related tools