Q. Can you tell me command to change login shell in Linux / UNIX operating system?
A. You don't have to edit /etc/passwd file to change your shell. You need to use chsh command. It changes the user login shell. This determines the name of the users initial login command. A normal user may only change the login shell for his/her own account, the super user i.e. root user may change the login shell for any account. Following is syntax of chsh command:
chsh -s {shell-name} {user-name}
Where,
- -s {shell-name} : Specify your login shell name. You can obtained list of avialble shell from /etc/shells file.
- User-name: It is optional, useful if you are a root user.
First, find out available shell list:
$ less /etc/shells
Output:
/bin/ash /bin/csh /bin/sh /usr/bin/es /bin/ksh /bin/tcsh /bin/sash /bin/zsh /bin/dash /usr/bin/screen /bin/bash /bin/rbash
Now change your shell name to /bin/tcsh:
$ chsh -s /bin/tcsh
Password:
When promoted for password, type your own password. If you just type chsh command, it will prompt for shell name interactively:
$ chsh
Output:
Password:
Changing the login shell for tv
Enter the new value, or press ENTER for the default
Login Shell [/bin/bash]: - 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop










{ 3 comments… read them below or add one }
I need to change my root password on daily basis. But the new password should be create from shell script. The input for the new password should be current date. Which means
let we say
the current date is x1, then the password should be x2. (but user should be able to calculate the new password)
is it possible to do it?
yes, try the cron deamon (crontab)
Hi.
Followed, but still see csh welcome in new tab of Terminal in xfce on FreeBSD.
/etc/passwd shows bash. What I’ve missed?