Imagine having a powerful tool at your fingertips that allows you to communicate with your computer using simple, yet mighty commands. That's precisely what the shell offers! It provides a command-line interface that lets you efficiently interact with your system.
With the Linux shell, you can effortlessly explore your files and directories, launch applications, manage running processes, and perform a lot of tasks—all through straightforward commands.
But what makes the Linux shell truly remarkable is its versatility. It supports a variety of shells, including the widely-used Bash (Bourne Again Shell), which comes preinstalled on most Linux distributions. These shells offer a treasure trove of features, such as auto-completion, command history, and scripting capabilities, making your interactions with the system a breeze.
But the shell's power doesn't stop at file management. It also enables you to control processes, tweak user permissions, configure system settings, and even automate repetitive tasks using scripts. With scripting, you can write a series of commands and save them as a script file, allowing you to perform complex actions with a single command—saving you time and effort.
What's more, the Linux shell is incredibly flexible and customizable. You can personalize your shell environment by adjusting settings such as the appearance of your command prompt, choosing color schemes that match your style, and creating aliases for frequently used commands. These customizations transform the shell into your very own cozy corner of the Linux world, tailored to your preferences and boosting your productivity.
Let's break down - the Prompt [IMP]
[root@servera~]#
The text [root@servera~]#
you see is called a prompt, and it's like a friendly invitation from your Linux system, asking you to interact with it. It's displayed in the terminal or command-line interface, indicating that you have the power to enter commands and perform various actions.
Let's dissect it further:
"root" refers to the user who currently has administrative privileges or superuser access. Think of it as the boss of the system, capable of making important decisions and carrying out critical tasks.
"@servera" signifies the name of the system or server you are connected to. In this case, it's called "servera." Each system can have a unique name, allowing you to distinguish between different machines if you're working in a networked environment.
The "~" symbol represents the current working directory, which is the location within the file system where you're currently positioned. In this case, the "~" symbol often indicates that you're in the home directory of the "root" user.
"#" is known as the command prompt symbol. It indicates that you're currently logged in as the root user, giving you the highest level of access and control over the system.
Remember, the Linux shell is your gateway to communicate with the operating system using text-based commands.
Get ready to embark on an exciting journey and let the Linux shell be your trusted guide!
Now enough theory let's do some hands-on practical stuff
To check how many shells are present in your system execute the below command
chsh -l
/bin/sh
: This is the path to the "sh" shell executable located in the "/bin" directory. The "sh" shell is the Bourne shell, which is a simple and efficient shell that has been around for a long time. It's a reliable choice for running scripts and executing basic commands./bin/bash
: This is the path to the "bash" shell executable located in the "/bin" directory. "bash" stands for Bourne Again SHell, and it's one of the most commonly used shells in Linux. It includes all the features of the original Bourne shell but also introduces additional capabilities like command history, tab completion, and advanced scripting functionalities./usr/bin/sh
: This is the path to another "sh" shell executable, but this time located in the "/usr/bin" directory. It's possible to have multiple instances of the "sh" shell on a Linux system, and this one might have some variations or additional features compared to the one in "/bin"./usr/bin/bash
: Similar to the previous example, this is the path to the "bash" shell executable in the "/usr/bin" directory. It could be an alternative or an updated version of the "bash" shell with additional enhancements or bug fixes.
Let's Dive into Echo
The "echo" command is a handy tool that allows you to display text or the values of shell variables on the command line.
By running the command "echo", you can simply print text or messages to the terminal. For example, typing "echo Hello, world!" will display "Hello, world!" on the screen.
Now, let's use the "echo" command with a couple of special shell variables:
"$0" represents the name of the currently running shell or the script being executed. When you run the command "echo $0", it will display the name of the shell you're currently using. For instance, if you're using the Bash shell, it will show "bash".
"$SHELL" refers to the default shell defined for your user account. Running "echo $SHELL" will reveal the path or name of your default shell.
Change Shell - temporarily and permanently
Now to change the shell type just type the name of the shell and it will be switched to the desired shell - Here in this example we just typed sh and the shell got changed from bash to sh5.1
By performing the above you can change the shell temporarily
On the other hand, to change the shell permanently, you'll need to modify the user's login configuration file. The specific file to modify depends on the Linux distribution and the shell you're using. For instance, if you want to change the default shell permanently for a user in RedHat system. We will need to change the config file by changing the /etc/bashrc
file, type the below on terminal
vi /etc/bashrc
Once you execute the above command your screen should resemble like the above
Remember to exercise caution when modifying shell settings, especially if you're not familiar with the process. It's a good practice to have a basic understanding of the shell you're switching to before making any permanent changes.
Now change the placeholder value and make the change to the shell variable to /bin/sh and save the file
Once you save the config file and check with the SHELL command you wil get the below and it is expected, this is because we just updated the config file but now loaded it or the shell here is not aware of it, so here we just need to reload the shell by just typing bash.
Once you type bash and check the shell once again then here you win the changes are made and your screen will 100% resemble like below if you're following correcty with me
That's a lot we have covered today... practice well hope you like this blog
Happy Linux-ing!
Love my content Let's Connet Here: https://www.linkedin.com/in/theshubhamgour/