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
The correct command for changing a shell in Ubuntu/Debian is
chsh -s /bin/ksh username
Example:
chsh -s /bin/ksh Nathalie
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
Hi Nathalie,
You have to replace the username with actual user name which exist in system.
For eg.
Regards
Sharad
[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
Seems you Red Hat OS in system is not subscribed. Register your system to Red Hat Subscription Management.
Reference : https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/registering-cmd.html
Regards
Sharad
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