enable

shell builtinLinux/Unix
The enable command is one of the most frequently used commands in Linux/Unix-like operating systems. enable Enable and disable shell built-in commands

Quick Reference

Command Name:

enable

Category:

shell builtin

Platform:

Linux/Unix

Basic Usage:

enable [options] [arguments]

Common Use Cases

  • 1

    Shell customization

    Enable or disable built-in commands to customize shell behavior

  • 2

    Command precedence control

    Control whether a built-in or external command is used

  • 3

    Script compatibility

    Ensure consistent command behavior across different systems

  • 4

    Shell extension

    Load new built-in commands from shared libraries

Syntax

enable [-a] [-dnps] [-f filename] [name ...]

Options

Option Description
-a List all built-ins showing which are enabled and which are disabled
-d Delete a built-in loaded with -f
-f filename Load a built-in from the shared object filename
-n Disable the named built-ins
-p List built-ins in a reusable format
-s List only Posix special built-ins

Examples

How to Use These Examples

The examples below show common ways to use the enable command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

Basic Examples:

enable
List all enabled built-in commands.
enable -n test
Disable the built-in 'test' command.

Advanced Examples:

enable -n cd pwd
Disable the 'cd' and 'pwd' built-in commands.
enable -a List all built-ins, indicating whether they are enabled or disabled. enable -p List all enabled built-ins in a format that can be reused as input. enable -f ./example.so example Load a new built-in command 'example' from the shared object file example.so.

Try It Yourself

Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

Understanding Syntax

Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

Notes

The enable command is a bash shell built-in that allows you to enable or disable other shell built-in commands. This can be useful when you want to use an external command with the same name as a built-in, or when creating custom shell environments. When a built-in command is disabled, bash will use any external command with the same name found in your PATH instead. For example, if you disable the 'echo' built-in, bash will use the external /bin/echo program. By default, running 'enable' without arguments displays a list of all enabled built-in commands. Built-in commands are typically faster than external commands because they don't require creating a new process. However, disabling certain built-ins can be useful in scripting to ensure consistent behavior across different systems. Note that some 'special' built-ins (like break, continue, eval, exec) cannot be disabled because they're essential to the shell's operation. The -f option, which allows loading new built-ins from shared libraries, is typically used for development and extending the shell's functionality.

Tips & Tricks

1

Use the -n option to disable a built-in command

2

Run enable without arguments to see all enabled built-ins

3

Use the -a option to see both enabled and disabled built-ins

4

Use the -p option to get output in a format that can be reused as input

5

Note that some special built-ins like break, continue, eval cannot be disabled

Common Use Cases

Shell customization

Enable or disable built-in commands to customize shell behavior

Command precedence control

Control whether a built-in or external command is used

Script compatibility

Ensure consistent command behavior across different systems

Shell extension

Load new built-in commands from shared libraries

Shell debugging

Modify shell behavior for testing and diagnostics

Related Commands

These commands are frequently used alongside enable or serve similar purposes:

Use Cases

1

Shell customization

Enable or disable built-in commands to customize shell behavior

2

Command precedence control

Control whether a built-in or external command is used

3

Script compatibility

Ensure consistent command behavior across different systems

4

Shell extension

Load new built-in commands from shared libraries

5

Shell debugging

Modify shell behavior for testing and diagnostics

Learn By Doing

The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the enable command works in different scenarios.

$ enable
View All Commands