IBM Support

Enable History keys and Backspace key in VIOS

Question & Answer


Question

How can I get history keys and the Backspace key working in VIOS?

Answer

Many users familiar with Unix environments, and even PC command line environments, are acquainted with using the Up and Down arrow keys to bring up previous commands, as well as using the Left and Right arrow keys to move the cursor within the current command line.

These functions are not enabled by default in the VIOS command line environment. Additionally, the Backspace key is not enabled by default, in many cases. Users are frequently interested in knowing the current user and current working directory. While this is not specifically needed in most VIOS cases, it is still useful to know.


Log in as padmin
Issue the following commands (in PuTTY, right-click pastes the clipboard contents):
    $ oem_setup_env

    # echo "export ENV=/home/padmin/.kshrc" >> /home/padmin/.profile

    # echo "export HOST=\"\$(/usr/bin/uname -n)\"\nif [ \"\`whoami\`\" = \"root\" ]; then\n  PS1=\"\`whoami\`@\$HOST:\\\$PWD # \"\nelse\n  PS1=\"\`whoami\`@\$HOST:\\\$PWD $ \"\nfi\n\nset -o emacs;alias -x __A=\"\$(echo '\\\\020')\"; alias -x __B=\"\$(echo '\\\\016')\"; alias -x __C=\"\$(echo '\\\\006')\"; alias -x __D=\"\$(echo '\\\\002')\"; alias -x __H=\"\$(echo '\\\\001')\"; alias -x __Y=\"\$(echo '\\\\005')\"\n" >> /home/padmin/.kshrc

    # exit

If you run tail -n 1 /home/padmin/.profile you should see:
    $ tail -n 1 /home/padmin/.profile
    export ENV=/home/padmin/.kshrc

If you run tail -n 9 /home/padmin/.kshrc you should see:
    $ tail -n 9 /home/padmin/.kshrc
    export HOST="$(/usr/bin/uname -n)"
    if [ "`whoami`" = "root" ]; then
      PS1="`whoami`@$HOST:\$PWD # "
    else
      PS1="`whoami`@$HOST:\$PWD $ "
    fi

    set -o emacs;alias -x __A="$(echo '\020')"; alias -x __B="$(echo '\016')"; alias -x __C="$(echo '\006')"; alias -x __D="$(echo '\002')"; alias -x __H="$(echo '\001')"; alias -x __Y="$(echo '\005')"
Now, if you log out and back in as padmin, you should have history keys (up/down arrows), line edit keys (right/left arrows), and backspace working properly. Additionally the command line prompt will show who you are logged in as, and what path you are in, like:
    padmin@vios:/home/padmin $

[{"Product":{"code":"SSPHKW","label":"PowerVM Virtual I\/O Server"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"--","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"Version Independent","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]

Document Information

Modified date:
19 February 2022

UID

nas8N1021067