Skip to content

ARKIT

  • Home
  • About Us
  • Free Books
  • Netapp
  • Subscribe
  • Interview
  • MSSQL
  • Contribute
  • Videos
  • Linux Training
  • Home
  • About Us
  • Free Books
  • Netapp
  • Subscribe
  • Interview
  • MSSQL
  • Contribute
  • Videos
  • Linux Training

ARKIT

- Learners Guide.

  • Home
  • About Us
  • Linux
  • Hardware
  • Monitoring Tools
  • Scripting
  • VMWare
  • Interview
  • Automation
  • Ask Support
  • Netapp Training
  • AIX
  • Networking
  • Centos / Fedora / Linux / RHEL7

Change login shell instantly Or permanently using these tricks Linux

by Ravi Kumar Ankam · January 3, 2017

The question here it is how to change user login shell.? Or how to change your login shell..?. Here are few examples how we can change shells instantly means just for current session. Change login shell permanently means if you logout / restart still your login shell will not change. Change login shell instantly Or Permanently using these tricks Linux.

First See Easy Way / Easy steps using chsh command

No Need to edit  /etc/passwd file for changing the shell in your Linux / Unix Operating system. It is very simple to change shell. Use chsh command for changing login shell. chsh command is used to change local machine user shell only. If you would like to change remote machine (non-local) you may consider to use ypchsh Or lchsh.

Syntax: chsh [Options] [shell name] [User Name]

Options:

-s – Change Login shell

-l – List all available shells in system

-u – Help

-v – Version

Before going to change login shells please check valid shells available in your machine. using below commands

[root@Arkit-Serv ~]# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/tcsh
/bin/csh

[root@Arkit-Serv ~]# chsh -l
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/tcsh
/bin/csh

Process of changing login shell using chsh command.

[ravi@Arkit-Serv ~]$ chsh
Changing shell for ravi.
New shell [/bin/bash]: /bin/csh
Password:
Shell changed.

[ravi@Arkit-Serv ~]$ echo $0
-csh
[ravi@Arkit-Serv ~]$ echo $SHELL
/bin/csh
[ravi@Arkit-Serv ~]$

Other user shell change can be done by super user Or root user. Normal user can’t change other user shell.

[root@Arkit-Serv ~]# chsh -s /bin/bash admin
Changing shell for admin.
chsh: Shell not changed.

usermod command can be used to change shell

One more command is usermod also helpful. We can simply use usermod -s option to change shell.

[root@Arkit-Serv ~]# usermod -s /bin/csh admin
[root@Arkit-Serv ~]# su - admin
[admin@Arkit-Serv ~]$ echo $0
-csh
[admin@Arkit-Serv ~]$ echo $SHELL
/bin/csh

Change login shell permanently by editing config file

Edit /etc/passwd using any text editor and change the login shell value. This option is not handy for new users.

[root@Arkit-Serv ~]# cat /etc/passwd |grep ravi
ravi:x:1001:1001:RHEL7 User:/home/ravi:/bin/csh
[root@Arkit-Serv ~]# vi /etc/passwd
[root@Arkit-Serv ~]# cat /etc/passwd |grep ravi
ravi:x:1001:1001:RHEL7 User:/home/ravi:/bin/bash

Change Login Shell Instantly

Instantly if you would like to switch in between shell you can also do that using simple commands

[ravi@Arkit-Serv ~]$ echo $0
-bash
[ravi@Arkit-Serv ~]$ csh
[ravi@Arkit-Serv ~]$ echo $0
csh

That’s all about Change Login shell instantly Or Permanently..!!

Related Articles

Adding User without using useradd command

User Administration Adding and Deleting User accounts in RHEL 7 / Centos 7

Reset forgot root user password RHEL 7 / Centos 7

Thanks for your wonderful Support and Encouragement

  • Get Email | Download E-Books
  • Facebook Page
  • Youtube Channel
  • Twitter
  • Exclusive Telegram Group
  • Discuss On WhatsApp Group