Linux / UNIX: Change Bash To KSH Shell

How do I change my current login shell from bash to ksh under Linux or UNIX or Apple OS X operating systems?

You need to use the chsh command to change the user login shell. This determines the name of the users initial login command. A normal user may only change the login shell for her own account, the superuser (root) may change the login shell for any account. /etc/passwd file stores your user account information including login shell. /etc/shells files list all valid login shells. So first make sure ksh is installed and valid login shell:
$ grep ksh /etc/shells
Sample outputs:

ADVERTISEMENTS

/usr/bin/ksh
/bin/ksh
/bin/pdksh

To change shell to ksh, enter:
$ chsh -s /bin/ksh
You need to enter your own login password to make shell change. Now, logout and login back again to use ksh as the default shell. You can verify your shell typing the following command:
$ grep "^username" /etc/passwd
$ grep "^vivek" /etc/passwd

Sample outputs:

vivek:x:6012:6013:Vivek Gite,,,:/home/vivek:/bin/ksh

A Note About Other User

The superuser (root) may change the login shell for any account using any one of the following syntax:
$ sudo chsh -s /bin/ksh username
OR
$ su -
# chsh -s /bin/ksh username

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
2 comments… add one
  • Francis Feb 25, 2011 @ 1:22

    If avaiable, try ‘chsh’ or edit /etc/passwd (root equivalent access required) in *nix.

    For os x (assuming 10.6): Systems Preferences, [System] Accounts, make sure it’s not locked (lower left) or authenticate to unlock the ‘My Account’ list, right click on the account and select ‘Advanced Options…’

  • Julien Jun 15, 2017 @ 7:55

    You can just type /bin/sh or /bin/ksh to change your local environment

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.