El problema
Cuando un usuario inicia sesión en el terminal utilizando un usuario con el shell korn (ksh), aparecen los siguientes mensajes:
Shopt: Not Found [No Such File Or Directory]
La solución
Se agregó la siguiente línea en /etc/profile :
shopt -s histappend
Nota :
/etc/perfil es un archivo de configuración que establece el entorno global para todos los usuarios. Según la página man de 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
El problema es con KSH ya que shopt es parte de BASH_BUILTINS . Según el /etc/passwd el archivo shell del usuario es "ksh" y no "bash":
# grep -i test /etc/passwd testuserX:x:54322:54323::/home/testuserX:/bin/bash test1:x:54323:112::/home/test1:/bin/ksh
==============
/etc/perfil:
==============
47 TMOUT=14400 48 HOSTNAME=`/bin/hostname 2>/dev/null` 49 HISTSIZE=1000 50 HISTTIMEFORMAT='%F.%T ' 51 shopt -s histappend <=============================== Line was added
Si cambiamos a prueba de usuario encontraremos los siguientes mensajes:
# su - test1 /etc/profile[277]: shopt: not found [No such file or directory]
Solución 1
1. Edite el archivo /etc/profile y la línea de comentario 51:shopt -s histappend:
# vi /etc/profile #shopt -s histappend
2. Vuelva a cargar el perfil o salga de la terminal e inicie sesión nuevamente.
# source /etc/profile .
3. Iniciar sesión de nuevo:
# su - test1 $ $ whoami test1Nota :Si necesita usar esta línea shopt -s histappend para un usuario específico como root, se recomienda usar esa opción en bash_profile para el usuario root o cualquier otro usuario que use bash de forma predeterminada.
Por ejemplo:
# cat /root/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi
Entorno específico del usuario y programas de inicio:
PATH=$PATH:$HOME/bin shopt -s histappend export PATH export HISTTIMEFORMAT="%
Eliminarlo de /etc/profile:
# cat /etc/profile| grep -i shopt #
Solución 2
Cambie el Shell de ksh a bash para el usuario test1.
1. Verifica tu Shell actual:
# chsh -l test1 /bin/sh /bin/bash /sbin/nologin /bin/dash /bin/tcsh /bin/csh /bin/ksh
2. Cámbialo a 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. Verifique y pruebe el nuevo shell:
# su - test1 $ whoami test1 $