• 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}]$ '

    [Ban17-adm01-a-br]$

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

    [deepak@Ban17-adm01-a-br]$





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

    [Ban17-adm01-a-br:/home/deepak]$

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

    [deepak@Ban17-adm01-a-br:/home/deepak]$

    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
    fi

    # 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

    Deepak Prasad is an anonymous 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?

    Become an author and be a part of our GoLinuxHub Team, 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.