• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Shopt: Not Found [No Such File Or Directory]

by admin

The Problem

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 Solution

The following line was added on /etc/profile:

shopt -s histappend

Note:
/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

==============
/etc/profile :
==============

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[277]: shopt: not found [No such file or directory]

Solution 1

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
Note : If you need to use this line shopt -s histappend for specific user like root it is advised to use that option on the bash_profile for root user or or any other user that is using bash as default.

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
#

Solution 2

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
$

Filed Under: Linux

Some more articles you might also be interested in …

  1. rename Command Examples in Linux
  2. watch command examples to run a command repeatedly or monitor dynamically changeable files (like /proc/*)
  3. How to use wget to download file via proxy
  4. rig: command not found
  5. How to Enable/Disable CPUs (Limiting CPU count) in CentOS / RHEL
  6. How to disable NetworkManager on CentOS / RHEL 7
  7. Difference between the Java heap and native C heap
  8. CentOS / RHEL : How to delete LUKS encrypted device
  9. blackfire: A command-line profiling tool for PHP (Command Examples)
  10. How To Create Virtual Data Optimizer(VD0) in CentOS/RHEL 7 and 8

You May Also Like

Primary Sidebar

Recent Posts

  • chars: Display names and codes for various ASCII and Unicode characters and code points
  • chafa: Image printing in the terminal
  • cf: Command-line tool to manage apps and services on Cloud Foundry
  • certutil: Manage keys and certificates in both NSS databases and other NSS tokens

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright