Problém
Když se uživatel přihlásí k terminálu pomocí uživatele s korn shell (ksh), objeví se následující zprávy:
Shopt: Not Found [No Such File Or Directory]
Řešení
Následující řádek byl přidán na /etc/profile :
shopt -s histappend
Poznámka :
/etc/profile je konfigurační soubor, který nastavuje globální prostředí pro všechny uživatele. Podle manuálové stránky 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
Problém je s KSH, protože shopt je součástí BASH_BUILTINS . Podle /etc/passwd uživatelský shell je „ksh“ a ne „bash“:
# grep -i test /etc/passwd testuserX:x:54322:54323::/home/testuserX:/bin/bash test1:x:54323:112::/home/test1:/bin/ksh
==============
/etc/profil :
==============
47 TMOUT=14400 48 HOSTNAME=`/bin/hostname 2>/dev/null` 49 HISTSIZE=1000 50 HISTTIMEFORMAT='%F.%T ' 51 shopt -s histappend <=============================== Line was added
Pokud přepneme na uživatelský test, najdeme následující zprávy:
# su - test1 /etc/profile[277]: shopt: not found [No such file or directory]
Řešení 1
1. Upravte soubor /etc/profile a řádek komentáře 51:shopt -s histappend:
# vi /etc/profile #shopt -s histappend
2. Znovu načtěte profil nebo ukončete terminál a znovu se přihlaste.
# source /etc/profile .
3. Znovu se přihlaste:
# su - test1 $ $ whoami test1Poznámka :Pokud potřebujete použít tento řádek shopt -s histappend pro konkrétního uživatele, jako je root, doporučuje se použít tuto volbu na bash_profile pro uživatele root nebo jakéhokoli jiného uživatele, který používá bash jako výchozí.
Například:
# cat /root/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi
Prostředí specifické pro uživatele a spouštěcí programy:
PATH=$PATH:$HOME/bin shopt -s histappend export PATH export HISTTIMEFORMAT="%
Odeberte jej z /etc/profile:
# cat /etc/profile| grep -i shopt #
Řešení 2
Změňte Shell z ksh na bash pro uživatelský test1.
1. Ověřte své proudy Shell:
# chsh -l test1 /bin/sh /bin/bash /sbin/nologin /bin/dash /bin/tcsh /bin/csh /bin/ksh
2. Změňte jej na 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. Ověřte a otestujte nový shell:
# su - test1 $ whoami test1 $