Home > UNIX > How to change shell for a user.

How to change shell for a user.

July 2, 2013

1) To find the list of shells available in the unix please check the following file.

      cat /etc/shell

2)  To change the shell details for a particular user use “chsh”

Syntax:-    chsh  -s < new shell>  < username>

E.g.:-    

chsh -s /bin/ksh oracle
chsh -s /bin/bash grid

3) you can cross check these changes by checking in /etc/passwd

E.g.:

Before modification:-

[root@lstgiamdb2 ~]# grep -i oracle /etc/passwd
oracle:x:502:502:Oracle RDBMS Owner:/home/oracle:/bin/bash
[root@lstgiamdb2 ~]# grep -i grid /etc/passwd
grid:x:501:503::/home/grid:/bin/bash

Changing shell.
[root@lstgiamdb2 ~]# chsh -s /bin/ksh oracle
Changing shell for oracle.
Shell changed.
[root@lstgiamdb2 ~]# chsh -s /bin/ksh grid
Changing shell for grid.
Shell changed.

After modification.
[root@lstgiamdb2 ~]# grep -i oracle /etc/passwd
oracle:x:502:502:Oracle RDBMS Owner:/home/oracle:/bin/ksh
[root@lstgiamdb2 ~]# grep -i grid /etc/grid
grep: /etc/grid: No such file or directory
[root@lstgiamdb2 ~]# grep -i grid /etc/passwd
grid:x:501:503::/home/grid:/bin/ksh
[root@lstgiamdb2 ~]#

 

 

You can also check SHELL value of a user using $SHELL.

Advertisements
Categories: UNIX
%d bloggers like this: