When a user logs in to the terminal using a user with the korn shell (ksh) the following messages occur:
Shopt: Not Found [No Such File Or Directory]
The following line was added on /etc/profile:
shopt -s histappend
/etc/profile is a configuration file which sets the global environment for all users. As per man page of shopt:
# man shopt shopt is part of BASH_BUILTINS -s Display readline key sequences bound to macros and the strings they output in such a way that they can be re-read. histappend If set, the history list is appended to the file named by the value of the HISTFILE variable when the shell exits, rather than overwriting the file
The issue is with KSH since shopt is part of BASH_BUILTINS. As per the /etc/passwd file the user shell is “ksh” and not “bash”:
# grep -i test /etc/passwd testuserX:x:54322:54323::/home/testuserX:/bin/bash test1:x:54323:112::/home/test1:/bin/ksh
47 TMOUT=14400 48 HOSTNAME=`/bin/hostname 2>/dev/null` 49 HISTSIZE=1000 50 HISTTIMEFORMAT='%F.%T ' 51 shopt -s histappend <=============================== Line was added
If we switch to user test we will find the following messages :
# su - test1 /etc/profile: shopt: not found [No such file or directory]
1. Edit the file /etc/profile and Comment line 51: shopt -s histappend:
# vi /etc/profile #shopt -s histappend
2. Reload the profile or exit from terminal and login again.
# source /etc/profile .
3. Login Again:
# su - test1 $ $ whoami test1
For example :
# cat /root/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi
User specific environment and startup programs:
PATH=$PATH:$HOME/bin shopt -s histappend export PATH export HISTTIMEFORMAT="%
Remove it from /etc/profile:
# cat /etc/profile| grep -i shopt #
Change the Shell from ksh to bash for user test1 .
1. Verify your currents Shell:
# chsh -l test1 /bin/sh /bin/bash /sbin/nologin /bin/dash /bin/tcsh /bin/csh /bin/ksh
2. Change it to bash
# chsh -s /bin/bash test1 Changing shell for test1. Shell changed.
# cat /etc/passwd|grep -i test1 test1:x:54323:112::/home/test1:/bin/bash #
3. Verify and test the new shell:
# su - test1 $ whoami test1 $