Linux Commands Examples

A great documentation place for Linux commands

chsh

change login shell


see also : chfn - passwd

Synopsis

chsh [options] [LOGIN]


add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2

Thanks for this example ! - It will be moderated and published shortly.

Feel free to post other examples
Oops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!

examples

0
source
            
chsh -s /bin/zsh
sudo rm /etc/zshenv
0
source
            
if [[ "$ZSH_VERSION" == ""$ ]]; then
chsh -s `which zsh`
fi
0
source

Use user-installed shell?

The whole point of /etc/shells is so that the administrator can control what users set as their shell. Setting a shell which isn't listed in /etc/shells would therefore be a security hole. The best solution is to ask the administrator to install zsh system wide, but if that's not possible your only option is configuring your current shell (I'm assuming bash) to execute your custom shell. You can do this by adding the following to ~/.bash_profile (this will only affect login shells, whereas ~/.bashrc will also affect non-login shells which may break scripts).

exec ~/bin/zsh

description

The chsh command changes the user login shell. This determines the name of the user's initial login command. A normal user may only change the login shell for her own account; the superuser may change the login shell for any account.

options

The options which apply to the chsh command are:

-h, --help

Display help message and exit.

-R, --root CHROOT_DIR

Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory.

-s, --shell SHELL

The name of the user's new login shell. Setting this field to blank causes the system to select the default login shell.

If the -s option is not selected, chsh operates in an interactive fashion, prompting the user with the current login shell. Enter the new value to change the shell, or leave the line blank to use the current one. The current shell is displayed between a pair of [ ] marks.

files

/etc/passwd

User account information.

/etc/shells

List of valid login shells.

/etc/login.defs

Shadow password suite configuration.

note

The only restriction placed on the login shell is that the command name must be listed in /etc/shells, unless the invoker is the superuser, and then any value may be added. An account with a restricted login shell may not change her login shell. For this reason, placing /bin/rsh in /etc/shells is discouraged since accidentally changing to a restricted shell would prevent the user from ever changing her login shell back to its original value.


see also

chfn , login.defs, passwd .

How can this site be more helpful to YOU ?


give  feedback