• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • How to change or customise login prompt for ksh shell in Linux (with examples)

    In my last article I had shown the steps to customise login prompt for bash shell

    How to customize and change color of the bash login prompt in Linux
    10 examples to customize or change the login prompt using PS1 variable of bash shell in Linux
    so now in this article I will share some examples which can be used to customise login prompt for 'ksh shell'

    By default in Red Hat Linux we only get a "$" prompt for ksh shell

    First let us create a user with default shell as 'ksh'
    # useradd  -s /bin/ksh deepak

    As you see we only get a dollar ($) prompt for ksh shell based user
    # su - deepak
    Last login: Thu Feb 15 09:27:42 IST 2018 on pts/0

    Display only hostname
    export PS1='[${HOSTNAME}]$ '


    Display username and hostname
    export PS1='[${USER}@${HOSTNAME}]$ '


    Display hostname with current working directory
    export PS1='[${HOSTNAME}:${PWD}]$ '


    Display user, hostname and current working directory
    export PS1='[${USER}@${HOSTNAME}:${PWD}]$ '


    To make the changes permanent, place your PS1 variable to .kshrc in the user home folder
    # .kshrc

    # Source global definitions
    if [ -f /etc/kshrc ]; then
            . /etc/kshrc

    # use emacs editing mode by default
    set -o emacs

    # User specific aliases and functions

    export PS1='${USER}\@${HOSTNAME}:${PWD}\> '

    I hope the article was useful.

    Deepak Prasad

    is a techie and an author who is still trying to survive in this IT generation with very little knowledge he has on Linux/Unix, VMware, SAN Storage, Automation, networking etc

    You can follow him on Facebook or Google+

    Do you also have something to share here?
    Join GoLinuxHub Team as an Author, Click here for more information
    How to change or customise login prompt for ksh shell in Linux (with examples) How to change or customise login prompt for ksh shell in Linux (with examples) Reviewed by Deepak Prasad on Thursday, February 15, 2018 Rating: 5

    No comments:

    Powered by Blogger.