How to change the shell for an already existing user – Unix/Linux
We can change the shell of a user by using the ‘usermod’ command. Some common types of shells are listed below:
We can find out the shell details from the ‘passwd’ file under ‘/etc’ location.
Display shell details of the user ‘me’
[[email protected] ~]# grep -w me /etc/passwd me:x:502:502::/home/me:/bin/bash
Shell is : /bin/bash
How to change the shell via command line?
The usermod command with switch ‘s’ is used to change the current shell of a user. Other useful usermod switches.
[[email protected] ~]# usermod -s /sbin/nologin me [[email protected] ~]# grep -w me /etc/passwd me:x:502:502::/home/me:/sbin/nologin
The shell changed to “/sbin/nologin”
That’s it!! 🙂