How to install korn shell ksh in Linux

Korn shell or ksh is another Unix shell like bash,sh and csh. Korn shell was developed by David Korn at Bell Labs in the early 1980s and announced at USENIX on July 14, 1983. Many Unix based operating system like AIX,BSD etc. they already have ksh preinstalled. The AIX by default uses the ksh.

To install Korn shell in Linux .follow the given below steps

Step 1: Login with superuser or become root. Or directly login as root.

sudo su -

or

su -

Step 2: Install ksh package

In Debian and Ubuntu

apt-get install ksh

In CentOS or Red Hat

yum install ksh

Step 3: After installation find out the path of ksh


which ksh 

or

whereis ksh

Reference:

root@ubuntu:~# which ksh
/usr/bin/ksh
root@ubuntu:~# whereis ksh
ksh: /bin/ksh /usr/bin/ksh /usr/share/ksh /usr/share/man/man1/ksh.1.gz
root@ubuntu:~# 

Step 4 : Check /etc/shells for line called /bin/ksh

Note: If you are seeing line /bin/ksh93 that is also ksh but enhanced ksh.If you want to use enhanced ksh (/bin/ksh93) instead of writing /bin/ksh use /bin/ksh93 in below given steps

cat /etc/shells

Reference:-

root@ubuntu:~# cat /etc/shells 
# /etc/shells: valid login shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash
/usr/bin/tmux
/usr/bin/screen
/bin/ksh93
root@ubuntu:~# 

Step 5: Here /bin/ksh is not there then we will add this line in /etc/shells

echo "/bin/ksh" >> /etc/shells

Step 6: Now create a user,set password and change its default shell as ksh

useradd username

passwd username

chmod -s /bin/ksh username

Step 7: Now login with newly created user and hit below command to know what is default shell it has.

Command: echo $SHELL


su -l username

$ echo $SHELL

6 thoughts on “How to install korn shell ksh in Linux”

  1. Hi, I ran the command

    chmod -s /bin/ksh username

    but an error turned up.

    chmod: cannot access ‘username’: No such file or directory.

    What to do? T.T Thanks

    Reply
  2. [root@localhost ~]# sudo yum -y install ksh
    Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Setting up Install Process
    No package ksh available.
    Error: Nothing to do

    Reply
  3. yum install ksh — this command is not working in RHEL6

    whenever i am trying to using this command its saying ksh package is not available.please help

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.