Difference between revisions of "Ksh"

From ArchWiki
Jump to: navigation, search
m (Installation)
m (Corrected file path (/bin/mksh, not /usr/bin/mksh))
 
(12 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
[[Category:Command shells]]
 
[[Category:Command shells]]
 +
[[ja:Ksh]]
 
Korn Shell (ksh) is a standard/restricted command and programming language developed by AT&T.
 
Korn Shell (ksh) is a standard/restricted command and programming language developed by AT&T.
==Installation==
 
The version from AT&T can be found on [https://aur.archlinux.org/packages.php?ID=13772 AUR].
 
  
The [http://www.mirbsd.org/mksh.htm MirBSD™ Korn Shell] is another free implementation of the Korn Shell. It can be found in the community repo. Install with pacman:
+
== Installation ==
# pacman -S mksh
+
  
The Public Domain Korn Shell is in the [https://aur.archlinux.org/packages/pdksh/ AUR].
+
First, [[install]] an implementation from the [[official repositories]]:
  
==Making Ksh your default login shell==
+
* {{App|MirBSD™ Korn Shell|Enhanced version of the public domain ksh.|https://www.mirbsd.org/mksh.htm|{{Pkg|mksh}}}}
  
Arch Linux init scripts use Bash. After the boot process is complete, the default login shell is user-specified. The chsh command can be used to change a user's default login shell without root access if the shell is listed in {{ic|/etc/shells}}. (If Ksh was installed using pacman, it should already have an entry in {{ic|/etc/shells}}).
+
More implementations are provided in the [[Arch User Repository]]:
 +
* {{App|loksh|A Linux port of OpenBSD's ksh|https://github.com/dimkr/loksh|{{AUR|loksh}} }}
 +
* {{App|Public Domain Korn Shell|Clone of the AT&T Korn shell. At the moment, it has most of the ksh88 features, not much of the ksh93 features, and a number of its own features.|http://www.cs.mun.ca/~michael/pdksh/|{{AUR|pdksh}}}}
 +
* {{App|[[Wikipedia:Korn_shell|AT&T Korn shell]]|Official AT&T version.|http://www.kornshell.com/|{{AUR|ksh}}}}
 +
* {{App|OpenBSDs Korn Shell|Porting of the OpenBSD version of ksh to GNU/Linux.|http://www.connochaetos.org/oksh/|{{AUR|oksh}}}}
 +
* {{App|obase|OpenBSD userland ported to Linux, statically linked.|https://github.com/chneukirchen/obase|{{AUR|obase-git}}{{Broken package link|{{aur-mirror|obase-git}}}}}}
 +
* {{App|obase musl|OpenBSD userland ported to Linux, statically linked to musl libc.|https://github.com/chneukirchen/obase|{{AUR|obase-musl-git}}{{Broken package link|{{aur-mirror|obase-musl-git}}}}}}
  
Grab the full path for Ksh using {{ic|/usr/bin/which}}:
+
== Making m/ksh your default login shell ==
 
+
$ which ksh
+
 
+
Which will probably output:
+
 
+
/bin/ksh
+
  
 
Change the default shell for the current user:
 
Change the default shell for the current user:
  
  $ chsh -s /bin/ksh
+
  $ chsh -s /bin/mksh
 
+
'''Alternative as root, using usermod'''
+
 
+
Change the default shell using usermod:
+
 
+
# usermod -s /bin/ksh username
+
 
+
{{Note| The user needs to logout and log back in, to start using Ksh as their default shell.}}
+
 
+
After logging back in, verify that Ksh is the default shell with:
+
 
+
$ echo $SHELL
+
 
+
==Uninstallation==
+
You must first change your default shell back to Bash before removing the Ksh package.
+
  
Change the default shell for the current user to bash:
+
== Uninstallation ==
  
$ chsh -s /bin/bash
+
Change the default shell before removing the {{Pkg|mksh}} package.
  
'''Alternative as root, using usermod'''
+
{{Warning|Failure to follow the below procedure may result in users no longer having access to a working shell.}}
  
Change the default shell using usermod:
+
Run following command:
  
  # usermod -s /bin/bash username
+
  $ chsh -s /bin/bash ''user''
  
Now you can safely remove the Ksh package:
+
Use it for every user with m/ksh set as their login shell (including root if needed). When completed, the {{Pkg|mksh}} package can be removed.
+
# pacman -R pdksh
+
  
{{Warning| Failure to follow the above will result in all kinds of problems.}}
+
Alternatively, change the default shell back to Bash by editing {{ic|/etc/passwd}} as root.
  
If you did not follow the above, you can still change the default shell back to Bash by editing {{ic|/etc/passwd}} as root.  
+
{{Warning|It is strongly recommended to use {{ic|vipw}} when editing {{ic|/etc/passwd}} as it helps prevent invalid entries and/or syntax errors.}}
  
For example:
+
For example, change the following:
+
from:
+
username:x:1000:1000:Full Name,,,:/home/username:/bin/ksh
+
to:
+
username:x:1000:1000:Full Name,,,:/home/username:/bin/bash
+
  
==External Resources==
+
''username'':x:1000:1000:''Full Name'',,,:/home/''username'':/bin/mksh
[http://www.cs.mun.ca/~michael/pdksh/ pdksh official page]
+
  
[http://en.wikipedia.org/wiki/Korn_shell Korn Shell at Wikipedia]
+
To this:
  
[http://linux.die.net/man/1/pdksh pdksh man page at die.net]
+
''username'':x:1000:1000:''Full Name'',,,:/home/''username'':/bin/bash
  
[http://kornshell.com/ Home Page For The KornShell Command And Programming Language]
+
== See Also ==
  
[http://www.openbsd.org/cgi-bin/man.cgi?query=ksh&sektion=1 pdksh man page at OpenBSD]
+
*[https://www.mirbsd.org/mksh.htm mksh - The MirBSD Korn Shell]
 +
*[http://www.cs.mun.ca/~michael/pdksh/ pdksh - the Public Domain Korn Shell]

Latest revision as of 14:12, 29 March 2016

Korn Shell (ksh) is a standard/restricted command and programming language developed by AT&T.

Installation

First, install an implementation from the official repositories:

  • MirBSD™ Korn Shell — Enhanced version of the public domain ksh.
https://www.mirbsd.org/mksh.htm || mksh

More implementations are provided in the Arch User Repository:

  • loksh — A Linux port of OpenBSD's ksh
https://github.com/dimkr/loksh || lokshAUR
  • Public Domain Korn Shell — Clone of the AT&T Korn shell. At the moment, it has most of the ksh88 features, not much of the ksh93 features, and a number of its own features.
http://www.cs.mun.ca/~michael/pdksh/ || pdkshAUR
http://www.kornshell.com/ || kshAUR
  • OpenBSDs Korn Shell — Porting of the OpenBSD version of ksh to GNU/Linux.
http://www.connochaetos.org/oksh/ || okshAUR
  • obase — OpenBSD userland ported to Linux, statically linked.
https://github.com/chneukirchen/obase || obase-gitAUR[broken link: archived in aur-mirror]
  • obase musl — OpenBSD userland ported to Linux, statically linked to musl libc.
https://github.com/chneukirchen/obase || obase-musl-gitAUR[broken link: archived in aur-mirror]

Making m/ksh your default login shell

Change the default shell for the current user:

$ chsh -s /bin/mksh

Uninstallation

Change the default shell before removing the mksh package.

Warning: Failure to follow the below procedure may result in users no longer having access to a working shell.

Run following command:

$ chsh -s /bin/bash user

Use it for every user with m/ksh set as their login shell (including root if needed). When completed, the mksh package can be removed.

Alternatively, change the default shell back to Bash by editing /etc/passwd as root.

Warning: It is strongly recommended to use vipw when editing /etc/passwd as it helps prevent invalid entries and/or syntax errors.

For example, change the following:

username:x:1000:1000:Full Name,,,:/home/username:/bin/mksh

To this:

username:x:1000:1000:Full Name,,,:/home/username:/bin/bash

See Also