3 Ways to Check Which Shell You are Using on Linux

Written by

Reviewed by

Last updated: June 27, 2023

Expert verified

SVG Image


To check which shell you are using, you can try these methods:

  1. Using the echo $SHELL Command: Retrieve the path of your active shell.
  2. Checking the /etc/passwd File: Identify your default shell by inspecting the /etc/passwd file.
  3. Utilizing the ps Command: Determine your active shell by examining the processes using the ps command.

The cat command allows you to check the valid login shells on Linux, ensuring proper shell selection and system-wide configuration. Implementing best practices, such as double-checking output, documenting your shell, verifying compatibility, familiarizing yourself with features, and securing your shell, enhances accuracy, productivity, and system security.

Read the guide below to learn different methods to check which shell you are using. Also, learn how to check valid shells and best practices for checking shells you are using.

To truly harness Linux command line power, it’s crucial to know which shell you’re using. Your active shell determines the features, syntax, and customization options at your fingertips. Whether you’re a seasoned Linux user or just starting your journey, understanding your active shell opens doors to enhanced productivity, troubleshooting prowess, and the ability to tap into the vast ecosystem of shell-specific tools and resources.  In this engaging guide, I will explore various methods of checking which shell you are using on Linux, checking valid login sessions, and best practices for checking the shell you are using. 

How to Check Which Shell You Are Using on Linux

To check which shell you are using on Linux, you can employ three methods. The first involves using the echo $SHELL command to retrieve the shell path. The second method is inspecting the /etc/passwd file for the default shell associated with your user account. Lastly, utilizing the ps command allows you to identify the active shell by examining the processes.

1. Using the echo $SHELL Command

By employing the echo $SHELL command, you can quickly retrieve the path of your active shell. This method provides a straightforward way to check your shell, allowing you to troubleshoot issues, ensure script compatibility, and customize your command-line environment effortlessly. Follow these steps to check your shell:

  1. Open the Terminal.
opening terminal 21
  1. Type the following command and press Enter:
    <strong>echo $SHELL</strong>
    1. The output will display the path of your current shell, such as /bin/bash, /usr/bin/zsh, or /usr/bin/fish.
      displaying current shell path

      2. Checking the /etc/passwd File

      Inspecting the /etc/passwd file reveals the default shell associated with your user account. This method lets you determine your default shell, ensuring seamless integration with system configurations and proper execution of scripts. Here’s how to use this file to identify your shell:

      1. Access your command window and run the following command: 
      <strong>grep ^$USER /etc/passwd</strong>
      1. The output will display a line containing your username and other user-related information, including the shell associated with your account. Locate the shell field, which typically appears at the end of the line, separated by a colon (:).
      2. The value within the shell field indicates your active shell.
      displaying current user info and associated shell

      3. Utilizing the ps Command

      The ps command displays information about active processes in your Linux system. By inspecting the processes associated with your current session, you can identify the shell in use. Here’s how:

      1. Launch the Terminal and execute the following command:
      <strong>ps -p $$</strong>
      1. The output will provide details about the current shell process.
      2. Locate the CMD column, which displays the command used to initiate the shell process.
      viewing current shell process
      1. The value within the CMD column represents your active shell.

      How to Check the Valid Login Shells

      Using the cat command, you can quickly view the valid login shells defined on your Linux system. This information is useful for selecting and configuring the appropriate shell for user accounts, ensuring compatibility, and managing system-wide shell configurations.

      1. Access the command window.
      2. Run the following command: 
      <strong>cat /etc/shells</strong>
      1. The output will display a list of valid login shells supported by your system. Each shell will be listed on a separate line, showing the path to the shell executable file, such as /bin/bash or /usr/bin/zsh.
      displaying valid login shells

      Best Practices for Checking Which Shell You are Using on Linux

      Implementing best practices will help you accurately identify your active shell, utilize its features effectively, and ensure a secure and optimized command-line experience on Linux. Here are five best practices that you can use:

      • 🔍 Double-check the Output: After using any method to check your shell, always double-check the output to ensure accuracy. Typos or misinterpretations can lead to incorrect results. Pay attention to details such as capitalization and spelling. For example, ensure the output displays the correct shell name and path, matching your expectation.
      • 📝 Document Your Shell: Keeping a record of your active shell provides valuable reference information. Create a dedicated document or maintain a personal knowledge base where you note down the shells you use on different systems or projects. This documentation helps you quickly refer to the specific shell and its associated configurations, saving time and effort.
      • 🔄 Verify Shell Compatibility: Different shells may have specific features or commands that are not universally available. When using commands or scripts, verify their compatibility with your active shell. Check for any shell-specific syntax or functionalities that may differ and ensure your commands or scripts are compatible across different shell variants. This practice ensures the smooth execution of your scripts and avoids any unexpected issues or errors.
      • 🔧 Familiarize Yourself with Shell Features: Take the time to explore and understand your active shell’s unique features and capabilities. Each shell offers its own set of commands, customization options, and productivity-enhancing features. By familiarizing yourself with these features, you can leverage them to streamline your workflow, automate tasks, and make the most out of your shell environment.
      • 🔐 Secure Your Shell: Protecting your shell environment is crucial for maintaining system security. Regularly update your shell and related packages to ensure you have the latest security patches. Stay informed about any vulnerabilities associated with your shell and promptly apply the necessary fixes. Also, practice good password hygiene by using strong and unique passwords for your shell access. 

      In Conclusion

      I have explored various methods to determine which shell you are using on Linux, including checking the SHELL environment variable, examining the /etc/passwd file, and using commands like ps. By following the common and best practices discussed in the article, you can ensure an optimized command-line experience.

      However, this is just the beginning of your journey. To expand your command-line skills and deepen your Linux knowledge, consider exploring the following topics, Customizing Your Shell Environment, Mastering Shell Scripting, and Exploring Advanced Command-Line Tools. Embrace the power of the Linux command line, keep expanding your knowledge, and unlock new possibilities on your Linux journey.

      Frequently Asked Questions

      How can I change my default shell in Linux?

      To change your default shell in Linux, you can use the chsh command. This command allows you to modify the default shell associated with your user account. Open the Terminal and type chsh -s /path/to/newshell. Replace /path/to/newshell with the desired shell’s path, such as /usr/bin/zsh for the Zsh shell. After executing the command, you may be prompted to enter your password for authentication. Once changed, the new shell will become your default shell, effective upon your next login.

      Can I have multiple shells active simultaneously in Linux?

      Absolutely! Linux allows you to have multiple shells active simultaneously, enabling you to work with different shells concurrently. One way to achieve this is by opening new Terminal windows or tabs, each running a different shell. Alternatively, you can use multiplexer tools like tmux or screen, which provide virtual Terminals that allow you to manage multiple shell sessions within a single Terminal window. These tools offer flexibility and convenience, empowering you to switch between various shells and keep your workflow organized.

      Does the choice of shell affect system performance or resource usage?

      The impact of the shell choice on system performance and resource usage depends on several factors. Generally, modern shells, such as Bash, Zsh, Fish, and Ksh, have similar performance characteristics with negligible differences. However, resource usage can vary based on the specific features, extensions, and plugins enabled within each shell. For instance, shells incorporating extensive scripting capabilities or heavy customization options may consume slightly more system resources. It’s important to strike a balance between the desired features and the potential impact on system performance, ensuring an optimal user experience while considering resource constraints.

      While the Bash shell is widely used and considered the default on many Linux distributions, several alternative shells have gained popularity within the Linux ecosystem. Zsh (Z Shell) is renowned for its advanced features, extensive customization options, and improved command-line editing capabilities. Fish (Friendly Interactive Shell) focuses on user-friendliness and discoverability, with intuitive auto-completion and syntax highlighting. Ksh (KornShell) combines the features of both the Bourne shell and the C shell, offering a powerful scripting environment. These alternative shells provide users diverse choices, allowing them to tailor their command-line experience to their specific preferences and requirements.

      Is it possible to change the default shell for a specific user?

      Yes, it is possible to change the default shell for a specific user in Linux. As the system administrator, you can use the chsh command with the -s option followed by the desired shell’s path and the username. For example, to change the default shell for the user john to Zsh, you would run the command sudo chsh -s /usr/bin/zsh john. This allows you to customize the shell for individual users on the system.



      Ojash is a skilled Linux expert and tech writer with over a decade of experience. He has extensive knowledge of Linux's file system, command-line interface, and software installations. Ojash is also an expert in shell scripting and automation, with experience in Bash, Python, and Perl. He has published numerous articles on Linux in various online publications, making him a valuable resource for both seasoned Linux users and beginners. Ojash is also an active member of the Linux community and participates in Linux forums.



      Akshat is a software engineer, product designer and the co-founder of Scrutify. He's an experienced Linux professional and the senior editor of this blog. He is also an open-source contributor to many projects on Github and has written several technical guides on Linux. Apart from that, he’s also actively sharing his ideas and tutorials on Medium and Attirer. As the editor of this blog, Akshat brings his wealth of knowledge and experience to provide readers with valuable insights and advice on a wide range of Linux-related topics.

      Share this article
      Shareable URL
      Prev Post

      4 Best Methods to Change or Set User Password in Linux

      Next Post

      How to Install Eclipse on Ubuntu [10 Easy Steps]

      Leave a Reply

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

      Read next