0
0
Linux CLIscripting~5 mins

Shell concept (Bash, Zsh) in Linux CLI - Commands & Configuration

Choose your learning style9 modes available
Introduction
A shell is a program that lets you talk to your computer by typing commands. Bash and Zsh are popular shells that help you run commands, manage files, and automate tasks easily.
When you want to run commands to manage files or programs on your computer.
When you need to automate repetitive tasks like backups or file renaming.
When you want to customize your command prompt or environment for easier use.
When you want to write scripts to perform multiple commands automatically.
When you want to explore and learn how your operating system works through commands.
Commands
This command shows which shell you are currently using by printing the shell's path.
Terminal
echo $SHELL
Expected OutputExpected
/bin/bash
This command shows the version of Bash installed on your system to confirm it is available.
Terminal
bash --version
Expected OutputExpected
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu) Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
This command shows the version of Zsh installed on your system to check if Zsh is available.
Terminal
zsh --version
Expected OutputExpected
zsh 5.8 (x86_64-ubuntu-linux-gnu)
This command changes your default shell to Zsh so that every new terminal session uses Zsh.
Terminal
chsh -s /bin/zsh
Expected OutputExpected
Password:
-s - Specifies the new shell to set as default
This command prints the name of the current shell session to confirm which shell you are using now.
Terminal
echo $0
Expected OutputExpected
zsh
Key Concept

If you remember nothing else, remember: a shell is your command-line helper that runs your commands and scripts.

Common Mistakes
Trying to run shell commands without knowing which shell is active.
Different shells can behave differently, so commands might not work as expected.
Always check your current shell with 'echo $SHELL' before running commands.
Changing the default shell without installing it first.
If the shell is not installed, the change will fail or cause login issues.
Verify the shell is installed using '--version' before changing it.
Not restarting the terminal after changing the default shell.
The shell change only applies to new sessions, so the current terminal still uses the old shell.
Close and reopen the terminal or log out and back in to start using the new shell.
Summary
Use 'echo $SHELL' to find out which shell you are using.
Check shell versions with 'bash --version' or 'zsh --version' to confirm availability.
Change your default shell with 'chsh -s /bin/zsh' and restart your terminal to apply.