To change the default shell to Bash in Linux or Unix, you can use the chsh
command. This command allows you to change the login shell for a user.
To change the login shell for the current user to Bash, run the chsh
command and specify the path to the Bash shell as the new login shell.
For example, to change the login shell to Bash, you can run the following command:
chsh -s /bin/bash
This will change the login shell for the current user to Bash.
It's worth noting that the chsh
command may prompt you for your password before changing the login shell. This is a security measure to prevent unauthorized changes to the login shell.
After running the chsh
command, you will need to log out and log back in for the changes to take effect.
Alternatively, you can specify the path to the Bash shell in the SHELL
field of the /etc/passwd
file. This file contains information about the users on the system, including the login shell for each user.
To change the login shell for a user in the /etc/passwd
file, open the file in a text editor and find the line corresponding to the user. Then, update the SHELL
field with the path to the Bash shell.
For example, to change the login shell for the user alice
to Bash, you can update the /etc/passwd
file as follows:
alice:x:1000:1000:Alice:/home/alice:/bin/bash
It's worth noting that you will need to have root privileges to edit the /etc/passwd
file. You can use the sudo
command to edit the file as the root
user.
After updating the /etc/passwd
file, you will need to log out and log back in for the changes to take effect.
It's also a good idea to verify that the login shell has been changed to Bash by running the echo $SHELL
command. This command will display the current login shell for the user.
If the login shell has been successfully changed to Bash, the echo $SHELL
command should output the path to the Bash shell.
/bin/bash