We have moved to www.dataGenX.net, Keep Learning with us.

Tuesday, June 26, 2012

chsh Command


The chsh command changes a user's login shell attribute. The shell attribute defines the initial program that runs after a user logs in to the system. This attribute is specified in the /etc/passwd file. By default, the chsh command changes the login shell for the user who gives the command.


Shell used by me
[root@home ~]# echo $SHELL
/bin/bash

To get the chsh help
[root@home ~]# chsh --help
Usage: chsh [ -s shell ] [ --list-shells ] [ --help ] [ --version ][ username ]

 
To list the available shells in system
[root@home ~]# chsh -l
/bin/sh
/bin/bash
/bin/ksh
/usr/bin/ksh
/bin/tcsh
/bin/csh

  
Step to change Linux login shell.
The example below show the use of chsh command to change shell for current user.
[atul@home ~]$ chsh
Changing shell for atul.
Password:
New shell [/bin/bash]: /bin/csh
Shell changed.

[atul@home ~]$ chsh -s /bin/bash  ---> chsh [ -s shell ]
Changing shell for atul.
Password:
Shell changed.


The chsh command issue with no option and –s option with the full pathname of the desired shell, is used to change shell for the user and it will prompt user for their password (note: the password only prompt for non-root user).  In above example we change the shell to /bin/csh (C SHell) and to /bin/bash (Bourne-Again Shell).  NOTE: the changes will take effect after you logout and login again.


Step to change shell for other user.
[root@home ~]# chsh -s /bin/csh atul  -->  chsh [ -s shell ][ username ]
Changing shell for atul.
Shell changed.



njoy the simplicity.......
Atul Singh

No comments :

Post a Comment