Sourcing and aliasing with bash

In the realm of Bash scripting, understanding how to source scripts and create aliases can significantly enhance your productivity and streamline your workflow. In this guide, we’ll delve into the intricacies of sourcing scripts and creating aliases in Bash, unraveling their potential and practical applications.

Sourcing Scripts

Sourcing a script in Bash involves executing its contents within the current shell environment, rather than spawning a new process. This is achieved using the source command or its shorthand, the dot (.) symbol followed by a space. Sourcing is particularly useful for importing variable assignments and function definitions from external scripts.



. ./


Aliases in Bash provide a convenient way to define alternative or shorter names for commands. For example, the common alias ll is often defined to execute ls -l. Aliases can be tailored to suit your preferences, making frequently used commands more accessible and easier to remember.

alias ll='ls -l'

Creating Aliases

To create an alias, use the alias command followed by the desired alias name and the command or sequence of commands it should represent. Aliases are specific to commands and are not applicable to general strings.

Creating Aliases in bash shell

Managing Aliases

You can view all defined aliases in your current shell environment by simply typing alias. If you wish to unset or remove an alias, you can use the unalias command followed by the alias name.

list aliases and unset aliases in bash shell


By mastering the art of sourcing scripts and creating aliases in Bash, you can enhance your scripting capabilities and streamline your command-line experience. Whether it’s importing variable assignments, defining custom command shortcuts, or managing existing aliases, these techniques offer flexibility and efficiency in your Bash environment. Experiment with different aliases and sourced scripts to tailor your shell experience to your unique preferences and workflow.

Leave a Reply

Your email address will not be published. Required fields are marked *