Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

If I wanted to use zsh, for instance, rather than bash, where would I make this change for the current user?

share|improve this question

marked as duplicate by Raphael Ahrens, Anthon, dr01, garethTheRed, slm Jul 5 at 19:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 12 down vote accepted

Chris Browne's answer works well if you don't have access to the user and have root privileges.

If you want to change the default shell of your current user you can also use:

chsh -s /bin/ksh

More info

The login shell of a user is defined in a file (/etc/passwd on Debian). This files has an entry for each user with the info entered at creation.

rahmu:x:1000:1000:My Nameisrahmu,,,:/home/rahmu:/bin/bash

The last column is the login shell. It will be forked by the login program if successful.

However it is highly recommended that you do not modify this file by hand. You should use chsh or usermod whenever possible.

share|improve this answer
Thanks, that's good to know! – Naftuli Tzvi Kay Oct 16 '11 at 23:02
Need to make sure that /bin/zsh is listed in /etc/shells. – Arcege Oct 16 '11 at 23:40
re: "on debian" is there a unix where this isn't true? – xenoterracide Oct 19 '11 at 3:38
I just checked on the Solaris server at work. File /etc/passwd has only 19 entries. I know for a fact there are a lot more users on the system that that. – rahmu Oct 19 '11 at 8:13

usermod -s /bin/zsh <username>

See man usermod for more options.

share|improve this answer
Right, it's not set in a config, file, rather it's a user-definition level thing. Thanks! – Naftuli Tzvi Kay Oct 16 '11 at 22:56
You'll need to run this through sudo. The usermod command is unprivileged unlike chsh. – Arcege Oct 16 '11 at 23:50
This is very true, and there is in fact a third way of doing it, which is to add the command "/bin/zsh" to the end of your .bash_rc. I believe rahmu's answer more accurately answers this question, my answer answers the more generalised "how do I change a user's shell?" question - which is more of a sysadmin's question, and less of a user's question, which is why I assumed that was the question being asked. – Chris Browne Oct 17 '11 at 0:08

You can change your login shell with the chsh command. As man chsh notes, a normal user can only change the shell for their own account, while root can change the shell for all accounts.

/etc/shells contains the pathnames of valid login shells. This file is queried by chsh when it is invoked.

The instructions for using chsh vary according to your UNIX flavour:


chsh -s newshell


chsh newshell


chsh username newshell



This will start an interactive session where you are prompted for the full path to your new shell.

Reference: http://kb.iu.edu/data/benf.html

share|improve this answer

On systems where you don't have sudo access or proper permission to use chsh (for example if you cannot add /bin/zsh to /etc/shell), then you can do it the old fashioned way:

$ mv ~/.bash_profile ~/.bash_profile.old
$ (echo :; echo exec /bin/zsh -il) > ~/.bash_profile
$ source ~/.bash_profile

This will replace the bash shell with a login zsh at login.

share|improve this answer

I was trying to do this on a Synology device running DSM 5.1 with ash shell running. For some reason the chsh command was not available. I had to instead edit the file /etc/passwd, putting in the full path to the shell executable I instead wanted.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.