Skip to content

Click on each book below to review & buy on Amazon.

As an Amazon Associate, I earn from qualifying purchases.

CompTIA Linux+ XK0-005 - 3.1 - Environment Variables: SHELL

The SHELL environment variable in Linux determines the default shell or command-line interpreter for a user. It specifies the program that will be launched when a user opens a new terminal session.

Viewing the Variable

To view the current value of the SHELL environment variable, enter the following command:

echo $SHELL

This command will display the current value of the SHELL variable, which represents the default shell for your user account.

Changing the Variable

To change the SHELL environment variable, you need to update the user's configuration files. Here's how you can do it:

  • Identify the configuration file associated with the user account you want to modify. The most common configuration files are:

    • /etc/bashrc: System-wide Bash configuration file.
    • ~/.bashrc: Used by the Bash shell.
    • ~/.bash_profile: Used by the Bash shell as a login shell.
    • ~/.zshrc: Used by the Zsh shell.

    The configuration file might differ based on the shell you are using.

  • Open the configuration file using a text editor of your choice.

    vi ~/.bashrc
  • Locate the line that sets the SHELL variable. It may appear as follows, or it may not exist at all:

    export SHELL=/bin/bash

    The above example sets the SHELL variable to the Bash shell (/bin/bash).

  • Modify or set the value of the SHELL variable to the desired shell. For instance, if you want to use the zsh shell, the line will be:

    export SHELL=/usr/bin/zsh
  • Save the changes and exit the text editor.

  • To apply the updated configuration, either log out and log back in, or run the following command:

    source ~/.bashrc

    This command reloads the configuration file, making the changes effective in the current terminal session.

  • Verify that the SHELL variable has been updated by running the echo $SHELL command again.


The SHELL environment variable is a crucial aspect of Linux system configuration. Being able to view and change the SHELL variable allows you to customize your command-line experience and choose the default shell that suits your preferences.

Support DTV Linux

Click on each book below to review & buy on Amazon. As an Amazon Associate, I earn from qualifying purchases.

NordVPN ®: Elevate your online privacy and security. Grab our Special Offer to safeguard your data on public Wi-Fi and secure your devices. I may earn a commission on purchases made through this link.