How to Change Default Shell in Linux

If we are a non-root user we can not make direct changes to /etc/passwd file to change the default shell we have. To change the default shell we can use the command chsh. You can see the default shell and View the available shells on your computer before changing your default shell. The syntax of chsh command as follows:

chsh -s

The shell name contains the new shell name you will use and is an absolute path. for example if your default shell is bash (/ bin / bash) and you want to convert to csh (/ bin / csh), then the command you should use:

[lica @ canada ~] $ chsh -s /bin/csh
Changing shell for lica.
Shell changed.

When changing shell with chsh command you will be prompted for password. fill in with your user password and not the root password (if you have root access). to see the changes we can see the contents of /etc/passwd

[lica @ canada ~] $ grep lica / etc / passwd
lica: x: 500: 500: lica: / home/lica: /bin/csh

If you are running chsh from root, you can add username parameters as input to chsh to change a specific user shell in your system.

when you run chsh with no option, chsh will run in interactive mode, for example :

[lica @ canada ~] $ chsh
Changing shell for lica.
New shell [/ bin / csh]: / bin / bash
Shell changed.

Good luck!

Leave a Reply

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