chsh commad : NIX classes

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.

 
 

keep scripting…….
©Victimizeit

Advertisements

About victimizeit
This is Atul.. working for IBM as a DataStage Developer. I may not be an expert on any particular DataStgae technology, but I'm sure I do know a few things about DB2, AIX, Unix, Windows, and DataBase. In this blog, I'll give out some tips on these subjects. If you find them useful, great, I'll be happy. Thanks for stopping by !!

What is your opinion ?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: